mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-21 03:21:43 -06:00
Some progress towards less usage of SIGNAL and SLOT macros
This is in no way complete but since it is a routine task and I got bored of it I am going to stop here.
This commit is contained in:
@@ -121,7 +121,7 @@ AddRecordDialog::AddRecordDialog(DBBrowserDB& db, const sqlb::ObjectIdentifier&
|
||||
{
|
||||
// Create UI
|
||||
ui->setupUi(this);
|
||||
connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),this,SLOT(itemChanged(QTreeWidgetItem*,int)));
|
||||
connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &AddRecordDialog::itemChanged);
|
||||
|
||||
populateFields();
|
||||
|
||||
@@ -163,10 +163,8 @@ void AddRecordDialog::setDefaultsStyle(QTreeWidgetItem* item)
|
||||
|
||||
void AddRecordDialog::populateFields()
|
||||
{
|
||||
// disconnect the itemChanged signal or the SQL text will
|
||||
// be updated while filling the treewidget.
|
||||
disconnect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
|
||||
this,SLOT(itemChanged(QTreeWidgetItem*,int)));
|
||||
// Block the itemChanged signal or the SQL text will be updated while filling the treewidget.
|
||||
ui->treeWidget->blockSignals(true);
|
||||
|
||||
ui->treeWidget->clear();
|
||||
|
||||
@@ -260,8 +258,8 @@ void AddRecordDialog::populateFields()
|
||||
|
||||
updateSqlText();
|
||||
|
||||
// and reconnect
|
||||
connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),this,SLOT(itemChanged(QTreeWidgetItem*,int)));
|
||||
// Enable signals from tree widget
|
||||
ui->treeWidget->blockSignals(false);
|
||||
}
|
||||
|
||||
void AddRecordDialog::accept()
|
||||
|
||||
@@ -152,7 +152,7 @@ Application::Application(int& argc, char** argv) :
|
||||
// Show main window
|
||||
m_mainWindow = new MainWindow();
|
||||
m_mainWindow->show();
|
||||
connect(this, SIGNAL(lastWindowClosed()), this, SLOT(quit()));
|
||||
connect(this, &Application::lastWindowClosed, this, &Application::quit);
|
||||
|
||||
// Open database if one was specified
|
||||
if(fileToOpen.size())
|
||||
|
||||
@@ -227,8 +227,8 @@ ExtendedTableWidget::ExtendedTableWidget(QWidget* parent) :
|
||||
// Force ScrollPerItem, so scrolling shows all table rows
|
||||
setVerticalScrollMode(ExtendedTableWidget::ScrollPerItem);
|
||||
|
||||
connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(vscrollbarChanged(int)));
|
||||
connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(cellClicked(QModelIndex)));
|
||||
connect(verticalScrollBar(), &QScrollBar::valueChanged, this, &ExtendedTableWidget::vscrollbarChanged);
|
||||
connect(this, &ExtendedTableWidget::clicked, this, &ExtendedTableWidget::cellClicked);
|
||||
|
||||
// Set up filter row
|
||||
m_tableHeader = new FilterTableHeader(this);
|
||||
|
||||
@@ -18,9 +18,9 @@ FilterTableHeader::FilterTableHeader(QTableView* parent) :
|
||||
setSectionResizeMode(QHeaderView::Interactive);
|
||||
|
||||
// Do some connects: Basically just resize and reposition the input widgets whenever anything changes
|
||||
connect(this, SIGNAL(sectionResized(int,int,int)), this, SLOT(adjustPositions()));
|
||||
connect(parent->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(adjustPositions()));
|
||||
connect(parent->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(adjustPositions()));
|
||||
connect(this, &FilterTableHeader::sectionResized, this, &FilterTableHeader::adjustPositions);
|
||||
connect(parent->horizontalScrollBar(), &QScrollBar::valueChanged, this, &FilterTableHeader::adjustPositions);
|
||||
connect(parent->verticalScrollBar(), &QScrollBar::valueChanged, this, &FilterTableHeader::adjustPositions);
|
||||
|
||||
// Set custom context menu handling
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
@@ -40,10 +40,10 @@ void FilterTableHeader::generateFilters(size_t number, bool showFirst)
|
||||
l->setVisible(false);
|
||||
else
|
||||
l->setVisible(true);
|
||||
connect(l, SIGNAL(delayedTextChanged(QString)), this, SLOT(inputChanged(QString)));
|
||||
connect(l, SIGNAL(addFilterAsCondFormat(QString)), this, SLOT(addFilterAsCondFormat(QString)));
|
||||
connect(l, SIGNAL(clearAllCondFormats()), this, SLOT(clearAllCondFormats()));
|
||||
connect(l, SIGNAL(editCondFormats()), this, SLOT(editCondFormats()));
|
||||
connect(l, &FilterLineEdit::delayedTextChanged, this, &FilterTableHeader::inputChanged);
|
||||
connect(l, &FilterLineEdit::addFilterAsCondFormat, this, &FilterTableHeader::addFilterAsCondFormat);
|
||||
connect(l, &FilterLineEdit::clearAllCondFormats, this, &FilterTableHeader::clearAllCondFormats);
|
||||
connect(l, &FilterLineEdit::editCondFormats, this, &FilterTableHeader::editCondFormats);
|
||||
filterWidgets.push_back(l);
|
||||
}
|
||||
|
||||
@@ -105,13 +105,13 @@ void FilterTableHeader::addFilterAsCondFormat(const QString& filter)
|
||||
void FilterTableHeader::clearAllCondFormats()
|
||||
{
|
||||
// Just get the column number and send it to anybody responsible or interested in clearing conditional formatting
|
||||
emit clearAllCondFormats(sender()->property("column").toInt());
|
||||
emit allCondFormatsCleared(sender()->property("column").toInt());
|
||||
}
|
||||
|
||||
void FilterTableHeader::editCondFormats()
|
||||
{
|
||||
// Just get the column number and the new value and send them to anybody interested in editting conditional formatting
|
||||
emit editCondFormats(sender()->property("column").toInt());
|
||||
emit condFormatsEdited(sender()->property("column").toInt());
|
||||
}
|
||||
|
||||
void FilterTableHeader::clearFilters()
|
||||
|
||||
@@ -25,8 +25,8 @@ public slots:
|
||||
signals:
|
||||
void filterChanged(int column, QString value);
|
||||
void addCondFormat(int column, QString filter);
|
||||
void clearAllCondFormats(int column);
|
||||
void editCondFormats(int column);
|
||||
void allCondFormatsCleared(int column);
|
||||
void condFormatsEdited(int column);
|
||||
|
||||
protected:
|
||||
void updateGeometries() override;
|
||||
|
||||
@@ -34,8 +34,8 @@ void FindReplaceDialog::setExtendedScintilla(ExtendedScintilla* scintilla)
|
||||
ui->replaceButton->setEnabled(isWriteable);
|
||||
ui->replaceAllButton->setEnabled(isWriteable);
|
||||
|
||||
connect(m_scintilla, SIGNAL(destroyed()), this, SLOT(hide()));
|
||||
connect(ui->findText, SIGNAL(editingFinished()), this, SLOT(cancelFind()));
|
||||
connect(m_scintilla, &ExtendedScintilla::destroyed, this, &FindReplaceDialog::hide);
|
||||
connect(ui->findText, &QLineEdit::editingFinished, this, &FindReplaceDialog::cancelFind);
|
||||
connect(ui->regexpCheckBox, &QCheckBox::toggled, this, &FindReplaceDialog::cancelFind);
|
||||
connect(ui->caseCheckBox, &QCheckBox::toggled, this, &FindReplaceDialog::cancelFind);
|
||||
connect(ui->wholeWordsCheckBox, &QCheckBox::toggled, this, &FindReplaceDialog::cancelFind);
|
||||
|
||||
@@ -180,12 +180,12 @@ void MainWindow::init()
|
||||
ui->editGoto->setValidator(gotoValidator);
|
||||
|
||||
// Set up filters
|
||||
connect(ui->dataTable->filterHeader(), SIGNAL(filterChanged(int,QString)), this, SLOT(updateFilter(int,QString)));
|
||||
connect(ui->dataTable->filterHeader(), SIGNAL(addCondFormat(int,QString)), this, SLOT(addCondFormat(int,QString)));
|
||||
connect(ui->dataTable->filterHeader(), SIGNAL(clearAllCondFormats(int)), this, SLOT(clearAllCondFormats(int)));
|
||||
connect(ui->dataTable->filterHeader(), SIGNAL(editCondFormats(int)), this, SLOT(editCondFormats(int)));
|
||||
connect(ui->dataTable, SIGNAL(editCondFormats(int)), this, SLOT(editCondFormats(int)));
|
||||
connect(m_browseTableModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataTableSelectionChanged(QModelIndex)));
|
||||
connect(ui->dataTable->filterHeader(), &FilterTableHeader::filterChanged, this, &MainWindow::updateFilter);
|
||||
connect(ui->dataTable->filterHeader(), &FilterTableHeader::addCondFormat, this, &MainWindow::addCondFormat);
|
||||
connect(ui->dataTable->filterHeader(), &FilterTableHeader::allCondFormatsCleared, this, &MainWindow::clearAllCondFormats);
|
||||
connect(ui->dataTable->filterHeader(), &FilterTableHeader::condFormatsEdited, this, &MainWindow::editCondFormats);
|
||||
connect(ui->dataTable, &ExtendedTableWidget::editCondFormats, this, &MainWindow::editCondFormats);
|
||||
connect(m_browseTableModel, &SqliteTableModel::dataChanged, this, &MainWindow::dataTableSelectionChanged);
|
||||
|
||||
// Select in table the rows correspoding to the selected points in plot
|
||||
connect(plotDock, SIGNAL(pointsSelected(int,int)), ui->dataTable, SLOT(selectTableLines(int,int)));
|
||||
@@ -235,9 +235,9 @@ void MainWindow::init()
|
||||
// Add keyboard shortcuts
|
||||
|
||||
QShortcut* shortcutBrowseRefreshF5 = new QShortcut(QKeySequence("F5"), this);
|
||||
connect(shortcutBrowseRefreshF5, SIGNAL(activated()), this, SLOT(refresh()));
|
||||
connect(shortcutBrowseRefreshF5, &QShortcut::activated, this, &MainWindow::refresh);
|
||||
QShortcut* shortcutBrowseRefreshCtrlR = new QShortcut(QKeySequence("Ctrl+R"), this);
|
||||
connect(shortcutBrowseRefreshCtrlR, SIGNAL(activated()), this, SLOT(refresh()));
|
||||
connect(shortcutBrowseRefreshCtrlR, &QShortcut::activated, this, &MainWindow::refresh);
|
||||
|
||||
// Add print shortcut for the DB Structure tab (dbTreeWidget) with context to the widget, so other print shortcuts aren't eclipsed.
|
||||
QShortcut* shortcutPrint = new QShortcut(QKeySequence(QKeySequence::Print), ui->dbTreeWidget, nullptr, nullptr, Qt::WidgetShortcut);
|
||||
@@ -439,16 +439,16 @@ void MainWindow::init()
|
||||
});
|
||||
|
||||
// Connect some more signals and slots
|
||||
connect(ui->dataTable->filterHeader(), SIGNAL(sectionClicked(int)), this, SLOT(browseTableHeaderClicked(int)));
|
||||
connect(ui->dataTable->filterHeader(), &FilterTableHeader::sectionClicked, this, &MainWindow::browseTableHeaderClicked);
|
||||
connect(ui->dataTable->filterHeader(), &QHeaderView::sectionDoubleClicked, ui->dataTable, &QTableView::selectColumn);
|
||||
connect(ui->dataTable->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(setRecordsetLabel()));
|
||||
connect(ui->dataTable->horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(updateBrowseDataColumnWidth(int,int,int)));
|
||||
connect(editDock, SIGNAL(recordTextUpdated(QPersistentModelIndex, QByteArray, bool)), this, SLOT(updateRecordText(QPersistentModelIndex, QByteArray, bool)));
|
||||
connect(ui->dbTreeWidget->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(changeTreeSelection()));
|
||||
connect(ui->dataTable->horizontalHeader(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showDataColumnPopupMenu(QPoint)));
|
||||
connect(ui->dataTable->verticalHeader(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showRecordPopupMenu(QPoint)));
|
||||
connect(ui->dataTable->verticalScrollBar(), &QScrollBar::valueChanged, this, &MainWindow::setRecordsetLabel);
|
||||
connect(ui->dataTable->horizontalHeader(), &QHeaderView::sectionResized, this, &MainWindow::updateBrowseDataColumnWidth);
|
||||
connect(editDock, &EditDialog::recordTextUpdated, this, &MainWindow::updateRecordText);
|
||||
connect(ui->dbTreeWidget->selectionModel(), &QItemSelectionModel::currentChanged, this, &MainWindow::changeTreeSelection);
|
||||
connect(ui->dataTable->horizontalHeader(), &QHeaderView::customContextMenuRequested, this, &MainWindow::showDataColumnPopupMenu);
|
||||
connect(ui->dataTable->verticalHeader(), &QHeaderView::customContextMenuRequested, this, &MainWindow::showRecordPopupMenu);
|
||||
connect(ui->dataTable, SIGNAL(openFileFromDropEvent(QString)), this, SLOT(fileOpen(QString)));
|
||||
connect(ui->dockEdit, SIGNAL(visibilityChanged(bool)), this, SLOT(toggleEditDock(bool)));
|
||||
connect(ui->dockEdit, &QDockWidget::visibilityChanged, this, &MainWindow::toggleEditDock);
|
||||
connect(m_remoteDb, SIGNAL(openFile(QString)), this, SLOT(fileOpen(QString)));
|
||||
connect(m_remoteDb, &RemoteDatabase::gotCurrentVersion, this, &MainWindow::checkNewVersion);
|
||||
connect(m_browseTableModel, &SqliteTableModel::finishedFetch, this, &MainWindow::setRecordsetLabel);
|
||||
@@ -739,7 +739,7 @@ void MainWindow::populateTable()
|
||||
ui->dataTable->setModel(m_browseTableModel);
|
||||
if(reconnectSelectionSignals)
|
||||
{
|
||||
connect(ui->dataTable->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(dataTableSelectionChanged(QModelIndex)));
|
||||
connect(ui->dataTable->selectionModel(), &QItemSelectionModel::currentChanged, this, &MainWindow::dataTableSelectionChanged);
|
||||
connect(ui->dataTable->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection&, const QItemSelection&) {
|
||||
updateInsertDeleteRecordButton();
|
||||
|
||||
@@ -1077,9 +1077,8 @@ void MainWindow::attachPlot(ExtendedTableWidget* tableWidget, SqliteTableModel*
|
||||
disconnect(plotDock, SIGNAL(pointsSelected(int,int)), nullptr, nullptr);
|
||||
if(tableWidget) {
|
||||
// Connect plot selection to the current table results widget.
|
||||
connect(plotDock, SIGNAL(pointsSelected(int,int)), tableWidget, SLOT(selectTableLines(int,int)));
|
||||
connect(tableWidget, SIGNAL(destroyed()), plotDock, SLOT(resetPlot()));
|
||||
|
||||
connect(plotDock, &PlotDock::pointsSelected, tableWidget, &ExtendedTableWidget::selectTableLines);
|
||||
connect(tableWidget, &ExtendedTableWidget::destroyed, plotDock, &PlotDock::resetPlot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1578,7 +1577,7 @@ void MainWindow::executeQuery()
|
||||
disconnect(*conn);
|
||||
|
||||
attachPlot(sqlWidget->getTableResult(), sqlWidget->getModel());
|
||||
connect(sqlWidget->getTableResult()->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(dataTableSelectionChanged(QModelIndex)));
|
||||
connect(sqlWidget->getTableResult()->selectionModel(), &QItemSelectionModel::currentChanged, this, &MainWindow::dataTableSelectionChanged);
|
||||
connect(sqlWidget->getTableResult(), &QTableView::doubleClicked, this, &MainWindow::doubleClickTable);
|
||||
|
||||
auto time_end = std::chrono::high_resolution_clock::now();
|
||||
@@ -2404,11 +2403,11 @@ int MainWindow::openSqlTab(bool resetCounter)
|
||||
// would interfere with the search bar and it'd be anyway redundant.
|
||||
w->getEditor()->setEnabledFindDialog(false);
|
||||
w->getEditor()->setFocus();
|
||||
connect(w, SIGNAL(findFrameVisibilityChanged(bool)), ui->actionSqlFind, SLOT(setChecked(bool)));
|
||||
connect(w, &SqlExecutionArea::findFrameVisibilityChanged, ui->actionSqlFind, &QAction::setChecked);
|
||||
|
||||
// Connect now the find shortcut to the editor with widget context, so it isn't ambiguous with other Scintilla Widgets.
|
||||
QShortcut* shortcutFind = new QShortcut(ui->actionSqlFind->shortcut(), w->getEditor(), nullptr, nullptr, Qt::WidgetShortcut);
|
||||
connect(shortcutFind, SIGNAL(activated()), ui->actionSqlFind, SLOT(toggle()));
|
||||
connect(shortcutFind, &QShortcut::activated, ui->actionSqlFind, &QAction::toggle);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ PlotDock::PlotDock(QWidget* parent)
|
||||
|
||||
// Connect signals
|
||||
connect(ui->treePlotColumns, &QTreeWidget::itemChanged, this, &PlotDock::on_treePlotColumns_itemChanged);
|
||||
connect(ui->plotWidget, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged()));
|
||||
connect(ui->plotWidget, &QCustomPlot::selectionChangedByUser, this, &PlotDock::selectionChanged);
|
||||
|
||||
// connect slots that takes care that when an axis is selected, only that direction can be dragged and zoomed:
|
||||
connect(ui->plotWidget, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
|
||||
connect(ui->plotWidget, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));
|
||||
connect(ui->plotWidget, &QCustomPlot::mousePress, this, &PlotDock::mousePress);
|
||||
connect(ui->plotWidget, &QCustomPlot::mouseWheel, this, &PlotDock::mouseWheel);
|
||||
|
||||
// Enable: click on items to select them, Ctrl+Click for multi-selection, mouse-wheel for zooming and mouse drag for
|
||||
// changing the visible range.
|
||||
@@ -61,7 +61,7 @@ PlotDock::PlotDock(QWidget* parent)
|
||||
ui->plotWidget->setSelectionRectMode(QCP::srmNone);
|
||||
|
||||
QShortcut* shortcutCopy = new QShortcut(QKeySequence::Copy, ui->plotWidget, nullptr, nullptr, Qt::WidgetShortcut);
|
||||
connect(shortcutCopy, SIGNAL(activated()), this, SLOT(copy()));
|
||||
connect(shortcutCopy, &QShortcut::activated, this, &PlotDock::copy);
|
||||
|
||||
QShortcut* shortcutPrint = new QShortcut(QKeySequence::Print, ui->plotWidget, nullptr, nullptr, Qt::WidgetShortcut);
|
||||
connect(shortcutPrint, &QShortcut::activated, this, &PlotDock::openPrintDialog);
|
||||
@@ -89,13 +89,13 @@ PlotDock::PlotDock(QWidget* parent)
|
||||
showLegendAction->setCheckable(true);
|
||||
m_contextMenu->addAction(showLegendAction);
|
||||
|
||||
connect(showLegendAction, SIGNAL(toggled(bool)), this, SLOT(toggleLegendVisible(bool)));
|
||||
connect(showLegendAction, &QAction::toggled, this, &PlotDock::toggleLegendVisible);
|
||||
|
||||
QAction* stackedBarsAction = new QAction(tr("Stacked bars"), m_contextMenu);
|
||||
stackedBarsAction->setCheckable(true);
|
||||
m_contextMenu->addAction(stackedBarsAction);
|
||||
|
||||
connect(stackedBarsAction, SIGNAL(toggled(bool)), this, SLOT(toggleStackedBars(bool)));
|
||||
connect(stackedBarsAction, &QAction::toggled, this, &PlotDock::toggleStackedBars);
|
||||
|
||||
connect(ui->plotWidget, &QTableView::customContextMenuRequested,
|
||||
[=](const QPoint& pos) {
|
||||
|
||||
@@ -29,14 +29,13 @@ SqlExecutionArea::SqlExecutionArea(DBBrowserDB& _db, QWidget* parent) :
|
||||
ui->findFrame->hide();
|
||||
|
||||
QShortcut* shortcutHideFind = new QShortcut(QKeySequence("ESC"), ui->findLineEdit);
|
||||
connect(shortcutHideFind, SIGNAL(activated()), this, SLOT(hideFindFrame()));
|
||||
connect(shortcutHideFind, &QShortcut::activated, this, &SqlExecutionArea::hideFindFrame);
|
||||
|
||||
connect(ui->findLineEdit, SIGNAL(textChanged(const QString &)),
|
||||
this, SLOT(findLineEdit_textChanged(const QString &)));
|
||||
connect(ui->previousToolButton, SIGNAL(clicked()), this, SLOT(findPrevious()));
|
||||
connect(ui->nextToolButton, SIGNAL(clicked()), this, SLOT(findNext()));
|
||||
connect(ui->findLineEdit, SIGNAL(returnPressed()), this, SLOT(findNext()));
|
||||
connect(ui->hideFindButton, SIGNAL(clicked()), this, SLOT(hideFindFrame()));
|
||||
connect(ui->findLineEdit, &QLineEdit::textChanged, this, &SqlExecutionArea::findLineEdit_textChanged);
|
||||
connect(ui->previousToolButton, &QToolButton::clicked, this, &SqlExecutionArea::findPrevious);
|
||||
connect(ui->nextToolButton, &QToolButton::clicked, this, &SqlExecutionArea::findNext);
|
||||
connect(ui->findLineEdit, &QLineEdit::returnPressed, this, &SqlExecutionArea::findNext);
|
||||
connect(ui->hideFindButton, &QToolButton::clicked, this, &SqlExecutionArea::hideFindFrame);
|
||||
|
||||
connect(&fileSystemWatch, &QFileSystemWatcher::fileChanged, this, &SqlExecutionArea::fileChanged);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user