koFind.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KOFIND_H
00022 #define KOFIND_H
00023
00024 #include <kdialogbase.h>
00025
00026 class KHistoryCombo;
00027 class QCheckBox;
00028 class QGroupBox;
00029 class QLabel;
00030 class QPopupMenu;
00031 class QPushButton;
00032 class QRect;
00033 class QGridLayout;
00034
00063 class KoFindDialog:
00064 public KDialogBase
00065 {
00066 Q_OBJECT
00067
00068 public:
00069
00070
00071
00072 typedef enum
00073 {
00074 WholeWordsOnly = 1,
00075 FromCursor = 2,
00076 SelectedText = 4,
00077 CaseSensitive = 8,
00078 FindBackwards = 16,
00079 RegularExpression = 32,
00080
00081 MinimumUserOption = 65536
00082 } Options;
00083
00093 KoFindDialog( QWidget *parent = 0, const char *name = 0, long options = 0,
00094 const QStringList &findStrings = QStringList(), bool hasSelection = true );
00095
00099 virtual ~KoFindDialog();
00100
00109 void setFindHistory( const QStringList &strings );
00110
00116 QStringList findHistory() const;
00117
00124 void setHasSelection( bool hasSelection );
00125
00131 void setOptions( long options );
00132
00139 long options() const;
00140
00144 QString pattern() const;
00145
00152 QWidget *findExtension();
00153
00154 signals:
00155
00160 void okClicked();
00161
00162 protected slots:
00163
00164 void slotOk();
00165 void slotSelectedTextToggled(bool);
00166 void showPatterns();
00167 void showPlaceholders();
00168 void textSearchChanged( const QString &);
00169
00170 public:
00171 KHistoryCombo *m_find;
00172 KHistoryCombo *m_replace;
00173
00174 private:
00175 QGroupBox *m_findGrp;
00176 QLabel *m_findLabel;
00177 QCheckBox *m_regExp;
00178 QPushButton *m_regExpItem;
00179 QGridLayout *m_findLayout;
00180 QWidget *m_findExtension;
00181
00182 QGroupBox *m_optionGrp;
00183 QCheckBox *m_wholeWordsOnly;
00184 QCheckBox *m_fromCursor;
00185 QCheckBox *m_selectedText;
00186 QCheckBox *m_caseSensitive;
00187 QCheckBox *m_findBackwards;
00188
00189 QPopupMenu *m_patterns;
00190
00191
00192
00193
00194 friend class KoReplaceDialog;
00195
00204 KoFindDialog( QWidget *parent, const char *name, bool forReplace );
00205 void init( bool forReplace, const QStringList &findStrings, bool hasSelection );
00206
00207 QGroupBox *m_replaceGrp;
00208 QLabel *m_replaceLabel;
00209 QCheckBox* m_backRef;
00210 QPushButton* m_backRefItem;
00211 QGridLayout *m_replaceLayout;
00212 QWidget *m_replaceExtension;
00213
00214 QCheckBox* m_promptOnReplace;
00215
00216 QPopupMenu *m_placeholders;
00217
00218
00219 class KoFindDialogPrivate;
00220 KoFindDialogPrivate *d;
00221 };
00222
00260 class KoFind :
00261 public KDialogBase
00262 {
00263 Q_OBJECT
00264
00265 public:
00266
00267
00268 KoFind(const QString &pattern, long options, QWidget *parent = 0);
00269 ~KoFind();
00270
00280 bool find(const QString &text, const QRect &expose);
00281
00282 virtual bool validateMatch( const QString &, int , int ) { return true; }
00283
00298 static int find( const QString &text, const QString &pattern, int index, long options, int *matchedlength );
00299 static int find( const QString &text, const QRegExp &pattern, int index, long options, int *matchedlength );
00300
00305 void abort();
00306
00307 signals:
00308
00309
00310
00311 void highlight(const QString &text, int matchingIndex, int matchedLength, const QRect &expose);
00312
00313 private:
00314
00315 QString m_pattern;
00316 QRegExp *m_regExp;
00317 long m_options;
00318 QWidget *m_parent;
00319 unsigned m_matches;
00320 QString m_text;
00321 int m_index;
00322 QRect m_expose;
00323 int m_matchedLength;
00324 bool m_cancelled;
00325
00326 static bool isInWord( QChar ch );
00327 static bool isWholeWords( const QString &text, int starts, int matchedLength );
00328
00329
00330 class KoFindPrivate;
00331 KoFindPrivate *d;
00332
00333 private slots:
00334
00335 virtual void slotUser1();
00336 virtual void slotClose();
00337 };
00338
00339 #endif
This file is part of the documentation for KDevelop Version 3.1.2.