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
4#ifndef PROPERTYEDITOR_H
5#define PROPERTYEDITOR_H
6
8#include <qdesigner_propertyeditor_p.h>
9
10#include <QtCore/qlist.h>
11#include <QtCore/qmap.h>
12#include <QtCore/qpointer.h>
13#include <QtCore/qset.h>
14
16
17class DomProperty;
20class QLineEdit;
21
25class QtProperty;
27class QtBrowserItem;
28class QStackedWidget;
29
30namespace qdesigner_internal {
31
32class StringProperty;
35class ElidingLabel;
36
38{
40public:
43
44 QDesignerFormEditorInterface *core() const override;
45
46 bool isReadOnly() const override;
47 void setReadOnly(bool readOnly) override;
48 void setPropertyValue(const QString &name, const QVariant &value, bool changed = true) override;
50
51 void setObject(QObject *object) override;
52
54
55 QObject *object() const override
56 { return m_object; }
57
58 QString currentPropertyName() const override;
59
60protected:
61
62 bool event(QEvent *event) override;
63
64private slots:
66 void slotValueChanged(QtProperty *property, const QVariant &value, bool enableSubPropertyHandling);
67 void slotViewTriggered(QAction *action);
68 void slotAddDynamicProperty(QAction *action);
69 void slotRemoveDynamicProperty();
70 void slotSorting(bool sort);
71 void slotColoring(bool color);
72 void slotCurrentItemChanged(QtBrowserItem*);
73 void setFilter(const QString &pattern);
74
75private:
76 void updateBrowserValue(QtVariantProperty *property, const QVariant &value);
77 void updateToolBarLabel();
78 int toBrowserType(const QVariant &value, const QString &propertyName) const;
79 QString removeScope(const QString &value) const;
80 QDesignerMetaDataBaseItemInterface *metaDataBaseItem() const;
81 void setupStringProperty(QtVariantProperty *property, bool isMainContainer);
82 void setupPaletteProperty(QtVariantProperty *property);
83 QString realClassName(QObject *object) const;
84 void storeExpansionState();
85 void applyExpansionState();
86 void storePropertiesExpansionState(const QList<QtBrowserItem *> &items);
87 void applyPropertiesExpansionState(const QList<QtBrowserItem *> &items);
88 void applyFilter();
89 int applyPropertiesFilter(const QList<QtBrowserItem *> &items);
90 void setExpanded(QtBrowserItem *item, bool expanded);
91 bool isExpanded(QtBrowserItem *item) const;
92 void setItemVisible(QtBrowserItem *item, bool visible);
93 bool isItemVisible(QtBrowserItem *item) const;
94 void collapseAll();
95 void clearView();
96 void fillView();
97 bool isLayoutGroup(QtProperty *group) const;
98 void updateColors();
99 void updateForegroundBrightness();
100 QColor propertyColor(QtProperty *property) const;
101 void updateActionsState();
102 QtBrowserItem *nonFakePropertyBrowserItem(QtBrowserItem *item) const;
103 void saveSettings() const;
104 void editProperty(const QString &name);
105 bool isDynamicProperty(const QtBrowserItem* item) const;
106
107 struct Strings {
108 Strings();
109 QSet<QString> m_alignmentProperties;
110 const QString m_fontProperty;
111 const QString m_qLayoutWidget;
112 const QString m_designerPrefix;
113 const QString m_layout;
114 const QString m_validationModeAttribute;
115 const QString m_fontAttribute;
116 const QString m_superPaletteAttribute;
117 const QString m_enumNamesAttribute;
118 const QString m_resettableAttribute;
119 const QString m_flagsAttribute;
120 };
121
122 const Strings m_strings;
123 QDesignerFormEditorInterface *m_core;
124 QDesignerPropertySheetExtension *m_propertySheet = nullptr;
125 QtAbstractPropertyBrowser *m_currentBrowser = nullptr;
126 QtButtonPropertyBrowser *m_buttonBrowser;
127 QtTreePropertyBrowser *m_treeBrowser = nullptr;
128 DesignerPropertyManager *m_propertyManager;
129 DesignerEditorFactory *m_treeFactory;
130 DesignerEditorFactory *m_groupFactory;
131 QPointer<QObject> m_object;
132 QMap<QString, QtVariantProperty*> m_nameToProperty;
133 QHash<QtProperty *, QString> m_propertyToGroup;
134 QMap<QString, QtVariantProperty*> m_nameToGroup;
135 QList<QtProperty *> m_groups;
136 QtProperty *m_dynamicGroup = nullptr;
137 QString m_recentlyAddedDynamicProperty;
138 bool m_updatingBrowser = false;
139
140 QStackedWidget *m_stackedWidget;
141 QLineEdit *m_filterWidget;
142 int m_buttonIndex = -1;
143 int m_treeIndex = -1;
144 QAction *m_addDynamicAction;
145 QAction *m_removeDynamicAction;
146 QAction *m_sortingAction;
147 QAction *m_coloringAction;
148 QAction *m_treeAction;
149 QAction *m_buttonAction;
150 ElidingLabel *m_classLabel;
151
152 bool m_sorting = false;
153 bool m_coloring = false;
154
155 QMap<QString, bool> m_expansionState;
156
157 QString m_filterPattern;
159 std::pair<QColor, QColor> m_dynamicColor;
160 std::pair<QColor, QColor> m_layoutColor;
161
162 bool m_brightness = false;
163};
164
165} // namespace qdesigner_internal
166
167QT_END_NAMESPACE
168
169#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:97
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
#define INIT_PLUGIN_INSTANCE(PLUGIN)
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