| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
| 3 | |
| 4 | #ifndef TABLEWIDGETEDITOR_H |
| 5 | #define TABLEWIDGETEDITOR_H |
| 6 | |
| 7 | #include "ui_tablewidgeteditor.h" |
| 8 | |
| 9 | #include "listwidgeteditor.h" |
| 10 | |
| 11 | #include <QtWidgets/qdialog.h> |
| 12 | |
| 13 | QT_BEGIN_NAMESPACE |
| 14 | |
| 15 | class QTableWidget; |
| 16 | class QDesignerFormWindowInterface; |
| 17 | |
| 18 | namespace qdesigner_internal { |
| 19 | |
| 20 | class FormWindowBase; |
| 21 | class PropertySheetIconValue; |
| 22 | |
| 23 | class TableWidgetEditor: public AbstractItemEditor |
| 24 | { |
| 25 | Q_OBJECT |
| 26 | public: |
| 27 | explicit TableWidgetEditor(QDesignerFormWindowInterface *form, QDialog *dialog); |
| 28 | |
| 29 | TableWidgetContents fillContentsFromTableWidget(QTableWidget *tableWidget); |
| 30 | TableWidgetContents contents() const; |
| 31 | |
| 32 | private slots: |
| 33 | |
| 34 | void tableWidgetCurrentCellChanged(int currentRow, int currentCol); |
| 35 | void tableWidgetItemChanged(QTableWidgetItem *item); |
| 36 | |
| 37 | void columnEditorIndexChanged(int idx); |
| 38 | void columnEditorItemChanged(int idx, int role, const QVariant &v); |
| 39 | |
| 40 | void columnEditorItemInserted(int idx); |
| 41 | void columnEditorItemDeleted(int idx); |
| 42 | void columnEditorItemMovedUp(int idx); |
| 43 | void columnEditorItemMovedDown(int idx); |
| 44 | |
| 45 | void rowEditorIndexChanged(int idx); |
| 46 | void rowEditorItemChanged(int idx, int role, const QVariant &v); |
| 47 | |
| 48 | void rowEditorItemInserted(int idx); |
| 49 | void rowEditorItemDeleted(int idx); |
| 50 | void rowEditorItemMovedUp(int idx); |
| 51 | void rowEditorItemMovedDown(int idx); |
| 52 | |
| 53 | void togglePropertyBrowser(); |
| 54 | |
| 55 | void cacheReloaded(); |
| 56 | |
| 57 | protected: |
| 58 | void setItemData(int role, const QVariant &v) override; |
| 59 | QVariant getItemData(int role) const override; |
| 60 | int defaultItemFlags() const override; |
| 61 | |
| 62 | private: |
| 63 | void setPropertyBrowserVisible(bool v); |
| 64 | void updateEditor(); |
| 65 | void moveColumnsLeft(int fromColumn, int toColumn); |
| 66 | void moveColumnsRight(int fromColumn, int toColumn); |
| 67 | void moveRowsUp(int fromRow, int toRow); |
| 68 | void moveRowsDown(int fromRow, int toRow); |
| 69 | |
| 70 | Ui::TableWidgetEditor ui; |
| 71 | ItemListEditor *m_rowEditor; |
| 72 | ItemListEditor *m_columnEditor; |
| 73 | bool m_updatingBrowser; |
| 74 | }; |
| 75 | |
| 76 | class TableWidgetEditorDialog : public QDialog |
| 77 | { |
| 78 | Q_OBJECT |
| 79 | public: |
| 80 | explicit TableWidgetEditorDialog(QDesignerFormWindowInterface *form, QWidget *parent); |
| 81 | |
| 82 | TableWidgetContents fillContentsFromTableWidget(QTableWidget *tableWidget); |
| 83 | TableWidgetContents contents() const; |
| 84 | |
| 85 | private: |
| 86 | TableWidgetEditor m_editor; |
| 87 | }; |
| 88 | |
| 89 | } // namespace qdesigner_internal |
| 90 | |
| 91 | QT_END_NAMESPACE |
| 92 | |
| 93 | #endif // TABLEWIDGETEDITOR_H |
| 94 | |