kfind.h
/*
Copyright (C) 2001, S.R.Haque <srhaque@iee.org>.
Copyright (C) 2002, David Faure <david@mandrakesoft.com>
This file is part of the KDE project
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2, as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KFIND_H
#define KFIND_H
#include <kdialogbase.h>
#include <qrect.h>
class KUTILS_EXPORT KFind :
public QObject
{
Q_OBJECT
public:
KFind(const QString &pattern, long options, QWidget *parent);
KFind(const QString &pattern, long options, QWidget *parent, QWidget* findDialog);
virtual ~KFind();
enum Result {
NoMatch,
Match
};
bool needData() const;
void setData( const QString& data, int startPos = -1 );
void setData( int id, const QString& data, int startPos = -1 );
Result find();
long options() const { return m_options; }
virtual void setOptions( long options );
QString pattern() const { return m_pattern; }
void setPattern( const QString& pattern );
int numMatches() const { return m_matches; }
virtual void resetCounts() { m_matches = 0; }
virtual bool validateMatch( const QString & text, int index, int matchedlength ) {
Q_UNUSED(text); Q_UNUSED(index); Q_UNUSED(matchedlength); return true; }
virtual bool shouldRestart( bool forceAsking = false, bool showNumMatches = true ) const;
static int find( const QString &text, const QString &pattern, int index, long options, int *matchedlength );
static int find( const QString &text, const QRegExp &pattern, int index, long options, int *matchedlength );
virtual void displayFinalDialog() const;
KDialogBase* findNextDialog( bool create = false );
void closeFindNextDialog();
int index() const;
signals:
void highlight(const QString &text, int matchingIndex, int matchedLength);
void highlight(int id, int matchingIndex, int matchedLength);
// ## TODO docu
// findprevious will also emit findNext, after temporarily switching the value
// of FindBackwards
void findNext();
void optionsChanged();
void dialogClosed();
protected:
QWidget* parentWidget() const { return (QWidget *)parent(); }
QWidget* dialogsParent() const;
protected slots:
void slotFindNext();
void slotDialogClosed();
private:
void init( const QString& pattern );
void startNewIncrementalSearch();
static bool isInWord( QChar ch );
static bool isWholeWords( const QString &text, int starts, int matchedLength );
friend class KReplace;
QString m_pattern;
QRegExp *m_regExp;
KDialogBase* m_dialog;
long m_options;
unsigned m_matches;
QString m_text; // the text set by setData
int m_index;
int m_matchedLength;
bool m_dialogClosed;
bool m_lastResult;
// Binary compatible extensibility.
struct Private;
Private *d;
};
#endif
KFind::resetCounts
virtual void resetCounts()
Call this to reset the numMatches count (and the numReplacements count for a KReplace).
Definition: kfind.h:231
KDialogBase
KReplace
A generic implementation of the "replace" function.
Definition: kreplace.h:97
KFind::numMatches
int numMatches() const
Return the number of matches found (i.e.
Definition: kfind.h:223
KFind::Result
Result
Result enum.
Definition: kfind.h:139
KFind
A generic implementation of the "find" function.
Definition: kfind.h:103
KFind::pattern
QString pattern() const
Definition: kfind.h:208
KFind::validateMatch
virtual bool validateMatch(const QString &text, int index, int matchedlength)
Virtual method, which allows applications to add extra checks for validating a candidate match...
Definition: kfind.h:243
KFind::options
long options() const
Return the current options.
Definition: kfind.h:195
KFind::NoMatch
No match was found.
Definition: kfind.h:140

KDE Home | KDE Accessibility Home | Description of Access Keys