summaryrefslogtreecommitdiff
path: root/examples/designer/containerextension
diff options
context:
space:
mode:
Diffstat (limited to 'examples/designer/containerextension')
-rw-r--r--examples/designer/containerextension/containerextension.pro28
-rw-r--r--examples/designer/containerextension/multipagewidget.cpp130
-rw-r--r--examples/designer/containerextension/multipagewidget.h87
-rw-r--r--examples/designer/containerextension/multipagewidgetcontainerextension.cpp100
-rw-r--r--examples/designer/containerextension/multipagewidgetcontainerextension.h74
-rw-r--r--examples/designer/containerextension/multipagewidgetextensionfactory.cpp64
-rw-r--r--examples/designer/containerextension/multipagewidgetextensionfactory.h63
-rw-r--r--examples/designer/containerextension/multipagewidgetplugin.cpp196
-rw-r--r--examples/designer/containerextension/multipagewidgetplugin.h80
9 files changed, 822 insertions, 0 deletions
diff --git a/examples/designer/containerextension/containerextension.pro b/examples/designer/containerextension/containerextension.pro
new file mode 100644
index 000000000..6ded91737
--- /dev/null
+++ b/examples/designer/containerextension/containerextension.pro
@@ -0,0 +1,28 @@
+#! [0]
+TEMPLATE = lib
+#! [0]
+TARGET = $$qtLibraryTarget($$TARGET)
+#! [1]
+CONFIG += designer plugin
+#! [1]
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/designer
+
+#! [2]
+HEADERS += multipagewidget.h \
+ multipagewidgetplugin.h \
+ multipagewidgetcontainerextension.h \
+ multipagewidgetextensionfactory.h
+
+SOURCES += multipagewidget.cpp \
+ multipagewidgetplugin.cpp \
+ multipagewidgetcontainerextension.cpp \
+ multipagewidgetextensionfactory.cpp
+#! [2]
+
+# install
+target.path = $$[QT_INSTALL_PLUGINS]/designer
+sources.files = $$SOURCES $$HEADERS *.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qttools/designer/containerextension
+INSTALLS += target sources
+
+symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/examples/designer/containerextension/multipagewidget.cpp b/examples/designer/containerextension/multipagewidget.cpp
new file mode 100644
index 000000000..5b44f36d2
--- /dev/null
+++ b/examples/designer/containerextension/multipagewidget.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "multipagewidget.h"
+
+MultiPageWidget::MultiPageWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ comboBox = new QComboBox();
+ comboBox->setObjectName("__qt__passive_comboBox");
+ stackWidget = new QStackedWidget();
+
+ connect(comboBox, SIGNAL(activated(int)),
+ this, SLOT(setCurrentIndex(int)));
+
+ layout = new QVBoxLayout();
+ layout->addWidget(comboBox);
+ layout->addWidget(stackWidget);
+ setLayout(layout);
+}
+
+QSize MultiPageWidget::sizeHint() const
+{
+ return QSize(200, 150);
+}
+
+void MultiPageWidget::addPage(QWidget *page)
+{
+ insertPage(count(), page);
+}
+
+void MultiPageWidget::removePage(int index)
+{
+ QWidget *widget = stackWidget->widget(index);
+ stackWidget->removeWidget(widget);
+
+ comboBox->removeItem(index);
+}
+
+int MultiPageWidget::count() const
+{
+ return stackWidget->count();
+}
+
+int MultiPageWidget::currentIndex() const
+{
+ return stackWidget->currentIndex();
+}
+
+void MultiPageWidget::insertPage(int index, QWidget *page)
+{
+ page->setParent(stackWidget);
+
+ stackWidget->insertWidget(index, page);
+
+ QString title = page->windowTitle();
+ if (title.isEmpty()) {
+ title = tr("Page %1").arg(comboBox->count() + 1);
+ page->setWindowTitle(title);
+ }
+ comboBox->insertItem(index, title);
+}
+
+void MultiPageWidget::setCurrentIndex(int index)
+{
+ if (index != currentIndex()) {
+ stackWidget->setCurrentIndex(index);
+ comboBox->setCurrentIndex(index);
+ emit currentIndexChanged(index);
+ }
+}
+
+QWidget* MultiPageWidget::widget(int index)
+{
+ return stackWidget->widget(index);
+}
+
+QString MultiPageWidget::pageTitle() const
+{
+ if (const QWidget *currentWidget = stackWidget->currentWidget())
+ return currentWidget->windowTitle();
+ return QString();
+}
+
+void MultiPageWidget::setPageTitle(QString const &newTitle)
+{
+ comboBox->setItemText(currentIndex(), newTitle);
+ if (QWidget *currentWidget = stackWidget->currentWidget())
+ currentWidget->setWindowTitle(newTitle);
+ emit pageTitleChanged(newTitle);
+}
diff --git a/examples/designer/containerextension/multipagewidget.h b/examples/designer/containerextension/multipagewidget.h
new file mode 100644
index 000000000..b2f3b7d5d
--- /dev/null
+++ b/examples/designer/containerextension/multipagewidget.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MULTIPAGEWIDGET_H
+#define MULTIPAGEWIDGET_H
+
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+class QComboBox;
+class QStackedWidget;
+class QVBoxLayout;
+QT_END_NAMESPACE
+
+//! [0]
+class MultiPageWidget : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex)
+ Q_PROPERTY(QString pageTitle READ pageTitle WRITE setPageTitle STORED false)
+
+public:
+ MultiPageWidget(QWidget *parent = 0);
+
+ QSize sizeHint() const;
+
+ int count() const;
+ int currentIndex() const;
+ QWidget *widget(int index);
+ QString pageTitle() const;
+
+public slots:
+ void addPage(QWidget *page);
+ void insertPage(int index, QWidget *page);
+ void removePage(int index);
+ void setPageTitle(QString const &newTitle);
+ void setCurrentIndex(int index);
+
+signals:
+ void currentIndexChanged(int index);
+ void pageTitleChanged(const QString &title);
+
+private:
+ QStackedWidget *stackWidget;
+ QComboBox *comboBox;
+ QVBoxLayout *layout;
+};
+//! [0]
+
+#endif
diff --git a/examples/designer/containerextension/multipagewidgetcontainerextension.cpp b/examples/designer/containerextension/multipagewidgetcontainerextension.cpp
new file mode 100644
index 000000000..fe815341a
--- /dev/null
+++ b/examples/designer/containerextension/multipagewidgetcontainerextension.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "multipagewidgetcontainerextension.h"
+#include "multipagewidget.h"
+
+//! [0]
+MultiPageWidgetContainerExtension::MultiPageWidgetContainerExtension(MultiPageWidget *widget,
+ QObject *parent)
+ :QObject(parent)
+{
+ myWidget = widget;
+}
+//! [0]
+
+//! [1]
+void MultiPageWidgetContainerExtension::addWidget(QWidget *widget)
+{
+ myWidget->addPage(widget);
+}
+//! [1]
+
+//! [2]
+int MultiPageWidgetContainerExtension::count() const
+{
+ return myWidget->count();
+}
+//! [2]
+
+//! [3]
+int MultiPageWidgetContainerExtension::currentIndex() const
+{
+ return myWidget->currentIndex();
+}
+//! [3]
+
+//! [4]
+void MultiPageWidgetContainerExtension::insertWidget(int index, QWidget *widget)
+{
+ myWidget->insertPage(index, widget);
+}
+//! [4]
+
+//! [5]
+void MultiPageWidgetContainerExtension::remove(int index)
+{
+ myWidget->removePage(index);
+}
+//! [5]
+
+//! [6]
+void MultiPageWidgetContainerExtension::setCurrentIndex(int index)
+{
+ myWidget->setCurrentIndex(index);
+}
+//! [6]
+
+//! [7]
+QWidget* MultiPageWidgetContainerExtension::widget(int index) const
+{
+ return myWidget->widget(index);
+}
+//! [7]
diff --git a/examples/designer/containerextension/multipagewidgetcontainerextension.h b/examples/designer/containerextension/multipagewidgetcontainerextension.h
new file mode 100644
index 000000000..dfb10c625
--- /dev/null
+++ b/examples/designer/containerextension/multipagewidgetcontainerextension.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MULTIPAGEWIDGETCONTAINEREXTENSION_H
+#define MULTIPAGEWIDGETCONTAINEREXTENSION_H
+
+#include <QtDesigner/QDesignerContainerExtension>
+
+QT_BEGIN_NAMESPACE
+class QExtensionManager;
+QT_END_NAMESPACE
+class MultiPageWidget;
+
+//! [0]
+class MultiPageWidgetContainerExtension: public QObject,
+ public QDesignerContainerExtension
+{
+ Q_OBJECT
+ Q_INTERFACES(QDesignerContainerExtension)
+
+public:
+ MultiPageWidgetContainerExtension(MultiPageWidget *widget, QObject *parent);
+
+ void addWidget(QWidget *widget);
+ int count() const;
+ int currentIndex() const;
+ void insertWidget(int index, QWidget *widget);
+ void remove(int index);
+ void setCurrentIndex(int index);
+ QWidget *widget(int index) const;
+
+private:
+ MultiPageWidget *myWidget;
+};
+//! [0]
+
+#endif
diff --git a/examples/designer/containerextension/multipagewidgetextensionfactory.cpp b/examples/designer/containerextension/multipagewidgetextensionfactory.cpp
new file mode 100644
index 000000000..36f3c8f46
--- /dev/null
+++ b/examples/designer/containerextension/multipagewidgetextensionfactory.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "multipagewidgetextensionfactory.h"
+#include "multipagewidgetcontainerextension.h"
+#include "multipagewidget.h"
+
+//! [0]
+MultiPageWidgetExtensionFactory::MultiPageWidgetExtensionFactory(QExtensionManager *parent)
+ : QExtensionFactory(parent)
+{}
+//! [0]
+
+//! [1]
+QObject *MultiPageWidgetExtensionFactory::createExtension(QObject *object,
+ const QString &iid,
+ QObject *parent) const
+{
+ MultiPageWidget *widget = qobject_cast<MultiPageWidget*>(object);
+
+ if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) {
+ return new MultiPageWidgetContainerExtension(widget, parent);
+ } else {
+ return 0;
+ }
+}
+//! [1]
diff --git a/examples/designer/containerextension/multipagewidgetextensionfactory.h b/examples/designer/containerextension/multipagewidgetextensionfactory.h
new file mode 100644
index 000000000..2ed2946f6
--- /dev/null
+++ b/examples/designer/containerextension/multipagewidgetextensionfactory.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MULTIPAGEWIDGETEXTENSIONFACTORY_H
+#define MULTIPAGEWIDGETEXTENSIONFACTORY_H
+
+#include <QtDesigner/QExtensionFactory>
+
+QT_BEGIN_NAMESPACE
+class QExtensionManager;
+QT_END_NAMESPACE
+
+//! [0]
+class MultiPageWidgetExtensionFactory: public QExtensionFactory
+{
+ Q_OBJECT
+
+public:
+ MultiPageWidgetExtensionFactory(QExtensionManager *parent = 0);
+
+protected:
+ QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const;
+};
+//! [0]
+
+#endif
diff --git a/examples/designer/containerextension/multipagewidgetplugin.cpp b/examples/designer/containerextension/multipagewidgetplugin.cpp
new file mode 100644
index 000000000..60aab4fea
--- /dev/null
+++ b/examples/designer/containerextension/multipagewidgetplugin.cpp
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtDesigner/QExtensionFactory>
+#include <QtDesigner/QExtensionManager>
+#include <QtDesigner/QDesignerFormEditorInterface>
+#include <QtDesigner/QDesignerFormWindowInterface>
+#include <QtDesigner/QDesignerContainerExtension>
+#include <QtDesigner/QDesignerPropertySheetExtension>
+
+#include <QIcon>
+#include <QtPlugin>
+
+#include "multipagewidget.h"
+#include "multipagewidgetplugin.h"
+#include "multipagewidgetextensionfactory.h"
+
+//! [0]
+MultiPageWidgetPlugin::MultiPageWidgetPlugin(QObject *parent)
+ :QObject(parent)
+{
+ initialized = false;
+}
+
+QString MultiPageWidgetPlugin::name() const
+{
+ return QLatin1String("MultiPageWidget");
+}
+
+QString MultiPageWidgetPlugin::group() const
+{
+ return QLatin1String("Display Widgets [Examples]");
+}
+
+QString MultiPageWidgetPlugin::toolTip() const
+{
+ return QString();
+}
+
+QString MultiPageWidgetPlugin::whatsThis() const
+{
+ return QString();
+}
+
+QString MultiPageWidgetPlugin::includeFile() const
+{
+ return QLatin1String("multipagewidget.h");
+}
+
+QIcon MultiPageWidgetPlugin::icon() const
+{
+ return QIcon();
+}
+
+//! [0] //! [1]
+bool MultiPageWidgetPlugin::isContainer() const
+{
+ return true;
+}
+
+//! [1] //! [2]
+QWidget *MultiPageWidgetPlugin::createWidget(QWidget *parent)
+{
+ MultiPageWidget *widget = new MultiPageWidget(parent);
+ connect(widget, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(currentIndexChanged(int)));
+ connect(widget, SIGNAL(pageTitleChanged(QString)),
+ this, SLOT(pageTitleChanged(QString)));
+ return widget;
+}
+
+//! [2] //! [3]
+bool MultiPageWidgetPlugin::isInitialized() const
+{
+ return initialized;
+}
+//! [3]
+
+//! [4]
+void MultiPageWidgetPlugin::initialize(QDesignerFormEditorInterface *formEditor)
+{
+ if (initialized)
+ return;
+//! [4]
+
+//! [5]
+ QExtensionManager *manager = formEditor->extensionManager();
+//! [5] //! [6]
+ QExtensionFactory *factory = new MultiPageWidgetExtensionFactory(manager);
+
+ Q_ASSERT(manager != 0);
+ manager->registerExtensions(factory, Q_TYPEID(QDesignerContainerExtension));
+
+ initialized = true;
+}
+//! [6]
+
+//! [7]
+QString MultiPageWidgetPlugin::domXml() const
+{
+ return QLatin1String("\
+<ui language=\"c++\">\
+ <widget class=\"MultiPageWidget\" name=\"multipagewidget\">\
+ <widget class=\"QWidget\" name=\"page\" />\
+ </widget>\
+ <customwidgets>\
+ <customwidget>\
+ <class>MultiPageWidget</class>\
+ <extends>QWidget</extends>\
+ <addpagemethod>addPage</addpagemethod>\
+ </customwidget>\
+ </customwidgets>\
+</ui>");
+}
+//! [7]
+
+//! [8]
+void MultiPageWidgetPlugin::currentIndexChanged(int index)
+{
+ Q_UNUSED(index);
+ MultiPageWidget *widget = qobject_cast<MultiPageWidget*>(sender());
+//! [8] //! [9]
+ if (widget) {
+ QDesignerFormWindowInterface *form = QDesignerFormWindowInterface::findFormWindow(widget);
+ if (form)
+ form->emitSelectionChanged();
+ }
+}
+//! [9]
+
+//! [10]
+void MultiPageWidgetPlugin::pageTitleChanged(const QString &title)
+{
+ Q_UNUSED(title);
+ MultiPageWidget *widget = qobject_cast<MultiPageWidget*>(sender());
+//! [10] //! [11]
+ if (widget) {
+ QWidget *page = widget->widget(widget->currentIndex());
+ QDesignerFormWindowInterface *form;
+ form = QDesignerFormWindowInterface::findFormWindow(widget);
+//! [11]
+ if (form) {
+//! [12]
+ QDesignerFormEditorInterface *editor = form->core();
+ QExtensionManager *manager = editor->extensionManager();
+//! [12] //! [13]
+ QDesignerPropertySheetExtension *sheet;
+ sheet = qt_extension<QDesignerPropertySheetExtension*>(manager, page);
+ const int propertyIndex = sheet->indexOf(QLatin1String("windowTitle"));
+ sheet->setChanged(propertyIndex, true);
+ }
+ }
+}
+
+//! [13]
+
+//! [14]
+Q_EXPORT_PLUGIN2(containerextension, MultiPageWidgetPlugin)
+//! [14]
diff --git a/examples/designer/containerextension/multipagewidgetplugin.h b/examples/designer/containerextension/multipagewidgetplugin.h
new file mode 100644
index 000000000..3d9ac52bf
--- /dev/null
+++ b/examples/designer/containerextension/multipagewidgetplugin.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#ifndef MULTIPAGEWIDGETPLUGIN_H
+#define MULTIPAGEWIDGETPLUGIN_H
+
+#include <QtDesigner/QDesignerCustomWidgetInterface>
+
+QT_BEGIN_NAMESPACE
+class QIcon;
+class QWidget;
+QT_END_NAMESPACE
+
+class MultiPageWidgetPlugin: public QObject, public QDesignerCustomWidgetInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QDesignerCustomWidgetInterface)
+public:
+ MultiPageWidgetPlugin(QObject *parent = 0);
+
+ QString name() const;
+ QString group() const;
+ QString toolTip() const;
+ QString whatsThis() const;
+ QString includeFile() const;
+ QIcon icon() const;
+ bool isContainer() const;
+ QWidget *createWidget(QWidget *parent);
+ bool isInitialized() const;
+ void initialize(QDesignerFormEditorInterface *formEditor);
+ QString domXml() const;
+
+private slots:
+ void currentIndexChanged(int index);
+ void pageTitleChanged(const QString &title);
+
+private:
+ bool initialized;
+};
+
+#endif
+//! [0]