kutils Library API Documentation

kfind.h

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., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 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 // ## TODO docu 00280 // findprevious will also emit findNext, after temporarily switching the value 00281 // of FindBackwards 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; // the text set by setData 00325 int m_index; 00326 int m_matchedLength; 00327 bool m_dialogClosed; 00328 bool m_lastResult; 00329 00330 // Binary compatible extensibility. 00331 class Private; 00332 Private *d; 00333 }; 00334 00335 #endif
KDE Logo
This file is part of the documentation for kutils Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 16 17:22:59 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003