summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-05-20 10:10:32 +0200
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-05-20 10:10:32 +0200
commite00b8105bfcf3d4e36275dea6355705ec5fdbc40 (patch)
tree338f76f395ce8e23b4579e21074150c6185cb14e
parent66498850f2d5cf3a41579323c5119a7b6c9ce830 (diff)
Designer: Extend container extension.
Make it possible to disable adding/removing pages by adding respective bool virtual functions. Useful for implementing containers with fixed, single children like QScrollArea, QDockWidget, which require a container extension to work properly in Qt Designer. Previously, the problem was that the add/remove page context menu actions were enabled for them, leading to crashes und undesired behaviour. Reviewed-by: Jarek Kobus <jaroslaw.kobus@nokia.com>
-rw-r--r--tools/uilib/container.h7
-rw-r--r--tools/uilib/container.qdoc27
2 files changed, 34 insertions, 0 deletions
diff --git a/tools/uilib/container.h b/tools/uilib/container.h
index 89df461e02..f0d89faa08 100644
--- a/tools/uilib/container.h
+++ b/tools/uilib/container.h
@@ -65,6 +65,13 @@ public:
virtual void addWidget(QWidget *widget) = 0;
virtual void insertWidget(int index, QWidget *widget) = 0;
virtual void remove(int index) = 0;
+
+ virtual bool canAddWidget() const
+ // ### Qt6 remove body, provided in Qt5 for source compatibility to Qt4.
+ { return true; }
+ virtual bool canRemove(int index) const
+ // ### Qt6 remove body, provided in Qt5 for source compatibility to Qt4.
+ { Q_UNUSED(index); return true; }
};
Q_DECLARE_EXTENSION_INTERFACE(QDesignerContainerExtension, "com.trolltech.Qt.Designer.Container")
diff --git a/tools/uilib/container.qdoc b/tools/uilib/container.qdoc
index d9310515d3..f8e0670811 100644
--- a/tools/uilib/container.qdoc
+++ b/tools/uilib/container.qdoc
@@ -170,3 +170,30 @@
\sa addWidget(), insertWidget()
*/
+
+/*!
+ \fn bool QDesignerContainerExtension::canAddWidget() const
+
+ Returns whether a widget can be added. This determines whether
+ the context menu options to add or insert pages are enabled.
+
+ This should return false for containers that have a single, fixed
+ page, for example QScrollArea or QDockWidget.
+
+ \since 5.0
+ \sa addWidget(), canRemove()
+*/
+
+/*!
+ \fn bool QDesignerContainerExtension::canRemove(int index) const
+
+ Returns whether the widget at the given \a index can be removed.
+ This determines whether the context menu option to remove the current
+ page is enabled.
+
+ This should return false for containers that have a single, fixed
+ page, for example QScrollArea or QDockWidget.
+
+ \since 5.0
+ \sa remove(), canAddWidget()
+*/