15#ifndef QLAYOUT_WIDGET_H
16#define QLAYOUT_WIDGET_H
20#include <QtDesigner/layoutdecoration.h>
22#include <QtCore/qpointer.h>
23#include <QtCore/qvariant.h>
24#include <QtWidgets/qwidget.h>
25#include <QtWidgets/qlayout.h>
29class QDesignerFormWindowInterface;
30class QDesignerFormEditorInterface;
50#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
62 static int visibleProperties(
const QLayout *layout);
65 int fromPropertySheet(
const QDesignerFormEditorInterface *core, QLayout *l,
int mask =
AllProperties);
66 int toPropertySheet(
const QDesignerFormEditorInterface *core, QLayout *l,
int mask =
AllProperties,
bool applyChanged =
true)
const;
76#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
127 static int indexOf(
const QLayout *lt,
const QWidget *widget);
130 QRect itemInfo(QLayout *lt,
const QWidget *widget)
const;
132 virtual QRect itemInfo(QLayout *lt,
int index)
const = 0;
133 virtual void insertWidget(QLayout *lt,
const QRect &info,
QWidget *w) = 0;
134 virtual void removeWidget(QLayout *lt,
QWidget *widget) = 0;
140 virtual bool canSimplify(
const QDesignerFormEditorInterface *core,
const QWidget *widgetWithManagedLayout,
const QRect &restrictionArea)
const = 0;
141 virtual void simplify(
const QDesignerFormEditorInterface *core,
QWidget *widgetWithManagedLayout,
const QRect &restrictionArea) = 0;
146 virtual void pushState(
const QDesignerFormEditorInterface *core,
const QWidget *widgetWithManagedLayout) = 0;
147 virtual void popState(
const QDesignerFormEditorInterface *core,
QWidget *widgetWithManagedLayout) = 0;
154 Q_INTERFACES(QDesignerLayoutDecorationExtension)
157 QLayoutSupport(QDesignerFormWindowInterface *formWindow, QWidget *widget, LayoutHelper *helper, QObject *parent =
nullptr);
160 ~QLayoutSupport() override;
162 inline QDesignerFormWindowInterface *formWindow()
const {
return m_formWindow; }
165 LayoutHelper* helper()
const {
return m_helper; }
168 int currentIndex()
const override {
return m_currentIndex; }
170 InsertMode currentInsertMode()
const override {
return m_currentInsertMode; }
172 std::pair<
int,
int> currentCell()
const override {
return m_currentCell; }
174 int findItemAt(
const QPoint &pos)
const override;
175 int indexOf(QWidget *widget)
const override;
176 int indexOf(QLayoutItem *item)
const override;
178 void adjustIndicator(
const QPoint &pos,
int index) override;
180 QWidgetList widgets(QLayout *layout)
const override;
183 static void createEmptyCells(QGridLayout *gridLayout);
185 static bool removeEmptyCells(QGridLayout *gridLayout,
const QRect &area);
186 static void createEmptyCells(QFormLayout *formLayout);
187 static bool removeEmptyCells(QFormLayout *formLayout,
const QRect &area);
190 static int findItemAt(QGridLayout *,
int row,
int column);
191 using QDesignerLayoutDecorationExtension::findItemAt;
193 static bool canSimplifyQuickCheck(
const QGridLayout *);
194 static bool canSimplifyQuickCheck(
const QFormLayout *fl);
196 static QLayoutSupport *createLayoutSupport(QDesignerFormWindowInterface *formWindow, QWidget *widget, QObject *parent =
nullptr);
200 virtual void setCurrentCellFromIndicatorOnEmptyCell(
int index) = 0;
202 virtual void setCurrentCellFromIndicator(Qt::Orientation indicatorOrientation,
int index,
int increment) = 0;
206 virtual QRect extendedGeometry(
int index)
const = 0;
207 virtual bool supportsIndicatorOrientation(Qt::Orientation indicatorOrientation)
const = 0;
209 QRect itemInfo(
int index)
const override;
210 QLayout *layout()
const;
211 QGridLayout *gridLayout()
const;
212 QWidget *widget()
const {
return m_widget; }
214 void setInsertMode(InsertMode im);
215 void setCurrentCell(
const std::pair<
int,
int> &cell);
218 enum Indicator { LeftIndicator, TopIndicator, RightIndicator, BottomIndicator, NumIndicators };
220 void hideIndicator(Indicator i);
221 void showIndicator(Indicator i,
const QRect &geometry,
const QPalette &);
223 QDesignerFormWindowInterface *m_formWindow;
224 LayoutHelper* m_helper;
226 QPointer<QWidget> m_widget;
227 QPointer<QWidget> m_indicators[NumIndicators];
229 InsertMode m_currentInsertMode;
230 std::pair<
int,
int> m_currentCell;
239 explicit QLayoutWidget(QDesignerFormWindowInterface *formWindow, QWidget *parent =
nullptr);
241 int layoutLeftMargin()
const;
242 void setLayoutLeftMargin(
int layoutMargin);
244 int layoutTopMargin()
const;
245 void setLayoutTopMargin(
int layoutMargin);
247 int layoutRightMargin()
const;
248 void setLayoutRightMargin(
int layoutMargin);
250 int layoutBottomMargin()
const;
251 void setLayoutBottomMargin(
int layoutMargin);
253 inline QDesignerFormWindowInterface *formWindow()
const {
return m_formWindow; }
256 bool event(QEvent *e) override;
257 void paintEvent(QPaintEvent *e) override;
260 QDesignerFormWindowInterface *m_formWindow;
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.
static LayoutHelper * createLayoutHelper(int type)
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.
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)
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
QVariant m_gridRowStretch
int m_margins[MarginCount]
bool m_formAlignmentChanged
bool m_gridRowMinimumHeightChanged
QVariant m_labelAlignment
bool m_vertSizeConstraintChanged
QVariant m_gridRowMinimumHeight
bool m_marginsChanged[MarginCount]
bool m_horizSizeConstraintChanged
@ GridRowMinimumHeightProperty
@ GridColumnStretchProperty
@ HorizSizeConstraintProperty
@ VertSizeConstraintProperty
@ FieldGrowthPolicyProperty
@ GridColumnMinimumWidthProperty
bool m_fieldGrowthPolicyChanged
bool m_spacingsChanged[SpacingsCount]
QVariant m_vertSizeConstraint
bool m_labelAlignmentChanged
bool m_gridColumnStretchChanged
QVariant m_gridColumnMinimumWidth
QVariant m_horizSizeConstraint
QVariant m_fieldGrowthPolicy
QVariant m_gridColumnStretch
bool m_rowWrapPolicyChanged
bool m_gridColumnMinimumWidthChanged
bool m_gridRowStretchChanged
int m_spacings[SpacingsCount]