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#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
123 PropertyLayoutSizeConstraint,
124#else
125 PropertyLayoutHorizontalSizeConstraint,
126 PropertyLayoutVerticalSizeConstraint,
127#endif
128 PropertyLayoutFieldGrowthPolicy,
129 PropertyLayoutRowWrapPolicy,
130 PropertyLayoutLabelAlignment,
131 PropertyLayoutFormAlignment,
132 PropertyLayoutBoxStretch,
133 PropertyLayoutGridRowStretch,
134 PropertyLayoutGridColumnStretch,
135 PropertyLayoutGridRowMinimumHeight,
136 PropertyLayoutGridColumnMinimumWidth,
137 PropertyBuddy,
138 PropertyAccessibility,
139 PropertyGeometry,
140 PropertyChecked,
141 PropertyCheckable,
142 PropertyVisible,
143 PropertyWindowTitle,
144 PropertyWindowIcon,
145 PropertyWindowFilePath,
146 PropertyWindowOpacity,
147 PropertyWindowIconText,
148 PropertyWindowModality,
149 PropertyWindowModified,
150 PropertyStyleSheet,
151 PropertyText
152 };
153
154 enum ObjectType { ObjectNone, ObjectLabel, ObjectLayout, ObjectLayoutWidget };
155 enum ObjectFlag
156 {
157 CheckableProperty = 0x1 // Has a "checked" property depending on "checkable"
158 };
159 Q_DECLARE_FLAGS(ObjectFlags, ObjectFlag)
160
161 static ObjectType objectTypeFromObject(const QObject *o);
162 static ObjectFlags objectFlagsFromObject(const QObject *o);
163 static PropertyType propertyTypeFromName(const QString &name);
164
165protected:
166 PropertyType propertyType(int index) const;
167 ObjectType objectType() const;
168
169private:
170 QDesignerPropertySheetPrivate *d;
171};
172
173/* Abstract base class for factories that register a property sheet that implements
174 * both QDesignerPropertySheetExtension and QDesignerDynamicPropertySheetExtension
175 * by multiple inheritance. The factory maintains ownership of
176 * the extension and returns it for both id's. */
177
179{
180 Q_OBJECT
181 Q_INTERFACES(QAbstractExtensionFactory)
182public:
183 explicit QDesignerAbstractPropertySheetFactory(QExtensionManager *parent = nullptr);
184 ~QDesignerAbstractPropertySheetFactory() override;
185
186 QObject *extension(QObject *object, const QString &iid) const override;
187
188private slots:
189 void objectDestroyed(QObject *object);
190
191private:
192 virtual QObject *createPropertySheet(QObject *qObject, QObject *parent) const = 0;
193
194 struct PropertySheetFactoryPrivate;
195 PropertySheetFactoryPrivate *m_impl;
196};
197
198/* Convenience factory template for property sheets that implement
199 * QDesignerPropertySheetExtension and QDesignerDynamicPropertySheetExtension
200 * by multiple inheritance. */
201
202template <class Object, class PropertySheet>
204public:
205 explicit QDesignerPropertySheetFactory(QExtensionManager *parent = nullptr);
206
207 static void registerExtension(QExtensionManager *mgr);
208
209private:
210 // Does a qobject_cast on the object.
211 QObject *createPropertySheet(QObject *qObject, QObject *parent) const override;
212};
213
214template <class Object, class PropertySheet>
215QDesignerPropertySheetFactory<Object, PropertySheet>::QDesignerPropertySheetFactory(QExtensionManager *parent) :
217{
218}
219
220template <class Object, class PropertySheet>
221QObject *QDesignerPropertySheetFactory<Object, PropertySheet>::createPropertySheet(QObject *qObject, QObject *parent) const
222{
223 Object *object = qobject_cast<Object *>(qObject);
224 if (!object)
225 return nullptr;
226 return new PropertySheet(object, parent);
227}
228
229template <class Object, class PropertySheet>
230void QDesignerPropertySheetFactory<Object, PropertySheet>::registerExtension(QExtensionManager *mgr)
231{
233 mgr->registerExtensions(factory, Q_TYPEID(QDesignerPropertySheetExtension));
234 mgr->registerExtensions(factory, Q_TYPEID(QDesignerDynamicPropertySheetExtension));
235}
236
237
238// Standard property sheet
239using QDesignerDefaultPropertySheetFactory = QDesignerPropertySheetFactory<QObject, QDesignerPropertySheet>;
240
241Q_DECLARE_OPERATORS_FOR_FLAGS(QDesignerPropertySheet::ObjectFlags)
242
243QT_END_NAMESPACE
244
245#endif // QDESIGNER_PROPERTYSHEET_H
QDesignerPropertySheetFactory(QExtensionManager *parent=nullptr)
static void registerExtension(QExtensionManager *mgr)
friend class QWidget
Definition qpainter.h:431
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
Auxiliary methods to store/retrieve settings.
#define QDESIGNER_SHARED_EXPORT