Implement an extended table widget to add proper copy to clipboard su… · joedf/sqlitebrowser@d9cd62b · GitHub
Skip to content

Commit d9cd62b

Browse files
committed
Implement an extended table widget to add proper copy to clipboard support
Extend the standard table widget class to make it possible to copy multiple cells to the clipboard.
1 parent 1daaac9 commit d9cd62b

4 files changed

Lines changed: 96 additions & 6 deletions

File tree

‎src/ExtendedTableWidget.cpp‎

Lines changed: 61 additions & 0 deletions

‎src/ExtendedTableWidget.h‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef __EXTENDEDTABLEWIDGET_H__
2+
#define __EXTENDEDTABLEWIDGET_H__
3+
4+
#include <QTableWidget>
5+
6+
class ExtendedTableWidget : public QTableWidget
7+
{
8+
Q_OBJECT
9+
10+
public:
11+
explicit ExtendedTableWidget(int rows, int columns, QWidget* parent = 0);
12+
explicit ExtendedTableWidget(QWidget* parent = 0);
13+
14+
private:
15+
void copy();
16+
17+
protected:
18+
virtual void keyPressEvent(QKeyEvent* event);
19+
};
20+
21+
#endif

‎src/MainWindow.ui‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@
205205
</layout>
206206
</item>
207207
<item>
208-
<widget class="QTableWidget" name="dataTable">
208+
<widget class="ExtendedTableWidget" name="dataTable">
209209
<property name="whatsThis">
210210
<string>This is the database view. You can double-click any record to edit its contents in the cell editor window.</string>
211211
</property>
212212
<property name="selectionMode">
213-
<enum>QAbstractItemView::SingleSelection</enum>
213+
<enum>QAbstractItemView::ExtendedSelection</enum>
214214
</property>
215215
<property name="horizontalScrollMode">
216216
<enum>QAbstractItemView::ScrollPerPixel</enum>
@@ -316,8 +316,8 @@
316316
<rect>
317317
<x>0</x>
318318
<y>0</y>
319-
<width>763</width>
320-
<height>494</height>
319+
<width>278</width>
320+
<height>444</height>
321321
</rect>
322322
</property>
323323
<layout class="QFormLayout" name="formLayout">
@@ -1399,6 +1399,11 @@
13991399
<extends>QTextEdit</extends>
14001400
<header>sqltextedit.h</header>
14011401
</customwidget>
1402+
<customwidget>
1403+
<class>ExtendedTableWidget</class>
1404+
<extends>QTableWidget</extends>
1405+
<header>ExtendedTableWidget.h</header>
1406+
</customwidget>
14021407
</customwidgets>
14031408
<tabstops>
14041409
<tabstop>dbTreeWidget</tabstop>
@@ -2169,5 +2174,6 @@
21692174
<slot>deleteField()</slot>
21702175
<slot>loadPragmas()</slot>
21712176
<slot>savePragmas()</slot>
2177+
<slot>copy()</slot>
21722178
</slots>
21732179
</ui>

‎src/src.pro‎

Lines changed: 4 additions & 2 deletions

0 commit comments

Comments
 (0)