![]() |
XML Mill
1.0.0
A GUI based XML editor with a memory.
|
Search through the current document for specific text. More...
#include <gcsearchform.h>
Signals | |
void | foundItem (GCTreeWidgetItem *) |
Emitted when the search string is found in the document. | |
Public Member Functions | |
GCSearchForm (const QList< GCTreeWidgetItem * > &items, QPlainTextEdit *textEdit, QWidget *parent=0) | |
Constructor. | |
~GCSearchForm () | |
Destructor. | |
Private Slots | |
void | search () |
Triggered when the user clicks the search button. | |
void | resetCursor () |
Resets the text edit's cursor to the top or the bottom of the text edit (depending on the direction of the search) so that the user can keep cycling through all the matches (if any). | |
void | searchUp () |
Triggered when the user ticks the "Search Up" checkbox. | |
void | caseSensitive () |
Triggered when the user ticks the "Case Sensitive" checkbox. | |
void | wholeWords () |
Triggered when the user ticks the "Whole Words Only" checkbox. | |
Private Member Functions | |
QList< GCTreeWidgetItem * > | gatherMatchingItems (const QString &nodeText) |
Gathers all items matching "nodeText" into a list. | |
void | findMatchingTreeItem (const QList< GCTreeWidgetItem * > matchingItems, bool ascending) |
Called from within the search function, finds the match (if any) and emits the foundItem signal if it does. | |
void | resetHighlights () |
Resets all "manually" highlighted text to their standard appearance. | |
void | highlightFind () |
Called whenever the found text does not match a node (i.e. | |
Private Attributes | |
Ui::GCSearchForm * | ui |
QPlainTextEdit * | m_text |
QBrush | m_savedBackground |
QBrush | m_savedForeground |
bool | m_wasFound |
bool | m_searchUp |
bool | m_firstRun |
int | m_previousIndex |
QTextDocument::FindFlags | m_searchFlags |
QList< GCTreeWidgetItem * > | m_items |
Search through the current document for specific text.
The Qt::WA_DeleteOnClose flag is set for all instances of this form. If you're unfamiliar with Qt, this means that Qt will delete this widget as soon as the widget accepts the close event (i.e. you don't need to worry about clean-up of dynamically created instances of this object).
Definition at line 50 of file gcsearchform.h.
GCSearchForm::GCSearchForm | ( | const QList< GCTreeWidgetItem * > & | items, |
QPlainTextEdit * | textEdit, | ||
QWidget * | parent = 0 |
||
) | [explicit] |
Constructor.
elements | - a list of all the elements in the active document. |
textEdit | - the textEdit currently displaying the active document's DOM content. |
Definition at line 52 of file gcsearchform.cpp.
Destructor.
Definition at line 81 of file gcsearchform.cpp.
void GCSearchForm::caseSensitive | ( | ) | [private, slot] |
Triggered when the user ticks the "Case Sensitive" checkbox.
If checked, the search string's case will be matched exactly.
Definition at line 192 of file gcsearchform.cpp.
void GCSearchForm::findMatchingTreeItem | ( | const QList< GCTreeWidgetItem * > | matchingItems, |
bool | ascending | ||
) | [private] |
Called from within the search function, finds the match (if any) and emits the foundItem signal if it does.
Definition at line 245 of file gcsearchform.cpp.
void GCSearchForm::foundItem | ( | GCTreeWidgetItem * | ) | [signal] |
Emitted when the search string is found in the document.
The item emitted in this signal will contain the matched string in either its corresponding element's name, or the name of an associated attribute or attribute value.
QList< GCTreeWidgetItem * > GCSearchForm::gatherMatchingItems | ( | const QString & | nodeText | ) | [private] |
Gathers all items matching "nodeText" into a list.
Definition at line 226 of file gcsearchform.cpp.
void GCSearchForm::highlightFind | ( | ) | [private] |
Called whenever the found text does not match a node (i.e.
matches text in a closing bracket, or in a comment, etc) so that we may highlight the match ourselves for display purposes.
Definition at line 285 of file gcsearchform.cpp.
void GCSearchForm::resetCursor | ( | ) | [private, slot] |
Resets the text edit's cursor to the top or the bottom of the text edit (depending on the direction of the search) so that the user can keep cycling through all the matches (if any).
Definition at line 150 of file gcsearchform.cpp.
void GCSearchForm::resetHighlights | ( | ) | [private] |
Resets all "manually" highlighted text to their standard appearance.
Definition at line 269 of file gcsearchform.cpp.
void GCSearchForm::search | ( | ) | [private, slot] |
Triggered when the user clicks the search button.
If a match has already been found, this function will search for the next occurrence of the search string (if any). Repeatedly triggering this slot will cause the search to cycle through all the matches in the user-specified direction.
Definition at line 89 of file gcsearchform.cpp.
void GCSearchForm::searchUp | ( | ) | [private, slot] |
Triggered when the user ticks the "Search Up" checkbox.
If checked, the search will try to find a match above the current cursor position, otherwise the search will try to find a match below the cursor position.
Definition at line 169 of file gcsearchform.cpp.
void GCSearchForm::wholeWords | ( | ) | [private, slot] |
Triggered when the user ticks the "Whole Words Only" checkbox.
If checked, the search string's content will be matched exactly.
Definition at line 209 of file gcsearchform.cpp.