彻底改版2.0

This commit is contained in:
feiyangqingyun
2021-11-17 16:41:30 +08:00
parent a7f4347959
commit ebfd531a91
2622 changed files with 8915 additions and 7263 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,290 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef ABSTRACTFORMBUILDER_H
#define ABSTRACTFORMBUILDER_H
#include <QtDesigner/uilib_global.h>
#include <QtCore/QList>
#include <QtCore/QHash>
#include <QtCore/QDir>
#include <QtGui/QSizePolicy>
#include <QtGui/QPalette>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#if 0
// pragma for syncqt, don't remove.
#pragma qt_class(QAbstractFormBuilder)
#endif
class QAction;
class QButtonGroup;
class QActionGroup;
class QComboBox;
class QIODevice;
class QIcon;
class QLayout;
class QLayoutItem;
class QListWidget;
class QObject;
class QSpacerItem;
class QTreeWidget;
class QTableWidget;
class QVariant;
class QWidget;
class QAbstractButton;
class QAbstractItemView;
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal
{
#endif
class DomAction;
class DomActionGroup;
class DomButtonGroup;
class DomButtonGroups;
class DomActionRef;
class DomBrush;
class DomColorGroup;
class DomConnections;
class DomCustomWidgets;
class DomLayout;
class DomLayoutItem;
class DomProperty;
class DomResources;
class DomSpacer;
class DomString;
class DomTabStops;
class DomUI;
class DomWidget;
class DomResourcePixmap;
class QResourceBuilder;
class QTextBuilder;
#ifndef QT_FORMBUILDER_NO_SCRIPT
class QFormScriptRunner;
#endif
class QDESIGNER_UILIB_EXPORT QAbstractFormBuilder
{
public:
QAbstractFormBuilder();
virtual ~QAbstractFormBuilder();
QDir workingDirectory() const;
void setWorkingDirectory(const QDir &directory);
virtual QWidget *load(QIODevice *dev, QWidget *parentWidget=0);
virtual void save(QIODevice *dev, QWidget *widget);
void setScriptingEnabled(bool enabled);
bool isScriptingEnabled() const;
protected:
//
// load
//
virtual void loadExtraInfo(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget);
virtual QWidget *create(DomUI *ui, QWidget *parentWidget);
virtual QWidget *create(DomWidget *ui_widget, QWidget *parentWidget);
virtual QLayout *create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget);
virtual QLayoutItem *create(DomLayoutItem *ui_layoutItem, QLayout *layout, QWidget *parentWidget);
virtual QAction *create(DomAction *ui_action, QObject *parent);
virtual QActionGroup *create(DomActionGroup *ui_action_group, QObject *parent);
virtual void addMenuAction(QAction *action);
virtual void applyProperties(QObject *o, const QList<DomProperty*> &properties);
bool applyPropertyInternally(QObject *o, const QString &propertyName, const QVariant &value);
virtual void applyTabStops(QWidget *widget, DomTabStops *tabStops);
virtual QWidget *createWidget(const QString &widgetName, QWidget *parentWidget, const QString &name);
virtual QLayout *createLayout(const QString &layoutName, QObject *parent, const QString &name);
virtual QAction *createAction(QObject *parent, const QString &name);
virtual QActionGroup *createActionGroup(QObject *parent, const QString &name);
virtual void createCustomWidgets(DomCustomWidgets *) {}
virtual void createConnections(DomConnections *, QWidget *) {}
virtual void createResources(DomResources*) {}
virtual bool addItem(DomLayoutItem *ui_item, QLayoutItem *item, QLayout *layout);
virtual bool addItem(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget);
//
// save
//
virtual void saveExtraInfo(QWidget *widget, DomWidget *ui_widget, DomWidget *ui_parentWidget);
virtual void saveDom(DomUI *ui, QWidget *widget);
virtual DomActionRef *createActionRefDom(QAction *action);
virtual DomWidget *createDom(QWidget *widget, DomWidget *ui_parentWidget, bool recursive = true);
virtual DomLayout *createDom(QLayout *layout, DomLayout *ui_layout, DomWidget *ui_parentWidget);
virtual DomLayoutItem *createDom(QLayoutItem *item, DomLayout *ui_parentLayout, DomWidget *ui_parentWidget);
virtual DomSpacer *createDom(QSpacerItem *spacer, DomLayout *ui_parentLayout, DomWidget *ui_parentWidget);
virtual DomAction *createDom(QAction *action);
virtual DomActionGroup *createDom(QActionGroup *actionGroup);
DomButtonGroup *createDom(QButtonGroup *buttonGroup);
virtual DomConnections *saveConnections();
virtual DomCustomWidgets *saveCustomWidgets();
virtual DomTabStops *saveTabStops();
virtual DomResources *saveResources();
DomButtonGroups *saveButtonGroups(const QWidget *mainContainer);
virtual QList<DomProperty*> computeProperties(QObject *obj);
virtual bool checkProperty(QObject *obj, const QString &prop) const;
virtual DomProperty *createProperty(QObject *object, const QString &propertyName, const QVariant &value);
virtual void layoutInfo(DomLayout *layout, QObject *parent, int *margin, int *spacing);
virtual QIcon nameToIcon(const QString &filePath, const QString &qrcPath);
virtual QString iconToFilePath(const QIcon &pm) const;
virtual QString iconToQrcPath(const QIcon &pm) const;
virtual QPixmap nameToPixmap(const QString &filePath, const QString &qrcPath);
virtual QString pixmapToFilePath(const QPixmap &pm) const;
virtual QString pixmapToQrcPath(const QPixmap &pm) const;
void loadListWidgetExtraInfo(DomWidget *ui_widget, QListWidget *listWidget, QWidget *parentWidget);
void loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWidget *treeWidget, QWidget *parentWidget);
void loadTableWidgetExtraInfo(DomWidget *ui_widget, QTableWidget *tableWidget, QWidget *parentWidget);
void loadComboBoxExtraInfo(DomWidget *ui_widget, QComboBox *comboBox, QWidget *parentWidget);
void loadButtonExtraInfo(const DomWidget *ui_widget, QAbstractButton *button, QWidget *parentWidget);
void loadItemViewExtraInfo(DomWidget *ui_widget, QAbstractItemView *itemView, QWidget *parentWidget);
void saveListWidgetExtraInfo(QListWidget *widget, DomWidget *ui_widget, DomWidget *ui_parentWidget);
void saveTreeWidgetExtraInfo(QTreeWidget *treeWidget, DomWidget *ui_widget, DomWidget *ui_parentWidget);
void saveTableWidgetExtraInfo(QTableWidget *tablWidget, DomWidget *ui_widget, DomWidget *ui_parentWidget);
void saveComboBoxExtraInfo(QComboBox *widget, DomWidget *ui_widget, DomWidget *ui_parentWidget);
void saveButtonExtraInfo(const QAbstractButton *widget, DomWidget *ui_widget, DomWidget *ui_parentWidget);
void saveItemViewExtraInfo(const QAbstractItemView *itemView, DomWidget *ui_widget, DomWidget *ui_parentWidget);
void setResourceBuilder(QResourceBuilder *builder);
QResourceBuilder *resourceBuilder() const;
DomProperty *saveResource(const QVariant &v) const;
void setTextBuilder(QTextBuilder *builder);
QTextBuilder *textBuilder() const;
DomProperty *saveText(const QString &attributeName, const QVariant &v) const;
//
// utils
//
QVariant toVariant(const QMetaObject *meta, DomProperty *property);
static QString toString(const DomString *str);
typedef QHash<QString, DomProperty*> DomPropertyHash;
static DomPropertyHash propertyMap(const QList<DomProperty*> &properties);
void setupColorGroup(QPalette &palette, QPalette::ColorGroup colorGroup, DomColorGroup *group);
DomColorGroup *saveColorGroup(const QPalette &palette);
QBrush setupBrush(DomBrush *brush);
DomBrush *saveBrush(const QBrush &brush);
void reset();
void initialize(const DomUI *ui);
#ifndef QT_FORMBUILDER_NO_SCRIPT
QFormScriptRunner *formScriptRunner() const;
#endif
//
// utils
//
static QMetaEnum toolBarAreaMetaEnum();
//
// Icon/pixmap stuff
//
// A Pair of icon path/qrc path.
typedef QPair<QString, QString> IconPaths;
IconPaths iconPaths(const QIcon &) const;
IconPaths pixmapPaths(const QPixmap &) const;
void setIconProperty(DomProperty &, const IconPaths &) const;
void setPixmapProperty(DomProperty &, const IconPaths &) const;
DomProperty* iconToDomProperty(const QIcon &) const;
static const DomResourcePixmap *domPixmap(const DomProperty* p);
QIcon domPropertyToIcon(const DomResourcePixmap *);
QIcon domPropertyToIcon(const DomProperty* p);
QPixmap domPropertyToPixmap(const DomResourcePixmap* p);
QPixmap domPropertyToPixmap(const DomProperty* p);
QHash<QObject*, bool> m_laidout;
QHash<QString, QAction*> m_actions;
QHash<QString, QActionGroup*> m_actionGroups;
int m_defaultMargin;
int m_defaultSpacing;
QDir m_workingDirectory;
private:
//
// utils
//
static Qt::ToolBarArea toolbarAreaFromDOMAttributes(const DomPropertyHash &attributeMap);
QAbstractFormBuilder(const QAbstractFormBuilder &other);
void operator = (const QAbstractFormBuilder &other);
friend QDESIGNER_UILIB_EXPORT DomProperty *variantToDomProperty(QAbstractFormBuilder *abstractFormBuilder, const QMetaObject *meta, const QString &propertyName, const QVariant &value);
friend QDESIGNER_UILIB_EXPORT QVariant domPropertyToVariant(QAbstractFormBuilder *abstractFormBuilder,const QMetaObject *meta, const DomProperty *property);
};
#ifdef QFORMINTERNAL_NAMESPACE
}
#endif
QT_END_NAMESPACE
QT_END_HEADER
#endif // ABSTRACTFORMBUILDER_H

View File

@@ -0,0 +1,75 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef CONTAINER_H
#define CONTAINER_H
#include <QtDesigner/extension.h>
#include <QtCore/QObject>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QWidget;
class QDesignerContainerExtension
{
public:
virtual ~QDesignerContainerExtension() {}
virtual int count() const = 0;
virtual QWidget *widget(int index) const = 0;
virtual int currentIndex() const = 0;
virtual void setCurrentIndex(int index) = 0;
virtual void addWidget(QWidget *widget) = 0;
virtual void insertWidget(int index, QWidget *widget) = 0;
virtual void remove(int index) = 0;
};
Q_DECLARE_EXTENSION_INTERFACE(QDesignerContainerExtension, "com.trolltech.Qt.Designer.Container")
QT_END_NAMESPACE
QT_END_HEADER
#endif // CONTAINER_H

View File

@@ -0,0 +1,172 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in a
** written agreement between you and Nokia.
**
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of this
** file.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\class QDesignerContainerExtension
\brief The QDesignerContainerExtension class allows you to add pages to
a custom multi-page container in Qt Designer's workspace.
\inmodule QtDesigner
QDesignerContainerExtension provide an interface for creating
custom container extensions. A container extension consists of a
collection of functions that \QD needs to manage a multi-page
container plugin, and a list of the container's pages.
\image containerextension-example.png
\warning This is \e not an extension for container plugins in
general, only custom \e multi-page containers.
To create a container extension, your extension class must inherit
from both QObject and QDesignerContainerExtension. For example:
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 6
Since we are implementing an interface, we must ensure that it's
made known to the meta object system using the Q_INTERFACES()
macro. This enables \QD to use the qobject_cast() function to
query for supported interfaces using nothing but a QObject
pointer.
You must reimplement several functions to enable \QD to manage a
custom multi-page container widget: \QD uses count() to keep track
of the number pages in your container, widget() to return the page
at a given index in the list of the container's pages, and
currentIndex() to return the list index of the selected page. \QD
uses the addWidget() function to add a given page to the
container, expecting it to be appended to the list of pages, while
it expects the insertWidget() function to add a given page to the
container by inserting it at a given index.
In \QD the extensions are not created until they are
required. For that reason you must also create a
QExtensionFactory, i.e a class that is able to make an instance of
your extension, and register it using \QD's \l
{QExtensionManager}{extension manager}.
When a container extension is required, \QD's \l
{QExtensionManager}{extension manager} will run through all its
registered factories calling QExtensionFactory::createExtension()
for each until the first one that is able to create a container
extension, is found. This factory will then create the extension
for the plugin.
There are four available types of extensions in \QD:
QDesignerContainerExtension , QDesignerMemberSheetExtension,
QDesignerPropertySheetExtension and QDesignerTaskMenuExtension.
\QD's behavior is the same whether the requested extension is
associated with a multi page container, a member sheet, a property
sheet or a task menu.
The QExtensionFactory class provides a standard extension factory,
and can also be used as an interface for custom extension
factories. You can either create a new QExtensionFactory and
reimplement the QExtensionFactory::createExtension() function. For
example:
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 7
Or you can use an existing factory, expanding the
QExtensionFactory::createExtension() function to make the factory
able to create a container extension as well. For example:
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 8
For a complete example using the QDesignerContainerExtension
class, see the \l {designer/containerextension}{Container
Extension example}. The example shows how to create a custom
multi-page plugin for \QD.
\sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
Extensions}
*/
/*!
\fn QDesignerContainerExtension::~QDesignerContainerExtension()
Destroys the extension.
*/
/*!
\fn int QDesignerContainerExtension::count() const
Returns the number of pages in the container.
*/
/*!
\fn QWidget *QDesignerContainerExtension::widget(int index) const
Returns the page at the given \a index in the extension's list of
pages.
\sa addWidget(), insertWidget()
*/
/*!
\fn int QDesignerContainerExtension::currentIndex() const
Returns the index of the currently selected page in the
container.
\sa setCurrentIndex()
*/
/*!
\fn void QDesignerContainerExtension::setCurrentIndex(int index)
Sets the currently selected page in the container to be the
page at the given \a index in the extension's list of pages.
\sa currentIndex()
*/
/*!
\fn void QDesignerContainerExtension::addWidget(QWidget *page)
Adds the given \a page to the container by appending it to the
extension's list of pages.
\sa insertWidget(), remove(), widget()
*/
/*!
\fn void QDesignerContainerExtension::insertWidget(int index, QWidget *page)
Adds the given \a page to the container by inserting it at the
given \a index in the extension's list of pages.
\sa addWidget(), remove(), widget()
*/
/*!
\fn void QDesignerContainerExtension::remove(int index)
Removes the page at the given \a index from the extension's list
of pages.
\sa addWidget(), insertWidget()
*/

