mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
Find/Replace dialog improvements
Find/Replace dialog does not block the main window. Dialog reused, so checks changed by user are preserved. The selection of the last occurrence in Find All and Replace All is cleared, so all the occurrences have the same appearance.
This commit is contained in:
@@ -26,12 +26,12 @@ void FindReplaceDialog::setSqlTextEdit(SqlTextEdit* sqlTextEdit)
|
||||
m_sqlTextEdit->setIndicatorForegroundColor(Qt::magenta, foundIndicatorNumber);
|
||||
m_sqlTextEdit->setIndicatorDrawUnder(true, foundIndicatorNumber);
|
||||
|
||||
if (m_sqlTextEdit->isReadOnly()) {
|
||||
ui->replaceWithText->setEnabled(false);
|
||||
ui->replaceButton->setEnabled(false);
|
||||
ui->replaceAllButton->setEnabled(false);
|
||||
}
|
||||
bool isWriteable = ! m_sqlTextEdit->isReadOnly();
|
||||
ui->replaceWithText->setEnabled(isWriteable);
|
||||
ui->replaceButton->setEnabled(isWriteable);
|
||||
ui->replaceAllButton->setEnabled(isWriteable);
|
||||
|
||||
connect(m_sqlTextEdit, SIGNAL(destroyed()), this, SLOT(hide()));
|
||||
}
|
||||
|
||||
bool FindReplaceDialog::findNext()
|
||||
@@ -52,6 +52,13 @@ bool FindReplaceDialog::findNext()
|
||||
|
||||
}
|
||||
|
||||
void FindReplaceDialog::show()
|
||||
{
|
||||
ui->findText->setFocus();
|
||||
ui->findText->selectAll();
|
||||
QDialog::show();
|
||||
}
|
||||
|
||||
void FindReplaceDialog::replace()
|
||||
{
|
||||
m_sqlTextEdit->replace(ui->replaceWithText->text());
|
||||
@@ -80,8 +87,9 @@ void FindReplaceDialog::findAll()
|
||||
indicateSelection();
|
||||
++occurrences;
|
||||
}
|
||||
m_sqlTextEdit->clearSelection();
|
||||
|
||||
QString message;
|
||||
QString message;
|
||||
switch (occurrences) {
|
||||
case 0:
|
||||
message = tr("The searched text was not found.");
|
||||
@@ -113,6 +121,7 @@ void FindReplaceDialog::replaceAll()
|
||||
indicateSelection();
|
||||
++occurrences;
|
||||
}
|
||||
m_sqlTextEdit->clearSelection();
|
||||
|
||||
QString message;
|
||||
switch (occurrences) {
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
explicit FindReplaceDialog(QWidget* parent = nullptr);
|
||||
~FindReplaceDialog();
|
||||
void setSqlTextEdit(SqlTextEdit* sqlTextEdit);
|
||||
void show();
|
||||
|
||||
private slots:
|
||||
bool findNext();
|
||||
|
||||
@@ -58,6 +58,7 @@ MainWindow::MainWindow(QWidget* parent)
|
||||
editDock(new EditDialog(this)),
|
||||
plotDock(new PlotDock(this)),
|
||||
remoteDock(new RemoteDock(this)),
|
||||
findReplaceDialog(new FindReplaceDialog(this)),
|
||||
gotoValidator(new QIntValidator(0, 0, this))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -2714,8 +2715,7 @@ void MainWindow::openFindReplaceDialog()
|
||||
focusedSqlTextEdit = sqlWidget->getEditor();
|
||||
|
||||
if (focusedSqlTextEdit) {
|
||||
FindReplaceDialog dialog(this);
|
||||
dialog.setSqlTextEdit(focusedSqlTextEdit);
|
||||
dialog.exec();
|
||||
findReplaceDialog->setSqlTextEdit(focusedSqlTextEdit);
|
||||
findReplaceDialog->show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ class SqliteTableModel;
|
||||
class DbStructureModel;
|
||||
class RemoteDock;
|
||||
class RemoteDatabase;
|
||||
class FindReplaceDialog;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@@ -173,6 +174,7 @@ private:
|
||||
EditDialog* editDock;
|
||||
PlotDock* plotDock;
|
||||
RemoteDock* remoteDock;
|
||||
FindReplaceDialog* findReplaceDialog;
|
||||
|
||||
QIntValidator* gotoValidator;
|
||||
|
||||
|
||||
@@ -198,7 +198,11 @@ bool SqlTextEdit::findText(QString text, bool regexp, bool caseSensitive, bool w
|
||||
}
|
||||
|
||||
return findFirst(text, regexp, caseSensitive, words, wrap, forward);
|
||||
}
|
||||
|
||||
void SqlTextEdit::clearSelection()
|
||||
{
|
||||
setSelection(-1,-1,-1,-1);
|
||||
}
|
||||
|
||||
void SqlTextEdit::openFindReplaceDialog()
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
virtual ~SqlTextEdit();
|
||||
|
||||
bool findText(QString text, bool regexp, bool caseSensitive, bool words, bool wrap, bool forward);
|
||||
void clearSelection();
|
||||
static SqlUiLexer* sqlLexer;
|
||||
|
||||
public slots:
|
||||
|
||||
Reference in New Issue
Block a user