QCodeEdit  2.2
qdocumentsearch.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2006-2009 fullmetalcoder <fullmetalcoder@hotmail.fr>
4 **
5 ** This file is part of the Edyuk project <http://edyuk.org>
6 **
7 ** This file may be used under the terms of the GNU General Public License
8 ** version 3 as published by the Free Software Foundation and appearing in the
9 ** file GPL.txt included in the packaging of this file.
10 **
11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 **
14 ****************************************************************************/
15 
16 #ifndef _QDOCUMENT_SEARCH_H_
17 #define _QDOCUMENT_SEARCH_H_
18 
19 #include "qce-config.h"
20 
26 #include <QString>
27 #include <QRegExp>
28 #include <QPointer>
29 #include <QCoreApplication>
30 
31 #include "qdocumentcursor.h"
32 
33 class QEditor;
34 
36 {
37  Q_DECLARE_TR_FUNCTIONS(QDocumentSearch)
38 
39  public:
40  enum Option
41  {
42  WholeWords = 1,
43  CaseSensitive = 2,
44  RegExp = 4,
45  Replace = 8,
46  Prompt = 16,
47  Silent = 32,
48  HighlightAll = 64
49  };
50 
51  Q_DECLARE_FLAGS(Options, Option);
52 
53  QDocumentSearch(QEditor *e, const QString& f, Options opt, const QString& r = QString());
54  ~QDocumentSearch();
55 
56  int currentMatchIndex() const;
57  int indexedMatchCount() const;
58  QDocumentCursor match(int idx) const;
59 
60  QString searchText() const;
61  void setSearchText(const QString& f);
62 
63  Options options() const;
64  bool hasOption(Option opt) const;
65  void setOption(Option opt, bool on);
66 
67  QString replaceText() const;
68  void setReplaceText(const QString& r);
69 
70  QDocumentCursor origin() const;
71  void setOrigin(const QDocumentCursor& c);
72 
73  QDocumentCursor cursor() const;
74  void setCursor(const QDocumentCursor& c);
75 
76  QDocumentCursor scope() const;
77  void setScope(const QDocumentCursor& c);
78 
79  void next(bool backward, bool all = false);
80 
81  private:
82  bool end(bool backward) const;
83 
84  void clearMatches();
85 
86  int m_group;
87  int m_index;
88  Options m_option;
89  QString m_string;
90  QString m_replace;
91  QPointer<QEditor> m_editor;
92  QDocumentCursor m_cursor, m_scope, m_origin;
93  QList<QDocumentCursor> m_highlight;
94 };
95 
96 Q_DECLARE_OPERATORS_FOR_FLAGS(QDocumentSearch::Options)
97 
98 #endif // !_QDOCUMENT_SEARCH_H_