View File

@@ -0,0 +1,101 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef CUSTOMWIDGET_H
#define CUSTOMWIDGET_H
#include <QtDesigner/extension.h>
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtGui/QIcon>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QWidget;
class QDesignerFormEditorInterface;
class QDesignerCustomWidgetInterface
{
public:
virtual ~QDesignerCustomWidgetInterface() {}
virtual QString name() const = 0;
virtual QString group() const = 0;
virtual QString toolTip() const = 0;
virtual QString whatsThis() const = 0;
virtual QString includeFile() const = 0;
virtual QIcon icon() const = 0;
virtual bool isContainer() const = 0;
virtual QWidget *createWidget(QWidget *parent) = 0;
virtual bool isInitialized() const { return false; }
virtual void initialize(QDesignerFormEditorInterface *core) { Q_UNUSED(core); }
virtual QString domXml() const
{
return QString::fromUtf8("<widget class=\"%1\" name=\"%2\"/>")
.arg(name()).arg(name().toLower());
}
virtual QString codeTemplate() const { return QString(); }
};
Q_DECLARE_INTERFACE(QDesignerCustomWidgetInterface, "com.trolltech.Qt.Designer.CustomWidget")
class QDesignerCustomWidgetCollectionInterface
{
public:
virtual ~QDesignerCustomWidgetCollectionInterface() {}
virtual QList<QDesignerCustomWidgetInterface*> customWidgets() const = 0;
};
Q_DECLARE_INTERFACE(QDesignerCustomWidgetCollectionInterface,
"com.trolltech.Qt.Designer.CustomWidgetCollection")
QT_END_NAMESPACE
QT_END_HEADER
#endif // CUSTOMWIDGET_H

View File

@@ -0,0 +1,295 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in a
** written agreement between you and Nokia.
**
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of this
** file.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\class QDesignerCustomWidgetInterface
\brief The QDesignerCustomWidgetInterface class enables Qt Designer
to access and construct custom widgets.
\inmodule QtDesigner
QDesignerCustomWidgetInterface provides a custom widget with an
interface. The class contains a set of functions that must be subclassed
to return basic information about the widget, such as its class name and
the name of its header file. Other functions must be implemented to
initialize the plugin when it is loaded, and to construct instances of
the custom widget for \QD to use.
When implementing a custom widget you must subclass
QDesignerCustomWidgetInterface to expose your widget to \QD. For
example, this is the declaration for the plugin used in the
\l{Custom Widget Plugin Example}{Custom Widget Plugin example} that
enables an analog clock custom widget to be used by \QD:
\snippet examples/designer/customwidgetplugin/customwidgetplugin.h 0
Note that the only part of the class definition that is specific
to this particular custom widget is the class name. In addition,
since we are implementing an interface, we must ensure that it's
made known to the meta object system using the Q_INTERFACES()
macro. This enables \QD to use the qobject_cast() function to
query for supported interfaces using nothing but a QObject
pointer.
After \QD loads a custom widget plugin, it calls the interface's
initialize() function to enable it to set up any resources that it
may need. This function is called with a QDesignerFormEditorInterface
parameter that provides the plugin with a gateway to all of \QD's API.
\QD constructs instances of the custom widget by calling the plugin's
createWidget() function with a suitable parent widget. Plugins must
construct and return an instance of a custom widget with the specified
parent widget.
In the implementation of the class you must remember to export
your custom widget plugin to \QD using the Q_EXPORT_PLUGIN2()
macro. For example, if a library called \c libcustomwidgetplugin.so
(on Unix) or \c libcustomwidget.dll (on Windows) contains a widget
class called \c MyCustomWidget, we can export it by adding the
following line to the file containing the plugin implementation:
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 14
This macro ensures that \QD can access and construct the custom widget.
Without this macro, there is no way for \QD to use it.
When implementing a custom widget plugin, you build it as a
separate library. If you want to include several custom widget
plugins in the same library, you must in addition subclass
QDesignerCustomWidgetCollectionInterface.
\warning If your custom widget plugin contains QVariant
properties, be aware that only the following \l
{QVariant::Type}{types} are supported:
\list
\o QVariant::ByteArray
\o QVariant::Bool
\o QVariant::Color
\o QVariant::Cursor
\o QVariant::Date
\o QVariant::DateTime
\o QVariant::Double
\o QVariant::Int
\o QVariant::Point
\o QVariant::Rect
\o QVariant::Size
\o QVariant::SizePolicy
\o QVariant::String
\o QVariant::Time
\o QVariant::UInt
\endlist
For a complete example using the QDesignerCustomWidgetInterface
class, see the \l {designer/customwidgetplugin}{Custom Widget
Example}. The example shows how to create a custom widget plugin
for \QD.
\sa QDesignerCustomWidgetCollectionInterface {Creating Custom
Widgets for Qt Designer}
*/
/*!
\fn QDesignerCustomWidgetInterface::~QDesignerCustomWidgetInterface()
Destroys the custom widget interface.
*/
/*!
\fn QString QDesignerCustomWidgetInterface::name() const
Returns the class name of the custom widget supplied by the interface.
The name returned \e must be identical to the class name used for the
custom widget.
*/
/*!
\fn QString QDesignerCustomWidgetInterface::group() const
Returns the name of the group to which the custom widget belongs.
*/
/*!
\fn QString QDesignerCustomWidgetInterface::toolTip() const
Returns a short description of the widget that can be used by \QD
in a tool tip.
*/
/*!
\fn QString QDesignerCustomWidgetInterface::whatsThis() const
Returns a description of the widget that can be used by \QD in
"What's This?" help for the widget.
*/
/*!
\fn QString QDesignerCustomWidgetInterface::includeFile() const
Returns the path to the include file that \l uic uses when
creating code for the custom widget.
*/
/*!
\fn QIcon QDesignerCustomWidgetInterface::icon() const
Returns the icon used to represent the custom widget in \QD's
widget box.
*/
/*!
\fn bool QDesignerCustomWidgetInterface::isContainer() const
Returns true if the custom widget is intended to be used as a
container; otherwise returns false.
Most custom widgets are not used to hold other widgets, so their
implementations of this function will return false, but custom
containers will return true to ensure that they behave correctly
in \QD.
*/
/*!
\fn QWidget *QDesignerCustomWidgetInterface::createWidget(QWidget *parent)
Returns a new instance of the custom widget, with the given \a
parent.
*/
/*!
\fn bool QDesignerCustomWidgetInterface::isInitialized() const
Returns true if the widget has been initialized; otherwise returns
false.
\sa initialize()
*/
/*!
\fn void QDesignerCustomWidgetInterface::initialize(QDesignerFormEditorInterface *formEditor)
Initializes the widget for use with the specified \a formEditor
interface.
\sa isInitialized()
*/
/*!
\fn QString QDesignerCustomWidgetInterface::domXml() const
Returns the XML that is used to describe the custom widget's
properties to \QD.
*/
/*!
\fn QString QDesignerCustomWidgetInterface::codeTemplate() const
This function is reserved for future use by \QD.
\omit
Returns the code template that \QD includes in forms that contain
the custom widget when they are saved.
\endomit
*/
/*!
\macro QDESIGNER_WIDGET_EXPORT
\relates QDesignerCustomWidgetInterface
\since 4.1
This macro is used when defining custom widgets to ensure that they are
correctly exported from plugins for use with \QD.
On some platforms, the symbols required by \QD to create new widgets
are removed from plugins by the build system, making them unusable.
Using this macro ensures that the symbols are retained on those platforms,
and has no side effects on other platforms.
For example, the \l{designer/worldtimeclockplugin}{World Time Clock Plugin}
example exports a custom widget class with the following declaration:
\snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 0
\dots
\snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 2
\sa {Creating Custom Widgets for Qt Designer}
*/
/*!
\class QDesignerCustomWidgetCollectionInterface
\brief The QDesignerCustomWidgetCollectionInterface class allows
you to include several custom widgets in one single library.
\inmodule QtDesigner
When implementing a custom widget plugin, you build it as a
separate library. If you want to include several custom widget
plugins in the same library, you must in addition subclass
QDesignerCustomWidgetCollectionInterface.
QDesignerCustomWidgetCollectionInterface contains one single
function returning a list of the collection's
QDesignerCustomWidgetInterface objects. For example, if you have
several custom widgets \c CustomWidgetOne, \c CustomWidgetTwo and
\c CustomWidgetThree, the class definition may look like this:
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 12
In the class constructor you add the interfaces to your custom
widgets to the list which you return in the customWidgets()
function:
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 13
Note that instead of exporting each custom widget plugin using the
Q_EXPORT_PLUGIN2() macro, you export the entire collection. The
Q_EXPORT_PLUGIN2() macro ensures that \QD can access and construct
the custom widgets. Without this macro, there is no way for \QD to
use them.
\sa QDesignerCustomWidgetInterface, {Creating Custom Widgets for
Qt Designer}
*/
/*!
\fn QDesignerCustomWidgetCollectionInterface::~QDesignerCustomWidgetCollectionInterface() {
Destroys the custom widget collection interface.
*/
/*!
\fn QList<QDesignerCustomWidgetInterface*> QDesignerCustomWidgetCollectionInterface::customWidgets() const
Returns a list of interfaces to the collection's custom widgets.
*/

View File

