mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Easy way of selecting columns (and rows)
Add shortcuts for selection of entire columns ("Ctrl+Space") or rows
("Shift+Space") from the current cell selection.
A new menu entry in the column header is also added, including the shortcut
legend for selecting the column.
This addresses #1717 and complements #1976 for quick formatting of entire
columns or rows.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include <QTextDocument>
|
||||
#include <QCompleter>
|
||||
#include <QComboBox>
|
||||
#include <QShortcut>
|
||||
|
||||
#include <limits>
|
||||
|
||||
@@ -380,6 +381,16 @@ ExtendedTableWidget::ExtendedTableWidget(QWidget* parent) :
|
||||
openPrintDialog();
|
||||
});
|
||||
|
||||
// Add spreadsheet shortcuts for selecting entire columns or entire rows.
|
||||
QShortcut* selectColumnShortcut = new QShortcut(QKeySequence("Ctrl+Space"), this);
|
||||
connect(selectColumnShortcut, &QShortcut::activated, [this]() {
|
||||
selectionModel()->select(QItemSelection(selectionModel()->selectedIndexes().constFirst(), selectionModel()->selectedIndexes().constLast()), QItemSelectionModel::Select | QItemSelectionModel::Columns);
|
||||
});
|
||||
QShortcut* selectRowShortcut = new QShortcut(QKeySequence("Shift+Space"), this);
|
||||
connect(selectRowShortcut, &QShortcut::activated, [this]() {
|
||||
selectionModel()->select(QItemSelection(selectionModel()->selectedIndexes().constFirst(), selectionModel()->selectedIndexes().constLast()), QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
});
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) && QT_VERSION < QT_VERSION_CHECK(5, 12, 3)
|
||||
// This work arounds QTBUG-73721 and it is applied only for the affected version range.
|
||||
setWordWrap(false);
|
||||
|
||||
@@ -56,6 +56,7 @@ TableBrowser::TableBrowser(QWidget* parent) :
|
||||
popupHeaderMenu->addAction(ui->actionShowRowidColumn);
|
||||
popupHeaderMenu->addAction(ui->actionHideColumns);
|
||||
popupHeaderMenu->addAction(ui->actionShowAllColumns);
|
||||
popupHeaderMenu->addAction(ui->actionSelectColumn);
|
||||
popupHeaderMenu->addSeparator();
|
||||
popupHeaderMenu->addAction(ui->actionUnlockViewEditing);
|
||||
popupHeaderMenu->addAction(ui->actionBrowseTableEditDisplayFormat);
|
||||
@@ -63,6 +64,10 @@ TableBrowser::TableBrowser(QWidget* parent) :
|
||||
popupHeaderMenu->addAction(ui->actionSetTableEncoding);
|
||||
popupHeaderMenu->addAction(ui->actionSetAllTablesEncoding);
|
||||
|
||||
connect(ui->actionSelectColumn, &QAction::triggered, [this]() {
|
||||
ui->dataTable->selectColumn(ui->actionBrowseTableEditDisplayFormat->property("clicked_column").toInt());
|
||||
});
|
||||
|
||||
// Set up shortcuts
|
||||
QShortcut* dittoRecordShortcut = new QShortcut(QKeySequence("Ctrl+\""), this);
|
||||
connect(dittoRecordShortcut, &QShortcut::activated, [this]() {
|
||||
|
||||
@@ -942,6 +942,14 @@
|
||||
<string>This button shows or hides the formatting toolbar of the Data Browser</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSelectColumn">
|
||||
<property name="text">
|
||||
<string>Select column</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Space</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
||||
Reference in New Issue
Block a user