Skip to content

Commit 2a9c8ce

Browse files
committed
Add view menu entry and keyboard shortcut to clear table selection
1 parent 88c2db7 commit 2a9c8ce

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/main/main_window.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ void MainWindow::connectUI()
172172
connect(autoResizeColumnsAction, &QAction::triggered, this, &MainWindow::handle_autoResizeColumns);
173173
connect(resetColumnOrderAction, &QAction::triggered, this, &MainWindow::handle_resetColumnOrder);
174174
connect(restoreHiddenColumnsAction, &QAction::triggered, this, &MainWindow::handle_restoreHiddenColumns);
175+
connect(clearTableSelectionAction, &QAction::triggered, this, &MainWindow::handle_clearTableSelection);
175176
// Menu "New"
176177
for (const ItemTypeMapper* const mapper : typesHandler->getAllMappers()) {
177178
auto newFunction = [this, mapper] () {
@@ -1467,6 +1468,19 @@ void MainWindow::handle_restoreHiddenColumns()
14671468
mapper->compTable->updateBothBuffers();
14681469
}
14691470

1471+
/**
1472+
* Event handler for the "clear table selection" action in the view menu.
1473+
*
1474+
* Clears the selection of the currently active table.
1475+
*/
1476+
void MainWindow::handle_clearTableSelection()
1477+
{
1478+
const ItemTypeMapper* const mapper = getActiveMapper();
1479+
assert(mapper);
1480+
1481+
mapper->tableView->selectionModel()->clearSelection();
1482+
}
1483+
14701484

14711485

14721486
// TOOLS MENU ACTION HANDLERS

src/main/main_window.h

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ private slots:
164164
void handle_autoResizeColumns();
165165
void handle_resetColumnOrder();
166166
void handle_restoreHiddenColumns();
167+
void handle_clearTableSelection();
167168
// Tools menu action handlers
168169
void handle_relocatePhotos();
169170
void handle_exportData();

src/ui/main_window.ui

+10
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,8 @@
12891289
<addaction name="autoResizeColumnsAction"/>
12901290
<addaction name="resetColumnOrderAction"/>
12911291
<addaction name="restoreHiddenColumnsAction"/>
1292+
<addaction name="separator"/>
1293+
<addaction name="clearTableSelectionAction"/>
12921294
</widget>
12931295
<widget class="QMenu" name="newMenu">
12941296
<property name="title">
@@ -1506,6 +1508,14 @@
15061508
<string>Show on all tabs</string>
15071509
</property>
15081510
</action>
1511+
<action name="clearTableSelectionAction">
1512+
<property name="text">
1513+
<string>Clear table selection</string>
1514+
</property>
1515+
<property name="shortcut">
1516+
<string notr="true">Esc</string>
1517+
</property>
1518+
</action>
15091519
</widget>
15101520
<customwidgets>
15111521
<customwidget>

0 commit comments

Comments
 (0)