@@ -0,0 +1,570 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "customwidget.h"
#include "formbuilder.h"
#include "formbuilderextra_p.h"
#include "ui4_p.h"
#include <QtGui/QtGui>
#include <QtCore/QCoreApplication>
QT_BEGIN_NAMESPACE
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal {
#endif
/*!
\class QFormBuilder
\brief The QFormBuilder class is used to dynamically construct
user interfaces from UI files at run-time.
\inmodule QtDesigner
The QFormBuilder class provides a mechanism for dynamically
creating user interfaces at run-time, based on UI files
created with \QD. For example:
\snippet doc/src/snippets/code/tools_designer_src_lib_uilib_formbuilder.cpp 0
By including the user interface in the example's resources (\c
myForm.qrc), we ensure that it will be present when the example is
run:
\snippet doc/src/snippets/code/tools_designer_src_lib_uilib_formbuilder.cpp 1
QFormBuilder extends the QAbstractFormBuilder base class with a
number of functions that are used to support custom widget
plugins:
\list
\o pluginPaths() returns the list of paths that the form builder
searches when loading custom widget plugins.
\o addPluginPath() allows additional paths to be registered with
the form builder.
\o setPluginPath() is used to replace the existing list of paths
with a list obtained from some other source.
\o clearPluginPaths() removes all paths registered with the form
builder.
\o customWidgets() returns a list of interfaces to plugins that
can be used to create new instances of registered custom widgets.
\endlist
The QFormBuilder class is typically used by custom components and
applications that embed \QD. Standalone applications that need to
dynamically generate user interfaces at run-time use the
QUiLoader class, found in the QtUiTools module.
\sa QAbstractFormBuilder, {QtUiTools Module}
*/
/*!
\fn QFormBuilder::QFormBuilder()
Constructs a new form builder.
*/
QFormBuilder::QFormBuilder() : QAbstractFormBuilder()
{
}
/*!
Destroys the form builder.
*/
QFormBuilder::~QFormBuilder()
{
}
/*!
\internal
*/
QWidget *QFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget)
{
QFormBuilderExtra *fb = QFormBuilderExtra::instance(this);
if (!fb->parentWidgetIsSet())
fb->setParentWidget(parentWidget);
// Is this a QLayoutWidget with a margin of 0: Not a known page-based
// container and no method for adding pages registered.
fb->setProcessingLayoutWidget(false);
if (ui_widget->attributeClass() == QFormBuilderStrings::instance().qWidgetClass && !ui_widget->hasAttributeNative()
&& parentWidget
#ifndef QT_NO_MAINWINDOW
&& !qobject_cast<QMainWindow *>(parentWidget)
#endif
#ifndef QT_NO_TOOLBOX
&& !qobject_cast<QToolBox *>(parentWidget)
#endif
#ifndef QT_NO_STACKEDWIDGET
&& !qobject_cast<QStackedWidget *>(parentWidget)
#endif
#ifndef QT_NO_STACKEDWIDGET
&& !qobject_cast<QTabWidget *>(parentWidget)
#endif
#ifndef QT_NO_SCROLLAREA
&& !qobject_cast<QScrollArea *>(parentWidget)
#endif
#ifndef QT_NO_MDIAREA
&& !qobject_cast<QMdiArea *>(parentWidget)
#endif
#ifndef QT_NO_DOCKWIDGET
&& !qobject_cast<QDockWidget *>(parentWidget)
#endif
) {
const QString parentClassName = QLatin1String(parentWidget->metaObject()->className());
if (!fb->isCustomWidgetContainer(parentClassName))
fb->setProcessingLayoutWidget(true);
}
return QAbstractFormBuilder::create(ui_widget, parentWidget);
}
/*!
\internal
*/
QWidget *QFormBuilder::createWidget(const QString &widgetName, QWidget *parentWidget, const QString &name)
{
if (widgetName.isEmpty()) {
//: Empty class name passed to widget factory method
qWarning() << QCoreApplication::translate("QFormBuilder", "An empty class name was passed on to %1 (object name: '%2').").arg(QString::fromUtf8(Q_FUNC_INFO), name);
return 0;
}
QWidget *w = 0;
#ifndef QT_NO_TABWIDGET
if (qobject_cast<QTabWidget*>(parentWidget))
parentWidget = 0;
#endif
#ifndef QT_NO_STACKEDWIDGET
if (qobject_cast<QStackedWidget*>(parentWidget))
parentWidget = 0;
#endif
#ifndef QT_NO_TOOLBOX
if (qobject_cast<QToolBox*>(parentWidget))
parentWidget = 0;
#endif
// ### special-casing for Line (QFrame) -- fix for 4.2
do {
if (widgetName == QFormBuilderStrings::instance().lineClass) {
w = new QFrame(parentWidget);
static_cast<QFrame*>(w)->setFrameStyle(QFrame::HLine | QFrame::Sunken);
break;
}
const QByteArray widgetNameBA = widgetName.toUtf8();
const char *widgetNameC = widgetNameBA.constData();
if (w) { // symmetry for macro
}
#define DECLARE_LAYOUT(L, C)
#define DECLARE_COMPAT_WIDGET(W, C)
#define DECLARE_WIDGET(W, C) else if (!qstrcmp(widgetNameC, #W)) { Q_ASSERT(w == 0); w = new W(parentWidget); }
#define DECLARE_WIDGET_1(W, C) else if (!qstrcmp(widgetNameC, #W)) { Q_ASSERT(w == 0); w = new W(0, parentWidget); }
#include "widgets.table"
#undef DECLARE_COMPAT_WIDGET
#undef DECLARE_LAYOUT
#undef DECLARE_WIDGET
#undef DECLARE_WIDGET_1
if (w)
break;
// try with a registered custom widget
QDesignerCustomWidgetInterface *factory = m_customWidgets.value(widgetName);
if (factory != 0)
w = factory->createWidget(parentWidget);
} while(false);
QFormBuilderExtra *fb = QFormBuilderExtra::instance(this);
if (w == 0) { // Attempt to instantiate base class of promoted/custom widgets
const QString baseClassName = fb->customWidgetBaseClass(widgetName);
if (!baseClassName.isEmpty()) {
qWarning() << QCoreApplication::translate("QFormBuilder", "QFormBuilder was unable to create a custom widget of the class '%1'; defaulting to base class '%2'.").arg(widgetName, baseClassName);
return createWidget(baseClassName, parentWidget, name);
}
}
if (w == 0) { // nothing to do
qWarning() << QCoreApplication::translate("QFormBuilder", "QFormBuilder was unable to create a widget of the class '%1'.").arg(widgetName);
return 0;
}
w->setObjectName(name);
if (qobject_cast<QDialog *>(w))
w->setParent(parentWidget);
return w;
}
/*!
\internal
*/
QLayout *QFormBuilder::createLayout(const QString &layoutName, QObject *parent, const QString &name)
{
QLayout *l = 0;
QWidget *parentWidget = qobject_cast<QWidget*>(parent);
QLayout *parentLayout = qobject_cast<QLayout*>(parent);
Q_ASSERT(parentWidget || parentLayout);
#define DECLARE_WIDGET(W, C)
#define DECLARE_COMPAT_WIDGET(W, C)
#define DECLARE_LAYOUT(L, C) \
if (layoutName == QLatin1String(#L)) { \
Q_ASSERT(l == 0); \
l = parentLayout \
? new L() \
: new L(parentWidget); \
}
#include "widgets.table"
#undef DECLARE_LAYOUT
#undef DECLARE_COMPAT_WIDGET
#undef DECLARE_WIDGET
if (l) {
l->setObjectName(name);
if (parentLayout) {
QWidget *w = qobject_cast<QWidget *>(parentLayout->parent());
if (w && w->inherits("Q3GroupBox")) {
l->setContentsMargins(w->style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
w->style()->pixelMetric(QStyle::PM_LayoutTopMargin),
w->style()->pixelMetric(QStyle::PM_LayoutRightMargin),
w->style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
QGridLayout *grid = qobject_cast<QGridLayout *>(l);
if (grid) {
grid->setHorizontalSpacing(-1);
grid->setVerticalSpacing(-1);
} else {
l->setSpacing(-1);
}
l->setAlignment(Qt::AlignTop);
}
}
} else {
qWarning() << QCoreApplication::translate("QFormBuilder", "The layout type `%1' is not supported.").arg(layoutName);
}
return l;
}
/*!
\internal
*/
bool QFormBuilder::addItem(DomLayoutItem *ui_item, QLayoutItem *item, QLayout *layout)
{
return QAbstractFormBuilder::addItem(ui_item, item, layout);
}
/*!
\internal
*/
bool QFormBuilder::addItem(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget)
{
return QAbstractFormBuilder::addItem(ui_widget, widget, parentWidget);
}
/*!
\internal
*/
QWidget *QFormBuilder::widgetByName(QWidget *topLevel, const QString &name)
{
Q_ASSERT(topLevel);
if (topLevel->objectName() == name)
return topLevel;
return qFindChild<QWidget*>(topLevel, name);
}
static QObject *objectByName(QWidget *topLevel, const QString &name)
{
Q_ASSERT(topLevel);
if (topLevel->objectName() == name)
return topLevel;
return qFindChild<QObject*>(topLevel, name);
}
/*!
\internal
*/
void QFormBuilder::createConnections(DomConnections *ui_connections, QWidget *widget)
{
typedef QList<DomConnection*> DomConnectionList;
Q_ASSERT(widget != 0);
if (ui_connections == 0)
return;
const DomConnectionList connections = ui_connections->elementConnection();
if (!connections.empty()) {
const DomConnectionList::const_iterator cend = connections.constEnd();
for (DomConnectionList::const_iterator it = connections.constBegin(); it != cend; ++it) {
QObject *sender = objectByName(widget, (*it)->elementSender());
QObject *receiver = objectByName(widget, (*it)->elementReceiver());
if (!sender || !receiver)
continue;
QByteArray sig = (*it)->elementSignal().toUtf8();
sig.prepend("2");
QByteArray sl = (*it)->elementSlot().toUtf8();
sl.prepend("1");
QObject::connect(sender, sig, receiver, sl);
}
}
}
/*!
\internal
*/
QWidget *QFormBuilder::create(DomUI *ui, QWidget *parentWidget)
{
return QAbstractFormBuilder::create(ui, parentWidget);
}
/*!
\internal
*/
QLayout *QFormBuilder::create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget)
{
QFormBuilderExtra *fb = QFormBuilderExtra::instance(this);
// Is this a temporary layout widget used to represent QLayout hierarchies in Designer?
// Set its margins to 0.
bool layoutWidget = fb->processingLayoutWidget();
QLayout *l = QAbstractFormBuilder::create(ui_layout, layout, parentWidget);
if (layoutWidget) {
const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
int left, top, right, bottom;
left = top = right = bottom = 0;
const DomPropertyHash properties = propertyMap(ui_layout->elementProperty());
if (DomProperty *prop = properties.value(strings.leftMarginProperty))
left = prop->elementNumber();
if (DomProperty *prop = properties.value(strings.topMarginProperty))
top = prop->elementNumber();
if (DomProperty *prop = properties.value(strings.rightMarginProperty))
right = prop->elementNumber();
if (DomProperty *prop = properties.value(strings.bottomMarginProperty))
bottom = prop->elementNumber();
l->setContentsMargins(left, top, right, bottom);
fb->setProcessingLayoutWidget(false);
}
return l;
}
/*!
\internal
*/
QLayoutItem *QFormBuilder::create(DomLayoutItem *ui_layoutItem, QLayout *layout, QWidget *parentWidget)
{
return QAbstractFormBuilder::create(ui_layoutItem, layout, parentWidget);
}
/*!
\internal
*/
QAction *QFormBuilder::create(DomAction *ui_action, QObject *parent)
{
return QAbstractFormBuilder::create(ui_action, parent);
}
/*!
\internal
*/
QActionGroup *QFormBuilder::create(DomActionGroup *ui_action_group, QObject *parent)
{
return QAbstractFormBuilder::create(ui_action_group, parent);
}
/*!
Returns the list of paths the form builder searches for plugins.
\sa addPluginPath()
*/
QStringList QFormBuilder::pluginPaths() const
{
return m_pluginPaths;
}
/*!
Clears the list of paths that the form builder uses to search for
custom widget plugins.
\sa pluginPaths()
*/
void QFormBuilder::clearPluginPaths()
{
m_pluginPaths.clear();
updateCustomWidgets();
}
/*!
Adds a new plugin path specified by \a pluginPath to the list of
paths that will be searched by the form builder when loading a
custom widget plugin.
\sa setPluginPath(), clearPluginPaths()
*/
void QFormBuilder::addPluginPath(const QString &pluginPath)
{
m_pluginPaths.append(pluginPath);
updateCustomWidgets();
}
/*!
Sets the list of plugin paths to the list specified by \a pluginPaths.
\sa addPluginPath()
*/
void QFormBuilder::setPluginPath(const QStringList &pluginPaths)
{
m_pluginPaths = pluginPaths;
updateCustomWidgets();
}
static void insertPlugins(QObject *o, QMap<QString, QDesignerCustomWidgetInterface*> *customWidgets)
{
// step 1) try with a normal plugin
if (QDesignerCustomWidgetInterface *iface = qobject_cast<QDesignerCustomWidgetInterface *>(o)) {
customWidgets->insert(iface->name(), iface);
return;
}
// step 2) try with a collection of plugins
if (QDesignerCustomWidgetCollectionInterface *c = qobject_cast<QDesignerCustomWidgetCollectionInterface *>(o)) {
foreach (QDesignerCustomWidgetInterface *iface, c->customWidgets())
customWidgets->insert(iface->name(), iface);
}
}
/*!
\internal
*/
void QFormBuilder::updateCustomWidgets()
{
m_customWidgets.clear();
foreach (const QString &path, m_pluginPaths) {
const QDir dir(path);
const QStringList candidates = dir.entryList(QDir::Files);
foreach (const QString &plugin, candidates) {
if (!QLibrary::isLibrary(plugin))
continue;
QString loaderPath = path;
loaderPath += QLatin1Char('/');
loaderPath += plugin;
QPluginLoader loader(loaderPath);
if (loader.load())
insertPlugins(loader.instance(), &m_customWidgets);
}
}
// Check statically linked plugins
const QObjectList staticPlugins = QPluginLoader::staticInstances();
if (!staticPlugins.empty())
foreach (QObject *o, staticPlugins)
insertPlugins(o, &m_customWidgets);
}
/*!
\fn QList<QDesignerCustomWidgetInterface*> QFormBuilder::customWidgets() const
Returns a list of the available plugins.
*/
QList<QDesignerCustomWidgetInterface*> QFormBuilder::customWidgets() const
{
return m_customWidgets.values();
}
/*!
\internal
*/
void QFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties)
{
typedef QList<DomProperty*> DomPropertyList;
if (properties.empty())
return;
QFormBuilderExtra *fb = QFormBuilderExtra::instance(this);
const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
const DomPropertyList::const_iterator cend = properties.constEnd();
for (DomPropertyList::const_iterator it = properties.constBegin(); it != cend; ++it) {
const QVariant v = toVariant(o->metaObject(), *it);
if (v.isNull())
continue;
const QString attributeName = (*it)->attributeName();
const bool isWidget = o->isWidgetType();
if (isWidget && o->parent() == fb->parentWidget() && attributeName == strings.geometryProperty) {
// apply only the size part of a geometry for the root widget
static_cast<QWidget*>(o)->resize(qvariant_cast<QRect>(v).size());
} else if (fb->applyPropertyInternally(o, attributeName, v)) {
} else if (isWidget && !qstrcmp("QFrame", o->metaObject()->className ()) && attributeName == strings.orientationProperty) {
// ### special-casing for Line (QFrame) -- try to fix me
o->setProperty("frameShape", v); // v is of QFrame::Shape enum
} else {
o->setProperty(attributeName.toUtf8(), v);
}
}
}
#ifdef QFORMINTERNAL_NAMESPACE
} // namespace QFormInternal
#endif
QT_END_NAMESPACE

View File

@@ -0,0 +1,115 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef FORMBUILDER_H
#define FORMBUILDER_H
#include <QtDesigner/uilib_global.h>
#include <QtDesigner/QAbstractFormBuilder>
#include <QtCore/QStringList>
#include <QtCore/QMap>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#if 0
// pragma for syncqt, don't remove.
#pragma qt_class(QFormBuilder)
#endif
class QDesignerCustomWidgetInterface;
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal
{
#endif
class QDESIGNER_UILIB_EXPORT QFormBuilder: public QAbstractFormBuilder
{
public:
QFormBuilder();
virtual ~QFormBuilder();
QStringList pluginPaths() const;
void clearPluginPaths();
void addPluginPath(const QString &pluginPath);
void setPluginPath(const QStringList &pluginPaths);
QList<QDesignerCustomWidgetInterface*> customWidgets() const;
protected:
virtual QWidget *create(DomUI *ui, QWidget *parentWidget);
virtual QWidget *create(DomWidget *ui_widget, QWidget *parentWidget);
virtual QLayout *create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget);
virtual QLayoutItem *create(DomLayoutItem *ui_layoutItem, QLayout *layout, QWidget *parentWidget);
virtual QAction *create(DomAction *ui_action, QObject *parent);
virtual QActionGroup *create(DomActionGroup *ui_action_group, QObject *parent);
virtual QWidget *createWidget(const QString &widgetName, QWidget *parentWidget, const QString &name);
virtual QLayout *createLayout(const QString &layoutName, QObject *parent, const QString &name);
virtual void createConnections(DomConnections *connections, QWidget *widget);
virtual bool addItem(DomLayoutItem *ui_item, QLayoutItem *item, QLayout *layout);
virtual bool addItem(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget);
virtual void updateCustomWidgets();
virtual void applyProperties(QObject *o, const QList<DomProperty*> &properties);
static QWidget *widgetByName(QWidget *topLevel, const QString &name);
private:
QStringList m_pluginPaths;
QMap<QString, QDesignerCustomWidgetInterface*> m_customWidgets;
};
#ifdef QFORMINTERNAL_NAMESPACE
}
#endif
QT_END_NAMESPACE
QT_END_HEADER
#endif // FORMBUILDER_H

View File

