• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • kdeui
  • findreplace
kfind.h
Go to the documentation of this file.
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 <kdialog.h>
25#include <QtCore/QRect>
26
101class KDEUI_EXPORT KFind :
102 public QObject
103{
104 Q_OBJECT
105
106public:
107
109 enum Options
110 {
111 WholeWordsOnly = 1,
112 FromCursor = 2,
113 SelectedText = 4,
114 CaseSensitive = 8,
115 FindBackwards = 16,
116 RegularExpression = 32,
117 FindIncremental = 64,
118 // Note that KReplaceDialog uses 256 and 512
119 // User extensions can use boolean options above this value.
120 MinimumUserOption = 65536
121 };
122 Q_DECLARE_FLAGS(SearchOptions, Options)
123
124
128 KFind(const QString &pattern, long options, QWidget *parent);
129
136 KFind(const QString &pattern, long options, QWidget *parent, QWidget* findDialog);
137 virtual ~KFind();
138
139 enum Result { NoMatch, Match };
140
147 bool needData() const;
148
158 void setData( const QString& data, int startPos = -1 );
159
171 void setData( int id, const QString& data, int startPos = -1 );
172
178 Result find();
179
189 long options() const;
190
197 virtual void setOptions( long options );
198
202 QString pattern() const;
203
207 void setPattern( const QString& pattern );
208
215 int numMatches() const;
216
223 virtual void resetCounts();
224
235 virtual bool validateMatch( const QString & text,
236 int index,
237 int matchedlength );
238
252 virtual bool shouldRestart( bool forceAsking = false, bool showNumMatches = true ) const;
253
268 static int find( const QString &text, const QString &pattern, int index, long options, int *matchedlength );
269
270 static int find( const QString &text, const QRegExp &pattern, int index, long options, int *matchedlength );
271
276 virtual void displayFinalDialog() const;
277
285 KDialog* findNextDialog( bool create = false );
286
295 void closeFindNextDialog();
296
303 int index() const;
304
305Q_SIGNALS:
306
320 void highlight(const QString &text, int matchingIndex, int matchedLength);
321
335 void highlight(int id, int matchingIndex, int matchedLength);
336
337 // ## TODO docu
338 // findprevious will also emit findNext, after temporarily switching the value
339 // of FindBackwards
340 void findNext();
341
347 void optionsChanged();
348
355 void dialogClosed();
356
357protected:
358
359 QWidget* parentWidget() const;
360 QWidget* dialogsParent() const;
361
362private:
363 friend class KReplace;
364 friend class KReplacePrivate;
365
366 struct Private;
367 Private* const d;
368
369 Q_PRIVATE_SLOT( d, void _k_slotFindNext() )
370 Q_PRIVATE_SLOT( d, void _k_slotDialogClosed() )
371};
372
373Q_DECLARE_OPERATORS_FOR_FLAGS(KFind::SearchOptions)
374
375#endif
KDialog
A dialog base class with standard buttons and predefined layouts.
Definition kdialog.h:129
KFind
A generic implementation of the "find" function.
Definition kfind.h:103
KFind::dialogsParent
QWidget * dialogsParent() const
Definition kfind.cpp:715
KFind::KReplace
friend class KReplace
Definition kfind.h:363
KFind::KReplacePrivate
friend class KReplacePrivate
Definition kfind.h:364
KFind::Result
Result
Definition kfind.h:139
KFind::NoMatch
@ NoMatch
Definition kfind.h:139
KFind::Match
@ Match
Definition kfind.h:139
KFind::parentWidget
QWidget * parentWidget() const
Definition kfind.cpp:710
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::dialogClosed
void dialogClosed()
Emitted when the 'find next' dialog is being closed.
KFind::optionsChanged
void optionsChanged()
Emitted when the options have changed.
KFind::findNext
void findNext()
KFind::KFind
KFind(const QString &pattern, long options, QWidget *parent)
Only use this constructor if you don't use KFindDialog, or if you use it as a modal dialog.
Definition kfind.cpp:61
KFind::Options
Options
the options
Definition kfind.h:110
KFind::CaseSensitive
@ CaseSensitive
Consider case when matching.
Definition kfind.h:114
KFind::SelectedText
@ SelectedText
Only search selected area.
Definition kfind.h:113
KFind::RegularExpression
@ RegularExpression
Interpret the pattern as a regular expression.
Definition kfind.h:116
KFind::MinimumUserOption
@ MinimumUserOption
user options start with this bit
Definition kfind.h:120
KFind::FromCursor
@ FromCursor
Start from current cursor position.
Definition kfind.h:112
KFind::FindBackwards
@ FindBackwards
Go backwards.
Definition kfind.h:115
KFind::FindIncremental
@ FindIncremental
Find incremental.
Definition kfind.h:117
KFind::WholeWordsOnly
@ WholeWordsOnly
Match whole words only.
Definition kfind.h:111
KFind::highlight
void highlight(const QString &text, int matchingIndex, int matchedLength)
Connect to this signal to implement highlighting of found text during the find operation.
QObject
QWidget
kdialog.h
Result
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 17 2025 00:00:00 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal