Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
New shortcut for Copy with Headers and some self-documented shortcuts
Ctrl+H invokes the Copy with Headersers action in the Extended Table Widget
as suggested in #1058.

The following options in context menu display now their shortcuts:
Set to Null, Copy, Copy with Headers and Paste.

Some other shortcuts are now displayed in the corresponding tooltips.
  • Loading branch information
mgrojo committed Nov 12, 2017
1 parent d8aeae1 commit 9ce4b23
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/EditDialog.ui
Expand Up @@ -160,8 +160,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>83</width>
<height>40</height>
<width>98</width>
<height>35</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
Expand Down Expand Up @@ -212,6 +212,9 @@
</item>
<item>
<widget class="QPushButton" name="buttonApply">
<property name="toolTip">
<string>Apply data to cell [Ctrl+Return]</string>
</property>
<property name="text">
<string>Apply</string>
</property>
Expand Down
14 changes: 12 additions & 2 deletions src/ExtendedTableWidget.cpp
Expand Up @@ -95,6 +95,13 @@ ExtendedTableWidget::ExtendedTableWidget(QWidget* parent) :
m_contextMenu->addAction(pasteAction);
setContextMenuPolicy(Qt::CustomContextMenu);

// This is only for displaying the shortcut in the context menu.
// An entry in keyPressEvent is still needed.
nullAction->setShortcut(QKeySequence(tr("Alt+Del")));
copyAction->setShortcut(QKeySequence::Copy);
copyWithHeadersAction->setShortcut(QKeySequence(tr("Ctrl+H")));
pasteAction->setShortcut(QKeySequence::Paste);

// Set up context menu actions
connect(this, &QTableView::customContextMenuRequested,
[=](const QPoint& pos)
Expand Down Expand Up @@ -389,11 +396,14 @@ void ExtendedTableWidget::keyPressEvent(QKeyEvent* event)
// Call a custom copy method when Ctrl-C is pressed
if(event->matches(QKeySequence::Copy))
{
copy();
copy(false);
return;
} else if(event->matches(QKeySequence::Paste)) {
// Call a custom paste method when Ctrl-P is pressed
// Call a custom paste method when Ctrl-V is pressed
paste();
} else if(event->modifiers().testFlag(Qt::ControlModifier) && (event->key() == Qt::Key_H)) {
// Call copy with headers when Ctrl-H is pressed
copy(true);
} else if(event->key() == Qt::Key_Tab && hasFocus() &&
selectedIndexes().count() == 1 &&
selectedIndexes().at(0).row() == model()->rowCount()-1 && selectedIndexes().at(0).column() == model()->columnCount()-1) {
Expand Down
4 changes: 2 additions & 2 deletions src/MainWindow.ui
Expand Up @@ -22,7 +22,7 @@
<item>
<widget class="QTabWidget" name="mainTab">
<property name="currentIndex">
<number>0</number>
<number>1</number>

This comment has been minimized.

Copy link
@MKleusberg

MKleusberg Nov 17, 2017

Member

Just noted that the default tab was changed here 😉

This comment has been minimized.

Copy link
@mgrojo

mgrojo Nov 17, 2017

Author Member

I struggle with qtcreator. I don't know why it makes some changes, so I will review and undo if necessary every line it changes 😃

This comment has been minimized.

Copy link
@MKleusberg

MKleusberg Nov 17, 2017

Member

No worries 😄

This comment has been minimized.

Copy link
@justinclift

justinclift Nov 17, 2017

Member

@mgrojo I think that's from when a person changes the tab in the UI (even just to look at it in the UI), then Qt Creator changes the tab in the file. Which can be a pain, as having to switch back to the correct tab before saving is something I used to forget fairly often.

The way I personally catch stuff like this is by manually reviewing all (text) file changes before pushing a commit. That seems to catch most stuff. 😄

This comment has been minimized.

Copy link
@MKleusberg

MKleusberg Nov 18, 2017

Member

Yep, that's exactly how I do it as well 😃

I still remember by the way that until maybe one or two years ago DB4S would crash upon startup if the Browse Data tab was selected as the default tab like here. So we have definitely improved from there 😉

</property>
<widget class="QWidget" name="structure">
<attribute name="title">
Expand Down Expand Up @@ -130,7 +130,7 @@
<item>
<widget class="QToolButton" name="buttonRefresh">
<property name="toolTip">
<string>Refresh the data in the selected table.</string>
<string>Refresh the data in the selected table [F5, Ctrl+R]</string>
</property>
<property name="whatsThis">
<string>This button refreshes the data in the currently selected table.</string>
Expand Down

0 comments on commit 9ce4b23

Please sign in to comment.