@@ -0,0 +1,555 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "formbuilderextra_p.h"
#include "abstractformbuilder.h"
#include "resourcebuilder_p.h"
#include "textbuilder_p.h"
#include "ui4_p.h"
#include <QtGui/QLabel>
#include <QtGui/QBoxLayout>
#include <QtGui/QGridLayout>
#include <QtCore/QVariant>
#include <QtCore/qdebug.h>
#include <QtCore/QTextStream>
#include <QtCore/QStringList>
#include <QtCore/QCoreApplication>
QT_BEGIN_NAMESPACE
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal {
#endif
void uiLibWarning(const QString &message) {
qWarning("Designer: %s", qPrintable(message));
}
QFormBuilderExtra::CustomWidgetData::CustomWidgetData() :
isContainer(false)
{
}
QFormBuilderExtra::CustomWidgetData::CustomWidgetData(const DomCustomWidget *dcw) :
addPageMethod(dcw->elementAddPageMethod()),
baseClass(dcw->elementExtends()),
isContainer(dcw->hasElementContainer() && dcw->elementContainer() != 0)
{
#ifndef QT_FORMBUILDER_NO_SCRIPT
if (const DomScript *domScript = dcw->elementScript())
script = domScript->text();
#endif
}
QFormBuilderExtra::QFormBuilderExtra() :
m_layoutWidget(false),
m_resourceBuilder(0),
m_textBuilder(0)
{
}
QFormBuilderExtra::~QFormBuilderExtra()
{
clearResourceBuilder();
clearTextBuilder();
}
void QFormBuilderExtra::clear()
{
m_buddies.clear();
m_parentWidget = 0;
m_parentWidgetIsSet = false;
#ifndef QT_FORMBUILDER_NO_SCRIPT
m_FormScriptRunner.clearErrors();
#endif
m_customWidgetDataHash.clear();
m_buttonGroups.clear();
}
bool QFormBuilderExtra::applyPropertyInternally(QObject *o, const QString &propertyName, const QVariant &value)
{
// Store buddies and apply them later on as the widgets might not exist yet.
QLabel *label = qobject_cast<QLabel*>(o);
if (!label || propertyName != QFormBuilderStrings::instance().buddyProperty)
return false;
m_buddies.insert(label, value.toString());
return true;
}
void QFormBuilderExtra::applyInternalProperties() const
{
if (m_buddies.empty())
return;
const BuddyHash::const_iterator cend = m_buddies.constEnd();
for (BuddyHash::const_iterator it = m_buddies.constBegin(); it != cend; ++it )
applyBuddy(it.value(), BuddyApplyAll, it.key());
}
bool QFormBuilderExtra::applyBuddy(const QString &buddyName, BuddyMode applyMode, QLabel *label)
{
if (buddyName.isEmpty()) {
label->setBuddy(0);
return false;
}
const QWidgetList widgets = qFindChildren<QWidget*>(label->topLevelWidget(), buddyName);
if (widgets.empty()) {
label->setBuddy(0);
return false;
}
const QWidgetList::const_iterator cend = widgets.constEnd();
for ( QWidgetList::const_iterator it = widgets.constBegin(); it != cend; ++it) {
if (applyMode == BuddyApplyAll || !(*it)->isHidden()) {
label->setBuddy(*it);
return true;
}
}
label->setBuddy(0);
return false;
}
const QPointer<QWidget> &QFormBuilderExtra::parentWidget() const
{
return m_parentWidget;
}
bool QFormBuilderExtra::parentWidgetIsSet() const
{
return m_parentWidgetIsSet;
}
void QFormBuilderExtra::setParentWidget(const QPointer<QWidget> &w)
{
// Parent widget requires special handling of the geometry property.
m_parentWidget = w;
m_parentWidgetIsSet = true;
}
#ifndef QT_FORMBUILDER_NO_SCRIPT
QFormScriptRunner &QFormBuilderExtra::formScriptRunner()
{
return m_FormScriptRunner;
}
QString QFormBuilderExtra::customWidgetScript(const QString &className) const
{
const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className);
if (it != m_customWidgetDataHash.constEnd())
return it.value().script;
return QString();
}
#endif
void QFormBuilderExtra::storeCustomWidgetData(const QString &className, const DomCustomWidget *d)
{
if (d)
m_customWidgetDataHash.insert(className, CustomWidgetData(d));
}
QString QFormBuilderExtra::customWidgetBaseClass(const QString &className) const
{
const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className);
if (it != m_customWidgetDataHash.constEnd())
return it.value().baseClass;
return QString();
}
QString QFormBuilderExtra::customWidgetAddPageMethod(const QString &className) const
{
const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className);
if (it != m_customWidgetDataHash.constEnd())
return it.value().addPageMethod;
return QString();
}
bool QFormBuilderExtra::isCustomWidgetContainer(const QString &className) const
{
const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className);
if (it != m_customWidgetDataHash.constEnd())
return it.value().isContainer;
return false;
}
namespace {
typedef QHash<const QAbstractFormBuilder *, QFormBuilderExtra *> FormBuilderPrivateHash;
}
Q_GLOBAL_STATIC(FormBuilderPrivateHash, g_FormBuilderPrivateHash)
QFormBuilderExtra *QFormBuilderExtra::instance(const QAbstractFormBuilder *afb)
{
FormBuilderPrivateHash &fbHash = *g_FormBuilderPrivateHash();
FormBuilderPrivateHash::iterator it = fbHash.find(afb);
if (it == fbHash.end())
it = fbHash.insert(afb, new QFormBuilderExtra);
return it.value();
}
void QFormBuilderExtra::removeInstance(const QAbstractFormBuilder *afb)
{
FormBuilderPrivateHash &fbHash = *g_FormBuilderPrivateHash();
FormBuilderPrivateHash::iterator it = fbHash.find(afb);
if (it != fbHash.end()) {
delete it.value();
fbHash.erase(it);
}
}
void QFormBuilderExtra::setProcessingLayoutWidget(bool processing)
{
m_layoutWidget = processing;
}
bool QFormBuilderExtra::processingLayoutWidget() const
{
return m_layoutWidget;
}
void QFormBuilderExtra::setResourceBuilder(QResourceBuilder *builder)
{
if (m_resourceBuilder == builder)
return;
clearResourceBuilder();
m_resourceBuilder = builder;
}
QResourceBuilder *QFormBuilderExtra::resourceBuilder() const
{
return m_resourceBuilder;
}
void QFormBuilderExtra::clearResourceBuilder()
{
if (m_resourceBuilder) {
delete m_resourceBuilder;
m_resourceBuilder = 0;
}
}
void QFormBuilderExtra::setTextBuilder(QTextBuilder *builder)
{
if (m_textBuilder == builder)
return;
clearTextBuilder();
m_textBuilder = builder;
}
QTextBuilder *QFormBuilderExtra::textBuilder() const
{
return m_textBuilder;
}
void QFormBuilderExtra::clearTextBuilder()
{
if (m_textBuilder) {
delete m_textBuilder;
m_textBuilder = 0;
}
}
void QFormBuilderExtra::registerButtonGroups(const DomButtonGroups *domGroups)
{
typedef QList<DomButtonGroup*> DomButtonGroupList;
const DomButtonGroupList domGroupList = domGroups->elementButtonGroup();
const DomButtonGroupList::const_iterator cend = domGroupList.constEnd();
for (DomButtonGroupList::const_iterator it = domGroupList.constBegin(); it != cend; ++it) {
DomButtonGroup *domGroup = *it;
m_buttonGroups.insert(domGroup->attributeName(), ButtonGroupEntry(domGroup, 0));
}
}
// Utilities for parsing per-cell integer properties that have setters and
// getters of the form 'setX(int idx, int value)' and 'x(int index)'
// (converting them to comma-separated string lists and back).
// Used for layout stretch and grid per-row/column properties.
// Format a list of cell-properties of one dimension as a ','-separated list
template <class Layout>
inline QString perCellPropertyToString(const Layout *l, int count, int (Layout::*getter)(int) const)
{
if (count == 0)
return QString();
QString rc;
{
QTextStream str(&rc);
for (int i = 0; i < count; i++) {
if (i)
str << QLatin1Char(',');
str << (l->*getter)(i);
}
}
return rc;
}
// Clear the property, set all cells to 0
template <class Layout>
inline void clearPerCellValue(Layout *l, int count, void (Layout::*setter)(int,int), int value = 0)
{
for (int i = 0; i < count; i++)
(l->*setter)(i, value);
}
// Parse and set the property from a comma-separated list
template <class Layout>
inline bool parsePerCellProperty(Layout *l, int count, void (Layout::*setter)(int,int), const QString &s, int defaultValue = 0)
{
if (s.isEmpty()) {
clearPerCellValue(l, count, setter, defaultValue);
return true;
}
const QStringList list = s.split(QLatin1Char(','));
if (list.empty()) {
clearPerCellValue(l, count, setter, defaultValue);
return true;
}
// Apply all values contained in list
const int ac = qMin(count, list.size());
bool ok;
int i = 0;
for ( ; i < ac; i++) {
const int value = list.at(i).toInt(&ok);
if (!ok || value < 0)
return false;
(l->*setter)(i, value);
}
// Clear rest
for ( ; i < count; i++)
(l->*setter)(i, defaultValue);
return true;
}
// Read and write stretch
static QString msgInvalidStretch(const QString &objectName, const QString &stretch)
{
//: Parsing layout stretch values
return QCoreApplication::translate("FormBuilder", "Invalid stretch value for '%1': '%2'").arg(objectName, stretch);
}
QString QFormBuilderExtra::boxLayoutStretch(const QBoxLayout *box)
{
return perCellPropertyToString(box, box->count(), &QBoxLayout::stretch);
}
bool QFormBuilderExtra::setBoxLayoutStretch(const QString &s, QBoxLayout *box)
{
const bool rc = parsePerCellProperty(box, box->count(), &QBoxLayout::setStretch, s);
if (!rc)
uiLibWarning(msgInvalidStretch(box->objectName(), s));
return rc;
}
void QFormBuilderExtra::clearBoxLayoutStretch(QBoxLayout *box)
{
clearPerCellValue(box, box->count(), &QBoxLayout::setStretch);
}
QString QFormBuilderExtra::gridLayoutRowStretch(const QGridLayout *grid)
{
return perCellPropertyToString(grid, grid->rowCount(), &QGridLayout::rowStretch);
}
bool QFormBuilderExtra::setGridLayoutRowStretch(const QString &s, QGridLayout *grid)
{
const bool rc = parsePerCellProperty(grid, grid->rowCount(), &QGridLayout::setRowStretch, s);
if (!rc)
uiLibWarning(msgInvalidStretch(grid->objectName(), s));
return rc;
}
void QFormBuilderExtra::clearGridLayoutRowStretch(QGridLayout *grid)
{
clearPerCellValue(grid, grid->rowCount(), &QGridLayout::setRowStretch);
}
QString QFormBuilderExtra::gridLayoutColumnStretch(const QGridLayout *grid)
{
return perCellPropertyToString(grid, grid->columnCount(), &QGridLayout::columnStretch);
}
bool QFormBuilderExtra::setGridLayoutColumnStretch(const QString &s, QGridLayout *grid)
{
const bool rc = parsePerCellProperty(grid, grid->columnCount(), &QGridLayout::setColumnStretch, s);
if (!rc)
uiLibWarning(msgInvalidStretch(grid->objectName(), s));
return rc;
}
void QFormBuilderExtra::clearGridLayoutColumnStretch(QGridLayout *grid)
{
clearPerCellValue(grid, grid->columnCount(), &QGridLayout::setColumnStretch);
}
// Read and write grid layout row/column size limits
static QString msgInvalidMinimumSize(const QString &objectName, const QString &ms)
{
//: Parsing grid layout minimum size values
return QCoreApplication::translate("FormBuilder", "Invalid minimum size for '%1': '%2'").arg(objectName, ms);
}
QString QFormBuilderExtra::gridLayoutRowMinimumHeight(const QGridLayout *grid)
{
return perCellPropertyToString(grid, grid->rowCount(), &QGridLayout::rowMinimumHeight);
}
bool QFormBuilderExtra::setGridLayoutRowMinimumHeight(const QString &s, QGridLayout *grid)
{
const bool rc = parsePerCellProperty(grid, grid->rowCount(), &QGridLayout::setRowMinimumHeight, s);
if (!rc)
uiLibWarning(msgInvalidMinimumSize(grid->objectName(), s));
return rc;
}
void QFormBuilderExtra::clearGridLayoutRowMinimumHeight(QGridLayout *grid)
{
clearPerCellValue(grid, grid->rowCount(), &QGridLayout::setRowMinimumHeight);
}
QString QFormBuilderExtra::gridLayoutColumnMinimumWidth(const QGridLayout *grid)
{
return perCellPropertyToString(grid, grid->columnCount(), &QGridLayout::columnMinimumWidth);
}
bool QFormBuilderExtra::setGridLayoutColumnMinimumWidth(const QString &s, QGridLayout *grid)
{
const bool rc = parsePerCellProperty(grid, grid->columnCount(), &QGridLayout::setColumnMinimumWidth, s);
if (!rc)
uiLibWarning(msgInvalidMinimumSize(grid->objectName(), s));
return rc;
}
void QFormBuilderExtra::clearGridLayoutColumnMinimumWidth(QGridLayout *grid)
{
clearPerCellValue(grid, grid->columnCount(), &QGridLayout::setColumnMinimumWidth);
}
// ------------ QFormBuilderStrings
QFormBuilderStrings::QFormBuilderStrings() :
buddyProperty(QLatin1String("buddy")),
cursorProperty(QLatin1String("cursor")),
objectNameProperty(QLatin1String("objectName")),
trueValue(QLatin1String("true")),
falseValue(QLatin1String("false")),
horizontalPostFix(QLatin1String("Horizontal")),
separator(QLatin1String("separator")),
defaultTitle(QLatin1String("Page")),
titleAttribute(QLatin1String("title")),
labelAttribute(QLatin1String("label")),
toolTipAttribute(QLatin1String("toolTip")),
whatsThisAttribute(QLatin1String("whatsThis")),
flagsAttribute(QLatin1String("flags")),
iconAttribute(QLatin1String("icon")),
pixmapAttribute(QLatin1String("pixmap")),
textAttribute(QLatin1String("text")),
currentIndexProperty(QLatin1String("currentIndex")),
toolBarAreaAttribute(QLatin1String("toolBarArea")),
toolBarBreakAttribute(QLatin1String("toolBarBreak")),
dockWidgetAreaAttribute(QLatin1String("dockWidgetArea")),
marginProperty(QLatin1String("margin")),
spacingProperty(QLatin1String("spacing")),
leftMarginProperty(QLatin1String("leftMargin")),
topMarginProperty(QLatin1String("topMargin")),
rightMarginProperty(QLatin1String("rightMargin")),
bottomMarginProperty(QLatin1String("bottomMargin")),
horizontalSpacingProperty(QLatin1String("horizontalSpacing")),
verticalSpacingProperty(QLatin1String("verticalSpacing")),
sizeHintProperty(QLatin1String("sizeHint")),
sizeTypeProperty(QLatin1String("sizeType")),
orientationProperty(QLatin1String("orientation")),
styleSheetProperty(QLatin1String("styleSheet")),
qtHorizontal(QLatin1String("Qt::Horizontal")),
qtVertical(QLatin1String("Qt::Vertical")),
currentRowProperty(QLatin1String("currentRow")),
tabSpacingProperty(QLatin1String("tabSpacing")),
qWidgetClass(QLatin1String("QWidget")),
lineClass(QLatin1String("Line")),
geometryProperty(QLatin1String("geometry")),
scriptWidgetVariable(QLatin1String("widget")),
scriptChildWidgetsVariable(QLatin1String("childWidgets"))
{
itemRoles.append(qMakePair(Qt::FontRole, QString::fromLatin1("font")));
itemRoles.append(qMakePair(Qt::TextAlignmentRole, QString::fromLatin1("textAlignment")));
itemRoles.append(qMakePair(Qt::BackgroundRole, QString::fromLatin1("background")));
itemRoles.append(qMakePair(Qt::ForegroundRole, QString::fromLatin1("foreground")));
itemRoles.append(qMakePair(Qt::CheckStateRole, QString::fromLatin1("checkState")));
foreach (const RoleNName &it, itemRoles)
treeItemRoleHash.insert(it.second, it.first);
itemTextRoles.append(qMakePair(qMakePair(Qt::EditRole, Qt::DisplayPropertyRole),
textAttribute)); // This must be first for the loop below
itemTextRoles.append(qMakePair(qMakePair(Qt::ToolTipRole, Qt::ToolTipPropertyRole),
toolTipAttribute));
itemTextRoles.append(qMakePair(qMakePair(Qt::StatusTipRole, Qt::StatusTipPropertyRole),
QString::fromLatin1("statusTip")));
itemTextRoles.append(qMakePair(qMakePair(Qt::WhatsThisRole, Qt::WhatsThisPropertyRole),
whatsThisAttribute));
// Note: this skips the first item!
QList<TextRoleNName>::const_iterator it = itemTextRoles.constBegin(), end = itemTextRoles.constEnd();
while (++it != end)
treeItemTextRoleHash.insert(it->second, it->first);
}
const QFormBuilderStrings &QFormBuilderStrings::instance()
{
static const QFormBuilderStrings rc;
return rc;
}
#ifdef QFORMINTERNAL_NAMESPACE
} // namespace QFormInternal
#endif
QT_END_NAMESPACE

