summaryrefslogtreecommitdiff
path: root/src/tools/qtcreatorwidgets/customwidgets.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2009-10-02 10:12:32 +0200
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2009-10-02 10:12:32 +0200
commit9dd0a108e30b297ce9b735026304c4dfd5bf21d3 (patch)
tree6c4f1ce72fb0253de4cfc128e01754716b5b2c6d /src/tools/qtcreatorwidgets/customwidgets.cpp
parent9bef75f8f9cba9903cd180ea837d312985540950 (diff)
downloadqt-creator-9dd0a108e30b297ce9b735026304c4dfd5bf21d3.tar.gz
Fix the Creator widgets Designer plugin, add DetailsWidgets.
Polish the DetailsWidget for that purpose, add properties, make it survive without widgets, add a container extension.
Diffstat (limited to 'src/tools/qtcreatorwidgets/customwidgets.cpp')
-rw-r--r--src/tools/qtcreatorwidgets/customwidgets.cpp120
1 files changed, 119 insertions, 1 deletions
diff --git a/src/tools/qtcreatorwidgets/customwidgets.cpp b/src/tools/qtcreatorwidgets/customwidgets.cpp
index 3fba12ef18..e8867a59fa 100644
--- a/src/tools/qtcreatorwidgets/customwidgets.cpp
+++ b/src/tools/qtcreatorwidgets/customwidgets.cpp
@@ -31,6 +31,8 @@
#include <QtGui/QMenu>
#include <QtGui/QAction>
+#include <QtDesigner/QExtensionManager>
+#include <QtDesigner/QDesignerFormEditorInterface>
static const char *groupC = "QtCreator";
@@ -165,11 +167,125 @@ PathListEditor_CW::PathListEditor_CW(QObject *parent) :
{
}
+DetailsButton_CW::DetailsButton_CW(QObject *parent) :
+ QObject(parent),
+ CustomWidget<Utils::DetailsButton>
+ (QLatin1String("<utils/detailsbutton.h>"),
+ false,
+ QLatin1String(groupC),
+ QIcon(),
+ QLatin1String("Expandable button for 'Details'"))
+{
+}
+
+DetailsWidget_CW::DetailsWidget_CW(QObject *parent) :
+ QObject(parent),
+ CustomWidget<Utils::DetailsWidget>
+ (QLatin1String("<utils/detailswidget.h>"),
+ true,
+ QLatin1String(groupC),
+ QIcon(),
+ QLatin1String("Expandable widget for 'Details'. You might need an expandable spacer below."))
+{
+}
+
+QString DetailsWidget_CW::domXml() const
+{
+ // Expanded from start, else child visibility is wrong
+ const char *xmlC ="\
+<ui language=\"c++\" displayname=\"DetailsWidget\">\
+ <widget class=\"Utils::DetailsWidget\" name=\"detailsWidget\">\
+ <property name=\"geometry\">\
+ <rect><x>0</x><y>0</y><width>160</width><height>80</height></rect>\
+ </property>\
+ <property name=\"summaryText\">\
+ <string>Summary</string>\
+ </property>\
+ <property name=\"expanded\">\
+ <bool>true</bool>\
+ </property>\
+ <widget class=\"QWidget\" name=\"detailsContainer\" />\
+ </widget>\
+ <customwidgets>\
+ <customwidget>\
+ <class>Utils::DetailsWidget</class>\
+ <addpagemethod>setWidget</addpagemethod>\
+ </customwidget>\
+ </customwidgets>\
+</ui>";
+ return QLatin1String(xmlC);
+}
+
+void DetailsWidget_CW::initialize(QDesignerFormEditorInterface *core)
+{
+ const bool firstTime = !initialized();
+ CustomWidget<Utils::DetailsWidget>::initialize(core);
+ if (firstTime)
+ if (QExtensionManager *manager = core->extensionManager())
+ manager->registerExtensions(new DetailsWidgetExtensionFactory(manager), Q_TYPEID(QDesignerContainerExtension));
+}
+
+DetailsWidgetContainerExtension::DetailsWidgetContainerExtension(Utils::DetailsWidget *widget, QObject *parent) :
+ QObject(parent),
+ m_detailsWidget(widget)
+{
+}
+
+void DetailsWidgetContainerExtension::addWidget(QWidget *widget)
+{
+ if (m_detailsWidget->widget()) {
+ qWarning("Cannot add 2nd child to DetailsWidget");
+ } else {
+ m_detailsWidget->setWidget(widget);
+ }
+}
+
+int DetailsWidgetContainerExtension::count() const
+{
+ return m_detailsWidget->widget() ? 1 : 0;
+}
+
+int DetailsWidgetContainerExtension::currentIndex() const
+{
+ return 0;
+}
+
+void DetailsWidgetContainerExtension::insertWidget(int /* index */, QWidget *widget)
+{
+ addWidget(widget);
+}
+
+void DetailsWidgetContainerExtension::remove(int /* index */)
+{
+ m_detailsWidget->setWidget(0);
+}
+
+void DetailsWidgetContainerExtension::setCurrentIndex(int /* index */)
+{
+}
+
+QWidget *DetailsWidgetContainerExtension::widget(int /* index */) const
+{
+ return m_detailsWidget->widget();
+}
+
+DetailsWidgetExtensionFactory::DetailsWidgetExtensionFactory(QExtensionManager *parent) :
+ QExtensionFactory(parent)
+{
+}
+
+QObject *DetailsWidgetExtensionFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const
+{
+ if (Utils::DetailsWidget *dw = qobject_cast<Utils::DetailsWidget*>(object))
+ if (iid == Q_TYPEID(QDesignerContainerExtension))
+ return new DetailsWidgetContainerExtension(dw, parent);
+ return 0;
+}
+
// -------------- WidgetCollection
WidgetCollection::WidgetCollection(QObject *parent) :
QObject(parent)
{
-
m_plugins.push_back(new NewClassCustomWidget(this));
m_plugins.push_back(new ClassNameValidatingLineEdit_CW(this));
m_plugins.push_back(new FileNameValidatingLineEdit_CW(this));
@@ -181,6 +297,8 @@ WidgetCollection::WidgetCollection(QObject *parent) :
m_plugins.push_back(new SubmitEditorWidget_CW(this));
m_plugins.push_back(new SubmitFieldWidget_CW(this));
m_plugins.push_back(new PathListEditor_CW(this));
+ m_plugins.push_back(new DetailsButton_CW(this));
+ m_plugins.push_back(new DetailsWidget_CW(this));
}
QList<QDesignerCustomWidgetInterface*> WidgetCollection::customWidgets() const