forked from len0rd/rockbox
Theme Editor: Implemented replace and replace all in find/replace dialog
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27254 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a8bb62e6e2
commit
5aa684f058
2 changed files with 31 additions and 16 deletions
|
|
@ -57,13 +57,13 @@ void FindReplaceDialog::closeEvent(QCloseEvent* event)
|
||||||
|
|
||||||
void FindReplaceDialog::setupUI()
|
void FindReplaceDialog::setupUI()
|
||||||
{
|
{
|
||||||
QObject::connect(ui->findButton, SIGNAL(pressed()),
|
QObject::connect(ui->findButton, SIGNAL(clicked()),
|
||||||
this, SLOT(find()));
|
this, SLOT(find()));
|
||||||
QObject::connect(ui->replaceButton, SIGNAL(pressed()),
|
QObject::connect(ui->replaceButton, SIGNAL(clicked()),
|
||||||
this, SLOT(replace()));
|
this, SLOT(replace()));
|
||||||
QObject::connect(ui->replaceAllButton, SIGNAL(pressed()),
|
QObject::connect(ui->replaceAllButton, SIGNAL(clicked()),
|
||||||
this, SLOT(replaceAll()));
|
this, SLOT(replaceAll()));
|
||||||
QObject::connect(ui->closeButton, SIGNAL(pressed()),
|
QObject::connect(ui->closeButton, SIGNAL(clicked()),
|
||||||
this, SLOT(close()));
|
this, SLOT(close()));
|
||||||
QObject::connect(ui->findBox, SIGNAL(textChanged(QString)),
|
QObject::connect(ui->findBox, SIGNAL(textChanged(QString)),
|
||||||
this, SLOT(textChanged()));
|
this, SLOT(textChanged()));
|
||||||
|
|
@ -77,10 +77,6 @@ void FindReplaceDialog::find()
|
||||||
if(!editor)
|
if(!editor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Figuring out the range to search in */
|
|
||||||
int begin = editor->textCursor().selectionStart();
|
|
||||||
int end = editor->textCursor().selectionEnd();
|
|
||||||
|
|
||||||
QTextDocument::FindFlags flags = 0;
|
QTextDocument::FindFlags flags = 0;
|
||||||
if(ui->caseBox->isChecked())
|
if(ui->caseBox->isChecked())
|
||||||
flags |= QTextDocument::FindCaseSensitively;
|
flags |= QTextDocument::FindCaseSensitively;
|
||||||
|
|
@ -109,7 +105,7 @@ void FindReplaceDialog::find()
|
||||||
QPalette newPal;
|
QPalette newPal;
|
||||||
if(!textFound.isNull())
|
if(!textFound.isNull())
|
||||||
{
|
{
|
||||||
newPal.setColor(QPalette::Foreground, QColor(150, 255, 150));
|
newPal.setColor(QPalette::Foreground, QColor(0, 150, 0));
|
||||||
ui->statusLabel->setPalette(newPal);
|
ui->statusLabel->setPalette(newPal);
|
||||||
ui->statusLabel->setText(tr("Match Found"));
|
ui->statusLabel->setText(tr("Match Found"));
|
||||||
editor->setTextCursor(textFound);
|
editor->setTextCursor(textFound);
|
||||||
|
|
@ -126,12 +122,31 @@ void FindReplaceDialog::find()
|
||||||
|
|
||||||
void FindReplaceDialog::replace()
|
void FindReplaceDialog::replace()
|
||||||
{
|
{
|
||||||
|
if(textFound.isNull())
|
||||||
|
find();
|
||||||
|
|
||||||
|
if(textFound.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
editor->setTextCursor(textFound);
|
||||||
|
editor->insertPlainText(ui->replaceBox->text());
|
||||||
|
textFound = QTextCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindReplaceDialog::replaceAll()
|
void FindReplaceDialog::replaceAll()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if(!textFound.isNull())
|
||||||
|
{
|
||||||
|
editor->setTextCursor(textFound);
|
||||||
|
editor->insertPlainText(ui->replaceBox->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
find();
|
||||||
|
}while(!textFound.isNull());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindReplaceDialog::textChanged()
|
void FindReplaceDialog::textChanged()
|
||||||
|
|
|
||||||
|
|
@ -50,15 +50,15 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="statusLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="statusLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="caseBox">
|
<widget class="QCheckBox" name="caseBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue