diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-07-03 06:53:06 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-07-03 06:53:06 +0000 |
commit | a8bb62e6e290678f221a01bec7b24e6742366759 (patch) | |
tree | 8f77f0c145a1b63afbe82433940ab5daae899bfb /utils/themeeditor/gui/findreplacedialog.cpp | |
parent | fb09d6354c0b6badb449f532f40af9a8037377a3 (diff) | |
download | rockbox-a8bb62e6e290678f221a01bec7b24e6742366759.tar.gz rockbox-a8bb62e6e290678f221a01bec7b24e6742366759.zip |
Theme Editor: Made irrelevant menu items disabled at startup, made wrap-around search work in the find/replace dialog
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27253 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/gui/findreplacedialog.cpp')
-rw-r--r-- | utils/themeeditor/gui/findreplacedialog.cpp | 47 |
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 | ||
27 | FindReplaceDialog::FindReplaceDialog(QWidget *parent) : | 27 | FindReplaceDialog::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 | ||