summaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/dialogs/searchtextdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/dialogs/searchtextdialog.cpp')
-rw-r--r--SQLiteStudio3/guiSQLiteStudio/dialogs/searchtextdialog.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/dialogs/searchtextdialog.cpp b/SQLiteStudio3/guiSQLiteStudio/dialogs/searchtextdialog.cpp
new file mode 100644
index 0000000..87a6d88
--- /dev/null
+++ b/SQLiteStudio3/guiSQLiteStudio/dialogs/searchtextdialog.cpp
@@ -0,0 +1,75 @@
+#include "searchtextdialog.h"
+#include "ui_searchtextdialog.h"
+#include "searchtextlocator.h"
+#include "common/unused.h"
+
+SearchTextDialog::SearchTextDialog(SearchTextLocator* textLocator, QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::SearchTextDialog), textLocator(textLocator)
+{
+ ui->setupUi(this);
+ connect(textLocator, SIGNAL(replaceAvailable(bool)), this, SLOT(setReplaceAvailable(bool)));
+}
+
+SearchTextDialog::~SearchTextDialog()
+{
+ delete ui;
+}
+
+void SearchTextDialog::changeEvent(QEvent *e)
+{
+ QDialog::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+
+void SearchTextDialog::showEvent(QShowEvent* e)
+{
+ UNUSED(e);
+ ui->findEdit->setFocus();
+ ui->findEdit->selectAll();
+ configModifiedState = true;
+ setReplaceAvailable(false);
+}
+
+void SearchTextDialog::applyConfigToLocator()
+{
+ if (!configModifiedState)
+ return;
+
+ textLocator->setCaseSensitive(ui->caseSensitiveCheck->isChecked());
+ textLocator->setSearchBackwards(ui->backwardsCheck->isChecked());
+ textLocator->setRegularExpression(ui->regExpCheck->isChecked());
+ textLocator->setLookupString(ui->findEdit->text());
+ configModifiedState = false;
+}
+
+void SearchTextDialog::setReplaceAvailable(bool available)
+{
+ ui->replaceButton->setEnabled(available);
+}
+
+void SearchTextDialog::on_findButton_clicked()
+{
+ applyConfigToLocator();
+ textLocator->find();
+}
+
+void SearchTextDialog::on_replaceButton_clicked()
+{
+ applyConfigToLocator();
+ textLocator->setReplaceString(ui->replaceEdit->text());
+ textLocator->replaceAndFind();
+}
+
+void SearchTextDialog::on_replaceAllButton_clicked()
+{
+ applyConfigToLocator();
+ textLocator->setReplaceString(ui->replaceEdit->text());
+ textLocator->replaceAll();
+}