View File

@@ -0,0 +1,262 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef ABSTRACTFORMBUILDERPRIVATE_H
#define ABSTRACTFORMBUILDERPRIVATE_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "uilib_global.h"
#ifndef QT_FORMBUILDER_NO_SCRIPT
# include "formscriptrunner_p.h"
#endif
#include <QtCore/QHash>
#include <QtCore/QPointer>
#include <QtCore/QString>
QT_BEGIN_NAMESPACE
class QObject;
class QVariant;
class QWidget;
class QObject;
class QLabel;
class QButtonGroup;
class QBoxLayout;
class QGridLayout;
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal
{
#endif
class DomButtonGroups;
class DomButtonGroup;
class DomCustomWidget;
class QAbstractFormBuilder;
class QResourceBuilder;
class QTextBuilder;
class QDESIGNER_UILIB_EXPORT QFormBuilderExtra
{
QFormBuilderExtra();
~QFormBuilderExtra();
public:
struct CustomWidgetData {
CustomWidgetData();
explicit CustomWidgetData(const DomCustomWidget *dc);
QString addPageMethod;
QString script;
QString baseClass;
bool isContainer;
};
void clear();
bool applyPropertyInternally(QObject *o, const QString &propertyName, const QVariant &value);
enum BuddyMode { BuddyApplyAll, BuddyApplyVisibleOnly };
void applyInternalProperties() const;
static bool applyBuddy(const QString &buddyName, BuddyMode applyMode, QLabel *label);
const QPointer<QWidget> &parentWidget() const;
bool parentWidgetIsSet() const;
void setParentWidget(const QPointer<QWidget> &w);
#ifndef QT_FORMBUILDER_NO_SCRIPT
QFormScriptRunner &formScriptRunner();
QString customWidgetScript(const QString &className) const;
#endif
void setProcessingLayoutWidget(bool processing);
bool processingLayoutWidget() const;
void setResourceBuilder(QResourceBuilder *builder);
QResourceBuilder *resourceBuilder() const;
void setTextBuilder(QTextBuilder *builder);
QTextBuilder *textBuilder() const;
static QFormBuilderExtra *instance(const QAbstractFormBuilder *afb);
static void removeInstance(const QAbstractFormBuilder *afb);
void storeCustomWidgetData(const QString &className, const DomCustomWidget *d);
QString customWidgetAddPageMethod(const QString &className) const;
QString customWidgetBaseClass(const QString &className) const;
bool isCustomWidgetContainer(const QString &className) const;
// --- Hash used in creating button groups on demand. Store a map of name and pair of dom group and real group
void registerButtonGroups(const DomButtonGroups *groups);
typedef QPair<DomButtonGroup *, QButtonGroup*> ButtonGroupEntry;
typedef QHash<QString, ButtonGroupEntry> ButtonGroupHash;
const ButtonGroupHash &buttonGroups() const { return m_buttonGroups; }
ButtonGroupHash &buttonGroups() { return m_buttonGroups; }
// return stretch as a comma-separated list
static QString boxLayoutStretch(const QBoxLayout*);
// apply stretch
static bool setBoxLayoutStretch(const QString &, QBoxLayout*);
static void clearBoxLayoutStretch(QBoxLayout*);
static QString gridLayoutRowStretch(const QGridLayout *);
static bool setGridLayoutRowStretch(const QString &, QGridLayout *);
static void clearGridLayoutRowStretch(QGridLayout *);
static QString gridLayoutColumnStretch(const QGridLayout *);
static bool setGridLayoutColumnStretch(const QString &, QGridLayout *);
static void clearGridLayoutColumnStretch(QGridLayout *);
// return the row/column sizes as comma-separated lists
static QString gridLayoutRowMinimumHeight(const QGridLayout *);
static bool setGridLayoutRowMinimumHeight(const QString &, QGridLayout *);
static void clearGridLayoutRowMinimumHeight(QGridLayout *);
static QString gridLayoutColumnMinimumWidth(const QGridLayout *);
static bool setGridLayoutColumnMinimumWidth(const QString &, QGridLayout *);
static void clearGridLayoutColumnMinimumWidth(QGridLayout *);
private:
void clearResourceBuilder();
void clearTextBuilder();
typedef QHash<QLabel*, QString> BuddyHash;
BuddyHash m_buddies;
#ifndef QT_FORMBUILDER_NO_SCRIPT
QFormScriptRunner m_FormScriptRunner;
#endif
QHash<QString, CustomWidgetData> m_customWidgetDataHash;
ButtonGroupHash m_buttonGroups;
bool m_layoutWidget;
QResourceBuilder *m_resourceBuilder;
QTextBuilder *m_textBuilder;
QPointer<QWidget> m_parentWidget;
bool m_parentWidgetIsSet;
};
void uiLibWarning(const QString &message);
// Struct with static accessor that provides most strings used in the form builder.
struct QDESIGNER_UILIB_EXPORT QFormBuilderStrings {
QFormBuilderStrings();
static const QFormBuilderStrings &instance();
const QString buddyProperty;
const QString cursorProperty;
const QString objectNameProperty;
const QString trueValue;
const QString falseValue;
const QString horizontalPostFix;
const QString separator;
const QString defaultTitle;
const QString titleAttribute;
const QString labelAttribute;
const QString toolTipAttribute;
const QString whatsThisAttribute;
const QString flagsAttribute;
const QString iconAttribute;
const QString pixmapAttribute;
const QString textAttribute;
const QString currentIndexProperty;
const QString toolBarAreaAttribute;
const QString toolBarBreakAttribute;
const QString dockWidgetAreaAttribute;
const QString marginProperty;
const QString spacingProperty;
const QString leftMarginProperty;
const QString topMarginProperty;
const QString rightMarginProperty;
const QString bottomMarginProperty;
const QString horizontalSpacingProperty;
const QString verticalSpacingProperty;
const QString sizeHintProperty;
const QString sizeTypeProperty;
const QString orientationProperty;
const QString styleSheetProperty;
const QString qtHorizontal;
const QString qtVertical;
const QString currentRowProperty;
const QString tabSpacingProperty;
const QString qWidgetClass;
const QString lineClass;
const QString geometryProperty;
const QString scriptWidgetVariable;
const QString scriptChildWidgetsVariable;
typedef QPair<Qt::ItemDataRole, QString> RoleNName;
QList<RoleNName> itemRoles;
QHash<QString, Qt::ItemDataRole> treeItemRoleHash;
// first.first is primary role, first.second is shadow role.
// Shadow is used for either the translation source or the designer
// representation of the string value.
typedef QPair<QPair<Qt::ItemDataRole, Qt::ItemDataRole>, QString> TextRoleNName;
QList<TextRoleNName> itemTextRoles;
QHash<QString, QPair<Qt::ItemDataRole, Qt::ItemDataRole> > treeItemTextRoleHash;
};
#ifdef QFORMINTERNAL_NAMESPACE
}
#endif
QT_END_NAMESPACE
#endif // ABSTRACTFORMBUILDERPRIVATE_H

View File

@@ -0,0 +1,208 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "formscriptrunner_p.h"
#include "formbuilderextra_p.h"
#include "ui4_p.h"
#include <QtScript/QScriptEngine>
#include <QtGui/QWidget>
#include <QtCore/QDebug>
#include <QtCore/QCoreApplication>
QT_BEGIN_NAMESPACE
namespace {
enum { debugFormScriptRunner = 0 };
}
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal {
#endif
class QFormScriptRunner::QFormScriptRunnerPrivate {
public:
QFormScriptRunnerPrivate() : m_options(DisableScripts) {}
void clearErrors() { m_errors.clear(); }
bool run(const QString &script, QWidget *widget, const WidgetList &children, QString *errorMessage);
static void initializeEngine(QWidget *w, const WidgetList &children, QScriptEngine &scriptEngine);
static QString engineError(QScriptEngine &scriptEngine);
Options options() const { return m_options; }
void setOptions(Options options) { m_options = options; }
Errors errors() const { return m_errors; }
private:
QScriptEngine m_scriptEngine;
Options m_options;
Errors m_errors;
};
bool QFormScriptRunner::QFormScriptRunnerPrivate::run(const QString &script, QWidget *widget, const WidgetList &children, QString *errorMessage) {
bool rc = false;
initializeEngine(widget, children, m_scriptEngine);
do {
m_scriptEngine.evaluate(script);
if (m_scriptEngine.hasUncaughtException ()) {
*errorMessage = QCoreApplication::tr("Exception at line %1: %2").arg(m_scriptEngine.uncaughtExceptionLineNumber()).arg(engineError(m_scriptEngine));
break;
}
rc = true;
} while (false);
m_scriptEngine.popContext();
if (!rc) {
Error error;
error.objectName = widget->objectName();
error.script = script;
error.errorMessage = *errorMessage;
m_errors.push_back(error);
}
return rc;
}
void QFormScriptRunner::QFormScriptRunnerPrivate::initializeEngine(QWidget *w, const WidgetList &children, QScriptEngine &scriptEngine) {
// Populate the script variables. This pushes a context which must be popped.
QScriptContext *ctx = scriptEngine.pushContext();
QScriptValue widgetObject = scriptEngine.newQObject(w);
QScriptValue childrenArray = scriptEngine.newArray (children.size());
for(int i = 0; i < children.size(); i++) {
childrenArray.setProperty(i, scriptEngine.newQObject(children[i]));
}
const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
ctx ->activationObject().setProperty(strings.scriptWidgetVariable, widgetObject);
ctx ->activationObject().setProperty(strings.scriptChildWidgetsVariable, childrenArray);
}
QString QFormScriptRunner::QFormScriptRunnerPrivate::engineError(QScriptEngine &scriptEngine) {
QScriptValue error = scriptEngine.evaluate(QLatin1String("Error"));
if (error.isValid())
return error.toString();
return QCoreApplication::tr("Unknown error");
}
// -- QFormScriptRunner
QFormScriptRunner::QFormScriptRunner() : m_impl(new QFormScriptRunnerPrivate)
{
}
QFormScriptRunner::~QFormScriptRunner()
{
delete m_impl;
}
bool QFormScriptRunner::run(const DomWidget *domWidget,
const QString &customWidgetScript,
QWidget *widget, const WidgetList &children,
QString *errorMessage)
{
typedef QList<DomScript*> DomScripts;
const Options scriptOptions = m_impl->options();
if (scriptOptions & DisableScripts)
return true;
// get list
const DomScripts domScripts = domWidget->elementScript();
// Concatenate snippets, starting with custom widget script
QString script = customWidgetScript;
if (script.isEmpty() && domScripts.empty())
return true;
foreach (const DomScript *scriptSnippet, domScripts) {
// Ensure new line
if (!script.isEmpty() && !script.endsWith(QLatin1Char('\n')))
script += QLatin1Char('\n');
script += scriptSnippet->text();
}
if (script.isEmpty())
return true;
const bool rc = m_impl->run(script, widget, children, errorMessage);
if (debugFormScriptRunner) {
qDebug() << "For " << widget << " with " << children.size() << " children, ran: " << script;
if (!rc)
qDebug() << *errorMessage;
}
if (!rc) {
if (!(scriptOptions & DisableWarnings)) {
const QString message = QCoreApplication::tr("An error occurred while running the script for %1: %2\nScript: %3").
arg(widget->objectName()).arg(*errorMessage).arg(script);
qWarning() << message;
}
}
return rc;
}
QFormScriptRunner::Options QFormScriptRunner::options() const
{
return m_impl->options();
}
void QFormScriptRunner::setOptions(Options options)
{
m_impl->setOptions(options);
}
QFormScriptRunner::Errors QFormScriptRunner::errors() const
{
return m_impl->errors();
}
void QFormScriptRunner::clearErrors()
{
m_impl->clearErrors();
}
#ifdef QFORMINTERNAL_NAMESPACE
} // namespace QFormInternal
#endif
QT_END_NAMESPACE

View File

@@ -0,0 +1,120 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef FORMSCRIPTRUNNER_H
#define FORMSCRIPTRUNNER_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtDesigner/uilib_global.h>
#include <QtCore/QList>
#include <QtCore/QFlags>
#include <QtCore/QString>
QT_BEGIN_NAMESPACE
class QWidget;
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal
{
#endif
class DomWidget;
class QDESIGNER_UILIB_EXPORT QFormScriptRunner
{
public:
QFormScriptRunner();
~QFormScriptRunner();
typedef QList<QWidget*> WidgetList;
bool run(const DomWidget *domWidget,
const QString &customWidgetScript,
QWidget *widget, const WidgetList &children,
QString *errorMessage);
struct Error {
QString objectName;
QString script;
QString errorMessage;
};
typedef QList<Error> Errors;
Errors errors() const;
void clearErrors();
enum Option {
NoOptions = 0x0,
DisableWarnings = 0x1,
DisableScripts = 02
};
Q_DECLARE_FLAGS(Options, Option)
Options options() const;
void setOptions(Options options);
private:
class QFormScriptRunnerPrivate;
QFormScriptRunnerPrivate *m_impl;
QFormScriptRunner(const QFormScriptRunner &);
void operator = (const QFormScriptRunner &);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QFormScriptRunner::Options)
#ifdef QFORMINTERNAL_NAMESPACE
}
#endif
QT_END_NAMESPACE
#endif // FORMSCRIPTRUNNER_H

