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 TREEWIDGETEDITOR_H
30#define TREEWIDGETEDITOR_H
31
32#include "ui_treewidgeteditor.h"
33
34#include "listwidgeteditor.h"
35
36#include <QtWidgets/qdialog.h>
37
38QT_BEGIN_NAMESPACE
39
40class QTreeWidget;
41class QDesignerFormWindowInterface;
42
43namespace qdesigner_internal {
44
45class FormWindowBase;
46class PropertySheetIconValue;
47
48class TreeWidgetEditor: public AbstractItemEditor
49{
50 Q_OBJECT
51public:
52 explicit TreeWidgetEditor(QDesignerFormWindowInterface *form, QDialog *dialog);
53
54 TreeWidgetContents fillContentsFromTreeWidget(QTreeWidget *treeWidget);
55 TreeWidgetContents contents() const;
56
57private slots:
58 void on_newItemButton_clicked();
59 void on_newSubItemButton_clicked();
60 void on_deleteItemButton_clicked();
61 void on_moveItemUpButton_clicked();
62 void on_moveItemDownButton_clicked();
63 void on_moveItemRightButton_clicked();
64 void on_moveItemLeftButton_clicked();
65
66 void on_treeWidget_currentItemChanged();
67 void on_treeWidget_itemChanged(QTreeWidgetItem *item, int column);
68
69 void on_columnEditor_indexChanged(int idx);
70 void on_columnEditor_itemChanged(int idx, int role, const QVariant &v);
71
72 void on_columnEditor_itemInserted(int idx);
73 void on_columnEditor_itemDeleted(int idx);
74 void on_columnEditor_itemMovedUp(int idx);
75 void on_columnEditor_itemMovedDown(int idx);
76
77 void togglePropertyBrowser();
78 void cacheReloaded();
79
80protected:
81 void setItemData(int role, const QVariant &v) override;
82 QVariant getItemData(int role) const override;
83 int defaultItemFlags() const override;
84
85private:
86 void setPropertyBrowserVisible(bool v);
87 QtVariantProperty *setupPropertyGroup(const QString &title, PropertyDefinition *propDefs);
88 void updateEditor();
89 void moveColumnItems(const PropertyDefinition *propList, QTreeWidgetItem *item, int fromColumn, int toColumn, int step);
90 void moveColumns(int fromColumn, int toColumn, int step);
91 void moveColumnsLeft(int fromColumn, int toColumn);
92 void moveColumnsRight(int fromColumn, int toColumn);
93 void closeEditors();
94
95 Ui::TreeWidgetEditor ui;
96 ItemListEditor *m_columnEditor;
97 bool m_updatingBrowser;
98};
99
100class TreeWidgetEditorDialog : public QDialog
101{
102 Q_OBJECT
103public:
104 explicit TreeWidgetEditorDialog(QDesignerFormWindowInterface *form, QWidget *parent);
105
106 TreeWidgetContents fillContentsFromTreeWidget(QTreeWidget *treeWidget);
107 TreeWidgetContents contents() const;
108
109private:
110 TreeWidgetEditor m_editor;
111};
112
113} // namespace qdesigner_internal
114
115QT_END_NAMESPACE
116
117#endif // TREEWIDGETEDITOR_H
118

source code of qttools/src/designer/src/components/taskmenu/treewidgeteditor.h