kfind.h
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #ifndef KFIND_H
00022 #define KFIND_H
00023 
00024 #include <kdialogbase.h>
00025 #include <qrect.h>
00026 
00100 class KFind :
00101     public QObject
00102 {
00103     Q_OBJECT
00104 
00105 public:
00106 
00111     KFind(const QString &pattern, long options, QWidget *parent);
00112 
00119     KFind(const QString &pattern, long options, QWidget *parent, QWidget* findDialog);
00120     virtual ~KFind();
00121 
00122     enum Result { NoMatch, Match };
00123 
00130     bool needData() const;
00140     void setData( const QString& data, int startPos = -1 );
00141 
00147     Result find();
00148 
00157     long options() const { return m_options; }
00158 
00163     virtual void setOptions( long options );
00164 
00168     QString pattern() const { return m_pattern; }
00169 
00173     void setPattern( const QString& pattern );
00174 
00181     int numMatches() const { return m_matches; }
00182 
00189     virtual void resetCounts() { m_matches = 0; }
00190 
00201     virtual bool validateMatch( const QString & text, int index, int matchedlength ) {
00202         Q_UNUSED(text); Q_UNUSED(index); Q_UNUSED(matchedlength); return true; }
00203 
00217     virtual bool shouldRestart( bool forceAsking = false, bool showNumMatches = true ) const;
00218 
00233     static int find( const QString &text, const QString &pattern, int index, long options, int *matchedlength );
00234 
00235     static int find( const QString &text, const QRegExp &pattern, int index, long options, int *matchedlength );
00236 
00241     virtual void displayFinalDialog() const;
00242 
00250     KDialogBase* findNextDialog( bool create = false );
00251 
00260     void closeFindNextDialog();
00261 
00269     int index() const;
00270 
00271 signals:
00272 
00277     void highlight(const QString &text, int matchingIndex, int matchedLength);
00278 
00279     
00280     
00281     
00282     void findNext();
00283 
00289     void optionsChanged();
00290 
00297     void dialogClosed();
00298 
00299 protected:
00300 
00301     QWidget* parentWidget() const { return (QWidget *)parent(); }
00302     QWidget* dialogsParent() const;
00303 
00304 protected slots:
00305 
00306     void slotFindNext();
00307     void slotDialogClosed();
00308 
00309 private:
00310     void init( const QString& pattern );
00311 
00312     static bool isInWord( QChar ch );
00313     static bool isWholeWords( const QString &text, int starts, int matchedLength );
00314 
00315     friend class KReplace;
00316 
00317 
00318     QString m_pattern;
00319     QRegExp *m_regExp;
00320     KDialogBase* m_dialog;
00321     long m_options;
00322     unsigned m_matches;
00323 
00324     QString m_text; 
00325     int m_index;
00326     int m_matchedLength;
00327     bool m_dialogClosed;
00328     bool m_lastResult;
00329 
00330     
00331     class Private;
00332     Private *d;
00333 };
00334 
00335 #endif
 
This file is part of the documentation for kutils Library Version 3.2.0.