View File

@@ -0,0 +1,681 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "properties_p.h"
#include "ui4_p.h"
#include "abstractformbuilder.h"
#include "formbuilderextra_p.h"
#include "resourcebuilder_p.h"
#include <QtCore/QDateTime>
#include <QtCore/QUrl>
#include <QtCore/qdebug.h>
#include <QtGui/QIcon>
#include <QtGui/QPixmap>
#include <QtGui/QFont>
#include <QtGui/QFrame>
#include <QtGui/QAbstractScrollArea>
QT_BEGIN_NAMESPACE
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal
{
#endif
static inline void fixEnum(QString &s)
{
int qualifierIndex = s.lastIndexOf(QLatin1Char(':'));
if (qualifierIndex == -1)
qualifierIndex = s.lastIndexOf(QLatin1Char('.'));
if (qualifierIndex != -1)
s.remove(0, qualifierIndex + 1);
}
// Convert complex DOM types with the help of QAbstractFormBuilder
QVariant domPropertyToVariant(QAbstractFormBuilder *afb,const QMetaObject *meta,const DomProperty *p)
{
// Complex types that need functions from QAbstractFormBuilder
switch(p->kind()) {
case DomProperty::String: {
const int index = meta->indexOfProperty(p->attributeName().toUtf8());
if (index != -1 && meta->property(index).type() == QVariant::KeySequence)
return qVariantFromValue(QKeySequence(p->elementString()->text()));
}
break;
case DomProperty::Palette: {
const DomPalette *dom = p->elementPalette();
QPalette palette;
if (dom->elementActive())
afb->setupColorGroup(palette, QPalette::Active, dom->elementActive());
if (dom->elementInactive())
afb->setupColorGroup(palette, QPalette::Inactive, dom->elementInactive());
if (dom->elementDisabled())
afb->setupColorGroup(palette, QPalette::Disabled, dom->elementDisabled());
palette.setCurrentColorGroup(QPalette::Active);
return qVariantFromValue(palette);
}
case DomProperty::Set: {
const QByteArray pname = p->attributeName().toUtf8();
const int index = meta->indexOfProperty(pname);
if (index == -1) {
uiLibWarning(QCoreApplication::translate("QFormBuilder", "The set-type property %1 could not be read.").arg(p->attributeName()));
return QVariant();
}
const QMetaEnum e = meta->property(index).enumerator();
Q_ASSERT(e.isFlag() == true);
return QVariant(e.keysToValue(p->elementSet().toUtf8()));
}
case DomProperty::Enum: {
const QByteArray pname = p->attributeName().toUtf8();
const int index = meta->indexOfProperty(pname);
QString enumValue = p->elementEnum();
// Triggers in case of objects in Designer like Spacer/Line for which properties
// are serialized using language introspection. On preview, however, these objects are
// emulated by hacks in the formbuilder (size policy/orientation)
fixEnum(enumValue);
if (index == -1) {
// ### special-casing for Line (QFrame) -- fix for 4.2. Jambi hack for enumerations
if (!qstrcmp(meta->className(), "QFrame")
&& (pname == QByteArray("orientation"))) {
return QVariant(enumValue == QFormBuilderStrings::instance().horizontalPostFix ? QFrame::HLine : QFrame::VLine);
} else {
uiLibWarning(QCoreApplication::translate("QFormBuilder", "The enumeration-type property %1 could not be read.").arg(p->attributeName()));
return QVariant();
}
}
const QMetaEnum e = meta->property(index).enumerator();
return QVariant(e.keyToValue(enumValue.toUtf8()));
}
case DomProperty::Brush:
return qVariantFromValue(afb->setupBrush(p->elementBrush()));
default:
if (afb->resourceBuilder()->isResourceProperty(p)) {
return afb->resourceBuilder()->loadResource(afb->workingDirectory(), p);
}
break;
}
// simple type
return domPropertyToVariant(p);
}
// Convert simple DOM types
QVariant domPropertyToVariant(const DomProperty *p)
{
// requires non-const virtual nameToIcon, etc.
switch(p->kind()) {
case DomProperty::Bool:
return QVariant(p->elementBool() == QFormBuilderStrings::instance().trueValue);
case DomProperty::Cstring:
return QVariant(p->elementCstring().toUtf8());
case DomProperty::Point: {
const DomPoint *point = p->elementPoint();
return QVariant(QPoint(point->elementX(), point->elementY()));
}
case DomProperty::PointF: {
const DomPointF *pointf = p->elementPointF();
return QVariant(QPointF(pointf->elementX(), pointf->elementY()));
}
case DomProperty::Size: {
const DomSize *size = p->elementSize();
return QVariant(QSize(size->elementWidth(), size->elementHeight()));
}
case DomProperty::SizeF: {
const DomSizeF *sizef = p->elementSizeF();
return QVariant(QSizeF(sizef->elementWidth(), sizef->elementHeight()));
}
case DomProperty::Rect: {
const DomRect *rc = p->elementRect();
const QRect g(rc->elementX(), rc->elementY(), rc->elementWidth(), rc->elementHeight());
return QVariant(g);
}
case DomProperty::RectF: {
const DomRectF *rcf = p->elementRectF();
const QRectF g(rcf->elementX(), rcf->elementY(), rcf->elementWidth(), rcf->elementHeight());
return QVariant(g);
}
case DomProperty::String:
return QVariant(p->elementString()->text());
case DomProperty::Number:
return QVariant(p->elementNumber());
case DomProperty::UInt:
return QVariant(p->elementUInt());
case DomProperty::LongLong:
return QVariant(p->elementLongLong());
case DomProperty::ULongLong:
return QVariant(p->elementULongLong());
case DomProperty::Double:
return QVariant(p->elementDouble());
case DomProperty::Char: {
const DomChar *character = p->elementChar();
const QChar c(character->elementUnicode());
return qVariantFromValue(c);
}
case DomProperty::Color: {
const DomColor *color = p->elementColor();
QColor c(color->elementRed(), color->elementGreen(), color->elementBlue());
if (color->hasAttributeAlpha())
c.setAlpha(color->attributeAlpha());
return qVariantFromValue(c);
}
case DomProperty::Font: {
const DomFont *font = p->elementFont();
QFont f;
if (font->hasElementFamily() && !font->elementFamily().isEmpty())
f.setFamily(font->elementFamily());
if (font->hasElementPointSize() && font->elementPointSize() > 0)
f.setPointSize(font->elementPointSize());
if (font->hasElementWeight() && font->elementWeight() > 0)
f.setWeight(font->elementWeight());
if (font->hasElementItalic())
f.setItalic(font->elementItalic());
if (font->hasElementBold())
f.setBold(font->elementBold());
if (font->hasElementUnderline())
f.setUnderline(font->elementUnderline());
if (font->hasElementStrikeOut())
f.setStrikeOut(font->elementStrikeOut());
if (font->hasElementKerning())
f.setKerning(font->elementKerning());
if (font->hasElementAntialiasing())
f.setStyleStrategy(font->elementAntialiasing() ? QFont::PreferDefault : QFont::NoAntialias);
if (font->hasElementStyleStrategy()) {
f.setStyleStrategy(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QFont::StyleStrategy>("styleStrategy", font->elementStyleStrategy().toLatin1()));
}
return qVariantFromValue(f);
}
case DomProperty::Date: {
const DomDate *date = p->elementDate();
return QVariant(QDate(date->elementYear(), date->elementMonth(), date->elementDay()));
}
case DomProperty::Time: {
const DomTime *t = p->elementTime();
return QVariant(QTime(t->elementHour(), t->elementMinute(), t->elementSecond()));
}
case DomProperty::DateTime: {
const DomDateTime *dateTime = p->elementDateTime();
const QDate d(dateTime->elementYear(), dateTime->elementMonth(), dateTime->elementDay());
const QTime tm(dateTime->elementHour(), dateTime->elementMinute(), dateTime->elementSecond());
return QVariant(QDateTime(d, tm));
}
case DomProperty::Url: {
const DomUrl *url = p->elementUrl();
return QVariant(QUrl(url->elementString()->text()));
}
#ifndef QT_NO_CURSOR
case DomProperty::Cursor:
return qVariantFromValue(QCursor(static_cast<Qt::CursorShape>(p->elementCursor())));
case DomProperty::CursorShape:
return qVariantFromValue(QCursor(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, Qt::CursorShape>("cursorShape", p->elementCursorShape().toLatin1())));
#endif
case DomProperty::Locale: {
const DomLocale *locale = p->elementLocale();
return qVariantFromValue(QLocale(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Language>("language", locale->attributeLanguage().toLatin1()),
enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Country>("country", locale->attributeCountry().toLatin1())));
}
case DomProperty::SizePolicy: {
const DomSizePolicy *sizep = p->elementSizePolicy();
QSizePolicy sizePolicy;
sizePolicy.setHorizontalStretch(sizep->elementHorStretch());
sizePolicy.setVerticalStretch(sizep->elementVerStretch());
const QMetaEnum sizeType_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType");
if (sizep->hasElementHSizeType()) {
sizePolicy.setHorizontalPolicy((QSizePolicy::Policy) sizep->elementHSizeType());
} else if (sizep->hasAttributeHSizeType()) {
const QSizePolicy::Policy sp = enumKeyToValue<QSizePolicy::Policy>(sizeType_enum, sizep->attributeHSizeType().toLatin1());
sizePolicy.setHorizontalPolicy(sp);
}
if (sizep->hasElementVSizeType()) {
sizePolicy.setVerticalPolicy((QSizePolicy::Policy) sizep->elementVSizeType());
} else if (sizep->hasAttributeVSizeType()) {
const QSizePolicy::Policy sp = enumKeyToValue<QSizePolicy::Policy>(sizeType_enum, sizep->attributeVSizeType().toLatin1());
sizePolicy.setVerticalPolicy(sp);
}
return qVariantFromValue(sizePolicy);
}
case DomProperty::StringList:
return QVariant(p->elementStringList()->elementString());
default:
uiLibWarning(QCoreApplication::translate("QFormBuilder", "Reading properties of the type %1 is not supported yet.").arg(p->kind()));
break;
}
return QVariant();
}
// Apply a simple variant type to a DOM property
static bool applySimpleProperty(const QVariant &v, bool translateString, DomProperty *dom_prop)
{
switch (v.type()) {
case QVariant::String: {
DomString *str = new DomString();
str->setText(v.toString());
if (!translateString)
str->setAttributeNotr(QLatin1String("true"));
dom_prop->setElementString(str);
}
return true;
case QVariant::ByteArray:
dom_prop->setElementCstring(QString::fromUtf8(v.toByteArray()));
return true;
case QVariant::Int:
dom_prop->setElementNumber(v.toInt());
return true;
case QVariant::UInt:
dom_prop->setElementUInt(v.toUInt());
return true;
case QVariant::LongLong:
dom_prop->setElementLongLong(v.toLongLong());
return true;
case QVariant::ULongLong:
dom_prop->setElementULongLong(v.toULongLong());
return true;
case QVariant::Double:
dom_prop->setElementDouble(v.toDouble());
return true;
case QVariant::Bool:
dom_prop->setElementBool(v.toBool() ? QFormBuilderStrings::instance().trueValue : QFormBuilderStrings::instance().falseValue);
return true;
case QVariant::Char: {
DomChar *ch = new DomChar();
const QChar character = v.toChar();
ch->setElementUnicode(character.unicode());
dom_prop->setElementChar(ch);
}
return true;
case QVariant::Point: {
DomPoint *pt = new DomPoint();
const QPoint point = v.toPoint();
pt->setElementX(point.x());
pt->setElementY(point.y());
dom_prop->setElementPoint(pt);
}
return true;
case QVariant::PointF: {
DomPointF *ptf = new DomPointF();
const QPointF pointf = v.toPointF();
ptf->setElementX(pointf.x());
ptf->setElementY(pointf.y());
dom_prop->setElementPointF(ptf);
}
return true;
case QVariant::Color: {
DomColor *clr = new DomColor();
const QColor color = qvariant_cast<QColor>(v);
clr->setElementRed(color.red());
clr->setElementGreen(color.green());
clr->setElementBlue(color.blue());
const int alphaChannel = color.alpha();
if (alphaChannel != 255)
clr->setAttributeAlpha(alphaChannel);
dom_prop->setElementColor(clr);
}
return true;
case QVariant::Size: {
DomSize *sz = new DomSize();
const QSize size = v.toSize();
sz->setElementWidth(size.width());
sz->setElementHeight(size.height());
dom_prop->setElementSize(sz);
}
return true;
case QVariant::SizeF: {
DomSizeF *szf = new DomSizeF();
const QSizeF sizef = v.toSizeF();
szf->setElementWidth(sizef.width());
szf->setElementHeight(sizef.height());
dom_prop->setElementSizeF(szf);
}
return true;
case QVariant::Rect: {
DomRect *rc = new DomRect();
const QRect rect = v.toRect();
rc->setElementX(rect.x());
rc->setElementY(rect.y());
rc->setElementWidth(rect.width());
rc->setElementHeight(rect.height());
dom_prop->setElementRect(rc);
}
return true;
case QVariant::RectF: {
DomRectF *rcf = new DomRectF();
const QRectF rectf = v.toRectF();
rcf->setElementX(rectf.x());
rcf->setElementY(rectf.y());
rcf->setElementWidth(rectf.width());
rcf->setElementHeight(rectf.height());
dom_prop->setElementRectF(rcf);
}
return true;
case QVariant::Font: {
DomFont *fnt = new DomFont();
const QFont font = qvariant_cast<QFont>(v);
const uint mask = font.resolve();
if (mask & QFont::WeightResolved) {
fnt->setElementBold(font.bold());
fnt->setElementWeight(font.weight());
}
if (mask & QFont::FamilyResolved)
fnt->setElementFamily(font.family());
if (mask & QFont::StyleResolved)
fnt->setElementItalic(font.italic());
if (mask & QFont::SizeResolved)
fnt->setElementPointSize(font.pointSize());
if (mask & QFont::StrikeOutResolved)
fnt->setElementStrikeOut(font.strikeOut());
if (mask & QFont::UnderlineResolved)
fnt->setElementUnderline(font.underline());
if (mask & QFont::KerningResolved)
fnt->setElementKerning(font.kerning());
if (mask & QFont::StyleStrategyResolved) {
const QMetaEnum styleStrategy_enum = metaEnum<QAbstractFormBuilderGadget>("styleStrategy");
fnt->setElementStyleStrategy(QLatin1String(styleStrategy_enum.valueToKey(font.styleStrategy())));
}
dom_prop->setElementFont(fnt);
}
return true;
#ifndef QT_NO_CURSOR
case QVariant::Cursor: {
const QMetaEnum cursorShape_enum = metaEnum<QAbstractFormBuilderGadget>("cursorShape");
dom_prop->setElementCursorShape(QLatin1String(cursorShape_enum.valueToKey(qvariant_cast<QCursor>(v).shape())));
}
return true;
#endif
case QVariant::KeySequence: {
DomString *s = new DomString();
s->setText(qvariant_cast<QKeySequence>(v).toString(QKeySequence::PortableText));
dom_prop->setElementString(s);
}
return true;
case QVariant::Locale: {
DomLocale *dom = new DomLocale();
const QLocale locale = qvariant_cast<QLocale>(v);
const QMetaEnum language_enum = metaEnum<QAbstractFormBuilderGadget>("language");
const QMetaEnum country_enum = metaEnum<QAbstractFormBuilderGadget>("country");
dom->setAttributeLanguage(QLatin1String(language_enum.valueToKey(locale.language())));
dom->setAttributeCountry(QLatin1String(country_enum.valueToKey(locale.country())));
dom_prop->setElementLocale(dom);
}
return true;
case QVariant::SizePolicy: {
DomSizePolicy *dom = new DomSizePolicy();
const QSizePolicy sizePolicy = qvariant_cast<QSizePolicy>(v);
dom->setElementHorStretch(sizePolicy.horizontalStretch());
dom->setElementVerStretch(sizePolicy.verticalStretch());
const QMetaEnum sizeType_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType");
dom->setAttributeHSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.horizontalPolicy())));
dom->setAttributeVSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.verticalPolicy())));
dom_prop->setElementSizePolicy(dom);
}
return true;
case QVariant::Date: {
DomDate *dom = new DomDate();
const QDate date = qvariant_cast<QDate>(v);
dom->setElementYear(date.year());
dom->setElementMonth(date.month());
dom->setElementDay(date.day());
dom_prop->setElementDate(dom);
}
return true;
case QVariant::Time: {
DomTime *dom = new DomTime();
const QTime time = qvariant_cast<QTime>(v);
dom->setElementHour(time.hour());
dom->setElementMinute(time.minute());
dom->setElementSecond(time.second());
dom_prop->setElementTime(dom);
}
return true;
case QVariant::DateTime: {
DomDateTime *dom = new DomDateTime();
const QDateTime dateTime = qvariant_cast<QDateTime>(v);
dom->setElementHour(dateTime.time().hour());
dom->setElementMinute(dateTime.time().minute());
dom->setElementSecond(dateTime.time().second());
dom->setElementYear(dateTime.date().year());
dom->setElementMonth(dateTime.date().month());
dom->setElementDay(dateTime.date().day());
dom_prop->setElementDateTime(dom);
}
return true;
case QVariant::Url: {
DomUrl *dom = new DomUrl();
const QUrl url = v.toUrl();
DomString *str = new DomString();
str->setText(url.toString());
dom->setElementString(str);
dom_prop->setElementUrl(dom);
}
return true;
case QVariant::StringList: {
DomStringList *sl = new DomStringList;
sl->setElementString(qvariant_cast<QStringList>(v));
dom_prop->setElementStringList(sl);
}
return true;
default:
break;
}
return false;
}
static QString msgCannotWriteProperty(const QString &pname, const QVariant &v)
{
return QCoreApplication::translate("QFormBuilder", "The property %1 could not be written. The type %2 is not supported yet.").
arg(pname).arg(QLatin1String(v.typeName()));
}
static bool isOfType(const QMetaObject *what, const QMetaObject *type)
{
do {
if (what == type)
return true;
} while ((what = what->superClass()));
return false;
}
static bool isTranslatable(const QString &pname, const QVariant &v, const QMetaObject *meta)
{
const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
if (pname == strings.objectNameProperty)
return false;
if (pname == strings.styleSheetProperty && v.type() == QVariant::String && isOfType(meta, &QWidget::staticMetaObject))
return false;
return true;
}
// Convert complex variant types to DOM properties with the help of QAbstractFormBuilder
// Does not perform a check using QAbstractFormBuilder::checkProperty().
DomProperty *variantToDomProperty(QAbstractFormBuilder *afb, const QMetaObject *meta,
const QString &pname, const QVariant &v)
{
const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
DomProperty *dom_prop = new DomProperty();
dom_prop->setAttributeName(pname);
const int pindex = meta->indexOfProperty(pname.toLatin1());
if (pindex != -1) {
QMetaProperty meta_property = meta->property(pindex);
if ((v.type() == QVariant::Int || v.type() == QVariant::UInt) && meta_property.isEnumType()) {
const QMetaEnum e = meta_property.enumerator();
if (e.isFlag())
dom_prop->setElementSet(QString::fromAscii(e.valueToKeys(v.toInt())));
else
dom_prop->setElementEnum(QString::fromAscii(e.valueToKey(v.toInt())));
return dom_prop;
}
if (!meta_property.hasStdCppSet() || (isOfType(meta, &QAbstractScrollArea::staticMetaObject) && pname == strings.cursorProperty))
dom_prop->setAttributeStdset(0);
}
// Try simple properties
if (applySimpleProperty(v, isTranslatable(pname, v, meta), dom_prop))
return dom_prop;
// Complex properties
switch (v.type()) {
case QVariant::Palette: {
DomPalette *dom = new DomPalette();
QPalette palette = qvariant_cast<QPalette>(v);
palette.setCurrentColorGroup(QPalette::Active);
dom->setElementActive(afb->saveColorGroup(palette));
palette.setCurrentColorGroup(QPalette::Inactive);
dom->setElementInactive(afb->saveColorGroup(palette));
palette.setCurrentColorGroup(QPalette::Disabled);
dom->setElementDisabled(afb->saveColorGroup(palette));
dom_prop->setElementPalette(dom);
} break;
case QVariant::Brush:
dom_prop->setElementBrush(afb->saveBrush(qvariant_cast<QBrush>(v)));
break;
default: {
const bool hadAttributeStdset = dom_prop->hasAttributeStdset();
const bool attributeStdset = dom_prop->attributeStdset();
delete dom_prop;
if (afb->resourceBuilder()->isResourceType(v)) {
dom_prop = afb->resourceBuilder()->saveResource(afb->workingDirectory(), v);
if (dom_prop) {
dom_prop->setAttributeName(pname);
if (hadAttributeStdset)
dom_prop->setAttributeStdset(attributeStdset);
}
break;
}
uiLibWarning(msgCannotWriteProperty(pname, v));
} return 0;
}
return dom_prop;
}
#ifdef QFORMINTERNAL_NAMESPACE
}
#endif
QT_END_NAMESPACE

