00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _QDOCUMENT_SEARCH_H_
00017 #define _QDOCUMENT_SEARCH_H_
00018
00019 #include "qce-config.h"
00020
00026 #include <QString>
00027 #include <QRegExp>
00028 #include <QPointer>
00029 #include <QCoreApplication>
00030
00031 #include "qdocumentcursor.h"
00032
00033 class QEditor;
00034
00035 class QCE_EXPORT QDocumentSearch
00036 {
00037 Q_DECLARE_TR_FUNCTIONS(QDocumentSearch)
00038
00039 public:
00040 enum Option
00041 {
00042 WholeWords = 1,
00043 CaseSensitive = 2,
00044 RegExp = 4,
00045 Replace = 8,
00046 Prompt = 16,
00047 Silent = 32,
00048 HighlightAll = 64
00049 };
00050
00051 Q_DECLARE_FLAGS(Options, Option);
00052
00053 QDocumentSearch(QEditor *e, const QString& f, Options opt, const QString& r = QString());
00054 ~QDocumentSearch();
00055
00056 int indexedMatchCount() const;
00057
00058 QString searchText() const;
00059 void setSearchText(const QString& f);
00060
00061 bool hasOption(Option opt) const;
00062 void setOption(Option opt, bool on);
00063
00064 QString replaceText() const;
00065 void setReplaceText(const QString& r);
00066
00067 QDocumentCursor origin() const;
00068 void setOrigin(const QDocumentCursor& c);
00069
00070 QDocumentCursor cursor() const;
00071 void setCursor(const QDocumentCursor& c);
00072
00073 QDocumentCursor scope() const;
00074 void setScope(const QDocumentCursor& c);
00075
00076 void next(bool backward, bool all = false);
00077
00078 private:
00079 bool end(bool backward) const;
00080
00081 void clearMatches();
00082
00083 int m_group;
00084 int m_index;
00085 Options m_option;
00086 QString m_string;
00087 QString m_replace;
00088 QPointer<QEditor> m_editor;
00089 QDocumentCursor m_cursor, m_scope, m_origin;
00090 QList<QDocumentCursor> m_highlight;
00091 };
00092
00093 Q_DECLARE_OPERATORS_FOR_FLAGS(QDocumentSearch::Options)
00094
00095 #endif // !_QDOCUMENT_SEARCH_H_