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
00097 class KFind :
00098 public QObject
00099 {
00100 Q_OBJECT
00101
00102 public:
00103
00104 KFind(const QString &pattern, long options, QWidget *parent);
00105 virtual ~KFind();
00106
00107 enum Result { NoMatch, Match };
00108
00115 bool needData() const;
00125 void setData( const QString& data, int startPos = -1 );
00126
00132 Result find();
00133
00142 long options() const { return m_options; }
00143
00148 virtual void setOptions( long options );
00149
00156 int numMatches() const { return m_matches; }
00157
00164 virtual void resetCounts() { m_matches = 0; }
00165
00176 virtual bool validateMatch( const QString &, int , int ) { return true; }
00177
00191 virtual bool shouldRestart( bool forceAsking = false, bool showNumMatches = true ) const;
00192
00206 static int find( const QString &text, const QString &pattern, int index, long options, int *matchedlength );
00207 static int find( const QString &text, const QRegExp &pattern, int index, long options, int *matchedlength );
00208
00213 virtual void displayFinalDialog() const;
00214
00222 KDialogBase* findNextDialog( bool create = false );
00223
00229 void closeFindNextDialog();
00230
00231 signals:
00232
00237 void highlight(const QString &text, int matchingIndex, int matchedLength);
00238
00239
00240
00241
00242 void findNext();
00243
00249 void optionsChanged();
00250
00257 void dialogClosed();
00258
00259 protected:
00263 KFind(const QString &pattern, const QString &replacement, long options, QWidget *parent);
00264
00265 QWidget* parentWidget() const { return (QWidget *)parent(); }
00266
00267 protected slots:
00268
00269 void slotFindNext();
00270 void slotDialogClosed();
00271
00272 private:
00273 void init( const QString& pattern );
00274
00275 static bool isInWord( QChar ch );
00276 static bool isWholeWords( const QString &text, int starts, int matchedLength );
00277
00278 friend class KReplace;
00279
00280
00281 QString m_pattern;
00282 QRegExp *m_regExp;
00283 KDialogBase* m_dialog;
00284 long m_options;
00285 unsigned m_matches;
00286
00287 QString m_text;
00288 int m_index;
00289 int m_matchedLength;
00290 bool m_dialogClosed;
00291 bool m_lastResult;
00292
00293
00294 class KFindPrivate;
00295 KFindPrivate *d;
00296 };
00297
00298 #endif
This file is part of the documentation for kdelibs Version 3.1.4.