• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeutils
 

tdeutils

  • tdeutils
kfind.h
1 /*
2  Copyright (C) 2001, S.R.Haque <srhaque@iee.org>.
3  Copyright (C) 2002, David Faure <david@mandrakesoft.com>
4  This file is part of the KDE project
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2, as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef KFIND_H
22 #define KFIND_H
23 
24 #include <kdialogbase.h>
25 #include <tqrect.h>
26 
103 class TDEUTILS_EXPORT KFind :
104  public TQObject
105 {
106  TQ_OBJECT
107 
108 
109 public:
110 
118  KFind(const TQString &pattern, long options, TQWidget *parent);
119 
130  KFind(const TQString &pattern, long options, TQWidget *parent, TQWidget* findDialog);
131 
135  virtual ~KFind();
136 
140  enum Result {
141  NoMatch,
142  Match
143  };
144 
151  bool needData() const;
152 
162  void setData( const TQString& data, int startPos = -1 );
163 
177  void setData( int id, const TQString& data, int startPos = -1 );
178 
185  Result find();
186 
196  long options() const { return m_options; }
197 
204  virtual void setOptions( long options );
205 
209  TQString pattern() const { return m_pattern; }
210 
215  void setPattern( const TQString& pattern );
216 
224  int numMatches() const { return m_matches; }
225 
232  virtual void resetCounts() { m_matches = 0; }
233 
244  virtual bool validateMatch( const TQString & text, int index, int matchedlength ) {
245  Q_UNUSED(text); Q_UNUSED(index); Q_UNUSED(matchedlength); return true; }
246 
262  virtual bool shouldRestart( bool forceAsking = false, bool showNumMatches = true ) const;
263 
278  static int find( const TQString &text, const TQString &pattern, int index, long options, int *matchedlength );
279 
293  static int find( const TQString &text, const TQRegExp &pattern, int index, long options, int *matchedlength );
294 
299  virtual void displayFinalDialog() const;
300 
309  KDialogBase* findNextDialog( bool create = false );
310 
319  void closeFindNextDialog();
320 
328  int index() const;
329 
330 signals:
331 
348  void highlight(const TQString &text, int matchingIndex, int matchedLength);
349 
368  void highlight(int id, int matchingIndex, int matchedLength);
369 
370  // ## TODO docu
371  // findprevious will also emit findNext, after temporarily switching the value
372  // of FindBackwards
373  void findNext();
374 
380  void optionsChanged();
381 
388  void dialogClosed();
389 
390 protected:
391 
392  TQWidget* parentWidget() const { return (TQWidget *)parent(); }
393  TQWidget* dialogsParent() const;
394 
395 protected slots:
396 
397  void slotFindNext();
398  void slotDialogClosed();
399 
400 private:
401  void init( const TQString& pattern );
402  void startNewIncrementalSearch();
403 
404  static bool isInWord( TQChar ch );
405  static bool isWholeWords( const TQString &text, int starts, int matchedLength );
406 
407  friend class KReplace;
408 
409 
410  TQString m_pattern;
411  TQRegExp *m_regExp;
412  KDialogBase* m_dialog;
413  long m_options;
414  unsigned m_matches;
415 
416  TQString m_text; // the text set by setData
417  int m_index;
418  int m_matchedLength;
419  bool m_dialogClosed;
420  bool m_lastResult;
421 
422  // Binary compatible extensibility.
423  struct Private;
424  Private *d;
425 };
426 
427 #endif
KDialogBase
KFind
A generic implementation of the "find" function.
Definition: kfind.h:105
KFind::validateMatch
virtual bool validateMatch(const TQString &text, int index, int matchedlength)
Virtual method, which allows applications to add extra checks for validating a candidate match.
Definition: kfind.h:244
KFind::Result
Result
Result enum.
Definition: kfind.h:140
KFind::NoMatch
@ NoMatch
No match was found.
Definition: kfind.h:141
KFind::numMatches
int numMatches() const
Return the number of matches found (i.e.
Definition: kfind.h:224
KFind::highlight
void highlight(int id, int matchingIndex, int matchedLength)
Connect to this signal to implement highlighting of found text during the find operation.
KFind::pattern
TQString pattern() const
Definition: kfind.h:209
KFind::dialogClosed
void dialogClosed()
Emitted when the 'find next' dialog is being closed.
KFind::optionsChanged
void optionsChanged()
Emitted when the options have changed.
KFind::highlight
void highlight(const TQString &text, int matchingIndex, int matchedLength)
Connect to this signal to implement highlighting of found text during the find operation.
KFind::options
long options() const
Return the current options.
Definition: kfind.h:196
KFind::resetCounts
virtual void resetCounts()
Call this to reset the numMatches count (and the numReplacements count for a KReplace).
Definition: kfind.h:232
KReplace
A generic implementation of the "replace" function.
Definition: kreplace.h:99

tdeutils

Skip menu "tdeutils"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeutils

Skip menu "tdeutils"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeutils by doxygen 1.9.1
This website is maintained by Timothy Pearson.