diff --git a/src/ExtendedTableWidget.cpp b/src/ExtendedTableWidget.cpp index d1c4f24b..7d15efc7 100644 --- a/src/ExtendedTableWidget.cpp +++ b/src/ExtendedTableWidget.cpp @@ -300,9 +300,8 @@ void ExtendedTableWidget::keyPressEvent(QKeyEvent* event) { copy(); return; - // Call a custom paste method when Ctrl-P is pressed - } else if(event->matches(QKeySequence::Paste)) - { + } else if(event->matches(QKeySequence::Paste)) { + // Call a custom paste method when Ctrl-P is pressed paste(); } else if(event->key() == Qt::Key_Tab && hasFocus() && selectedIndexes().count() == 1 && @@ -320,6 +319,10 @@ void ExtendedTableWidget::keyPressEvent(QKeyEvent* event) foreach(const QModelIndex& index, selectedIndexes()) model()->setData(index, ""); } + } else if(event->modifiers().testFlag(Qt::ControlModifier) && (event->key() == Qt::Key_PageUp || event->key() == Qt::Key_PageDown)) { + // When pressing Ctrl + Page up/down send a signal indicating the user wants to change the current table + emit switchTable(event->key() == Qt::Key_PageDown); + return; } // This prevents the current selection from being changed when pressing tab to move to the next filter. Note that this is in an 'if' condition, diff --git a/src/ExtendedTableWidget.h b/src/ExtendedTableWidget.h index 297527fa..6feadfe0 100644 --- a/src/ExtendedTableWidget.h +++ b/src/ExtendedTableWidget.h @@ -22,6 +22,7 @@ public: signals: void foreignKeyClicked(const QString& table, const QString& column, const QByteArray& value); + void switchTable(bool next); // 'next' parameter is set to true if next table should be selected and to false if previous table should be selected private: void copy(); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 7e18f9ea..9327ae79 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -225,6 +225,22 @@ void MainWindow::init() connect(ui->dockEdit, SIGNAL(visibilityChanged(bool)), this, SLOT(toggleEditDock(bool))); connect(&m_remoteDb, SIGNAL(openFile(QString)), this, SLOT(fileOpen(QString))); + // Lambda function for keyboard shortcuts for selecting next/previous table in Browse Data tab + connect(ui->dataTable, &ExtendedTableWidget::switchTable, [this](bool next) { + int index = ui->comboBrowseTable->currentIndex(); + int num_items = ui->comboBrowseTable->count(); + if(next) + { + if(++index >= num_items) + index = 0; + } else { + if(--index < 0) + index = num_items - 1; + } + ui->comboBrowseTable->setCurrentIndex(index); + populateTable(); + }); + // Set other window settings setAcceptDrops(true); setWindowTitle(QApplication::applicationName());