15#ifndef QDESIGNER_PROPERTYCOMMAND_H
16#define QDESIGNER_PROPERTYCOMMAND_H
20#include <QtCore/qvariant.h>
21#include <QtCore/qhash.h>
22#include <QtCore/qlist.h>
23#include <QtCore/qpair.h>
24#include <QtCore/qpointer.h>
25#include <QtCore/qsharedpointer.h>
29class QDesignerFormWindowInterface;
31class QDesignerIntegration;
66 virtual Value setValue(QDesignerFormWindowInterface *fw,
const QVariant &value,
67 bool changed, quint64 subPropertyMask);
75 {
return m_oldValue.first; }
78 { m_oldValue.first = oldValue; }
85 bool canMerge(
const PropertyHelper &other)
const;
86 QDesignerIntegration *
integration(QDesignerFormWindowInterface *fw)
const;
94 static void checkApplyWidgetValue(QDesignerFormWindowInterface *fw,
QWidget* w,
97 void updateObject(QDesignerFormWindowInterface *fw,
const QVariant &oldValue,
const QVariant &newValue);
98 QVariant findDefaultValue(QDesignerFormWindowInterface *fw)
const;
99 void ensureUniqueObjectName(QDesignerFormWindowInterface *fw, QObject *object)
const;
102 QPointer<QObject> m_object;
104 QPointer<QWidget> m_parentWidget;
116 explicit PropertyListCommand(QDesignerFormWindowInterface *formWindow, QUndoCommand *parent =
nullptr);
118 QObject* object(
int index = 0)
const;
120 QVariant oldValue(
int index = 0)
const;
122 void setOldValue(
const QVariant &oldValue,
int index = 0);
125 void undo() override;
128 using PropertyHelperPtr = std::unique_ptr<PropertyHelper>;
129 using PropertyHelperList = std::vector<PropertyHelperPtr>;
132 bool add(QObject *object,
const QString &propertyName);
135 bool initList(
const QObjectList &list,
const QString &apropertyName, QObject *referenceObject =
nullptr);
138 unsigned setValue(
const QVariant &value,
bool changed, quint64 subPropertyMask);
141 unsigned restoreOldValue();
143 unsigned restoreDefaultValue();
146 void update(
unsigned updateMask);
149 bool canMergeLists(
const PropertyHelperList& other)
const;
151 PropertyHelperList& propertyHelperList() {
return m_propertyHelperList; }
152 const PropertyHelperList& propertyHelperList()
const {
return m_propertyHelperList; }
154 const QString propertyName()
const;
155 SpecialProperty specialProperty()
const;
159 struct PropertyDescription {
161 PropertyDescription() =
default;
162 PropertyDescription(
const QString &propertyName, QDesignerPropertySheetExtension *propertySheet,
int index);
163 bool equals(
const PropertyDescription &p)
const;
166 QString m_propertyName;
167 QString m_propertyGroup;
168 int m_propertyType = QMetaType::UnknownType;
169 SpecialProperty m_specialProperty = SP_None;
171 const PropertyDescription &propertyDescription()
const {
return m_propertyDescription; }
174 virtual std::unique_ptr<PropertyHelper>
175 createPropertyHelper(QObject *o, SpecialProperty sp,
176 QDesignerPropertySheetExtension *sheet,
int sheetIndex)
const;
179 PropertyDescription m_propertyDescription;
180 PropertyHelperList m_propertyHelperList;
187 explicit SetPropertyCommand(QDesignerFormWindowInterface *formWindow, QUndoCommand *parent =
nullptr);
189 bool init(QObject *object,
const QString &propertyName,
const QVariant &newValue);
190 bool init(
const QObjectList &list,
const QString &propertyName,
const QVariant &newValue,
191 QObject *referenceObject =
nullptr,
bool enableSubPropertyHandling =
true);
194 inline QVariant newValue()
const
195 {
return m_newValue; }
197 inline void setNewValue(
const QVariant &newValue)
198 { m_newValue = newValue; }
200 int id()
const override;
201 bool mergeWith(
const QUndoCommand *other) override;
203 void redo() override;
206 virtual QVariant mergeValue(
const QVariant &newValue);
209 quint64 subPropertyMask(
const QVariant &newValue, QObject *referenceObject);
210 void setDescription();
212 quint64 m_subPropertyMask;
219 explicit ResetPropertyCommand(QDesignerFormWindowInterface *formWindow);
221 bool init(QObject *object,
const QString &propertyName);
222 bool init(
const QObjectList &list,
const QString &propertyName, QObject *referenceObject =
nullptr);
224 void redo() override;
227 bool mergeWith(
const QUndoCommand *) override {
return false; }
230 void setDescription();
231 QString m_propertyName;
239 explicit AddDynamicPropertyCommand(QDesignerFormWindowInterface *formWindow);
241 bool init(
const QObjectList &selection, QObject *current,
const QString &propertyName,
const QVariant &value);
243 void redo() override;
244 void undo() override;
246 void setDescription();
247 QString m_propertyName;
248 QObjectList m_selection;
256 explicit RemoveDynamicPropertyCommand(QDesignerFormWindowInterface *formWindow);
258 bool init(
const QObjectList &selection, QObject *current,
const QString &propertyName);
260 void redo() override;
261 void undo() override;
263 void setDescription();
264 QString m_propertyName;
265 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.
QDESIGNER_SHARED_EXPORT void getFormLayoutItemPosition(const QFormLayout *formLayout, int index, int *rowPtr, int *columnPtr=nullptr, int *rowspanPtr=nullptr, int *colspanPtr=nullptr)
QDESIGNER_SHARED_EXPORT QDebug operator<<(QDebug, const PropertySheetIconValue &)
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)
#define QDESIGNER_SHARED_EXPORT