View File

@@ -0,0 +1,176 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of Qt Designer. This header
// file may change from version to version without notice, or even be removed.
//
// We mean it.
//
#ifndef UILIBPROPERTIES_H
#define UILIBPROPERTIES_H
#include <QtDesigner/uilib_global.h>
#include <QtCore/QObject>
#include <QtCore/QMetaProperty>
#include <QtCore/QLocale>
#include <QtCore/QCoreApplication>
#include <QtGui/QWidget>
#include "formbuilderextra_p.h"
QT_BEGIN_NAMESPACE
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal
{
#endif
class QAbstractFormBuilder;
class DomProperty;
QDESIGNER_UILIB_EXPORT DomProperty *variantToDomProperty(QAbstractFormBuilder *abstractFormBuilder, const QMetaObject *meta, const QString &propertyName, const QVariant &value);
QDESIGNER_UILIB_EXPORT QVariant domPropertyToVariant(const DomProperty *property);
QDESIGNER_UILIB_EXPORT QVariant domPropertyToVariant(QAbstractFormBuilder *abstractFormBuilder, const QMetaObject *meta, const DomProperty *property);
// This class exists to provide meta information
// for enumerations only.
class QAbstractFormBuilderGadget: public QWidget
{
Q_OBJECT
Q_PROPERTY(Qt::ItemFlags itemFlags READ fakeItemFlags)
Q_PROPERTY(Qt::CheckState checkState READ fakeCheckState)
Q_PROPERTY(Qt::Alignment textAlignment READ fakeAlignment)
Q_PROPERTY(Qt::Orientation orientation READ fakeOrientation)
Q_PROPERTY(QSizePolicy::Policy sizeType READ fakeSizeType)
Q_PROPERTY(QPalette::ColorRole colorRole READ fakeColorRole)
Q_PROPERTY(QPalette::ColorGroup colorGroup READ fakeColorGroup)
Q_PROPERTY(QFont::StyleStrategy styleStrategy READ fakeStyleStrategy)
Q_PROPERTY(Qt::CursorShape cursorShape READ fakeCursorShape)
Q_PROPERTY(Qt::BrushStyle brushStyle READ fakeBrushStyle)
Q_PROPERTY(Qt::ToolBarArea toolBarArea READ fakeToolBarArea)
Q_PROPERTY(QGradient::Type gradientType READ fakeGradientType)
Q_PROPERTY(QGradient::Spread gradientSpread READ fakeGradientSpread)
Q_PROPERTY(QGradient::CoordinateMode gradientCoordinate READ fakeGradientCoordinate)
Q_PROPERTY(QLocale::Language language READ fakeLanguage)
Q_PROPERTY(QLocale::Country country READ fakeCountry)
public:
QAbstractFormBuilderGadget() { Q_ASSERT(0); }
Qt::Orientation fakeOrientation() const { Q_ASSERT(0); return Qt::Horizontal; }
QSizePolicy::Policy fakeSizeType() const { Q_ASSERT(0); return QSizePolicy::Expanding; }
QPalette::ColorGroup fakeColorGroup() const { Q_ASSERT(0); return static_cast<QPalette::ColorGroup>(0); }
QPalette::ColorRole fakeColorRole() const { Q_ASSERT(0); return static_cast<QPalette::ColorRole>(0); }
QFont::StyleStrategy fakeStyleStrategy() const { Q_ASSERT(0); return QFont::PreferDefault; }
Qt::CursorShape fakeCursorShape() const { Q_ASSERT(0); return Qt::ArrowCursor; }
Qt::BrushStyle fakeBrushStyle() const { Q_ASSERT(0); return Qt::NoBrush; }
Qt::ToolBarArea fakeToolBarArea() const { Q_ASSERT(0); return Qt::NoToolBarArea; }
QGradient::Type fakeGradientType() const { Q_ASSERT(0); return QGradient::NoGradient; }
QGradient::Spread fakeGradientSpread() const { Q_ASSERT(0); return QGradient::PadSpread; }
QGradient::CoordinateMode fakeGradientCoordinate() const { Q_ASSERT(0); return QGradient::LogicalMode; }
QLocale::Language fakeLanguage() const { Q_ASSERT(0); return QLocale::C; }
QLocale::Country fakeCountry() const { Q_ASSERT(0); return QLocale::AnyCountry; }
Qt::ItemFlags fakeItemFlags() const { Q_ASSERT(0); return Qt::NoItemFlags; }
Qt::CheckState fakeCheckState() const { Q_ASSERT(0); return Qt::Unchecked; }
Qt::Alignment fakeAlignment() const { Q_ASSERT(0); return Qt::AlignLeft; }
};
// Convert key to value for a given QMetaEnum
template <class EnumType>
inline EnumType enumKeyToValue(const QMetaEnum &metaEnum,const char *key, const EnumType* = 0)
{
int val = metaEnum.keyToValue(key);
if (val == -1) {
uiLibWarning(QCoreApplication::translate("QFormBuilder", "The enumeration-value '%1' is invalid. The default value '%2' will be used instead.")
.arg(QString::fromUtf8(key)).arg(QString::fromUtf8(metaEnum.key(0))));
val = metaEnum.value(0);
}
return static_cast<EnumType>(val);
}
// Convert keys to value for a given QMetaEnum
template <class EnumType>
inline EnumType enumKeysToValue(const QMetaEnum &metaEnum,const char *keys, const EnumType* = 0)
{
int val = metaEnum.keysToValue(keys);
if (val == -1) {
uiLibWarning(QCoreApplication::translate("QFormBuilder", "The flag-value '%1' is invalid. Zero will be used instead.")
.arg(QString::fromUtf8(keys)));
val = 0;
}
return static_cast<EnumType>(QFlag(val));
}
// Access meta enumeration object of a qobject
template <class QObjectType>
inline QMetaEnum metaEnum(const char *name, const QObjectType* = 0)
{
const int e_index = QObjectType::staticMetaObject.indexOfProperty(name);
Q_ASSERT(e_index != -1);
return QObjectType::staticMetaObject.property(e_index).enumerator();
}
// Convert key to value for enumeration by name
template <class QObjectType, class EnumType>
inline EnumType enumKeyOfObjectToValue(const char *enumName, const char *key, const QObjectType* = 0, const EnumType* = 0)
{
const QMetaEnum me = metaEnum<QObjectType>(enumName);
return enumKeyToValue<EnumType>(me, key);
}
#ifdef QFORMINTERNAL_NAMESPACE
}
#endif
QT_END_NAMESPACE
#endif // UILIBPROPERTIES_H

View File

@@ -0,0 +1,66 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QDESIGNEREXPORTWIDGET_H
#define QDESIGNEREXPORTWIDGET_H
#include <QtCore/QtGlobal>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#if 0
// pragma for syncqt, don't remove.
#pragma qt_class(QDesignerExportWidget)
#endif
#if defined(QDESIGNER_EXPORT_WIDGETS)
# define QDESIGNER_WIDGET_EXPORT Q_DECL_EXPORT
#else
# define QDESIGNER_WIDGET_EXPORT Q_DECL_IMPORT
#endif
QT_END_NAMESPACE
QT_END_HEADER
#endif //QDESIGNEREXPORTWIDGET_H

View File

