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
propertyeditor.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// Qt-Security score:significant reason:default
4
5#ifndef PROPERTYEDITOR_H
6#define PROPERTYEDITOR_H
7
9#include <qdesigner_propertyeditor_p.h>
10
11#include <QtCore/qlist.h>
12#include <QtCore/qmap.h>
13#include <QtCore/qpointer.h>
14#include <QtCore/qset.h>
15
17
18class DomProperty;
21class QLineEdit;
22
26class QtProperty;
28class QtBrowserItem;
29class QStackedWidget;
30
31namespace qdesigner_internal {
32
33class StringProperty;
36class ElidingLabel;
37
39{
41public:
44
45 QDesignerFormEditorInterface *core() const override;
46
47 bool isReadOnly() const override;
48 void setReadOnly(bool readOnly) override;
49 void setPropertyValue(const QString &name, const QVariant &value, bool changed = true) override;
51
52 void setObject(QObject *object) override;
53
55
56 QObject *object() const override
57 { return m_object; }
58
59 QString currentPropertyName() const override;
60
61protected:
62
63 bool event(QEvent *event) override;
64
65private slots:
67 void slotValueChanged(QtProperty *property, const QVariant &value, bool enableSubPropertyHandling);
68 void slotViewTriggered(QAction *action);
69 void slotAddDynamicProperty(QAction *action);
70 void slotRemoveDynamicProperty();
71 void slotSorting(bool sort);
72 void slotColoring(bool color);
73 void slotCurrentItemChanged(QtBrowserItem*);
74 void setFilter(const QString &pattern);
75
76private:
77 void updateBrowserValue(QtVariantProperty *property, const QVariant &value);
78 void updateToolBarLabel();
79 int toBrowserType(const QVariant &value, const QString &propertyName) const;
80 QString removeScope(const QString &value) const;
81 QDesignerMetaDataBaseItemInterface *metaDataBaseItem() const;
82 void setupStringProperty(QtVariantProperty *property, bool isMainContainer);
83 void setupPaletteProperty(QtVariantProperty *property);
84 QString realClassName(QObject *object) const;
85 void storeExpansionState();
86 void applyExpansionState();
87 void storePropertiesExpansionState(const QList<QtBrowserItem *> &items);
88 void applyPropertiesExpansionState(const QList<QtBrowserItem *> &items);
89 void applyFilter();
90 int applyPropertiesFilter(const QList<QtBrowserItem *> &items);
91 void setExpanded(QtBrowserItem *item, bool expanded);
92 bool isExpanded(QtBrowserItem *item) const;
93 void setItemVisible(QtBrowserItem *item, bool visible);
94 bool isItemVisible(QtBrowserItem *item) const;
95 void collapseAll();
96 void clearView();
97 void fillView();
98 bool isLayoutGroup(QtProperty *group) const;
99 void updateColors();
100 void updateForegroundBrightness();
101 QColor propertyColor(QtProperty *property) const;
102 void updateActionsState();
103 QtBrowserItem *nonFakePropertyBrowserItem(QtBrowserItem *item) const;
104 void saveSettings() const;
105 void editProperty(const QString &name);
106 bool isDynamicProperty(const QtBrowserItem* item) const;
107
108 struct Strings {
109 Strings();
110 QSet<QString> m_alignmentProperties;
111 const QString m_fontProperty;
112 const QString m_qLayoutWidget;
113 const QString m_designerPrefix;
114 const QString m_layout;
115 const QString m_validationModeAttribute;
116 const QString m_fontAttribute;
117 const QString m_superPaletteAttribute;
118 const QString m_enumNamesAttribute;
119 const QString m_resettableAttribute;
120 const QString m_flagsAttribute;
121 };
122
123 const Strings m_strings;
124 QDesignerFormEditorInterface *m_core;
125 QDesignerPropertySheetExtension *m_propertySheet = nullptr;
126 QtAbstractPropertyBrowser *m_currentBrowser = nullptr;
127 QtButtonPropertyBrowser *m_buttonBrowser;
128 QtTreePropertyBrowser *m_treeBrowser = nullptr;
129 DesignerPropertyManager *m_propertyManager;
130 DesignerEditorFactory *m_treeFactory;
131 DesignerEditorFactory *m_groupFactory;
132 QPointer<QObject> m_object;
133 QMap<QString, QtVariantProperty*> m_nameToProperty;
134 QHash<QtProperty *, QString> m_propertyToGroup;
135 QMap<QString, QtVariantProperty*> m_nameToGroup;
136 QList<QtProperty *> m_groups;
137 QtProperty *m_dynamicGroup = nullptr;
138 QString m_recentlyAddedDynamicProperty;
139 bool m_updatingBrowser = false;
140
141 QStackedWidget *m_stackedWidget;
142 QLineEdit *m_filterWidget;
143 int m_buttonIndex = -1;
144 int m_treeIndex = -1;
145 QAction *m_addDynamicAction;
146 QAction *m_removeDynamicAction;
147 QAction *m_sortingAction;
148 QAction *m_coloringAction;
149 QAction *m_treeAction;
150 QAction *m_buttonAction;
151 ElidingLabel *m_classLabel;
152
153 bool m_sorting = false;
154 bool m_coloring = false;
155
156 QMap<QString, bool> m_expansionState;
157
158 QString m_filterPattern;
159 QList<std::pair<QColor, QColor> > m_colors;
160 std::pair<QColor, QColor> m_dynamicColor;
161 std::pair<QColor, QColor> m_layoutColor;
162
163 bool m_brightness = false;
164};
165
166} // namespace qdesigner_internal
167
168QT_END_NAMESPACE
169
170#endif // PROPERTYEDITOR_H
The QDesignerMetaDataBaseItemInterface class provides an interface to individual items in \QD's meta ...
QtAbstractPropertyBrowser provides a base class for implementing property browsers.
The QtBrowserItem class represents a property in a property browser instance.
The QtButtonPropertyBrowser class provides a drop down QToolButton based property browser.
The QtProperty class encapsulates an instance of a property.
The QtTreePropertyBrowser class provides QTreeWidget based property browser.
The QtVariantProperty class is a convenience class handling QVariant based properties.
QString currentPropertyName() const override
Returns the name of the currently selected property in the property editor.
bool event(QEvent *event) override
This virtual function receives events to an object and should return true if the event e was recogniz...
QDesignerFormEditorInterface * core() const override
Returns a pointer to \QD's current QDesignerFormEditorInterface object.
void setObject(QObject *object) override
Changes the currently selected object in \QD's workspace, to object.
QObject * object() const override
Returns the currently selected object in \QD's workspace.
void setReadOnly(bool readOnly) override
If readOnly is true, the property editor is made write protected; otherwise the write protection is r...
bool isReadOnly() const override
Returns true if the property editor is write protected; otherwise false.
void setPropertyValue(const QString &name, const QVariant &value, bool changed=true) override
Sets the value of the property specified by name to value.
bool loadContents(const QString &contents) override
void dropEvent(QDropEvent *event) override
QString fileName() const override
Returns the name of the XML file \QD is currently using to populate its widget box.
Widget widget(int cat_idx, int wgt_idx) const override
Category category(int cat_idx) const override
bool load() override
Populates \QD's widget box by loading (or reloading) the currently specified XML file.
void dragEnterEvent(QDragEnterEvent *event) override
void dropWidgets(const QList< QDesignerDnDItemInterface * > &item_list, const QPoint &global_mouse_pos) override
void removeCategory(int cat_idx) override
void dragMoveEvent(QDragMoveEvent *event) override
void addWidget(int cat_idx, const Widget &wgt) override
int categoryCount() const override
void setFileName(const QString &file_name) override
Sets the XML file that \QD will use to populate its widget box, to fileName.
bool save() override
Saves the contents of \QD's widget box in the file specified by the fileName() function.
void addCategory(const Category &cat) override
QDesignerFormEditorInterface * core() const
Definition widgetbox.cpp:98
int widgetCount(int cat_idx) const override
void removeWidget(int cat_idx, int wgt_idx) override
QIcon iconForWidget(const QString &className, const QString &category=QString()) const override
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.
#define QT_PROPERTYEDITOR_EXPORT
static int qtMajorVersion(int qtVersion)
static QString widgetBoxFileName(int qtVersion, const QDesignerLanguageExtension *lang=nullptr)
static void setMinorVersion(int minorVersion, int *qtVersion)
static int qtMinorVersion(int qtVersion)
#define QDESIGNER_SHARED_EXPORT
#define QT_WIDGETBOX_EXPORT