summaryrefslogtreecommitdiff
path: root/utils/themeeditor/gui/findreplacedialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor/gui/findreplacedialog.cpp')
-rw-r--r--utils/themeeditor/gui/findreplacedialog.cpp47
1 files changed, 45 insertions, 2 deletions
diff --git a/utils/themeeditor/gui/findreplacedialog.cpp b/utils/themeeditor/gui/findreplacedialog.cpp
index 234c6f6886..e2b8b9bc43 100644
--- a/utils/themeeditor/gui/findreplacedialog.cpp
+++ b/utils/themeeditor/gui/findreplacedialog.cpp
@@ -26,7 +26,7 @@
26 26
27FindReplaceDialog::FindReplaceDialog(QWidget *parent) : 27FindReplaceDialog::FindReplaceDialog(QWidget *parent) :
28 QDialog(parent), 28 QDialog(parent),
29 ui(new Ui::FindReplaceDialog), editor(0) 29 ui(new Ui::FindReplaceDialog), editor(0), textFound()
30{ 30{
31 ui->setupUi(this); 31 ui->setupUi(this);
32 setupUI(); 32 setupUI();
@@ -77,7 +77,50 @@ void FindReplaceDialog::find()
77 if(!editor) 77 if(!editor)
78 return; 78 return;
79 79
80 editor->setTextCursor(editor->document()->find(ui->findBox->text())); 80 /* Figuring out the range to search in */
81 int begin = editor->textCursor().selectionStart();
82 int end = editor->textCursor().selectionEnd();
83
84 QTextDocument::FindFlags flags = 0;
85 if(ui->caseBox->isChecked())
86 flags |= QTextDocument::FindCaseSensitively;
87 if(ui->backwardsBox->isChecked())
88 flags |= QTextDocument::FindBackward;
89
90 QTextCursor start = textFound.isNull() ? editor->textCursor() : textFound;
91
92 textFound = editor->document()->find(ui->findBox->text(), start, flags);
93
94 if(textFound.isNull() && ui->wrapBox->isChecked())
95 {
96 if(ui->backwardsBox->isChecked())
97 {
98 textFound = editor->document()
99 ->find(ui->findBox->text(),
100 editor->document()->toPlainText().length(),
101 flags);
102 }
103 else
104 {
105 textFound = editor->document()->find(ui->findBox->text(), 0, flags);
106 }
107 }
108
109 QPalette newPal;
110 if(!textFound.isNull())
111 {
112 newPal.setColor(QPalette::Foreground, QColor(150, 255, 150));
113 ui->statusLabel->setPalette(newPal);
114 ui->statusLabel->setText(tr("Match Found"));
115 editor->setTextCursor(textFound);
116 }
117 else
118 {
119 newPal.setColor(QPalette::Foreground, Qt::red);
120 ui->statusLabel->setPalette(newPal);
121 ui->statusLabel->setText(tr("Match Not Found"));
122 editor->setTextCursor(start);
123 }
81 124
82} 125}
83 126