edbee - Qt Editor Library
textsearcher.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <QObject>
9 
10 #include "edbee/models/textrange.h"
11 
12 namespace edbee {
13 
14 
15 class RegExp;
16 class TextDocument;
17 class TextEditorWidget;
18 
23 class TextSearcher : public QObject
24 {
25  Q_OBJECT
26 public:
27 
28  enum SyntaxType {
31  };
32 
33  explicit TextSearcher(QObject *parent = 0);
34  virtual ~TextSearcher();
35 
36  QString searchTerm() const;
37  void setSearchTerm( const QString& term );
38 
39  SyntaxType syntax() const;
41 
42  bool isCaseSensitive() const;
43  void setCaseSensitive( bool sensitive );
44 
45  bool isWrapAroundEnabled() const;
46  void setWrapAround( bool on );
47 
48  bool isReverse() const;
49  void setReverse( bool on );
50 
51  TextRange findNextRange( TextRangeSet* selection );
52 
53  bool findNext( TextRangeSet* selection );
54  bool findPrev( TextRangeSet* selection );
55  bool selectNext( TextRangeSet* selection );
56  bool selectPrev( TextRangeSet* selection );
57  bool selectAll( TextRangeSet* selection );
58 
59 public slots:
60 
61  bool findNext( TextEditorWidget* widget );
62  bool findPrev( TextEditorWidget* widget );
63  bool selectNext( TextEditorWidget* widget );
64  bool selectPrev( TextEditorWidget* widget );
65  bool selectAll( TextEditorWidget* widget );
66 
67  void selectUnderExpand(TextEditorWidget* widget, bool selectAllTexts );
68 
69 
70 
71 
72 protected:
73 
74  void setDirty();
76 
77 private:
78 
79  QString searchTerm_;
80  SyntaxType syntax_;
81  bool caseSensitive_;
82  bool wrapAround_;
83  bool reverse_;
84 
85  RegExp* regExp_;
86 
87 };
88 
89 } // edbee
TextSearcher(QObject *parent=0)
Definition: textsearcher.cpp:21
bool isReverse() const
Checks the reverse mode.
Definition: textsearcher.cpp:99
bool selectPrev(TextRangeSet *selection)
Selects the previous item based on the given caret position in the selection.
Definition: textsearcher.cpp:206
void setSearchTerm(const QString &term)
Sets the current search term.
Definition: textsearcher.cpp:46
TextRange findNextRange(TextRangeSet *selection)
Finds the next matching textrange This method does not alter the textrange selection. It only returns the range of the next match.
Definition: textsearcher.cpp:116
virtual ~TextSearcher()
destroys the textsearcher
Definition: textsearcher.cpp:33
void setDirty()
Marks the regexp as dirty (and deletes it)
Definition: textsearcher.cpp:352
bool isWrapAroundEnabled() const
Should the search wrap around the contents of the document.
Definition: textsearcher.cpp:84
Definition: textsearcher.h:30
RegExp * createRegExp()
Creates a regular expression for the current selected options.
Definition: textsearcher.cpp:361
bool isCaseSensitive() const
Returns the case sensitivity of the textsearcher.
Definition: textsearcher.cpp:69
void setReverse(bool on)
Sets the search reverse mode.
Definition: textsearcher.cpp:106
Copyright 2011-2013 - Reliable Bits Software by Blommers IT.
Definition: commentcommand.cpp:22
A class for matching QStrings with the Oniguruma API We need this Regular Expression library to be ab...
Definition: regexp.h:36
bool selectNext(TextRangeSet *selection)
Selects the next item that matches the given critaria (Adds an extra selection range ) ...
Definition: textsearcher.cpp:186
void selectUnderExpand(TextEditorWidget *widget, bool selectAllTexts)
A smart selection: when there&#39;s no selection the current word is used and selected. The next word will be selected, if all is specified all words are selected.
Definition: textsearcher.cpp:315
void setWrapAround(bool on)
For changing the wrap around mode of the TextSearcher.
Definition: textsearcher.cpp:91
void setCaseSensitive(bool sensitive)
sets the case sensitivity of the search operation
Definition: textsearcher.cpp:76
bool selectAll(TextRangeSet *selection)
Select all matching items in the document.
Definition: textsearcher.cpp:218
Definition: textsearcher.h:29
The basic textrange class. A simple class of textrange with a simple vector implementation.
Definition: textrange.h:198
SyntaxType syntax() const
Returns the syntax type of the current search operation.
Definition: textsearcher.cpp:53
QString searchTerm() const
Returns the current active searchterm.
Definition: textsearcher.cpp:39
This is the general edbee widget This core functionality of this widget is divided in several seperat...
Definition: texteditorwidget.h:32
The text searcher is a class to remember the current search operation It remembers the current search...
Definition: textsearcher.h:23
bool findPrev(TextRangeSet *selection)
Finds the previous item based on the given caret position in the selection.
Definition: textsearcher.cpp:173
bool findNext(TextRangeSet *selection)
Finds the next item based on the given caret position in the selection.
Definition: textsearcher.cpp:158
A single text region A region constists of an anchor and a caret: The anchor defines the &#39;start&#39; of t...
Definition: textrange.h:29
void setSyntax(SyntaxType syntax)
Sets the syntax mode of the searcher syntax the SyntaxType to use (SyntaxPlainString, SyntaxRegExp)
Definition: textsearcher.cpp:61
SyntaxType
Definition: textsearcher.h:28