16#ifndef QDESIGNER_PROPERTYCOMMAND_H
17#define QDESIGNER_PROPERTYCOMMAND_H
21#include <QtCore/qvariant.h>
22#include <QtCore/qhash.h>
23#include <QtCore/qlist.h>
24#include <QtCore/qpointer.h>
25#include <QtCore/qsharedpointer.h>
31class QDesignerFormWindowInterface;
33class QDesignerIntegration;
68 virtual Value setValue(QDesignerFormWindowInterface *fw,
const QVariant &value,
69 bool changed, quint64 subPropertyMask);
77 {
return m_oldValue.first; }
80 { m_oldValue.first = oldValue; }
87 bool canMerge(
const PropertyHelper &other)
const;
88 QDesignerIntegration *
integration(QDesignerFormWindowInterface *fw)
const;
96 static void checkApplyWidgetValue(QDesignerFormWindowInterface *fw,
QWidget* w,
99 void updateObject(QDesignerFormWindowInterface *fw,
const QVariant &oldValue,
const QVariant &newValue);
100 QVariant findDefaultValue(QDesignerFormWindowInterface *fw)
const;
101 void ensureUniqueObjectName(QDesignerFormWindowInterface *fw, QObject *object)
const;
104 QPointer<QObject> m_object;
106 QPointer<QWidget> m_parentWidget;
118 explicit PropertyListCommand(QDesignerFormWindowInterface *formWindow, QUndoCommand *parent =
nullptr);
120 QObject* object(
int index = 0)
const;
122 QVariant oldValue(
int index = 0)
const;
124 void setOldValue(
const QVariant &oldValue,
int index = 0);
127 void undo() override;
130 using PropertyHelperPtr = std::unique_ptr<PropertyHelper>;
131 using PropertyHelperList = std::vector<PropertyHelperPtr>;
134 bool add(QObject *object,
const QString &propertyName);
137 bool initList(
const QObjectList &list,
const QString &apropertyName, QObject *referenceObject =
nullptr);
140 unsigned setValue(
const QVariant &value,
bool changed, quint64 subPropertyMask);
143 unsigned restoreOldValue();
145 unsigned restoreDefaultValue();
148 void update(
unsigned updateMask);
151 bool canMergeLists(
const PropertyHelperList& other)
const;
153 PropertyHelperList& propertyHelperList() {
return m_propertyHelperList; }
154 const PropertyHelperList& propertyHelperList()
const {
return m_propertyHelperList; }
156 const QString propertyName()
const;
157 SpecialProperty specialProperty()
const;
161 struct PropertyDescription {
163 PropertyDescription() =
default;
164 PropertyDescription(
const QString &propertyName, QDesignerPropertySheetExtension *propertySheet,
int index);
165 bool equals(
const PropertyDescription &p)
const;
168 QString m_propertyName;
169 QString m_propertyGroup;
170 int m_propertyType = QMetaType::UnknownType;
171 SpecialProperty m_specialProperty = SP_None;
173 const PropertyDescription &propertyDescription()
const {
return m_propertyDescription; }
176 virtual std::unique_ptr<PropertyHelper>
177 createPropertyHelper(QObject *o, SpecialProperty sp,
178 QDesignerPropertySheetExtension *sheet,
int sheetIndex)
const;
181 PropertyDescription m_propertyDescription;
182 PropertyHelperList m_propertyHelperList;
189 explicit SetPropertyCommand(QDesignerFormWindowInterface *formWindow, QUndoCommand *parent =
nullptr);
191 bool init(QObject *object,
const QString &propertyName,
const QVariant &newValue);
192 bool init(
const QObjectList &list,
const QString &propertyName,
const QVariant &newValue,
193 QObject *referenceObject =
nullptr,
bool enableSubPropertyHandling =
true);
196 inline QVariant newValue()
const
197 {
return m_newValue; }
199 inline void setNewValue(
const QVariant &newValue)
200 { m_newValue = newValue; }
202 int id()
const override;
203 bool mergeWith(
const QUndoCommand *other) override;
205 void redo() override;
208 virtual QVariant mergeValue(
const QVariant &newValue);
211 quint64 subPropertyMask(
const QVariant &newValue, QObject *referenceObject);
212 void setDescription();
214 quint64 m_subPropertyMask;
221 explicit ResetPropertyCommand(QDesignerFormWindowInterface *formWindow);
223 bool init(QObject *object,
const QString &propertyName);
224 bool init(
const QObjectList &list,
const QString &propertyName, QObject *referenceObject =
nullptr);
226 void redo() override;
229 bool mergeWith(
const QUndoCommand *) override {
return false; }
232 void setDescription();
233 QString m_propertyName;
241 explicit AddDynamicPropertyCommand(QDesignerFormWindowInterface *formWindow);
243 bool init(
const QObjectList &selection, QObject *current,
const QString &propertyName,
const QVariant &value);
245 void redo() override;
246 void undo() override;
248 void setDescription();
249 QString m_propertyName;
250 QObjectList m_selection;
258 explicit RemoveDynamicPropertyCommand(QDesignerFormWindowInterface *formWindow);
260 bool init(
const QObjectList &selection, QObject *current,
const QString &propertyName);
262 void redo() override;
263 void undo() override;
265 void setDescription();
266 QString m_propertyName;
267 QHash<QObject *, std::pair<QVariant,
bool> > m_objectToValueAndChanged;
static bool canBeBuddy(QWidget *w, QDesignerFormWindowInterface *form)
static QString buddy(QLabel *label, QDesignerFormEditorInterface *core)
static constexpr auto buddyPropertyC
#define QT_BUDDYEDITOR_EXPORT
void init(QWidget *parentWidget, QAction *action, QAction *beforeAction=nullptr, bool update=true)
ActionInsertionCommand(const QString &text, QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
AddMenuActionCommand(QDesignerFormWindowInterface *formWindow)
void undo() override
Reverts a change to the document.
void redo() override
Applies a change to the document.
AddStackedWidgetPageCommand(QDesignerFormWindowInterface *formWindow)
void undo() override
Reverts a change to the document.
void init(QStackedWidget *stackedWidget)
void init(QStackedWidget *stackedWidget, InsertionMode mode)
~AddStackedWidgetPageCommand() override
void redo() override
Applies a change to the document.
void undo() override
Reverts a change to the document.
~AddTabPageCommand() override
void init(QTabWidget *tabWidget, InsertionMode mode)
void init(QTabWidget *tabWidget)
AddTabPageCommand(QDesignerFormWindowInterface *formWindow)
AddToolBoxPageCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void init(QToolBox *toolBox, InsertionMode mode)
~AddToolBoxPageCommand() override
void init(QToolBox *toolBox)
void undo() override
Reverts a change to the document.
void setBackground(QWidget *background) override
QDesignerFormWindowInterface * formWindow() const
void endConnection(QWidget *target, const QPoint &pos) override
void widgetRemoved(QWidget *w) override
QWidget * widgetAt(const QPoint &pos) const override
Connection * createConnection(QWidget *source, QWidget *destination) override
void createContextMenu(QMenu &menu) override
void deleteSelected() override
CreateMenuBarCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void init(QMainWindow *mainWindow)
void undo() override
Reverts a change to the document.
void redo() override
Applies a change to the document.
void undo() override
Reverts a change to the document.
void init(QMainWindow *mainWindow)
CreateStatusBarCommand(QDesignerFormWindowInterface *formWindow)
void undo() override
Reverts a change to the document.
void init(QDesignerMenu *menu, QAction *action, QObject *m_objectToSelect=nullptr)
CreateSubmenuCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void restore(QDesignerFormWindowInterface *formWindow) const
void save(const QDesignerFormWindowInterface *formWindow)
void init(QMenuBar *menuBar)
void redo() override
Applies a change to the document.
void undo() override
Reverts a change to the document.
DeleteMenuBarCommand(QDesignerFormWindowInterface *formWindow)
DeleteStackedWidgetPageCommand(QDesignerFormWindowInterface *formWindow)
void init(QStackedWidget *stackedWidget)
void redo() override
Applies a change to the document.
~DeleteStackedWidgetPageCommand() override
void undo() override
Reverts a change to the document.
void init(QTabWidget *tabWidget)
void redo() override
Applies a change to the document.
~DeleteTabPageCommand() override
void undo() override
Reverts a change to the document.
DeleteTabPageCommand(QDesignerFormWindowInterface *formWindow)
void init(QToolBox *toolBox)
DeleteToolBoxPageCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void undo() override
Reverts a change to the document.
~DeleteToolBoxPageCommand() override
void undo() override
Reverts a change to the document.
InsertActionIntoCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void init(QAction *action, QAction *actionBefore, QWidget *associatedWidget, QWidget *objectToSelect)
MenuActionCommand(const QString &text, QDesignerFormWindowInterface *formWindow)
~MoveTabPageCommand() override
void undo() override
Reverts a change to the document.
MoveTabPageCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void init(QTabWidget *tabWidget, QWidget *page, const QIcon &icon, const QString &label, int index, int newIndex)
MoveToolBoxPageCommand(QDesignerFormWindowInterface *formWindow)
void redo() override
Applies a change to the document.
void init(QToolBox *toolBox, QWidget *page, int newIndex)
void undo() override
Reverts a change to the document.
~MoveToolBoxPageCommand() override
QDesignerIntegration * integration(QDesignerFormWindowInterface *fw) const
PropertyHelper(QObject *object, SpecialProperty specialProperty, QDesignerPropertySheetExtension *sheet, int index)
static void triggerActionChanged(QAction *a)
SpecialProperty specialProperty() const
void setOldValue(const QVariant &oldValue)
unsigned updateMask() const
QVariant oldValue() const
Value restoreDefaultValue(QDesignerFormWindowInterface *fw)
Value restoreOldValue(QDesignerFormWindowInterface *fw)
bool canMerge(const PropertyHelper &other) const
virtual Value setValue(QDesignerFormWindowInterface *fw, const QVariant &value, bool changed, quint64 subPropertyMask)
RemoveActionFromCommand(QDesignerFormWindowInterface *formWindow)
void undo() override
Reverts a change to the document.
void redo() override
Applies a change to the document.
RemoveMenuActionCommand(QDesignerFormWindowInterface *formWindow)
void undo() override
Reverts a change to the document.
void redo() override
Applies a change to the document.
Combined button and popup list for selecting options.
int valueOf(const QVariant &value, bool *ok=nullptr)
bool isObjectAncestorOf(QObject *ancestor, QObject *child)
bool isCentralWidget(QDesignerFormWindowInterface *fw, QWidget *widget)
Auxiliary methods to store/retrieve settings.
enum SpecialProperty getSpecialProperty(const QString &propertyName)
QDESIGNER_SHARED_EXPORT void getFormLayoutItemPosition(const QFormLayout *formLayout, int index, int *rowPtr, int *columnPtr=nullptr, int *rowspanPtr=nullptr, int *colspanPtr=nullptr)
static QUndoCommand * createBuddyCommand(QDesignerFormWindowInterface *fw, QLabel *label, QWidget *buddy)
QDESIGNER_SHARED_EXPORT void formLayoutAddWidget(QFormLayout *formLayout, QWidget *w, const QRect &r, bool insert)
QDESIGNER_SHARED_EXPORT void designerWarning(const QString &message)
QDESIGNER_SHARED_EXPORT void reloadIconResources(DesignerIconCache *iconCache, QObject *object)
QDESIGNER_SHARED_EXPORT bool runUIC(const QString &fileName, UicLanguage language, QByteArray &ba, QString &errorMessage)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
QT_END_NAMESPACE Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QtOhos::enums::kit::ShareKit::systemShare::SelectionMode))
#define QDESIGNER_SHARED_EXPORT
DesignerMetaEnum metaEnum
DesignerMetaFlags metaFlags