Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdesigner_propertysheet_p.h
Go to the documentation of this file.
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//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists for the convenience
9// of Qt Designer. This header
10// file may change from version to version without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef QDESIGNER_PROPERTYSHEET_H
16#define QDESIGNER_PROPERTYSHEET_H
17
20#include <QtDesigner/propertysheet.h>
21#include <QtDesigner/default_extensionfactory.h>
22#include <QtDesigner/qextensionmanager.h>
23
24#include <QtCore/qvariant.h>
25#include <QtCore/qpair.h>
26
27#include <QtCore/qpointer.h>
28
29QT_BEGIN_NAMESPACE
30
31class QLayout;
32class QDesignerFormEditorInterface;
34
35namespace qdesigner_internal
36{
37 class DesignerPixmapCache;
38 class DesignerIconCache;
39 class FormWindowBase;
40}
41
42class QDESIGNER_SHARED_EXPORT QDesignerPropertySheet: public QObject, public QDesignerPropertySheetExtension, public QDesignerDynamicPropertySheetExtension
43{
44 Q_OBJECT
45 Q_INTERFACES(QDesignerPropertySheetExtension QDesignerDynamicPropertySheetExtension)
46public:
47 explicit QDesignerPropertySheet(QObject *object, QObject *parent = nullptr);
48 ~QDesignerPropertySheet() override;
49
50 int indexOf(const QString &name) const override;
51
52 int count() const override;
53 QString propertyName(int index) const override;
54
55 QString propertyGroup(int index) const override;
56 void setPropertyGroup(int index, const QString &group) override;
57
58 bool hasReset(int index) const override;
59 bool reset(int index) override;
60
61 bool isAttribute(int index) const override;
62 void setAttribute(int index, bool b) override;
63
64 bool isVisible(int index) const override;
65 void setVisible(int index, bool b) override;
66
67 QVariant property(int index) const override;
68 void setProperty(int index, const QVariant &value) override;
69
70 bool isChanged(int index) const override;
71
72 void setChanged(int index, bool changed) override;
73
74 bool dynamicPropertiesAllowed() const override;
75 int addDynamicProperty(const QString &propertyName, const QVariant &value) override;
76 bool removeDynamicProperty(int index) override;
77 bool isDynamicProperty(int index) const override;
78 bool canAddDynamicProperty(const QString &propertyName) const override;
79
80 bool isDefaultDynamicProperty(int index) const;
81
82 bool isResourceProperty(int index) const;
83 QVariant defaultResourceProperty(int index) const;
84
85 qdesigner_internal::DesignerPixmapCache *pixmapCache() const;
86 void setPixmapCache(qdesigner_internal::DesignerPixmapCache *cache);
87 qdesigner_internal::DesignerIconCache *iconCache() const;
88 void setIconCache(qdesigner_internal::DesignerIconCache *cache);
89 int createFakeProperty(const QString &propertyName, const QVariant &value = QVariant());
90
91 bool isEnabled(int index) const override;
92 QObject *object() const;
93
94 static bool internalDynamicPropertiesEnabled();
95 static void setInternalDynamicPropertiesEnabled(bool v);
96
97 static QDesignerFormEditorInterface *formEditorForObject(QObject *o);
98
99protected:
100 bool isAdditionalProperty(int index) const;
101 bool isFakeProperty(int index) const;
102 QVariant resolvePropertyValue(int index, const QVariant &value) const;
103 QVariant metaProperty(int index) const;
104 void setFakeProperty(int index, const QVariant &value);
105 void clearFakeProperties();
106
107 bool isFakeLayoutProperty(int index) const;
108 bool isDynamic(int index) const;
109 qdesigner_internal::FormWindowBase *formWindowBase() const;
110 QDesignerFormEditorInterface *core() const;
111
112public:
113 enum PropertyType { PropertyNone,
114 PropertyLayoutObjectName,
115 PropertyLayoutLeftMargin,
116 PropertyLayoutTopMargin,
117 PropertyLayoutRightMargin,
118 PropertyLayoutBottomMargin,
119 PropertyLayoutSpacing,
120 PropertyLayoutHorizontalSpacing,
121 PropertyLayoutVerticalSpacing,
122 PropertyLayoutSizeConstraint,
123 PropertyLayoutFieldGrowthPolicy,
124 PropertyLayoutRowWrapPolicy,
125 PropertyLayoutLabelAlignment,
126 PropertyLayoutFormAlignment,
127 PropertyLayoutBoxStretch,
128 PropertyLayoutGridRowStretch,
129 PropertyLayoutGridColumnStretch,
130 PropertyLayoutGridRowMinimumHeight,
131 PropertyLayoutGridColumnMinimumWidth,
132 PropertyBuddy,
133 PropertyAccessibility,
134 PropertyGeometry,
135 PropertyChecked,
136 PropertyCheckable,
137 PropertyVisible,
138 PropertyWindowTitle,
139 PropertyWindowIcon,
140 PropertyWindowFilePath,
141 PropertyWindowOpacity,
142 PropertyWindowIconText,
143 PropertyWindowModality,
144 PropertyWindowModified,
145 PropertyStyleSheet,
146 PropertyText
147 };
148
149 enum ObjectType { ObjectNone, ObjectLabel, ObjectLayout, ObjectLayoutWidget };
150 enum ObjectFlag
151 {
152 CheckableProperty = 0x1 // Has a "checked" property depending on "checkable"
153 };
154 Q_DECLARE_FLAGS(ObjectFlags, ObjectFlag)
155
156 static ObjectType objectTypeFromObject(const QObject *o);
157 static ObjectFlags objectFlagsFromObject(const QObject *o);
158 static PropertyType propertyTypeFromName(const QString &name);
159
160protected:
161 PropertyType propertyType(int index) const;
162 ObjectType objectType() const;
163
164private:
165 QDesignerPropertySheetPrivate *d;
166};
167
168/* Abstract base class for factories that register a property sheet that implements
169 * both QDesignerPropertySheetExtension and QDesignerDynamicPropertySheetExtension
170 * by multiple inheritance. The factory maintains ownership of
171 * the extension and returns it for both id's. */
172
174{
175 Q_OBJECT
176 Q_INTERFACES(QAbstractExtensionFactory)
177public:
178 explicit QDesignerAbstractPropertySheetFactory(QExtensionManager *parent = nullptr);
179 ~QDesignerAbstractPropertySheetFactory() override;
180
181 QObject *extension(QObject *object, const QString &iid) const override;
182
183private slots:
184 void objectDestroyed(QObject *object);
185
186private:
187 virtual QObject *createPropertySheet(QObject *qObject, QObject *parent) const = 0;
188
189 struct PropertySheetFactoryPrivate;
190 PropertySheetFactoryPrivate *m_impl;
191};
192
193/* Convenience factory template for property sheets that implement
194 * QDesignerPropertySheetExtension and QDesignerDynamicPropertySheetExtension
195 * by multiple inheritance. */
196
197template <class Object, class PropertySheet>
199public:
200 explicit QDesignerPropertySheetFactory(QExtensionManager *parent = nullptr);
201
202 static void registerExtension(QExtensionManager *mgr);
203
204private:
205 // Does a qobject_cast on the object.
206 QObject *createPropertySheet(QObject *qObject, QObject *parent) const override;
207};
208
209template <class Object, class PropertySheet>
210QDesignerPropertySheetFactory<Object, PropertySheet>::QDesignerPropertySheetFactory(QExtensionManager *parent) :
212{
213}
214
215template <class Object, class PropertySheet>
216QObject *QDesignerPropertySheetFactory<Object, PropertySheet>::createPropertySheet(QObject *qObject, QObject *parent) const
217{
218 Object *object = qobject_cast<Object *>(qObject);
219 if (!object)
220 return nullptr;
221 return new PropertySheet(object, parent);
222}
223
224template <class Object, class PropertySheet>
225void QDesignerPropertySheetFactory<Object, PropertySheet>::registerExtension(QExtensionManager *mgr)
226{
228 mgr->registerExtensions(factory, Q_TYPEID(QDesignerPropertySheetExtension));
229 mgr->registerExtensions(factory, Q_TYPEID(QDesignerDynamicPropertySheetExtension));
230}
231
232
233// Standard property sheet
234using QDesignerDefaultPropertySheetFactory = QDesignerPropertySheetFactory<QObject, QDesignerPropertySheet>;
235
236Q_DECLARE_OPERATORS_FOR_FLAGS(QDesignerPropertySheet::ObjectFlags)
237
238QT_END_NAMESPACE
239
240#endif // QDESIGNER_PROPERTYSHEET_H
QDesignerPropertySheetFactory(QExtensionManager *parent=nullptr)
static void registerExtension(QExtensionManager *mgr)
friend class QWidget
Definition qpainter.h:421
FormEditorOptionsPage(QDesignerFormEditorInterface *core)
QWidget * createPage(QWidget *parent) override
FormEditor(const QStringList &pluginPaths, QObject *parent=nullptr)
QWidget * widget(int index) const override
void insertWidget(int index, QWidget *widget) override
void addWidget(QWidget *widget) override
static void positionNewMdiChild(const QWidget *area, QWidget *mdiChild)
QWidget * widget(int index) const override
void insertWidget(int index, QWidget *widget) override
void setProperty(int index, const QVariant &value) override
static bool checkProperty(const QString &propertyName)
QVariant property(int index) const override
QWidget * createPage(QWidget *parent) override
static QString chooseTemplatePath(QDesignerFormEditorInterface *core, QWidget *parent)
#define QT_FORMEDITOR_EXPORT
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
#define QDESIGNER_SHARED_EXPORT