1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Designer of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
21 | ** included in the packaging of this file. Please review the following |
22 | ** information to ensure the GNU General Public License requirements will |
23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
24 | ** |
25 | ** $QT_END_LICENSE$ |
26 | ** |
27 | ****************************************************************************/ |
28 | |
29 | #ifndef TABLEWIDGETEDITOR_H |
30 | #define TABLEWIDGETEDITOR_H |
31 | |
32 | #include "ui_tablewidgeteditor.h" |
33 | |
34 | #include "listwidgeteditor.h" |
35 | |
36 | #include <QtWidgets/qdialog.h> |
37 | |
38 | QT_BEGIN_NAMESPACE |
39 | |
40 | class QTableWidget; |
41 | class QDesignerFormWindowInterface; |
42 | |
43 | namespace qdesigner_internal { |
44 | |
45 | class FormWindowBase; |
46 | class PropertySheetIconValue; |
47 | |
48 | class TableWidgetEditor: public AbstractItemEditor |
49 | { |
50 | Q_OBJECT |
51 | public: |
52 | explicit TableWidgetEditor(QDesignerFormWindowInterface *form, QDialog *dialog); |
53 | |
54 | TableWidgetContents fillContentsFromTableWidget(QTableWidget *tableWidget); |
55 | TableWidgetContents contents() const; |
56 | |
57 | private slots: |
58 | |
59 | void on_tableWidget_currentCellChanged(int currentRow, int currentCol, int, int); |
60 | void on_tableWidget_itemChanged(QTableWidgetItem *item); |
61 | |
62 | void on_columnEditor_indexChanged(int idx); |
63 | void on_columnEditor_itemChanged(int idx, int role, const QVariant &v); |
64 | |
65 | void on_columnEditor_itemInserted(int idx); |
66 | void on_columnEditor_itemDeleted(int idx); |
67 | void on_columnEditor_itemMovedUp(int idx); |
68 | void on_columnEditor_itemMovedDown(int idx); |
69 | |
70 | void on_rowEditor_indexChanged(int idx); |
71 | void on_rowEditor_itemChanged(int idx, int role, const QVariant &v); |
72 | |
73 | void on_rowEditor_itemInserted(int idx); |
74 | void on_rowEditor_itemDeleted(int idx); |
75 | void on_rowEditor_itemMovedUp(int idx); |
76 | void on_rowEditor_itemMovedDown(int idx); |
77 | |
78 | void togglePropertyBrowser(); |
79 | |
80 | void cacheReloaded(); |
81 | |
82 | protected: |
83 | void setItemData(int role, const QVariant &v) override; |
84 | QVariant getItemData(int role) const override; |
85 | int defaultItemFlags() const override; |
86 | |
87 | private: |
88 | void setPropertyBrowserVisible(bool v); |
89 | void updateEditor(); |
90 | void moveColumnsLeft(int fromColumn, int toColumn); |
91 | void moveColumnsRight(int fromColumn, int toColumn); |
92 | void moveRowsUp(int fromRow, int toRow); |
93 | void moveRowsDown(int fromRow, int toRow); |
94 | |
95 | Ui::TableWidgetEditor ui; |
96 | ItemListEditor *m_rowEditor; |
97 | ItemListEditor *m_columnEditor; |
98 | bool m_updatingBrowser; |
99 | }; |
100 | |
101 | class TableWidgetEditorDialog : public QDialog |
102 | { |
103 | Q_OBJECT |
104 | public: |
105 | explicit TableWidgetEditorDialog(QDesignerFormWindowInterface *form, QWidget *parent); |
106 | |
107 | TableWidgetContents fillContentsFromTableWidget(QTableWidget *tableWidget); |
108 | TableWidgetContents contents() const; |
109 | |
110 | private: |
111 | TableWidgetEditor m_editor; |
112 | }; |
113 | |
114 | } // namespace qdesigner_internal |
115 | |
116 | QT_END_NAMESPACE |
117 | |
118 | #endif // TABLEWIDGETEDITOR_H |
119 | |