KDEUI
kfind.h
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2001, S.R.Haque <srhaque@iee.org>. 00003 Copyright (C) 2002, David Faure <david@mandrakesoft.com> 00004 This file is part of the KDE project 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2, as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KFIND_H 00022 #define KFIND_H 00023 00024 #include <kdialog.h> 00025 #include <QtCore/QRect> 00026 00101 class KDEUI_EXPORT KFind : 00102 public QObject 00103 { 00104 Q_OBJECT 00105 00106 public: 00107 00109 enum Options 00110 { 00111 WholeWordsOnly = 1, 00112 FromCursor = 2, 00113 SelectedText = 4, 00114 CaseSensitive = 8, 00115 FindBackwards = 16, 00116 RegularExpression = 32, 00117 FindIncremental = 64, 00118 // Note that KReplaceDialog uses 256 and 512 00119 // User extensions can use boolean options above this value. 00120 MinimumUserOption = 65536 00121 }; 00122 Q_DECLARE_FLAGS(SearchOptions, Options) 00123 00124 00128 KFind(const QString &pattern, long options, QWidget *parent); 00129 00136 KFind(const QString &pattern, long options, QWidget *parent, QWidget* findDialog); 00137 virtual ~KFind(); 00138 00139 enum Result { NoMatch, Match }; 00140 00147 bool needData() const; 00148 00158 void setData( const QString& data, int startPos = -1 ); 00159 00171 void setData( int id, const QString& data, int startPos = -1 ); 00172 00178 Result find(); 00179 00189 long options() const; 00190 00197 virtual void setOptions( long options ); 00198 00202 QString pattern() const; 00203 00207 void setPattern( const QString& pattern ); 00208 00215 int numMatches() const; 00216 00223 virtual void resetCounts(); 00224 00235 virtual bool validateMatch( const QString & text, 00236 int index, 00237 int matchedlength ); 00238 00252 virtual bool shouldRestart( bool forceAsking = false, bool showNumMatches = true ) const; 00253 00268 static int find( const QString &text, const QString &pattern, int index, long options, int *matchedlength ); 00269 00270 static int find( const QString &text, const QRegExp &pattern, int index, long options, int *matchedlength ); 00271 00276 virtual void displayFinalDialog() const; 00277 00285 KDialog* findNextDialog( bool create = false ); 00286 00295 void closeFindNextDialog(); 00296 00303 int index() const; 00304 00305 Q_SIGNALS: 00306 00320 void highlight(const QString &text, int matchingIndex, int matchedLength); 00321 00335 void highlight(int id, int matchingIndex, int matchedLength); 00336 00337 // ## TODO docu 00338 // findprevious will also emit findNext, after temporarily switching the value 00339 // of FindBackwards 00340 void findNext(); 00341 00347 void optionsChanged(); 00348 00355 void dialogClosed(); 00356 00357 protected: 00358 00359 QWidget* parentWidget() const; 00360 QWidget* dialogsParent() const; 00361 00362 private: 00363 friend class KReplace; 00364 friend class KReplacePrivate; 00365 00366 struct Private; 00367 Private* const d; 00368 00369 Q_PRIVATE_SLOT( d, void _k_slotFindNext() ) 00370 Q_PRIVATE_SLOT( d, void _k_slotDialogClosed() ) 00371 }; 00372 00373 Q_DECLARE_OPERATORS_FOR_FLAGS(KFind::SearchOptions) 00374 00375 #endif
KDE 4.6 API Reference