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//
30// W A R N I N G
31// -------------
32//
33// This file is not part of the Qt API. It exists for the convenience
34// of Qt Designer. This header
35// file may change from version to version without notice, or even be removed.
36//
37// We mean it.
38//
39
40#ifndef PROMOTIONEDITORDIALOG_H
41#define PROMOTIONEDITORDIALOG_H
42
43#include <QtWidgets/qdialog.h>
44#include <QtWidgets/qgroupbox.h>
45
46QT_BEGIN_NAMESPACE
47
48class QDesignerFormEditorInterface;
49class QDesignerFormWindowInterface;
50class QDesignerPromotionInterface;
51class QDesignerWidgetDataBaseItemInterface;
52
53class QTreeView;
54class QPushButton;
55class QItemSelection;
56class QDialogButtonBox;
57class QComboBox;
58class QLineEdit;
59class QCheckBox;
60
61namespace qdesigner_internal {
62 struct PromotionParameters;
63 class PromotionModel;
64
65
66 // Panel for adding a new promoted class. Separate class for code cleanliness.
67 class NewPromotedClassPanel : public QGroupBox {
68 Q_OBJECT
69 public:
70 explicit NewPromotedClassPanel(const QStringList &baseClasses,
71 int selectedBaseClass = -1,
72 QWidget *parent = nullptr);
73
74 QString promotedHeaderSuffix() const { return m_promotedHeaderSuffix; }
75 void setPromotedHeaderSuffix(const QString &s) { m_promotedHeaderSuffix = s; }
76
77 bool isPromotedHeaderLowerCase() const { return m_promotedHeaderLowerCase; }
78 void setPromotedHeaderLowerCase(bool l) { m_promotedHeaderLowerCase = l; }
79
80 signals:
81 void newPromotedClass(const PromotionParameters &, bool *ok);
82
83 public slots:
84 void grabFocus();
85 void chooseBaseClass(const QString &);
86 private slots:
87 void slotNameChanged(const QString &);
88 void slotIncludeFileChanged(const QString &);
89 void slotAdd();
90 void slotReset();
91
92 private:
93 PromotionParameters promotionParameters() const;
94 void enableButtons();
95
96 QString m_promotedHeaderSuffix;
97 bool m_promotedHeaderLowerCase;
98
99 QComboBox *m_baseClassCombo;
100 QLineEdit *m_classNameEdit;
101 QLineEdit *m_includeFileEdit;
102 QCheckBox *m_globalIncludeCheckBox;
103 QPushButton *m_addButton;
104 };
105
106 // Dialog for editing promoted classes.
107 class QDesignerPromotionDialog : public QDialog {
108 Q_OBJECT
109
110 public:
111 enum Mode { ModeEdit, ModeEditChooseClass };
112
113 explicit QDesignerPromotionDialog(QDesignerFormEditorInterface *core,
114 QWidget *parent = nullptr,
115 const QString &promotableWidgetClassName = QString(),
116 QString *promoteTo = nullptr);
117 // Return an alphabetically ordered list of base class names for adding new classes.
118 static const QStringList &baseClassNames(const QDesignerPromotionInterface *promotion);
119
120 signals:
121 void selectedBaseClassChanged(const QString &);
122 private slots:
123 void slotRemove();
124 void slotAcceptPromoteTo();
125 void slotSelectionChanged(const QItemSelection &, const QItemSelection &);
126 void slotNewPromotedClass(const PromotionParameters &, bool *ok);
127
128 void slotIncludeFileChanged(QDesignerWidgetDataBaseItemInterface *, const QString &includeFile);
129 void slotClassNameChanged(QDesignerWidgetDataBaseItemInterface *, const QString &newName);
130 void slotUpdateFromWidgetDatabase();
131 void slotTreeViewContextMenu(const QPoint &);
132 void slotEditSignalsSlots();
133
134 private:
135 QDialogButtonBox *createButtonBox();
136 void delayedUpdateFromWidgetDatabase();
137 // Return item at model index and a combination of flags or 0.
138 enum { Referenced = 1, CanPromote = 2 };
139 QDesignerWidgetDataBaseItemInterface *databaseItemAt(const QItemSelection &, unsigned &flags) const;
140 void displayError(const QString &message);
141
142 const Mode m_mode;
143 const QString m_promotableWidgetClassName;
144 QDesignerFormEditorInterface *m_core;
145 QString *m_promoteTo;
146 QDesignerPromotionInterface *m_promotion;
147 PromotionModel *m_model;
148 QTreeView *m_treeView;
149 QDialogButtonBox *m_buttonBox;
150 QPushButton *m_removeButton;
151 QString m_lastSelectedBaseClass;
152 };
153} // namespace qdesigner_internal
154
155QT_END_NAMESPACE
156
157#endif // PROMOTIONEDITORDIALOG_H
158

source code of qttools/src/designer/src/lib/shared/qdesigner_promotiondialog_p.h