@@ -0,0 +1,169 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "resourcebuilder_p.h"
#include "ui4_p.h"
#include <QtCore/QVariant>
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
#include <QtGui/QPixmap>
#include <QtGui/QIcon>
QT_BEGIN_NAMESPACE
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal {
#endif
QResourceBuilder::QResourceBuilder()
{
}
QResourceBuilder::~QResourceBuilder()
{
}
int QResourceBuilder::iconStateFlags(const DomResourceIcon *dpi)
{
int rc = 0;
if (dpi->hasElementNormalOff())
rc |= NormalOff;
if (dpi->hasElementNormalOn())
rc |= NormalOn;
if (dpi->hasElementDisabledOff())
rc |= DisabledOff;
if (dpi->hasElementDisabledOn())
rc |= DisabledOn;
if (dpi->hasElementActiveOff())
rc |= ActiveOff;
if (dpi->hasElementActiveOn())
rc |= ActiveOn;
if (dpi->hasElementSelectedOff())
rc |= SelectedOff;
if (dpi->hasElementSelectedOn())
rc |= SelectedOn;
return rc;
}
QVariant QResourceBuilder::loadResource(const QDir &workingDirectory, const DomProperty *property) const
{
switch (property->kind()) {
case DomProperty::Pixmap: {
const DomResourcePixmap *dpx = property->elementPixmap();
QPixmap pixmap(QFileInfo(workingDirectory, dpx->text()).absoluteFilePath());
return qVariantFromValue(pixmap);
}
case DomProperty::IconSet: {
const DomResourceIcon *dpi = property->elementIconSet();
if (const int flags = iconStateFlags(dpi)) { // new, post 4.4 format
QIcon icon;
if (flags & NormalOff)
icon.addFile(QFileInfo(workingDirectory, dpi->elementNormalOff()->text()).absoluteFilePath(), QSize(), QIcon::Normal, QIcon::Off);
if (flags & NormalOn)
icon.addFile(QFileInfo(workingDirectory, dpi->elementNormalOn()->text()).absoluteFilePath(), QSize(), QIcon::Normal, QIcon::On);
if (flags & DisabledOff)
icon.addFile(QFileInfo(workingDirectory, dpi->elementDisabledOff()->text()).absoluteFilePath(), QSize(), QIcon::Disabled, QIcon::Off);
if (flags & DisabledOn)
icon.addFile(QFileInfo(workingDirectory, dpi->elementDisabledOn()->text()).absoluteFilePath(), QSize(), QIcon::Disabled, QIcon::On);
if (flags & ActiveOff)
icon.addFile(QFileInfo(workingDirectory, dpi->elementActiveOff()->text()).absoluteFilePath(), QSize(), QIcon::Active, QIcon::Off);
if (flags & ActiveOn)
icon.addFile(QFileInfo(workingDirectory, dpi->elementActiveOn()->text()).absoluteFilePath(), QSize(), QIcon::Active, QIcon::On);
if (flags & SelectedOff)
icon.addFile(QFileInfo(workingDirectory, dpi->elementSelectedOff()->text()).absoluteFilePath(), QSize(), QIcon::Selected, QIcon::Off);
if (flags & SelectedOn)
icon.addFile(QFileInfo(workingDirectory, dpi->elementSelectedOn()->text()).absoluteFilePath(), QSize(), QIcon::Selected, QIcon::On);
return qVariantFromValue(icon);
} else { // 4.3 legacy
const QIcon icon(QFileInfo(workingDirectory, dpi->text()).absoluteFilePath());
return qVariantFromValue(icon);
}
}
break;
default:
break;
}
return QVariant();
}
QVariant QResourceBuilder::toNativeValue(const QVariant &value) const
{
return value;
}
DomProperty *QResourceBuilder::saveResource(const QDir &workingDirectory, const QVariant &value) const
{
Q_UNUSED(workingDirectory)
Q_UNUSED(value)
return 0;
}
bool QResourceBuilder::isResourceProperty(const DomProperty *p) const
{
switch (p->kind()) {
case DomProperty::Pixmap:
case DomProperty::IconSet:
return true;
default:
break;
}
return false;
}
bool QResourceBuilder::isResourceType(const QVariant &value) const
{
switch (value.type()) {
case QVariant::Pixmap:
case QVariant::Icon:
return true;
default:
break;
}
return false;
}
#ifdef QFORMINTERNAL_NAMESPACE
} // namespace QFormInternal
#endif
QT_END_NAMESPACE

View File

@@ -0,0 +1,104 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef RESOURCEBUILDER_H
#define RESOURCEBUILDER_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtDesigner/uilib_global.h>
#include <QtCore/QList>
#include <QtCore/QString>
QT_BEGIN_NAMESPACE
class QDir;
class QVariant;
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal
{
#endif
class DomProperty;
class DomResourceIcon;
class QDESIGNER_UILIB_EXPORT QResourceBuilder
{
public:
enum IconStateFlags {
NormalOff = 0x1, NormalOn = 0x2, DisabledOff = 0x4, DisabledOn = 0x8,
ActiveOff = 0x10, ActiveOn = 0x20, SelectedOff = 0x40, SelectedOn = 0x80
};
QResourceBuilder();
virtual ~QResourceBuilder();
virtual QVariant loadResource(const QDir &workingDirectory, const DomProperty *property) const;
virtual QVariant toNativeValue(const QVariant &value) const;
virtual DomProperty *saveResource(const QDir &workingDirectory, const QVariant &value) const;
virtual bool isResourceProperty(const DomProperty *p) const;
virtual bool isResourceType(const QVariant &value) const;
static int iconStateFlags(const DomResourceIcon *resIcon);
};
#ifdef QFORMINTERNAL_NAMESPACE
}
#endif
QT_END_NAMESPACE
#endif // RESOURCEBUILDER_H

View File

@@ -0,0 +1,84 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#include "textbuilder_p.h"
#include "ui4_p.h"
#include <QtCore/QVariant>
QT_BEGIN_NAMESPACE
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal {
#endif
QTextBuilder::QTextBuilder()
{
}
QTextBuilder::~QTextBuilder()
{
}
QVariant QTextBuilder::loadText(const DomProperty *property) const
{
if (property->kind() == DomProperty::String)
return property->elementString()->text();
return QVariant();
}
QVariant QTextBuilder::toNativeValue(const QVariant &value) const
{
return value;
}
DomProperty *QTextBuilder::saveText(const QVariant &value) const
{
Q_UNUSED(value)
return 0;
}
#ifdef QFORMINTERNAL_NAMESPACE
} // namespace QFormInternal
#endif
QT_END_NAMESPACE

View File

@@ -0,0 +1,93 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef TEXTBUILDER_H
#define TEXTBUILDER_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtDesigner/uilib_global.h>
#include <QtCore/QList>
#include <QtCore/QString>
QT_BEGIN_NAMESPACE
class QDir;
class QVariant;
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal
{
#endif
class DomProperty;
class DomString;
class QDESIGNER_UILIB_EXPORT QTextBuilder
{
public:
QTextBuilder();
virtual ~QTextBuilder();
virtual QVariant loadText(const DomProperty *property) const;
virtual QVariant toNativeValue(const QVariant &value) const;
virtual DomProperty *saveText(const QVariant &value) const;
};
#ifdef QFORMINTERNAL_NAMESPACE
}
#endif
QT_END_NAMESPACE
#endif // TEXTBUILDER_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
INCLUDEPATH += $$PWD
DEFINES += QT_DESIGNER
!contains(QT_CONFIG, script): DEFINES += QT_FORMBUILDER_NO_SCRIPT
# Input
HEADERS += \
$$PWD/ui4_p.h \
$$PWD/abstractformbuilder.h \
$$PWD/formbuilder.h \
$$PWD/container.h \
$$PWD/customwidget.h \
$$PWD/properties_p.h \
$$PWD/formbuilderextra_p.h \
$$PWD/resourcebuilder_p.h \
$$PWD/textbuilder_p.h
SOURCES += \
$$PWD/abstractformbuilder.cpp \
$$PWD/formbuilder.cpp \
$$PWD/ui4.cpp \
$$PWD/properties.cpp \
$$PWD/formbuilderextra.cpp \
$$PWD/resourcebuilder.cpp \
$$PWD/textbuilder.cpp
!contains(DEFINES, QT_FORMBUILDER_NO_SCRIPT) {
QT += script
HEADERS += $$PWD/formscriptrunner_p.h
SOURCES += $$PWD/formscriptrunner.cpp
}

View File

@@ -0,0 +1,64 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef UILIB_GLOBAL_H
#define UILIB_GLOBAL_H
#include <QtCore/qglobal.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#define QDESIGNER_UILIB_EXTERN Q_DECL_EXPORT
#define QDESIGNER_UILIB_IMPORT Q_DECL_IMPORT
#ifdef QT_DESIGNER_STATIC
# define QDESIGNER_UILIB_EXPORT
#elif defined(QDESIGNER_UILIB_LIBRARY)
# define QDESIGNER_UILIB_EXPORT QDESIGNER_UILIB_EXTERN
#else
# define QDESIGNER_UILIB_EXPORT QDESIGNER_UILIB_IMPORT
#endif
QT_END_NAMESPACE
QT_END_HEADER
#endif // UILIB_GLOBAL_H

View File

@@ -0,0 +1,148 @@
#ifndef DECLARE_WIDGET_1
# define DECLARE_WIDGET_1(a,b) DECLARE_WIDGET(a,b)
#endif
// widgets
#ifndef QT_NO_CHECKBOX
DECLARE_WIDGET(QCheckBox, "text")
#endif
#ifndef QT_NO_COMBOBOX
DECLARE_WIDGET(QComboBox, "")
#endif
#ifndef QT_NO_DATETIMEEDIT
DECLARE_WIDGET(QDateTimeEdit, "")
#endif
#ifndef QT_NO_DATEEDIT
DECLARE_WIDGET(QDateEdit, "")
#endif
#ifndef QT_NO_TIMEEDIT
DECLARE_WIDGET(QTimeEdit, "")
#endif
#ifndef QT_NO_DIAL
DECLARE_WIDGET(QDial, "")
#endif
DECLARE_WIDGET(QDialog, "")
#ifndef QT_NO_DOCKWIDGET
DECLARE_WIDGET(QDockWidget, "")
#endif
DECLARE_WIDGET(QFrame, "")
#ifndef QT_NO_GROUPBOX
DECLARE_WIDGET(QGroupBox, "")
#endif
#ifndef QT_NO_SCROLLAREA
DECLARE_WIDGET(QScrollArea, "")
#endif
#ifndef QT_NO_LCDNUMBER
DECLARE_WIDGET(QLCDNumber, "")
#endif
DECLARE_WIDGET(QLabel, "")
#ifndef QT_NO_LINEEDIT
DECLARE_WIDGET(QLineEdit, "")
#endif
#ifndef QT_NO_LISTVIEW
DECLARE_WIDGET(QListView, "")
#endif
#ifndef QT_NO_LISTWIDGET
DECLARE_WIDGET(QListWidget, "")
#endif
#ifndef QT_NO_MAINWINDOW
DECLARE_WIDGET(QMainWindow, "")
#endif
#ifndef QT_NO_MDIAREA
DECLARE_WIDGET(QMdiArea, "")
#endif
#ifndef QT_NO_MENU
DECLARE_WIDGET(QMenu, "")
#endif
#ifndef QT_NO_MENUBAR
DECLARE_WIDGET(QMenuBar, "")
#endif
#ifndef QT_NO_PROGRESSBAR
DECLARE_WIDGET(QProgressBar, "")
#endif
DECLARE_WIDGET(QPushButton, "text")
DECLARE_WIDGET(QRadioButton, "text")
DECLARE_WIDGET(QCommandLinkButton, "text")
#ifndef QT_NO_SCROLLBAR
DECLARE_WIDGET(QScrollBar, "")
#endif
#ifndef QT_NO_SLIDER
DECLARE_WIDGET(QSlider, "")
#endif
#ifndef QT_NO_SPINBOX
DECLARE_WIDGET(QSpinBox, "")
DECLARE_WIDGET(QDoubleSpinBox, "")
#endif
#ifndef QT_NO_TABWIDGET
DECLARE_WIDGET(QTabWidget, "")
#endif
#ifndef QT_NO_TABLEVIEW
DECLARE_WIDGET(QTableView, "")
#endif
#ifndef QT_NO_TABLEWIDGET
DECLARE_WIDGET(QTableWidget, "")
#endif
#ifndef QT_NO_TEXTBROWSER
DECLARE_WIDGET(QTextBrowser, "")
#endif
#ifndef QT_NO_TEXTEDIT
DECLARE_WIDGET(QTextEdit, "")
DECLARE_WIDGET(QPlainTextEdit, "")
#endif
#ifndef QT_NO_TOOLBAR
DECLARE_WIDGET(QToolBar, "")
#endif
#ifndef QT_NO_TOOLBOX
DECLARE_WIDGET(QToolBox, "")
#endif
#ifndef QT_NO_TOOLBUTTON
DECLARE_WIDGET(QToolButton, "text")
#endif
#ifndef QT_NO_TREEVIEW
DECLARE_WIDGET(QTreeView, "")
#endif
#ifndef QT_NO_TREEWIDGET
DECLARE_WIDGET(QTreeWidget, "")
#endif
DECLARE_WIDGET(QWidget, "")
#ifndef QT_NO_WORKSPACE
DECLARE_WIDGET(QWorkspace, "")
#endif
#ifndef QT_NO_SPLITTER
DECLARE_WIDGET(QSplitter, "")
#endif
#ifndef QT_NO_STACKEDWIDGET
DECLARE_WIDGET(QStackedWidget, "")
#endif
#ifndef QT_NO_STATUSBAR
DECLARE_WIDGET(QStatusBar, "")
#endif
DECLARE_WIDGET(QDialogButtonBox, "")
#ifndef QT_NO_FONTCOMBOBOX
DECLARE_WIDGET(QFontComboBox, "")
#endif
#ifndef QT_NO_CALENDARWIDGET
DECLARE_WIDGET(QCalendarWidget, "")
#endif
#ifndef QT_NO_COLUMNVIEW
DECLARE_WIDGET(QColumnView, "")
#endif
#ifndef QT_NO_WIZARD
DECLARE_WIDGET(QWizard, "")
DECLARE_WIDGET(QWizardPage, "")
#endif
#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
DECLARE_WIDGET_1(QGraphicsView, "")
#endif
// layouts
DECLARE_LAYOUT(QGridLayout, "")
DECLARE_LAYOUT(QHBoxLayout, "")
DECLARE_LAYOUT(QStackedLayout, "")
DECLARE_LAYOUT(QVBoxLayout, "")
#ifndef QT_NO_FORMLAYOUT
DECLARE_LAYOUT(QFormLayout, "")
#endif