彻底改版2.0
This commit is contained in:
178
third/designer/lib/extension/default_extensionfactory.cpp
Normal file
178
third/designer/lib/extension/default_extensionfactory.cpp
Normal file
@@ -0,0 +1,178 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <QtDesigner/default_extensionfactory.h>
|
||||
#include "qextensionmanager.h"
|
||||
#include <qpointer.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QExtensionFactory
|
||||
|
||||
\brief The QExtensionFactory class allows you to create a factory
|
||||
that is able to make instances of custom extensions in Qt
|
||||
Designer.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
In \QD the extensions are not created until they are required. For
|
||||
that reason, when implementing a custom extension, 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}.
|
||||
|
||||
The QExtensionManager class provides extension management
|
||||
facilities for Qt Designer. When an extension is required, Qt
|
||||
Designer'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 requested extension for the selected
|
||||
object, is found. This factory will then make an instance of the
|
||||
extension.
|
||||
|
||||
There are four available types of extensions in Qt Designer:
|
||||
QDesignerContainerExtension , QDesignerMemberSheetExtension,
|
||||
QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. Qt
|
||||
Designer'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.
|
||||
|
||||
You can either create a new QExtensionFactory and reimplement the
|
||||
QExtensionFactory::createExtension() function. For example:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_extension_default_extensionfactory.cpp 0
|
||||
|
||||
Or you can use an existing factory, expanding the
|
||||
QExtensionFactory::createExtension() function to make the factory
|
||||
able to create your extension as well. For example:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_extension_default_extensionfactory.cpp 1
|
||||
|
||||
For a complete example using the QExtensionFactory class, see the
|
||||
\l {designer/taskmenuextension}{Task Menu Extension example}. The
|
||||
example shows how to create a custom widget plugin for Qt
|
||||
Designer, and how to to use the QDesignerTaskMenuExtension class
|
||||
to add custom items to Qt Designer's task menu.
|
||||
|
||||
\sa QExtensionManager, QAbstractExtensionFactory
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs an extension factory with the given \a parent.
|
||||
*/
|
||||
QExtensionFactory::QExtensionFactory(QExtensionManager *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the extension specified by \a iid for the given \a object.
|
||||
|
||||
\sa createExtension()
|
||||
*/
|
||||
|
||||
QObject *QExtensionFactory::extension(QObject *object, const QString &iid) const
|
||||
{
|
||||
if (!object)
|
||||
return 0;
|
||||
const IdObjectKey key = qMakePair(iid, object);
|
||||
|
||||
ExtensionMap::iterator it = m_extensions.find(key);
|
||||
if (it == m_extensions.end()) {
|
||||
if (QObject *ext = createExtension(object, iid, const_cast<QExtensionFactory*>(this))) {
|
||||
connect(ext, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)));
|
||||
it = m_extensions.insert(key, ext);
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_extended.contains(object)) {
|
||||
connect(object, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)));
|
||||
m_extended.insert(object, true);
|
||||
}
|
||||
|
||||
if (it == m_extensions.end())
|
||||
return 0;
|
||||
|
||||
return it.value();
|
||||
}
|
||||
|
||||
void QExtensionFactory::objectDestroyed(QObject *object)
|
||||
{
|
||||
QMutableMapIterator< IdObjectKey, QObject*> it(m_extensions);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
|
||||
QObject *o = it.key().second;
|
||||
if (o == object || object == it.value()) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
m_extended.remove(object);
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates an extension specified by \a iid for the given \a object.
|
||||
The extension object is created as a child of the specified \a
|
||||
parent.
|
||||
|
||||
\sa extension()
|
||||
*/
|
||||
QObject *QExtensionFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const
|
||||
{
|
||||
Q_UNUSED(object);
|
||||
Q_UNUSED(iid);
|
||||
Q_UNUSED(parent);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the extension manager for the extension factory.
|
||||
*/
|
||||
QExtensionManager *QExtensionFactory::extensionManager() const
|
||||
{
|
||||
return static_cast<QExtensionManager *>(parent());
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
86
third/designer/lib/extension/default_extensionfactory.h
Normal file
86
third/designer/lib/extension/default_extensionfactory.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 DEFAULT_EXTENSIONFACTORY_H
|
||||
#define DEFAULT_EXTENSIONFACTORY_H
|
||||
|
||||
#include <QtDesigner/extension_global.h>
|
||||
#include <QtDesigner/extension.h>
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QPair>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QExtensionManager;
|
||||
|
||||
class QDESIGNER_EXTENSION_EXPORT QExtensionFactory : public QObject, public QAbstractExtensionFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QAbstractExtensionFactory)
|
||||
public:
|
||||
QExtensionFactory(QExtensionManager *parent = 0);
|
||||
|
||||
virtual QObject *extension(QObject *object, const QString &iid) const;
|
||||
QExtensionManager *extensionManager() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void objectDestroyed(QObject *object);
|
||||
|
||||
protected:
|
||||
virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const;
|
||||
|
||||
private:
|
||||
typedef QPair<QString,QObject*> IdObjectKey;
|
||||
typedef QMap< IdObjectKey, QObject*> ExtensionMap;
|
||||
mutable ExtensionMap m_extensions;
|
||||
typedef QHash<QObject*, bool> ExtendedSet;
|
||||
mutable ExtendedSet m_extended;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // DEFAULT_EXTENSIONFACTORY_H
|
||||
186
third/designer/lib/extension/extension.cpp
Normal file
186
third/designer/lib/extension/extension.cpp
Normal file
@@ -0,0 +1,186 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <QtDesigner/extension.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QAbstractExtensionFactory
|
||||
|
||||
\brief The QAbstractExtensionFactory class provides an interface
|
||||
for extension factories in Qt Designer.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
QAbstractExtensionFactory is not intended to be instantiated
|
||||
directly; use the QExtensionFactory instead.
|
||||
|
||||
In \QD, extension factories are used to look up and create named
|
||||
extensions as they are required. For that reason, when
|
||||
implementing a custom extension, 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 an 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 the requested
|
||||
extension for the selected object, is found. This factory will
|
||||
then make an instance of the extension.
|
||||
|
||||
\sa QExtensionFactory, QExtensionManager
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QAbstractExtensionFactory::~QAbstractExtensionFactory()
|
||||
|
||||
Destroys the extension factory.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QObject *QAbstractExtensionFactory::extension(QObject *object, const QString &iid) const
|
||||
|
||||
Returns the extension specified by \a iid for the given \a object.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\class QAbstractExtensionManager
|
||||
|
||||
\brief The QAbstractExtensionManager class provides an interface
|
||||
for extension managers in Qt Designer.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
QAbstractExtensionManager is not intended to be instantiated
|
||||
directly; use the QExtensionManager instead.
|
||||
|
||||
In \QD, extension are not created until they are required. For
|
||||
that reason, when implementing a custom extension, 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 an 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 the requested
|
||||
extension for the selected object, is found. This factory will
|
||||
then make an instance of the extension.
|
||||
|
||||
\sa QExtensionManager, QExtensionFactory
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QAbstractExtensionManager::~QAbstractExtensionManager()
|
||||
|
||||
Destroys the extension manager.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QAbstractExtensionManager::registerExtensions(QAbstractExtensionFactory *factory, const QString &iid)
|
||||
|
||||
Register the given extension \a factory with the extension
|
||||
specified by \a iid.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QAbstractExtensionManager::unregisterExtensions(QAbstractExtensionFactory *factory, const QString &iid)
|
||||
|
||||
Unregister the given \a factory with the extension specified by \a
|
||||
iid.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QObject *QAbstractExtensionManager::extension(QObject *object, const QString &iid) const
|
||||
|
||||
Returns the extension, specified by \a iid, for the given \a
|
||||
object.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn T qt_extension(QAbstractExtensionManager* manager, QObject *object)
|
||||
|
||||
\relates QExtensionManager
|
||||
|
||||
Returns the extension of the given \a object cast to type T if the
|
||||
object is of type T (or of a subclass); otherwise returns 0. The
|
||||
extension is retrieved using the given extension \a manager.
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp 0
|
||||
|
||||
When implementing a custom widget plugin, a pointer to \QD's
|
||||
current QDesignerFormEditorInterface object (\c formEditor) is
|
||||
provided by the QDesignerCustomWidgetInterface::initialize()
|
||||
function's parameter.
|
||||
|
||||
If the widget in the example above doesn't have a defined
|
||||
QDesignerPropertySheetExtension, \c propertySheet will be a null
|
||||
pointer.
|
||||
|
||||
*/
|
||||
|
||||
/*!
|
||||
\macro Q_DECLARE_EXTENSION_INTERFACE(ExtensionName, Identifier)
|
||||
|
||||
\relates QExtensionManager
|
||||
|
||||
Associates the given \a Identifier (a string literal) to the
|
||||
extension class called \a ExtensionName. The \a Identifier must be
|
||||
unique. For example:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp 1
|
||||
|
||||
Using the company and product names is a good way to ensure
|
||||
uniqueness of the identifier.
|
||||
|
||||
When implementing a custom extension class, you must use
|
||||
Q_DECLARE_EXTENSION_INTERFACE() to enable usage of the
|
||||
qt_extension() function. The macro is normally located right after the
|
||||
class definition for \a ExtensionName, in the associated header
|
||||
file.
|
||||
|
||||
\sa Q_DECLARE_INTERFACE()
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
109
third/designer/lib/extension/extension.h
Normal file
109
third/designer/lib/extension/extension.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 EXTENSION_H
|
||||
#define EXTENSION_H
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QObject>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#define Q_TYPEID(IFace) QLatin1String(IFace##_iid)
|
||||
|
||||
class QAbstractExtensionFactory
|
||||
{
|
||||
public:
|
||||
virtual ~QAbstractExtensionFactory() {}
|
||||
|
||||
virtual QObject *extension(QObject *object, const QString &iid) const = 0;
|
||||
};
|
||||
Q_DECLARE_INTERFACE(QAbstractExtensionFactory, "com.trolltech.Qt.QAbstractExtensionFactory")
|
||||
|
||||
class QAbstractExtensionManager
|
||||
{
|
||||
public:
|
||||
virtual ~QAbstractExtensionManager() {}
|
||||
|
||||
virtual void registerExtensions(QAbstractExtensionFactory *factory, const QString &iid) = 0;
|
||||
virtual void unregisterExtensions(QAbstractExtensionFactory *factory, const QString &iid) = 0;
|
||||
|
||||
virtual QObject *extension(QObject *object, const QString &iid) const = 0;
|
||||
};
|
||||
Q_DECLARE_INTERFACE(QAbstractExtensionManager, "com.trolltech.Qt.QAbstractExtensionManager")
|
||||
|
||||
#if defined(Q_CC_MSVC) && (_MSC_VER < 1300)
|
||||
|
||||
template <class T>
|
||||
inline T qt_extension_helper(QAbstractExtensionManager *, QObject *, T)
|
||||
{ return 0; }
|
||||
|
||||
template <class T>
|
||||
inline T qt_extension(QAbstractExtensionManager* manager, QObject *object)
|
||||
{ return qt_extension_helper(manager, object, T(0)); }
|
||||
|
||||
#define Q_DECLARE_EXTENSION_INTERFACE(IFace, IId) \
|
||||
const char * const IFace##_iid = IId; \
|
||||
Q_DECLARE_INTERFACE(IFace, IId) \
|
||||
template <> inline IFace *qt_extension_helper<IFace *>(QAbstractExtensionManager *manager, QObject *object, IFace *) \
|
||||
{ QObject *extension = manager->extension(object, Q_TYPEID(IFace)); return (IFace *)(extension ? extension->qt_metacast(IFace##_iid) : 0); }
|
||||
|
||||
#else
|
||||
|
||||
template <class T>
|
||||
inline T qt_extension(QAbstractExtensionManager* manager, QObject *object)
|
||||
{ return 0; }
|
||||
|
||||
#define Q_DECLARE_EXTENSION_INTERFACE(IFace, IId) \
|
||||
const char * const IFace##_iid = IId; \
|
||||
Q_DECLARE_INTERFACE(IFace, IId) \
|
||||
template <> inline IFace *qt_extension<IFace *>(QAbstractExtensionManager *manager, QObject *object) \
|
||||
{ QObject *extension = manager->extension(object, Q_TYPEID(IFace)); return extension ? static_cast<IFace *>(extension->qt_metacast(IFace##_iid)) : static_cast<IFace *>(0); }
|
||||
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // EXTENSION_H
|
||||
12
third/designer/lib/extension/extension.pri
Normal file
12
third/designer/lib/extension/extension.pri
Normal file
@@ -0,0 +1,12 @@
|
||||
# Input
|
||||
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += $$PWD/default_extensionfactory.h \
|
||||
$$PWD/extension.h \
|
||||
$$PWD/qextensionmanager.h
|
||||
|
||||
SOURCES += $$PWD/default_extensionfactory.cpp \
|
||||
$$PWD/extension.cpp \
|
||||
$$PWD/qextensionmanager.cpp
|
||||
|
||||
64
third/designer/lib/extension/extension_global.h
Normal file
64
third/designer/lib/extension/extension_global.h
Normal 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 EXTENSION_GLOBAL_H
|
||||
#define EXTENSION_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#define QDESIGNER_EXTENSION_EXTERN Q_DECL_EXPORT
|
||||
#define QDESIGNER_EXTENSION_IMPORT Q_DECL_IMPORT
|
||||
|
||||
#ifdef QT_DESIGNER_STATIC
|
||||
# define QDESIGNER_EXTENSION_EXPORT
|
||||
#elif defined(QDESIGNER_EXTENSION_LIBRARY)
|
||||
# define QDESIGNER_EXTENSION_EXPORT QDESIGNER_EXTENSION_EXTERN
|
||||
#else
|
||||
# define QDESIGNER_EXTENSION_EXPORT QDESIGNER_EXTENSION_IMPORT
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // EXTENSION_GLOBAL_H
|
||||
174
third/designer/lib/extension/qextensionmanager.cpp
Normal file
174
third/designer/lib/extension/qextensionmanager.cpp
Normal file
@@ -0,0 +1,174 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "qextensionmanager.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QExtensionManager
|
||||
|
||||
\brief The QExtensionManager class provides extension management
|
||||
facilities for Qt Designer.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
In \QD the extensions are not created until they are required. For
|
||||
that reason, when implementing an extension, 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 extension manager.
|
||||
|
||||
The registration of an extension factory is typically made in the
|
||||
QDesignerCustomWidgetInterface::initialize() function:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_extension_qextensionmanager.cpp 0
|
||||
|
||||
The QExtensionManager is not intended to be instantiated
|
||||
directly. You can retrieve an interface to \QD's extension manager
|
||||
using the QDesignerFormEditorInterface::extensionManager()
|
||||
function. A pointer to \QD's current QDesignerFormEditorInterface
|
||||
object (\c formEditor in the example above) is provided by the
|
||||
QDesignerCustomWidgetInterface::initialize() function's
|
||||
parameter. When implementing a custom widget plugin, you must
|
||||
subclass the QDesignerCustomWidgetInterface to expose your plugin
|
||||
to \QD.
|
||||
|
||||
Then, when an extension is required, \QD's extension manager will
|
||||
run through all its registered factories calling
|
||||
QExtensionFactory::createExtension() for each until the first one
|
||||
that is able to create the requested extension for the selected
|
||||
object, is found. This factory will then make an instance of the
|
||||
extension.
|
||||
|
||||
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 container, a member
|
||||
sheet, a property sheet or a task menu.
|
||||
|
||||
For a complete example using the QExtensionManager class, see the
|
||||
\l {designer/taskmenuextension}{Task Menu Extension example}. The
|
||||
example shows how to create a custom widget plugin for Qt
|
||||
Designer, and how to to use the QDesignerTaskMenuExtension class
|
||||
to add custom items to \QD's task menu.
|
||||
|
||||
\sa QExtensionFactory, QAbstractExtensionManager
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs an extension manager with the given \a parent.
|
||||
*/
|
||||
QExtensionManager::QExtensionManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Destroys the extension manager
|
||||
*/
|
||||
QExtensionManager::~QExtensionManager()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Register the extension specified by the given \a factory and
|
||||
extension identifier \a iid.
|
||||
*/
|
||||
void QExtensionManager::registerExtensions(QAbstractExtensionFactory *factory, const QString &iid)
|
||||
{
|
||||
if (iid.isEmpty()) {
|
||||
m_globalExtension.prepend(factory);
|
||||
return;
|
||||
}
|
||||
|
||||
FactoryMap::iterator it = m_extensions.find(iid);
|
||||
if (it == m_extensions.end())
|
||||
it = m_extensions.insert(iid, FactoryList());
|
||||
|
||||
it.value().prepend(factory);
|
||||
}
|
||||
|
||||
/*!
|
||||
Unregister the extension specified by the given \a factory and
|
||||
extension identifier \a iid.
|
||||
*/
|
||||
void QExtensionManager::unregisterExtensions(QAbstractExtensionFactory *factory, const QString &iid)
|
||||
{
|
||||
if (iid.isEmpty()) {
|
||||
m_globalExtension.removeAll(factory);
|
||||
return;
|
||||
}
|
||||
|
||||
const FactoryMap::iterator it = m_extensions.find(iid);
|
||||
if (it == m_extensions.end())
|
||||
return;
|
||||
|
||||
FactoryList &factories = it.value();
|
||||
factories.removeAll(factory);
|
||||
|
||||
if (factories.isEmpty())
|
||||
m_extensions.erase(it);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the extension specified by \a iid, for the given \a
|
||||
object.
|
||||
*/
|
||||
QObject *QExtensionManager::extension(QObject *object, const QString &iid) const
|
||||
{
|
||||
const FactoryMap::const_iterator it = m_extensions.constFind(iid);
|
||||
if (it != m_extensions.constEnd()) {
|
||||
const FactoryList::const_iterator fcend = it.value().constEnd();
|
||||
for (FactoryList::const_iterator fit = it.value().constBegin(); fit != fcend; ++fit)
|
||||
if (QObject *ext = (*fit)->extension(object, iid))
|
||||
return ext;
|
||||
}
|
||||
const FactoryList::const_iterator gfcend = m_globalExtension.constEnd();
|
||||
for (FactoryList::const_iterator git = m_globalExtension.constBegin(); git != gfcend; ++git)
|
||||
if (QObject *ext = (*git)->extension(object, iid))
|
||||
return ext;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
79
third/designer/lib/extension/qextensionmanager.h
Normal file
79
third/designer/lib/extension/qextensionmanager.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 QEXTENSIONMANAGER_H
|
||||
#define QEXTENSIONMANAGER_H
|
||||
|
||||
#include <QtDesigner/extension_global.h>
|
||||
#include <QtDesigner/extension.h>
|
||||
#include <QtCore/QHash>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QObject; // Fool syncqt
|
||||
|
||||
class QDESIGNER_EXTENSION_EXPORT QExtensionManager: public QObject, public QAbstractExtensionManager
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QAbstractExtensionManager)
|
||||
public:
|
||||
QExtensionManager(QObject *parent = 0);
|
||||
~QExtensionManager();
|
||||
|
||||
virtual void registerExtensions(QAbstractExtensionFactory *factory, const QString &iid = QString());
|
||||
virtual void unregisterExtensions(QAbstractExtensionFactory *factory, const QString &iid = QString());
|
||||
|
||||
virtual QObject *extension(QObject *object, const QString &iid) const;
|
||||
|
||||
private:
|
||||
typedef QList<QAbstractExtensionFactory*> FactoryList;
|
||||
typedef QHash<QString, FactoryList> FactoryMap;
|
||||
FactoryMap m_extensions;
|
||||
FactoryList m_globalExtension;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QEXTENSIONMANAGER_H
|
||||
78
third/designer/lib/lib.pro
Normal file
78
third/designer/lib/lib.pro
Normal file
@@ -0,0 +1,78 @@
|
||||
TEMPLATE=lib
|
||||
TARGET=QtDesigner
|
||||
QT += xml
|
||||
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
|
||||
CONFIG += qt
|
||||
win32|mac: CONFIG += debug_and_release
|
||||
DESTDIR = ../../../../lib
|
||||
!wince*:DLLDESTDIR = ../../../../bin
|
||||
|
||||
isEmpty(QT_MAJOR_VERSION) {
|
||||
VERSION=4.3.0
|
||||
} else {
|
||||
VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION}
|
||||
}
|
||||
|
||||
unix:QMAKE_PKGCONFIG_REQUIRES += QtXml
|
||||
|
||||
include(../../../../src/qt_targets.pri)
|
||||
QMAKE_TARGET_PRODUCT = Designer
|
||||
QMAKE_TARGET_DESCRIPTION = Graphical user interface designer.
|
||||
|
||||
!contains(CONFIG, static) {
|
||||
CONFIG += dll
|
||||
|
||||
DEFINES += \
|
||||
QDESIGNER_SDK_LIBRARY \
|
||||
QDESIGNER_EXTENSION_LIBRARY \
|
||||
QDESIGNER_UILIB_LIBRARY \
|
||||
QDESIGNER_SHARED_LIBRARY
|
||||
} else {
|
||||
DEFINES += QT_DESIGNER_STATIC
|
||||
}
|
||||
|
||||
#load up the headers info
|
||||
CONFIG += qt_install_headers
|
||||
HEADERS_PRI = $$QT_BUILD_TREE/include/QtDesigner/headers.pri
|
||||
include($$HEADERS_PRI, "", true)|clear(HEADERS_PRI)
|
||||
|
||||
#mac frameworks
|
||||
mac:CONFIG += explicitlib
|
||||
mac:!static:contains(QT_CONFIG, qt_framework) {
|
||||
QMAKE_FRAMEWORK_BUNDLE_NAME = $$TARGET
|
||||
CONFIG += lib_bundle qt_no_framework_direct_includes qt_framework
|
||||
CONFIG(debug, debug|release) {
|
||||
!build_pass:CONFIG += build_all
|
||||
} else { #release
|
||||
!debug_and_release|build_pass {
|
||||
CONFIG -= qt_install_headers #no need to install these as well
|
||||
FRAMEWORK_HEADERS.version = Versions
|
||||
FRAMEWORK_HEADERS.files = $$SYNCQT.HEADER_FILES $$SYNCQT.HEADER_CLASSES
|
||||
FRAMEWORK_HEADERS.path = Headers
|
||||
}
|
||||
QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS
|
||||
}
|
||||
}
|
||||
|
||||
include(extension/extension.pri)
|
||||
include(sdk/sdk.pri)
|
||||
include(uilib/uilib.pri)
|
||||
include(shared/shared.pri)
|
||||
PRECOMPILED_HEADER=lib_pch.h
|
||||
|
||||
include(../sharedcomponents.pri)
|
||||
include(../components/component.pri)
|
||||
|
||||
target.path=$$[QT_INSTALL_LIBS]
|
||||
INSTALLS += target
|
||||
win32 {
|
||||
dlltarget.path=$$[QT_INSTALL_BINS]
|
||||
INSTALLS += dlltarget
|
||||
}
|
||||
|
||||
|
||||
qt_install_headers {
|
||||
designer_headers.files = $$SYNCQT.HEADER_FILES $$SYNCQT.HEADER_CLASSES
|
||||
designer_headers.path = $$[QT_INSTALL_HEADERS]/QtDesigner
|
||||
INSTALLS += designer_headers
|
||||
}
|
||||
65
third/designer/lib/lib_pch.h
Normal file
65
third/designer/lib/lib_pch.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "shared_global_p.h"
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtDesigner/abstractformeditor.h>
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtDesigner/qextensionmanager.h>
|
||||
#include <QtDesigner/abstractformwindow.h>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtDesigner/propertysheet.h>
|
||||
#include <QtDesigner/extension.h>
|
||||
#include <QtDesigner/abstractmetadatabase.h>
|
||||
#include <QtCore/QList>
|
||||
#include <QtDesigner/abstractwidgetfactory.h>
|
||||
#include <QtDesigner/abstractwidgetdatabase.h>
|
||||
#include <QtGui/QWidget>
|
||||
#include "qdesigner_widget_p.h"
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore/QPointer>
|
||||
#include "layout_p.h"
|
||||
#endif
|
||||
123
third/designer/lib/sdk/abstractactioneditor.cpp
Normal file
123
third/designer/lib/sdk/abstractactioneditor.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractactioneditor.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerActionEditorInterface
|
||||
|
||||
\brief The QDesignerActionEditorInterface class allows you to
|
||||
change the focus of Qt Designer's action editor.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
The QDesignerActionEditorInterface class is not intended to be
|
||||
instantiated directly. You can retrieve an interface to \QD's
|
||||
action editor using the
|
||||
QDesignerFormEditorInterface::actionEditor() function.
|
||||
|
||||
You can control which actions that are available in the action
|
||||
editor's window using the manageAction() and unmanageAction()
|
||||
functions. An action that is managed by \QD is available in the
|
||||
action editor while an unmanaged action is ignored.
|
||||
|
||||
QDesignerActionEditorInterface also provides the core() function
|
||||
that you can use to retrieve a pointer to \QD's current
|
||||
QDesignerFormEditorInterface object, and the setFormWindow()
|
||||
function that enables you to change the currently selected form
|
||||
window.
|
||||
|
||||
\sa QDesignerFormEditorInterface, QDesignerFormWindowInterface
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs an action editor interface with the given \a parent and
|
||||
the specified window \a flags.
|
||||
*/
|
||||
QDesignerActionEditorInterface::QDesignerActionEditorInterface(QWidget *parent, Qt::WindowFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the action editor interface.
|
||||
*/
|
||||
QDesignerActionEditorInterface::~QDesignerActionEditorInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a pointer to \QD's current QDesignerFormEditorInterface
|
||||
object.
|
||||
*/
|
||||
QDesignerFormEditorInterface *QDesignerActionEditorInterface::core() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QDesignerActionEditorInterface::setFormWindow(QDesignerFormWindowInterface *formWindow)
|
||||
|
||||
Sets the currently selected form window to \a formWindow.
|
||||
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerActionEditorInterface::manageAction(QAction *action)
|
||||
|
||||
Instructs \QD to manage the specified \a action. An action that is
|
||||
managed by \QD is available in the action editor.
|
||||
|
||||
\sa unmanageAction()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerActionEditorInterface::unmanageAction(QAction *action)
|
||||
|
||||
Instructs \QD to ignore the specified \a action. An unmanaged
|
||||
action is not available in the action editor.
|
||||
|
||||
\sa manageAction()
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
76
third/designer/lib/sdk/abstractactioneditor.h
Normal file
76
third/designer/lib/sdk/abstractactioneditor.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTACTIONEDITOR_H
|
||||
#define ABSTRACTACTIONEDITOR_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
class QDesignerFormWindowInterface;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerActionEditorInterface: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerActionEditorInterface(QWidget *parent, Qt::WindowFlags flags = 0);
|
||||
virtual ~QDesignerActionEditorInterface();
|
||||
|
||||
virtual QDesignerFormEditorInterface *core() const;
|
||||
|
||||
virtual void manageAction(QAction *action) = 0;
|
||||
virtual void unmanageAction(QAction *action) = 0;
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void setFormWindow(QDesignerFormWindowInterface *formWindow) = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTACTIONEDITOR_H
|
||||
83
third/designer/lib/sdk/abstractbrushmanager.h
Normal file
83
third/designer/lib/sdk/abstractbrushmanager.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTBRUSHMANAGER_H
|
||||
#define ABSTRACTBRUSHMANAGER_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qmap.h>
|
||||
#include <QtGui/qbrush.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QObject;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerBrushManagerInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerBrushManagerInterface(QObject *parentObject = 0) : QObject(parentObject) {}
|
||||
|
||||
virtual QBrush brush(const QString &name) const = 0;
|
||||
virtual QMap<QString, QBrush> brushes() const = 0;
|
||||
virtual QString currentBrush() const = 0;
|
||||
|
||||
virtual QString addBrush(const QString &name, const QBrush &brush) = 0;
|
||||
virtual void removeBrush(const QString &name) = 0;
|
||||
virtual void setCurrentBrush(const QString &name) = 0;
|
||||
|
||||
virtual QPixmap brushPixmap(const QBrush &brush) const = 0;
|
||||
Q_SIGNALS:
|
||||
void brushAdded(const QString &name, const QBrush &brush);
|
||||
void brushRemoved(const QString &name);
|
||||
void currentBrushChanged(const QString &name, const QBrush &brush);
|
||||
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
||||
161
third/designer/lib/sdk/abstractdialoggui.cpp
Normal file
161
third/designer/lib/sdk/abstractdialoggui.cpp
Normal file
@@ -0,0 +1,161 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractdialoggui_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerDialogGuiInterface
|
||||
\since 4.4
|
||||
\internal
|
||||
|
||||
\brief The QDesignerDialogGuiInterface allows integrations of \QD to replace the
|
||||
message boxes displayed by \QD by custom dialogs.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
QDesignerDialogGuiInterface provides virtual functions that can be overwritten
|
||||
to display message boxes and file dialogs.
|
||||
\sa QMessageBox, QFileDialog
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDesignerDialogGuiInterface::Message
|
||||
|
||||
This enum specifies the context from within the message box is called.
|
||||
|
||||
\value FormLoadFailureMessage Loading of a form failed
|
||||
\value UiVersionMismatchMessage Attempt to load a file created with an old version of Designer
|
||||
\value ResourceLoadFailureMessage Resources specified in a file could not be found
|
||||
\value TopLevelSpacerMessage Spacer items detected on a container without layout
|
||||
\value PropertyEditorMessage Messages of the propert yeditor
|
||||
\value SignalSlotEditorMessage Messages of the signal / slot editor
|
||||
\value FormEditorMessage Messages of the form editor
|
||||
\value PreviewFailureMessage A preview could not be created
|
||||
\value PromotionErrorMessage Messages related to promotion of a widget
|
||||
\value ResourceEditorMessage Messages of the resource editor
|
||||
\value ScriptDialogMessage Messages of the script dialog
|
||||
\value SignalSlotDialogMessage Messages of the signal slot dialog
|
||||
\value OtherMessage Unspecified context
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QDesignerDialogGuiInterface object.
|
||||
*/
|
||||
|
||||
QDesignerDialogGuiInterface::QDesignerDialogGuiInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the QDesignerDialogGuiInterface object.
|
||||
*/
|
||||
QDesignerDialogGuiInterface::~QDesignerDialogGuiInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QMessageBox::StandardButton QDesignerDialogGuiInterface::message(QWidget *parent, Message context, QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
|
||||
|
||||
Opens a message box as child of \a parent within the context \a context, using \a icon, \a title, \a text, \a buttons and \a defaultButton
|
||||
and returns the button chosen by the user.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerDialogGuiInterface::getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options)
|
||||
|
||||
Opens a file dialog as child of \a parent using the parameters \a caption, \a dir and \a options that prompts the
|
||||
user for an existing directory. Returns a directory selected by the user.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerDialogGuiInterface::getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options)
|
||||
|
||||
Opens a file dialog as child of \a parent using the parameters \a caption, \a dir, \a filter, \a selectedFilter and \a options
|
||||
that prompts the user for an existing file. Returns a file selected by the user.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QStringList QDesignerDialogGuiInterface::getOpenFileNames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options)
|
||||
|
||||
Opens a file dialog as child of \a parent using the parameters \a caption, \a dir, \a filter, \a selectedFilter and \a options
|
||||
that prompts the user for a set of existing files. Returns one or more existing files selected by the user.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Opens a file dialog with image browsing capabilities as child of \a parent using the parameters \a caption, \a dir, \a filter, \a selectedFilter and \a options
|
||||
that prompts the user for an existing file. Returns a file selected by the user.
|
||||
|
||||
The default implementation simply calls getOpenFileName(). On platforms that do not support an image preview in the QFileDialog,
|
||||
the function can be reimplemented to provide an image browser.
|
||||
|
||||
\since 4.5
|
||||
*/
|
||||
|
||||
QString QDesignerDialogGuiInterface::getOpenImageFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
|
||||
{
|
||||
return getOpenFileName(parent, caption, dir, filter, selectedFilter, options);
|
||||
}
|
||||
|
||||
/*!
|
||||
Opens a file dialog with image browsing capabilities as child of \a parent using the parameters \a caption, \a dir, \a filter, \a selectedFilter and \a options
|
||||
that prompts the user for a set of existing files. Returns one or more existing files selected by the user.
|
||||
|
||||
The default implementation simply calls getOpenFileNames(). On platforms that do not support an image preview in the QFileDialog,
|
||||
the function can be reimplemented to provide an image browser.
|
||||
|
||||
\since 4.5
|
||||
*/
|
||||
|
||||
QStringList QDesignerDialogGuiInterface::getOpenImageFileNames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
|
||||
{
|
||||
return getOpenImageFileNames(parent, caption, dir, filter, selectedFilter, options);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerDialogGuiInterface::getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options)
|
||||
|
||||
Opens a file dialog as child of \a parent using the parameters \a caption, \a dir, \a filter, \a selectedFilter and \a options
|
||||
that prompts the user for a file. Returns a file selected by the user. The file does not have to exist.
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
107
third/designer/lib/sdk/abstractdialoggui_p.h
Normal file
107
third/designer/lib/sdk/abstractdialoggui_p.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTDIALOGGUI_H
|
||||
#define ABSTRACTDIALOGGUI_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QFileDialog>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWidget;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerDialogGuiInterface
|
||||
{
|
||||
Q_DISABLE_COPY(QDesignerDialogGuiInterface)
|
||||
public:
|
||||
QDesignerDialogGuiInterface();
|
||||
virtual ~QDesignerDialogGuiInterface();
|
||||
|
||||
enum Message { FormLoadFailureMessage, UiVersionMismatchMessage, ResourceLoadFailureMessage,
|
||||
TopLevelSpacerMessage, PropertyEditorMessage, SignalSlotEditorMessage, FormEditorMessage,
|
||||
PreviewFailureMessage, PromotionErrorMessage, ResourceEditorMessage,
|
||||
ScriptDialogMessage, SignalSlotDialogMessage, OtherMessage, FileChangedMessage };
|
||||
|
||||
virtual QMessageBox::StandardButton
|
||||
message(QWidget *parent, Message context, QMessageBox::Icon icon,
|
||||
const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton) = 0;
|
||||
|
||||
virtual QMessageBox::StandardButton
|
||||
message(QWidget *parent, Message context, QMessageBox::Icon icon,
|
||||
const QString &title, const QString &text, const QString &informativeText,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton) = 0;
|
||||
|
||||
virtual QMessageBox::StandardButton
|
||||
message(QWidget *parent, Message context, QMessageBox::Icon icon,
|
||||
const QString &title, const QString &text, const QString &informativeText, const QString &detailedText,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton) = 0;
|
||||
|
||||
virtual QString getExistingDirectory(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), QFileDialog::Options options = QFileDialog::ShowDirsOnly)= 0;
|
||||
virtual QString getOpenFileName(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0)= 0;
|
||||
virtual QString getOpenImageFileName(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
virtual QStringList getOpenFileNames(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0)= 0;
|
||||
virtual QStringList getOpenImageFileNames(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
virtual QString getSaveFileName(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0)= 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTDIALOGGUI_H
|
||||
75
third/designer/lib/sdk/abstractdnditem.h
Normal file
75
third/designer/lib/sdk/abstractdnditem.h
Normal 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 ABSTRACTDNDITEM_H
|
||||
#define ABSTRACTDNDITEM_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class DomUI;
|
||||
class QWidget;
|
||||
class QPoint;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerDnDItemInterface
|
||||
{
|
||||
public:
|
||||
enum DropType { MoveDrop, CopyDrop };
|
||||
|
||||
QDesignerDnDItemInterface() {}
|
||||
virtual ~QDesignerDnDItemInterface() {}
|
||||
|
||||
virtual DomUI *domUi() const = 0;
|
||||
virtual QWidget *widget() const = 0;
|
||||
virtual QWidget *decoration() const = 0;
|
||||
virtual QPoint hotSpot() const = 0;
|
||||
virtual DropType type() const = 0;
|
||||
virtual QWidget *source() const = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTDNDITEM_H
|
||||
98
third/designer/lib/sdk/abstractdnditem.qdoc
Normal file
98
third/designer/lib/sdk/abstractdnditem.qdoc
Normal file
@@ -0,0 +1,98 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 QDesignerDnDItemInterface
|
||||
\brief The QDesignerDnDItemInterface class provides an interface that is used to manage items
|
||||
during a drag and drop operation.
|
||||
\inmodule QtDesigner
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDesignerDnDItemInterface::DropType
|
||||
|
||||
This enum describes the result of a drag and drop operation.
|
||||
|
||||
\value MoveDrop The item was moved.
|
||||
\value CopyDrop The item was copied.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerDnDItemInterface::QDesignerDnDItemInterface()
|
||||
|
||||
Constructs a new interface to a drag and drop item.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerDnDItemInterface::~QDesignerDnDItemInterface()
|
||||
|
||||
Destroys the interface to the item.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn DomUI *QDesignerDnDItemInterface::domUi() const
|
||||
|
||||
Returns a user interface object for the item.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QWidget *QDesignerDnDItemInterface::widget() const
|
||||
|
||||
Returns the widget being copied or moved in the drag and drop operation.
|
||||
|
||||
\sa source()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QWidget *QDesignerDnDItemInterface::decoration() const
|
||||
|
||||
Returns the widget used to represent the item.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QPoint QDesignerDnDItemInterface::hotSpot() const
|
||||
|
||||
Returns the cursor's hotspot.
|
||||
|
||||
\sa QDrag::hotSpot()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn DropType QDesignerDnDItemInterface::type() const
|
||||
|
||||
Returns the type of drag and drop operation in progress.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QWidget *QDesignerDnDItemInterface::source() const
|
||||
|
||||
Returns the widget that is the source of the drag and drop operation; i.e. the original
|
||||
container of the widget being dragged.
|
||||
|
||||
\sa widget()
|
||||
*/
|
||||
630
third/designer/lib/sdk/abstractformeditor.cpp
Normal file
630
third/designer/lib/sdk/abstractformeditor.cpp
Normal file
@@ -0,0 +1,630 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractformeditor.h"
|
||||
#include "abstractdialoggui_p.h"
|
||||
#include "abstractintrospection_p.h"
|
||||
#include "abstractsettings_p.h"
|
||||
#include "abstractoptionspage_p.h"
|
||||
|
||||
#include <QtDesigner/QDesignerWidgetBoxInterface>
|
||||
#include <QtDesigner/QDesignerPropertyEditorInterface>
|
||||
#include <QtDesigner/QDesignerFormWindowManagerInterface>
|
||||
#include <QtDesigner/QExtensionManager>
|
||||
#include <QtDesigner/QDesignerMetaDataBaseInterface>
|
||||
#include <QtDesigner/QDesignerWidgetDataBaseInterface>
|
||||
#include <QtDesigner/QDesignerWidgetFactoryInterface>
|
||||
#include <QtDesigner/QDesignerObjectInspectorInterface>
|
||||
#include <QtDesigner/QDesignerBrushManagerInterface>
|
||||
#include <QtDesigner/QDesignerIntegrationInterface>
|
||||
#include <QtDesigner/QDesignerIconCacheInterface>
|
||||
#include <QtDesigner/QDesignerActionEditorInterface>
|
||||
#include <pluginmanager_p.h>
|
||||
#include <qtresourcemodel_p.h>
|
||||
#include <qtgradientmanager.h>
|
||||
#include <widgetfactory_p.h>
|
||||
#include <shared_settings_p.h>
|
||||
#include <formwindowbase_p.h>
|
||||
#include <grid_p.h>
|
||||
#include <QtDesigner/QDesignerPromotionInterface>
|
||||
|
||||
// Must be done outside of the Qt namespace
|
||||
static void initResources()
|
||||
{
|
||||
Q_INIT_RESOURCE(shared);
|
||||
Q_INIT_RESOURCE(ClamshellPhone);
|
||||
Q_INIT_RESOURCE(PortableMedia);
|
||||
Q_INIT_RESOURCE(S60_nHD_Touchscreen);
|
||||
Q_INIT_RESOURCE(S60_QVGA_Candybar);
|
||||
Q_INIT_RESOURCE(SmartPhone2);
|
||||
Q_INIT_RESOURCE(SmartPhone);
|
||||
Q_INIT_RESOURCE(SmartPhoneWithButtons);
|
||||
Q_INIT_RESOURCE(TouchscreenPhone);
|
||||
}
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormEditorInterfacePrivate {
|
||||
public:
|
||||
QDesignerFormEditorInterfacePrivate();
|
||||
~QDesignerFormEditorInterfacePrivate();
|
||||
|
||||
|
||||
QPointer<QWidget> m_topLevel;
|
||||
QPointer<QDesignerWidgetBoxInterface> m_widgetBox;
|
||||
QPointer<QDesignerPropertyEditorInterface> m_propertyEditor;
|
||||
QPointer<QDesignerFormWindowManagerInterface> m_formWindowManager;
|
||||
QPointer<QExtensionManager> m_extensionManager;
|
||||
QPointer<QDesignerMetaDataBaseInterface> m_metaDataBase;
|
||||
QPointer<QDesignerWidgetDataBaseInterface> m_widgetDataBase;
|
||||
QPointer<QDesignerWidgetFactoryInterface> m_widgetFactory;
|
||||
QPointer<QDesignerObjectInspectorInterface> m_objectInspector;
|
||||
QPointer<QDesignerBrushManagerInterface> m_brushManager;
|
||||
QPointer<QDesignerIntegrationInterface> m_integration;
|
||||
QPointer<QDesignerIconCacheInterface> m_iconCache;
|
||||
QPointer<QDesignerActionEditorInterface> m_actionEditor;
|
||||
QDesignerSettingsInterface *m_settingsManager;
|
||||
QDesignerPluginManager *m_pluginManager;
|
||||
QDesignerPromotionInterface *m_promotion;
|
||||
QDesignerIntrospectionInterface *m_introspection;
|
||||
QDesignerDialogGuiInterface *m_dialogGui;
|
||||
QPointer<QtResourceModel> m_resourceModel;
|
||||
QPointer<QtGradientManager> m_gradientManager; // instantiated and deleted by designer_integration
|
||||
QList<QDesignerOptionsPageInterface*> m_optionsPages;
|
||||
};
|
||||
|
||||
QDesignerFormEditorInterfacePrivate::QDesignerFormEditorInterfacePrivate() :
|
||||
m_settingsManager(0),
|
||||
m_pluginManager(0),
|
||||
m_promotion(0),
|
||||
m_introspection(0),
|
||||
m_dialogGui(0),
|
||||
m_resourceModel(0),
|
||||
m_gradientManager(0)
|
||||
{
|
||||
}
|
||||
|
||||
QDesignerFormEditorInterfacePrivate::~QDesignerFormEditorInterfacePrivate()
|
||||
{
|
||||
delete m_settingsManager;
|
||||
delete m_formWindowManager;
|
||||
delete m_promotion;
|
||||
delete m_introspection;
|
||||
delete m_dialogGui;
|
||||
delete m_resourceModel;
|
||||
qDeleteAll(m_optionsPages);
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QDesignerFormEditorInterface
|
||||
|
||||
\brief The QDesignerFormEditorInterface class allows you to access
|
||||
Qt Designer's various components.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
\QD's current QDesignerFormEditorInterface object holds
|
||||
information about all \QD's components: The action editor, the
|
||||
object inspector, the property editor, the widget box, and the
|
||||
extension and form window managers. QDesignerFormEditorInterface
|
||||
contains a collection of functions that provides interfaces to all
|
||||
these components. They are typically used to query (and
|
||||
manipulate) the respective component. For example:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformeditor.cpp 0
|
||||
|
||||
QDesignerFormEditorInterface is not intended to be instantiated
|
||||
directly. A pointer to \QD's current QDesignerFormEditorInterface
|
||||
object (\c formEditor in the example above) is provided by the
|
||||
QDesignerCustomWidgetInterface::initialize() function's
|
||||
parameter. When implementing a custom widget plugin, you must
|
||||
subclass the QDesignerCustomWidgetInterface to expose your plugin
|
||||
to \QD.
|
||||
|
||||
QDesignerFormEditorInterface also provides functions that can set
|
||||
the action editor, property editor, object inspector and widget
|
||||
box. These are only useful if you want to provide your own custom
|
||||
components.
|
||||
|
||||
If designer is embedded in another program, one could to provide its
|
||||
own settings manager. The manager is used by the components of \QD
|
||||
to store/retrieve persistent configuration settings. The default
|
||||
manager uses QSettings as the backend.
|
||||
|
||||
Finally, QDesignerFormEditorInterface provides the topLevel()
|
||||
function that returns \QD's top-level widget.
|
||||
|
||||
\sa QDesignerCustomWidgetInterface
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QDesignerFormEditorInterface object with the given \a
|
||||
parent.
|
||||
*/
|
||||
|
||||
QDesignerFormEditorInterface::QDesignerFormEditorInterface(QObject *parent)
|
||||
: QObject(parent),
|
||||
d(new QDesignerFormEditorInterfacePrivate())
|
||||
{
|
||||
initResources();
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the QDesignerFormEditorInterface object.
|
||||
*/
|
||||
QDesignerFormEditorInterface::~QDesignerFormEditorInterface()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns an interface to \QD's widget box.
|
||||
|
||||
\sa setWidgetBox()
|
||||
*/
|
||||
QDesignerWidgetBoxInterface *QDesignerFormEditorInterface::widgetBox() const
|
||||
{
|
||||
return d->m_widgetBox;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets \QD's widget box to be the specified \a widgetBox.
|
||||
|
||||
\sa widgetBox()
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setWidgetBox(QDesignerWidgetBoxInterface *widgetBox)
|
||||
{
|
||||
d->m_widgetBox = widgetBox;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns an interface to \QD's property editor.
|
||||
|
||||
\sa setPropertyEditor()
|
||||
*/
|
||||
QDesignerPropertyEditorInterface *QDesignerFormEditorInterface::propertyEditor() const
|
||||
{
|
||||
return d->m_propertyEditor;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets \QD's property editor to be the specified \a propertyEditor.
|
||||
|
||||
\sa propertyEditor()
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setPropertyEditor(QDesignerPropertyEditorInterface *propertyEditor)
|
||||
{
|
||||
d->m_propertyEditor = propertyEditor;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns an interface to \QD's action editor.
|
||||
|
||||
\sa setActionEditor()
|
||||
*/
|
||||
QDesignerActionEditorInterface *QDesignerFormEditorInterface::actionEditor() const
|
||||
{
|
||||
return d->m_actionEditor;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets \QD's action editor to be the specified \a actionEditor.
|
||||
|
||||
\sa actionEditor()
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setActionEditor(QDesignerActionEditorInterface *actionEditor)
|
||||
{
|
||||
d->m_actionEditor = actionEditor;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \QD's top-level widget.
|
||||
*/
|
||||
QWidget *QDesignerFormEditorInterface::topLevel() const
|
||||
{
|
||||
return d->m_topLevel;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setTopLevel(QWidget *topLevel)
|
||||
{
|
||||
d->m_topLevel = topLevel;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns an interface to \QD's form window manager.
|
||||
*/
|
||||
QDesignerFormWindowManagerInterface *QDesignerFormEditorInterface::formWindowManager() const
|
||||
{
|
||||
return d->m_formWindowManager;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setFormManager(QDesignerFormWindowManagerInterface *formWindowManager)
|
||||
{
|
||||
d->m_formWindowManager = formWindowManager;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns an interface to \QD's extension manager.
|
||||
*/
|
||||
QExtensionManager *QDesignerFormEditorInterface::extensionManager() const
|
||||
{
|
||||
return d->m_extensionManager;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setExtensionManager(QExtensionManager *extensionManager)
|
||||
{
|
||||
d->m_extensionManager = extensionManager;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Returns an interface to the meta database used by the form editor.
|
||||
*/
|
||||
QDesignerMetaDataBaseInterface *QDesignerFormEditorInterface::metaDataBase() const
|
||||
{
|
||||
return d->m_metaDataBase;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setMetaDataBase(QDesignerMetaDataBaseInterface *metaDataBase)
|
||||
{
|
||||
d->m_metaDataBase = metaDataBase;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Returns an interface to the widget database used by the form editor.
|
||||
*/
|
||||
QDesignerWidgetDataBaseInterface *QDesignerFormEditorInterface::widgetDataBase() const
|
||||
{
|
||||
return d->m_widgetDataBase;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setWidgetDataBase(QDesignerWidgetDataBaseInterface *widgetDataBase)
|
||||
{
|
||||
d->m_widgetDataBase = widgetDataBase;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Returns an interface to the designer promotion handler.
|
||||
*/
|
||||
|
||||
QDesignerPromotionInterface *QDesignerFormEditorInterface::promotion() const
|
||||
{
|
||||
return d->m_promotion;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Sets the designer promotion handler.
|
||||
*/
|
||||
|
||||
void QDesignerFormEditorInterface::setPromotion(QDesignerPromotionInterface *promotion)
|
||||
{
|
||||
if (d->m_promotion)
|
||||
delete d->m_promotion;
|
||||
d->m_promotion = promotion;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Returns an interface to the widget factory used by the form editor
|
||||
to create widgets for the form.
|
||||
*/
|
||||
QDesignerWidgetFactoryInterface *QDesignerFormEditorInterface::widgetFactory() const
|
||||
{
|
||||
return d->m_widgetFactory;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setWidgetFactory(QDesignerWidgetFactoryInterface *widgetFactory)
|
||||
{
|
||||
d->m_widgetFactory = widgetFactory;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns an interface to \QD's object inspector.
|
||||
*/
|
||||
QDesignerObjectInspectorInterface *QDesignerFormEditorInterface::objectInspector() const
|
||||
{
|
||||
return d->m_objectInspector;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets \QD's object inspector to be the specified \a
|
||||
objectInspector.
|
||||
|
||||
\sa objectInspector()
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setObjectInspector(QDesignerObjectInspectorInterface *objectInspector)
|
||||
{
|
||||
d->m_objectInspector = objectInspector;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Returns an interface to the brush manager used by the palette editor.
|
||||
*/
|
||||
QDesignerBrushManagerInterface *QDesignerFormEditorInterface::brushManager() const
|
||||
{
|
||||
return d->m_brushManager;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setBrushManager(QDesignerBrushManagerInterface *brushManager)
|
||||
{
|
||||
d->m_brushManager = brushManager;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Returns an interface to the integration.
|
||||
*/
|
||||
QDesignerIntegrationInterface *QDesignerFormEditorInterface::integration() const
|
||||
{
|
||||
return d->m_integration;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setIntegration(QDesignerIntegrationInterface *integration)
|
||||
{
|
||||
d->m_integration = integration;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Returns an interface to the icon cache used by the form editor to
|
||||
manage icons.
|
||||
*/
|
||||
QDesignerIconCacheInterface *QDesignerFormEditorInterface::iconCache() const
|
||||
{
|
||||
return d->m_iconCache;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setIconCache(QDesignerIconCacheInterface *cache)
|
||||
{
|
||||
d->m_iconCache = cache;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 4.5
|
||||
Returns the list of options pages that allow the user to configure \QD components.
|
||||
*/
|
||||
QList<QDesignerOptionsPageInterface*> QDesignerFormEditorInterface::optionsPages() const
|
||||
{
|
||||
return d->m_optionsPages;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 4.5
|
||||
Sets the list of options pages that allow the user to configure \QD components.
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setOptionsPages(const QList<QDesignerOptionsPageInterface*> &optionsPages)
|
||||
{
|
||||
d->m_optionsPages = optionsPages;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Returns the plugin manager used by the form editor.
|
||||
*/
|
||||
QDesignerPluginManager *QDesignerFormEditorInterface::pluginManager() const
|
||||
{
|
||||
return d->m_pluginManager;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Sets the plugin manager used by the form editor to the specified
|
||||
\a pluginManager.
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setPluginManager(QDesignerPluginManager *pluginManager)
|
||||
{
|
||||
d->m_pluginManager = pluginManager;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 4.4
|
||||
Returns the resource model used by the form editor.
|
||||
*/
|
||||
QtResourceModel *QDesignerFormEditorInterface::resourceModel() const
|
||||
{
|
||||
return d->m_resourceModel;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Sets the resource model used by the form editor to the specified
|
||||
\a resourceModel.
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setResourceModel(QtResourceModel *resourceModel)
|
||||
{
|
||||
d->m_resourceModel = resourceModel;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 4.4
|
||||
Returns the gradient manager used by the style sheet editor.
|
||||
*/
|
||||
QtGradientManager *QDesignerFormEditorInterface::gradientManager() const
|
||||
{
|
||||
return d->m_gradientManager;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Sets the gradient manager used by the style sheet editor to the specified
|
||||
\a gradientManager.
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setGradientManager(QtGradientManager *gradientManager)
|
||||
{
|
||||
d->m_gradientManager = gradientManager;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 4.5
|
||||
Returns the settings manager used by the components to store persistent settings.
|
||||
*/
|
||||
QDesignerSettingsInterface *QDesignerFormEditorInterface::settingsManager() const
|
||||
{
|
||||
return d->m_settingsManager;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 4.5
|
||||
Sets the settings manager used to store/retrieve the persistent settings of the components.
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setSettingsManager(QDesignerSettingsInterface *settingsManager)
|
||||
{
|
||||
if (d->m_settingsManager)
|
||||
delete d->m_settingsManager;
|
||||
d->m_settingsManager = settingsManager;
|
||||
|
||||
// This is a (hopefully) safe place to perform settings-dependent
|
||||
// initializations.
|
||||
const qdesigner_internal::QDesignerSharedSettings settings(this);
|
||||
qdesigner_internal::FormWindowBase::setDefaultDesignerGrid(settings.defaultGrid());
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 4.4
|
||||
Returns the introspection used by the form editor.
|
||||
*/
|
||||
QDesignerIntrospectionInterface *QDesignerFormEditorInterface::introspection() const
|
||||
{
|
||||
return d->m_introspection;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 4.4
|
||||
|
||||
Sets the introspection used by the form editor to the specified \a introspection.
|
||||
*/
|
||||
void QDesignerFormEditorInterface::setIntrospection(QDesignerIntrospectionInterface *introspection)
|
||||
{
|
||||
if (d->m_introspection)
|
||||
delete d->m_introspection;
|
||||
d->m_introspection = introspection;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Returns the path to the resources used by the form editor.
|
||||
*/
|
||||
QString QDesignerFormEditorInterface::resourceLocation() const
|
||||
{
|
||||
#ifdef Q_WS_MAC
|
||||
return QLatin1String(":/trolltech/formeditor/images/mac");
|
||||
#else
|
||||
return QLatin1String(":/trolltech/formeditor/images/win");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Returns the dialog GUI used by the form editor.
|
||||
*/
|
||||
|
||||
QDesignerDialogGuiInterface *QDesignerFormEditorInterface::dialogGui() const
|
||||
{
|
||||
return d->m_dialogGui;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Sets the dialog GUI used by the form editor to the specified \a dialogGui.
|
||||
*/
|
||||
|
||||
void QDesignerFormEditorInterface::setDialogGui(QDesignerDialogGuiInterface *dialogGui)
|
||||
{
|
||||
delete d->m_dialogGui;
|
||||
d->m_dialogGui = dialogGui;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
159
third/designer/lib/sdk/abstractformeditor.h
Normal file
159
third/designer/lib/sdk/abstractformeditor.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTFORMEDITOR_H
|
||||
#define ABSTRACTFORMEDITOR_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QPointer>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerWidgetBoxInterface;
|
||||
class QDesignerPropertyEditorInterface;
|
||||
class QDesignerFormWindowManagerInterface;
|
||||
class QDesignerWidgetDataBaseInterface;
|
||||
class QDesignerMetaDataBaseInterface;
|
||||
class QDesignerWidgetFactoryInterface;
|
||||
class QDesignerObjectInspectorInterface;
|
||||
class QDesignerPromotionInterface;
|
||||
class QDesignerBrushManagerInterface;
|
||||
class QDesignerIconCacheInterface;
|
||||
class QDesignerActionEditorInterface;
|
||||
class QDesignerIntegrationInterface;
|
||||
class QDesignerPluginManager;
|
||||
class QDesignerIntrospectionInterface;
|
||||
class QDesignerDialogGuiInterface;
|
||||
class QDesignerSettingsInterface;
|
||||
class QDesignerOptionsPageInterface;
|
||||
class QtResourceModel;
|
||||
class QtGradientManager;
|
||||
|
||||
class QWidget;
|
||||
|
||||
class QExtensionManager;
|
||||
|
||||
class QDesignerFormEditorInterfacePrivate;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerFormEditorInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerFormEditorInterface(QObject *parent = 0);
|
||||
virtual ~QDesignerFormEditorInterface();
|
||||
|
||||
QExtensionManager *extensionManager() const;
|
||||
|
||||
QWidget *topLevel() const;
|
||||
QDesignerWidgetBoxInterface *widgetBox() const;
|
||||
QDesignerPropertyEditorInterface *propertyEditor() const;
|
||||
QDesignerObjectInspectorInterface *objectInspector() const;
|
||||
QDesignerFormWindowManagerInterface *formWindowManager() const;
|
||||
QDesignerWidgetDataBaseInterface *widgetDataBase() const;
|
||||
QDesignerMetaDataBaseInterface *metaDataBase() const;
|
||||
QDesignerPromotionInterface *promotion() const;
|
||||
QDesignerWidgetFactoryInterface *widgetFactory() const;
|
||||
QDesignerBrushManagerInterface *brushManager() const;
|
||||
QDesignerIconCacheInterface *iconCache() const;
|
||||
QDesignerActionEditorInterface *actionEditor() const;
|
||||
QDesignerIntegrationInterface *integration() const;
|
||||
QDesignerPluginManager *pluginManager() const;
|
||||
QDesignerIntrospectionInterface *introspection() const;
|
||||
QDesignerDialogGuiInterface *dialogGui() const;
|
||||
QDesignerSettingsInterface *settingsManager() const;
|
||||
QString resourceLocation() const;
|
||||
QtResourceModel *resourceModel() const;
|
||||
QtGradientManager *gradientManager() const;
|
||||
QList<QDesignerOptionsPageInterface*> optionsPages() const;
|
||||
|
||||
void setTopLevel(QWidget *topLevel);
|
||||
void setWidgetBox(QDesignerWidgetBoxInterface *widgetBox);
|
||||
void setPropertyEditor(QDesignerPropertyEditorInterface *propertyEditor);
|
||||
void setObjectInspector(QDesignerObjectInspectorInterface *objectInspector);
|
||||
void setPluginManager(QDesignerPluginManager *pluginManager);
|
||||
void setActionEditor(QDesignerActionEditorInterface *actionEditor);
|
||||
void setIntegration(QDesignerIntegrationInterface *integration);
|
||||
void setIntrospection(QDesignerIntrospectionInterface *introspection);
|
||||
void setDialogGui(QDesignerDialogGuiInterface *dialogGui);
|
||||
void setSettingsManager(QDesignerSettingsInterface *settingsManager);
|
||||
void setResourceModel(QtResourceModel *model);
|
||||
void setGradientManager(QtGradientManager *manager);
|
||||
void setOptionsPages(const QList<QDesignerOptionsPageInterface*> &optionsPages);
|
||||
|
||||
protected:
|
||||
void setFormManager(QDesignerFormWindowManagerInterface *formWindowManager);
|
||||
void setMetaDataBase(QDesignerMetaDataBaseInterface *metaDataBase);
|
||||
void setWidgetDataBase(QDesignerWidgetDataBaseInterface *widgetDataBase);
|
||||
void setPromotion(QDesignerPromotionInterface *promotion);
|
||||
void setWidgetFactory(QDesignerWidgetFactoryInterface *widgetFactory);
|
||||
void setExtensionManager(QExtensionManager *extensionManager);
|
||||
void setBrushManager(QDesignerBrushManagerInterface *brushManager);
|
||||
void setIconCache(QDesignerIconCacheInterface *cache);
|
||||
|
||||
private:
|
||||
QPointer<QWidget> m_pad1;
|
||||
QPointer<QDesignerWidgetBoxInterface> m_pad2;
|
||||
QPointer<QDesignerPropertyEditorInterface> m_pad3;
|
||||
QPointer<QDesignerFormWindowManagerInterface> m_pad4;
|
||||
QPointer<QExtensionManager> m_pad5;
|
||||
QPointer<QDesignerMetaDataBaseInterface> m_pad6;
|
||||
QPointer<QDesignerWidgetDataBaseInterface> m_pad7;
|
||||
QPointer<QDesignerWidgetFactoryInterface> m_pad8;
|
||||
QPointer<QDesignerObjectInspectorInterface> m_pad9;
|
||||
QPointer<QDesignerBrushManagerInterface> m_pad10;
|
||||
QPointer<QDesignerIconCacheInterface> m_pad11;
|
||||
QPointer<QDesignerActionEditorInterface> m_pad12;
|
||||
QDesignerFormEditorInterfacePrivate *d;
|
||||
|
||||
private:
|
||||
QDesignerFormEditorInterface(const QDesignerFormEditorInterface &other);
|
||||
void operator = (const QDesignerFormEditorInterface &other);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTFORMEDITOR_H
|
||||
86
third/designer/lib/sdk/abstractformeditorplugin.cpp
Normal file
86
third/designer/lib/sdk/abstractformeditorplugin.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <QtDesigner/abstractformeditorplugin.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\class QDesignerFormEditorPluginInterface
|
||||
\brief The QDesignerFormEditorPluginInterface class provides an interface that is used to
|
||||
manage plugins for Qt Designer's form editor component.
|
||||
\inmodule QtDesigner
|
||||
|
||||
\sa QDesignerFormEditorInterface
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerFormEditorPluginInterface::~QDesignerFormEditorPluginInterface()
|
||||
|
||||
Destroys the plugin interface.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerFormEditorPluginInterface::isInitialized() const = 0
|
||||
|
||||
Returns true if the plugin interface is initialized; otherwise returns false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormEditorPluginInterface::initialize(QDesignerFormEditorInterface *core) = 0
|
||||
|
||||
Initializes the plugin interface for the specified \a core interface.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QAction *QDesignerFormEditorPluginInterface::action() const = 0
|
||||
|
||||
Returns the action associated with this interface.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerFormEditorInterface *QDesignerFormEditorPluginInterface::core() const = 0
|
||||
|
||||
Returns the core form editor interface associated with this component.
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
73
third/designer/lib/sdk/abstractformeditorplugin.h
Normal file
73
third/designer/lib/sdk/abstractformeditorplugin.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTFORMEDITORPLUGIN_H
|
||||
#define ABSTRACTFORMEDITORPLUGIN_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
class QAction;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerFormEditorPluginInterface
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerFormEditorPluginInterface() {}
|
||||
|
||||
virtual bool isInitialized() const = 0;
|
||||
virtual void initialize(QDesignerFormEditorInterface *core) = 0;
|
||||
virtual QAction *action() const = 0;
|
||||
|
||||
virtual QDesignerFormEditorInterface *core() const = 0;
|
||||
};
|
||||
Q_DECLARE_INTERFACE(QDesignerFormEditorPluginInterface, "com.trolltech.Qt.Designer.QDesignerFormEditorPluginInterface")
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTFORMEDITORPLUGIN_H
|
||||
814
third/designer/lib/sdk/abstractformwindow.cpp
Normal file
814
third/designer/lib/sdk/abstractformwindow.cpp
Normal file
@@ -0,0 +1,814 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractformwindow.h"
|
||||
|
||||
#include <widgetfactory_p.h>
|
||||
|
||||
#include <QtGui/QTabBar>
|
||||
#include <QtGui/QSizeGrip>
|
||||
#include <QtGui/QAbstractButton>
|
||||
#include <QtGui/QToolBox>
|
||||
#include <QtGui/QMenuBar>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QDockWidget>
|
||||
#include <QtGui/QToolBar>
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerFormWindowInterface
|
||||
|
||||
\brief The QDesignerFormWindowInterface class allows you to query
|
||||
and manipulate form windows appearing in Qt Designer's workspace.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
QDesignerFormWindowInterface provides information about
|
||||
the associated form window as well as allowing its properties to be
|
||||
altered. The interface is not intended to be instantiated
|
||||
directly, but to provide access to \QD's current form windows
|
||||
controlled by \QD's \l {QDesignerFormWindowManagerInterface}{form
|
||||
window manager}.
|
||||
|
||||
If you are looking for the form window containing a specific
|
||||
widget, you can use the static
|
||||
QDesignerFormWindowInterface::findFormWindow() function:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindow.cpp 0
|
||||
|
||||
But in addition, you can access any of the current form windows
|
||||
through \QD's form window manager: Use the
|
||||
QDesignerFormEditorInterface::formWindowManager() function to
|
||||
retrieve an interface to the manager. Once you have this
|
||||
interface, you have access to all of \QD's current form windows
|
||||
through the QDesignerFormWindowManagerInterface::formWindow()
|
||||
function. For example:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindow.cpp 1
|
||||
|
||||
The pointer to \QD's current QDesignerFormEditorInterface object
|
||||
(\c formEditor in the example above) is provided by the
|
||||
QDesignerCustomWidgetInterface::initialize() function's
|
||||
parameter. When implementing a custom widget plugin, you must
|
||||
subclass the QDesignerCustomWidgetInterface class to expose your
|
||||
plugin to \QD.
|
||||
|
||||
Once you have the form window, you can query its properties. For
|
||||
example, a plain custom widget plugin is managed by \QD only at
|
||||
its top level, i.e. none of its child widgets can be resized in
|
||||
\QD's workspace. But QDesignerFormWindowInterface provides you
|
||||
with functions that enables you to control whether a widget should
|
||||
be managed by \QD, or not:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindow.cpp 2
|
||||
|
||||
The complete list of functions concerning widget management is:
|
||||
isManaged(), manageWidget() and unmanageWidget(). There is also
|
||||
several associated signals: widgetManaged(), widgetRemoved(),
|
||||
aboutToUnmanageWidget() and widgetUnmanaged().
|
||||
|
||||
In addition to controlling the management of widgets, you can
|
||||
control the current selection in the form window using the
|
||||
selectWidget(), clearSelection() and emitSelectionChanged()
|
||||
functions, and the selectionChanged() signal.
|
||||
|
||||
You can also retrieve information about where the form is stored
|
||||
using absoluteDir(), its include files using includeHints(), and
|
||||
its layout and pixmap functions using layoutDefault(),
|
||||
layoutFunction() and pixmapFunction(). You can find out whether
|
||||
the form window has been modified (but not saved) or not, using
|
||||
the isDirty() function. You can retrieve its author(), its
|
||||
contents(), its fileName(), associated comment() and
|
||||
exportMacro(), its mainContainer(), its features(), its grid() and
|
||||
its resourceFiles().
|
||||
|
||||
The interface provides you with functions and slots allowing you
|
||||
to alter most of this information as well. The exception is the
|
||||
directory storing the form window. Finally, there is several
|
||||
signals associated with changes to the information mentioned above
|
||||
and to the form window in general.
|
||||
|
||||
\sa QDesignerFormWindowCursorInterface,
|
||||
QDesignerFormEditorInterface, QDesignerFormWindowManagerInterface
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDesignerFormWindowInterface::FeatureFlag
|
||||
|
||||
This enum describes the features that are available and can be
|
||||
controlled by the form window interface. These values are used
|
||||
when querying the form window to determine which features it
|
||||
supports:
|
||||
|
||||
\value EditFeature Form editing
|
||||
\value GridFeature Grid display and snap-to-grid facilities for editing
|
||||
\value TabOrderFeature Tab order management
|
||||
\value DefaultFeature Support for default features (form editing and grid)
|
||||
|
||||
\sa hasFeature(), features()
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a form window interface with the given \a parent and
|
||||
the specified window \a flags.
|
||||
*/
|
||||
QDesignerFormWindowInterface::QDesignerFormWindowInterface(QWidget *parent, Qt::WindowFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the form window interface.
|
||||
*/
|
||||
QDesignerFormWindowInterface::~QDesignerFormWindowInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a pointer to \QD's current QDesignerFormEditorInterface
|
||||
object.
|
||||
*/
|
||||
QDesignerFormEditorInterface *QDesignerFormWindowInterface::core() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QDesignerFormWindowInterface *QDesignerFormWindowInterface::findFormWindow(QWidget *widget)
|
||||
|
||||
Returns the form window interface for the given \a widget.
|
||||
*/
|
||||
|
||||
static inline bool stopFindAtTopLevel(const QObject *w, bool stopAtMenu)
|
||||
{
|
||||
// Do we need to go beyond top levels when looking for the form window?
|
||||
// 1) A dialog has a window attribute at the moment it is created
|
||||
// before it is properly embedded into a form window. The property
|
||||
// sheet queries the layout attributes precisely at this moment.
|
||||
// 2) In the case of floating docks and toolbars, we also need to go beyond the top level window.
|
||||
// 3) In the case of menu editing, we don't want to block events from the
|
||||
// Designer menu, so, we say stop.
|
||||
// Note that there must be no false positives for dialogs parented on
|
||||
// the form (for example, the "change object name" dialog), else, its
|
||||
// events will be blocked.
|
||||
|
||||
if (stopAtMenu && w->inherits("QDesignerMenu"))
|
||||
return true;
|
||||
return !qdesigner_internal::WidgetFactory::isFormEditorObject(w);
|
||||
}
|
||||
|
||||
QDesignerFormWindowInterface *QDesignerFormWindowInterface::findFormWindow(QWidget *w)
|
||||
{
|
||||
while (w != 0) {
|
||||
if (QDesignerFormWindowInterface *fw = qobject_cast<QDesignerFormWindowInterface*>(w)) {
|
||||
return fw;
|
||||
} else {
|
||||
if (w->isWindow() && stopFindAtTopLevel(w, true))
|
||||
break;
|
||||
}
|
||||
|
||||
w = w->parentWidget();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QDesignerFormWindowInterface *QDesignerFormWindowInterface::findFormWindow(QObject *object)
|
||||
|
||||
Returns the form window interface for the given \a object.
|
||||
|
||||
\since 4.4
|
||||
*/
|
||||
|
||||
QDesignerFormWindowInterface *QDesignerFormWindowInterface::findFormWindow(QObject *object)
|
||||
{
|
||||
while (object != 0) {
|
||||
if (QDesignerFormWindowInterface *fw = qobject_cast<QDesignerFormWindowInterface*>(object)) {
|
||||
return fw;
|
||||
} else {
|
||||
QWidget *w = qobject_cast<QWidget *>(object);
|
||||
// QDesignerMenu is a window, so stopFindAtTopLevel(w) returns 0.
|
||||
// However, we want to find the form window for QActions of a menu.
|
||||
// If this check is inside stopFindAtTopLevel(w), it will break designer
|
||||
// menu editing (e.g. when clicking on items inside an opened menu)
|
||||
if (w && w->isWindow() && stopFindAtTopLevel(w, false))
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
object = object->parent();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerFormWindowInterface::fileName() const
|
||||
|
||||
Returns the file name of the UI file that describes the form
|
||||
currently being shown.
|
||||
|
||||
\sa setFileName()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QDir QDesignerFormWindowInterface::absoluteDir() const
|
||||
|
||||
Returns the absolute location of the directory containing the form
|
||||
shown in the form window.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerFormWindowInterface::contents() const
|
||||
|
||||
Returns details of the contents of the form currently being
|
||||
displayed in the window.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setContents(QIODevice *device)
|
||||
|
||||
Sets the form's contents using data obtained from the given \a device.
|
||||
|
||||
Data can be read from QFile objects or any other subclass of QIODevice.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual Feature QDesignerFormWindowInterface::features() const
|
||||
|
||||
Returns a combination of the features provided by the form window
|
||||
associated with the interface. The value returned can be tested
|
||||
against the \l Feature enum values to determine which features are
|
||||
supported by the window.
|
||||
|
||||
\sa setFeatures(), hasFeature()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerFormWindowInterface::hasFeature(Feature feature) const
|
||||
|
||||
Returns true if the form window offers the specified \a feature;
|
||||
otherwise returns false.
|
||||
|
||||
\sa features()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerFormWindowInterface::author() const
|
||||
|
||||
Returns details of the author or creator of the form currently
|
||||
being displayed in the window.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setAuthor(const QString &author)
|
||||
|
||||
Sets the details for the author or creator of the form to the \a
|
||||
author specified.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerFormWindowInterface::comment() const
|
||||
|
||||
Returns comments about the form currently being displayed in the window.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setComment(const QString &comment)
|
||||
|
||||
Sets the information about the form to the \a comment
|
||||
specified. This information should be a human-readable comment
|
||||
about the form.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::layoutDefault(int *margin, int *spacing)
|
||||
|
||||
Fills in the default margin and spacing for the form's default
|
||||
layout in the \a margin and \a spacing variables specified.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setLayoutDefault(int margin, int spacing)
|
||||
|
||||
Sets the default \a margin and \a spacing for the form's layout.
|
||||
|
||||
\sa layoutDefault()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::layoutFunction(QString *margin, QString *spacing)
|
||||
|
||||
Fills in the current margin and spacing for the form's layout in
|
||||
the \a margin and \a spacing variables specified.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setLayoutFunction(const QString &margin, const QString &spacing)
|
||||
|
||||
Sets the \a margin and \a spacing for the form's layout.
|
||||
|
||||
The default layout properties will be replaced by the
|
||||
corresponding layout functions when \c uic generates code for the
|
||||
form, that is, if the functions are specified. This is useful when
|
||||
different environments requires different layouts for the same
|
||||
form.
|
||||
|
||||
\sa layoutFunction()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerFormWindowInterface::pixmapFunction() const
|
||||
|
||||
Returns the name of the function used to load pixmaps into the
|
||||
form window.
|
||||
|
||||
\sa setPixmapFunction()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setPixmapFunction(const QString &pixmapFunction)
|
||||
|
||||
Sets the function used to load pixmaps into the form window
|
||||
to the given \a pixmapFunction.
|
||||
|
||||
\sa pixmapFunction()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerFormWindowInterface::exportMacro() const
|
||||
|
||||
Returns the export macro associated with the form currently being
|
||||
displayed in the window. The export macro is used when the form
|
||||
is compiled to create a widget plugin.
|
||||
|
||||
\sa {Creating Custom Widgets for Qt Designer}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setExportMacro(const QString &exportMacro)
|
||||
|
||||
Sets the form window's export macro to \a exportMacro. The export
|
||||
macro is used when building a widget plugin to export the form's
|
||||
interface to other components.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QStringList QDesignerFormWindowInterface::includeHints() const
|
||||
|
||||
Returns a list of the header files that will be included in the
|
||||
form window's associated UI file.
|
||||
|
||||
Header files may be local, i.e. relative to the project's
|
||||
directory, \c "mywidget.h", or global, i.e. part of Qt or the
|
||||
compilers standard libraries: \c <QtGui/QWidget>.
|
||||
|
||||
\sa setIncludeHints()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setIncludeHints(const QStringList &includeHints)
|
||||
|
||||
Sets the header files that will be included in the form window's
|
||||
associated UI file to the specified \a includeHints.
|
||||
|
||||
Header files may be local, i.e. relative to the project's
|
||||
directory, \c "mywidget.h", or global, i.e. part of Qt or the
|
||||
compilers standard libraries: \c <QtGui/QWidget>.
|
||||
|
||||
\sa includeHints()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerFormWindowCursorInterface *QDesignerFormWindowInterface::cursor() const
|
||||
|
||||
Returns the cursor interface used by the form window.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual int QDesignerFormWindowInterface::toolCount() const
|
||||
|
||||
Returns the number of tools available.
|
||||
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual int QDesignerFormWindowInterface::currentTool() const
|
||||
|
||||
Returns the index of the current tool in use.
|
||||
|
||||
\sa setCurrentTool()
|
||||
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setCurrentTool(int index)
|
||||
|
||||
Sets the current tool to be the one with the given \a index.
|
||||
|
||||
\sa currentTool()
|
||||
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerFormWindowToolInterface *QDesignerFormWindowInterface::tool(int index) const
|
||||
|
||||
Returns an interface to the tool with the given \a index.
|
||||
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::registerTool(QDesignerFormWindowToolInterface *tool)
|
||||
|
||||
Registers the given \a tool with the form window.
|
||||
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QPoint QDesignerFormWindowInterface::grid() const = 0
|
||||
|
||||
Returns the grid spacing used by the form window.
|
||||
|
||||
\sa setGrid()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QWidget *QDesignerFormWindowInterface::mainContainer() const
|
||||
|
||||
Returns the main container widget for the form window.
|
||||
|
||||
\sa setMainContainer()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setMainContainer(QWidget *mainContainer)
|
||||
|
||||
Sets the main container widget on the form to the specified \a
|
||||
mainContainer.
|
||||
|
||||
\sa mainContainer(), mainContainerChanged()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerFormWindowInterface::isManaged(QWidget *widget) const
|
||||
|
||||
Returns true if the specified \a widget is managed by the form
|
||||
window; otherwise returns false.
|
||||
|
||||
\sa manageWidget()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerFormWindowInterface::isDirty() const
|
||||
|
||||
Returns true if the form window is "dirty" (modified but not
|
||||
saved); otherwise returns false.
|
||||
|
||||
\sa setDirty()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QUndoStack *QDesignerFormWindowInterface::commandHistory() const
|
||||
|
||||
Returns an object that can be used to obtain the commands used so
|
||||
far in the construction of the form.
|
||||
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::beginCommand(const QString &description)
|
||||
|
||||
Begins execution of a command with the given \a
|
||||
description. Commands are executed between beginCommand() and
|
||||
endCommand() function calls to ensure that they are recorded on
|
||||
the undo stack.
|
||||
|
||||
\sa endCommand()
|
||||
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::endCommand()
|
||||
|
||||
Ends execution of the current command.
|
||||
|
||||
\sa beginCommand()
|
||||
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::simplifySelection(QList<QWidget*> *widgets) const
|
||||
|
||||
Simplifies the selection of widgets specified by \a widgets.
|
||||
|
||||
\sa selectionChanged()
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::emitSelectionChanged()
|
||||
|
||||
Emits the selectionChanged() signal.
|
||||
|
||||
\sa selectWidget(), clearSelection()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QStringList QDesignerFormWindowInterface::resourceFiles() const
|
||||
|
||||
Returns a list of paths to resource files that are currently being
|
||||
used by the form window.
|
||||
|
||||
\sa addResourceFile(), removeResourceFile()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::addResourceFile(const QString &path)
|
||||
|
||||
Adds the resource file at the given \a path to those used by the form.
|
||||
|
||||
\sa resourceFiles(), resourceFilesChanged()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::removeResourceFile(const QString &path)
|
||||
|
||||
Removes the resource file at the specified \a path from the list
|
||||
of those used by the form.
|
||||
|
||||
\sa resourceFiles(), resourceFilesChanged()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::ensureUniqueObjectName(QObject *object)
|
||||
|
||||
Ensures that the specified \a object has a unique name amongst the
|
||||
other objects on the form.
|
||||
|
||||
\internal
|
||||
*/
|
||||
|
||||
// Slots
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::manageWidget(QWidget *widget)
|
||||
|
||||
Instructs the form window to manage the specified \a widget.
|
||||
|
||||
\sa isManaged(), unmanageWidget(), widgetManaged()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::unmanageWidget(QWidget *widget)
|
||||
|
||||
Instructs the form window not to manage the specified \a widget.
|
||||
|
||||
\sa aboutToUnmanageWidget(), widgetUnmanaged()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setFeatures(Feature features)
|
||||
|
||||
Enables the specified \a features for the form window.
|
||||
|
||||
\sa features(), featureChanged()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setDirty(bool dirty)
|
||||
|
||||
If \a dirty is true, the form window is marked as dirty, meaning
|
||||
that it is modified but not saved. If \a dirty is false, the form
|
||||
window is considered to be unmodified.
|
||||
|
||||
\sa isDirty()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::clearSelection(bool update)
|
||||
|
||||
Clears the current selection in the form window. If \a update is
|
||||
true, the emitSelectionChanged() function is called, emitting the
|
||||
selectionChanged() signal.
|
||||
|
||||
\sa selectWidget()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::selectWidget(QWidget *widget, bool select)
|
||||
|
||||
If \a select is true, the given \a widget is selected; otherwise
|
||||
the \a widget is deselected.
|
||||
|
||||
\sa clearSelection(), selectionChanged()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setGrid(const QPoint &grid)
|
||||
|
||||
Sets the grid size for the form window to the point specified by
|
||||
\a grid. In this function, the coordinates in the QPoint are used
|
||||
to specify the dimensions of a rectangle in the grid.
|
||||
|
||||
\sa grid()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setFileName(const QString &fileName)
|
||||
|
||||
Sets the file name for the form to the given \a fileName.
|
||||
|
||||
\sa fileName(), fileNameChanged()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::setContents(const QString &contents)
|
||||
|
||||
Sets the contents of the form using data read from the specified
|
||||
\a contents string.
|
||||
|
||||
\sa contents()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowInterface::editWidgets()
|
||||
|
||||
Switches the form window into editing mode.
|
||||
|
||||
\sa \l {Qt Designer's Form Editing Mode}
|
||||
|
||||
\internal
|
||||
*/
|
||||
|
||||
// Signals
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::mainContainerChanged(QWidget *mainContainer)
|
||||
|
||||
This signal is emitted whenever the main container changes.
|
||||
The new container is specified by \a mainContainer.
|
||||
|
||||
\sa setMainContainer()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::toolChanged(int toolIndex)
|
||||
|
||||
This signal is emitted whenever the current tool changes.
|
||||
The specified \a toolIndex is the index of the new tool in the list of
|
||||
tools in the widget box.
|
||||
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::fileNameChanged(const QString &fileName)
|
||||
|
||||
This signal is emitted whenever the file name of the form changes.
|
||||
The new file name is specified by \a fileName.
|
||||
|
||||
\sa setFileName()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::featureChanged(Feature feature)
|
||||
|
||||
This signal is emitted whenever a feature changes in the form.
|
||||
The new feature is specified by \a feature.
|
||||
|
||||
\sa setFeatures()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::selectionChanged()
|
||||
|
||||
This signal is emitted whenever the selection in the form changes.
|
||||
|
||||
\sa selectWidget(), clearSelection()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::geometryChanged()
|
||||
|
||||
This signal is emitted whenever the form's geometry changes.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::resourceFilesChanged()
|
||||
|
||||
This signal is emitted whenever the list of resource files used by the
|
||||
form changes.
|
||||
|
||||
\sa resourceFiles()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::widgetManaged(QWidget *widget)
|
||||
|
||||
This signal is emitted whenever a widget on the form becomes managed.
|
||||
The newly managed widget is specified by \a widget.
|
||||
|
||||
\sa manageWidget()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::widgetUnmanaged(QWidget *widget)
|
||||
|
||||
This signal is emitted whenever a widget on the form becomes unmanaged.
|
||||
The newly released widget is specified by \a widget.
|
||||
|
||||
\sa unmanageWidget(), aboutToUnmanageWidget()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::aboutToUnmanageWidget(QWidget *widget)
|
||||
|
||||
This signal is emitted whenever a widget on the form is about to
|
||||
become unmanaged. When this signal is emitted, the specified \a
|
||||
widget is still managed, and a widgetUnmanaged() signal will
|
||||
follow, indicating when it is no longer managed.
|
||||
|
||||
\sa unmanageWidget(), isManaged()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::activated(QWidget *widget)
|
||||
|
||||
This signal is emitted whenever a widget is activated on the form.
|
||||
The activated widget is specified by \a widget.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::changed()
|
||||
|
||||
This signal is emitted whenever a form is changed.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::widgetRemoved(QWidget *widget)
|
||||
|
||||
This signal is emitted whenever a widget is removed from the form.
|
||||
The widget that was removed is specified by \a widget.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowInterface::objectRemoved(QObject *object)
|
||||
|
||||
This signal is emitted whenever an object (such as
|
||||
an action or a QButtonGroup) is removed from the form.
|
||||
The object that was removed is specified by \a object.
|
||||
|
||||
\since 4.5
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
183
third/designer/lib/sdk/abstractformwindow.h
Normal file
183
third/designer/lib/sdk/abstractformwindow.h
Normal file
@@ -0,0 +1,183 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTFORMWINDOW_H
|
||||
#define ABSTRACTFORMWINDOW_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
class QDesignerFormWindowCursorInterface;
|
||||
class QDesignerFormWindowToolInterface;
|
||||
class DomUI;
|
||||
class QUndoStack;
|
||||
class QDir;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerFormWindowInterface: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum FeatureFlag
|
||||
{
|
||||
EditFeature = 0x01,
|
||||
GridFeature = 0x02,
|
||||
TabOrderFeature = 0x04,
|
||||
DefaultFeature = EditFeature | GridFeature
|
||||
};
|
||||
Q_DECLARE_FLAGS(Feature, FeatureFlag)
|
||||
|
||||
public:
|
||||
QDesignerFormWindowInterface(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
virtual ~QDesignerFormWindowInterface();
|
||||
|
||||
virtual QString fileName() const = 0;
|
||||
virtual QDir absoluteDir() const = 0;
|
||||
|
||||
virtual QString contents() const = 0;
|
||||
virtual void setContents(QIODevice *dev) = 0;
|
||||
|
||||
virtual Feature features() const = 0;
|
||||
virtual bool hasFeature(Feature f) const = 0;
|
||||
|
||||
virtual QString author() const = 0;
|
||||
virtual void setAuthor(const QString &author) = 0;
|
||||
|
||||
virtual QString comment() const = 0;
|
||||
virtual void setComment(const QString &comment) = 0;
|
||||
|
||||
virtual void layoutDefault(int *margin, int *spacing) = 0;
|
||||
virtual void setLayoutDefault(int margin, int spacing) = 0;
|
||||
|
||||
virtual void layoutFunction(QString *margin, QString *spacing) = 0;
|
||||
virtual void setLayoutFunction(const QString &margin, const QString &spacing) = 0;
|
||||
|
||||
virtual QString pixmapFunction() const = 0;
|
||||
virtual void setPixmapFunction(const QString &pixmapFunction) = 0;
|
||||
|
||||
virtual QString exportMacro() const = 0;
|
||||
virtual void setExportMacro(const QString &exportMacro) = 0;
|
||||
|
||||
virtual QStringList includeHints() const = 0;
|
||||
virtual void setIncludeHints(const QStringList &includeHints) = 0;
|
||||
|
||||
virtual QDesignerFormEditorInterface *core() const;
|
||||
virtual QDesignerFormWindowCursorInterface *cursor() const = 0;
|
||||
|
||||
virtual int toolCount() const = 0;
|
||||
|
||||
virtual int currentTool() const = 0;
|
||||
virtual void setCurrentTool(int index) = 0;
|
||||
|
||||
virtual QDesignerFormWindowToolInterface *tool(int index) const = 0;
|
||||
virtual void registerTool(QDesignerFormWindowToolInterface *tool) = 0;
|
||||
|
||||
virtual QPoint grid() const = 0;
|
||||
|
||||
virtual QWidget *mainContainer() const = 0;
|
||||
virtual void setMainContainer(QWidget *mainContainer) = 0;
|
||||
|
||||
virtual bool isManaged(QWidget *widget) const = 0;
|
||||
|
||||
virtual bool isDirty() const = 0;
|
||||
|
||||
static QDesignerFormWindowInterface *findFormWindow(QWidget *w);
|
||||
static QDesignerFormWindowInterface *findFormWindow(QObject *obj);
|
||||
|
||||
virtual QUndoStack *commandHistory() const = 0;
|
||||
virtual void beginCommand(const QString &description) = 0;
|
||||
virtual void endCommand() = 0;
|
||||
|
||||
virtual void simplifySelection(QList<QWidget*> *widgets) const = 0;
|
||||
|
||||
// notifications
|
||||
virtual void emitSelectionChanged() = 0;
|
||||
|
||||
virtual QStringList resourceFiles() const = 0;
|
||||
virtual void addResourceFile(const QString &path) = 0;
|
||||
virtual void removeResourceFile(const QString &path) = 0;
|
||||
|
||||
virtual void ensureUniqueObjectName(QObject *object) = 0;
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void manageWidget(QWidget *widget) = 0;
|
||||
virtual void unmanageWidget(QWidget *widget) = 0;
|
||||
|
||||
virtual void setFeatures(Feature f) = 0;
|
||||
virtual void setDirty(bool dirty) = 0;
|
||||
virtual void clearSelection(bool changePropertyDisplay = true) = 0;
|
||||
virtual void selectWidget(QWidget *w, bool select = true) = 0;
|
||||
virtual void setGrid(const QPoint &grid) = 0;
|
||||
virtual void setFileName(const QString &fileName) = 0;
|
||||
virtual void setContents(const QString &contents) = 0;
|
||||
|
||||
virtual void editWidgets() = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void mainContainerChanged(QWidget *mainContainer);
|
||||
void toolChanged(int toolIndex);
|
||||
void fileNameChanged(const QString &fileName);
|
||||
void featureChanged(Feature f);
|
||||
void selectionChanged();
|
||||
void geometryChanged();
|
||||
|
||||
void resourceFilesChanged();
|
||||
|
||||
void widgetManaged(QWidget *widget);
|
||||
void widgetUnmanaged(QWidget *widget);
|
||||
void aboutToUnmanageWidget(QWidget *widget);
|
||||
void activated(QWidget *widget);
|
||||
|
||||
void changed();
|
||||
void widgetRemoved(QWidget *w);
|
||||
void objectRemoved(QObject *o);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTFORMWINDOW_H
|
||||
252
third/designer/lib/sdk/abstractformwindowcursor.cpp
Normal file
252
third/designer/lib/sdk/abstractformwindowcursor.cpp
Normal file
@@ -0,0 +1,252 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractformwindowcursor.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerFormWindowCursorInterface
|
||||
|
||||
\brief The QDesignerFormWindowCursorInterface class allows you to
|
||||
query and modify a form window's widget selection, and in addition
|
||||
modify the properties of all the form's widgets.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
QDesignerFormWindowCursorInterface is a convenience class that
|
||||
provides an interface to the associated form window's text cursor;
|
||||
it provides a collection of functions that enables you to query a
|
||||
given form window's selection and change the selection's focus
|
||||
according to defined modes (MoveMode) and movements
|
||||
(MoveOperation). You can also use the interface to query the
|
||||
form's widgets and change their properties.
|
||||
|
||||
The interface is not intended to be instantiated directly, but to
|
||||
provide access to the selections and widgets of \QD's current form
|
||||
windows. QDesignerFormWindowInterface always provides an
|
||||
associated cursor interface. The form window for a given widget
|
||||
can be retrieved using the static
|
||||
QDesignerFormWindowInterface::findFormWindow() functions. For
|
||||
example:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowcursor.cpp 0
|
||||
|
||||
You can retrieve any of \QD's current form windows through
|
||||
\QD's \l {QDesignerFormWindowManagerInterface}{form window
|
||||
manager}.
|
||||
|
||||
Once you have a form window's cursor interface, you can check if
|
||||
the form window has a selection at all using the hasSelection()
|
||||
function. You can query the form window for its total
|
||||
widgetCount() and selectedWidgetCount(). You can retrieve the
|
||||
currently selected widget (or widgets) using the current() or
|
||||
selectedWidget() functions.
|
||||
|
||||
You can retrieve any of the form window's widgets using the
|
||||
widget() function, and check if a widget is selected using the
|
||||
isWidgetSelected() function. You can use the setProperty()
|
||||
function to set the selected widget's properties, and the
|
||||
setWidgetProperty() or resetWidgetProperty() functions to modify
|
||||
the properties of any given widget.
|
||||
|
||||
Finally, you can change the selection by changing the text
|
||||
cursor's position() using the setPosition() and movePosition()
|
||||
functions.
|
||||
|
||||
\sa QDesignerFormWindowInterface, QDesignerFormWindowManagerInterface
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDesignerFormWindowCursorInterface::MoveOperation
|
||||
|
||||
This enum describes the types of text cursor operation that can occur in a form window.
|
||||
|
||||
\value NoMove The cursor does not move.
|
||||
\value Start Moves the cursor to the start of the focus chain.
|
||||
\value End Moves the cursor to the end of the focus chain.
|
||||
\value Next Moves the cursor to the next widget in the focus chain.
|
||||
\value Prev Moves the cursor to the previous widget in the focus chain.
|
||||
\value Left The cursor moves to the left.
|
||||
\value Right The cursor moves to the right.
|
||||
\value Up The cursor moves upwards.
|
||||
\value Down The cursor moves downwards.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDesignerFormWindowCursorInterface::MoveMode
|
||||
|
||||
This enum describes the different modes that are used when the text cursor moves.
|
||||
|
||||
\value MoveAnchor The anchor moves with the cursor to its new location.
|
||||
\value KeepAnchor The anchor remains at the cursor's old location.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns true if the specified \a widget is selected; otherwise
|
||||
returns false.
|
||||
*/
|
||||
bool QDesignerFormWindowCursorInterface::isWidgetSelected(QWidget *widget) const
|
||||
{
|
||||
for (int index=0; index<selectedWidgetCount(); ++index) {
|
||||
if (selectedWidget(index) == widget)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerFormWindowCursorInterface::~QDesignerFormWindowCursorInterface()
|
||||
|
||||
Destroys the cursor interface.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerFormWindowInterface *QDesignerFormWindowCursorInterface::formWindow() const
|
||||
|
||||
Returns the form window interface associated with this cursor interface.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerFormWindowCursorInterface::movePosition(MoveOperation operation, MoveMode mode)
|
||||
|
||||
Performs the given \a operation on the cursor using the specified
|
||||
\a mode, and returns true if it completed successfully; otherwise
|
||||
returns false.
|
||||
|
||||
\sa position(), setPosition()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual int QDesignerFormWindowCursorInterface::position() const
|
||||
|
||||
Returns the cursor position.
|
||||
|
||||
\sa setPosition(), movePosition()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowCursorInterface::setPosition(int position, MoveMode mode = MoveAnchor)
|
||||
|
||||
Sets the position of the cursor to the given \a position using the
|
||||
\a mode to specify how it is moved there.
|
||||
|
||||
\sa position(), movePosition()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QWidget *QDesignerFormWindowCursorInterface::current() const
|
||||
|
||||
Returns the currently selected widget in the form window.
|
||||
|
||||
\sa selectedWidget()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual int QDesignerFormWindowCursorInterface::widgetCount() const
|
||||
|
||||
Returns the number of widgets in the form window.
|
||||
|
||||
\sa selectedWidgetCount()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QWidget *QDesignerFormWindowCursorInterface::widget(int index) const
|
||||
|
||||
Returns the widget with the given \a index in the list of widgets
|
||||
in the form window.
|
||||
|
||||
\sa selectedWidget()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerFormWindowCursorInterface::hasSelection() const
|
||||
|
||||
Returns true if the form window contains a selection; otherwise
|
||||
returns false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual int QDesignerFormWindowCursorInterface::selectedWidgetCount() const
|
||||
|
||||
Returns the number of selected widgets in the form window.
|
||||
|
||||
\sa widgetCount()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QWidget *QDesignerFormWindowCursorInterface::selectedWidget(int index) const
|
||||
|
||||
Returns the widget with the given \a index in the list of selected
|
||||
widgets.
|
||||
|
||||
\sa current(), widget()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowCursorInterface::setProperty(const QString &name, const QVariant &value)
|
||||
|
||||
Sets the property with the given \a name for the currently
|
||||
selected widget to the specified \a value.
|
||||
|
||||
\sa setWidgetProperty(), resetWidgetProperty()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowCursorInterface::setWidgetProperty(QWidget *widget, const QString &name, const QVariant &value)
|
||||
|
||||
Sets the property with the given \a name for the given \a widget
|
||||
to the specified \a value.
|
||||
|
||||
\sa resetWidgetProperty(), setProperty()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowCursorInterface::resetWidgetProperty(QWidget *widget, const QString &name)
|
||||
|
||||
Resets the property with the given \a name for the specified \a
|
||||
widget to its default value.
|
||||
|
||||
\sa setProperty(), setWidgetProperty()
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
109
third/designer/lib/sdk/abstractformwindowcursor.h
Normal file
109
third/designer/lib/sdk/abstractformwindowcursor.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTFORMWINDOWCURSOR_H
|
||||
#define ABSTRACTFORMWINDOWCURSOR_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormWindowInterface;
|
||||
class QWidget;
|
||||
class QVariant;
|
||||
class QString;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerFormWindowCursorInterface
|
||||
{
|
||||
public:
|
||||
enum MoveOperation
|
||||
{
|
||||
NoMove,
|
||||
|
||||
Start,
|
||||
End,
|
||||
Next,
|
||||
Prev,
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
Down
|
||||
};
|
||||
|
||||
enum MoveMode
|
||||
{
|
||||
MoveAnchor,
|
||||
KeepAnchor
|
||||
};
|
||||
|
||||
public:
|
||||
virtual ~QDesignerFormWindowCursorInterface() {}
|
||||
|
||||
virtual QDesignerFormWindowInterface *formWindow() const = 0;
|
||||
|
||||
virtual bool movePosition(MoveOperation op, MoveMode mode = MoveAnchor) = 0;
|
||||
|
||||
virtual int position() const = 0;
|
||||
virtual void setPosition(int pos, MoveMode mode = MoveAnchor) = 0;
|
||||
|
||||
virtual QWidget *current() const = 0;
|
||||
|
||||
virtual int widgetCount() const = 0;
|
||||
virtual QWidget *widget(int index) const = 0;
|
||||
|
||||
virtual bool hasSelection() const = 0;
|
||||
virtual int selectedWidgetCount() const = 0;
|
||||
virtual QWidget *selectedWidget(int index) const = 0;
|
||||
|
||||
virtual void setProperty(const QString &name, const QVariant &value) = 0;
|
||||
virtual void setWidgetProperty(QWidget *widget, const QString &name, const QVariant &value) = 0;
|
||||
virtual void resetWidgetProperty(QWidget *widget, const QString &name) = 0;
|
||||
|
||||
bool isWidgetSelected(QWidget *widget) const;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTFORMWINDOWCURSOR_H
|
||||
502
third/designer/lib/sdk/abstractformwindowmanager.cpp
Normal file
502
third/designer/lib/sdk/abstractformwindowmanager.cpp
Normal file
@@ -0,0 +1,502 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractformwindowmanager.h"
|
||||
|
||||
#include <QtCore/QMap>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerFormWindowManagerInterface
|
||||
|
||||
\brief The QDesignerFormWindowManagerInterface class allows you to
|
||||
manipulate the collection of form windows in Qt Designer, and
|
||||
control Qt Designer's form editing actions.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
QDesignerFormWindowManagerInterface is not intended to be
|
||||
instantiated directly. \QD uses the form window manager to
|
||||
control the various form windows in its workspace. You can
|
||||
retrieve an interface to \QD's form window manager using
|
||||
the QDesignerFormEditorInterface::formWindowManager()
|
||||
function. For example:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractformwindowmanager.cpp 0
|
||||
|
||||
When implementing a custom widget plugin, a pointer to \QD's
|
||||
current QDesignerFormEditorInterface object (\c formEditor in the
|
||||
example above) is provided by the
|
||||
QDesignerCustomWidgetInterface::initialize() function's parameter.
|
||||
You must subclass the QDesignerCustomWidgetInterface to expose
|
||||
your plugin to Qt Designer.
|
||||
|
||||
The form window manager interface provides the createFormWindow()
|
||||
function that enables you to create a new form window which you
|
||||
can add to the collection of form windows that the manager
|
||||
maintains, using the addFormWindow() slot. It also provides the
|
||||
formWindowCount() function returning the number of form windows
|
||||
currently under the manager's control, the formWindow() function
|
||||
returning the form window associated with a given index, and the
|
||||
activeFormWindow() function returning the currently selected form
|
||||
window. The removeFormWindow() slot allows you to reduce the
|
||||
number of form windows the manager must maintain, and the
|
||||
setActiveFormWindow() slot allows you to change the form window
|
||||
focus in \QD's workspace.
|
||||
|
||||
In addition, QDesignerFormWindowManagerInterface contains a
|
||||
collection of functions that enables you to intervene and control
|
||||
\QD's form editing actions. All these functions return the
|
||||
original action, making it possible to propagate the function
|
||||
further after intervention.
|
||||
|
||||
Finally, the interface provides three signals which are emitted
|
||||
when a form window is added, when the currently selected form
|
||||
window changes, or when a form window is removed, respectively. All
|
||||
the signals carry the form window in question as their parameter.
|
||||
|
||||
\sa QDesignerFormEditorInterface, QDesignerFormWindowInterface
|
||||
*/
|
||||
|
||||
// ------------- QDesignerFormWindowManagerInterfacePrivate
|
||||
|
||||
struct QDesignerFormWindowManagerInterfacePrivate {
|
||||
QDesignerFormWindowManagerInterfacePrivate();
|
||||
QAction *m_simplifyLayoutAction;
|
||||
QAction *m_formLayoutAction;
|
||||
};
|
||||
|
||||
QDesignerFormWindowManagerInterfacePrivate::QDesignerFormWindowManagerInterfacePrivate() :
|
||||
m_simplifyLayoutAction(0),
|
||||
m_formLayoutAction(0)
|
||||
{
|
||||
}
|
||||
|
||||
typedef QMap<const QDesignerFormWindowManagerInterface *, QDesignerFormWindowManagerInterfacePrivate *> FormWindowManagerPrivateMap;
|
||||
|
||||
Q_GLOBAL_STATIC(FormWindowManagerPrivateMap, g_FormWindowManagerPrivateMap)
|
||||
|
||||
/*!
|
||||
Constructs an interface with the given \a parent for the form window
|
||||
manager.
|
||||
*/
|
||||
QDesignerFormWindowManagerInterface::QDesignerFormWindowManagerInterface(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
g_FormWindowManagerPrivateMap()->insert(this, new QDesignerFormWindowManagerInterfacePrivate);
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the interface for the form window manager.
|
||||
*/
|
||||
QDesignerFormWindowManagerInterface::~QDesignerFormWindowManagerInterface()
|
||||
{
|
||||
FormWindowManagerPrivateMap *fwmpm = g_FormWindowManagerPrivateMap();
|
||||
const FormWindowManagerPrivateMap::iterator it = fwmpm->find(this);
|
||||
Q_ASSERT(it != fwmpm->end());
|
||||
delete it.value();
|
||||
fwmpm->erase(it);
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control \QD's "cut" action. The function
|
||||
returns the original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionCut() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control \QD's "copy" action. The
|
||||
function returns the original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionCopy() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control \QD's "paste" action. The
|
||||
function returns the original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionPaste() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control \QD's "delete" action. The function
|
||||
returns the original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionDelete() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control \QD's "select all" action. The
|
||||
function returns the original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionSelectAll() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control the action of lowering a form
|
||||
window in \QD's workspace. The function returns the original
|
||||
action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionLower() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control the action of raising of a
|
||||
form window in \QD's workspace. The function returns the original
|
||||
action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionRaise() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control a request for horizontal
|
||||
layout for a form window in \QD's workspace. The function returns
|
||||
the original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionHorizontalLayout() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control a request for vertical layout
|
||||
for a form window in \QD's workspace. The function returns the
|
||||
original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionVerticalLayout() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control \QD's "split horizontal"
|
||||
action. The function returns the original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionSplitHorizontal() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control \QD's "split vertical"
|
||||
action. The function returns the original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionSplitVertical() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control a request for grid layout for
|
||||
a form window in \QD's workspace. The function returns the
|
||||
original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionGridLayout() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control \QD's "form layout" action. The
|
||||
function returns the original action.
|
||||
|
||||
FormWindowManagerPrivateMap *fwmpm = g_FormWindowManagerPrivateMap(); \sa QAction
|
||||
\since 4.4
|
||||
*/
|
||||
|
||||
QAction *QDesignerFormWindowManagerInterface::actionFormLayout() const
|
||||
{
|
||||
const QDesignerFormWindowManagerInterfacePrivate *d = g_FormWindowManagerPrivateMap()->value(this);
|
||||
Q_ASSERT(d);
|
||||
return d->m_formLayoutAction;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the "form layout" action to \a action.
|
||||
|
||||
\internal
|
||||
\since 4.4
|
||||
*/
|
||||
|
||||
void QDesignerFormWindowManagerInterface::setActionFormLayout(QAction *action)
|
||||
{
|
||||
QDesignerFormWindowManagerInterfacePrivate *d = g_FormWindowManagerPrivateMap()->value(this);
|
||||
Q_ASSERT(d);
|
||||
d->m_formLayoutAction = action;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control \QD's "break layout" action. The
|
||||
function returns the original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionBreakLayout() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control \QD's "adjust size" action. The
|
||||
function returns the original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionAdjustSize() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control \QD's "simplify layout" action. The
|
||||
function returns the original action.
|
||||
|
||||
\sa QAction
|
||||
\since 4.4
|
||||
*/
|
||||
|
||||
QAction *QDesignerFormWindowManagerInterface::actionSimplifyLayout() const
|
||||
{
|
||||
const QDesignerFormWindowManagerInterfacePrivate *d = g_FormWindowManagerPrivateMap()->value(this);
|
||||
Q_ASSERT(d);
|
||||
return d->m_simplifyLayoutAction;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the "simplify layout" action to \a action.
|
||||
|
||||
\internal
|
||||
\since 4.4
|
||||
*/
|
||||
|
||||
void QDesignerFormWindowManagerInterface::setActionSimplifyLayout(QAction *action)
|
||||
{
|
||||
QDesignerFormWindowManagerInterfacePrivate *d = g_FormWindowManagerPrivateMap()->value(this);
|
||||
Q_ASSERT(d);
|
||||
d->m_simplifyLayoutAction = action;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the currently active form window in \QD's workspace.
|
||||
|
||||
\sa setActiveFormWindow(), removeFormWindow()
|
||||
*/
|
||||
QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::activeFormWindow() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a pointer to \QD's current QDesignerFormEditorInterface
|
||||
object.
|
||||
*/
|
||||
QDesignerFormEditorInterface *QDesignerFormWindowManagerInterface::core() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds the given \a formWindow to the collection of windows that
|
||||
\QD's form window manager maintains.
|
||||
|
||||
\sa formWindowAdded()
|
||||
*/
|
||||
void QDesignerFormWindowManagerInterface::addFormWindow(QDesignerFormWindowInterface *formWindow)
|
||||
{
|
||||
Q_UNUSED(formWindow);
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes the given \a formWindow from the collection of windows that
|
||||
\QD's form window manager maintains.
|
||||
|
||||
\sa formWindow(), formWindowRemoved()
|
||||
*/
|
||||
void QDesignerFormWindowManagerInterface::removeFormWindow(QDesignerFormWindowInterface *formWindow)
|
||||
{
|
||||
Q_UNUSED(formWindow);
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the given \a formWindow to be the currently active form window in
|
||||
\QD's workspace.
|
||||
|
||||
\sa activeFormWindow(), activeFormWindowChanged()
|
||||
*/
|
||||
void QDesignerFormWindowManagerInterface::setActiveFormWindow(QDesignerFormWindowInterface *formWindow)
|
||||
{
|
||||
Q_UNUSED(formWindow);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of form windows maintained by \QD's form window
|
||||
manager.
|
||||
*/
|
||||
int QDesignerFormWindowManagerInterface::formWindowCount() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the form window at the given \a index.
|
||||
|
||||
\sa setActiveFormWindow(), removeFormWindow()
|
||||
*/
|
||||
QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::formWindow(int index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::createFormWindow(QWidget *parent, Qt::WindowFlags flags)
|
||||
|
||||
Creates a form window with the given \a parent and the given window
|
||||
\a flags.
|
||||
|
||||
\sa addFormWindow()
|
||||
*/
|
||||
QDesignerFormWindowInterface *QDesignerFormWindowManagerInterface::createFormWindow(QWidget *parentWidget, Qt::WindowFlags flags)
|
||||
{
|
||||
Q_UNUSED(parentWidget);
|
||||
Q_UNUSED(flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control \QD's "undo" action. The
|
||||
function returns the original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionUndo() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allows you to intervene and control \QD's "redo" action. The
|
||||
function returns the original action.
|
||||
|
||||
\sa QAction
|
||||
*/
|
||||
QAction *QDesignerFormWindowManagerInterface::actionRedo() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowManagerInterface::formWindowAdded(QDesignerFormWindowInterface *formWindow)
|
||||
|
||||
This signal is emitted when a new form window is added to the
|
||||
collection of windows that \QD's form window manager maintains. A
|
||||
pointer to the new \a formWindow is passed as an argument.
|
||||
|
||||
\sa addFormWindow(), setActiveFormWindow()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowManagerInterface::formWindowRemoved(QDesignerFormWindowInterface *formWindow)
|
||||
|
||||
This signal is emitted when a form window is removed from the
|
||||
collection of windows that \QD's form window manager maintains. A
|
||||
pointer to the removed \a formWindow is passed as an argument.
|
||||
|
||||
\sa removeFormWindow()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowManagerInterface::activeFormWindowChanged(QDesignerFormWindowInterface *formWindow)
|
||||
|
||||
This signal is emitted when the contents of the currently active
|
||||
form window in \QD's workspace changed. A pointer to the currently
|
||||
active \a formWindow is passed as an argument.
|
||||
|
||||
\sa activeFormWindow()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerFormWindowManagerInterface::dragItems(const QList<QDesignerDnDItemInterface*> &item_list)
|
||||
|
||||
\internal
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
122
third/designer/lib/sdk/abstractformwindowmanager.h
Normal file
122
third/designer/lib/sdk/abstractformwindowmanager.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTFORMWINDOWMANAGER_H
|
||||
#define ABSTRACTFORMWINDOWMANAGER_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
#include <QtDesigner/abstractformwindow.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QAction;
|
||||
class QActionGroup;
|
||||
class QDesignerFormEditorInterface;
|
||||
class DomUI;
|
||||
class QWidget;
|
||||
class QDesignerDnDItemInterface;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerFormWindowManagerInterface: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerFormWindowManagerInterface(QObject *parent = 0);
|
||||
virtual ~QDesignerFormWindowManagerInterface();
|
||||
|
||||
virtual QAction *actionCut() const;
|
||||
virtual QAction *actionCopy() const;
|
||||
virtual QAction *actionPaste() const;
|
||||
virtual QAction *actionDelete() const;
|
||||
virtual QAction *actionSelectAll() const;
|
||||
virtual QAction *actionLower() const;
|
||||
virtual QAction *actionRaise() const;
|
||||
virtual QAction *actionUndo() const;
|
||||
virtual QAction *actionRedo() const;
|
||||
|
||||
virtual QAction *actionHorizontalLayout() const;
|
||||
virtual QAction *actionVerticalLayout() const;
|
||||
virtual QAction *actionSplitHorizontal() const;
|
||||
virtual QAction *actionSplitVertical() const;
|
||||
virtual QAction *actionGridLayout() const;
|
||||
QAction *actionFormLayout() const;
|
||||
virtual QAction *actionBreakLayout() const;
|
||||
virtual QAction *actionAdjustSize() const;
|
||||
QAction *actionSimplifyLayout() const;
|
||||
|
||||
virtual QDesignerFormWindowInterface *activeFormWindow() const;
|
||||
|
||||
virtual int formWindowCount() const;
|
||||
virtual QDesignerFormWindowInterface *formWindow(int index) const;
|
||||
|
||||
virtual QDesignerFormWindowInterface *createFormWindow(QWidget *parentWidget = 0, Qt::WindowFlags flags = 0);
|
||||
|
||||
virtual QDesignerFormEditorInterface *core() const;
|
||||
|
||||
virtual void dragItems(const QList<QDesignerDnDItemInterface*> &item_list) = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void formWindowAdded(QDesignerFormWindowInterface *formWindow);
|
||||
void formWindowRemoved(QDesignerFormWindowInterface *formWindow);
|
||||
void activeFormWindowChanged(QDesignerFormWindowInterface *formWindow);
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void addFormWindow(QDesignerFormWindowInterface *formWindow);
|
||||
virtual void removeFormWindow(QDesignerFormWindowInterface *formWindow);
|
||||
virtual void setActiveFormWindow(QDesignerFormWindowInterface *formWindow);
|
||||
|
||||
protected:
|
||||
void setActionFormLayout(QAction *action);
|
||||
void setActionSimplifyLayout(QAction *action);
|
||||
|
||||
private:
|
||||
QDesignerFormWindowManagerInterface(const QDesignerFormWindowManagerInterface &other);
|
||||
QDesignerFormWindowManagerInterface &operator = (const QDesignerFormWindowManagerInterface &other);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTFORMWINDOWMANAGER_H
|
||||
106
third/designer/lib/sdk/abstractformwindowtool.cpp
Normal file
106
third/designer/lib/sdk/abstractformwindowtool.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractformwindowtool.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerFormWindowToolInterface
|
||||
|
||||
\brief The QDesignerFormWindowToolInterface class provides an
|
||||
interface that enables tools to be used on items in a form window.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
*/
|
||||
QDesignerFormWindowToolInterface::QDesignerFormWindowToolInterface(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
QDesignerFormWindowToolInterface::~QDesignerFormWindowToolInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerFormEditorInterface *QDesignerFormWindowToolInterface::core() const = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerFormWindowInterface *QDesignerFormWindowToolInterface::formWindow() const = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QWidget *QDesignerFormWindowToolInterface::editor() const = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QAction *QDesignerFormWindowToolInterface::action() const = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowToolInterface::activated() = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowToolInterface::deactivated() = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowToolInterface::saveToDom(DomUI*, QWidget*) {
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerFormWindowToolInterface::loadFromDom(DomUI*, QWidget*) {
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerFormWindowToolInterface::handleEvent(QWidget *widget, QWidget *managedWidget, QEvent *event) = 0
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
85
third/designer/lib/sdk/abstractformwindowtool.h
Normal file
85
third/designer/lib/sdk/abstractformwindowtool.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTFORMWINDOWTOOL_H
|
||||
#define ABSTRACTFORMWINDOWTOOL_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
class QDesignerFormWindowInterface;
|
||||
class QWidget;
|
||||
class QAction;
|
||||
class DomUI;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerFormWindowToolInterface: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerFormWindowToolInterface(QObject *parent = 0);
|
||||
virtual ~QDesignerFormWindowToolInterface();
|
||||
|
||||
virtual QDesignerFormEditorInterface *core() const = 0;
|
||||
virtual QDesignerFormWindowInterface *formWindow() const = 0;
|
||||
virtual QWidget *editor() const = 0;
|
||||
|
||||
virtual QAction *action() const = 0;
|
||||
|
||||
virtual void activated() = 0;
|
||||
virtual void deactivated() = 0;
|
||||
|
||||
virtual void saveToDom(DomUI*, QWidget*) {}
|
||||
virtual void loadFromDom(DomUI*, QWidget*) {}
|
||||
|
||||
virtual bool handleEvent(QWidget *widget, QWidget *managedWidget, QEvent *event) = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTFORMWINDOWTOOL_H
|
||||
83
third/designer/lib/sdk/abstracticoncache.h
Normal file
83
third/designer/lib/sdk/abstracticoncache.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTICONCACHE_H
|
||||
#define ABSTRACTICONCACHE_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QIcon;
|
||||
class QPixmap;
|
||||
class QString;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerIconCacheInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerIconCacheInterface(QObject *parent_)
|
||||
: QObject(parent_) {}
|
||||
|
||||
virtual QIcon nameToIcon(const QString &filePath, const QString &qrcPath = QString()) = 0;
|
||||
virtual QPixmap nameToPixmap(const QString &filePath, const QString &qrcPath = QString()) = 0;
|
||||
|
||||
virtual QString iconToFilePath(const QIcon &pm) const = 0;
|
||||
virtual QString iconToQrcPath(const QIcon &pm) const = 0;
|
||||
|
||||
virtual QString pixmapToFilePath(const QPixmap &pm) const = 0;
|
||||
virtual QString pixmapToQrcPath(const QPixmap &pm) const = 0;
|
||||
|
||||
virtual QList<QPixmap> pixmapList() const = 0;
|
||||
virtual QList<QIcon> iconList() const = 0;
|
||||
|
||||
virtual QString resolveQrcPath(const QString &filePath, const QString &qrcPath, const QString &workingDirectory = QString()) const = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTICONCACHE_H
|
||||
116
third/designer/lib/sdk/abstracticoncache.qdoc
Normal file
116
third/designer/lib/sdk/abstracticoncache.qdoc
Normal file
@@ -0,0 +1,116 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 QDesignerIconCacheInterface
|
||||
\brief The QDesignerIconCacheInterface class provides an interface to \QD's icon cache.
|
||||
\inmodule QtDesigner
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerIconCacheInterface::QDesignerIconCacheInterface(QObject *parent)
|
||||
|
||||
Constructs a new interface with the given \a parent.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QIcon QDesignerIconCacheInterface::nameToIcon(const QString &filePath, const QString &qrcPath)
|
||||
|
||||
Returns the icon associated with the name specified by \a filePath in the resource
|
||||
file specified by \a qrcPath.
|
||||
|
||||
If \a qrcPath refers to a valid resource file, the name used for the file path is a path
|
||||
within those resources; otherwise the file path refers to a local file.
|
||||
|
||||
\sa {The Qt Resource System}, nameToPixmap()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QPixmap QDesignerIconCacheInterface::nameToPixmap(const QString &filePath, const QString &qrcPath)
|
||||
|
||||
Returns the pixmap associated with the name specified by \a filePath in the resource
|
||||
file specified by \a qrcPath.
|
||||
|
||||
If \a qrcPath refers to a valid resource file, the name used for the file path is a path
|
||||
within those resources; otherwise the file path refers to a local file.
|
||||
|
||||
\sa {The Qt Resource System}, nameToIcon()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerIconCacheInterface::iconToFilePath(const QIcon &icon) const
|
||||
|
||||
Returns the file path associated with the given \a icon. The file path is a path within
|
||||
an application resources.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerIconCacheInterface::iconToQrcPath(const QIcon &icon) const
|
||||
|
||||
Returns the path to the resource file that refers to the specified \a icon. The resource
|
||||
path refers to a local file.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerIconCacheInterface::pixmapToFilePath(const QPixmap &pixmap) const
|
||||
|
||||
Returns the file path associated with the given \a pixmap. The file path is a path within
|
||||
an application resources.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerIconCacheInterface::pixmapToQrcPath(const QPixmap &pixmap) const
|
||||
|
||||
Returns the path to the resource file that refers to the specified \a pixmap. The resource
|
||||
path refers to a local file.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QList<QPixmap> QDesignerIconCacheInterface::pixmapList() const
|
||||
|
||||
Returns a list of pixmaps for the icons provided by the icon cache.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QList<QIcon> QDesignerIconCacheInterface::iconList() const
|
||||
|
||||
Returns a list of icons provided by the icon cache.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerIconCacheInterface::resolveQrcPath(const QString &filePath, const QString &qrcPath, const QString &workingDirectory) const
|
||||
|
||||
Returns a path to a resource specified by the \a filePath within
|
||||
the resource file located at \a qrcPath. If \a workingDirectory is
|
||||
a valid path to a directory, the path returned will be relative to
|
||||
that directory; otherwise an absolute path is returned.
|
||||
|
||||
\omit
|
||||
### Needs checking
|
||||
\endomit
|
||||
*/
|
||||
54
third/designer/lib/sdk/abstractintegration.cpp
Normal file
54
third/designer/lib/sdk/abstractintegration.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractintegration.h"
|
||||
#include "abstractformeditor.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QDesignerIntegrationInterface::QDesignerIntegrationInterface(QDesignerFormEditorInterface *core, QObject *parent)
|
||||
: QObject(parent),
|
||||
m_core(core)
|
||||
{
|
||||
core->setIntegration(this);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
76
third/designer/lib/sdk/abstractintegration.h
Normal file
76
third/designer/lib/sdk/abstractintegration.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTINTEGRATION_H
|
||||
#define ABSTRACTINTEGRATION_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerIntegrationInterface: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerIntegrationInterface(QDesignerFormEditorInterface *core, QObject *parent = 0);
|
||||
|
||||
inline QDesignerFormEditorInterface *core() const;
|
||||
|
||||
virtual QWidget *containerWindow(QWidget *widget) const = 0;
|
||||
|
||||
private:
|
||||
QDesignerFormEditorInterface *m_core;
|
||||
};
|
||||
|
||||
inline QDesignerFormEditorInterface *QDesignerIntegrationInterface::core() const
|
||||
{ return m_core; }
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTINTEGRATION_H
|
||||
548
third/designer/lib/sdk/abstractintrospection.cpp
Normal file
548
third/designer/lib/sdk/abstractintrospection.cpp
Normal file
@@ -0,0 +1,548 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractintrospection_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerMetaEnumInterface
|
||||
\internal
|
||||
\since 4.4
|
||||
|
||||
\brief QDesignerMetaEnumInterface is part of \QD's introspection interface and represents an enumeration.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
The QDesignerMetaEnumInterface class provides meta-data about an enumerator.
|
||||
|
||||
\sa QDesignerMetaObjectInterface
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QDesignerMetaEnumInterface object.
|
||||
*/
|
||||
|
||||
QDesignerMetaEnumInterface::QDesignerMetaEnumInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the QDesignerMetaEnumInterface object.
|
||||
*/
|
||||
QDesignerMetaEnumInterface::~QDesignerMetaEnumInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerMetaEnumInterface::isFlag() const
|
||||
|
||||
Returns true if this enumerator is used as a flag.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaEnumInterface::key(int index) const
|
||||
|
||||
Returns the key with the given \a index.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaEnumInterface::keyCount() const
|
||||
|
||||
Returns the number of keys.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaEnumInterface::keyToValue(const QString &key) const
|
||||
|
||||
Returns the integer value of the given enumeration \a key, or -1 if \a key is not defined.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaEnumInterface::keysToValue(const QString &keys) const
|
||||
|
||||
Returns the value derived from combining together the values of the \a keys using the OR operator, or -1 if keys is not defined. Note that the strings in \a keys must be '|'-separated.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaEnumInterface::name() const
|
||||
|
||||
Returns the name of the enumerator (without the scope).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaEnumInterface::scope() const
|
||||
|
||||
Returns the scope this enumerator was declared in.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaEnumInterface::separator() const
|
||||
|
||||
Returns the separator to be used when building enumeration names.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaEnumInterface::value(int index) const
|
||||
|
||||
Returns the value with the given \a index; or returns -1 if there is no such value.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaEnumInterface::valueToKey(int value) const
|
||||
|
||||
Returns the string that is used as the name of the given enumeration \a value, or QString::null if value is not defined.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaEnumInterface::valueToKeys(int value) const
|
||||
|
||||
Returns a byte array of '|'-separated keys that represents the given \a value.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class QDesignerMetaPropertyInterface
|
||||
\internal
|
||||
\since 4.4
|
||||
|
||||
\brief QDesignerMetaPropertyInterface is part of \QD's introspection interface and represents a property.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
The QDesignerMetaPropertyInterface class provides meta-data about a property.
|
||||
|
||||
\sa QDesignerMetaObjectInterface
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QDesignerMetaPropertyInterface object.
|
||||
*/
|
||||
|
||||
QDesignerMetaPropertyInterface::QDesignerMetaPropertyInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the QDesignerMetaPropertyInterface object.
|
||||
*/
|
||||
|
||||
QDesignerMetaPropertyInterface::~QDesignerMetaPropertyInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\enum QDesignerMetaPropertyInterface::Kind
|
||||
|
||||
This enum indicates whether the property is of a special type.
|
||||
|
||||
\value EnumKind The property is of an enumeration type
|
||||
\value FlagKind The property is of an flag type
|
||||
\value OtherKind The property is of another type
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDesignerMetaPropertyInterface::AccessFlag
|
||||
|
||||
These flags specify the access the property provides.
|
||||
|
||||
\value ReadAccess Property can be read
|
||||
\value WriteAccess Property can be written
|
||||
\value ResetAccess Property can be reset to a default value
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDesignerMetaPropertyInterface::Attribute
|
||||
|
||||
Various attributes of the property.
|
||||
|
||||
\value DesignableAttribute Property is designable (visible in \QD)
|
||||
\value ScriptableAttribute Property is scriptable
|
||||
\value StoredAttribute Property is stored, that is, not calculated
|
||||
\value UserAttribute Property is the property that the user can edit for the QObject
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QDesignerMetaEnumInterface *QDesignerMetaPropertyInterface::enumerator() const
|
||||
|
||||
Returns the enumerator if this property's type is an enumerator type;
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn Kind QDesignerMetaPropertyInterface::kind() const
|
||||
|
||||
Returns the type of the property.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn AccessFlags QDesignerMetaPropertyInterface::accessFlags() const
|
||||
|
||||
Returns a combination of access flags.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn Attributes QDesignerMetaPropertyInterface::attributes(const QObject *object) const
|
||||
|
||||
Returns the attributes of the property for the gives \a object.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVariant::Type QDesignerMetaPropertyInterface::type() const
|
||||
|
||||
Returns the type of the property.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaPropertyInterface::name() const
|
||||
|
||||
Returns the name of the property.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaPropertyInterface::typeName() const
|
||||
|
||||
Returns the name of this property's type.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaPropertyInterface::userType() const
|
||||
|
||||
Returns this property's user type.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerMetaPropertyInterface::hasSetter() const
|
||||
|
||||
Returns whether getter and setter methods exist for this property.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVariant QDesignerMetaPropertyInterface::read(const QObject *object) const
|
||||
|
||||
Reads the property's value from the given \a object. Returns the value if it was able to read it; otherwise returns an invalid variant.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerMetaPropertyInterface::reset(QObject *object) const
|
||||
|
||||
Resets the property for the given \a object with a reset method. Returns true if the reset worked; otherwise returns false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerMetaPropertyInterface::write(QObject *object, const QVariant &value) const
|
||||
|
||||
Writes \a value as the property's value to the given \a object. Returns true if the write succeeded; otherwise returns false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class QDesignerMetaMethodInterface
|
||||
\internal
|
||||
\since 4.4
|
||||
|
||||
\brief QDesignerMetaMethodInterface is part of \QD's introspection interface and represents a member function.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
The QDesignerMetaMethodInterface class provides meta-data about a member function.
|
||||
|
||||
\sa QDesignerMetaObjectInterface
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QDesignerMetaMethodInterface object.
|
||||
*/
|
||||
|
||||
QDesignerMetaMethodInterface::QDesignerMetaMethodInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the QDesignerMetaMethodInterface object.
|
||||
*/
|
||||
|
||||
QDesignerMetaMethodInterface::~QDesignerMetaMethodInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\enum QDesignerMetaMethodInterface::MethodType
|
||||
|
||||
This enum specifies the type of the method
|
||||
|
||||
\value Method The function is a plain member function.
|
||||
\value Signal The function is a signal.
|
||||
\value Slot The function is a slot.
|
||||
\value Constructor The function is a constructor.
|
||||
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDesignerMetaMethodInterface::Access
|
||||
|
||||
This enum represents the access specification of the method
|
||||
|
||||
\value Private A private member function
|
||||
\value Protected A protected member function
|
||||
\value Public A public member function
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerMetaMethodInterface::Access QDesignerMetaMethodInterface::access() const
|
||||
|
||||
Returns the access specification of this method.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn QDesignerMetaMethodInterface::MethodType QDesignerMetaMethodInterface::methodType() const
|
||||
|
||||
Returns the type of this method.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QStringList QDesignerMetaMethodInterface::parameterNames() const
|
||||
|
||||
Returns a list of parameter names.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QStringList QDesignerMetaMethodInterface::parameterTypes() const
|
||||
|
||||
Returns a list of parameter types.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaMethodInterface::signature() const
|
||||
|
||||
Returns the signature of this method.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaMethodInterface::normalizedSignature() const
|
||||
|
||||
Returns the normalized signature of this method (suitable as signal/slot specification).
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaMethodInterface::tag() const
|
||||
|
||||
Returns the tag associated with this method.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaMethodInterface::typeName() const
|
||||
|
||||
Returns the return type of this method, or an empty string if the return type is void.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class QDesignerMetaObjectInterface
|
||||
\internal
|
||||
\since 4.4
|
||||
|
||||
\brief QDesignerMetaObjectInterface is part of \QD's introspection interface and provides meta-information about Qt objects
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
The QDesignerMetaObjectInterface class provides meta-data about Qt objects. For a given object, it can be obtained
|
||||
by querying QDesignerIntrospectionInterface.
|
||||
|
||||
\sa QDesignerIntrospectionInterface
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QDesignerMetaObjectInterface object.
|
||||
*/
|
||||
|
||||
QDesignerMetaObjectInterface::QDesignerMetaObjectInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the QDesignerMetaObjectInterface object.
|
||||
*/
|
||||
|
||||
QDesignerMetaObjectInterface::~QDesignerMetaObjectInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaObjectInterface::className() const
|
||||
|
||||
Returns the class name.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QDesignerMetaEnumInterface *QDesignerMetaObjectInterface::enumerator(int index) const
|
||||
|
||||
Returns the meta-data for the enumerator with the given \a index.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaObjectInterface::enumeratorCount() const
|
||||
|
||||
Returns the number of enumerators in this class.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaObjectInterface::enumeratorOffset() const
|
||||
|
||||
Returns the enumerator offset for this class; i.e. the index position of this class's first enumerator.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaObjectInterface::indexOfEnumerator(const QString &name) const
|
||||
|
||||
Finds enumerator \a name and returns its index; otherwise returns -1.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaObjectInterface::indexOfMethod(const QString &method) const
|
||||
|
||||
Finds \a method and returns its index; otherwise returns -1.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaObjectInterface::indexOfProperty(const QString &name) const
|
||||
|
||||
Finds property \a name and returns its index; otherwise returns -1.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaObjectInterface::indexOfSignal(const QString &signal) const
|
||||
|
||||
Finds \a signal and returns its index; otherwise returns -1.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaObjectInterface::indexOfSlot(const QString &slot) const
|
||||
|
||||
Finds \a slot and returns its index; otherwise returns -1.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QDesignerMetaMethodInterface *QDesignerMetaObjectInterface::method(int index) const
|
||||
|
||||
Returns the meta-data for the method with the given \a index.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaObjectInterface::methodCount() const
|
||||
|
||||
Returns the number of methods in this class. These include ordinary methods, signals, and slots.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMetaObjectInterface::methodOffset() const
|
||||
|
||||
Returns the method offset for this class; i.e. the index position of this class's first member function.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QDesignerMetaPropertyInterface *QDesignerMetaObjectInterface::property(int index) const
|
||||
|
||||
Returns the meta-data for the property with the given \a index.
|
||||
*/
|
||||
/*!
|
||||
\fn int QDesignerMetaObjectInterface::propertyCount() const
|
||||
|
||||
Returns the number of properties in this class.
|
||||
*/
|
||||
/*!
|
||||
\fn int QDesignerMetaObjectInterface::propertyOffset() const
|
||||
|
||||
Returns the property offset for this class; i.e. the index position of this class's first property.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QDesignerMetaObjectInterface *QDesignerMetaObjectInterface::superClass() const
|
||||
|
||||
Returns the meta-object of the superclass, or 0 if there is no such object.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QDesignerMetaPropertyInterface *QDesignerMetaObjectInterface::userProperty() const
|
||||
|
||||
Returns the property that has the USER flag set to true.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class QDesignerIntrospectionInterface
|
||||
\internal
|
||||
\since 4.4
|
||||
|
||||
\brief QDesignerIntrospectionInterface provides access to a QDesignerMetaObjectInterface for a given Qt object.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
QDesignerIntrospectionInterface is the main class of \QD's introspection interface. These
|
||||
interfaces provide a layer of abstraction around QMetaObject and related classes to allow for the integration
|
||||
of other programming languages.
|
||||
|
||||
An instance of QDesignerIntrospectionInterface can be obtained from the core.
|
||||
|
||||
\sa QDesignerMetaObjectInterface
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QDesignerIntrospectionInterface object.
|
||||
*/
|
||||
|
||||
QDesignerIntrospectionInterface::QDesignerIntrospectionInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the QDesignerIntrospectionInterface object.
|
||||
*/
|
||||
|
||||
QDesignerIntrospectionInterface::~QDesignerIntrospectionInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn const QDesignerMetaObjectInterface* QDesignerIntrospectionInterface::metaObject(const QObject *object) const
|
||||
|
||||
Returns the meta object of this \a object.
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
174
third/designer/lib/sdk/abstractintrospection_p.h
Normal file
174
third/designer/lib/sdk/abstractintrospection_p.h
Normal file
@@ -0,0 +1,174 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTMETAOBJECT_H
|
||||
#define ABSTRACTMETAOBJECT_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QFlags>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerMetaEnumInterface
|
||||
{
|
||||
public:
|
||||
QDesignerMetaEnumInterface();
|
||||
virtual ~QDesignerMetaEnumInterface();
|
||||
virtual bool isFlag() const = 0;
|
||||
virtual QString key(int index) const = 0;
|
||||
virtual int keyCount() const = 0;
|
||||
virtual int keyToValue(const QString &key) const = 0;
|
||||
virtual int keysToValue(const QString &keys) const = 0;
|
||||
virtual QString name() const = 0;
|
||||
virtual QString scope() const = 0;
|
||||
virtual QString separator() const = 0;
|
||||
virtual int value(int index) const = 0;
|
||||
virtual QString valueToKey(int value) const = 0;
|
||||
virtual QString valueToKeys(int value) const = 0;
|
||||
};
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerMetaPropertyInterface
|
||||
{
|
||||
public:
|
||||
enum Kind { EnumKind, FlagKind, OtherKind };
|
||||
enum AccessFlag { ReadAccess = 0x0001, WriteAccess = 0x0002, ResetAccess = 0x0004 };
|
||||
enum Attribute { DesignableAttribute = 0x0001, ScriptableAttribute = 0x0002, StoredAttribute = 0x0004, UserAttribute = 0x0008};
|
||||
Q_DECLARE_FLAGS(Attributes, Attribute)
|
||||
Q_DECLARE_FLAGS(AccessFlags, AccessFlag)
|
||||
|
||||
QDesignerMetaPropertyInterface();
|
||||
virtual ~QDesignerMetaPropertyInterface();
|
||||
|
||||
virtual const QDesignerMetaEnumInterface *enumerator() const = 0;
|
||||
|
||||
virtual Kind kind() const = 0;
|
||||
virtual AccessFlags accessFlags() const = 0;
|
||||
virtual Attributes attributes(const QObject *object = 0) const = 0;
|
||||
|
||||
virtual QVariant::Type type() const = 0;
|
||||
virtual QString name() const = 0;
|
||||
virtual QString typeName() const = 0;
|
||||
virtual int userType() const = 0;
|
||||
virtual bool hasSetter() const = 0;
|
||||
|
||||
virtual QVariant read(const QObject *object) const = 0;
|
||||
virtual bool reset(QObject *object) const = 0;
|
||||
virtual bool write(QObject *object, const QVariant &value) const = 0;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QDesignerMetaPropertyInterface::AccessFlags)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QDesignerMetaPropertyInterface::Attributes)
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerMetaMethodInterface
|
||||
{
|
||||
public:
|
||||
QDesignerMetaMethodInterface();
|
||||
virtual ~QDesignerMetaMethodInterface();
|
||||
|
||||
enum MethodType { Method, Signal, Slot, Constructor };
|
||||
enum Access { Private, Protected, Public };
|
||||
|
||||
virtual Access access() const = 0;
|
||||
virtual MethodType methodType() const = 0;
|
||||
virtual QStringList parameterNames() const = 0;
|
||||
virtual QStringList parameterTypes() const = 0;
|
||||
virtual QString signature() const = 0;
|
||||
virtual QString normalizedSignature() const = 0;
|
||||
virtual QString tag() const = 0;
|
||||
virtual QString typeName() const = 0;
|
||||
};
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerMetaObjectInterface {
|
||||
public:
|
||||
QDesignerMetaObjectInterface();
|
||||
virtual ~QDesignerMetaObjectInterface();
|
||||
|
||||
virtual QString className() const = 0;
|
||||
virtual const QDesignerMetaEnumInterface *enumerator(int index) const = 0;
|
||||
virtual int enumeratorCount() const = 0;
|
||||
virtual int enumeratorOffset() const = 0;
|
||||
|
||||
virtual int indexOfEnumerator(const QString &name) const = 0;
|
||||
virtual int indexOfMethod(const QString &method) const = 0;
|
||||
virtual int indexOfProperty(const QString &name) const = 0;
|
||||
virtual int indexOfSignal(const QString &signal) const = 0;
|
||||
virtual int indexOfSlot(const QString &slot) const = 0;
|
||||
|
||||
virtual const QDesignerMetaMethodInterface *method(int index) const = 0;
|
||||
virtual int methodCount() const = 0;
|
||||
virtual int methodOffset() const = 0;
|
||||
|
||||
virtual const QDesignerMetaPropertyInterface *property(int index) const = 0;
|
||||
virtual int propertyCount() const = 0;
|
||||
virtual int propertyOffset() const = 0;
|
||||
|
||||
virtual const QDesignerMetaObjectInterface *superClass() const = 0;
|
||||
virtual const QDesignerMetaPropertyInterface *userProperty() const = 0;
|
||||
};
|
||||
|
||||
// To be obtained from core
|
||||
class QDESIGNER_SDK_EXPORT QDesignerIntrospectionInterface {
|
||||
public:
|
||||
QDesignerIntrospectionInterface();
|
||||
virtual ~QDesignerIntrospectionInterface();
|
||||
|
||||
virtual const QDesignerMetaObjectInterface* metaObject(const QObject *object) const = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTMETAOBJECT_H
|
||||
100
third/designer/lib/sdk/abstractlanguage.h
Normal file
100
third/designer/lib/sdk/abstractlanguage.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 QDESIGNER_ABTRACT_LANGUAGE_H
|
||||
#define QDESIGNER_ABTRACT_LANGUAGE_H
|
||||
|
||||
#include <QtDesigner/extension.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDialog;
|
||||
class QWidget;
|
||||
class QDesignerFormWindowInterface;
|
||||
class QDesignerFormEditorInterface;
|
||||
class QDesignerResourceBrowserInterface;
|
||||
|
||||
class QDesignerLanguageExtension
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerLanguageExtension() {}
|
||||
|
||||
virtual QDialog *createFormWindowSettingsDialog(QDesignerFormWindowInterface *formWindow, QWidget *parentWidget) = 0;
|
||||
virtual QDesignerResourceBrowserInterface *createResourceBrowser(QWidget *parentWidget) = 0;
|
||||
|
||||
virtual QDialog *createPromotionDialog(QDesignerFormEditorInterface *formEditor, QWidget *parentWidget = 0) = 0;
|
||||
|
||||
virtual QDialog *createPromotionDialog(QDesignerFormEditorInterface *formEditor,
|
||||
const QString &promotableWidgetClassName,
|
||||
QString *promoteToClassName,
|
||||
QWidget *parentWidget = 0) = 0;
|
||||
|
||||
virtual bool isLanguageResource(const QString &path) const = 0;
|
||||
|
||||
virtual QString classNameOf(QObject *object) const = 0;
|
||||
|
||||
virtual bool signalMatchesSlot(const QString &signal, const QString &slot) const = 0;
|
||||
|
||||
virtual QString widgetBoxContents() const = 0;
|
||||
|
||||
virtual QString uiExtension() const = 0;
|
||||
};
|
||||
|
||||
Q_DECLARE_EXTENSION_INTERFACE(QDesignerLanguageExtension, "com.trolltech.Qt.Designer.Language.3")
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QDESIGNER_ABTRACT_LANGUAGE_H
|
||||
170
third/designer/lib/sdk/abstractmetadatabase.cpp
Normal file
170
third/designer/lib/sdk/abstractmetadatabase.cpp
Normal file
@@ -0,0 +1,170 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
// sdk
|
||||
#include "abstractmetadatabase.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerMetaDataBaseInterface
|
||||
\brief The QDesignerMetaDataBaseInterface class provides an interface to Qt Designer's
|
||||
object meta database.
|
||||
\inmodule QtDesigner
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs an interface to the meta database with the given \a parent.
|
||||
*/
|
||||
QDesignerMetaDataBaseInterface::QDesignerMetaDataBaseInterface(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the interface to the meta database.
|
||||
*/
|
||||
QDesignerMetaDataBaseInterface::~QDesignerMetaDataBaseInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QDesignerMetaDataBaseItemInterface *QDesignerMetaDataBaseInterface::item(QObject *object) const
|
||||
|
||||
Returns the item in the meta database associated with the given \a object.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerMetaDataBaseInterface::add(QObject *object)
|
||||
|
||||
Adds the specified \a object to the meta database.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerMetaDataBaseInterface::remove(QObject *object)
|
||||
|
||||
Removes the specified \a object from the meta database.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QList<QObject*> QDesignerMetaDataBaseInterface::objects() const
|
||||
|
||||
Returns the list of objects that have corresponding items in the meta database.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerFormEditorInterface *QDesignerMetaDataBaseInterface::core() const
|
||||
|
||||
Returns the core interface that is associated with the meta database.
|
||||
*/
|
||||
|
||||
|
||||
// Doc: Interface only
|
||||
|
||||
/*!
|
||||
\class QDesignerMetaDataBaseItemInterface
|
||||
\brief The QDesignerMetaDataBaseItemInterface class provides an interface to individual
|
||||
items in Qt Designer's meta database.
|
||||
\inmodule QtDesigner
|
||||
\internal
|
||||
|
||||
This class allows individual items in \QD's meta-data database to be accessed and modified.
|
||||
Use the QDesignerMetaDataBaseInterface class to change the properties of the database itself.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerMetaDataBaseItemInterface::~QDesignerMetaDataBaseItemInterface()
|
||||
|
||||
Destroys the item interface to the meta-data database.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMetaDataBaseItemInterface::name() const
|
||||
|
||||
Returns the name of the item in the database.
|
||||
|
||||
\sa setName()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerMetaDataBaseItemInterface::setName(const QString &name)
|
||||
|
||||
Sets the name of the item to the given \a name.
|
||||
|
||||
\sa name()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QList<QWidget*> QDesignerMetaDataBaseItemInterface::tabOrder() const
|
||||
|
||||
Returns a list of widgets in the order defined by the form's tab order.
|
||||
|
||||
\sa setTabOrder()
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn void QDesignerMetaDataBaseItemInterface::setTabOrder(const QList<QWidget*> &tabOrder)
|
||||
|
||||
Sets the tab order in the form using the list of widgets defined by \a tabOrder.
|
||||
|
||||
\sa tabOrder()
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerMetaDataBaseItemInterface::enabled() const
|
||||
|
||||
Returns whether the item is enabled.
|
||||
|
||||
\sa setEnabled()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerMetaDataBaseItemInterface::setEnabled(bool enabled)
|
||||
|
||||
If \a enabled is true, the item is enabled; otherwise it is disabled.
|
||||
|
||||
\sa enabled()
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
99
third/designer/lib/sdk/abstractmetadatabase.h
Normal file
99
third/designer/lib/sdk/abstractmetadatabase.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTMETADATABASE_H
|
||||
#define ABSTRACTMETADATABASE_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QHash>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QCursor;
|
||||
class QWidget;
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
|
||||
class QDesignerMetaDataBaseItemInterface
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerMetaDataBaseItemInterface() {}
|
||||
|
||||
virtual QString name() const = 0;
|
||||
virtual void setName(const QString &name) = 0;
|
||||
|
||||
virtual QList<QWidget*> tabOrder() const = 0;
|
||||
virtual void setTabOrder(const QList<QWidget*> &tabOrder) = 0;
|
||||
|
||||
virtual bool enabled() const = 0;
|
||||
virtual void setEnabled(bool b) = 0;
|
||||
};
|
||||
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerMetaDataBaseInterface: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerMetaDataBaseInterface(QObject *parent = 0);
|
||||
virtual ~QDesignerMetaDataBaseInterface();
|
||||
|
||||
virtual QDesignerMetaDataBaseItemInterface *item(QObject *object) const = 0;
|
||||
virtual void add(QObject *object) = 0;
|
||||
virtual void remove(QObject *object) = 0;
|
||||
|
||||
virtual QList<QObject*> objects() const = 0;
|
||||
|
||||
virtual QDesignerFormEditorInterface *core() const = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void changed();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTMETADATABASE_H
|
||||
117
third/designer/lib/sdk/abstractnewformwidget.cpp
Normal file
117
third/designer/lib/sdk/abstractnewformwidget.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractnewformwidget_p.h"
|
||||
#include <newformwidget_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerNewFormWidgetInterface
|
||||
\since 4.5
|
||||
\internal
|
||||
|
||||
\brief QDesignerNewFormWidgetInterface provides an interface for chooser
|
||||
widgets that can be used within "New Form" dialogs and wizards.
|
||||
It presents the user with a list of choices taken from built-in
|
||||
templates, pre-defined template paths and suitable custom widgets.
|
||||
It provides a static creation function that returns \QD's
|
||||
implementation.
|
||||
|
||||
\inmodule QtDesigner
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QDesignerNewFormWidgetInterface object.
|
||||
*/
|
||||
|
||||
QDesignerNewFormWidgetInterface::QDesignerNewFormWidgetInterface(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the QDesignerNewFormWidgetInterface object.
|
||||
*/
|
||||
|
||||
QDesignerNewFormWidgetInterface::~QDesignerNewFormWidgetInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates an instance of the QDesignerNewFormWidgetInterface as a child
|
||||
of \a parent using \a core.
|
||||
*/
|
||||
|
||||
QDesignerNewFormWidgetInterface *QDesignerNewFormWidgetInterface::createNewFormWidget(QDesignerFormEditorInterface *core, QWidget *parent)
|
||||
{
|
||||
return new qdesigner_internal::NewFormWidget(core, parent);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerNewFormWidgetInterface::hasCurrentTemplate() const
|
||||
|
||||
Returns whether a form template is currently selected.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerNewFormWidgetInterface::currentTemplate(QString *errorMessage = 0)
|
||||
|
||||
Returns the contents of the currently selected template. If the method fails,
|
||||
an empty string is returned and \a errorMessage receives an error message.
|
||||
*/
|
||||
|
||||
// Signals
|
||||
|
||||
/*!
|
||||
\fn void QDesignerNewFormWidgetInterface::templateActivated()
|
||||
|
||||
This signal is emitted whenever the user activates a template by double-clicking.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerNewFormWidgetInterface::currentTemplateChanged(bool templateSelected)
|
||||
|
||||
This signal is emitted whenever the user changes the current template.
|
||||
\a templateSelected indicates whether a template is currently selected.
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
88
third/designer/lib/sdk/abstractnewformwidget_p.h
Normal file
88
third/designer/lib/sdk/abstractnewformwidget_p.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTNEWFORMWIDGET_H
|
||||
#define ABSTRACTNEWFORMWIDGET_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerNewFormWidgetInterface : public QWidget
|
||||
{
|
||||
Q_DISABLE_COPY(QDesignerNewFormWidgetInterface)
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QDesignerNewFormWidgetInterface(QWidget *parent = 0);
|
||||
virtual ~QDesignerNewFormWidgetInterface();
|
||||
|
||||
virtual bool hasCurrentTemplate() const = 0;
|
||||
virtual QString currentTemplate(QString *errorMessage = 0) = 0;
|
||||
|
||||
static QDesignerNewFormWidgetInterface *createNewFormWidget(QDesignerFormEditorInterface *core, QWidget *parent = 0);
|
||||
|
||||
Q_SIGNALS:
|
||||
void templateActivated();
|
||||
void currentTemplateChanged(bool templateSelected);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTNEWFORMWIDGET_H
|
||||
110
third/designer/lib/sdk/abstractobjectinspector.cpp
Normal file
110
third/designer/lib/sdk/abstractobjectinspector.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractobjectinspector.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerObjectInspectorInterface
|
||||
|
||||
\brief The QDesignerObjectInspectorInterface class allows you to
|
||||
change the focus of Qt Designer's object inspector.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
You can use the QDesignerObjectInspectorInterface to change the
|
||||
current form window selection. For example, when implementing a
|
||||
custom widget plugin:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractobjectinspector.cpp 0
|
||||
|
||||
The QDesignerObjectInspectorInterface class is not intended to be
|
||||
instantiated directly. You can retrieve an interface to \QD's
|
||||
object inspector using the
|
||||
QDesignerFormEditorInterface::objectInspector() function. A
|
||||
pointer to \QD's current QDesignerFormEditorInterface object (\c
|
||||
formEditor in the example above) is provided by the
|
||||
QDesignerCustomWidgetInterface::initialize() function's
|
||||
parameter. When implementing a custom widget plugin, you must
|
||||
subclass the QDesignerCustomWidgetInterface to expose your plugin
|
||||
to \QD.
|
||||
|
||||
The interface provides the core() function that you can use to
|
||||
retrieve a pointer to \QD's current QDesignerFormEditorInterface
|
||||
object, and the setFormWindow() function that enables you to
|
||||
change the current form window selection.
|
||||
|
||||
\sa QDesignerFormEditorInterface, QDesignerFormWindowInterface
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs an object inspector interface with the given \a parent
|
||||
and the specified window \a flags.
|
||||
*/
|
||||
QDesignerObjectInspectorInterface::QDesignerObjectInspectorInterface(QWidget *parent, Qt::WindowFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the object inspector interface.
|
||||
*/
|
||||
QDesignerObjectInspectorInterface::~QDesignerObjectInspectorInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a pointer to \QD's current QDesignerFormEditorInterface
|
||||
object.
|
||||
*/
|
||||
QDesignerFormEditorInterface *QDesignerObjectInspectorInterface::core() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QDesignerObjectInspectorInterface::setFormWindow(QDesignerFormWindowInterface *formWindow)
|
||||
|
||||
Sets the currently selected form window to \a formWindow.
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
73
third/designer/lib/sdk/abstractobjectinspector.h
Normal file
73
third/designer/lib/sdk/abstractobjectinspector.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTOBJECTINSPECTOR_H
|
||||
#define ABSTRACTOBJECTINSPECTOR_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
class QDesignerFormWindowInterface;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerObjectInspectorInterface: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerObjectInspectorInterface(QWidget *parent, Qt::WindowFlags flags = 0);
|
||||
virtual ~QDesignerObjectInspectorInterface();
|
||||
|
||||
virtual QDesignerFormEditorInterface *core() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void setFormWindow(QDesignerFormWindowInterface *formWindow) = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTOBJECTINSPECTOR_H
|
||||
79
third/designer/lib/sdk/abstractoptionspage_p.h
Normal file
79
third/designer/lib/sdk/abstractoptionspage_p.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTOPTIONSPAGE_P_H
|
||||
#define ABSTRACTOPTIONSPAGE_P_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QString;
|
||||
class QWidget;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerOptionsPageInterface
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerOptionsPageInterface() {}
|
||||
virtual QString name() const = 0;
|
||||
virtual QWidget *createPage(QWidget *parent) = 0;
|
||||
virtual void apply() = 0;
|
||||
virtual void finish() = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTOPTIONSPAGE_P_H
|
||||
113
third/designer/lib/sdk/abstractpromotioninterface.cpp
Normal file
113
third/designer/lib/sdk/abstractpromotioninterface.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractpromotioninterface.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QDesignerPromotionInterface::~QDesignerPromotionInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QDesignerPromotionInterface
|
||||
|
||||
\brief The QDesignerPromotionInterface provides functions for modifying
|
||||
the promoted classes in Designer.
|
||||
\inmodule QtDesigner
|
||||
\internal
|
||||
\since 4.3
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class QDesignerPromotionInterface::PromotedClass
|
||||
A pair of database items containing the base class and the promoted class.
|
||||
|
||||
\typedef QDesignerPromotionInterface::PromotedClasses
|
||||
A list of PromotedClass items.
|
||||
|
||||
virtual QDesignerPromotionInterface::PromotedClasses promotedClasses() const
|
||||
|
||||
Returns a list of promoted classes along with their base classes in alphabetical order.
|
||||
It can be used to populate tree models for editing promoted widgets.
|
||||
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QSet<QString> QDesignerPromotionInterface::referencedPromotedClassNames() const
|
||||
|
||||
Returns a set of promoted classed that are referenced by the currently opened forms.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerPromotionInterface::addPromotedClass(const QString &baseClass, const QString &className, const QString &includeFile, QString *errorMessage)
|
||||
|
||||
Add a promoted class named \a with the base class \a and include file \a includeFile. Returns \c true on success or \c false along
|
||||
with an error message in \a errorMessage on failure.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerPromotionInterface::removePromotedClass(const QString &className, QString *errorMessage)
|
||||
|
||||
Remove the promoted class named \a className unless it is referenced by a form. Returns \c true on success or \c false along
|
||||
with an error message in \a errorMessage on failure.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerPromotionInterface::changePromotedClassName(const QString &oldClassName, const QString &newClassName, QString *errorMessage)
|
||||
|
||||
Change the class name of a promoted class from \a oldClassName to \a newClassName. Returns \c true on success or \c false along
|
||||
with an error message in \a errorMessage on failure.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerPromotionInterface::setPromotedClassIncludeFile(const QString &className, const QString &includeFile, QString *errorMessage)
|
||||
|
||||
Change the include file of a promoted class named \a className to be \a includeFile. Returns \c true on success or \c false along
|
||||
with an error message in \a errorMessage on failure.
|
||||
*/
|
||||
|
||||
/*! \fn virtual QList<QDesignerWidgetDataBaseItemInterface *> QDesignerPromotionInterface::promotionBaseClasses() const
|
||||
|
||||
Return a list of base classes that are suitable for promotion.
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
91
third/designer/lib/sdk/abstractpromotioninterface.h
Normal file
91
third/designer/lib/sdk/abstractpromotioninterface.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTPROMOTIONINTERFACE_H
|
||||
#define ABSTRACTPROMOTIONINTERFACE_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtCore/QPair>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QSet>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerWidgetDataBaseItemInterface;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerPromotionInterface
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerPromotionInterface();
|
||||
|
||||
struct PromotedClass {
|
||||
QDesignerWidgetDataBaseItemInterface *baseItem;
|
||||
QDesignerWidgetDataBaseItemInterface *promotedItem;
|
||||
};
|
||||
|
||||
typedef QList<PromotedClass> PromotedClasses;
|
||||
|
||||
virtual PromotedClasses promotedClasses() const = 0;
|
||||
|
||||
virtual QSet<QString> referencedPromotedClassNames() const = 0;
|
||||
|
||||
virtual bool addPromotedClass(const QString &baseClass,
|
||||
const QString &className,
|
||||
const QString &includeFile,
|
||||
QString *errorMessage) = 0;
|
||||
|
||||
virtual bool removePromotedClass(const QString &className, QString *errorMessage) = 0;
|
||||
|
||||
virtual bool changePromotedClassName(const QString &oldClassName, const QString &newClassName, QString *errorMessage) = 0;
|
||||
|
||||
virtual bool setPromotedClassIncludeFile(const QString &className, const QString &includeFile, QString *errorMessage) = 0;
|
||||
|
||||
virtual QList<QDesignerWidgetDataBaseItemInterface *> promotionBaseClasses() const = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTPROMOTIONINTERFACE_H
|
||||
193
third/designer/lib/sdk/abstractpropertyeditor.cpp
Normal file
193
third/designer/lib/sdk/abstractpropertyeditor.cpp
Normal file
@@ -0,0 +1,193 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractpropertyeditor.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerPropertyEditorInterface
|
||||
|
||||
\brief The QDesignerPropertyEditorInterface class allows you to
|
||||
query and manipulate the current state of Qt Designer's property
|
||||
editor.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
QDesignerPropertyEditorInterface contains a collection of
|
||||
functions that is typically used to query the property editor for
|
||||
its current state, and several slots manipulating it's state. The
|
||||
interface also provide a signal, propertyChanged(), which is
|
||||
emitted whenever a property changes in the property editor. The
|
||||
signal's arguments are the property that changed and its new
|
||||
value.
|
||||
|
||||
For example, when implementing a custom widget plugin, you can
|
||||
connect the signal to a custom slot:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp 0
|
||||
|
||||
Then the custom slot can check if the new value is within the
|
||||
range we want when a specified property, belonging to a particular
|
||||
widget, changes:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp 1
|
||||
|
||||
The QDesignerPropertyEditorInterface class is not intended to be
|
||||
instantiated directly. You can retrieve an interface to \QD's
|
||||
property editor using the
|
||||
QDesignerFormEditorInterface::propertyEditor() function. A pointer
|
||||
to \QD's current QDesignerFormEditorInterface object (\c
|
||||
formEditor in the examples above) is provided by the
|
||||
QDesignerCustomWidgetInterface::initialize() function's
|
||||
parameter. When implementing a custom widget plugin, you must
|
||||
subclass the QDesignerCustomWidgetInterface to expose your plugin
|
||||
to \QD.
|
||||
|
||||
The functions accessing the property editor are the core()
|
||||
function that you can use to retrieve an interface to the form
|
||||
editor, the currentPropertyName() function that returns the name
|
||||
of the currently selected property in the property editor, the
|
||||
object() function that returns the currently selected object in
|
||||
\QD's workspace, and the isReadOnly() function that returns true
|
||||
if the property editor is write proteced (otherwise false).
|
||||
|
||||
The slots manipulating the property editor's state are the
|
||||
setObject() slot that you can use to change the currently selected
|
||||
object in \QD's workspace, the setPropertyValue() slot that
|
||||
changes the value of a given property and the setReadOnly() slot
|
||||
that control the write protection of the property editor.
|
||||
|
||||
\sa QDesignerFormEditorInterface
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a property editor interface with the given \a parent and
|
||||
the specified window \a flags.
|
||||
*/
|
||||
QDesignerPropertyEditorInterface::QDesignerPropertyEditorInterface(QWidget *parent, Qt::WindowFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the property editor interface.
|
||||
*/
|
||||
QDesignerPropertyEditorInterface::~QDesignerPropertyEditorInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a pointer to \QD's current QDesignerFormEditorInterface
|
||||
object.
|
||||
*/
|
||||
QDesignerFormEditorInterface *QDesignerPropertyEditorInterface::core() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerPropertyEditorInterface::isReadOnly() const
|
||||
|
||||
Returns true if the property editor is write protected; otherwise
|
||||
false.
|
||||
|
||||
\sa setReadOnly()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QObject *QDesignerPropertyEditorInterface::object() const
|
||||
|
||||
Returns the currently selected object in \QD's workspace.
|
||||
|
||||
\sa setObject()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerPropertyEditorInterface::currentPropertyName() const
|
||||
|
||||
Returns the name of the currently selected property in the
|
||||
property editor.
|
||||
|
||||
\sa setPropertyValue()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerPropertyEditorInterface::propertyChanged(const QString &name, const QVariant &value)
|
||||
|
||||
This signal is emitted whenever a property changes in the property
|
||||
editor. The property that changed and its new value are specified
|
||||
by \a name and \a value respectively.
|
||||
|
||||
\sa setPropertyValue()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerPropertyEditorInterface::setObject(QObject *object)
|
||||
|
||||
Changes the currently selected object in \QD's workspace, to \a
|
||||
object.
|
||||
|
||||
\sa object()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerPropertyEditorInterface::setPropertyValue(const QString &name, const QVariant &value, bool changed = true)
|
||||
|
||||
Sets the value of the property specified by \a name to \a
|
||||
value.
|
||||
|
||||
In addition, the property is marked as \a changed in the property
|
||||
editor, i.e. its value is different from the default value.
|
||||
|
||||
\sa currentPropertyName(), propertyChanged()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerPropertyEditorInterface::setReadOnly(bool readOnly)
|
||||
|
||||
If \a readOnly is true, the property editor is made write
|
||||
protected; otherwise the write protection is removed.
|
||||
|
||||
\sa isReadOnly()
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
84
third/designer/lib/sdk/abstractpropertyeditor.h
Normal file
84
third/designer/lib/sdk/abstractpropertyeditor.h
Normal 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ABSTRACTPROPERTYEDITOR_H
|
||||
#define ABSTRACTPROPERTYEDITOR_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
class QString;
|
||||
class QVariant;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerPropertyEditorInterface: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerPropertyEditorInterface(QWidget *parent, Qt::WindowFlags flags = 0);
|
||||
virtual ~QDesignerPropertyEditorInterface();
|
||||
|
||||
virtual QDesignerFormEditorInterface *core() const;
|
||||
|
||||
virtual bool isReadOnly() const = 0;
|
||||
virtual QObject *object() const = 0;
|
||||
|
||||
virtual QString currentPropertyName() const = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void propertyChanged(const QString &name, const QVariant &value);
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void setObject(QObject *object) = 0;
|
||||
virtual void setPropertyValue(const QString &name, const QVariant &value, bool changed = true) = 0;
|
||||
virtual void setReadOnly(bool readOnly) = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTPROPERTYEDITOR_H
|
||||
57
third/designer/lib/sdk/abstractresourcebrowser.cpp
Normal file
57
third/designer/lib/sdk/abstractresourcebrowser.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractresourcebrowser.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QDesignerResourceBrowserInterface::QDesignerResourceBrowserInterface(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QDesignerResourceBrowserInterface::~QDesignerResourceBrowserInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
75
third/designer/lib/sdk/abstractresourcebrowser.h
Normal file
75
third/designer/lib/sdk/abstractresourcebrowser.h
Normal 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 ABSTRACTRESOURCEBROWSER_H
|
||||
#define ABSTRACTRESOURCEBROWSER_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWidget; // FIXME: fool syncqt
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerResourceBrowserInterface: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerResourceBrowserInterface(QWidget *parent = 0);
|
||||
virtual ~QDesignerResourceBrowserInterface();
|
||||
|
||||
virtual void setCurrentPath(const QString &filePath) = 0;
|
||||
virtual QString currentPath() const = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void currentPathChanged(const QString &filePath);
|
||||
void pathActivated(const QString &filePath);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTFORMEDITOR_H
|
||||
|
||||
87
third/designer/lib/sdk/abstractsettings_p.h
Normal file
87
third/designer/lib/sdk/abstractsettings_p.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTSETTINGS_P_H
|
||||
#define ABSTRACTSETTINGS_P_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QString;
|
||||
|
||||
/*!
|
||||
To be implemented by IDEs that want to control the way designer retrieves/stores its settings.
|
||||
*/
|
||||
class QDESIGNER_SDK_EXPORT QDesignerSettingsInterface
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerSettingsInterface() {}
|
||||
|
||||
virtual void beginGroup(const QString &prefix) = 0;
|
||||
virtual void endGroup() = 0;
|
||||
|
||||
virtual bool contains(const QString &key) const = 0;
|
||||
virtual void setValue(const QString &key, const QVariant &value) = 0;
|
||||
virtual QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const = 0;
|
||||
virtual void remove(const QString &key) = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTSETTINGS_P_H
|
||||
340
third/designer/lib/sdk/abstractwidgetbox.cpp
Normal file
340
third/designer/lib/sdk/abstractwidgetbox.cpp
Normal file
@@ -0,0 +1,340 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractwidgetbox.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerWidgetBoxInterface
|
||||
|
||||
\brief The QDesignerWidgetBoxInterface class allows you to control
|
||||
the contents of Qt Designer's widget box.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
QDesignerWidgetBoxInterface contains a collection of functions
|
||||
that is typically used to manipulate the contents of \QD's widget
|
||||
box.
|
||||
|
||||
\QD uses an XML file to populate its widget box. The name of that
|
||||
file is one of the widget box's properties, and you can retrieve
|
||||
it using the fileName() function.
|
||||
|
||||
QDesignerWidgetBoxInterface also provides the save() function that
|
||||
saves the contents of the widget box in the file specified by the
|
||||
widget box's file name property. If you have made changes to the
|
||||
widget box, for example by dropping a widget into the widget box,
|
||||
without calling the save() function, the original content can be
|
||||
restored by a simple invocation of the load() function:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp 0
|
||||
|
||||
The QDesignerWidgetBoxInterface class is not intended to be
|
||||
instantiated directly. You can retrieve an interface to Qt
|
||||
Designer's widget box using the
|
||||
QDesignerFormEditorInterface::widgetBox() function. A pointer to
|
||||
\QD's current QDesignerFormEditorInterface object (\c formEditor
|
||||
in the example above) is provided by the
|
||||
QDesignerCustomWidgetInterface::initialize() function's
|
||||
parameter. When implementing a custom widget plugin, you must
|
||||
subclass the QDesignerCustomWidgetInterface to expose your plugin
|
||||
to \QD.
|
||||
|
||||
If you want to save your changes, and at the same time preserve
|
||||
the original contents, you can use the save() function combined
|
||||
with the setFileName() function to save your changes into another
|
||||
file. Remember to store the name of the original file first:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp 1
|
||||
|
||||
Then you can restore the original contents of the widget box by
|
||||
resetting the file name to the original file and calling load():
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp 2
|
||||
|
||||
In a similar way, you can later use your customized XML file:
|
||||
|
||||
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp 3
|
||||
|
||||
|
||||
\sa QDesignerFormEditorInterface
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a widget box interface with the given \a parent and
|
||||
the specified window \a flags.
|
||||
*/
|
||||
QDesignerWidgetBoxInterface::QDesignerWidgetBoxInterface(QWidget *parent, Qt::WindowFlags flags)
|
||||
: QWidget(parent, flags)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the widget box interface.
|
||||
*/
|
||||
QDesignerWidgetBoxInterface::~QDesignerWidgetBoxInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
int QDesignerWidgetBoxInterface::findOrInsertCategory(const QString &categoryName)
|
||||
{
|
||||
int count = categoryCount();
|
||||
for (int index=0; index<count; ++index) {
|
||||
Category c = category(index);
|
||||
if (c.name() == categoryName)
|
||||
return index;
|
||||
}
|
||||
|
||||
addCategory(Category(categoryName));
|
||||
return count;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\fn int QDesignerWidgetBoxInterface::categoryCount() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\fn Category QDesignerWidgetBoxInterface::category(int cat_idx) const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\fn void QDesignerWidgetBoxInterface::addCategory(const Category &cat)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\fn void QDesignerWidgetBoxInterface::removeCategory(int cat_idx)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\fn int QDesignerWidgetBoxInterface::widgetCount(int cat_idx) const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\fn Widget QDesignerWidgetBoxInterface::widget(int cat_idx, int wgt_idx) const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\fn void QDesignerWidgetBoxInterface::addWidget(int cat_idx, const Widget &wgt)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\fn void QDesignerWidgetBoxInterface::removeWidget(int cat_idx, int wgt_idx)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\fn void QDesignerWidgetBoxInterface::dropWidgets(const QList<QDesignerDnDItemInterface*> &item_list, const QPoint &global_mouse_pos)
|
||||
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerWidgetBoxInterface::setFileName(const QString &fileName)
|
||||
|
||||
Sets the XML file that \QD will use to populate its widget box, to
|
||||
\a fileName. You must call load() to update the widget box with
|
||||
the new XML file.
|
||||
|
||||
\sa fileName(), load()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerWidgetBoxInterface::fileName() const
|
||||
|
||||
Returns the name of the XML file \QD is currently using to
|
||||
populate its widget box.
|
||||
|
||||
\sa setFileName()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerWidgetBoxInterface::load()
|
||||
|
||||
Populates \QD's widget box by loading (or reloading) the currently
|
||||
specified XML file. Returns true if the file is successfully
|
||||
loaded; otherwise false.
|
||||
|
||||
\sa setFileName()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerWidgetBoxInterface::save()
|
||||
|
||||
Saves the contents of \QD's widget box in the file specified by
|
||||
the fileName() function. Returns true if the content is
|
||||
successfully saved; otherwise false.
|
||||
|
||||
\sa fileName(), setFileName()
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
\class QDesignerWidgetBoxInterface::Widget
|
||||
|
||||
\brief The Widget class specified a widget in Qt Designer's widget
|
||||
box component.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDesignerWidgetBoxInterface::Widget::Type
|
||||
|
||||
\value Default
|
||||
\value Custom
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerWidgetBoxInterface::Widget::Widget(const QString &aname, const QString &xml, const QString &icon_name, Type atype)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerWidgetBoxInterface::Widget::name() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerWidgetBoxInterface::Widget::setName(const QString &aname)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerWidgetBoxInterface::Widget::domXml() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerWidgetBoxInterface::Widget::setDomXml(const QString &xml)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerWidgetBoxInterface::Widget::iconName() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerWidgetBoxInterface::Widget::setIconName(const QString &icon_name)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn Type QDesignerWidgetBoxInterface::Widget::type() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerWidgetBoxInterface::Widget::setType(Type atype)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerWidgetBoxInterface::Widget::isNull() const
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\class QDesignerWidgetBoxInterface::Category
|
||||
\brief The Category class specifies a category in Qt Designer's widget box component.
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDesignerWidgetBoxInterface::Category::Type
|
||||
|
||||
\value Default
|
||||
\value Scratchpad
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerWidgetBoxInterface::Category::Category(const QString &aname, Type atype)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerWidgetBoxInterface::Category::name() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerWidgetBoxInterface::Category::setName(const QString &aname)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerWidgetBoxInterface::Category::widgetCount() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn Widget QDesignerWidgetBoxInterface::Category::widget(int idx) const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerWidgetBoxInterface::Category::removeWidget(int idx)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerWidgetBoxInterface::Category::addWidget(const Widget &awidget)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn Type QDesignerWidgetBoxInterface::Category::type() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerWidgetBoxInterface::Category::setType(Type atype)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerWidgetBoxInterface::Category::isNull() const
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typedef QDesignerWidgetBoxInterface::CategoryList
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typedef QDesignerWidgetBoxInterface::WidgetList
|
||||
\internal
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
142
third/designer/lib/sdk/abstractwidgetbox.h
Normal file
142
third/designer/lib/sdk/abstractwidgetbox.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTWIDGETBOX_H
|
||||
#define ABSTRACTWIDGETBOX_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtCore/QMetaType>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class DomUI;
|
||||
class QDesignerDnDItemInterface;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerWidgetBoxInterface : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
class Widget {
|
||||
public:
|
||||
enum Type { Default, Custom };
|
||||
Widget(const QString &aname = QString(), const QString &xml = QString(),
|
||||
const QString &icon_name = QString(), Type atype = Default)
|
||||
: m_name(aname), m_xml(xml), m_icon_name(icon_name), m_type(atype) {}
|
||||
QString name() const { return m_name; }
|
||||
void setName(const QString &aname) { m_name = aname; }
|
||||
QString domXml() const { return m_xml; }
|
||||
void setDomXml(const QString &xml) { m_xml = xml; }
|
||||
QString iconName() const { return m_icon_name; }
|
||||
void setIconName(const QString &icon_name) { m_icon_name = icon_name; }
|
||||
Type type() const { return m_type; }
|
||||
void setType(Type atype) { m_type = atype; }
|
||||
|
||||
bool isNull() const { return m_name.isEmpty(); }
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
QString m_xml;
|
||||
QString m_icon_name;
|
||||
Type m_type;
|
||||
};
|
||||
typedef QList<Widget> WidgetList;
|
||||
|
||||
class Category {
|
||||
public:
|
||||
enum Type { Default, Scratchpad };
|
||||
|
||||
Category(const QString &aname = QString(), Type atype = Default)
|
||||
: m_name(aname), m_type(atype) {}
|
||||
|
||||
QString name() const { return m_name; }
|
||||
void setName(const QString &aname) { m_name = aname; }
|
||||
int widgetCount() const { return m_widget_list.size(); }
|
||||
Widget widget(int idx) const { return m_widget_list.at(idx); }
|
||||
void removeWidget(int idx) { m_widget_list.removeAt(idx); }
|
||||
void addWidget(const Widget &awidget) { m_widget_list.append(awidget); }
|
||||
Type type() const { return m_type; }
|
||||
void setType(Type atype) { m_type = atype; }
|
||||
|
||||
bool isNull() const { return m_name.isEmpty(); }
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
Type m_type;
|
||||
QList<Widget> m_widget_list;
|
||||
};
|
||||
typedef QList<Category> CategoryList;
|
||||
|
||||
QDesignerWidgetBoxInterface(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
virtual ~QDesignerWidgetBoxInterface();
|
||||
|
||||
virtual int categoryCount() const = 0;
|
||||
virtual Category category(int cat_idx) const = 0;
|
||||
virtual void addCategory(const Category &cat) = 0;
|
||||
virtual void removeCategory(int cat_idx) = 0;
|
||||
|
||||
virtual int widgetCount(int cat_idx) const = 0;
|
||||
virtual Widget widget(int cat_idx, int wgt_idx) const = 0;
|
||||
virtual void addWidget(int cat_idx, const Widget &wgt) = 0;
|
||||
virtual void removeWidget(int cat_idx, int wgt_idx) = 0;
|
||||
|
||||
int findOrInsertCategory(const QString &categoryName);
|
||||
|
||||
virtual void dropWidgets(const QList<QDesignerDnDItemInterface*> &item_list,
|
||||
const QPoint &global_mouse_pos) = 0;
|
||||
|
||||
virtual void setFileName(const QString &file_name) = 0;
|
||||
virtual QString fileName() const = 0;
|
||||
virtual bool load() = 0;
|
||||
virtual bool save() = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QDesignerWidgetBoxInterface::Widget))
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTWIDGETBOX_H
|
||||
360
third/designer/lib/sdk/abstractwidgetdatabase.cpp
Normal file
360
third/designer/lib/sdk/abstractwidgetdatabase.cpp
Normal file
@@ -0,0 +1,360 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractwidgetdatabase.h"
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <qalgorithms.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace {
|
||||
enum { debugWidgetDataBase = 0 };
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QDesignerWidgetDataBaseInterface
|
||||
\brief The QDesignerWidgetDataBaseInterface class provides an interface that is used to
|
||||
access and modify Qt Designer's widget database.
|
||||
\inmodule QtDesigner
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs an interface to the widget database with the given \a parent.
|
||||
*/
|
||||
QDesignerWidgetDataBaseInterface::QDesignerWidgetDataBaseInterface(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the interface to the widget database.
|
||||
*/
|
||||
QDesignerWidgetDataBaseInterface::~QDesignerWidgetDataBaseInterface()
|
||||
{
|
||||
qDeleteAll(m_items);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
int QDesignerWidgetDataBaseInterface::count() const
|
||||
{
|
||||
return m_items.count();
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
QDesignerWidgetDataBaseItemInterface *QDesignerWidgetDataBaseInterface::item(int index) const
|
||||
{
|
||||
return index != -1 ? m_items.at(index) : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
int QDesignerWidgetDataBaseInterface::indexOf(QDesignerWidgetDataBaseItemInterface *item) const
|
||||
{
|
||||
return m_items.indexOf(item);
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
void QDesignerWidgetDataBaseInterface::insert(int index, QDesignerWidgetDataBaseItemInterface *item)
|
||||
{
|
||||
if (debugWidgetDataBase)
|
||||
qDebug() << "insert at " << index << ' ' << item->name() << " derived from " << item->extends();
|
||||
|
||||
m_items.insert(index, item);
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
void QDesignerWidgetDataBaseInterface::append(QDesignerWidgetDataBaseItemInterface *item)
|
||||
{
|
||||
if (debugWidgetDataBase)
|
||||
qDebug() << "append " << item->name() << " derived from " << item->extends();
|
||||
m_items.append(item);
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
QDesignerFormEditorInterface *QDesignerWidgetDataBaseInterface::core() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
int QDesignerWidgetDataBaseInterface::indexOfClassName(const QString &name, bool) const
|
||||
{
|
||||
const int itemCount = count();
|
||||
for (int i=0; i<itemCount; ++i) {
|
||||
const QDesignerWidgetDataBaseItemInterface *entry = item(i);
|
||||
if (entry->name() == name)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
int QDesignerWidgetDataBaseInterface::indexOfObject(QObject *object, bool) const
|
||||
{
|
||||
if (!object)
|
||||
return -1;
|
||||
|
||||
const QString className = QString::fromUtf8(object->metaObject()->className());
|
||||
return indexOfClassName(className);
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
bool QDesignerWidgetDataBaseInterface::isContainer(QObject *object, bool resolveName) const
|
||||
{
|
||||
if (const QDesignerWidgetDataBaseItemInterface *i = item(indexOfObject(object, resolveName)))
|
||||
return i->isContainer();
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
*/
|
||||
bool QDesignerWidgetDataBaseInterface::isCustom(QObject *object, bool resolveName) const
|
||||
{
|
||||
if (const QDesignerWidgetDataBaseItemInterface *i = item(indexOfObject(object, resolveName)))
|
||||
return i->isCustom();
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QDesignerWidgetDataBaseInterface::changed()
|
||||
|
||||
This signal is emitted ...
|
||||
*/
|
||||
|
||||
|
||||
// Doc: No implementation - an abstract class
|
||||
|
||||
/*!
|
||||
\class QDesignerWidgetDataBaseItemInterface
|
||||
\brief The QDesignerWidgetDataBaseItemInterface class provides an interface that is used to
|
||||
access individual items in Qt Designer's widget database.
|
||||
\inmodule QtDesigner
|
||||
\internal
|
||||
|
||||
This class enables individual items in the widget database to be accessed and modified.
|
||||
Changes to the widget database itself are made through the QDesignerWidgetDataBaseInterface
|
||||
class.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerWidgetDataBaseItemInterface::~QDesignerWidgetDataBaseItemInterface()
|
||||
|
||||
Destroys the interface.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerWidgetDataBaseItemInterface::name() const = 0
|
||||
|
||||
Returns the name of the widget.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetDataBaseItemInterface::setName(const QString &name) = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerWidgetDataBaseItemInterface::group() const = 0
|
||||
|
||||
Returns the name of the group that the widget belongs to.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetDataBaseItemInterface::setGroup(const QString &group) = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerWidgetDataBaseItemInterface::toolTip() const = 0
|
||||
|
||||
Returns the tool tip to be used by the widget.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetDataBaseItemInterface::setToolTip(const QString &toolTip) = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerWidgetDataBaseItemInterface::whatsThis() const = 0
|
||||
|
||||
Returns the "What's This?" help for the widget.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetDataBaseItemInterface::setWhatsThis(const QString &whatsThis) = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerWidgetDataBaseItemInterface::includeFile() const = 0
|
||||
|
||||
Returns the name of the include file that the widget needs when being built from source.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetDataBaseItemInterface::setIncludeFile(const QString &includeFile) = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QIcon QDesignerWidgetDataBaseItemInterface::icon() const = 0
|
||||
|
||||
Returns the icon used to represent the item.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetDataBaseItemInterface::setIcon(const QIcon &icon) = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerWidgetDataBaseItemInterface::isCompat() const = 0
|
||||
|
||||
Returns true if this type of widget is provided for compatibility purposes (e.g. Qt3Support
|
||||
widgets); otherwise returns false.
|
||||
|
||||
\sa setCompat()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetDataBaseItemInterface::setCompat(bool compat) = 0
|
||||
|
||||
If \a compat is true, the widget is handled as a compatibility widget; otherwise it is
|
||||
handled normally by \QD.
|
||||
|
||||
\sa isCompat()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerWidgetDataBaseItemInterface::isContainer() const = 0
|
||||
|
||||
Returns true if this widget is intended to be used to hold other widgets; otherwise returns
|
||||
false.
|
||||
|
||||
\sa setContainer()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetDataBaseItemInterface::setContainer(bool container) = 0
|
||||
|
||||
If \a container is true, the widget can be used to hold other widgets in \QD; otherwise
|
||||
\QD will refuse to let the user place other widgets inside it.
|
||||
|
||||
\sa isContainer()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerWidgetDataBaseItemInterface::isCustom() const = 0
|
||||
|
||||
Returns true if the widget is a custom widget; otherwise return false if it is a standard
|
||||
Qt widget.
|
||||
|
||||
\sa setCustom()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetDataBaseItemInterface::setCustom(bool custom) = 0
|
||||
|
||||
If \a custom is true, the widget is handled specially by \QD; otherwise it is handled as
|
||||
a standard Qt widget.
|
||||
|
||||
\sa isCustom()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerWidgetDataBaseItemInterface::pluginPath() const = 0
|
||||
|
||||
Returns the path to use for the widget plugin.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetDataBaseItemInterface::setPluginPath(const QString &path) = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerWidgetDataBaseItemInterface::isPromoted() const = 0
|
||||
|
||||
Returns true if the widget is promoted; otherwise returns false.
|
||||
|
||||
Promoted widgets are those that represent custom widgets, but which are represented in
|
||||
\QD by either standard Qt widgets or readily-available custom widgets.
|
||||
|
||||
\sa setPromoted()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetDataBaseItemInterface::setPromoted(bool promoted) = 0
|
||||
|
||||
If \a promoted is true, the widget is handled as a promoted widget by \QD and will use
|
||||
a placeholder widget to represent it; otherwise it is handled as a standard widget.
|
||||
|
||||
\sa isPromoted()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerWidgetDataBaseItemInterface::extends() const = 0
|
||||
|
||||
Returns the name of the widget that the item extends.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetDataBaseItemInterface::setExtends(const QString &s) = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetDataBaseItemInterface::setDefaultPropertyValues(const QList<QVariant> &list) = 0
|
||||
|
||||
Sets the default property values for the widget to the given \a list.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QList<QVariant> QDesignerWidgetDataBaseItemInterface::defaultPropertyValues() const = 0
|
||||
|
||||
Returns a list of default values to be used as properties for the item.
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
137
third/designer/lib/sdk/abstractwidgetdatabase.h
Normal file
137
third/designer/lib/sdk/abstractwidgetdatabase.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTWIDGETDATABASE_H
|
||||
#define ABSTRACTWIDGETDATABASE_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QList>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QIcon;
|
||||
class QString;
|
||||
class QDesignerFormEditorInterface;
|
||||
class QDebug;
|
||||
|
||||
class QDesignerWidgetDataBaseItemInterface
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerWidgetDataBaseItemInterface() {}
|
||||
|
||||
virtual QString name() const = 0;
|
||||
virtual void setName(const QString &name) = 0;
|
||||
|
||||
virtual QString group() const = 0;
|
||||
virtual void setGroup(const QString &group) = 0;
|
||||
|
||||
virtual QString toolTip() const = 0;
|
||||
virtual void setToolTip(const QString &toolTip) = 0;
|
||||
|
||||
virtual QString whatsThis() const = 0;
|
||||
virtual void setWhatsThis(const QString &whatsThis) = 0;
|
||||
|
||||
virtual QString includeFile() const = 0;
|
||||
virtual void setIncludeFile(const QString &includeFile) = 0;
|
||||
|
||||
virtual QIcon icon() const = 0;
|
||||
virtual void setIcon(const QIcon &icon) = 0;
|
||||
|
||||
virtual bool isCompat() const = 0;
|
||||
virtual void setCompat(bool compat) = 0;
|
||||
|
||||
virtual bool isContainer() const = 0;
|
||||
virtual void setContainer(bool container) = 0;
|
||||
|
||||
virtual bool isCustom() const = 0;
|
||||
virtual void setCustom(bool custom) = 0;
|
||||
|
||||
virtual QString pluginPath() const = 0;
|
||||
virtual void setPluginPath(const QString &path) = 0;
|
||||
|
||||
virtual bool isPromoted() const = 0;
|
||||
virtual void setPromoted(bool b) = 0;
|
||||
|
||||
virtual QString extends() const = 0;
|
||||
virtual void setExtends(const QString &s) = 0;
|
||||
|
||||
virtual void setDefaultPropertyValues(const QList<QVariant> &list) = 0;
|
||||
virtual QList<QVariant> defaultPropertyValues() const = 0;
|
||||
};
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerWidgetDataBaseInterface: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerWidgetDataBaseInterface(QObject *parent = 0);
|
||||
virtual ~QDesignerWidgetDataBaseInterface();
|
||||
|
||||
virtual int count() const;
|
||||
virtual QDesignerWidgetDataBaseItemInterface *item(int index) const;
|
||||
|
||||
virtual int indexOf(QDesignerWidgetDataBaseItemInterface *item) const;
|
||||
virtual void insert(int index, QDesignerWidgetDataBaseItemInterface *item);
|
||||
virtual void append(QDesignerWidgetDataBaseItemInterface *item);
|
||||
|
||||
virtual int indexOfObject(QObject *object, bool resolveName = true) const;
|
||||
virtual int indexOfClassName(const QString &className, bool resolveName = true) const;
|
||||
|
||||
virtual QDesignerFormEditorInterface *core() const;
|
||||
|
||||
bool isContainer(QObject *object, bool resolveName = true) const;
|
||||
bool isCustom(QObject *object, bool resolveName = true) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void changed();
|
||||
|
||||
protected:
|
||||
QList<QDesignerWidgetDataBaseItemInterface *> m_items;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTWIDGETDATABASE_H
|
||||
112
third/designer/lib/sdk/abstractwidgetfactory.cpp
Normal file
112
third/designer/lib/sdk/abstractwidgetfactory.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 <QtDesigner/abstractwidgetfactory.h>
|
||||
#include "abstractformeditor.h"
|
||||
#include "abstractwidgetdatabase.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerWidgetFactoryInterface
|
||||
\brief The QDesignerWidgetFactoryInterface class provides an interface that is used to control
|
||||
the widget factory used by Qt Designer.
|
||||
\inmodule QtDesigner
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerWidgetFactoryInterface::QDesignerWidgetFactoryInterface(QObject *parent)
|
||||
|
||||
Constructs an interface to a widget factory with the given \a parent.
|
||||
*/
|
||||
QDesignerWidgetFactoryInterface::QDesignerWidgetFactoryInterface(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerWidgetFactoryInterface::~QDesignerWidgetFactoryInterface()
|
||||
*/
|
||||
QDesignerWidgetFactoryInterface::~QDesignerWidgetFactoryInterface()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerFormEditorInterface *QDesignerWidgetFactoryInterface::core() const = 0
|
||||
|
||||
Returns the core form editor interface associated with this interface.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QWidget* QDesignerWidgetFactoryInterface::containerOfWidget(QWidget *child) const = 0
|
||||
|
||||
Returns the widget that contains the specified \a child widget.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QWidget* QDesignerWidgetFactoryInterface::widgetOfContainer(QWidget *container) const = 0
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QWidget *QDesignerWidgetFactoryInterface::createWidget(const QString &name, QWidget *parent) const = 0
|
||||
|
||||
Returns a new widget with the given \a name and \a parent widget. If no parent is specified,
|
||||
the widget created will be a top-level widget.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QLayout *QDesignerWidgetFactoryInterface::createLayout(QWidget *widget, QLayout *layout, int type) const = 0
|
||||
|
||||
Returns a new layout of the specified \a type for the given \a widget or \a layout.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerWidgetFactoryInterface::isPassiveInteractor(QWidget *widget) = 0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerWidgetFactoryInterface::initialize(QObject *object) const = 0
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
79
third/designer/lib/sdk/abstractwidgetfactory.h
Normal file
79
third/designer/lib/sdk/abstractwidgetfactory.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ABSTRACTWIDGETFACTORY_H
|
||||
#define ABSTRACTWIDGETFACTORY_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
#include <QtCore/QObject>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
class QWidget;
|
||||
class QLayout;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerWidgetFactoryInterface: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDesignerWidgetFactoryInterface(QObject *parent = 0);
|
||||
virtual ~QDesignerWidgetFactoryInterface();
|
||||
|
||||
virtual QDesignerFormEditorInterface *core() const = 0;
|
||||
|
||||
virtual QWidget* containerOfWidget(QWidget *w) const = 0;
|
||||
virtual QWidget* widgetOfContainer(QWidget *w) const = 0;
|
||||
|
||||
virtual QWidget *createWidget(const QString &name, QWidget *parentWidget = 0) const = 0;
|
||||
virtual QLayout *createLayout(QWidget *widget, QLayout *layout, int type) const = 0;
|
||||
|
||||
virtual bool isPassiveInteractor(QWidget *widget) = 0;
|
||||
virtual void initialize(QObject *object) const = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // ABSTRACTWIDGETFACTORY_H
|
||||
81
third/designer/lib/sdk/dynamicpropertysheet.h
Normal file
81
third/designer/lib/sdk/dynamicpropertysheet.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 DYNAMICPROPERTYSHEET_H
|
||||
#define DYNAMICPROPERTYSHEET_H
|
||||
|
||||
#include <QtDesigner/extension.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QString; // FIXME: fool syncqt
|
||||
|
||||
class QDesignerDynamicPropertySheetExtension
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerDynamicPropertySheetExtension() {}
|
||||
|
||||
virtual bool dynamicPropertiesAllowed() const = 0;
|
||||
virtual int addDynamicProperty(const QString &propertyName, const QVariant &value) = 0;
|
||||
virtual bool removeDynamicProperty(int index) = 0;
|
||||
virtual bool isDynamicProperty(int index) const = 0;
|
||||
virtual bool canAddDynamicProperty(const QString &propertyName) const = 0;
|
||||
};
|
||||
Q_DECLARE_EXTENSION_INTERFACE(QDesignerDynamicPropertySheetExtension, "com.trolltech.Qt.Designer.DynamicPropertySheet")
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // DYNAMICPROPERTYSHEET_H
|
||||
80
third/designer/lib/sdk/dynamicpropertysheet.qdoc
Normal file
80
third/designer/lib/sdk/dynamicpropertysheet.qdoc
Normal file
@@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 QDesignerDynamicPropertySheetExtension
|
||||
|
||||
\brief The QDesignerDynamicPropertySheetExtension class allows you to
|
||||
manipulate a widget's dynamic properties in Qt Designer's property editor.
|
||||
|
||||
\sa QDesignerPropertySheetExtension, {QObject#Dynamic Properties}{Dynamic Properties}
|
||||
|
||||
\inmodule QtDesigner
|
||||
\since 4.3
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerDynamicPropertySheetExtension::~QDesignerDynamicPropertySheetExtension()
|
||||
|
||||
Destroys the dynamic property sheet extension.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerDynamicPropertySheetExtension::dynamicPropertiesAllowed() const
|
||||
|
||||
Returns true if the widget supports dynamic properties; otherwise returns false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerDynamicPropertySheetExtension::addDynamicProperty(const QString &propertyName, const QVariant &value)
|
||||
|
||||
Adds a dynamic property named \a propertyName and sets its value to \a value.
|
||||
Returns the index of the property if it was added successfully; otherwise returns -1 to
|
||||
indicate failure.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerDynamicPropertySheetExtension::removeDynamicProperty(int index)
|
||||
|
||||
Removes the dynamic property at the given \a index.
|
||||
Returns true if the operation succeeds; otherwise returns false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerDynamicPropertySheetExtension::isDynamicProperty(int index) const
|
||||
|
||||
Returns true if the property at the given \a index is a dynamic property; otherwise
|
||||
returns false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerDynamicPropertySheetExtension::canAddDynamicProperty(const QString &propertyName) const
|
||||
|
||||
Returns true if \a propertyName is a valid, unique name for a dynamic
|
||||
property; otherwise returns false.
|
||||
|
||||
*/
|
||||
116
third/designer/lib/sdk/extrainfo.cpp
Normal file
116
third/designer/lib/sdk/extrainfo.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "extrainfo.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerExtraInfoExtension
|
||||
\brief The QDesignerExtraInfoExtension class provides extra information about a widget in
|
||||
Qt Designer.
|
||||
\inmodule QtDesigner
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the path to the working directory used by this extension.*/
|
||||
QString QDesignerExtraInfoExtension::workingDirectory() const
|
||||
{
|
||||
return m_workingDirectory;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the path to the working directory used by the extension to \a workingDirectory.*/
|
||||
void QDesignerExtraInfoExtension::setWorkingDirectory(const QString &workingDirectory)
|
||||
{
|
||||
m_workingDirectory = workingDirectory;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerExtraInfoExtension::~QDesignerExtraInfoExtension()
|
||||
|
||||
Destroys the extension.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerFormEditorInterface *QDesignerExtraInfoExtension::core() const = 0
|
||||
|
||||
\omit
|
||||
### Description required
|
||||
\endomit
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QWidget *QDesignerExtraInfoExtension::widget() const = 0
|
||||
|
||||
Returns the widget described by this extension.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerExtraInfoExtension::saveUiExtraInfo(DomUI *ui) = 0
|
||||
|
||||
Saves the information about the user interface specified by \a ui, and returns true if
|
||||
successful; otherwise returns false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerExtraInfoExtension::loadUiExtraInfo(DomUI *ui) = 0
|
||||
|
||||
Loads extra information about the user interface specified by \a ui, and returns true if
|
||||
successful; otherwise returns false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerExtraInfoExtension::saveWidgetExtraInfo(DomWidget *widget) = 0
|
||||
|
||||
Saves the information about the specified \a widget, and returns true if successful;
|
||||
otherwise returns false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerExtraInfoExtension::loadWidgetExtraInfo(DomWidget *widget) = 0
|
||||
|
||||
Loads extra information about the specified \a widget, and returns true if successful;
|
||||
otherwise returns false.
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
84
third/designer/lib/sdk/extrainfo.h
Normal file
84
third/designer/lib/sdk/extrainfo.h
Normal 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef EXTRAINFO_H
|
||||
#define EXTRAINFO_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
#include <QtDesigner/extension.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class DomWidget;
|
||||
class DomUI;
|
||||
class QWidget;
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerExtraInfoExtension
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerExtraInfoExtension() {}
|
||||
|
||||
virtual QDesignerFormEditorInterface *core() const = 0;
|
||||
virtual QWidget *widget() const = 0;
|
||||
|
||||
virtual bool saveUiExtraInfo(DomUI *ui) = 0;
|
||||
virtual bool loadUiExtraInfo(DomUI *ui) = 0;
|
||||
|
||||
virtual bool saveWidgetExtraInfo(DomWidget *ui_widget) = 0;
|
||||
virtual bool loadWidgetExtraInfo(DomWidget *ui_widget) = 0;
|
||||
|
||||
QString workingDirectory() const;
|
||||
void setWorkingDirectory(const QString &workingDirectory);
|
||||
|
||||
private:
|
||||
QString m_workingDirectory;
|
||||
};
|
||||
Q_DECLARE_EXTENSION_INTERFACE(QDesignerExtraInfoExtension, "com.trolltech.Qt.Designer.ExtraInfo.2")
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // EXTRAINFO_H
|
||||
99
third/designer/lib/sdk/layoutdecoration.h
Normal file
99
third/designer/lib/sdk/layoutdecoration.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 LAYOUTDECORATION_H
|
||||
#define LAYOUTDECORATION_H
|
||||
|
||||
#include <QtDesigner/extension.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QPair>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QPoint;
|
||||
class QLayoutItem;
|
||||
class QWidget;
|
||||
class QRect;
|
||||
class QLayout;
|
||||
|
||||
class QDesignerLayoutDecorationExtension
|
||||
{
|
||||
public:
|
||||
enum InsertMode
|
||||
{
|
||||
InsertWidgetMode,
|
||||
InsertRowMode,
|
||||
InsertColumnMode
|
||||
};
|
||||
|
||||
virtual ~QDesignerLayoutDecorationExtension() {}
|
||||
|
||||
virtual QList<QWidget*> widgets(QLayout *layout) const = 0;
|
||||
|
||||
virtual QRect itemInfo(int index) const = 0;
|
||||
virtual int indexOf(QWidget *widget) const = 0;
|
||||
virtual int indexOf(QLayoutItem *item) const = 0;
|
||||
|
||||
virtual InsertMode currentInsertMode() const = 0;
|
||||
virtual int currentIndex() const = 0;
|
||||
virtual QPair<int, int> currentCell() const = 0;
|
||||
virtual void insertWidget(QWidget *widget, const QPair<int, int> &cell) = 0;
|
||||
virtual void removeWidget(QWidget *widget) = 0;
|
||||
|
||||
virtual void insertRow(int row) = 0;
|
||||
virtual void insertColumn(int column) = 0;
|
||||
virtual void simplify() = 0;
|
||||
|
||||
virtual int findItemAt(const QPoint &pos) const = 0;
|
||||
virtual int findItemAt(int row, int column) const = 0; // atm only for grid.
|
||||
|
||||
virtual void adjustIndicator(const QPoint &pos, int index) = 0;
|
||||
};
|
||||
Q_DECLARE_EXTENSION_INTERFACE(QDesignerLayoutDecorationExtension, "com.trolltech.Qt.Designer.LayoutDecoration")
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // LAYOUTDECORATION_H
|
||||
149
third/designer/lib/sdk/layoutdecoration.qdoc
Normal file
149
third/designer/lib/sdk/layoutdecoration.qdoc
Normal file
@@ -0,0 +1,149 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 QDesignerLayoutDecorationExtension
|
||||
\brief The QDesignerLayoutDecorationExtension class provides an extension to a layout in \QD.
|
||||
\inmodule QtDesigner
|
||||
\internal
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QDesignerLayoutDecorationExtension::InsertMode
|
||||
|
||||
This enum describes the modes that are used to insert items into a layout.
|
||||
|
||||
\value InsertWidgetMode Widgets are inserted into empty cells in a layout.
|
||||
\value InsertRowMode Whole rows are inserted into a vertical or grid layout.
|
||||
\value InsertColumnMode Whole columns are inserted into a horizontal or grid layout.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QDesignerLayoutDecorationExtension::~QDesignerLayoutDecorationExtension()
|
||||
|
||||
Destroys the extension.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QList<QWidget*> QDesignerLayoutDecorationExtension::widgets(QLayout *layout) const
|
||||
|
||||
Returns the widgets that are managed by the given \a layout.
|
||||
|
||||
\sa insertWidget(), removeWidget()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QRect QDesignerLayoutDecorationExtension::itemInfo(int index) const
|
||||
|
||||
Returns the rectangle covered by the item at the given \a index in the layout.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerLayoutDecorationExtension::indexOf(QWidget *widget) const
|
||||
|
||||
Returns the index of the specified \a widget in the layout.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerLayoutDecorationExtension::indexOf(QLayoutItem *item) const
|
||||
|
||||
Returns the index of the specified layout \a item.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerLayoutDecorationExtension::InsertMode QDesignerLayoutDecorationExtension::currentInsertMode() const
|
||||
|
||||
Returns the current insertion mode.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerLayoutDecorationExtension::currentIndex() const
|
||||
|
||||
Returns the current index in the layout.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QPair<int, int> QDesignerLayoutDecorationExtension::currentCell() const
|
||||
|
||||
Returns a pair containing the row and column of the current cell in the layout.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerLayoutDecorationExtension::insertWidget(QWidget *widget, const QPair<int, int> &cell)
|
||||
|
||||
Inserts the given \a widget into the specified \a cell in the layout.
|
||||
|
||||
\sa removeWidget()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerLayoutDecorationExtension::removeWidget(QWidget *widget)
|
||||
|
||||
Removes the specified \a widget from the layout.
|
||||
|
||||
\sa insertWidget()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerLayoutDecorationExtension::insertRow(int row)
|
||||
|
||||
Inserts a new row into the form at the position specified by \a row.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerLayoutDecorationExtension::insertColumn(int column)
|
||||
|
||||
Inserts a new column into the form at the position specified by \a column.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerLayoutDecorationExtension::simplify()
|
||||
|
||||
Simplifies the layout by removing unnecessary empty rows and columns, and by changing the
|
||||
number of rows or columns spanned by widgets.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerLayoutDecorationExtension::findItemAt(const QPoint &position) const
|
||||
|
||||
Returns the index of the item in the layout that covers the given \a position.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerLayoutDecorationExtension::findItemAt(int row, int column) const
|
||||
|
||||
Returns the item in the layout that occupies the specified \a row and \a column in the layout.
|
||||
|
||||
Currently, this only applies to grid layouts.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerLayoutDecorationExtension::adjustIndicator(const QPoint &position, int index)
|
||||
|
||||
Adjusts the indicator for the item specified by \a index so that
|
||||
it lies at the given \a position on the form.
|
||||
*/
|
||||
89
third/designer/lib/sdk/membersheet.h
Normal file
89
third/designer/lib/sdk/membersheet.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 MEMBERSHEET_H
|
||||
#define MEMBERSHEET_H
|
||||
|
||||
#include <QtDesigner/extension.h>
|
||||
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QByteArray>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QString; // FIXME: fool syncqt
|
||||
|
||||
class QDesignerMemberSheetExtension
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerMemberSheetExtension() {}
|
||||
|
||||
virtual int count() const = 0;
|
||||
|
||||
virtual int indexOf(const QString &name) const = 0;
|
||||
|
||||
virtual QString memberName(int index) const = 0;
|
||||
virtual QString memberGroup(int index) const = 0;
|
||||
virtual void setMemberGroup(int index, const QString &group) = 0;
|
||||
|
||||
virtual bool isVisible(int index) const = 0;
|
||||
virtual void setVisible(int index, bool b) = 0;
|
||||
|
||||
virtual bool isSignal(int index) const = 0;
|
||||
virtual bool isSlot(int index) const = 0;
|
||||
|
||||
virtual bool inheritedFromWidget(int index) const = 0;
|
||||
|
||||
virtual QString declaredInClass(int index) const = 0;
|
||||
|
||||
virtual QString signature(int index) const = 0;
|
||||
virtual QList<QByteArray> parameterTypes(int index) const = 0;
|
||||
virtual QList<QByteArray> parameterNames(int index) const = 0;
|
||||
};
|
||||
Q_DECLARE_EXTENSION_INTERFACE(QDesignerMemberSheetExtension, "com.trolltech.Qt.Designer.MemberSheet")
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // MEMBERSHEET_H
|
||||
249
third/designer/lib/sdk/membersheet.qdoc
Normal file
249
third/designer/lib/sdk/membersheet.qdoc
Normal file
@@ -0,0 +1,249 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 QDesignerMemberSheetExtension
|
||||
|
||||
\brief The QDesignerMemberSheetExtension class allows you to
|
||||
manipulate a widget's member functions which is displayed when
|
||||
configuring connections using Qt Designer's mode for editing
|
||||
signals and slots.
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
QDesignerMemberSheetExtension is a collection of functions that is
|
||||
typically used to query a widget's member functions, and to
|
||||
manipulate the member functions' appearance in \QD's signals and
|
||||
slots editing mode. For example:
|
||||
|
||||
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 2
|
||||
|
||||
When implementing a custom widget plugin, a pointer to \QD's
|
||||
current QDesignerFormEditorInterface object (\c formEditor in the
|
||||
example above) is provided by the
|
||||
QDesignerCustomWidgetInterface::initialize() function's parameter.
|
||||
|
||||
The member sheet (and any other extension), can be retrieved by
|
||||
querying \QD's extension manager using the qt_extension()
|
||||
function. When you want to release the extension, you only need to
|
||||
delete the pointer.
|
||||
|
||||
All widgets have a default member sheet used in \QD's signals and
|
||||
slots editing mode with the widget's member functions. But
|
||||
QDesignerMemberSheetExtension also provides an interface for
|
||||
creating custom member sheet extensions.
|
||||
|
||||
\warning \QD uses the QDesignerMemberSheetExtension to facilitate
|
||||
the signal and slot editing mode. Whenever a connection between
|
||||
two widgets is requested, \QD will query for the widgets' member
|
||||
sheet extensions. If a widget has an implemented member sheet
|
||||
extension, this extension will override the default member sheet.
|
||||
|
||||
To create a member sheet extension, your extension class must
|
||||
inherit from both QObject and QDesignerMemberSheetExtension. Then,
|
||||
since we are implementing an interface, we must ensure that it's
|
||||
made known to the meta object system using the Q_INTERFACES()
|
||||
macro:
|
||||
|
||||
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 3
|
||||
|
||||
This enables \QD to use qobject_cast() to query for
|
||||
supported interfaces using nothing but a QObject pointer.
|
||||
|
||||
In \QD the extensions are not created until they are
|
||||
required. For that reason, when implementing a member sheet
|
||||
extension, 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 widget's member sheet 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 member sheet
|
||||
extension for that widget, is found. This factory will then make
|
||||
an instance of the extension. If no such factory is found, \QD
|
||||
will use the default member sheet.
|
||||
|
||||
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 4
|
||||
|
||||
Or you can use an existing factory, expanding the
|
||||
QExtensionFactory::createExtension() function to make the factory
|
||||
able to create a member sheet extension as well. For example:
|
||||
|
||||
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 5
|
||||
|
||||
For a complete example using an extension class, see \l
|
||||
{designer/taskmenuextension}{Task Menu Extension example}. The
|
||||
example shows how to create a custom widget plugin for Qt
|
||||
Designer, and how to to use the QDesignerTaskMenuExtension class
|
||||
to add custom items to \QD's task menu.
|
||||
|
||||
\sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
|
||||
Extensions}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerMemberSheetExtension::~QDesignerMemberSheetExtension()
|
||||
|
||||
Destroys the member sheet extension.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMemberSheetExtension::count() const
|
||||
|
||||
Returns the extension's number of member functions.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerMemberSheetExtension::indexOf(const QString &name) const
|
||||
|
||||
Returns the index of the member function specified by the given \a
|
||||
name.
|
||||
|
||||
\sa memberName()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMemberSheetExtension::memberName(int index) const
|
||||
|
||||
Returns the name of the member function with the given \a index.
|
||||
|
||||
\sa indexOf()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMemberSheetExtension::memberGroup(int index) const
|
||||
|
||||
Returns the name of the member group specified for the function
|
||||
with the given \a index.
|
||||
|
||||
\sa indexOf(), setMemberGroup()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerMemberSheetExtension::setMemberGroup(int index, const QString &group)
|
||||
|
||||
Sets the member group of the member function with the given \a
|
||||
index, to \a group.
|
||||
|
||||
\sa indexOf(), memberGroup()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerMemberSheetExtension::isVisible(int index) const
|
||||
|
||||
Returns true if the member function with the given \a index is
|
||||
visible in \QD's signal and slot editor, otherwise false.
|
||||
|
||||
\sa indexOf(), setVisible()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerMemberSheetExtension::setVisible(int index, bool visible)
|
||||
|
||||
If \a visible is true, the member function with the given \a index
|
||||
is visible in \QD's signals and slots editing mode; otherwise the
|
||||
member function is hidden.
|
||||
|
||||
\sa indexOf(), isVisible()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual bool QDesignerMemberSheetExtension::isSignal(int index) const
|
||||
|
||||
Returns true if the member function with the given \a index is a
|
||||
signal, otherwise false.
|
||||
|
||||
\sa indexOf()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerMemberSheetExtension::isSlot(int index) const
|
||||
|
||||
Returns true if the member function with the given \a index is a
|
||||
slot, otherwise false.
|
||||
|
||||
\sa indexOf()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerMemberSheetExtension::inheritedFromWidget(int index) const
|
||||
|
||||
Returns true if the member function with the given \a index is
|
||||
inherited from QWidget, otherwise false.
|
||||
|
||||
\sa indexOf()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMemberSheetExtension::declaredInClass(int index) const
|
||||
|
||||
Returns the name of the class in which the member function with
|
||||
the given \a index is declared.
|
||||
|
||||
\sa indexOf()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerMemberSheetExtension::signature(int index) const
|
||||
|
||||
Returns the signature of the member function with the given \a
|
||||
index.
|
||||
|
||||
\sa indexOf()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QList<QByteArray> QDesignerMemberSheetExtension::parameterTypes(int index) const
|
||||
|
||||
Returns the parameter types of the member function with the given
|
||||
\a index, as a QByteArray list.
|
||||
|
||||
\sa indexOf(), parameterNames()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QList<QByteArray> QDesignerMemberSheetExtension::parameterNames(int index) const
|
||||
|
||||
Returns the parameter names of the member function with the given
|
||||
\a index, as a QByteArray list.
|
||||
|
||||
\sa indexOf(), parameterTypes()
|
||||
*/
|
||||
90
third/designer/lib/sdk/propertysheet.h
Normal file
90
third/designer/lib/sdk/propertysheet.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 PROPERTYSHEET_H
|
||||
#define PROPERTYSHEET_H
|
||||
|
||||
#include <QtDesigner/extension.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QVariant;
|
||||
|
||||
class QDesignerPropertySheetExtension
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerPropertySheetExtension() {}
|
||||
|
||||
virtual int count() const = 0;
|
||||
|
||||
virtual int indexOf(const QString &name) const = 0;
|
||||
|
||||
virtual QString propertyName(int index) const = 0;
|
||||
virtual QString propertyGroup(int index) const = 0;
|
||||
virtual void setPropertyGroup(int index, const QString &group) = 0;
|
||||
|
||||
virtual bool hasReset(int index) const = 0;
|
||||
virtual bool reset(int index) = 0;
|
||||
|
||||
virtual bool isVisible(int index) const = 0;
|
||||
virtual void setVisible(int index, bool b) = 0;
|
||||
|
||||
virtual bool isAttribute(int index) const = 0;
|
||||
virtual void setAttribute(int index, bool b) = 0;
|
||||
|
||||
virtual QVariant property(int index) const = 0;
|
||||
virtual void setProperty(int index, const QVariant &value) = 0;
|
||||
|
||||
virtual bool isChanged(int index) const = 0;
|
||||
virtual void setChanged(int index, bool changed) = 0;
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_EXTENSION_INTERFACE(QDesignerPropertySheetExtension,
|
||||
"com.trolltech.Qt.Designer.PropertySheet")
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // PROPERTYSHEET_H
|
||||
288
third/designer/lib/sdk/propertysheet.qdoc
Normal file
288
third/designer/lib/sdk/propertysheet.qdoc
Normal file
@@ -0,0 +1,288 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 QDesignerPropertySheetExtension
|
||||
|
||||
\brief The QDesignerPropertySheetExtension class allows you to
|
||||
manipulate a widget's properties which is displayed in Qt
|
||||
Designer's property editor.
|
||||
|
||||
\sa QDesignerDynamicPropertySheetExtension
|
||||
|
||||
\inmodule QtDesigner
|
||||
|
||||
QDesignerPropertySheetExtension provides a collection of functions that
|
||||
are typically used to query a widget's properties, and to
|
||||
manipulate the properties' appearance in the property editor. For
|
||||
example:
|
||||
|
||||
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 15
|
||||
|
||||
Note that if you change the value of a property using the
|
||||
QDesignerPropertySheetExtension::setProperty() function, the undo
|
||||
stack is not updated. To ensure that a property's value can be
|
||||
reverted using the undo stack, you must use the
|
||||
QDesignerFormWindowCursorInterface::setProperty() function, or its
|
||||
buddy \l
|
||||
{QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()},
|
||||
instead.
|
||||
|
||||
When implementing a custom widget plugin, a pointer to \QD's
|
||||
current QDesignerFormEditorInterface object (\c formEditor in the
|
||||
example above) is provided by the
|
||||
QDesignerCustomWidgetInterface::initialize() function's parameter.
|
||||
|
||||
The property sheet, or any other extension, can be retrieved by
|
||||
querying \QD's extension manager using the qt_extension()
|
||||
function. When you want to release the extension, you only need to
|
||||
delete the pointer.
|
||||
|
||||
All widgets have a default property sheet which populates \QD's
|
||||
property editor with the widget's properties (i.e the ones defined
|
||||
with the Q_PROPERTY() macro). But QDesignerPropertySheetExtension
|
||||
also provides an interface for creating custom property sheet
|
||||
extensions.
|
||||
|
||||
\warning \QD uses the QDesignerPropertySheetExtension to feed its
|
||||
property editor. Whenever a widget is selected in its workspace,
|
||||
\QD will query for the widget's property sheet extension. If the
|
||||
selected widget has an implemented property sheet extension, this
|
||||
extension will override the default property sheet.
|
||||
|
||||
To create a property sheet extension, your extension class must
|
||||
inherit from both QObject and
|
||||
QDesignerPropertySheetExtension. Then, since we are implementing
|
||||
an interface, we must ensure that it's made known to the meta
|
||||
object system using the Q_INTERFACES() macro:
|
||||
|
||||
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 16
|
||||
|
||||
This enables \QD to use qobject_cast() to query for supported
|
||||
interfaces using nothing but a QObject pointer.
|
||||
|
||||
In \QD the extensions are not created until they are
|
||||
required. For that reason, when implementing a property sheet
|
||||
extension, 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 property sheet 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 property
|
||||
sheet extension for the selected widget, is found. This factory
|
||||
will then make an instance of the extension. If no such factory
|
||||
can be found, \QD will use the default property sheet.
|
||||
|
||||
There are four available types of extensions in \QD:
|
||||
QDesignerContainerExtension, QDesignerMemberSheetExtension,
|
||||
QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. Qt
|
||||
Designer'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 17
|
||||
|
||||
Or you can use an existing factory, expanding the
|
||||
QExtensionFactory::createExtension() function to make the factory
|
||||
able to create a property sheet extension extension as well. For
|
||||
example:
|
||||
|
||||
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 18
|
||||
|
||||
For a complete example using an extension class, see the \l
|
||||
{designer/taskmenuextension}{Task Menu Extension example}. The
|
||||
example shows how to create a custom widget plugin for Qt
|
||||
Designer, and how to to use the QDesignerTaskMenuExtension class
|
||||
to add custom items to \QD's task menu.
|
||||
|
||||
\sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
|
||||
Extensions}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerPropertySheetExtension::~QDesignerPropertySheetExtension()
|
||||
|
||||
Destroys the property sheet extension.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerPropertySheetExtension::count() const
|
||||
|
||||
Returns the selected widget's number of properties.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QDesignerPropertySheetExtension::indexOf(const QString &name) const
|
||||
|
||||
Returns the index for a given property \a name.
|
||||
|
||||
\sa propertyName()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerPropertySheetExtension::propertyName(int index) const
|
||||
|
||||
Returns the name of the property at the given \a index.
|
||||
|
||||
\sa indexOf()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QDesignerPropertySheetExtension::propertyGroup(int index) const
|
||||
|
||||
Returns the property group for the property at the given \a index.
|
||||
|
||||
\QD's property editor supports property groups, i.e. sections of
|
||||
related properties. A property can be related to a group using the
|
||||
setPropertyGroup() function. The default group of any property is
|
||||
the name of the class that defines it. For example, the
|
||||
QObject::objectName property appears within the QObject property
|
||||
group.
|
||||
|
||||
\sa indexOf(), setPropertyGroup()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerPropertySheetExtension::setPropertyGroup(int index, const QString &group)
|
||||
|
||||
Sets the property group for the property at the given \a index to
|
||||
\a group.
|
||||
|
||||
Relating a property to a group makes it appear within that group's
|
||||
section in the property editor. The default property group of any
|
||||
property is the name of the class that defines it. For example,
|
||||
the QObject::objectName property appears within the QObject
|
||||
property group.
|
||||
|
||||
\sa indexOf(), property(), propertyGroup()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerPropertySheetExtension::hasReset(int index) const
|
||||
|
||||
Returns true if the property at the given \a index has a reset
|
||||
button in \QD's property editor, otherwise false.
|
||||
|
||||
\sa indexOf(), reset()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerPropertySheetExtension::reset(int index)
|
||||
|
||||
Resets the value of the property at the given \a index, to the
|
||||
default value. Returns true if a default value could be found, otherwise false.
|
||||
|
||||
\sa indexOf(), hasReset(), isChanged()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerPropertySheetExtension::isVisible(int index) const
|
||||
|
||||
Returns true if the property at the given \a index is visible in
|
||||
\QD's property editor, otherwise false.
|
||||
|
||||
\sa indexOf(), setVisible()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerPropertySheetExtension::setVisible(int index, bool visible)
|
||||
|
||||
If \a visible is true, the property at the given \a index is
|
||||
visible in \QD's property editor; otherwise the property is
|
||||
hidden.
|
||||
|
||||
\sa indexOf(), isVisible()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerPropertySheetExtension::isAttribute(int index) const
|
||||
|
||||
Returns true if the property at the given \a index is an attribute,
|
||||
which will be \e excluded from the UI file, otherwise false.
|
||||
|
||||
\sa indexOf(), setAttribute()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerPropertySheetExtension::setAttribute(int index, bool attribute)
|
||||
|
||||
If \a attribute is true, the property at the given \a index is
|
||||
made an attribute which will be \e excluded from the UI file;
|
||||
otherwise it will be included.
|
||||
|
||||
\sa indexOf(), isAttribute()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVariant QDesignerPropertySheetExtension::property(int index) const
|
||||
|
||||
Returns the value of the property at the given \a index.
|
||||
|
||||
\sa indexOf(), setProperty(), propertyGroup()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerPropertySheetExtension::setProperty(int index, const QVariant &value)
|
||||
|
||||
Sets the \a value of the property at the given \a index.
|
||||
|
||||
\warning If you change the value of a property using this
|
||||
function, the undo stack is not updated. To ensure that a
|
||||
property's value can be reverted using the undo stack, you must
|
||||
use the QDesignerFormWindowCursorInterface::setProperty()
|
||||
function, or its buddy \l
|
||||
{QDesignerFormWindowCursorInterface::setWidgetProperty()}{setWidgetProperty()},
|
||||
instead.
|
||||
|
||||
\sa indexOf(), property(), propertyGroup()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QDesignerPropertySheetExtension::isChanged(int index) const
|
||||
|
||||
Returns true if the value of the property at the given \a index
|
||||
differs from the property's default value, otherwise false.
|
||||
|
||||
\sa indexOf(), setChanged(), reset()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QDesignerPropertySheetExtension::setChanged(int index, bool changed)
|
||||
|
||||
Sets whether the property at the given \a index is different from
|
||||
its default value, or not, depending on the \a changed parameter.
|
||||
|
||||
\sa indexOf(), isChanged()
|
||||
*/
|
||||
109
third/designer/lib/sdk/script.cpp
Normal file
109
third/designer/lib/sdk/script.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "script_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QDesignerScriptExtension
|
||||
\brief The QDesignerScriptExtension class allows you to generate a
|
||||
per-widget \l{QtScript} {Qt Script} snippet to be executed while
|
||||
building the form.
|
||||
|
||||
\internal
|
||||
\inmodule QtDesigner
|
||||
\since 4.3
|
||||
|
||||
On saving the form, the extension is queried for a script snippet
|
||||
to be associated with the widget while saving the UI file.
|
||||
This script is then run after creating the widget by \l uic or
|
||||
QUiLoader.
|
||||
|
||||
As opposed to \l QDesignerCustomWidgetInterface::codeTemplate(),
|
||||
it allows for applying an internal state of the widget
|
||||
that can be manipulated using \QD.
|
||||
|
||||
Such a state might for example be the contents of a custom item view widget,
|
||||
for which an editor is provided by the QDesignerTaskMenuExtension.
|
||||
|
||||
While saving the form, the state is serialized as a QVariantMap of
|
||||
\QD-supported properties, which is stored in the UI file. This is
|
||||
handled by data() and setData().
|
||||
|
||||
For item view contents, there might be for example a key that determines
|
||||
the number of items and other keys that contain the actual items following
|
||||
a naming scheme (\c numItems, \c item1, \c item2, ...).
|
||||
|
||||
On saving, script() is invoked, which should return a script snippet that
|
||||
applies the state to the widget while building the form.
|
||||
|
||||
\sa {Creating Custom Widgets for Qt Designer#Using Qt Script to Aid in Building Forms}{Creating Custom Widgets for Qt Designer}, QtScript
|
||||
*/
|
||||
|
||||
/*!
|
||||
Destroys the extension.
|
||||
*/
|
||||
|
||||
QDesignerScriptExtension::~QDesignerScriptExtension()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn virtual QString QDesignerScriptExtension::script() const
|
||||
|
||||
Returns a script snippet to be associated with the widget.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual QVariantMap QDesignerScriptExtension::data() const
|
||||
|
||||
Returns a map of variants describing the internal state to be
|
||||
stored in the UI file.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn virtual void QDesignerScriptExtension::setData(const QVariantMap &data)
|
||||
|
||||
Applies the internal state stored in \a data to the widget while loading a form.
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
83
third/designer/lib/sdk/script_p.h
Normal file
83
third/designer/lib/sdk/script_p.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 SCRIPT_H
|
||||
#define SCRIPT_H
|
||||
|
||||
#include <QtDesigner/sdk_global.h>
|
||||
#include <QtDesigner/extension.h>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QString; // FIXME: fool syncqt
|
||||
|
||||
class QDESIGNER_SDK_EXPORT QDesignerScriptExtension
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerScriptExtension();
|
||||
|
||||
virtual QVariantMap data() const = 0;
|
||||
virtual void setData(const QVariantMap &data) = 0;
|
||||
|
||||
virtual QString script() const = 0;
|
||||
|
||||
};
|
||||
Q_DECLARE_EXTENSION_INTERFACE(QDesignerScriptExtension, "com.trolltech.Qt.Designer.Script")
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // SCRIPT_H
|
||||
58
third/designer/lib/sdk/sdk.pri
Normal file
58
third/designer/lib/sdk/sdk.pri
Normal file
@@ -0,0 +1,58 @@
|
||||
# Input
|
||||
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += $$PWD/abstractformeditor.h \
|
||||
$$PWD/abstractintrospection_p.h \
|
||||
$$PWD/abstractsettings_p.h \
|
||||
$$PWD/abstractformeditorplugin.h \
|
||||
$$PWD/abstractresourcebrowser.h \
|
||||
$$PWD/abstractintegration.h \
|
||||
$$PWD/abstractpropertyeditor.h \
|
||||
$$PWD/abstractformwindow.h \
|
||||
$$PWD/abstractformwindowtool.h \
|
||||
$$PWD/abstractformwindowcursor.h \
|
||||
$$PWD/abstractformwindowmanager.h \
|
||||
$$PWD/abstractwidgetdatabase.h \
|
||||
$$PWD/abstractmetadatabase.h \
|
||||
$$PWD/abstractwidgetfactory.h \
|
||||
$$PWD/abstractobjectinspector.h \
|
||||
$$PWD/abstractactioneditor.h \
|
||||
$$PWD/abstractbrushmanager.h \
|
||||
$$PWD/abstracticoncache.h \
|
||||
$$PWD/abstractlanguage.h \
|
||||
$$PWD/abstractoptionspage_p.h \
|
||||
$$PWD/propertysheet.h \
|
||||
$$PWD/dynamicpropertysheet.h \
|
||||
$$PWD/membersheet.h \
|
||||
$$PWD/taskmenu.h \
|
||||
$$PWD/extrainfo.h \
|
||||
$$PWD/abstractwidgetbox.h \
|
||||
$$PWD/layoutdecoration.h \
|
||||
$$PWD/abstractdnditem.h \
|
||||
$$PWD/abstractpromotioninterface.h \
|
||||
$$PWD/abstractdialoggui_p.h \
|
||||
$$PWD/script_p.h \
|
||||
$$PWD/abstractnewformwidget_p.h
|
||||
|
||||
SOURCES += $$PWD/abstractformeditor.cpp \
|
||||
$$PWD/abstractintrospection.cpp \
|
||||
$$PWD/abstractformeditorplugin.cpp \
|
||||
$$PWD/abstractresourcebrowser.cpp \
|
||||
$$PWD/abstractintegration.cpp \
|
||||
$$PWD/abstractpropertyeditor.cpp \
|
||||
$$PWD/abstractformwindow.cpp \
|
||||
$$PWD/abstractformwindowtool.cpp \
|
||||
$$PWD/abstractformwindowcursor.cpp \
|
||||
$$PWD/abstractformwindowmanager.cpp \
|
||||
$$PWD/abstractwidgetdatabase.cpp \
|
||||
$$PWD/abstractmetadatabase.cpp \
|
||||
$$PWD/abstractwidgetfactory.cpp \
|
||||
$$PWD/abstractobjectinspector.cpp \
|
||||
$$PWD/abstractactioneditor.cpp \
|
||||
$$PWD/abstractwidgetbox.cpp \
|
||||
$$PWD/extrainfo.cpp \
|
||||
$$PWD/abstractpromotioninterface.cpp \
|
||||
$$PWD/abstractdialoggui.cpp \
|
||||
$$PWD/script.cpp \
|
||||
$$PWD/abstractnewformwidget.cpp
|
||||
64
third/designer/lib/sdk/sdk_global.h
Normal file
64
third/designer/lib/sdk/sdk_global.h
Normal 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 SDK_GLOBAL_H
|
||||
#define SDK_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#define QDESIGNER_SDK_EXTERN Q_DECL_EXPORT
|
||||
#define QDESIGNER_SDK_IMPORT Q_DECL_IMPORT
|
||||
|
||||
#ifdef QT_DESIGNER_STATIC
|
||||
# define QDESIGNER_SDK_EXPORT
|
||||
#elif defined(QDESIGNER_SDK_LIBRARY)
|
||||
# define QDESIGNER_SDK_EXPORT QDESIGNER_SDK_EXTERN
|
||||
#else
|
||||
# define QDESIGNER_SDK_EXPORT QDESIGNER_SDK_IMPORT
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // SDK_GLOBAL_H
|
||||
72
third/designer/lib/sdk/taskmenu.h
Normal file
72
third/designer/lib/sdk/taskmenu.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 TASKMENU_H
|
||||
#define TASKMENU_H
|
||||
|
||||
#include <QtDesigner/extension.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QAction;
|
||||
|
||||
class QDesignerTaskMenuExtension
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerTaskMenuExtension() {}
|
||||
|
||||
virtual QAction *preferredEditAction() const;
|
||||
|
||||
virtual QList<QAction*> taskActions() const = 0;
|
||||
};
|
||||
Q_DECLARE_EXTENSION_INTERFACE(QDesignerTaskMenuExtension, "com.trolltech.Qt.Designer.TaskMenu")
|
||||
|
||||
|
||||
inline QAction *QDesignerTaskMenuExtension::preferredEditAction() const
|
||||
{ return 0; }
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // TASKMENU_H
|
||||
138
third/designer/lib/sdk/taskmenu.qdoc
Normal file
138
third/designer/lib/sdk/taskmenu.qdoc
Normal file
@@ -0,0 +1,138 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 QDesignerTaskMenuExtension
|
||||
\brief The QDesignerTaskMenuExtension class allows you to add custom
|
||||
menu entries to Qt Designer's task menu.
|
||||
\inmodule QtDesigner
|
||||
|
||||
QDesignerTaskMenuExtension provides an interface for creating
|
||||
custom task menu extensions. It is typically used to create task
|
||||
menu entries that are specific to a plugin in \QD.
|
||||
|
||||
\QD uses the QDesignerTaskMenuExtension to feed its task
|
||||
menu. Whenever a task menu is requested, \QD will query
|
||||
for the selected widget's task menu extension.
|
||||
|
||||
\image taskmenuextension-example-faded.png
|
||||
|
||||
A task menu extension is a collection of QActions. The actions
|
||||
appear as entries in the task menu when the plugin with the
|
||||
specified extension is selected. The image above shows the custom
|
||||
\gui {Edit State...} action which appears in addition to \QD's
|
||||
default task menu entries: \gui Cut, \gui Copy, \gui Paste etc.
|
||||
|
||||
To create a custom task menu extension, your extension class must
|
||||
inherit from both QObject and QDesignerTaskMenuExtension. For
|
||||
example:
|
||||
|
||||
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 9
|
||||
|
||||
Since we are implementing an interface, we must ensure that it
|
||||
is 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 the taskActions() function to return a list
|
||||
of actions that will be included in \QD task menu. Optionally, you
|
||||
can reimplement the preferredEditAction() function to set the
|
||||
action that is invoked when selecting your plugin and pressing
|
||||
\key F2. The preferred edit action must be one of the actions
|
||||
returned by taskActions() and, if it's not defined, pressing the
|
||||
\key F2 key will simply be ignored.
|
||||
|
||||
In \QD, extensions are not created until they are required. A
|
||||
task menu extension, for example, is created when you click the
|
||||
right mouse button over a widget in \QD's workspace. For that
|
||||
reason you must also construct an extension factory, using either
|
||||
QExtensionFactory or a subclass, and register it using \QD's
|
||||
\l {QExtensionManager}{extension manager}.
|
||||
|
||||
When a task menu extension is required, \QD's \l
|
||||
{QExtensionManager}{extension manager} will run through all its
|
||||
registered factories calling QExtensionFactory::createExtension()
|
||||
for each until it finds one that is able to create a task menu
|
||||
extension for the selected widget. This factory will then make an
|
||||
instance of the extension.
|
||||
|
||||
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 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 10
|
||||
|
||||
Or you can use an existing factory, expanding the
|
||||
QExtensionFactory::createExtension() function to make the factory
|
||||
able to create a task menu extension as well. For example:
|
||||
|
||||
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 11
|
||||
|
||||
For a complete example using the QDesignerTaskMenuExtension class,
|
||||
see the \l {designer/taskmenuextension}{Task Menu Extension
|
||||
example}. The example shows how to create a custom widget plugin
|
||||
for \QD, and how to to use the QDesignerTaskMenuExtension
|
||||
class to add custom items to \QD's task menu.
|
||||
|
||||
\sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
|
||||
Extensions}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QDesignerTaskMenuExtension::~QDesignerTaskMenuExtension()
|
||||
|
||||
Destroys the task menu extension.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QAction *QDesignerTaskMenuExtension::preferredEditAction() const
|
||||
|
||||
Returns the action that is invoked when selecting a plugin with
|
||||
the specified extension and pressing \key F2.
|
||||
|
||||
The action must be one of the actions returned by taskActions().
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QList<QAction*> QDesignerTaskMenuExtension::taskActions() const
|
||||
|
||||
Returns the task menu extension as a list of actions which will be
|
||||
included in \QD's task menu when a plugin with the specified
|
||||
extension is selected.
|
||||
|
||||
The function must be reimplemented to add actions to the list.
|
||||
*/
|
||||
824
third/designer/lib/shared/actioneditor.cpp
Normal file
824
third/designer/lib/shared/actioneditor.cpp
Normal file
@@ -0,0 +1,824 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "actioneditor_p.h"
|
||||
#include "filterwidget_p.h"
|
||||
#include "actionrepository_p.h"
|
||||
#include "iconloader_p.h"
|
||||
#include "newactiondialog_p.h"
|
||||
#include "qdesigner_menu_p.h"
|
||||
#include "qdesigner_command_p.h"
|
||||
#include "qdesigner_propertycommand_p.h"
|
||||
#include "qdesigner_objectinspector_p.h"
|
||||
#include "qdesigner_utils_p.h"
|
||||
#include "qsimpleresource_p.h"
|
||||
#include "formwindowbase_p.h"
|
||||
#include "qdesigner_taskmenu_p.h"
|
||||
|
||||
#include <QtDesigner/QDesignerFormEditorInterface>
|
||||
#include <QtDesigner/QDesignerPropertyEditorInterface>
|
||||
#include <QtDesigner/QDesignerPropertySheetExtension>
|
||||
#include <QtDesigner/QExtensionManager>
|
||||
#include <QtDesigner/QDesignerMetaDataBaseInterface>
|
||||
#include <QtDesigner/QDesignerIconCacheInterface>
|
||||
#include <QtDesigner/private/abstractsettings_p.h>
|
||||
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QSplitter>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QClipboard>
|
||||
#include <QtGui/QItemDelegate>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QContextMenuEvent>
|
||||
#include <QtGui/QItemSelection>
|
||||
|
||||
#include <QtCore/QRegExp>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QSignalMapper>
|
||||
#include <QtCore/QBuffer>
|
||||
|
||||
Q_DECLARE_METATYPE(QAction*)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static const char *actionEditorViewModeKey = "ActionEditorViewMode";
|
||||
|
||||
static const char *iconPropertyC = "icon";
|
||||
static const char *shortcutPropertyC = "shortcut";
|
||||
static const char *toolTipPropertyC = "toolTip";
|
||||
static const char *checkablePropertyC = "checkable";
|
||||
static const char *objectNamePropertyC = "objectName";
|
||||
static const char *textPropertyC = "text";
|
||||
|
||||
namespace qdesigner_internal {
|
||||
//-------- ActionGroupDelegate
|
||||
class ActionGroupDelegate: public QItemDelegate
|
||||
{
|
||||
public:
|
||||
ActionGroupDelegate(QObject *parent)
|
||||
: QItemDelegate(parent) {}
|
||||
|
||||
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
if (option.state & QStyle::State_Selected)
|
||||
painter->fillRect(option.rect, option.palette.highlight());
|
||||
|
||||
QItemDelegate::paint(painter, option, index);
|
||||
}
|
||||
|
||||
virtual void drawFocus(QPainter * /*painter*/, const QStyleOptionViewItem &/*option*/, const QRect &/*rect*/) const {}
|
||||
};
|
||||
|
||||
//-------- ActionEditor
|
||||
ActionEditor::ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent, Qt::WindowFlags flags) :
|
||||
QDesignerActionEditorInterface(parent, flags),
|
||||
m_core(core),
|
||||
m_actionGroups(0),
|
||||
m_actionView(new ActionView),
|
||||
m_actionNew(new QAction(tr("New..."), this)),
|
||||
m_actionEdit(new QAction(tr("Edit..."), this)),
|
||||
m_actionNavigateToSlot(new QAction(tr("Go to slot..."), this)),
|
||||
m_actionCopy(new QAction(tr("Copy"), this)),
|
||||
m_actionCut(new QAction(tr("Cut"), this)),
|
||||
m_actionPaste(new QAction(tr("Paste"), this)),
|
||||
m_actionSelectAll(new QAction(tr("Select all"), this)),
|
||||
m_actionDelete(new QAction(tr("Delete"), this)),
|
||||
m_viewModeGroup(new QActionGroup(this)),
|
||||
m_iconViewAction(0),
|
||||
m_listViewAction(0),
|
||||
m_filterWidget(0),
|
||||
m_selectAssociatedWidgetsMapper(0)
|
||||
{
|
||||
m_actionView->initialize(m_core);
|
||||
m_actionView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
setWindowTitle(tr("Actions"));
|
||||
|
||||
QVBoxLayout *l = new QVBoxLayout(this);
|
||||
l->setMargin(0);
|
||||
l->setSpacing(0);
|
||||
|
||||
QToolBar *toolbar = new QToolBar;
|
||||
toolbar->setIconSize(QSize(22, 22));
|
||||
toolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
l->addWidget(toolbar);
|
||||
// edit actions
|
||||
QIcon documentNewIcon = QIcon::fromTheme("document-new", createIconSet(QLatin1String("filenew.png")));
|
||||
m_actionNew->setIcon(documentNewIcon);
|
||||
m_actionNew->setEnabled(false);
|
||||
connect(m_actionNew, SIGNAL(triggered()), this, SLOT(slotNewAction()));
|
||||
toolbar->addAction(m_actionNew);
|
||||
|
||||
connect(m_actionSelectAll, SIGNAL(triggered()), m_actionView, SLOT(selectAll()));
|
||||
|
||||
m_actionCut->setEnabled(false);
|
||||
connect(m_actionCut, SIGNAL(triggered()), this, SLOT(slotCut()));
|
||||
QIcon editCutIcon = QIcon::fromTheme("edit-cut", createIconSet(QLatin1String("editcut.png")));
|
||||
m_actionCut->setIcon(editCutIcon);
|
||||
|
||||
m_actionCopy->setEnabled(false);
|
||||
connect(m_actionCopy, SIGNAL(triggered()), this, SLOT(slotCopy()));
|
||||
QIcon editCopyIcon = QIcon::fromTheme("edit-copy", createIconSet(QLatin1String("editcopy.png")));
|
||||
m_actionCopy->setIcon(editCopyIcon);
|
||||
toolbar->addAction(m_actionCopy);
|
||||
|
||||
connect(m_actionPaste, SIGNAL(triggered()), this, SLOT(slotPaste()));
|
||||
QIcon editPasteIcon = QIcon::fromTheme("edit-paste", createIconSet(QLatin1String("editpaste.png")));
|
||||
m_actionPaste->setIcon(editPasteIcon);
|
||||
toolbar->addAction(m_actionPaste);
|
||||
|
||||
m_actionEdit->setEnabled(false);
|
||||
connect(m_actionEdit, SIGNAL(triggered()), this, SLOT(editCurrentAction()));
|
||||
|
||||
connect(m_actionNavigateToSlot, SIGNAL(triggered()), this, SLOT(navigateToSlotCurrentAction()));
|
||||
|
||||
QIcon editDeleteIcon = QIcon::fromTheme("edit-delete", createIconSet(QLatin1String("editdelete.png")));
|
||||
m_actionDelete->setIcon(editDeleteIcon);
|
||||
m_actionDelete->setEnabled(false);
|
||||
connect(m_actionDelete, SIGNAL(triggered()), this, SLOT(slotDelete()));
|
||||
toolbar->addAction(m_actionDelete);
|
||||
|
||||
// Toolbutton with menu containing action group for detailed/icon view. Steal the icons from the file dialog.
|
||||
//
|
||||
QMenu *configureMenu;
|
||||
toolbar->addWidget(createConfigureMenuButton(tr("Configure Action Editor"), &configureMenu));
|
||||
|
||||
connect(m_viewModeGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotViewMode(QAction*)));
|
||||
m_iconViewAction = m_viewModeGroup->addAction(tr("Icon View"));
|
||||
m_iconViewAction->setData(QVariant(ActionView::IconView));
|
||||
m_iconViewAction->setCheckable(true);
|
||||
m_iconViewAction->setIcon(style()->standardIcon (QStyle::SP_FileDialogListView));
|
||||
configureMenu->addAction(m_iconViewAction);
|
||||
|
||||
m_listViewAction = m_viewModeGroup->addAction(tr("Detailed View"));
|
||||
m_listViewAction->setData(QVariant(ActionView::DetailedView));
|
||||
m_listViewAction->setCheckable(true);
|
||||
m_listViewAction->setIcon(style()->standardIcon (QStyle::SP_FileDialogDetailedView));
|
||||
configureMenu->addAction(m_listViewAction);
|
||||
// filter
|
||||
m_filterWidget = new FilterWidget(toolbar);
|
||||
connect(m_filterWidget, SIGNAL(filterChanged(QString)), this, SLOT(setFilter(QString)));
|
||||
m_filterWidget->setEnabled(false);
|
||||
toolbar->addWidget(m_filterWidget);
|
||||
|
||||
// main layout
|
||||
QSplitter *splitter = new QSplitter(Qt::Horizontal);
|
||||
splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
splitter->addWidget(m_actionView);
|
||||
l->addWidget(splitter);
|
||||
|
||||
#if 0 // ### implement me
|
||||
m_actionGroups = new QListWidget(splitter);
|
||||
splitter->addWidget(m_actionGroups);
|
||||
m_actionGroups->setItemDelegate(new ActionGroupDelegate(m_actionGroups));
|
||||
m_actionGroups->setMovement(QListWidget::Static);
|
||||
m_actionGroups->setResizeMode(QListWidget::Fixed);
|
||||
m_actionGroups->setIconSize(QSize(48, 48));
|
||||
m_actionGroups->setFlow(QListWidget::TopToBottom);
|
||||
m_actionGroups->setViewMode(QListWidget::IconMode);
|
||||
m_actionGroups->setWrapping(false);
|
||||
#endif
|
||||
|
||||
connect(m_actionView, SIGNAL(resourceImageDropped(QString,QAction*)),
|
||||
this, SLOT(resourceImageDropped(QString,QAction*)));
|
||||
|
||||
connect(m_actionView, SIGNAL(currentChanged(QAction*)),this, SLOT(slotCurrentItemChanged(QAction*)));
|
||||
// make it possible for vs integration to reimplement edit action dialog
|
||||
connect(m_actionView, SIGNAL(activated(QAction*)), this, SIGNAL(itemActivated(QAction*)));
|
||||
|
||||
connect(m_actionView,SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
||||
this, SLOT(slotSelectionChanged(QItemSelection,QItemSelection)));
|
||||
|
||||
connect(m_actionView, SIGNAL(contextMenuRequested(QContextMenuEvent*,QAction*)),
|
||||
this, SLOT(slotContextMenuRequested(QContextMenuEvent*,QAction*)));
|
||||
|
||||
connect(this, SIGNAL(itemActivated(QAction*)), this, SLOT(editAction(QAction*)));
|
||||
|
||||
restoreSettings();
|
||||
updateViewModeActions();
|
||||
}
|
||||
|
||||
// Utility to create a configure button with menu for usage on toolbars
|
||||
QToolButton *ActionEditor::createConfigureMenuButton(const QString &t, QMenu **ptrToMenu)
|
||||
{
|
||||
QToolButton *configureButton = new QToolButton;
|
||||
QAction *configureAction = new QAction(t, configureButton);
|
||||
QIcon configureIcon = QIcon::fromTheme("document-properties", createIconSet(QLatin1String("configure.png")));
|
||||
configureAction->setIcon(configureIcon);
|
||||
QMenu *configureMenu = new QMenu;
|
||||
configureAction->setMenu(configureMenu);
|
||||
configureButton->setDefaultAction(configureAction);
|
||||
configureButton->setPopupMode(QToolButton::InstantPopup);
|
||||
*ptrToMenu = configureMenu;
|
||||
return configureButton;
|
||||
}
|
||||
|
||||
ActionEditor::~ActionEditor()
|
||||
{
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
QAction *ActionEditor::actionNew() const
|
||||
{
|
||||
return m_actionNew;
|
||||
}
|
||||
|
||||
QAction *ActionEditor::actionDelete() const
|
||||
{
|
||||
return m_actionDelete;
|
||||
}
|
||||
|
||||
QDesignerFormWindowInterface *ActionEditor::formWindow() const
|
||||
{
|
||||
return m_formWindow;
|
||||
}
|
||||
|
||||
void ActionEditor::setFormWindow(QDesignerFormWindowInterface *formWindow)
|
||||
{
|
||||
if (formWindow != 0 && formWindow->mainContainer() == 0)
|
||||
formWindow = 0;
|
||||
|
||||
// we do NOT rely on this function to update the action editor
|
||||
if (m_formWindow == formWindow)
|
||||
return;
|
||||
|
||||
if (m_formWindow != 0) {
|
||||
const ActionList actionList = qFindChildren<QAction*>(m_formWindow->mainContainer());
|
||||
foreach (QAction *action, actionList)
|
||||
disconnect(action, SIGNAL(changed()), this, SLOT(slotActionChanged()));
|
||||
}
|
||||
|
||||
m_formWindow = formWindow;
|
||||
|
||||
m_actionView->model()->clearActions();
|
||||
|
||||
m_actionEdit->setEnabled(false);
|
||||
m_actionCopy->setEnabled(false);
|
||||
m_actionCut->setEnabled(false);
|
||||
m_actionDelete->setEnabled(false);
|
||||
|
||||
if (!formWindow || !formWindow->mainContainer()) {
|
||||
m_actionNew->setEnabled(false);
|
||||
m_filterWidget->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
m_actionNew->setEnabled(true);
|
||||
m_filterWidget->setEnabled(true);
|
||||
|
||||
const ActionList actionList = qFindChildren<QAction*>(formWindow->mainContainer());
|
||||
foreach (QAction *action, actionList)
|
||||
if (!action->isSeparator() && core()->metaDataBase()->item(action) != 0) {
|
||||
// Show unless it has a menu. However, listen for change on menu actions also as it might be removed
|
||||
if (!action->menu())
|
||||
m_actionView->model()->addAction(action);
|
||||
connect(action, SIGNAL(changed()), this, SLOT(slotActionChanged()));
|
||||
}
|
||||
|
||||
setFilter(m_filter);
|
||||
}
|
||||
|
||||
void ActionEditor::slotSelectionChanged(const QItemSelection& selected, const QItemSelection& /*deselected*/)
|
||||
{
|
||||
const bool hasSelection = !selected.indexes().empty();
|
||||
m_actionCopy->setEnabled(hasSelection);
|
||||
m_actionCut->setEnabled(hasSelection);
|
||||
m_actionDelete->setEnabled(hasSelection);
|
||||
}
|
||||
|
||||
void ActionEditor::slotCurrentItemChanged(QAction *action)
|
||||
{
|
||||
QDesignerFormWindowInterface *fw = formWindow();
|
||||
if (!fw)
|
||||
return;
|
||||
|
||||
const bool hasCurrentAction = action != 0;
|
||||
m_actionEdit->setEnabled(hasCurrentAction);
|
||||
|
||||
if (!action) {
|
||||
fw->clearSelection();
|
||||
return;
|
||||
}
|
||||
|
||||
QDesignerObjectInspector *oi = qobject_cast<QDesignerObjectInspector *>(core()->objectInspector());
|
||||
|
||||
if (action->associatedWidgets().empty()) {
|
||||
// Special case: action not in object tree. Deselect all and set in property editor
|
||||
fw->clearSelection(false);
|
||||
if (oi)
|
||||
oi->clearSelection();
|
||||
core()->propertyEditor()->setObject(action);
|
||||
} else {
|
||||
if (oi)
|
||||
oi->selectObject(action);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionEditor::slotActionChanged()
|
||||
{
|
||||
QAction *action = qobject_cast<QAction*>(sender());
|
||||
Q_ASSERT(action != 0);
|
||||
|
||||
ActionModel *model = m_actionView->model();
|
||||
const int row = model->findAction(action);
|
||||
if (row == -1) {
|
||||
if (action->menu() == 0) // action got its menu deleted, create item
|
||||
model->addAction(action);
|
||||
} else if (action->menu() != 0) { // action got its menu created, remove item
|
||||
model->removeRow(row);
|
||||
} else {
|
||||
// action text or icon changed, update item
|
||||
model->update(row);
|
||||
}
|
||||
}
|
||||
|
||||
QDesignerFormEditorInterface *ActionEditor::core() const
|
||||
{
|
||||
return m_core;
|
||||
}
|
||||
|
||||
QString ActionEditor::filter() const
|
||||
{
|
||||
return m_filter;
|
||||
}
|
||||
|
||||
void ActionEditor::setFilter(const QString &f)
|
||||
{
|
||||
m_filter = f;
|
||||
m_actionView->filter(m_filter);
|
||||
}
|
||||
|
||||
// Set changed state of icon property, reset when icon is cleared
|
||||
static void refreshIconPropertyChanged(const QAction *action, QDesignerPropertySheetExtension *sheet)
|
||||
{
|
||||
sheet->setChanged(sheet->indexOf(QLatin1String(iconPropertyC)), !action->icon().isNull());
|
||||
}
|
||||
|
||||
void ActionEditor::manageAction(QAction *action)
|
||||
{
|
||||
action->setParent(formWindow()->mainContainer());
|
||||
core()->metaDataBase()->add(action);
|
||||
|
||||
if (action->isSeparator() || action->menu() != 0)
|
||||
return;
|
||||
|
||||
QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action);
|
||||
sheet->setChanged(sheet->indexOf(QLatin1String(objectNamePropertyC)), true);
|
||||
sheet->setChanged(sheet->indexOf(QLatin1String(textPropertyC)), true);
|
||||
refreshIconPropertyChanged(action, sheet);
|
||||
|
||||
m_actionView->setCurrentIndex(m_actionView->model()->addAction(action));
|
||||
connect(action, SIGNAL(changed()), this, SLOT(slotActionChanged()));
|
||||
}
|
||||
|
||||
void ActionEditor::unmanageAction(QAction *action)
|
||||
{
|
||||
core()->metaDataBase()->remove(action);
|
||||
action->setParent(0);
|
||||
|
||||
disconnect(action, SIGNAL(changed()), this, SLOT(slotActionChanged()));
|
||||
|
||||
const int row = m_actionView->model()->findAction(action);
|
||||
if (row != -1)
|
||||
m_actionView->model()->remove(row);
|
||||
}
|
||||
|
||||
// Set an initial property and mark it as changed in the sheet
|
||||
static void setInitialProperty(QDesignerPropertySheetExtension *sheet, const QString &name, const QVariant &value)
|
||||
{
|
||||
const int index = sheet->indexOf(name);
|
||||
Q_ASSERT(index != -1);
|
||||
sheet->setProperty(index, value);
|
||||
sheet->setChanged(index, true);
|
||||
}
|
||||
|
||||
void ActionEditor::slotNewAction()
|
||||
{
|
||||
NewActionDialog dlg(this);
|
||||
dlg.setWindowTitle(tr("New action"));
|
||||
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
const ActionData actionData = dlg.actionData();
|
||||
m_actionView->clearSelection();
|
||||
|
||||
QAction *action = new QAction(formWindow());
|
||||
action->setObjectName(actionData.name);
|
||||
formWindow()->ensureUniqueObjectName(action);
|
||||
action->setText(actionData.text);
|
||||
|
||||
QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action);
|
||||
if (!actionData.toolTip.isEmpty())
|
||||
setInitialProperty(sheet, QLatin1String(toolTipPropertyC), actionData.toolTip);
|
||||
|
||||
if (actionData.checkable)
|
||||
setInitialProperty(sheet, QLatin1String(checkablePropertyC), QVariant(true));
|
||||
|
||||
if (!actionData.keysequence.value().isEmpty())
|
||||
setInitialProperty(sheet, QLatin1String(shortcutPropertyC), qVariantFromValue(actionData.keysequence));
|
||||
|
||||
sheet->setProperty(sheet->indexOf(QLatin1String(iconPropertyC)), qVariantFromValue(actionData.icon));
|
||||
|
||||
AddActionCommand *cmd = new AddActionCommand(formWindow());
|
||||
cmd->init(action);
|
||||
formWindow()->commandHistory()->push(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool isSameIcon(const QIcon &i1, const QIcon &i2)
|
||||
{
|
||||
return i1.serialNumber() == i2.serialNumber();
|
||||
}
|
||||
|
||||
// return a FormWindow command to apply an icon or a reset command in case it
|
||||
// is empty.
|
||||
|
||||
static QDesignerFormWindowCommand *setIconPropertyCommand(const PropertySheetIconValue &newIcon, QAction *action, QDesignerFormWindowInterface *fw)
|
||||
{
|
||||
const QString iconProperty = QLatin1String(iconPropertyC);
|
||||
if (newIcon.paths().isEmpty()) {
|
||||
ResetPropertyCommand *cmd = new ResetPropertyCommand(fw);
|
||||
cmd->init(action, iconProperty);
|
||||
return cmd;
|
||||
}
|
||||
SetPropertyCommand *cmd = new SetPropertyCommand(fw);
|
||||
cmd->init(action, iconProperty, qVariantFromValue(newIcon));
|
||||
return cmd;
|
||||
}
|
||||
|
||||
// return a FormWindow command to apply a QKeySequence or a reset command
|
||||
// in case it is empty.
|
||||
|
||||
static QDesignerFormWindowCommand *setKeySequencePropertyCommand(const PropertySheetKeySequenceValue &ks, QAction *action, QDesignerFormWindowInterface *fw)
|
||||
{
|
||||
const QString shortcutProperty = QLatin1String(shortcutPropertyC);
|
||||
if (ks.value().isEmpty()) {
|
||||
ResetPropertyCommand *cmd = new ResetPropertyCommand(fw);
|
||||
cmd->init(action, shortcutProperty);
|
||||
return cmd;
|
||||
}
|
||||
SetPropertyCommand *cmd = new SetPropertyCommand(fw);
|
||||
cmd->init(action, shortcutProperty, qVariantFromValue(ks));
|
||||
return cmd;
|
||||
}
|
||||
|
||||
// return a FormWindow command to apply a POD value or reset command in case
|
||||
// it is equal to the default value.
|
||||
|
||||
template <class T>
|
||||
QDesignerFormWindowCommand *setPropertyCommand(const QString &name, T value, T defaultValue,
|
||||
QObject *o, QDesignerFormWindowInterface *fw)
|
||||
{
|
||||
if (value == defaultValue) {
|
||||
ResetPropertyCommand *cmd = new ResetPropertyCommand(fw);
|
||||
cmd->init(o, name);
|
||||
return cmd;
|
||||
}
|
||||
SetPropertyCommand *cmd = new SetPropertyCommand(fw);
|
||||
cmd->init(o, name, QVariant(value));
|
||||
return cmd;
|
||||
}
|
||||
|
||||
// Return the text value of a string property via PropertySheetStringValue
|
||||
static inline QString textPropertyValue(const QDesignerPropertySheetExtension *sheet, const QString &name)
|
||||
{
|
||||
const int index = sheet->indexOf(name);
|
||||
Q_ASSERT(index != -1);
|
||||
const PropertySheetStringValue ps = qVariantValue<PropertySheetStringValue>(sheet->property(index));
|
||||
return ps.value();
|
||||
}
|
||||
|
||||
void ActionEditor::editAction(QAction *action)
|
||||
{
|
||||
if (!action)
|
||||
return;
|
||||
|
||||
NewActionDialog dlg(this);
|
||||
dlg.setWindowTitle(tr("Edit action"));
|
||||
|
||||
ActionData oldActionData;
|
||||
QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action);
|
||||
oldActionData.name = action->objectName();
|
||||
oldActionData.text = action->text();
|
||||
oldActionData.toolTip = textPropertyValue(sheet, QLatin1String(toolTipPropertyC));
|
||||
oldActionData.icon = qVariantValue<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC))));
|
||||
oldActionData.keysequence = ActionModel::actionShortCut(sheet);
|
||||
oldActionData.checkable = action->isCheckable();
|
||||
dlg.setActionData(oldActionData);
|
||||
|
||||
if (!dlg.exec())
|
||||
return;
|
||||
|
||||
// figure out changes and whether to start a macro
|
||||
const ActionData newActionData = dlg.actionData();
|
||||
const unsigned changeMask = newActionData.compare(oldActionData);
|
||||
if (changeMask == 0u)
|
||||
return;
|
||||
|
||||
const bool severalChanges = (changeMask != ActionData::TextChanged) && (changeMask != ActionData::NameChanged)
|
||||
&& (changeMask != ActionData::ToolTipChanged) && (changeMask != ActionData::IconChanged)
|
||||
&& (changeMask != ActionData::CheckableChanged) && (changeMask != ActionData::KeysequenceChanged);
|
||||
|
||||
QDesignerFormWindowInterface *fw = formWindow();
|
||||
QUndoStack *undoStack = fw->commandHistory();
|
||||
if (severalChanges)
|
||||
fw->beginCommand(QLatin1String("Edit action"));
|
||||
|
||||
if (changeMask & ActionData::NameChanged)
|
||||
undoStack->push(createTextPropertyCommand(QLatin1String(objectNamePropertyC), newActionData.name, action, fw));
|
||||
|
||||
if (changeMask & ActionData::TextChanged)
|
||||
undoStack->push(createTextPropertyCommand(QLatin1String(textPropertyC), newActionData.text, action, fw));
|
||||
|
||||
if (changeMask & ActionData::ToolTipChanged)
|
||||
undoStack->push(createTextPropertyCommand(QLatin1String(toolTipPropertyC), newActionData.toolTip, action, fw));
|
||||
|
||||
if (changeMask & ActionData::IconChanged)
|
||||
undoStack->push(setIconPropertyCommand(newActionData.icon, action, fw));
|
||||
|
||||
if (changeMask & ActionData::CheckableChanged)
|
||||
undoStack->push(setPropertyCommand(QLatin1String(checkablePropertyC), newActionData.checkable, false, action, fw));
|
||||
|
||||
if (changeMask & ActionData::KeysequenceChanged)
|
||||
undoStack->push(setKeySequencePropertyCommand(newActionData.keysequence, action, fw));
|
||||
|
||||
if (severalChanges)
|
||||
fw->endCommand();
|
||||
}
|
||||
|
||||
void ActionEditor::editCurrentAction()
|
||||
{
|
||||
if (QAction *a = m_actionView->currentAction())
|
||||
editAction(a);
|
||||
}
|
||||
|
||||
void ActionEditor::navigateToSlotCurrentAction()
|
||||
{
|
||||
if (QAction *a = m_actionView->currentAction())
|
||||
QDesignerTaskMenu::navigateToSlot(m_core, a, QLatin1String("triggered()"));
|
||||
}
|
||||
|
||||
void ActionEditor::deleteActions(QDesignerFormWindowInterface *fw, const ActionList &actions)
|
||||
{
|
||||
// We need a macro even in the case of single action because the commands might cause the
|
||||
// scheduling of other commands (signal slots connections)
|
||||
const QString description = actions.size() == 1 ?
|
||||
tr("Remove action '%1'").arg(actions.front()->objectName()) : tr("Remove actions");
|
||||
fw->beginCommand(description);
|
||||
foreach(QAction *action, actions) {
|
||||
RemoveActionCommand *cmd = new RemoveActionCommand(fw);
|
||||
cmd->init(action);
|
||||
fw->commandHistory()->push(cmd);
|
||||
}
|
||||
fw->endCommand();
|
||||
}
|
||||
|
||||
void ActionEditor::copyActions(QDesignerFormWindowInterface *fwi, const ActionList &actions)
|
||||
{
|
||||
FormWindowBase *fw = qobject_cast<FormWindowBase *>(fwi);
|
||||
if (!fw )
|
||||
return;
|
||||
|
||||
FormBuilderClipboard clipboard;
|
||||
clipboard.m_actions = actions;
|
||||
|
||||
if (clipboard.empty())
|
||||
return;
|
||||
|
||||
QEditorFormBuilder *formBuilder = fw->createFormBuilder();
|
||||
Q_ASSERT(formBuilder);
|
||||
|
||||
QBuffer buffer;
|
||||
if (buffer.open(QIODevice::WriteOnly))
|
||||
if (formBuilder->copy(&buffer, clipboard))
|
||||
qApp->clipboard()->setText(QString::fromUtf8(buffer.buffer()), QClipboard::Clipboard);
|
||||
delete formBuilder;
|
||||
}
|
||||
|
||||
void ActionEditor::slotDelete()
|
||||
{
|
||||
QDesignerFormWindowInterface *fw = formWindow();
|
||||
if (!fw)
|
||||
return;
|
||||
|
||||
const ActionView::ActionList selection = m_actionView->selectedActions();
|
||||
if (selection.empty())
|
||||
return;
|
||||
|
||||
deleteActions(fw, selection);
|
||||
}
|
||||
|
||||
QString ActionEditor::actionTextToName(const QString &text, const QString &prefix)
|
||||
{
|
||||
QString name = text;
|
||||
if (name.isEmpty())
|
||||
return QString();
|
||||
|
||||
name[0] = name.at(0).toUpper();
|
||||
name.prepend(prefix);
|
||||
const QString underscore = QString(QLatin1Char('_'));
|
||||
name.replace(QRegExp(QString(QLatin1String("[^a-zA-Z_0-9]"))), underscore);
|
||||
name.replace(QRegExp(QLatin1String("__*")), underscore);
|
||||
if (name.endsWith(underscore.at(0)))
|
||||
name.truncate(name.size() - 1);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
void ActionEditor::resourceImageDropped(const QString &path, QAction *action)
|
||||
{
|
||||
QDesignerFormWindowInterface *fw = formWindow();
|
||||
if (!fw)
|
||||
return;
|
||||
|
||||
QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action);
|
||||
const PropertySheetIconValue oldIcon =
|
||||
qVariantValue<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC))));
|
||||
PropertySheetIconValue newIcon;
|
||||
newIcon.setPixmap(QIcon::Normal, QIcon::Off, PropertySheetPixmapValue(path));
|
||||
if (newIcon.paths().isEmpty() || newIcon.paths() == oldIcon.paths())
|
||||
return;
|
||||
|
||||
fw->commandHistory()->push(setIconPropertyCommand(newIcon , action, fw));
|
||||
}
|
||||
|
||||
void ActionEditor::mainContainerChanged()
|
||||
{
|
||||
// Invalidate references to objects kept in model
|
||||
if (sender() == formWindow())
|
||||
setFormWindow(0);
|
||||
}
|
||||
|
||||
void ActionEditor::slotViewMode(QAction *a)
|
||||
{
|
||||
m_actionView->setViewMode(a->data().toInt());
|
||||
updateViewModeActions();
|
||||
}
|
||||
|
||||
void ActionEditor::slotSelectAssociatedWidget(QWidget *w)
|
||||
{
|
||||
QDesignerFormWindowInterface *fw = formWindow();
|
||||
if (!fw )
|
||||
return;
|
||||
|
||||
QDesignerObjectInspector *oi = qobject_cast<QDesignerObjectInspector *>(core()->objectInspector());
|
||||
if (!oi)
|
||||
return;
|
||||
|
||||
fw->clearSelection(); // Actually, there are no widgets selected due to focus in event handling. Just to be sure.
|
||||
oi->selectObject(w);
|
||||
}
|
||||
|
||||
void ActionEditor::restoreSettings()
|
||||
{
|
||||
QDesignerSettingsInterface *settings = m_core->settingsManager();
|
||||
m_actionView->setViewMode(settings->value(QLatin1String(actionEditorViewModeKey), 0).toInt());
|
||||
updateViewModeActions();
|
||||
}
|
||||
|
||||
void ActionEditor::saveSettings()
|
||||
{
|
||||
QDesignerSettingsInterface *settings = m_core->settingsManager();
|
||||
settings->setValue(QLatin1String(actionEditorViewModeKey), m_actionView->viewMode());
|
||||
}
|
||||
|
||||
void ActionEditor::updateViewModeActions()
|
||||
{
|
||||
switch (m_actionView->viewMode()) {
|
||||
case ActionView::IconView:
|
||||
m_iconViewAction->setChecked(true);
|
||||
break;
|
||||
case ActionView::DetailedView:
|
||||
m_listViewAction->setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ActionEditor::slotCopy()
|
||||
{
|
||||
QDesignerFormWindowInterface *fw = formWindow();
|
||||
if (!fw )
|
||||
return;
|
||||
|
||||
const ActionView::ActionList selection = m_actionView->selectedActions();
|
||||
if (selection.empty())
|
||||
return;
|
||||
|
||||
copyActions(fw, selection);
|
||||
}
|
||||
|
||||
void ActionEditor::slotCut()
|
||||
{
|
||||
QDesignerFormWindowInterface *fw = formWindow();
|
||||
if (!fw )
|
||||
return;
|
||||
|
||||
const ActionView::ActionList selection = m_actionView->selectedActions();
|
||||
if (selection.empty())
|
||||
return;
|
||||
|
||||
copyActions(fw, selection);
|
||||
deleteActions(fw, selection);
|
||||
}
|
||||
|
||||
void ActionEditor::slotPaste()
|
||||
{
|
||||
FormWindowBase *fw = qobject_cast<FormWindowBase *>(formWindow());
|
||||
if (!fw)
|
||||
return;
|
||||
m_actionView->clearSelection();
|
||||
fw->paste(FormWindowBase::PasteActionsOnly);
|
||||
}
|
||||
|
||||
void ActionEditor::slotContextMenuRequested(QContextMenuEvent *e, QAction *item)
|
||||
{
|
||||
// set up signal mapper
|
||||
if (!m_selectAssociatedWidgetsMapper) {
|
||||
m_selectAssociatedWidgetsMapper = new QSignalMapper(this);
|
||||
connect(m_selectAssociatedWidgetsMapper, SIGNAL(mapped(QWidget*)), this, SLOT(slotSelectAssociatedWidget(QWidget*)));
|
||||
}
|
||||
|
||||
QMenu menu(this);
|
||||
menu.addAction(m_actionNew);
|
||||
menu.addSeparator();
|
||||
menu.addAction(m_actionEdit);
|
||||
if (QDesignerTaskMenu::isSlotNavigationEnabled(m_core))
|
||||
menu.addAction(m_actionNavigateToSlot);
|
||||
|
||||
// Associated Widgets
|
||||
if (QAction *action = m_actionView->currentAction()) {
|
||||
const QWidgetList associatedWidgets = ActionModel::associatedWidgets(action);
|
||||
if (!associatedWidgets.empty()) {
|
||||
QMenu *associatedWidgetsSubMenu = menu.addMenu(tr("Used In"));
|
||||
foreach (QWidget *w, associatedWidgets) {
|
||||
QAction *action = associatedWidgetsSubMenu->addAction(w->objectName());
|
||||
m_selectAssociatedWidgetsMapper->setMapping(action, w);
|
||||
connect(action, SIGNAL(triggered()), m_selectAssociatedWidgetsMapper, SLOT(map()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
menu.addAction(m_actionCut);
|
||||
menu.addAction(m_actionCopy);
|
||||
menu.addAction(m_actionPaste);
|
||||
menu.addAction(m_actionSelectAll);
|
||||
menu.addAction(m_actionDelete);
|
||||
menu.addSeparator();
|
||||
menu.addAction(m_iconViewAction);
|
||||
menu.addAction(m_listViewAction);
|
||||
|
||||
emit contextMenuRequested(&menu, item);
|
||||
|
||||
menu.exec(e->globalPos());
|
||||
e->accept();
|
||||
}
|
||||
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
168
third/designer/lib/shared/actioneditor_p.h
Normal file
168
third/designer/lib/shared/actioneditor_p.h
Normal file
@@ -0,0 +1,168 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ACTIONEDITOR_H
|
||||
#define ACTIONEDITOR_H
|
||||
|
||||
#include "shared_global_p.h"
|
||||
#include <QtDesigner/QDesignerActionEditorInterface>
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerPropertyEditorInterface;
|
||||
class QDesignerSettingsInterface;
|
||||
class QMenu;
|
||||
class QActionGroup;
|
||||
class QSignalMapper;
|
||||
class QItemSelection;
|
||||
class QListWidget;
|
||||
class QPushButton;
|
||||
class QLineEdit;
|
||||
class QToolButton;
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
class ActionView;
|
||||
class ResourceMimeData;
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT ActionEditor: public QDesignerActionEditorInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
virtual ~ActionEditor();
|
||||
|
||||
QDesignerFormWindowInterface *formWindow() const;
|
||||
virtual void setFormWindow(QDesignerFormWindowInterface *formWindow);
|
||||
|
||||
virtual QDesignerFormEditorInterface *core() const;
|
||||
|
||||
QAction *actionNew() const;
|
||||
QAction *actionDelete() const;
|
||||
|
||||
QString filter() const;
|
||||
|
||||
virtual void manageAction(QAction *action);
|
||||
virtual void unmanageAction(QAction *action);
|
||||
|
||||
static QString actionTextToName(const QString &text, const QString &prefix = QLatin1String("action"));
|
||||
|
||||
// Utility to create a configure button with menu for usage on toolbars
|
||||
static QToolButton *createConfigureMenuButton(const QString &t, QMenu **ptrToMenu);
|
||||
|
||||
public slots:
|
||||
void setFilter(const QString &filter);
|
||||
void mainContainerChanged();
|
||||
|
||||
private slots:
|
||||
void slotCurrentItemChanged(QAction *item);
|
||||
void slotSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
|
||||
void editAction(QAction *item);
|
||||
void editCurrentAction();
|
||||
void navigateToSlotCurrentAction();
|
||||
void slotActionChanged();
|
||||
void slotNewAction();
|
||||
void slotDelete();
|
||||
void resourceImageDropped(const QString &path, QAction *action);
|
||||
void slotContextMenuRequested(QContextMenuEvent *, QAction *);
|
||||
void slotViewMode(QAction *a);
|
||||
void slotSelectAssociatedWidget(QWidget *w);
|
||||
void slotCopy();
|
||||
void slotCut();
|
||||
void slotPaste();
|
||||
|
||||
signals:
|
||||
void itemActivated(QAction *item);
|
||||
// Context menu for item or global menu if item == 0.
|
||||
void contextMenuRequested(QMenu *menu, QAction *item);
|
||||
|
||||
private:
|
||||
typedef QList<QAction *> ActionList;
|
||||
void deleteActions(QDesignerFormWindowInterface *formWindow, const ActionList &);
|
||||
void copyActions(QDesignerFormWindowInterface *formWindow, const ActionList &);
|
||||
|
||||
void restoreSettings();
|
||||
void saveSettings();
|
||||
|
||||
void updateViewModeActions();
|
||||
|
||||
QDesignerFormEditorInterface *m_core;
|
||||
QPointer<QDesignerFormWindowInterface> m_formWindow;
|
||||
QListWidget *m_actionGroups;
|
||||
|
||||
ActionView *m_actionView;
|
||||
|
||||
QAction *m_actionNew;
|
||||
QAction *m_actionEdit;
|
||||
QAction *m_actionNavigateToSlot;
|
||||
QAction *m_actionCopy;
|
||||
QAction *m_actionCut;
|
||||
QAction *m_actionPaste;
|
||||
QAction *m_actionSelectAll;
|
||||
QAction *m_actionDelete;
|
||||
|
||||
QActionGroup *m_viewModeGroup;
|
||||
QAction *m_iconViewAction;
|
||||
QAction *m_listViewAction;
|
||||
|
||||
QString m_filter;
|
||||
QWidget *m_filterWidget;
|
||||
QSignalMapper *m_selectAssociatedWidgetsMapper;
|
||||
};
|
||||
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // ACTIONEDITOR_H
|
||||
108
third/designer/lib/shared/actionprovider_p.h
Normal file
108
third/designer/lib/shared/actionprovider_p.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ACTIONPROVIDER_H
|
||||
#define ACTIONPROVIDER_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/extension.h>
|
||||
#include <QtCore/QPoint>
|
||||
#include <QtCore/QRect>
|
||||
#include <QtGui/QApplication>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QAction;
|
||||
|
||||
class QDesignerActionProviderExtension
|
||||
{
|
||||
public:
|
||||
virtual ~QDesignerActionProviderExtension() {}
|
||||
|
||||
virtual QRect actionGeometry(QAction *action) const = 0;
|
||||
virtual QAction *actionAt(const QPoint &pos) const = 0;
|
||||
|
||||
virtual void adjustIndicator(const QPoint &pos) = 0;
|
||||
};
|
||||
|
||||
// Find action at the given position for a widget that has actionGeometry() (QToolBar,
|
||||
// QMenuBar, QMenu). They usually have actionAt(), but that fails since Designer usually sets
|
||||
// WA_TransparentForMouseEvents on the widgets.
|
||||
template <class Widget>
|
||||
int actionIndexAt(const Widget *w, const QPoint &pos, Qt::Orientation orientation)
|
||||
{
|
||||
const QList<QAction*> actions = w->actions();
|
||||
const int actionCount = actions.count();
|
||||
if (actionCount == 0)
|
||||
return -1;
|
||||
// actionGeometry() can be wrong sometimes; it returns a geometry that
|
||||
// stretches to the end of the toolbar/menu bar. So, check from the beginning
|
||||
// in the case of a horizontal right-to-left orientation.
|
||||
const bool checkTopRight = orientation == Qt::Horizontal && w->layoutDirection() == Qt::RightToLeft;
|
||||
const QPoint topRight = QPoint(w->rect().width(), 0);
|
||||
for (int index = 0; index < actionCount; ++index) {
|
||||
QRect g = w->actionGeometry(actions.at(index));
|
||||
if (checkTopRight)
|
||||
g.setTopRight(topRight);
|
||||
else
|
||||
g.setTopLeft(QPoint(0, 0));
|
||||
|
||||
if (g.contains(pos))
|
||||
return index;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
Q_DECLARE_EXTENSION_INTERFACE(QDesignerActionProviderExtension, "com.trolltech.Qt.Designer.ActionProvider")
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // ACTIONPROVIDER_H
|
||||
663
third/designer/lib/shared/actionrepository.cpp
Normal file
663
third/designer/lib/shared/actionrepository.cpp
Normal file
@@ -0,0 +1,663 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "actionrepository_p.h"
|
||||
#include "qtresourceview_p.h"
|
||||
#include "iconloader_p.h"
|
||||
#include "qdesigner_utils_p.h"
|
||||
|
||||
#include <QtDesigner/QDesignerFormEditorInterface>
|
||||
#include <QtDesigner/QDesignerPropertySheetExtension>
|
||||
#include <QtDesigner/QExtensionManager>
|
||||
|
||||
#include <QtGui/QDrag>
|
||||
#include <QtGui/QContextMenuEvent>
|
||||
#include <QtGui/QStandardItemModel>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QHeaderView>
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/qevent.h>
|
||||
#include <QtCore/QSet>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
Q_DECLARE_METATYPE(QAction*)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace {
|
||||
enum { listModeIconSize = 16, iconModeIconSize = 24 };
|
||||
}
|
||||
|
||||
static const char *actionMimeType = "action-repository/actions";
|
||||
static const char *plainTextMimeType = "text/plain";
|
||||
|
||||
static inline QAction *actionOfItem(const QStandardItem* item)
|
||||
{
|
||||
return qvariant_cast<QAction*>(item->data(qdesigner_internal::ActionModel::ActionRole));
|
||||
}
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
// ----------- ActionModel
|
||||
ActionModel::ActionModel(QWidget *parent ) :
|
||||
QStandardItemModel(parent),
|
||||
m_emptyIcon(emptyIcon()),
|
||||
m_core(0)
|
||||
{
|
||||
QStringList headers;
|
||||
headers += tr("Name");
|
||||
headers += tr("Used");
|
||||
headers += tr("Text");
|
||||
headers += tr("Shortcut");
|
||||
headers += tr("Checkable");
|
||||
headers += tr("ToolTip");
|
||||
Q_ASSERT(NumColumns == headers.size());
|
||||
setHorizontalHeaderLabels(headers);
|
||||
}
|
||||
|
||||
void ActionModel::clearActions()
|
||||
{
|
||||
removeRows(0, rowCount());
|
||||
}
|
||||
|
||||
int ActionModel::findAction(QAction *action) const
|
||||
{
|
||||
const int rows = rowCount();
|
||||
for (int i = 0; i < rows; i++)
|
||||
if (action == actionOfItem(item(i)))
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ActionModel::update(int row)
|
||||
{
|
||||
Q_ASSERT(m_core);
|
||||
// need to create the row list ... grrr..
|
||||
if (row >= rowCount())
|
||||
return;
|
||||
|
||||
QStandardItemList list;
|
||||
for (int i = 0; i < NumColumns; i++)
|
||||
list += item(row, i);
|
||||
|
||||
setItems(m_core, actionOfItem(list.front()), m_emptyIcon, list);
|
||||
}
|
||||
|
||||
void ActionModel::remove(int row)
|
||||
{
|
||||
qDeleteAll(takeRow(row));
|
||||
}
|
||||
|
||||
QModelIndex ActionModel::addAction(QAction *action)
|
||||
{
|
||||
Q_ASSERT(m_core);
|
||||
QStandardItemList items;
|
||||
const Qt::ItemFlags flags = Qt::ItemIsSelectable|Qt::ItemIsDropEnabled|Qt::ItemIsDragEnabled|Qt::ItemIsEnabled;
|
||||
|
||||
QVariant itemData;
|
||||
qVariantSetValue(itemData, action);
|
||||
|
||||
for (int i = 0; i < NumColumns; i++) {
|
||||
QStandardItem *item = new QStandardItem;
|
||||
item->setData(itemData, ActionRole);
|
||||
item->setFlags(flags);
|
||||
items.push_back(item);
|
||||
}
|
||||
setItems(m_core, action, m_emptyIcon, items);
|
||||
appendRow(items);
|
||||
return indexFromItem(items.front());
|
||||
}
|
||||
|
||||
// Find the associated menus and toolbars, ignore toolbuttons
|
||||
QWidgetList ActionModel::associatedWidgets(const QAction *action)
|
||||
{
|
||||
QWidgetList rc = action->associatedWidgets();
|
||||
for (QWidgetList::iterator it = rc.begin(); it != rc.end(); )
|
||||
if (qobject_cast<const QMenu *>(*it) || qobject_cast<const QToolBar *>(*it)) {
|
||||
++it;
|
||||
} else {
|
||||
it = rc.erase(it);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
// shortcut is a fake property, need to retrieve it via property sheet.
|
||||
PropertySheetKeySequenceValue ActionModel::actionShortCut(QDesignerFormEditorInterface *core, QAction *action)
|
||||
{
|
||||
QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), action);
|
||||
if (!sheet)
|
||||
return PropertySheetKeySequenceValue();
|
||||
return actionShortCut(sheet);
|
||||
}
|
||||
|
||||
PropertySheetKeySequenceValue ActionModel::actionShortCut(const QDesignerPropertySheetExtension *sheet)
|
||||
{
|
||||
const int index = sheet->indexOf(QLatin1String("shortcut"));
|
||||
if (index == -1)
|
||||
return PropertySheetKeySequenceValue();
|
||||
return qvariant_cast<PropertySheetKeySequenceValue>(sheet->property(index));
|
||||
}
|
||||
|
||||
void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action,
|
||||
const QIcon &defaultIcon,
|
||||
QStandardItemList &sl)
|
||||
{
|
||||
|
||||
// Tooltip, mostly for icon view mode
|
||||
QString firstTooltip = action->objectName();
|
||||
const QString text = action->text();
|
||||
if (!text.isEmpty()) {
|
||||
firstTooltip += QLatin1Char('\n');
|
||||
firstTooltip += text;
|
||||
}
|
||||
|
||||
Q_ASSERT(sl.size() == NumColumns);
|
||||
|
||||
QStandardItem *item = sl[NameColumn];
|
||||
item->setText(action->objectName());
|
||||
QIcon icon = action->icon();
|
||||
if (icon.isNull())
|
||||
icon = defaultIcon;
|
||||
item->setIcon(icon);
|
||||
item->setToolTip(firstTooltip);
|
||||
item->setWhatsThis(firstTooltip);
|
||||
// Used
|
||||
const QWidgetList associatedDesignerWidgets = associatedWidgets(action);
|
||||
const bool used = !associatedDesignerWidgets.empty();
|
||||
item = sl[UsedColumn];
|
||||
item->setCheckState(used ? Qt::Checked : Qt::Unchecked);
|
||||
if (used) {
|
||||
QString usedToolTip;
|
||||
const QString separator = QLatin1String(", ");
|
||||
const int count = associatedDesignerWidgets.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (i)
|
||||
usedToolTip += separator;
|
||||
usedToolTip += associatedDesignerWidgets.at(i)->objectName();
|
||||
}
|
||||
item->setToolTip(usedToolTip);
|
||||
} else {
|
||||
item->setToolTip(QString());
|
||||
}
|
||||
// text
|
||||
item = sl[TextColumn];
|
||||
item->setText(action->text());
|
||||
item->setToolTip(action->text());
|
||||
// shortcut
|
||||
const QString shortcut = actionShortCut(core, action).value().toString(QKeySequence::NativeText);
|
||||
item = sl[ShortCutColumn];
|
||||
item->setText(shortcut);
|
||||
item->setToolTip(shortcut);
|
||||
// checkable
|
||||
sl[CheckedColumn]->setCheckState(action->isCheckable() ? Qt::Checked : Qt::Unchecked);
|
||||
// ToolTip. This might be multi-line, rich text
|
||||
QString toolTip = action->toolTip();
|
||||
item = sl[ToolTipColumn];
|
||||
item->setToolTip(toolTip);
|
||||
item->setText(toolTip.replace(QLatin1Char('\n'), QLatin1Char(' ')));
|
||||
}
|
||||
|
||||
QMimeData *ActionModel::mimeData(const QModelIndexList &indexes ) const
|
||||
{
|
||||
ActionRepositoryMimeData::ActionList actionList;
|
||||
|
||||
QSet<QAction*> actions;
|
||||
foreach (const QModelIndex &index, indexes)
|
||||
if (QStandardItem *item = itemFromIndex(index))
|
||||
if (QAction *action = actionOfItem(item))
|
||||
actions.insert(action);
|
||||
return new ActionRepositoryMimeData(actions.toList(), Qt::CopyAction);
|
||||
}
|
||||
|
||||
// Resource images are plain text. The drag needs to be restricted, however.
|
||||
QStringList ActionModel::mimeTypes() const
|
||||
{
|
||||
return QStringList(QLatin1String(plainTextMimeType));
|
||||
}
|
||||
|
||||
QString ActionModel::actionName(int row) const
|
||||
{
|
||||
return item(row, NameColumn)->text();
|
||||
}
|
||||
|
||||
bool ActionModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &)
|
||||
{
|
||||
if (action != Qt::CopyAction)
|
||||
return false;
|
||||
|
||||
QStandardItem *droppedItem = item(row, column);
|
||||
if (!droppedItem)
|
||||
return false;
|
||||
|
||||
|
||||
QtResourceView::ResourceType type;
|
||||
QString path;
|
||||
if (!QtResourceView::decodeMimeData(data, &type, &path) || type != QtResourceView::ResourceImage)
|
||||
return false;
|
||||
|
||||
emit resourceImageDropped(path, actionOfItem(droppedItem));
|
||||
return true;
|
||||
}
|
||||
|
||||
QAction *ActionModel::actionAt(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
QStandardItem *i = itemFromIndex(index);
|
||||
if (!i)
|
||||
return 0;
|
||||
return actionOfItem(i);
|
||||
}
|
||||
|
||||
// helpers
|
||||
|
||||
static bool handleImageDragEnterMoveEvent(QDropEvent *event)
|
||||
{
|
||||
QtResourceView::ResourceType type;
|
||||
const bool rc = QtResourceView::decodeMimeData(event->mimeData(), &type) && type == QtResourceView::ResourceImage;
|
||||
if (rc)
|
||||
event->acceptProposedAction();
|
||||
else
|
||||
event->ignore();
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void handleImageDropEvent(const QAbstractItemView *iv, QDropEvent *event, ActionModel *am)
|
||||
{
|
||||
const QModelIndex index = iv->indexAt(event->pos());
|
||||
if (!index.isValid()) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!handleImageDragEnterMoveEvent(event))
|
||||
return;
|
||||
|
||||
am->dropMimeData(event->mimeData(), event->proposedAction(), index.row(), 0, iv->rootIndex());
|
||||
}
|
||||
|
||||
// Basically mimic QAbstractItemView's startDrag routine, except that
|
||||
// another pixmap is used, we don't want the whole row.
|
||||
|
||||
void startActionDrag(QWidget *dragParent, ActionModel *model, const QModelIndexList &indexes, Qt::DropActions supportedActions)
|
||||
{
|
||||
if (indexes.empty())
|
||||
return;
|
||||
|
||||
QDrag *drag = new QDrag(dragParent);
|
||||
QMimeData *data = model->mimeData(indexes);
|
||||
drag->setMimeData(data);
|
||||
if (ActionRepositoryMimeData *actionMimeData = qobject_cast<ActionRepositoryMimeData *>(data))
|
||||
drag->setPixmap(ActionRepositoryMimeData::actionDragPixmap(actionMimeData->actionList().front()));
|
||||
|
||||
drag->start(supportedActions);
|
||||
}
|
||||
|
||||
// ---------------- ActionTreeView:
|
||||
ActionTreeView::ActionTreeView(ActionModel *model, QWidget *parent) :
|
||||
QTreeView(parent),
|
||||
m_model(model)
|
||||
{
|
||||
setDragEnabled(true);
|
||||
setAcceptDrops(true);
|
||||
setDropIndicatorShown(true);
|
||||
setDragDropMode(DragDrop);
|
||||
setModel(model);
|
||||
setRootIsDecorated(false);
|
||||
setTextElideMode(Qt::ElideMiddle);
|
||||
|
||||
setModel(model);
|
||||
connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(slotActivated(QModelIndex)));
|
||||
connect(header(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(resizeColumnToContents(int)));
|
||||
|
||||
setIconSize(QSize(listModeIconSize, listModeIconSize));
|
||||
|
||||
}
|
||||
|
||||
QAction *ActionTreeView::currentAction() const
|
||||
{
|
||||
return m_model->actionAt(currentIndex());
|
||||
}
|
||||
|
||||
void ActionTreeView::filter(const QString &text)
|
||||
{
|
||||
const int rowCount = m_model->rowCount();
|
||||
const bool empty = text.isEmpty();
|
||||
const QModelIndex parent = rootIndex();
|
||||
for (int i = 0; i < rowCount; i++)
|
||||
setRowHidden(i, parent, !empty && !m_model->actionName(i).contains(text, Qt::CaseInsensitive));
|
||||
}
|
||||
|
||||
void ActionTreeView::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
handleImageDragEnterMoveEvent(event);
|
||||
}
|
||||
|
||||
void ActionTreeView::dragMoveEvent(QDragMoveEvent *event)
|
||||
{
|
||||
handleImageDragEnterMoveEvent(event);
|
||||
}
|
||||
|
||||
void ActionTreeView::dropEvent(QDropEvent *event)
|
||||
{
|
||||
handleImageDropEvent(this, event, m_model);
|
||||
}
|
||||
|
||||
void ActionTreeView::focusInEvent(QFocusEvent *event)
|
||||
{
|
||||
QTreeView::focusInEvent(event);
|
||||
// Make property editor display current action
|
||||
if (QAction *a = currentAction())
|
||||
emit currentChanged(a);
|
||||
}
|
||||
|
||||
void ActionTreeView::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
emit contextMenuRequested(event, m_model->actionAt(indexAt(event->pos())));
|
||||
}
|
||||
|
||||
void ActionTreeView::currentChanged(const QModelIndex ¤t, const QModelIndex &/*previous*/)
|
||||
{
|
||||
emit currentChanged(m_model->actionAt(current));
|
||||
}
|
||||
|
||||
void ActionTreeView::slotActivated(const QModelIndex &index)
|
||||
{
|
||||
emit activated(m_model->actionAt(index));
|
||||
}
|
||||
|
||||
void ActionTreeView::startDrag(Qt::DropActions supportedActions)
|
||||
{
|
||||
startActionDrag(this, m_model, selectedIndexes(), supportedActions);
|
||||
}
|
||||
|
||||
// ---------------- ActionListView:
|
||||
ActionListView::ActionListView(ActionModel *model, QWidget *parent) :
|
||||
QListView(parent),
|
||||
m_model(model)
|
||||
{
|
||||
setDragEnabled(true);
|
||||
setAcceptDrops(true);
|
||||
setDropIndicatorShown(true);
|
||||
setDragDropMode(DragDrop);
|
||||
setModel(model);
|
||||
setTextElideMode(Qt::ElideMiddle);
|
||||
connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(slotActivated(QModelIndex)));
|
||||
|
||||
// We actually want 'Static' as the user should be able to
|
||||
// drag away actions only (not to rearrange icons).
|
||||
// We emulate that by not accepting our own
|
||||
// drag data. 'Static' causes the list view to disable drag and drop
|
||||
// on the viewport.
|
||||
setMovement(Snap);
|
||||
setViewMode(IconMode);
|
||||
setIconSize(QSize(iconModeIconSize, iconModeIconSize));
|
||||
setGridSize(QSize(4 * iconModeIconSize, 2 * iconModeIconSize));
|
||||
setSpacing(iconModeIconSize / 3);
|
||||
}
|
||||
|
||||
QAction *ActionListView::currentAction() const
|
||||
{
|
||||
return m_model->actionAt(currentIndex());
|
||||
}
|
||||
|
||||
void ActionListView::filter(const QString &text)
|
||||
{
|
||||
const int rowCount = m_model->rowCount();
|
||||
const bool empty = text.isEmpty();
|
||||
for (int i = 0; i < rowCount; i++)
|
||||
setRowHidden(i, !empty && !m_model->actionName(i).contains(text, Qt::CaseInsensitive));
|
||||
}
|
||||
|
||||
void ActionListView::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
handleImageDragEnterMoveEvent(event);
|
||||
}
|
||||
|
||||
void ActionListView::dragMoveEvent(QDragMoveEvent *event)
|
||||
{
|
||||
handleImageDragEnterMoveEvent(event);
|
||||
}
|
||||
|
||||
void ActionListView::dropEvent(QDropEvent *event)
|
||||
{
|
||||
handleImageDropEvent(this, event, m_model);
|
||||
}
|
||||
|
||||
void ActionListView::focusInEvent(QFocusEvent *event)
|
||||
{
|
||||
QListView::focusInEvent(event);
|
||||
// Make property editor display current action
|
||||
if (QAction *a = currentAction())
|
||||
emit currentChanged(a);
|
||||
}
|
||||
|
||||
void ActionListView::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
emit contextMenuRequested(event, m_model->actionAt(indexAt(event->pos())));
|
||||
}
|
||||
|
||||
void ActionListView::currentChanged(const QModelIndex ¤t, const QModelIndex & /*previous*/)
|
||||
{
|
||||
emit currentChanged(m_model->actionAt(current));
|
||||
}
|
||||
|
||||
void ActionListView::slotActivated(const QModelIndex &index)
|
||||
{
|
||||
emit activated(m_model->actionAt(index));
|
||||
}
|
||||
|
||||
void ActionListView::startDrag(Qt::DropActions supportedActions)
|
||||
{
|
||||
startActionDrag(this, m_model, selectedIndexes(), supportedActions);
|
||||
}
|
||||
|
||||
// ActionView
|
||||
ActionView::ActionView(QWidget *parent) :
|
||||
QStackedWidget(parent),
|
||||
m_model(new ActionModel(this)),
|
||||
m_actionTreeView(new ActionTreeView(m_model)),
|
||||
m_actionListView(new ActionListView(m_model))
|
||||
{
|
||||
addWidget(m_actionListView);
|
||||
addWidget(m_actionTreeView);
|
||||
// Wire signals
|
||||
connect(m_actionTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*,QAction*)),
|
||||
this, SIGNAL(contextMenuRequested(QContextMenuEvent*,QAction*)));
|
||||
connect(m_actionListView, SIGNAL(contextMenuRequested(QContextMenuEvent*,QAction*)),
|
||||
this, SIGNAL(contextMenuRequested(QContextMenuEvent*,QAction*)));
|
||||
|
||||
// make it possible for vs integration to reimplement edit action dialog
|
||||
// [which it shouldn't do actually]
|
||||
connect(m_actionListView, SIGNAL(activated(QAction*)), this, SIGNAL(activated(QAction*)));
|
||||
connect(m_actionTreeView, SIGNAL(activated(QAction*)), this, SIGNAL(activated(QAction*)));
|
||||
|
||||
connect(m_actionListView, SIGNAL(currentChanged(QAction*)),this, SLOT(slotCurrentChanged(QAction*)));
|
||||
connect(m_actionTreeView, SIGNAL(currentChanged(QAction*)),this, SLOT(slotCurrentChanged(QAction*)));
|
||||
|
||||
connect(m_model, SIGNAL(resourceImageDropped(QString,QAction*)),
|
||||
this, SIGNAL(resourceImageDropped(QString,QAction*)));
|
||||
|
||||
// sync selection models
|
||||
QItemSelectionModel *selectionModel = m_actionTreeView->selectionModel();
|
||||
m_actionListView->setSelectionModel(selectionModel);
|
||||
connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
||||
this, SIGNAL(selectionChanged(QItemSelection,QItemSelection)));
|
||||
}
|
||||
|
||||
int ActionView::viewMode() const
|
||||
{
|
||||
return currentWidget() == m_actionListView ? IconView : DetailedView;
|
||||
}
|
||||
|
||||
void ActionView::setViewMode(int lm)
|
||||
{
|
||||
if (viewMode() == lm)
|
||||
return;
|
||||
|
||||
switch (lm) {
|
||||
case IconView:
|
||||
setCurrentWidget(m_actionListView);
|
||||
break;
|
||||
case DetailedView:
|
||||
setCurrentWidget(m_actionTreeView);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ActionView::slotCurrentChanged(QAction *action)
|
||||
{
|
||||
// emit only for currently visible
|
||||
if (sender() == currentWidget())
|
||||
emit currentChanged(action);
|
||||
}
|
||||
|
||||
void ActionView::filter(const QString &text)
|
||||
{
|
||||
m_actionTreeView->filter(text);
|
||||
m_actionListView->filter(text);
|
||||
}
|
||||
|
||||
void ActionView::selectAll()
|
||||
{
|
||||
m_actionTreeView->selectAll();
|
||||
}
|
||||
|
||||
void ActionView::clearSelection()
|
||||
{
|
||||
m_actionTreeView->selectionModel()->clearSelection();
|
||||
}
|
||||
|
||||
void ActionView::setCurrentIndex(const QModelIndex &index)
|
||||
{
|
||||
m_actionTreeView->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
QAction *ActionView::currentAction() const
|
||||
{
|
||||
return m_actionListView->currentAction();
|
||||
}
|
||||
|
||||
void ActionView::setSelectionMode(QAbstractItemView::SelectionMode sm)
|
||||
{
|
||||
m_actionTreeView->setSelectionMode(sm);
|
||||
m_actionListView->setSelectionMode(sm);
|
||||
}
|
||||
|
||||
QAbstractItemView::SelectionMode ActionView::selectionMode() const
|
||||
{
|
||||
return m_actionListView->selectionMode();
|
||||
}
|
||||
|
||||
QItemSelection ActionView::selection() const
|
||||
{
|
||||
return m_actionListView->selectionModel()->selection();
|
||||
}
|
||||
|
||||
ActionView::ActionList ActionView::selectedActions() const
|
||||
{
|
||||
ActionList rc;
|
||||
foreach (const QModelIndex &index, selection().indexes())
|
||||
if (index.column() == 0)
|
||||
rc += actionOfItem(m_model->itemFromIndex(index));
|
||||
return rc;
|
||||
}
|
||||
// ---------- ActionRepositoryMimeData
|
||||
ActionRepositoryMimeData::ActionRepositoryMimeData(QAction *a, Qt::DropAction dropAction) :
|
||||
m_dropAction(dropAction)
|
||||
{
|
||||
m_actionList += a;
|
||||
}
|
||||
|
||||
ActionRepositoryMimeData::ActionRepositoryMimeData(const ActionList &al, Qt::DropAction dropAction) :
|
||||
m_dropAction(dropAction),
|
||||
m_actionList(al)
|
||||
{
|
||||
}
|
||||
|
||||
QStringList ActionRepositoryMimeData::formats() const
|
||||
{
|
||||
return QStringList(QLatin1String(actionMimeType));
|
||||
}
|
||||
|
||||
QPixmap ActionRepositoryMimeData::actionDragPixmap(const QAction *action)
|
||||
{
|
||||
|
||||
// Try to find a suitable pixmap. Grab either widget or icon.
|
||||
const QIcon icon = action->icon();
|
||||
if (!icon.isNull())
|
||||
return icon.pixmap(QSize(22, 22));
|
||||
|
||||
foreach (QWidget *w, action->associatedWidgets())
|
||||
if (QToolButton *tb = qobject_cast<QToolButton *>(w))
|
||||
return QPixmap::grabWidget(tb);
|
||||
|
||||
// Create a QToolButton
|
||||
QToolButton *tb = new QToolButton;
|
||||
tb->setText(action->text());
|
||||
tb->setToolButtonStyle(Qt::ToolButtonTextOnly);
|
||||
#ifdef Q_WS_WIN // Force alien off to make adjustSize() take the system minimumsize into account.
|
||||
tb->createWinId();
|
||||
#endif
|
||||
tb->adjustSize();
|
||||
const QPixmap rc = QPixmap::grabWidget(tb);
|
||||
tb->deleteLater();
|
||||
return rc;
|
||||
}
|
||||
|
||||
void ActionRepositoryMimeData::accept(QDragMoveEvent *event) const
|
||||
{
|
||||
if (event->proposedAction() == m_dropAction) {
|
||||
event->acceptProposedAction();
|
||||
} else {
|
||||
event->setDropAction(m_dropAction);
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
269
third/designer/lib/shared/actionrepository_p.h
Normal file
269
third/designer/lib/shared/actionrepository_p.h
Normal file
@@ -0,0 +1,269 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 ACTIONREPOSITORY_H
|
||||
#define ACTIONREPOSITORY_H
|
||||
|
||||
#include "shared_global_p.h"
|
||||
#include <QtCore/QMimeData>
|
||||
#include <QtGui/QStandardItemModel>
|
||||
#include <QtGui/QTreeView>
|
||||
#include <QtGui/QListView>
|
||||
#include <QtGui/QStackedWidget>
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QPixmap;
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
class QDesignerPropertySheetExtension;
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
class PropertySheetKeySequenceValue;
|
||||
|
||||
// Shared model of actions, to be used for several views (detailed/icon view).
|
||||
class QDESIGNER_SHARED_EXPORT ActionModel: public QStandardItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns { NameColumn, UsedColumn, TextColumn, ShortCutColumn, CheckedColumn, ToolTipColumn, NumColumns };
|
||||
enum { ActionRole = Qt::UserRole + 1000 };
|
||||
|
||||
explicit ActionModel(QWidget *parent = 0);
|
||||
void initialize(QDesignerFormEditorInterface *core) { m_core = core; }
|
||||
|
||||
void clearActions();
|
||||
QModelIndex addAction(QAction *a);
|
||||
// remove row
|
||||
void remove(int row);
|
||||
// update the row from the underlying action
|
||||
void update(int row);
|
||||
|
||||
// return row of action or -1.
|
||||
int findAction(QAction *) const;
|
||||
|
||||
QString actionName(int row) const;
|
||||
QAction *actionAt(const QModelIndex &index) const;
|
||||
|
||||
virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
|
||||
virtual QStringList mimeTypes() const;
|
||||
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
|
||||
|
||||
// Find the associated menus and toolbars, ignore toolbuttons
|
||||
static QWidgetList associatedWidgets(const QAction *action);
|
||||
|
||||
// Retrieve shortcut via property sheet as it is a fake property
|
||||
static PropertySheetKeySequenceValue actionShortCut(QDesignerFormEditorInterface *core, QAction *action);
|
||||
static PropertySheetKeySequenceValue actionShortCut(const QDesignerPropertySheetExtension *ps);
|
||||
|
||||
signals:
|
||||
void resourceImageDropped(const QString &path, QAction *action);
|
||||
|
||||
private:
|
||||
typedef QList<QStandardItem *> QStandardItemList;
|
||||
|
||||
void initializeHeaders();
|
||||
static void setItems(QDesignerFormEditorInterface *core, QAction *a,
|
||||
const QIcon &defaultIcon,
|
||||
QStandardItemList &sl);
|
||||
|
||||
const QIcon m_emptyIcon;
|
||||
|
||||
QDesignerFormEditorInterface *m_core;
|
||||
};
|
||||
|
||||
// Internal class that provides the detailed view of actions.
|
||||
class ActionTreeView: public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ActionTreeView(ActionModel *model, QWidget *parent = 0);
|
||||
QAction *currentAction() const;
|
||||
|
||||
public slots:
|
||||
void filter(const QString &text);
|
||||
|
||||
signals:
|
||||
void contextMenuRequested(QContextMenuEvent *event, QAction *);
|
||||
void currentChanged(QAction *action);
|
||||
void activated(QAction *action);
|
||||
|
||||
protected slots:
|
||||
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
|
||||
protected:
|
||||
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||
virtual void dragMoveEvent(QDragMoveEvent *event);
|
||||
virtual void dropEvent(QDropEvent *event);
|
||||
virtual void focusInEvent(QFocusEvent *event);
|
||||
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||
virtual void startDrag(Qt::DropActions supportedActions);
|
||||
|
||||
private slots:
|
||||
void slotActivated(const QModelIndex &);
|
||||
|
||||
private:
|
||||
ActionModel *m_model;
|
||||
};
|
||||
|
||||
// Internal class that provides the icon view of actions.
|
||||
class ActionListView: public QListView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ActionListView(ActionModel *model, QWidget *parent = 0);
|
||||
QAction *currentAction() const;
|
||||
|
||||
public slots:
|
||||
void filter(const QString &text);
|
||||
|
||||
signals:
|
||||
void contextMenuRequested(QContextMenuEvent *event, QAction *);
|
||||
void currentChanged(QAction *action);
|
||||
void activated(QAction *action);
|
||||
|
||||
protected slots:
|
||||
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
|
||||
protected:
|
||||
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||
virtual void dragMoveEvent(QDragMoveEvent *event);
|
||||
virtual void dropEvent(QDropEvent *event);
|
||||
virtual void focusInEvent(QFocusEvent *event);
|
||||
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||
virtual void startDrag(Qt::DropActions supportedActions);
|
||||
|
||||
private slots:
|
||||
void slotActivated(const QModelIndex &);
|
||||
|
||||
private:
|
||||
ActionModel *m_model;
|
||||
};
|
||||
|
||||
// Action View that can be switched between detailed and icon view
|
||||
// using a QStackedWidget of ActionListView / ActionTreeView
|
||||
// that share the item model and the selection model.
|
||||
|
||||
class ActionView : public QStackedWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
// Separate initialize() function takes core argument to make this
|
||||
// thing usable as promoted widget.
|
||||
explicit ActionView(QWidget *parent = 0);
|
||||
void initialize(QDesignerFormEditorInterface *core) { m_model->initialize(core); }
|
||||
|
||||
// View mode
|
||||
enum { DetailedView, IconView };
|
||||
int viewMode() const;
|
||||
void setViewMode(int lm);
|
||||
|
||||
void setSelectionMode(QAbstractItemView::SelectionMode sm);
|
||||
QAbstractItemView::SelectionMode selectionMode() const;
|
||||
|
||||
ActionModel *model() const { return m_model; }
|
||||
|
||||
QAction *currentAction() const;
|
||||
void setCurrentIndex(const QModelIndex &index);
|
||||
|
||||
typedef QList<QAction*> ActionList;
|
||||
ActionList selectedActions() const;
|
||||
QItemSelection selection() const;
|
||||
|
||||
public slots:
|
||||
void filter(const QString &text);
|
||||
void selectAll();
|
||||
void clearSelection();
|
||||
|
||||
signals:
|
||||
void contextMenuRequested(QContextMenuEvent *event, QAction *);
|
||||
void currentChanged(QAction *action);
|
||||
void activated(QAction *action);
|
||||
void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
|
||||
void resourceImageDropped(const QString &data, QAction *action);
|
||||
|
||||
private slots:
|
||||
void slotCurrentChanged(QAction *action);
|
||||
|
||||
private:
|
||||
ActionModel *m_model;
|
||||
ActionTreeView *m_actionTreeView;
|
||||
ActionListView *m_actionListView;
|
||||
};
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT ActionRepositoryMimeData: public QMimeData
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef QList<QAction*> ActionList;
|
||||
|
||||
ActionRepositoryMimeData(const ActionList &, Qt::DropAction dropAction);
|
||||
ActionRepositoryMimeData(QAction *, Qt::DropAction dropAction);
|
||||
|
||||
const ActionList &actionList() const { return m_actionList; }
|
||||
virtual QStringList formats() const;
|
||||
|
||||
static QPixmap actionDragPixmap(const QAction *action);
|
||||
|
||||
// Utility to accept with right action
|
||||
void accept(QDragMoveEvent *event) const;
|
||||
private:
|
||||
const Qt::DropAction m_dropAction;
|
||||
ActionList m_actionList;
|
||||
};
|
||||
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // ACTIONREPOSITORY_H
|
||||
112
third/designer/lib/shared/addlinkdialog.ui
Normal file
112
third/designer/lib/shared/addlinkdialog.ui
Normal file
@@ -0,0 +1,112 @@
|
||||
<ui version="4.0" >
|
||||
<class>AddLinkDialog</class>
|
||||
<widget class="QDialog" name="AddLinkDialog" >
|
||||
<property name="windowTitle" >
|
||||
<string>Insert Link</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="modal" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<item>
|
||||
<layout class="QFormLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Title:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="titleInput" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>337</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>URL:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="urlInput" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons" >
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>AddLinkDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>AddLinkDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
262
third/designer/lib/shared/codedialog.cpp
Normal file
262
third/designer/lib/shared/codedialog.cpp
Normal 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "codedialog_p.h"
|
||||
#include "qdesigner_utils_p.h"
|
||||
#include "iconloader_p.h"
|
||||
|
||||
#include <texteditfindwidget.h>
|
||||
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QClipboard>
|
||||
#include <QtGui/QDialogButtonBox>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtGui/QKeyEvent>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QTemporaryFile>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace qdesigner_internal {
|
||||
// ----------------- CodeDialogPrivate
|
||||
struct CodeDialog::CodeDialogPrivate {
|
||||
CodeDialogPrivate();
|
||||
|
||||
QTextEdit *m_textEdit;
|
||||
TextEditFindWidget *m_findWidget;
|
||||
QString m_formFileName;
|
||||
};
|
||||
|
||||
CodeDialog::CodeDialogPrivate::CodeDialogPrivate()
|
||||
: m_textEdit(new QTextEdit)
|
||||
, m_findWidget(new TextEditFindWidget)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------- CodeDialog
|
||||
CodeDialog::CodeDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
m_impl(new CodeDialogPrivate)
|
||||
{
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
QVBoxLayout *vBoxLayout = new QVBoxLayout;
|
||||
|
||||
// Edit tool bar
|
||||
QToolBar *toolBar = new QToolBar;
|
||||
|
||||
const QIcon saveIcon = createIconSet(QLatin1String("filesave.png"));
|
||||
QAction *saveAction = toolBar->addAction(saveIcon, tr("Save..."));
|
||||
connect(saveAction, SIGNAL(triggered()), this, SLOT(slotSaveAs()));
|
||||
|
||||
const QIcon copyIcon = createIconSet(QLatin1String("editcopy.png"));
|
||||
QAction *copyAction = toolBar->addAction(copyIcon, tr("Copy All"));
|
||||
connect(copyAction, SIGNAL(triggered()), this, SLOT(copyAll()));
|
||||
|
||||
QAction *findAction = toolBar->addAction(
|
||||
TextEditFindWidget::findIconSet(),
|
||||
tr("&Find in Text..."),
|
||||
m_impl->m_findWidget, SLOT(activate()));
|
||||
findAction->setShortcut(QKeySequence::Find);
|
||||
|
||||
vBoxLayout->addWidget(toolBar);
|
||||
|
||||
// Edit
|
||||
m_impl->m_textEdit->setReadOnly(true);
|
||||
m_impl->m_textEdit->setMinimumSize(QSize(
|
||||
m_impl->m_findWidget->minimumSize().width(),
|
||||
500));
|
||||
vBoxLayout->addWidget(m_impl->m_textEdit);
|
||||
|
||||
// Find
|
||||
m_impl->m_findWidget->setTextEdit(m_impl->m_textEdit);
|
||||
vBoxLayout->addWidget(m_impl->m_findWidget);
|
||||
|
||||
// Button box
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
// Disable auto default
|
||||
QPushButton *closeButton = buttonBox->button(QDialogButtonBox::Close);
|
||||
closeButton->setAutoDefault(false);
|
||||
vBoxLayout->addWidget(buttonBox);
|
||||
|
||||
setLayout(vBoxLayout);
|
||||
}
|
||||
|
||||
CodeDialog::~CodeDialog()
|
||||
{
|
||||
delete m_impl;
|
||||
}
|
||||
|
||||
void CodeDialog::setCode(const QString &code)
|
||||
{
|
||||
m_impl->m_textEdit->setPlainText(code);
|
||||
}
|
||||
|
||||
QString CodeDialog::code() const
|
||||
{
|
||||
return m_impl->m_textEdit->toPlainText();
|
||||
}
|
||||
|
||||
void CodeDialog::setFormFileName(const QString &f)
|
||||
{
|
||||
m_impl->m_formFileName = f;
|
||||
}
|
||||
|
||||
QString CodeDialog::formFileName() const
|
||||
{
|
||||
return m_impl->m_formFileName;
|
||||
}
|
||||
|
||||
bool CodeDialog::generateCode(const QDesignerFormWindowInterface *fw,
|
||||
QString *code,
|
||||
QString *errorMessage)
|
||||
{
|
||||
// Generate temporary file name similar to form file name
|
||||
// (for header guards)
|
||||
QString tempPattern = QDir::tempPath();
|
||||
if (!tempPattern.endsWith(QDir::separator())) // platform-dependant
|
||||
tempPattern += QDir::separator();
|
||||
const QString fileName = fw->fileName();
|
||||
if (fileName.isEmpty()) {
|
||||
tempPattern += QLatin1String("designer");
|
||||
} else {
|
||||
tempPattern += QFileInfo(fileName).baseName();
|
||||
}
|
||||
tempPattern += QLatin1String("XXXXXX.ui");
|
||||
// Write to temp file
|
||||
QTemporaryFile tempFormFile(tempPattern);
|
||||
|
||||
tempFormFile.setAutoRemove(true);
|
||||
if (!tempFormFile.open()) {
|
||||
*errorMessage = tr("A temporary form file could not be created in %1.").arg(QDir::tempPath());
|
||||
return false;
|
||||
}
|
||||
const QString tempFormFileName = tempFormFile.fileName();
|
||||
tempFormFile.write(fw->contents().toUtf8());
|
||||
if (!tempFormFile.flush()) {
|
||||
*errorMessage = tr("The temporary form file %1 could not be written.").arg(tempFormFileName);
|
||||
return false;
|
||||
}
|
||||
tempFormFile.close();
|
||||
// Run uic
|
||||
QByteArray rc;
|
||||
if (!runUIC(tempFormFileName, UIC_GenerateCode, rc, *errorMessage))
|
||||
return false;
|
||||
*code = QString::fromUtf8(rc);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CodeDialog::showCodeDialog(const QDesignerFormWindowInterface *fw,
|
||||
QWidget *parent,
|
||||
QString *errorMessage)
|
||||
{
|
||||
QString code;
|
||||
if (!generateCode(fw, &code, errorMessage))
|
||||
return false;
|
||||
|
||||
CodeDialog dialog(parent);
|
||||
dialog.setWindowTitle(tr("%1 - [Code]").arg(fw->mainContainer()->windowTitle()));
|
||||
dialog.setCode(code);
|
||||
dialog.setFormFileName(fw->fileName());
|
||||
dialog.exec();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CodeDialog::slotSaveAs()
|
||||
{
|
||||
// build the default relative name 'ui_sth.h'
|
||||
const QString headerSuffix = QString(QLatin1Char('h'));
|
||||
QString filter;
|
||||
const QString uiFile = formFileName();
|
||||
|
||||
if (!uiFile.isEmpty()) {
|
||||
filter = QLatin1String("ui_");
|
||||
filter += QFileInfo(uiFile).baseName();
|
||||
filter += QLatin1Char('.');
|
||||
filter += headerSuffix;
|
||||
}
|
||||
// file dialog
|
||||
while (true) {
|
||||
const QString fileName =
|
||||
QFileDialog::getSaveFileName (this, tr("Save Code"), filter, tr("Header Files (*.%1)").arg(headerSuffix));
|
||||
if (fileName.isEmpty())
|
||||
break;
|
||||
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly|QIODevice::Text)) {
|
||||
warning(tr("The file %1 could not be opened: %2").arg(fileName).arg(file.errorString()));
|
||||
continue;
|
||||
}
|
||||
file.write(code().toUtf8());
|
||||
if (!file.flush()) {
|
||||
warning(tr("The file %1 could not be written: %2").arg(fileName).arg(file.errorString()));
|
||||
continue;
|
||||
}
|
||||
file.close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CodeDialog::warning(const QString &msg)
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this, tr("%1 - Error").arg(windowTitle()),
|
||||
msg, QMessageBox::Close);
|
||||
}
|
||||
|
||||
void CodeDialog::copyAll()
|
||||
{
|
||||
QApplication::clipboard()->setText(code());
|
||||
}
|
||||
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
100
third/designer/lib/shared/codedialog_p.h
Normal file
100
third/designer/lib/shared/codedialog_p.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 CODEPREVIEWDIALOG_H
|
||||
#define CODEPREVIEWDIALOG_H
|
||||
|
||||
#include "shared_global_p.h"
|
||||
#include <QtGui/QDialog>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormWindowInterface;
|
||||
|
||||
namespace qdesigner_internal {
|
||||
// Dialog for viewing code.
|
||||
class QDESIGNER_SHARED_EXPORT CodeDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
explicit CodeDialog(QWidget *parent = 0);
|
||||
public:
|
||||
virtual ~CodeDialog();
|
||||
|
||||
static bool generateCode(const QDesignerFormWindowInterface *fw,
|
||||
QString *code,
|
||||
QString *errorMessage);
|
||||
|
||||
static bool showCodeDialog(const QDesignerFormWindowInterface *fw,
|
||||
QWidget *parent,
|
||||
QString *errorMessage);
|
||||
|
||||
private slots:
|
||||
void slotSaveAs();
|
||||
void copyAll();
|
||||
|
||||
private:
|
||||
void setCode(const QString &code);
|
||||
QString code() const;
|
||||
void setFormFileName(const QString &f);
|
||||
QString formFileName() const;
|
||||
|
||||
void warning(const QString &msg);
|
||||
|
||||
struct CodeDialogPrivate;
|
||||
CodeDialogPrivate *m_impl;
|
||||
};
|
||||
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // CODEPREVIEWDIALOG_H
|
||||
1612
third/designer/lib/shared/connectionedit.cpp
Normal file
1612
third/designer/lib/shared/connectionedit.cpp
Normal file
File diff suppressed because it is too large
Load Diff
324
third/designer/lib/shared/connectionedit_p.h
Normal file
324
third/designer/lib/shared/connectionedit_p.h
Normal file
@@ -0,0 +1,324 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 CONNECTIONEDIT_H
|
||||
#define CONNECTIONEDIT_H
|
||||
|
||||
#include "shared_global_p.h"
|
||||
|
||||
#include <QtCore/QMultiMap>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QPointer>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QPolygonF>
|
||||
|
||||
#include <QtGui/QUndoCommand>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormWindowInterface;
|
||||
class QUndoStack;
|
||||
class QMenu;
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
class Connection;
|
||||
class ConnectionEdit;
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT CETypes
|
||||
{
|
||||
public:
|
||||
typedef QList<Connection*> ConnectionList;
|
||||
typedef QMap<Connection*, Connection*> ConnectionSet;
|
||||
typedef QMap<QWidget*, QWidget*> WidgetSet;
|
||||
|
||||
class EndPoint {
|
||||
public:
|
||||
enum Type { Source, Target };
|
||||
explicit EndPoint(Connection *_con = 0, Type _type = Source) : con(_con), type(_type) {}
|
||||
bool isNull() const { return con == 0; }
|
||||
bool operator == (const EndPoint &other) const { return con == other.con && type == other.type; }
|
||||
bool operator != (const EndPoint &other) const { return !operator == (other); }
|
||||
Connection *con;
|
||||
Type type;
|
||||
};
|
||||
enum LineDir { UpDir = 0, DownDir, RightDir, LeftDir };
|
||||
};
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT Connection : public CETypes
|
||||
{
|
||||
public:
|
||||
explicit Connection(ConnectionEdit *edit);
|
||||
explicit Connection(ConnectionEdit *edit, QObject *source, QObject *target);
|
||||
virtual ~Connection() {}
|
||||
|
||||
QObject *object(EndPoint::Type type) const
|
||||
{
|
||||
return (type == EndPoint::Source ? m_source : m_target);
|
||||
}
|
||||
|
||||
QWidget *widget(EndPoint::Type type) const
|
||||
{
|
||||
return qobject_cast<QWidget*>(object(type));
|
||||
}
|
||||
|
||||
QPoint endPointPos(EndPoint::Type type) const;
|
||||
QRect endPointRect(EndPoint::Type) const;
|
||||
void setEndPoint(EndPoint::Type type, QObject *w, const QPoint &pos)
|
||||
{ type == EndPoint::Source ? setSource(w, pos) : setTarget(w, pos); }
|
||||
|
||||
bool isVisible() const;
|
||||
virtual void updateVisibility();
|
||||
void setVisible(bool b);
|
||||
|
||||
virtual QRegion region() const;
|
||||
bool contains(const QPoint &pos) const;
|
||||
virtual void paint(QPainter *p) const;
|
||||
|
||||
void update(bool update_widgets = true) const;
|
||||
void checkWidgets();
|
||||
|
||||
QString label(EndPoint::Type type) const
|
||||
{ return type == EndPoint::Source ? m_source_label : m_target_label; }
|
||||
void setLabel(EndPoint::Type type, const QString &text);
|
||||
QRect labelRect(EndPoint::Type type) const;
|
||||
QPixmap labelPixmap(EndPoint::Type type) const
|
||||
{ return type == EndPoint::Source ? m_source_label_pm : m_target_label_pm; }
|
||||
|
||||
ConnectionEdit *edit() const { return m_edit; }
|
||||
|
||||
virtual void inserted() {}
|
||||
virtual void removed() {}
|
||||
|
||||
private:
|
||||
QPoint m_source_pos, m_target_pos;
|
||||
QObject *m_source, *m_target;
|
||||
QList<QPoint> m_knee_list;
|
||||
QPolygonF m_arrow_head;
|
||||
ConnectionEdit *m_edit;
|
||||
QString m_source_label, m_target_label;
|
||||
QPixmap m_source_label_pm, m_target_label_pm;
|
||||
QRect m_source_rect, m_target_rect;
|
||||
bool m_visible;
|
||||
|
||||
void setSource(QObject *source, const QPoint &pos);
|
||||
void setTarget(QObject *target, const QPoint &pos);
|
||||
void updateKneeList();
|
||||
void trimLine();
|
||||
void updatePixmap(EndPoint::Type type);
|
||||
LineDir labelDir(EndPoint::Type type) const;
|
||||
bool ground() const;
|
||||
QRect groundRect() const;
|
||||
};
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT ConnectionEdit : public QWidget, public CETypes
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConnectionEdit(QWidget *parent, QDesignerFormWindowInterface *form);
|
||||
virtual ~ConnectionEdit();
|
||||
|
||||
inline const QPointer<QWidget> &background() const { return m_bg_widget; }
|
||||
|
||||
void setSelected(Connection *con, bool sel);
|
||||
bool selected(const Connection *con) const;
|
||||
|
||||
int connectionCount() const { return m_con_list.size(); }
|
||||
Connection *connection(int i) const { return m_con_list.at(i); }
|
||||
int indexOfConnection(Connection *con) const { return m_con_list.indexOf(con); }
|
||||
|
||||
virtual void setSource(Connection *con, const QString &obj_name);
|
||||
virtual void setTarget(Connection *con, const QString &obj_name);
|
||||
|
||||
QUndoStack *undoStack() const { return m_undo_stack; }
|
||||
|
||||
void clear();
|
||||
|
||||
void showEvent(QShowEvent * /*e*/)
|
||||
{
|
||||
updateBackground();
|
||||
}
|
||||
|
||||
signals:
|
||||
void aboutToAddConnection(int idx);
|
||||
void connectionAdded(Connection *con);
|
||||
void aboutToRemoveConnection(Connection *con);
|
||||
void connectionRemoved(int idx);
|
||||
void connectionSelected(Connection *con);
|
||||
void widgetActivated(QWidget *wgt);
|
||||
void connectionChanged(Connection *con);
|
||||
|
||||
public slots:
|
||||
void selectNone();
|
||||
void selectAll();
|
||||
virtual void deleteSelected();
|
||||
virtual void setBackground(QWidget *background);
|
||||
virtual void updateBackground();
|
||||
virtual void widgetRemoved(QWidget *w);
|
||||
virtual void objectRemoved(QObject *o);
|
||||
|
||||
void updateLines();
|
||||
void enableUpdateBackground(bool enable);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *e);
|
||||
virtual void mouseMoveEvent(QMouseEvent *e);
|
||||
virtual void mousePressEvent(QMouseEvent *e);
|
||||
virtual void mouseReleaseEvent(QMouseEvent *e);
|
||||
virtual void keyPressEvent(QKeyEvent *e);
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
virtual void resizeEvent(QResizeEvent *e);
|
||||
virtual void contextMenuEvent(QContextMenuEvent * event);
|
||||
|
||||
virtual Connection *createConnection(QWidget *source, QWidget *target);
|
||||
virtual void modifyConnection(Connection *con);
|
||||
|
||||
virtual QWidget *widgetAt(const QPoint &pos) const;
|
||||
virtual void createContextMenu(QMenu &menu);
|
||||
void addConnection(Connection *con);
|
||||
QRect widgetRect(QWidget *w) const;
|
||||
|
||||
enum State { Editing, Connecting, Dragging };
|
||||
State state() const;
|
||||
|
||||
virtual void endConnection(QWidget *target, const QPoint &pos);
|
||||
|
||||
const ConnectionList &connectionList() const { return m_con_list; }
|
||||
const ConnectionSet &selection() const { return m_sel_con_set; }
|
||||
Connection *takeConnection(Connection *con);
|
||||
Connection *newlyAddedConnection() { return m_tmp_con; }
|
||||
void clearNewlyAddedConnection();
|
||||
|
||||
void findObjectsUnderMouse(const QPoint &pos);
|
||||
|
||||
private:
|
||||
void startConnection(QWidget *source, const QPoint &pos);
|
||||
void continueConnection(QWidget *target, const QPoint &pos);
|
||||
void abortConnection();
|
||||
|
||||
void startDrag(const EndPoint &end_point, const QPoint &pos);
|
||||
void continueDrag(const QPoint &pos);
|
||||
void endDrag(const QPoint &pos);
|
||||
void adjustHotSopt(const EndPoint &end_point, const QPoint &pos);
|
||||
Connection *connectionAt(const QPoint &pos) const;
|
||||
EndPoint endPointAt(const QPoint &pos) const;
|
||||
void paintConnection(QPainter *p, Connection *con,
|
||||
WidgetSet *heavy_highlight_set,
|
||||
WidgetSet *light_highlight_set) const;
|
||||
void paintLabel(QPainter *p, EndPoint::Type type, Connection *con);
|
||||
|
||||
|
||||
QPointer<QWidget> m_bg_widget;
|
||||
QUndoStack *m_undo_stack;
|
||||
bool m_enable_update_background;
|
||||
|
||||
Connection *m_tmp_con; // the connection we are currently editing
|
||||
ConnectionList m_con_list;
|
||||
bool m_start_connection_on_drag;
|
||||
EndPoint m_end_point_under_mouse;
|
||||
QPointer<QWidget> m_widget_under_mouse;
|
||||
|
||||
EndPoint m_drag_end_point;
|
||||
QPoint m_old_source_pos, m_old_target_pos;
|
||||
ConnectionSet m_sel_con_set;
|
||||
const QColor m_inactive_color;
|
||||
const QColor m_active_color;
|
||||
|
||||
private:
|
||||
friend class Connection;
|
||||
friend class AddConnectionCommand;
|
||||
friend class DeleteConnectionsCommand;
|
||||
friend class SetEndPointCommand;
|
||||
};
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT CECommand : public QUndoCommand, public CETypes
|
||||
{
|
||||
public:
|
||||
explicit CECommand(ConnectionEdit *edit)
|
||||
: m_edit(edit) {}
|
||||
|
||||
virtual bool mergeWith(const QUndoCommand *) { return false; }
|
||||
|
||||
ConnectionEdit *edit() const { return m_edit; }
|
||||
|
||||
private:
|
||||
ConnectionEdit *m_edit;
|
||||
};
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT AddConnectionCommand : public CECommand
|
||||
{
|
||||
public:
|
||||
AddConnectionCommand(ConnectionEdit *edit, Connection *con);
|
||||
virtual void redo();
|
||||
virtual void undo();
|
||||
private:
|
||||
Connection *m_con;
|
||||
};
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT DeleteConnectionsCommand : public CECommand
|
||||
{
|
||||
public:
|
||||
DeleteConnectionsCommand(ConnectionEdit *edit, const ConnectionList &con_list);
|
||||
virtual void redo();
|
||||
virtual void undo();
|
||||
private:
|
||||
ConnectionList m_con_list;
|
||||
};
|
||||
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // CONNECTIONEDIT_H
|
||||
188
third/designer/lib/shared/csshighlighter.cpp
Normal file
188
third/designer/lib/shared/csshighlighter.cpp
Normal file
@@ -0,0 +1,188 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "csshighlighter_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
CssHighlighter::CssHighlighter(QTextDocument *document)
|
||||
: QSyntaxHighlighter(document)
|
||||
{
|
||||
}
|
||||
|
||||
void CssHighlighter::highlightBlock(const QString& text)
|
||||
{
|
||||
enum Token { ALNUM, LBRACE, RBRACE, COLON, SEMICOLON, COMMA, QUOTE, SLASH, STAR };
|
||||
static const int transitions[10][9] = {
|
||||
{ Selector, Property, Selector, Pseudo, Property, Selector, Quote, MaybeComment, Selector }, // Selector
|
||||
{ Property, Property, Selector, Value, Property, Property, Quote, MaybeComment, Property }, // Property
|
||||
{ Value, Property, Selector, Value, Property, Value, Quote, MaybeComment, Value }, // Value
|
||||
{ Pseudo1, Property, Selector, Pseudo2, Selector, Selector, Quote, MaybeComment, Pseudo }, // Pseudo
|
||||
{ Pseudo1, Property, Selector, Pseudo, Selector, Selector, Quote, MaybeComment, Pseudo1 }, // Pseudo1
|
||||
{ Pseudo2, Property, Selector, Pseudo, Selector, Selector, Quote, MaybeComment, Pseudo2 }, // Pseudo2
|
||||
{ Quote, Quote, Quote, Quote, Quote, Quote, -1, Quote, Quote }, // Quote
|
||||
{ -1, -1, -1, -1, -1, -1, -1, -1, Comment }, // MaybeComment
|
||||
{ Comment, Comment, Comment, Comment, Comment, Comment, Comment, Comment, MaybeCommentEnd }, // Comment
|
||||
{ Comment, Comment, Comment, Comment, Comment, Comment, Comment, -1, MaybeCommentEnd } // MaybeCommentEnd
|
||||
};
|
||||
|
||||
int lastIndex = 0;
|
||||
bool lastWasSlash = false;
|
||||
int state = previousBlockState(), save_state;
|
||||
if (state == -1) {
|
||||
// As long as the text is empty, leave the state undetermined
|
||||
if (text.isEmpty()) {
|
||||
setCurrentBlockState(-1);
|
||||
return;
|
||||
}
|
||||
// The initial state is based on the precense of a : and the absense of a {.
|
||||
// This is because Qt style sheets support both a full stylesheet as well as
|
||||
// an inline form with just properties.
|
||||
state = save_state = (text.indexOf(QLatin1Char(':')) > -1 &&
|
||||
text.indexOf(QLatin1Char('{')) == -1) ? Property : Selector;
|
||||
} else {
|
||||
save_state = state>>16;
|
||||
state &= 0x00ff;
|
||||
}
|
||||
|
||||
if (state == MaybeCommentEnd) {
|
||||
state = Comment;
|
||||
} else if (state == MaybeComment) {
|
||||
state = save_state;
|
||||
}
|
||||
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
int token = ALNUM;
|
||||
const QChar c = text.at(i);
|
||||
const char a = c.toAscii();
|
||||
|
||||
if (state == Quote) {
|
||||
if (a == '\\') {
|
||||
lastWasSlash = true;
|
||||
} else {
|
||||
if (a == '\"' && !lastWasSlash) {
|
||||
token = QUOTE;
|
||||
}
|
||||
lastWasSlash = false;
|
||||
}
|
||||
} else {
|
||||
switch (a) {
|
||||
case '{': token = LBRACE; break;
|
||||
case '}': token = RBRACE; break;
|
||||
case ':': token = COLON; break;
|
||||
case ';': token = SEMICOLON; break;
|
||||
case ',': token = COMMA; break;
|
||||
case '\"': token = QUOTE; break;
|
||||
case '/': token = SLASH; break;
|
||||
case '*': token = STAR; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
int new_state = transitions[state][token];
|
||||
|
||||
if (new_state != state) {
|
||||
bool include_token = new_state == MaybeCommentEnd || (state == MaybeCommentEnd && new_state!= Comment)
|
||||
|| state == Quote;
|
||||
highlight(text, lastIndex, i-lastIndex+include_token, state);
|
||||
|
||||
if (new_state == Comment) {
|
||||
lastIndex = i-1; // include the slash and star
|
||||
} else {
|
||||
lastIndex = i + ((token == ALNUM || new_state == Quote) ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (new_state == -1) {
|
||||
state = save_state;
|
||||
} else if (state <= Pseudo2) {
|
||||
save_state = state;
|
||||
state = new_state;
|
||||
} else {
|
||||
state = new_state;
|
||||
}
|
||||
}
|
||||
|
||||
highlight(text, lastIndex, text.length() - lastIndex, state);
|
||||
setCurrentBlockState(state + (save_state<<16));
|
||||
}
|
||||
|
||||
void CssHighlighter::highlight(const QString &text, int start, int length, int state)
|
||||
{
|
||||
if (start >= text.length() || length <= 0)
|
||||
return;
|
||||
|
||||
QTextCharFormat format;
|
||||
|
||||
switch (state) {
|
||||
case Selector:
|
||||
setFormat(start, length, Qt::darkRed);
|
||||
break;
|
||||
case Property:
|
||||
setFormat(start, length, Qt::blue);
|
||||
break;
|
||||
case Value:
|
||||
setFormat(start, length, Qt::black);
|
||||
break;
|
||||
case Pseudo1:
|
||||
setFormat(start, length, Qt::darkRed);
|
||||
break;
|
||||
case Pseudo2:
|
||||
setFormat(start, length, Qt::darkRed);
|
||||
break;
|
||||
case Quote:
|
||||
setFormat(start, length, Qt::darkMagenta);
|
||||
break;
|
||||
case Comment:
|
||||
case MaybeCommentEnd:
|
||||
format.setForeground(Qt::darkGreen);
|
||||
setFormat(start, length, format);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
82
third/designer/lib/shared/csshighlighter_p.h
Normal file
82
third/designer/lib/shared/csshighlighter_p.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 CSSHIGHLIGHTER_H
|
||||
#define CSSHIGHLIGHTER_H
|
||||
|
||||
#include <QtGui/QSyntaxHighlighter>
|
||||
#include "shared_global_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT CssHighlighter : public QSyntaxHighlighter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CssHighlighter(QTextDocument *document);
|
||||
|
||||
protected:
|
||||
void highlightBlock(const QString&);
|
||||
void highlight(const QString&, int, int, int/*State*/);
|
||||
|
||||
private:
|
||||
enum State { Selector, Property, Value, Pseudo, Pseudo1, Pseudo2, Quote,
|
||||
MaybeComment, Comment, MaybeCommentEnd };
|
||||
};
|
||||
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // CSSHIGHLIGHTER_H
|
||||
498
third/designer/lib/shared/defaultgradients.xml
Normal file
498
third/designer/lib/shared/defaultgradients.xml
Normal file
@@ -0,0 +1,498 @@
|
||||
<gradients>
|
||||
<gradient name="BlackWhite" >
|
||||
<gradientData spread="PadSpread" startX="0" startY="0" coordinateMode="StretchToDeviceMode" type="LinearGradient" endX="1" endY="0" >
|
||||
<stopData position="0" >
|
||||
<colorData g="0" r="0" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Czech" >
|
||||
<gradientData centerX="0.5" centerY="0.5" spread="RepeatSpread" coordinateMode="StretchToDeviceMode" type="ConicalGradient" angle="0" >
|
||||
<stopData position="0" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.373978669201521" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.3739913434727503" >
|
||||
<colorData g="30" r="33" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.6240176679340937" >
|
||||
<colorData g="30" r="33" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.6240430164765525" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Dutch" >
|
||||
<gradientData spread="PadSpread" startX="0" startY="0" coordinateMode="StretchToDeviceMode" type="LinearGradient" endX="0" endY="1" >
|
||||
<stopData position="0" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.3397947548460661" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.339798898163606" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.6624439732888147" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.6624690150250417" >
|
||||
<colorData g="0" r="0" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="0" r="0" a="255" b="255" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Eye" >
|
||||
<gradientData centerX="0.5" centerY="0.5" radius="0.5" spread="PadSpread" focalX="0.5" focalY="0.5" coordinateMode="StretchToDeviceMode" type="RadialGradient" >
|
||||
<stopData position="0" >
|
||||
<colorData g="0" r="0" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.1939699465240642" >
|
||||
<colorData g="0" r="0" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.202312192513369" >
|
||||
<colorData g="97" r="122" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.4955143315508022" >
|
||||
<colorData g="58" r="76" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.5048191443850267" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.79" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="158" r="255" a="255" b="158" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Flare1" >
|
||||
<gradientData centerX="0.5" centerY="0.5" radius="0.5" spread="PadSpread" focalX="0.5" focalY="0.5" coordinateMode="StretchToDeviceMode" type="RadialGradient" >
|
||||
<stopData position="0" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.1" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.2" >
|
||||
<colorData g="176" r="255" a="167" b="176" />
|
||||
</stopData>
|
||||
<stopData position="0.3" >
|
||||
<colorData g="151" r="255" a="92" b="151" />
|
||||
</stopData>
|
||||
<stopData position="0.4" >
|
||||
<colorData g="125" r="255" a="51" b="125" />
|
||||
</stopData>
|
||||
<stopData position="0.5" >
|
||||
<colorData g="76" r="255" a="205" b="76" />
|
||||
</stopData>
|
||||
<stopData position="0.52" >
|
||||
<colorData g="76" r="255" a="205" b="76" />
|
||||
</stopData>
|
||||
<stopData position="0.6" >
|
||||
<colorData g="180" r="255" a="84" b="180" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="255" r="255" a="0" b="255" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Flare2" >
|
||||
<gradientData centerX="0.5" centerY="0.5" radius="0.5" spread="PadSpread" focalX="0.5" focalY="0.5" coordinateMode="StretchToDeviceMode" type="RadialGradient" >
|
||||
<stopData position="0" >
|
||||
<colorData g="0" r="0" a="0" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.52" >
|
||||
<colorData g="0" r="0" a="0" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.5649999999999999" >
|
||||
<colorData g="121" r="82" a="33" b="76" />
|
||||
</stopData>
|
||||
<stopData position="0.65" >
|
||||
<colorData g="235" r="159" a="64" b="148" />
|
||||
</stopData>
|
||||
<stopData position="0.7219251336898396" >
|
||||
<colorData g="238" r="255" a="129" b="150" />
|
||||
</stopData>
|
||||
<stopData position="0.77" >
|
||||
<colorData g="128" r="255" a="204" b="128" />
|
||||
</stopData>
|
||||
<stopData position="0.89" >
|
||||
<colorData g="128" r="191" a="64" b="255" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="0" r="0" a="0" b="0" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Flare3" >
|
||||
<gradientData centerX="0.5" centerY="0.5" radius="0.5" spread="PadSpread" focalX="0.5" focalY="0.5" coordinateMode="StretchToDeviceMode" type="RadialGradient" >
|
||||
<stopData position="0" >
|
||||
<colorData g="235" r="255" a="206" b="235" />
|
||||
</stopData>
|
||||
<stopData position="0.35" >
|
||||
<colorData g="188" r="255" a="80" b="188" />
|
||||
</stopData>
|
||||
<stopData position="0.4" >
|
||||
<colorData g="162" r="255" a="80" b="162" />
|
||||
</stopData>
|
||||
<stopData position="0.425" >
|
||||
<colorData g="132" r="255" a="156" b="132" />
|
||||
</stopData>
|
||||
<stopData position="0.44" >
|
||||
<colorData g="128" r="252" a="80" b="128" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="255" r="255" a="0" b="255" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="German" >
|
||||
<gradientData spread="PadSpread" startX="0" startY="0" coordinateMode="StretchToDeviceMode" type="LinearGradient" endX="0" endY="1" >
|
||||
<stopData position="0" >
|
||||
<colorData g="0" r="0" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.33" >
|
||||
<colorData g="0" r="0" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.34" >
|
||||
<colorData g="30" r="255" a="255" b="30" />
|
||||
</stopData>
|
||||
<stopData position="0.66" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.67" >
|
||||
<colorData g="255" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="255" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Golden" >
|
||||
<gradientData centerX="0.5" centerY="0.5" spread="PadSpread" coordinateMode="StretchToDeviceMode" type="ConicalGradient" angle="0" >
|
||||
<stopData position="0" >
|
||||
<colorData g="40" r="35" a="255" b="3" />
|
||||
</stopData>
|
||||
<stopData position="0.16" >
|
||||
<colorData g="106" r="136" a="255" b="22" />
|
||||
</stopData>
|
||||
<stopData position="0.225" >
|
||||
<colorData g="140" r="166" a="255" b="41" />
|
||||
</stopData>
|
||||
<stopData position="0.285" >
|
||||
<colorData g="181" r="204" a="255" b="74" />
|
||||
</stopData>
|
||||
<stopData position="0.345" >
|
||||
<colorData g="219" r="235" a="255" b="102" />
|
||||
</stopData>
|
||||
<stopData position="0.415" >
|
||||
<colorData g="236" r="245" a="255" b="112" />
|
||||
</stopData>
|
||||
<stopData position="0.52" >
|
||||
<colorData g="190" r="209" a="255" b="76" />
|
||||
</stopData>
|
||||
<stopData position="0.57" >
|
||||
<colorData g="156" r="187" a="255" b="51" />
|
||||
</stopData>
|
||||
<stopData position="0.635" >
|
||||
<colorData g="142" r="168" a="255" b="42" />
|
||||
</stopData>
|
||||
<stopData position="0.695" >
|
||||
<colorData g="174" r="202" a="255" b="68" />
|
||||
</stopData>
|
||||
<stopData position="0.75" >
|
||||
<colorData g="202" r="218" a="255" b="86" />
|
||||
</stopData>
|
||||
<stopData position="0.8149999999999999" >
|
||||
<colorData g="187" r="208" a="255" b="73" />
|
||||
</stopData>
|
||||
<stopData position="0.88" >
|
||||
<colorData g="156" r="187" a="255" b="51" />
|
||||
</stopData>
|
||||
<stopData position="0.9350000000000001" >
|
||||
<colorData g="108" r="137" a="255" b="26" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="40" r="35" a="255" b="3" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Japanese" >
|
||||
<gradientData centerX="0.5" centerY="0.5" radius="0.5" spread="PadSpread" focalX="0.5" focalY="0.5" coordinateMode="StretchToDeviceMode" type="RadialGradient" >
|
||||
<stopData position="0" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.4799044117647059" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.5226851604278074" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Norwegian" >
|
||||
<gradientData spread="RepeatSpread" startX="0" startY="0" coordinateMode="StretchToDeviceMode" type="LinearGradient" endX="1" endY="0" >
|
||||
<stopData position="0" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.17" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.18" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.2102117403738299" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.2202117403738299" >
|
||||
<colorData g="16" r="0" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.2798973635190806" >
|
||||
<colorData g="16" r="0" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.2898973635190806" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.32" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.33" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Pastels" >
|
||||
<gradientData spread="PadSpread" startX="0" startY="0" coordinateMode="StretchToDeviceMode" type="LinearGradient" endX="1" endY="0" >
|
||||
<stopData position="0" >
|
||||
<colorData g="224" r="245" a="255" b="176" />
|
||||
</stopData>
|
||||
<stopData position="0.09" >
|
||||
<colorData g="189" r="246" a="255" b="237" />
|
||||
</stopData>
|
||||
<stopData position="0.14" >
|
||||
<colorData g="207" r="194" a="255" b="246" />
|
||||
</stopData>
|
||||
<stopData position="0.19" >
|
||||
<colorData g="160" r="184" a="255" b="168" />
|
||||
</stopData>
|
||||
<stopData position="0.25" >
|
||||
<colorData g="186" r="171" a="255" b="248" />
|
||||
</stopData>
|
||||
<stopData position="0.32" >
|
||||
<colorData g="248" r="243" a="255" b="224" />
|
||||
</stopData>
|
||||
<stopData position="0.385" >
|
||||
<colorData g="162" r="249" a="255" b="183" />
|
||||
</stopData>
|
||||
<stopData position="0.47" >
|
||||
<colorData g="115" r="100" a="255" b="124" />
|
||||
</stopData>
|
||||
<stopData position="0.58" >
|
||||
<colorData g="205" r="251" a="255" b="202" />
|
||||
</stopData>
|
||||
<stopData position="0.65" >
|
||||
<colorData g="128" r="170" a="255" b="185" />
|
||||
</stopData>
|
||||
<stopData position="0.75" >
|
||||
<colorData g="222" r="252" a="255" b="204" />
|
||||
</stopData>
|
||||
<stopData position="0.805" >
|
||||
<colorData g="122" r="206" a="255" b="218" />
|
||||
</stopData>
|
||||
<stopData position="0.86" >
|
||||
<colorData g="223" r="254" a="255" b="175" />
|
||||
</stopData>
|
||||
<stopData position="0.91" >
|
||||
<colorData g="236" r="254" a="255" b="244" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="191" r="255" a="255" b="221" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Polish" >
|
||||
<gradientData spread="PadSpread" startX="0" startY="0" coordinateMode="StretchToDeviceMode" type="LinearGradient" endX="0" endY="1" >
|
||||
<stopData position="0" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.495" >
|
||||
<colorData g="255" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.505" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Rainbow" >
|
||||
<gradientData spread="PadSpread" startX="0" startY="0" coordinateMode="StretchToDeviceMode" type="LinearGradient" endX="1" endY="0" >
|
||||
<stopData position="0" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.166" >
|
||||
<colorData g="255" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.333" >
|
||||
<colorData g="255" r="0" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.5" >
|
||||
<colorData g="255" r="0" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.666" >
|
||||
<colorData g="0" r="0" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.833" >
|
||||
<colorData g="0" r="255" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="0" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Sky" >
|
||||
<gradientData spread="PadSpread" startX="0" startY="1" coordinateMode="StretchToDeviceMode" type="LinearGradient" endX="0" endY="0" >
|
||||
<stopData position="0" >
|
||||
<colorData g="0" r="0" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.05" >
|
||||
<colorData g="8" r="14" a="255" b="73" />
|
||||
</stopData>
|
||||
<stopData position="0.36" >
|
||||
<colorData g="17" r="28" a="255" b="145" />
|
||||
</stopData>
|
||||
<stopData position="0.6" >
|
||||
<colorData g="14" r="126" a="255" b="81" />
|
||||
</stopData>
|
||||
<stopData position="0.75" >
|
||||
<colorData g="11" r="234" a="255" b="11" />
|
||||
</stopData>
|
||||
<stopData position="0.79" >
|
||||
<colorData g="70" r="244" a="255" b="5" />
|
||||
</stopData>
|
||||
<stopData position="0.86" >
|
||||
<colorData g="136" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.9350000000000001" >
|
||||
<colorData g="236" r="239" a="255" b="55" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="SunRay" >
|
||||
<gradientData centerX="0" centerY="0" spread="RepeatSpread" coordinateMode="StretchToDeviceMode" type="ConicalGradient" angle="135" >
|
||||
<stopData position="0" >
|
||||
<colorData g="255" r="255" a="69" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.375" >
|
||||
<colorData g="255" r="255" a="69" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.4235329090018885" >
|
||||
<colorData g="255" r="251" a="145" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.45" >
|
||||
<colorData g="255" r="247" a="208" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.4775811200061043" >
|
||||
<colorData g="244" r="255" a="130" b="71" />
|
||||
</stopData>
|
||||
<stopData position="0.5187165775401069" >
|
||||
<colorData g="218" r="255" a="130" b="71" />
|
||||
</stopData>
|
||||
<stopData position="0.55" >
|
||||
<colorData g="255" r="255" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.5775401069518716" >
|
||||
<colorData g="203" r="255" a="130" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.625" >
|
||||
<colorData g="255" r="255" a="69" b="0" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="255" r="255" a="69" b="0" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Tropical" >
|
||||
<gradientData spread="PadSpread" startX="0" startY="0" coordinateMode="StretchToDeviceMode" type="LinearGradient" endX="1" endY="0" >
|
||||
<stopData position="0" >
|
||||
<colorData g="41" r="9" a="255" b="4" />
|
||||
</stopData>
|
||||
<stopData position="0.08500000000000001" >
|
||||
<colorData g="79" r="2" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="0.19" >
|
||||
<colorData g="147" r="50" a="255" b="22" />
|
||||
</stopData>
|
||||
<stopData position="0.275" >
|
||||
<colorData g="191" r="236" a="255" b="49" />
|
||||
</stopData>
|
||||
<stopData position="0.39" >
|
||||
<colorData g="61" r="243" a="255" b="34" />
|
||||
</stopData>
|
||||
<stopData position="0.555" >
|
||||
<colorData g="81" r="135" a="255" b="60" />
|
||||
</stopData>
|
||||
<stopData position="0.667" >
|
||||
<colorData g="75" r="121" a="255" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.825" >
|
||||
<colorData g="255" r="164" a="255" b="244" />
|
||||
</stopData>
|
||||
<stopData position="0.885" >
|
||||
<colorData g="222" r="104" a="255" b="71" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="128" r="93" a="255" b="0" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Wave" >
|
||||
<gradientData centerX="0.5" centerY="0.5" radius="0.077" spread="RepeatSpread" focalX="0.5" focalY="0.5" coordinateMode="StretchToDeviceMode" type="RadialGradient" >
|
||||
<stopData position="0" >
|
||||
<colorData g="169" r="0" a="147" b="255" />
|
||||
</stopData>
|
||||
<stopData position="0.4973262032085561" >
|
||||
<colorData g="0" r="0" a="147" b="0" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="169" r="0" a="147" b="255" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
<gradient name="Wood" >
|
||||
<gradientData spread="PadSpread" startX="0" startY="0" coordinateMode="StretchToDeviceMode" type="LinearGradient" endX="1" endY="0" >
|
||||
<stopData position="0" >
|
||||
<colorData g="178" r="255" a="255" b="102" />
|
||||
</stopData>
|
||||
<stopData position="0.55" >
|
||||
<colorData g="148" r="235" a="255" b="61" />
|
||||
</stopData>
|
||||
<stopData position="0.98" >
|
||||
<colorData g="0" r="0" a="255" b="0" />
|
||||
</stopData>
|
||||
<stopData position="1" >
|
||||
<colorData g="0" r="0" a="0" b="0" />
|
||||
</stopData>
|
||||
</gradientData>
|
||||
</gradient>
|
||||
</gradients>
|
||||
467
third/designer/lib/shared/deviceprofile.cpp
Normal file
467
third/designer/lib/shared/deviceprofile.cpp
Normal file
@@ -0,0 +1,467 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "deviceprofile_p.h"
|
||||
|
||||
#include <QtDesigner/QDesignerFormEditorInterface>
|
||||
#include <widgetfactory_p.h>
|
||||
#include <qdesigner_utils_p.h>
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QFont>
|
||||
#include <QtGui/QDesktopWidget>
|
||||
#include <QtGui/QStyle>
|
||||
#include <QtGui/QStyleFactory>
|
||||
#include <QtGui/QApplication>
|
||||
|
||||
#include <QtCore/QSharedData>
|
||||
#include <QtCore/QTextStream>
|
||||
|
||||
#include <QtCore/QXmlStreamWriter>
|
||||
#include <QtCore/QXmlStreamReader>
|
||||
|
||||
|
||||
static const char *dpiXPropertyC = "_q_customDpiX";
|
||||
static const char *dpiYPropertyC = "_q_customDpiY";
|
||||
|
||||
// XML serialization
|
||||
static const char *xmlVersionC="1.0";
|
||||
static const char *rootElementC="deviceprofile";
|
||||
static const char *nameElementC = "name";
|
||||
static const char *fontFamilyElementC = "fontfamily";
|
||||
static const char *fontPointSizeElementC = "fontpointsize";
|
||||
static const char *dPIXElementC = "dpix";
|
||||
static const char *dPIYElementC = "dpiy";
|
||||
static const char *styleElementC = "style";
|
||||
|
||||
/* DeviceProfile:
|
||||
* For preview purposes (preview, widget box, new form dialog), the
|
||||
* QDesignerFormBuilder applies the settings to the form main container
|
||||
* (Point being here that the DPI must be set directly for size calculations
|
||||
* to be correct).
|
||||
* For editing purposes, FormWindow applies the settings to the form container
|
||||
* as not to interfere with the font settings of the form main container.
|
||||
* In addition, the widgetfactory maintains the system settings style
|
||||
* and applies it when creating widgets. */
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
// ---------------- DeviceProfileData
|
||||
class DeviceProfileData : public QSharedData {
|
||||
public:
|
||||
DeviceProfileData();
|
||||
void fromSystem();
|
||||
void clear();
|
||||
|
||||
QString m_fontFamily;
|
||||
int m_fontPointSize;
|
||||
QString m_style;
|
||||
int m_dpiX;
|
||||
int m_dpiY;
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
DeviceProfileData::DeviceProfileData() :
|
||||
m_fontPointSize(-1),
|
||||
m_dpiX(-1),
|
||||
m_dpiY(-1)
|
||||
{
|
||||
}
|
||||
|
||||
void DeviceProfileData::clear()
|
||||
{
|
||||
m_fontPointSize = -1;
|
||||
m_dpiX = 0;
|
||||
m_dpiY = 0;
|
||||
m_name.clear();
|
||||
m_style.clear();
|
||||
}
|
||||
|
||||
void DeviceProfileData::fromSystem()
|
||||
{
|
||||
const QFont appFont = QApplication::font();
|
||||
m_fontFamily = appFont.family();
|
||||
m_fontPointSize = appFont.pointSize();
|
||||
DeviceProfile::systemResolution(&m_dpiX, &m_dpiY);
|
||||
m_style.clear();
|
||||
}
|
||||
|
||||
// ---------------- DeviceProfile
|
||||
DeviceProfile::DeviceProfile() :
|
||||
m_d(new DeviceProfileData)
|
||||
{
|
||||
}
|
||||
|
||||
DeviceProfile::DeviceProfile(const DeviceProfile &o) :
|
||||
m_d(o.m_d)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
DeviceProfile& DeviceProfile::operator=(const DeviceProfile &o)
|
||||
{
|
||||
m_d.operator=(o.m_d);
|
||||
return *this;
|
||||
}
|
||||
|
||||
DeviceProfile::~DeviceProfile()
|
||||
{
|
||||
}
|
||||
|
||||
void DeviceProfile::clear()
|
||||
{
|
||||
m_d->clear();
|
||||
}
|
||||
|
||||
bool DeviceProfile::isEmpty() const
|
||||
{
|
||||
return m_d->m_name.isEmpty();
|
||||
}
|
||||
|
||||
QString DeviceProfile::fontFamily() const
|
||||
{
|
||||
return m_d->m_fontFamily;
|
||||
}
|
||||
|
||||
void DeviceProfile::setFontFamily(const QString &f)
|
||||
{
|
||||
m_d->m_fontFamily = f;
|
||||
}
|
||||
|
||||
int DeviceProfile::fontPointSize() const
|
||||
{
|
||||
return m_d->m_fontPointSize;
|
||||
}
|
||||
|
||||
void DeviceProfile::setFontPointSize(int p)
|
||||
{
|
||||
m_d->m_fontPointSize = p;
|
||||
}
|
||||
|
||||
QString DeviceProfile::style() const
|
||||
{
|
||||
return m_d->m_style;
|
||||
}
|
||||
|
||||
void DeviceProfile::setStyle(const QString &s)
|
||||
{
|
||||
m_d->m_style = s;
|
||||
}
|
||||
|
||||
int DeviceProfile::dpiX() const
|
||||
{
|
||||
return m_d->m_dpiX;
|
||||
}
|
||||
|
||||
void DeviceProfile::setDpiX(int d)
|
||||
{
|
||||
m_d->m_dpiX = d;
|
||||
}
|
||||
|
||||
int DeviceProfile::dpiY() const
|
||||
{
|
||||
return m_d->m_dpiY;
|
||||
}
|
||||
|
||||
void DeviceProfile::setDpiY(int d)
|
||||
{
|
||||
m_d->m_dpiY = d;
|
||||
}
|
||||
|
||||
void DeviceProfile::fromSystem()
|
||||
{
|
||||
m_d->fromSystem();
|
||||
}
|
||||
|
||||
QString DeviceProfile::name() const
|
||||
{
|
||||
return m_d->m_name;
|
||||
}
|
||||
|
||||
void DeviceProfile::setName(const QString &n)
|
||||
{
|
||||
m_d->m_name = n;
|
||||
}
|
||||
|
||||
void DeviceProfile::systemResolution(int *dpiX, int *dpiY)
|
||||
{
|
||||
const QDesktopWidget *dw = qApp->desktop();
|
||||
*dpiX = dw->logicalDpiX();
|
||||
*dpiY = dw->logicalDpiY();
|
||||
}
|
||||
|
||||
class FriendlyWidget : public QWidget {
|
||||
friend class DeviceProfile;
|
||||
};
|
||||
|
||||
void DeviceProfile::widgetResolution(const QWidget *w, int *dpiX, int *dpiY)
|
||||
{
|
||||
const FriendlyWidget *fw = static_cast<const FriendlyWidget*>(w);
|
||||
*dpiX = fw->metric(QPaintDevice::PdmDpiX);
|
||||
*dpiY = fw->metric(QPaintDevice::PdmDpiY);
|
||||
}
|
||||
|
||||
QString DeviceProfile::toString() const
|
||||
{
|
||||
const DeviceProfileData &d = *m_d;
|
||||
QString rc;
|
||||
QTextStream(&rc) << "DeviceProfile:name=" << d.m_name << " Font=" << d.m_fontFamily << ' '
|
||||
<< d.m_fontPointSize << " Style=" << d.m_style << " DPI=" << d.m_dpiX << ',' << d.m_dpiY;
|
||||
return rc;
|
||||
}
|
||||
|
||||
// Apply font to widget
|
||||
static void applyFont(const QString &family, int size, DeviceProfile::ApplyMode am, QWidget *widget)
|
||||
{
|
||||
QFont currentFont = widget->font();
|
||||
if (currentFont.pointSize() == size && currentFont.family() == family)
|
||||
return;
|
||||
switch (am) {
|
||||
case DeviceProfile::ApplyFormParent:
|
||||
// Invisible form parent: Apply all
|
||||
widget->setFont(QFont(family, size));
|
||||
break;
|
||||
case DeviceProfile::ApplyPreview: {
|
||||
// Preview: Apply only subproperties that have not been changed by designer properties
|
||||
bool apply = false;
|
||||
const uint resolve = currentFont.resolve();
|
||||
if (!(resolve & QFont::FamilyResolved)) {
|
||||
currentFont.setFamily(family);
|
||||
apply = true;
|
||||
}
|
||||
if (!(resolve & QFont::SizeResolved)) {
|
||||
currentFont.setPointSize(size);
|
||||
apply = true;
|
||||
}
|
||||
if (apply)
|
||||
widget->setFont(currentFont);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceProfile::applyDPI(int dpiX, int dpiY, QWidget *widget)
|
||||
{
|
||||
int sysDPIX, sysDPIY; // Set dynamic variables in case values are different from system DPI
|
||||
systemResolution(&sysDPIX, &sysDPIY);
|
||||
if (dpiX != sysDPIX && dpiY != sysDPIY) {
|
||||
widget->setProperty(dpiXPropertyC, QVariant(dpiX));
|
||||
widget->setProperty(dpiYPropertyC, QVariant(dpiY));
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceProfile::apply(const QDesignerFormEditorInterface *core, QWidget *widget, ApplyMode am) const
|
||||
{
|
||||
if (isEmpty())
|
||||
return;
|
||||
|
||||
const DeviceProfileData &d = *m_d;
|
||||
|
||||
if (!d.m_fontFamily.isEmpty())
|
||||
applyFont(d.m_fontFamily, d.m_fontPointSize, am, widget);
|
||||
|
||||
applyDPI(d.m_dpiX, d.m_dpiY, widget);
|
||||
|
||||
if (!d.m_style.isEmpty()) {
|
||||
if (WidgetFactory *wf = qobject_cast<qdesigner_internal::WidgetFactory *>(core->widgetFactory()))
|
||||
wf->applyStyleTopLevel(d.m_style, widget);
|
||||
}
|
||||
}
|
||||
|
||||
bool DeviceProfile::equals(const DeviceProfile& rhs) const
|
||||
{
|
||||
const DeviceProfileData &d = *m_d;
|
||||
const DeviceProfileData &rhs_d = *rhs.m_d;
|
||||
return d.m_fontPointSize == rhs_d.m_fontPointSize &&
|
||||
d.m_dpiX == rhs_d.m_dpiX && d.m_dpiY == rhs_d.m_dpiY && d.m_fontFamily == rhs_d.m_fontFamily &&
|
||||
d.m_style == rhs_d.m_style && d.m_name == rhs_d.m_name;
|
||||
}
|
||||
|
||||
static inline void writeElement(QXmlStreamWriter &writer, const QString &element, const QString &cdata)
|
||||
{
|
||||
writer.writeStartElement(element);
|
||||
writer.writeCharacters(cdata);
|
||||
writer.writeEndElement();
|
||||
}
|
||||
|
||||
QString DeviceProfile::toXml() const
|
||||
{
|
||||
const DeviceProfileData &d = *m_d;
|
||||
QString rc;
|
||||
QXmlStreamWriter writer(&rc);
|
||||
writer.writeStartDocument(QLatin1String(xmlVersionC));
|
||||
writer.writeStartElement(QLatin1String(rootElementC));
|
||||
writeElement(writer, QLatin1String(nameElementC), d.m_name);
|
||||
|
||||
if (!d.m_fontFamily.isEmpty())
|
||||
writeElement(writer, QLatin1String(fontFamilyElementC), d.m_fontFamily);
|
||||
if (d.m_fontPointSize >= 0)
|
||||
writeElement(writer, QLatin1String(fontPointSizeElementC), QString::number(d.m_fontPointSize));
|
||||
if (d.m_dpiX > 0)
|
||||
writeElement(writer, QLatin1String(dPIXElementC), QString::number(d.m_dpiX));
|
||||
if (d.m_dpiY > 0)
|
||||
writeElement(writer, QLatin1String(dPIYElementC), QString::number(d.m_dpiY));
|
||||
if (!d.m_style.isEmpty())
|
||||
writeElement(writer, QLatin1String(styleElementC), d.m_style);
|
||||
|
||||
writer.writeEndElement();
|
||||
writer.writeEndDocument();
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Switch stages when encountering a start element (state table) */
|
||||
enum ParseStage { ParseBeginning, ParseWithinRoot,
|
||||
ParseName, ParseFontFamily, ParseFontPointSize, ParseDPIX, ParseDPIY, ParseStyle,
|
||||
ParseError };
|
||||
|
||||
static ParseStage nextStage(ParseStage currentStage, const QStringRef &startElement)
|
||||
{
|
||||
switch (currentStage) {
|
||||
case ParseBeginning:
|
||||
if (startElement == QLatin1String(rootElementC))
|
||||
return ParseWithinRoot;
|
||||
break;
|
||||
case ParseWithinRoot:
|
||||
case ParseName:
|
||||
case ParseFontFamily:
|
||||
case ParseFontPointSize:
|
||||
case ParseDPIX:
|
||||
case ParseDPIY:
|
||||
case ParseStyle:
|
||||
if (startElement == QLatin1String(nameElementC))
|
||||
return ParseName;
|
||||
if (startElement == QLatin1String(fontFamilyElementC))
|
||||
return ParseFontFamily;
|
||||
if (startElement == QLatin1String(fontPointSizeElementC))
|
||||
return ParseFontPointSize;
|
||||
if (startElement == QLatin1String(dPIXElementC))
|
||||
return ParseDPIX;
|
||||
if (startElement == QLatin1String(dPIYElementC))
|
||||
return ParseDPIY;
|
||||
if (startElement == QLatin1String(styleElementC))
|
||||
return ParseStyle;
|
||||
break;
|
||||
case ParseError:
|
||||
break;
|
||||
}
|
||||
return ParseError;
|
||||
}
|
||||
|
||||
static bool readIntegerElement(QXmlStreamReader &reader, int *v)
|
||||
{
|
||||
const QString e = reader.readElementText();
|
||||
bool ok;
|
||||
*v = e.toInt(&ok);
|
||||
//: Reading a number for an embedded device profile
|
||||
if (!ok)
|
||||
reader.raiseError(QApplication::translate("DeviceProfile", "'%1' is not a number.").arg(e));
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool DeviceProfile::fromXml(const QString &xml, QString *errorMessage)
|
||||
{
|
||||
DeviceProfileData &d = *m_d;
|
||||
d.fromSystem();
|
||||
|
||||
QXmlStreamReader reader(xml);
|
||||
|
||||
ParseStage ps = ParseBeginning;
|
||||
QXmlStreamReader::TokenType tt = QXmlStreamReader::NoToken;
|
||||
int iv = 0;
|
||||
do {
|
||||
tt = reader.readNext();
|
||||
if (tt == QXmlStreamReader::StartElement) {
|
||||
ps = nextStage(ps, reader.name());
|
||||
switch (ps) {
|
||||
case ParseBeginning:
|
||||
case ParseWithinRoot:
|
||||
break;
|
||||
case ParseError:
|
||||
reader.raiseError(QApplication::translate("DeviceProfile", "An invalid tag <%1> was encountered.").arg(reader.name().toString()));
|
||||
tt = QXmlStreamReader::Invalid;
|
||||
break;
|
||||
case ParseName:
|
||||
d.m_name = reader.readElementText();
|
||||
break;
|
||||
case ParseFontFamily:
|
||||
d.m_fontFamily = reader.readElementText();
|
||||
break;
|
||||
case ParseFontPointSize:
|
||||
if (readIntegerElement(reader, &iv)) {
|
||||
d.m_fontPointSize = iv;
|
||||
} else {
|
||||
tt = QXmlStreamReader::Invalid;
|
||||
}
|
||||
break;
|
||||
case ParseDPIX:
|
||||
if (readIntegerElement(reader, &iv)) {
|
||||
d.m_dpiX = iv;
|
||||
} else {
|
||||
tt = QXmlStreamReader::Invalid;
|
||||
}
|
||||
break;
|
||||
case ParseDPIY:
|
||||
if (readIntegerElement(reader, &iv)) {
|
||||
d.m_dpiY = iv;
|
||||
} else {
|
||||
tt = QXmlStreamReader::Invalid;
|
||||
}
|
||||
break;
|
||||
case ParseStyle:
|
||||
d.m_style = reader.readElementText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (tt != QXmlStreamReader::Invalid && tt != QXmlStreamReader::EndDocument);
|
||||
|
||||
if (reader.hasError()) {
|
||||
*errorMessage = reader.errorString();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
152
third/designer/lib/shared/deviceprofile_p.h
Normal file
152
third/designer/lib/shared/deviceprofile_p.h
Normal file
@@ -0,0 +1,152 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 DEVICEPROFILE_H
|
||||
#define DEVICEPROFILE_H
|
||||
|
||||
#include "shared_global_p.h"
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QSharedDataPointer>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
class QWidget;
|
||||
class QStyle;
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
class DeviceProfileData;
|
||||
|
||||
/* DeviceProfile for embedded design. They influence
|
||||
* default properties (for example, fonts), dpi and
|
||||
* style of the form. This class represents a device
|
||||
* profile. */
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT DeviceProfile {
|
||||
public:
|
||||
DeviceProfile();
|
||||
|
||||
DeviceProfile(const DeviceProfile&);
|
||||
DeviceProfile& operator=(const DeviceProfile&);
|
||||
~DeviceProfile();
|
||||
|
||||
void clear();
|
||||
|
||||
// Device name
|
||||
QString name() const;
|
||||
void setName(const QString &);
|
||||
|
||||
// System settings active
|
||||
bool isEmpty() const;
|
||||
|
||||
// Default font family of the embedded system
|
||||
QString fontFamily() const;
|
||||
void setFontFamily(const QString &);
|
||||
|
||||
// Default font size of the embedded system
|
||||
int fontPointSize() const;
|
||||
void setFontPointSize(int p);
|
||||
|
||||
// Display resolution of the embedded system
|
||||
int dpiX() const;
|
||||
void setDpiX(int d);
|
||||
int dpiY() const;
|
||||
void setDpiY(int d);
|
||||
|
||||
// Style
|
||||
QString style() const;
|
||||
void setStyle(const QString &);
|
||||
|
||||
// Initialize from desktop system
|
||||
void fromSystem();
|
||||
|
||||
static void systemResolution(int *dpiX, int *dpiY);
|
||||
static void widgetResolution(const QWidget *w, int *dpiX, int *dpiY);
|
||||
|
||||
bool equals(const DeviceProfile& rhs) const;
|
||||
|
||||
// Apply to form/preview (using font inheritance)
|
||||
enum ApplyMode {
|
||||
/* Pre-Apply to parent widget of form being edited: Apply font
|
||||
* and make use of property inheritance to be able to modify the
|
||||
* font property freely. */
|
||||
ApplyFormParent,
|
||||
/* Post-Apply to preview widget: Change only inherited font
|
||||
* sub properties. */
|
||||
ApplyPreview
|
||||
};
|
||||
void apply(const QDesignerFormEditorInterface *core, QWidget *widget, ApplyMode am) const;
|
||||
|
||||
static void applyDPI(int dpiX, int dpiY, QWidget *widget);
|
||||
|
||||
QString toString() const;
|
||||
|
||||
QString toXml() const;
|
||||
bool fromXml(const QString &xml, QString *errorMessage);
|
||||
|
||||
private:
|
||||
QSharedDataPointer<DeviceProfileData> m_d;
|
||||
};
|
||||
|
||||
inline bool operator==(const DeviceProfile &s1, const DeviceProfile &s2)
|
||||
{ return s1.equals(s2); }
|
||||
inline bool operator!=(const DeviceProfile &s1, const DeviceProfile &s2)
|
||||
{ return !s1.equals(s2); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // DEVICEPROFILE_H
|
||||
265
third/designer/lib/shared/dialoggui.cpp
Normal file
265
third/designer/lib/shared/dialoggui.cpp
Normal file
@@ -0,0 +1,265 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "dialoggui_p.h"
|
||||
|
||||
#include <QtGui/QFileIconProvider>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtGui/QImage>
|
||||
#include <QtGui/QImageReader>
|
||||
#include <QtGui/QPixmap>
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QSet>
|
||||
|
||||
// QFileDialog on X11 does not provide an image preview. Display icons.
|
||||
#ifdef Q_WS_X11
|
||||
# define IMAGE_PREVIEW
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
// Icon provider that reads out the known image formats
|
||||
class IconProvider : public QFileIconProvider {
|
||||
Q_DISABLE_COPY(IconProvider)
|
||||
|
||||
public:
|
||||
IconProvider();
|
||||
virtual QIcon icon (const QFileInfo &info) const;
|
||||
|
||||
inline bool loadCheck(const QFileInfo &info) const;
|
||||
QImage loadImage(const QString &fileName) const;
|
||||
|
||||
private:
|
||||
QSet<QString> m_imageFormats;
|
||||
};
|
||||
|
||||
IconProvider::IconProvider()
|
||||
{
|
||||
// Determine a list of readable extensions (upper and lower case)
|
||||
typedef QList<QByteArray> ByteArrayList;
|
||||
const ByteArrayList fmts = QImageReader::supportedImageFormats();
|
||||
const ByteArrayList::const_iterator cend = fmts.constEnd();
|
||||
for (ByteArrayList::const_iterator it = fmts.constBegin(); it != cend; ++it) {
|
||||
const QString suffix = QString::fromUtf8(it->constData());
|
||||
m_imageFormats.insert(suffix.toLower());
|
||||
m_imageFormats.insert(suffix.toUpper());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Check by extension and type if this appears to be a loadable image
|
||||
bool IconProvider::loadCheck(const QFileInfo &info) const
|
||||
{
|
||||
if (info.isFile() && info.isReadable()) {
|
||||
const QString suffix = info.suffix();
|
||||
if (!suffix.isEmpty())
|
||||
return m_imageFormats.contains(suffix);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QImage IconProvider::loadImage(const QString &fileName) const
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QImageReader imgReader(&file);
|
||||
if (imgReader.canRead()) {
|
||||
QImage image;
|
||||
if (imgReader.read(&image))
|
||||
return image;
|
||||
}
|
||||
}
|
||||
return QImage();
|
||||
}
|
||||
|
||||
QIcon IconProvider::icon (const QFileInfo &info) const
|
||||
{
|
||||
// Don't get stuck on large images.
|
||||
const qint64 maxSize = 131072;
|
||||
if (loadCheck(info) && info.size() < maxSize) {
|
||||
const QImage image = loadImage(info.absoluteFilePath());
|
||||
if (!image.isNull())
|
||||
return QIcon(QPixmap::fromImage(image, Qt::ThresholdDither|Qt::AutoColor));
|
||||
}
|
||||
return QFileIconProvider::icon(info);
|
||||
}
|
||||
|
||||
// ---------------- DialogGui
|
||||
DialogGui::DialogGui() :
|
||||
m_iconProvider(0)
|
||||
{
|
||||
}
|
||||
|
||||
DialogGui::~DialogGui()
|
||||
{
|
||||
delete m_iconProvider;
|
||||
}
|
||||
|
||||
QFileIconProvider *DialogGui::ensureIconProvider()
|
||||
{
|
||||
if (!m_iconProvider)
|
||||
m_iconProvider = new IconProvider;
|
||||
return m_iconProvider;
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton
|
||||
DialogGui::message(QWidget *parent, Message /*context*/, QMessageBox::Icon icon,
|
||||
const QString &title, const QString &text, QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton)
|
||||
{
|
||||
QMessageBox::StandardButton rc = QMessageBox::NoButton;
|
||||
switch (icon) {
|
||||
case QMessageBox::Information:
|
||||
rc = QMessageBox::information(parent, title, text, buttons, defaultButton);
|
||||
break;
|
||||
case QMessageBox::Warning:
|
||||
rc = QMessageBox::warning(parent, title, text, buttons, defaultButton);
|
||||
break;
|
||||
case QMessageBox::Critical:
|
||||
rc = QMessageBox::critical(parent, title, text, buttons, defaultButton);
|
||||
break;
|
||||
case QMessageBox::Question:
|
||||
rc = QMessageBox::question(parent, title, text, buttons, defaultButton);
|
||||
break;
|
||||
case QMessageBox::NoIcon:
|
||||
break;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton
|
||||
DialogGui::message(QWidget *parent, Message /*context*/, QMessageBox::Icon icon,
|
||||
const QString &title, const QString &text, const QString &informativeText,
|
||||
QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
|
||||
{
|
||||
QMessageBox msgBox(icon, title, text, buttons, parent);
|
||||
msgBox.setDefaultButton(defaultButton);
|
||||
msgBox.setInformativeText(informativeText);
|
||||
return static_cast<QMessageBox::StandardButton>(msgBox.exec());
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton
|
||||
DialogGui::message(QWidget *parent, Message /*context*/, QMessageBox::Icon icon,
|
||||
const QString &title, const QString &text, const QString &informativeText, const QString &detailedText,
|
||||
QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
|
||||
{
|
||||
QMessageBox msgBox(icon, title, text, buttons, parent);
|
||||
msgBox.setDefaultButton(defaultButton);
|
||||
msgBox.setInformativeText(informativeText);
|
||||
msgBox.setDetailedText(detailedText);
|
||||
return static_cast<QMessageBox::StandardButton>(msgBox.exec());
|
||||
}
|
||||
|
||||
QString DialogGui::getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options)
|
||||
{
|
||||
return QFileDialog::getExistingDirectory(parent, caption, dir, options);
|
||||
}
|
||||
|
||||
QString DialogGui::getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
|
||||
{
|
||||
return QFileDialog::getOpenFileName(parent, caption, dir, filter, selectedFilter, options);
|
||||
}
|
||||
|
||||
QStringList DialogGui::getOpenFileNames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
|
||||
{
|
||||
return QFileDialog::getOpenFileNames(parent, caption, dir, filter, selectedFilter, options);
|
||||
}
|
||||
|
||||
QString DialogGui::getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
|
||||
{
|
||||
return QFileDialog::getSaveFileName(parent, caption, dir, filter, selectedFilter, options);
|
||||
}
|
||||
|
||||
void DialogGui::initializeImageFileDialog(QFileDialog &fileDialog, QFileDialog::Options options, QFileDialog::FileMode fm)
|
||||
{
|
||||
fileDialog.setConfirmOverwrite( !(options & QFileDialog::DontConfirmOverwrite) );
|
||||
fileDialog.setResolveSymlinks( !(options & QFileDialog::DontResolveSymlinks) );
|
||||
fileDialog.setIconProvider(ensureIconProvider());
|
||||
fileDialog.setFileMode(fm);
|
||||
}
|
||||
|
||||
QString DialogGui::getOpenImageFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options )
|
||||
{
|
||||
|
||||
#ifdef IMAGE_PREVIEW
|
||||
QFileDialog fileDialog(parent, caption, dir, filter);
|
||||
initializeImageFileDialog(fileDialog, options, QFileDialog::ExistingFile);
|
||||
if (fileDialog.exec() != QDialog::Accepted)
|
||||
return QString();
|
||||
|
||||
const QStringList selectedFiles = fileDialog.selectedFiles();
|
||||
if (selectedFiles.empty())
|
||||
return QString();
|
||||
|
||||
if (selectedFilter)
|
||||
*selectedFilter = fileDialog.selectedFilter();
|
||||
|
||||
return selectedFiles.front();
|
||||
#else
|
||||
return getOpenFileName(parent, caption, dir, filter, selectedFilter, options);
|
||||
#endif
|
||||
}
|
||||
|
||||
QStringList DialogGui::getOpenImageFileNames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options )
|
||||
{
|
||||
#ifdef IMAGE_PREVIEW
|
||||
QFileDialog fileDialog(parent, caption, dir, filter);
|
||||
initializeImageFileDialog(fileDialog, options, QFileDialog::ExistingFiles);
|
||||
if (fileDialog.exec() != QDialog::Accepted)
|
||||
return QStringList();
|
||||
|
||||
const QStringList selectedFiles = fileDialog.selectedFiles();
|
||||
if (!selectedFiles.empty() && selectedFilter)
|
||||
*selectedFilter = fileDialog.selectedFilter();
|
||||
|
||||
return selectedFiles;
|
||||
#else
|
||||
return getOpenFileNames(parent, caption, dir, filter, selectedFilter, options);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
107
third/designer/lib/shared/dialoggui_p.h
Normal file
107
third/designer/lib/shared/dialoggui_p.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 DIALOGGUI
|
||||
#define DIALOGGUI
|
||||
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#include "shared_global_p.h"
|
||||
#include <abstractdialoggui_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QFileIconProvider;
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT DialogGui : public QDesignerDialogGuiInterface
|
||||
{
|
||||
public:
|
||||
DialogGui();
|
||||
virtual ~DialogGui();
|
||||
|
||||
virtual QMessageBox::StandardButton
|
||||
message(QWidget *parent, Message context, QMessageBox::Icon icon,
|
||||
const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||
|
||||
virtual QMessageBox::StandardButton
|
||||
message(QWidget *parent, Message context, QMessageBox::Icon icon,
|
||||
const QString &title, const QString &text, const QString &informativeText,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||
|
||||
virtual QMessageBox::StandardButton
|
||||
message(QWidget *parent, Message context, QMessageBox::Icon icon,
|
||||
const QString &title, const QString &text, const QString &informativeText, const QString &detailedText,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||
|
||||
virtual QString getExistingDirectory(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), QFileDialog::Options options = QFileDialog::ShowDirsOnly);
|
||||
virtual QString getOpenFileName(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
virtual QStringList getOpenFileNames(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
virtual QString getSaveFileName(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
|
||||
virtual QString getOpenImageFileName(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
virtual QStringList getOpenImageFileNames(QWidget *parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
|
||||
private:
|
||||
QFileIconProvider *ensureIconProvider();
|
||||
void initializeImageFileDialog(QFileDialog &fd, QFileDialog::Options options, QFileDialog::FileMode);
|
||||
|
||||
QFileIconProvider *m_iconProvider;
|
||||
};
|
||||
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // DIALOGGUI
|
||||
120
third/designer/lib/shared/extensionfactory_p.h
Normal file
120
third/designer/lib/shared/extensionfactory_p.h
Normal 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$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// 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 SHARED_EXTENSIONFACTORY_H
|
||||
#define SHARED_EXTENSIONFACTORY_H
|
||||
|
||||
#include <QtDesigner/default_extensionfactory.h>
|
||||
#include <QtDesigner/QExtensionManager>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
// Extension factory for registering an extension for an object type.
|
||||
template <class ExtensionInterface, class Object, class Extension>
|
||||
class ExtensionFactory: public QExtensionFactory
|
||||
{
|
||||
public:
|
||||
explicit ExtensionFactory(const QString &iid, QExtensionManager *parent = 0);
|
||||
|
||||
// Convenience for registering the extension. Do not use for derived classes.
|
||||
static void registerExtension(QExtensionManager *mgr, const QString &iid);
|
||||
|
||||
protected:
|
||||
virtual QObject *createExtension(QObject *qObject, const QString &iid, QObject *parent) const;
|
||||
|
||||
private:
|
||||
// Can be overwritten to perform checks on the object.
|
||||
// Default does a qobject_cast to the desired class.
|
||||
virtual Object *checkObject(QObject *qObject) const;
|
||||
|
||||
const QString m_iid;
|
||||
};
|
||||
|
||||
template <class ExtensionInterface, class Object, class Extension>
|
||||
ExtensionFactory<ExtensionInterface, Object, Extension>::ExtensionFactory(const QString &iid, QExtensionManager *parent) :
|
||||
QExtensionFactory(parent),
|
||||
m_iid(iid)
|
||||
{
|
||||
}
|
||||
|
||||
template <class ExtensionInterface, class Object, class Extension>
|
||||
Object *ExtensionFactory<ExtensionInterface, Object, Extension>::checkObject(QObject *qObject) const
|
||||
{
|
||||
return qobject_cast<Object*>(qObject);
|
||||
}
|
||||
|
||||
template <class ExtensionInterface, class Object, class Extension>
|
||||
QObject *ExtensionFactory<ExtensionInterface, Object, Extension>::createExtension(QObject *qObject, const QString &iid, QObject *parent) const
|
||||
{
|
||||
if (iid != m_iid)
|
||||
return 0;
|
||||
|
||||
Object *object = checkObject(qObject);
|
||||
if (!object)
|
||||
return 0;
|
||||
|
||||
return new Extension(object, parent);
|
||||
}
|
||||
|
||||
template <class ExtensionInterface, class Object, class Extension>
|
||||
void ExtensionFactory<ExtensionInterface, Object, Extension>::registerExtension(QExtensionManager *mgr, const QString &iid)
|
||||
{
|
||||
ExtensionFactory *factory = new ExtensionFactory(iid, mgr);
|
||||
mgr->registerExtensions(factory, iid);
|
||||
}
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // SHARED_EXTENSIONFACTORY_H
|
||||
252
third/designer/lib/shared/filterwidget.cpp
Normal file
252
third/designer/lib/shared/filterwidget.cpp
Normal file
@@ -0,0 +1,252 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "filterwidget_p.h"
|
||||
#include "iconloader_p.h"
|
||||
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QFocusEvent>
|
||||
#include <QtGui/QPalette>
|
||||
#include <QtGui/QCursor>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QStyle>
|
||||
#include <QtGui/QStyleOption>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QPropertyAnimation>
|
||||
|
||||
enum { debugFilter = 0 };
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
HintLineEdit::HintLineEdit(QWidget *parent) :
|
||||
QLineEdit(parent),
|
||||
m_defaultFocusPolicy(focusPolicy()),
|
||||
m_refuseFocus(false)
|
||||
{
|
||||
}
|
||||
|
||||
IconButton::IconButton(QWidget *parent)
|
||||
: QToolButton(parent)
|
||||
{
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void IconButton::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
// Note isDown should really use the active state but in most styles
|
||||
// this has no proper feedback
|
||||
QIcon::Mode state = QIcon::Disabled;
|
||||
if (isEnabled())
|
||||
state = isDown() ? QIcon::Selected : QIcon::Normal;
|
||||
QPixmap iconpixmap = icon().pixmap(QSize(ICONBUTTON_SIZE, ICONBUTTON_SIZE),
|
||||
state, QIcon::Off);
|
||||
QRect pixmapRect = QRect(0, 0, iconpixmap.width(), iconpixmap.height());
|
||||
pixmapRect.moveCenter(rect().center());
|
||||
painter.setOpacity(m_fader);
|
||||
painter.drawPixmap(pixmapRect, iconpixmap);
|
||||
}
|
||||
|
||||
void IconButton::animateShow(bool visible)
|
||||
{
|
||||
if (visible) {
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "fader");
|
||||
animation->setDuration(160);
|
||||
animation->setEndValue(1.0);
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
} else {
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "fader");
|
||||
animation->setDuration(160);
|
||||
animation->setEndValue(0.0);
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
}
|
||||
|
||||
bool HintLineEdit::refuseFocus() const
|
||||
{
|
||||
return m_refuseFocus;
|
||||
}
|
||||
|
||||
void HintLineEdit::setRefuseFocus(bool v)
|
||||
{
|
||||
if (v == m_refuseFocus)
|
||||
return;
|
||||
m_refuseFocus = v;
|
||||
setFocusPolicy(m_refuseFocus ? Qt::NoFocus : m_defaultFocusPolicy);
|
||||
}
|
||||
|
||||
void HintLineEdit::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (debugFilter)
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
// Explicitly focus on click.
|
||||
if (m_refuseFocus && !hasFocus())
|
||||
setFocus(Qt::OtherFocusReason);
|
||||
QLineEdit::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void HintLineEdit::focusInEvent(QFocusEvent *e)
|
||||
{
|
||||
if (debugFilter)
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if (m_refuseFocus) {
|
||||
// Refuse the focus if the mouse it outside. In addition to the mouse
|
||||
// press logic, this prevents a re-focussing which occurs once
|
||||
// we actually had focus
|
||||
const Qt::FocusReason reason = e->reason();
|
||||
if (reason == Qt::ActiveWindowFocusReason || reason == Qt::PopupFocusReason) {
|
||||
const QPoint mousePos = mapFromGlobal(QCursor::pos());
|
||||
const bool refuse = !geometry().contains(mousePos);
|
||||
if (debugFilter)
|
||||
qDebug() << Q_FUNC_INFO << refuse ;
|
||||
if (refuse) {
|
||||
e->ignore();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QLineEdit::focusInEvent(e);
|
||||
}
|
||||
|
||||
// ------------------- FilterWidget
|
||||
FilterWidget::FilterWidget(QWidget *parent, LayoutMode lm) :
|
||||
QWidget(parent),
|
||||
m_editor(new HintLineEdit(this)),
|
||||
m_button(new IconButton(m_editor)),
|
||||
m_buttonwidth(0)
|
||||
{
|
||||
m_editor->setPlaceholderText(tr("Filter"));
|
||||
|
||||
// Let the style determine minimum height for our widget
|
||||
QSize size(ICONBUTTON_SIZE + 6, ICONBUTTON_SIZE + 2);
|
||||
|
||||
// Note KDE does not reserve space for the highlight color
|
||||
if (style()->inherits("OxygenStyle")) {
|
||||
size = size.expandedTo(QSize(24, 0));
|
||||
}
|
||||
|
||||
// Make room for clear icon
|
||||
QMargins margins = m_editor->textMargins();
|
||||
if (layoutDirection() == Qt::LeftToRight)
|
||||
margins.setRight(size.width());
|
||||
else
|
||||
margins.setLeft(size.width());
|
||||
|
||||
m_editor->setTextMargins(margins);
|
||||
|
||||
QHBoxLayout *l = new QHBoxLayout(this);
|
||||
l->setMargin(0);
|
||||
l->setSpacing(0);
|
||||
if (lm == LayoutAlignRight)
|
||||
l->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
|
||||
l->addWidget(m_editor);
|
||||
|
||||
// KDE has custom icons for this. Notice that icon namings are counter intuitive
|
||||
// If these icons are not avaiable we use the freedesktop standard name before
|
||||
// falling back to a bundled resource
|
||||
QIcon icon = QIcon::fromTheme(layoutDirection() == Qt::LeftToRight ?
|
||||
QLatin1String("edit-clear-locationbar-rtl") :
|
||||
QLatin1String("edit-clear-locationbar-ltr"),
|
||||
QIcon::fromTheme("edit-clear", createIconSet(QLatin1String("cleartext.png"))));
|
||||
|
||||
m_button->setIcon(icon);
|
||||
m_button->setToolTip(tr("Clear text"));
|
||||
connect(m_button, SIGNAL(clicked()), this, SLOT(reset()));
|
||||
connect(m_editor, SIGNAL(textChanged(QString)), this, SLOT(checkButton(QString)));
|
||||
connect(m_editor, SIGNAL(textEdited(QString)), this, SIGNAL(filterChanged(QString)));
|
||||
}
|
||||
|
||||
QString FilterWidget::text() const
|
||||
{
|
||||
return m_editor->text();
|
||||
}
|
||||
|
||||
void FilterWidget::checkButton(const QString &text)
|
||||
{
|
||||
if (m_oldText.isEmpty() || text.isEmpty())
|
||||
m_button->animateShow(!m_editor->text().isEmpty());
|
||||
m_oldText = text;
|
||||
}
|
||||
|
||||
void FilterWidget::reset()
|
||||
{
|
||||
if (debugFilter)
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if (!m_editor->text().isEmpty()) {
|
||||
// Editor has lost focus once this is pressed
|
||||
m_editor->clear();
|
||||
emit filterChanged(QString());
|
||||
}
|
||||
}
|
||||
|
||||
void FilterWidget::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
QRect contentRect = m_editor->rect();
|
||||
if (layoutDirection() == Qt::LeftToRight) {
|
||||
const int iconoffset = m_editor->textMargins().right() + 4;
|
||||
m_button->setGeometry(contentRect.adjusted(m_editor->width() - iconoffset, 0, 0, 0));
|
||||
} else {
|
||||
const int iconoffset = m_editor->textMargins().left() + 4;
|
||||
m_button->setGeometry(contentRect.adjusted(0, 0, -m_editor->width() + iconoffset, 0));
|
||||
}
|
||||
}
|
||||
|
||||
bool FilterWidget::refuseFocus() const
|
||||
{
|
||||
return m_editor->refuseFocus();
|
||||
}
|
||||
|
||||
void FilterWidget::setRefuseFocus(bool v)
|
||||
{
|
||||
m_editor->setRefuseFocus(v);
|
||||
}
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
151
third/designer/lib/shared/filterwidget_p.h
Normal file
151
third/designer/lib/shared/filterwidget_p.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 FILTERWIDGET_H
|
||||
#define FILTERWIDGET_H
|
||||
|
||||
#include "shared_global_p.h"
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QColor>
|
||||
#include <QtGui/QToolButton>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QToolButton;
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
/* This widget should never have initial focus
|
||||
* (ie, be the first widget of a dialog, else, the hint cannot be displayed.
|
||||
* For situations, where it is the only focusable control (widget box),
|
||||
* there is a special "refuseFocus()" mode, in which it clears the focus
|
||||
* policy and focusses explicitly on click (note that setting Qt::ClickFocus
|
||||
* is not sufficient for that as an ActivationFocus will occur). */
|
||||
|
||||
#define ICONBUTTON_SIZE 16
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT HintLineEdit : public QLineEdit {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HintLineEdit(QWidget *parent = 0);
|
||||
|
||||
bool refuseFocus() const;
|
||||
void setRefuseFocus(bool v);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent *event);
|
||||
virtual void focusInEvent(QFocusEvent *e);
|
||||
|
||||
private:
|
||||
const Qt::FocusPolicy m_defaultFocusPolicy;
|
||||
bool m_refuseFocus;
|
||||
};
|
||||
|
||||
// IconButton: This is a simple helper class that represents clickable icons
|
||||
|
||||
class IconButton: public QToolButton
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(float fader READ fader WRITE setFader)
|
||||
public:
|
||||
IconButton(QWidget *parent);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
float fader() { return m_fader; }
|
||||
void setFader(float value) { m_fader = value; update(); }
|
||||
void animateShow(bool visible);
|
||||
|
||||
private:
|
||||
float m_fader;
|
||||
};
|
||||
|
||||
// FilterWidget: For filtering item views, with reset button Uses HintLineEdit.
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT FilterWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum LayoutMode {
|
||||
// For use in toolbars: Expand to the right
|
||||
LayoutAlignRight,
|
||||
// No special alignment
|
||||
LayoutAlignNone
|
||||
};
|
||||
|
||||
explicit FilterWidget(QWidget *parent = 0, LayoutMode lm = LayoutAlignRight);
|
||||
|
||||
QString text() const;
|
||||
void resizeEvent(QResizeEvent *);
|
||||
bool refuseFocus() const; // see HintLineEdit
|
||||
void setRefuseFocus(bool v);
|
||||
|
||||
signals:
|
||||
void filterChanged(const QString &);
|
||||
|
||||
public slots:
|
||||
void reset();
|
||||
|
||||
private slots:
|
||||
void checkButton(const QString &text);
|
||||
|
||||
private:
|
||||
HintLineEdit *m_editor;
|
||||
IconButton *m_button;
|
||||
int m_buttonwidth;
|
||||
QString m_oldText;
|
||||
};
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
534
third/designer/lib/shared/formlayoutmenu.cpp
Normal file
534
third/designer/lib/shared/formlayoutmenu.cpp
Normal file
@@ -0,0 +1,534 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "formlayoutmenu_p.h"
|
||||
#include "layoutinfo_p.h"
|
||||
#include "qdesigner_command_p.h"
|
||||
#include "qdesigner_utils_p.h"
|
||||
#include "qdesigner_propertycommand_p.h"
|
||||
#include "ui_formlayoutrowdialog.h"
|
||||
|
||||
#include <QtDesigner/QDesignerFormWindowInterface>
|
||||
#include <QtDesigner/QDesignerFormEditorInterface>
|
||||
#include <QtDesigner/QDesignerWidgetFactoryInterface>
|
||||
#include <QtDesigner/QDesignerPropertySheetExtension>
|
||||
#include <QtDesigner/QExtensionManager>
|
||||
#include <QtDesigner/QDesignerWidgetDataBaseInterface>
|
||||
#include <QtDesigner/QDesignerLanguageExtension>
|
||||
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QFormLayout>
|
||||
#include <QtGui/QUndoStack>
|
||||
#include <QtGui/QDialog>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QRegExpValidator>
|
||||
|
||||
#include <QtCore/QPair>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QRegExp>
|
||||
#include <QtCore/QMultiHash>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
static const char *buddyPropertyC = "buddy";
|
||||
static const char *fieldWidgetBaseClasses[] = {
|
||||
"QLineEdit", "QComboBox", "QSpinBox", "QDoubleSpinBox", "QCheckBox",
|
||||
"QDateEdit", "QTimeEdit", "QDateTimeEdit", "QDial", "QWidget"
|
||||
};
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
// Struct that describes a row of controls (descriptive label and control) to
|
||||
// be added to a form layout.
|
||||
struct FormLayoutRow {
|
||||
FormLayoutRow() : buddy(false) {}
|
||||
|
||||
QString labelName;
|
||||
QString labelText;
|
||||
QString fieldClassName;
|
||||
QString fieldName;
|
||||
bool buddy;
|
||||
};
|
||||
|
||||
// A Dialog to edit a FormLayoutRow. Lets the user input a label text, label
|
||||
// name, field widget type, field object name and buddy setting. As the
|
||||
// user types the label text; the object names to be used for label and field
|
||||
// are updated. It also checks the buddy setting depending on whether the
|
||||
// label text contains a buddy marker.
|
||||
class FormLayoutRowDialog : public QDialog {
|
||||
Q_DISABLE_COPY(FormLayoutRowDialog)
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FormLayoutRowDialog(QDesignerFormEditorInterface *core,
|
||||
QWidget *parent);
|
||||
|
||||
FormLayoutRow formLayoutRow() const;
|
||||
|
||||
bool buddy() const;
|
||||
void setBuddy(bool);
|
||||
|
||||
// Accessors for form layout row numbers using 0..[n-1] convention
|
||||
int row() const;
|
||||
void setRow(int);
|
||||
void setRowRange(int, int);
|
||||
|
||||
QString fieldClass() const;
|
||||
QString labelText() const;
|
||||
|
||||
static QStringList fieldWidgetClasses(QDesignerFormEditorInterface *core);
|
||||
|
||||
private slots:
|
||||
void labelTextEdited(const QString &text);
|
||||
void labelNameEdited(const QString &text);
|
||||
void fieldNameEdited(const QString &text);
|
||||
void buddyClicked();
|
||||
void fieldClassChanged(int);
|
||||
|
||||
private:
|
||||
bool isValid() const;
|
||||
void updateObjectNames(bool updateLabel, bool updateField);
|
||||
void updateOkButton();
|
||||
|
||||
// Check for buddy marker in string
|
||||
const QRegExp m_buddyMarkerRegexp;
|
||||
|
||||
Ui::FormLayoutRowDialog m_ui;
|
||||
bool m_labelNameEdited;
|
||||
bool m_fieldNameEdited;
|
||||
bool m_buddyClicked;
|
||||
};
|
||||
|
||||
FormLayoutRowDialog::FormLayoutRowDialog(QDesignerFormEditorInterface *core,
|
||||
QWidget *parent) :
|
||||
QDialog(parent),
|
||||
m_buddyMarkerRegexp(QLatin1String("\\&[^&]")),
|
||||
m_labelNameEdited(false),
|
||||
m_fieldNameEdited(false),
|
||||
m_buddyClicked(false)
|
||||
{
|
||||
Q_ASSERT(m_buddyMarkerRegexp.isValid());
|
||||
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
setModal(true);
|
||||
m_ui.setupUi(this);
|
||||
connect(m_ui.labelTextLineEdit, SIGNAL(textEdited(QString)), this, SLOT(labelTextEdited(QString)));
|
||||
|
||||
QRegExpValidator *nameValidator = new QRegExpValidator(QRegExp(QLatin1String("^[a-zA-Z0-9_]+$")), this);
|
||||
Q_ASSERT(nameValidator->regExp().isValid());
|
||||
|
||||
m_ui.labelNameLineEdit->setValidator(nameValidator);
|
||||
connect(m_ui.labelNameLineEdit, SIGNAL(textEdited(QString)),
|
||||
this, SLOT(labelNameEdited(QString)));
|
||||
|
||||
m_ui.fieldNameLineEdit->setValidator(nameValidator);
|
||||
connect(m_ui.fieldNameLineEdit, SIGNAL(textEdited(QString)),
|
||||
this, SLOT(fieldNameEdited(QString)));
|
||||
|
||||
connect(m_ui.buddyCheckBox, SIGNAL(clicked()), this, SLOT(buddyClicked()));
|
||||
|
||||
m_ui.fieldClassComboBox->addItems(fieldWidgetClasses(core));
|
||||
m_ui.fieldClassComboBox->setCurrentIndex(0);
|
||||
connect(m_ui.fieldClassComboBox, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(fieldClassChanged(int)));
|
||||
|
||||
updateOkButton();
|
||||
}
|
||||
|
||||
FormLayoutRow FormLayoutRowDialog::formLayoutRow() const
|
||||
{
|
||||
FormLayoutRow rc;
|
||||
rc.labelText = labelText();
|
||||
rc.labelName = m_ui.labelNameLineEdit->text();
|
||||
rc.fieldClassName = fieldClass();
|
||||
rc.fieldName = m_ui.fieldNameLineEdit->text();
|
||||
rc.buddy = buddy();
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool FormLayoutRowDialog::buddy() const
|
||||
{
|
||||
return m_ui.buddyCheckBox->checkState() == Qt::Checked;
|
||||
}
|
||||
|
||||
void FormLayoutRowDialog::setBuddy(bool b)
|
||||
{
|
||||
m_ui.buddyCheckBox->setCheckState(b ? Qt::Checked : Qt::Unchecked);
|
||||
}
|
||||
|
||||
// Convert rows to 1..n convention for users
|
||||
int FormLayoutRowDialog::row() const
|
||||
{
|
||||
return m_ui.rowSpinBox->value() - 1;
|
||||
}
|
||||
|
||||
void FormLayoutRowDialog::setRow(int row)
|
||||
{
|
||||
m_ui.rowSpinBox->setValue(row + 1);
|
||||
}
|
||||
|
||||
void FormLayoutRowDialog::setRowRange(int from, int to)
|
||||
{
|
||||
m_ui.rowSpinBox->setMinimum(from + 1);
|
||||
m_ui.rowSpinBox->setMaximum(to + 1);
|
||||
m_ui.rowSpinBox->setEnabled(to - from > 0);
|
||||
}
|
||||
|
||||
QString FormLayoutRowDialog::fieldClass() const
|
||||
{
|
||||
return m_ui.fieldClassComboBox->itemText(m_ui.fieldClassComboBox->currentIndex());
|
||||
}
|
||||
|
||||
QString FormLayoutRowDialog::labelText() const
|
||||
{
|
||||
return m_ui.labelTextLineEdit->text();
|
||||
}
|
||||
|
||||
bool FormLayoutRowDialog::isValid() const
|
||||
{
|
||||
// Check for non-empty names and presence of buddy marker if checked
|
||||
const QString name = labelText();
|
||||
if (name.isEmpty() || m_ui.labelNameLineEdit->text().isEmpty() || m_ui.fieldNameLineEdit->text().isEmpty())
|
||||
return false;
|
||||
if (buddy() && !name.contains(m_buddyMarkerRegexp))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FormLayoutRowDialog::updateOkButton()
|
||||
{
|
||||
m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(isValid());
|
||||
}
|
||||
|
||||
void FormLayoutRowDialog::labelTextEdited(const QString &text)
|
||||
{
|
||||
updateObjectNames(true, true);
|
||||
// Set buddy if '&' is present unless the user changed it
|
||||
if (!m_buddyClicked)
|
||||
setBuddy(text.contains(m_buddyMarkerRegexp));
|
||||
|
||||
updateOkButton();
|
||||
}
|
||||
|
||||
// Get a suitable object name postfix from a class name:
|
||||
// "namespace::QLineEdit"->"LineEdit"
|
||||
static inline QString postFixFromClassName(QString className)
|
||||
{
|
||||
const int index = className.lastIndexOf(QLatin1String("::"));
|
||||
if (index != -1)
|
||||
className.remove(0, index + 2);
|
||||
if (className.size() > 2)
|
||||
if (className.at(0) == QLatin1Char('Q') || className.at(0) == QLatin1Char('K'))
|
||||
if (className.at(1).isUpper())
|
||||
className.remove(0, 1);
|
||||
return className;
|
||||
}
|
||||
|
||||
// Helper routines to filter out characters for converting texts into
|
||||
// class name prefixes. Only accepts ASCII characters/digits and underscores.
|
||||
|
||||
enum PrefixCharacterKind { PC_Digit, PC_UpperCaseLetter, PC_LowerCaseLetter,
|
||||
PC_Other, PC_Invalid };
|
||||
|
||||
static inline PrefixCharacterKind prefixCharacterKind(const QChar &c)
|
||||
{
|
||||
switch (c.category()) {
|
||||
case QChar::Number_DecimalDigit:
|
||||
return PC_Digit;
|
||||
case QChar::Letter_Lowercase: {
|
||||
const char a = c.toAscii();
|
||||
if (a >= 'a' && a <= 'z')
|
||||
return PC_LowerCaseLetter;
|
||||
}
|
||||
break;
|
||||
case QChar::Letter_Uppercase: {
|
||||
const char a = c.toAscii();
|
||||
if (a >= 'A' && a <= 'Z')
|
||||
return PC_UpperCaseLetter;
|
||||
}
|
||||
break;
|
||||
case QChar::Punctuation_Connector:
|
||||
if (c.toAscii() == '_')
|
||||
return PC_Other;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return PC_Invalid;
|
||||
}
|
||||
|
||||
// Convert the text the user types into a usable class name prefix by filtering
|
||||
// characters, lower-casing the first character and camel-casing subsequent
|
||||
// words. ("zip code:") --> ("zipCode").
|
||||
|
||||
static QString prefixFromLabel(const QString &prefix)
|
||||
{
|
||||
QString rc;
|
||||
const int length = prefix.size();
|
||||
bool lastWasAcceptable = false;
|
||||
for (int i = 0 ; i < length; i++) {
|
||||
const QChar c = prefix.at(i);
|
||||
const PrefixCharacterKind kind = prefixCharacterKind(c);
|
||||
const bool acceptable = kind != PC_Invalid;
|
||||
if (acceptable) {
|
||||
if (rc.isEmpty()) {
|
||||
// Lower-case first character
|
||||
rc += kind == PC_UpperCaseLetter ? c.toLower() : c;
|
||||
} else {
|
||||
// Camel-case words
|
||||
rc += !lastWasAcceptable && kind == PC_LowerCaseLetter ? c.toUpper() : c;
|
||||
}
|
||||
}
|
||||
lastWasAcceptable = acceptable;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
void FormLayoutRowDialog::updateObjectNames(bool updateLabel, bool updateField)
|
||||
{
|
||||
// Generate label + field object names from the label text, that is,
|
||||
// "&Zip code:" -> "zipcodeLabel", "zipcodeLineEdit" unless the user
|
||||
// edited it.
|
||||
const bool doUpdateLabel = !m_labelNameEdited && updateLabel;
|
||||
const bool doUpdateField = !m_fieldNameEdited && updateField;
|
||||
if (!doUpdateLabel && !doUpdateField)
|
||||
return;
|
||||
|
||||
const QString prefix = prefixFromLabel(labelText());
|
||||
// Set names
|
||||
if (doUpdateLabel)
|
||||
m_ui.labelNameLineEdit->setText(prefix + QLatin1String("Label"));
|
||||
if (doUpdateField)
|
||||
m_ui.fieldNameLineEdit->setText(prefix + postFixFromClassName(fieldClass()));
|
||||
}
|
||||
|
||||
void FormLayoutRowDialog::fieldClassChanged(int)
|
||||
{
|
||||
updateObjectNames(false, true);
|
||||
}
|
||||
|
||||
void FormLayoutRowDialog::labelNameEdited(const QString & /*text*/)
|
||||
{
|
||||
m_labelNameEdited = true; // stop auto-updating after user change
|
||||
updateOkButton();
|
||||
}
|
||||
|
||||
void FormLayoutRowDialog::fieldNameEdited(const QString & /*text*/)
|
||||
{
|
||||
m_fieldNameEdited = true; // stop auto-updating after user change
|
||||
updateOkButton();
|
||||
}
|
||||
|
||||
void FormLayoutRowDialog::buddyClicked()
|
||||
{
|
||||
m_buddyClicked = true; // stop auto-updating after user change
|
||||
updateOkButton();
|
||||
}
|
||||
|
||||
/* Create a list of classes suitable for field widgets. Take the fixed base
|
||||
* classes provided and look in the widget database for custom widgets derived
|
||||
* from them ("QLineEdit", "CustomLineEdit", "QComboBox"...). */
|
||||
QStringList FormLayoutRowDialog::fieldWidgetClasses(QDesignerFormEditorInterface *core)
|
||||
{
|
||||
// Base class -> custom widgets map
|
||||
typedef QMultiHash<QString, QString> ClassMap;
|
||||
|
||||
static QStringList rc;
|
||||
if (rc.empty()) {
|
||||
const int fwCount = sizeof(fieldWidgetBaseClasses)/sizeof(const char*);
|
||||
// Turn known base classes into list
|
||||
QStringList baseClasses;
|
||||
for (int i = 0; i < fwCount; i++)
|
||||
baseClasses.push_back(QLatin1String(fieldWidgetBaseClasses[i]));
|
||||
// Scan for custom widgets that inherit them and store them in a
|
||||
// multimap of base class->custom widgets unless we have a language
|
||||
// extension installed which might do funny things with custom widgets.
|
||||
ClassMap customClassMap;
|
||||
if (qt_extension<QDesignerLanguageExtension *>(core->extensionManager(), core) == 0) {
|
||||
const QDesignerWidgetDataBaseInterface *wdb = core->widgetDataBase();
|
||||
const int wdbCount = wdb->count();
|
||||
for (int w = 0; w < wdbCount; ++w) {
|
||||
// Check for non-container custom types that extend the
|
||||
// respective base class.
|
||||
const QDesignerWidgetDataBaseItemInterface *dbItem = wdb->item(w);
|
||||
if (!dbItem->isPromoted() && !dbItem->isContainer() && dbItem->isCustom()) {
|
||||
const int index = baseClasses.indexOf(dbItem->extends());
|
||||
if (index != -1)
|
||||
customClassMap.insert(baseClasses.at(index), dbItem->name());
|
||||
}
|
||||
}
|
||||
}
|
||||
// Compile final list, taking each base class and append custom widgets
|
||||
// based on it.
|
||||
for (int i = 0; i < fwCount; i++) {
|
||||
rc.push_back(baseClasses.at(i));
|
||||
rc += customClassMap.values(baseClasses.at(i));
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
// ------------------ Utilities
|
||||
|
||||
static QFormLayout *managedFormLayout(const QDesignerFormEditorInterface *core, const QWidget *w)
|
||||
{
|
||||
QLayout *l = 0;
|
||||
if (LayoutInfo::managedLayoutType(core, w, &l) == LayoutInfo::Form)
|
||||
return qobject_cast<QFormLayout *>(l);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Create the widgets of a control row and apply text properties contained
|
||||
// in the struct, called by addFormLayoutRow()
|
||||
static QPair<QWidget *,QWidget *>
|
||||
createWidgets(const FormLayoutRow &row, QWidget *parent,
|
||||
QDesignerFormWindowInterface *formWindow)
|
||||
{
|
||||
QDesignerFormEditorInterface *core = formWindow->core();
|
||||
QDesignerWidgetFactoryInterface *wf = core->widgetFactory();
|
||||
|
||||
QPair<QWidget *,QWidget *> rc = QPair<QWidget *,QWidget *>(wf->createWidget(QLatin1String("QLabel"), parent),
|
||||
wf->createWidget(row.fieldClassName, parent));
|
||||
// Set up properties of the label
|
||||
const QString objectNameProperty = QLatin1String("objectName");
|
||||
QDesignerPropertySheetExtension *labelSheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), rc.first);
|
||||
int nameIndex = labelSheet->indexOf(objectNameProperty);
|
||||
labelSheet->setProperty(nameIndex, qVariantFromValue(PropertySheetStringValue(row.labelName)));
|
||||
labelSheet->setChanged(nameIndex, true);
|
||||
formWindow->ensureUniqueObjectName(rc.first);
|
||||
const int textIndex = labelSheet->indexOf(QLatin1String("text"));
|
||||
labelSheet->setProperty(textIndex, qVariantFromValue(PropertySheetStringValue(row.labelText)));
|
||||
labelSheet->setChanged(textIndex, true);
|
||||
// Set up properties of the control
|
||||
QDesignerPropertySheetExtension *controlSheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), rc.second);
|
||||
nameIndex = controlSheet->indexOf(objectNameProperty);
|
||||
controlSheet->setProperty(nameIndex, qVariantFromValue(PropertySheetStringValue(row.fieldName)));
|
||||
controlSheet->setChanged(nameIndex, true);
|
||||
formWindow->ensureUniqueObjectName(rc.second);
|
||||
return rc;
|
||||
}
|
||||
|
||||
// Create a command sequence on the undo stack of the form window that creates
|
||||
// the widgets of the row and inserts them into the form layout.
|
||||
static void addFormLayoutRow(const FormLayoutRow &formLayoutRow, int row, QWidget *w,
|
||||
QDesignerFormWindowInterface *formWindow)
|
||||
{
|
||||
QFormLayout *formLayout = managedFormLayout(formWindow->core(), w);
|
||||
Q_ASSERT(formLayout);
|
||||
QUndoStack *undoStack = formWindow->commandHistory();
|
||||
const QString macroName = QCoreApplication::translate("Command", "Add '%1' to '%2'").arg(formLayoutRow.labelText, formLayout->objectName());
|
||||
undoStack->beginMacro(macroName);
|
||||
|
||||
// Create a list of widget insertion commands and pass them a cell position
|
||||
const QPair<QWidget *,QWidget *> widgetPair = createWidgets(formLayoutRow, w, formWindow);
|
||||
|
||||
InsertWidgetCommand *labelCmd = new InsertWidgetCommand(formWindow);
|
||||
labelCmd->init(widgetPair.first, false, row, 0);
|
||||
undoStack->push(labelCmd);
|
||||
InsertWidgetCommand *controlCmd = new InsertWidgetCommand(formWindow);
|
||||
controlCmd->init(widgetPair.second, false, row, 1);
|
||||
undoStack->push(controlCmd);
|
||||
if (formLayoutRow.buddy) {
|
||||
SetPropertyCommand *buddyCommand = new SetPropertyCommand(formWindow);
|
||||
buddyCommand->init(widgetPair.first, QLatin1String(buddyPropertyC), widgetPair.second->objectName());
|
||||
undoStack->push(buddyCommand);
|
||||
}
|
||||
undoStack->endMacro();
|
||||
}
|
||||
|
||||
// ---------------- FormLayoutMenu
|
||||
FormLayoutMenu::FormLayoutMenu(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_separator1(new QAction(this)),
|
||||
m_populateFormAction(new QAction(tr("Add form layout row..."), this)),
|
||||
m_separator2(new QAction(this))
|
||||
{
|
||||
m_separator1->setSeparator(true);
|
||||
connect(m_populateFormAction, SIGNAL(triggered()), this, SLOT(slotAddRow()));
|
||||
m_separator2->setSeparator(true);
|
||||
}
|
||||
|
||||
void FormLayoutMenu::populate(QWidget *w, QDesignerFormWindowInterface *fw, ActionList &actions)
|
||||
{
|
||||
switch (LayoutInfo::managedLayoutType(fw->core(), w)) {
|
||||
case LayoutInfo::Form:
|
||||
if (!actions.empty() && !actions.back()->isSeparator())
|
||||
actions.push_back(m_separator1);
|
||||
actions.push_back(m_populateFormAction);
|
||||
actions.push_back(m_separator2);
|
||||
m_widget = w;
|
||||
break;
|
||||
default:
|
||||
m_widget = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FormLayoutMenu::slotAddRow()
|
||||
{
|
||||
QDesignerFormWindowInterface *fw = QDesignerFormWindowInterface::findFormWindow(m_widget);
|
||||
Q_ASSERT(m_widget && fw);
|
||||
const int rowCount = managedFormLayout(fw->core(), m_widget)->rowCount();
|
||||
|
||||
FormLayoutRowDialog dialog(fw->core(), fw);
|
||||
dialog.setRowRange(0, rowCount);
|
||||
dialog.setRow(rowCount);
|
||||
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
addFormLayoutRow(dialog.formLayoutRow(), dialog.row(), m_widget, fw);
|
||||
}
|
||||
|
||||
QAction *FormLayoutMenu::preferredEditAction(QWidget *w, QDesignerFormWindowInterface *fw)
|
||||
{
|
||||
if (LayoutInfo::managedLayoutType(fw->core(), w) == LayoutInfo::Form) {
|
||||
m_widget = w;
|
||||
return m_populateFormAction;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "formlayoutmenu.moc"
|
||||
|
||||
100
third/designer/lib/shared/formlayoutmenu_p.h
Normal file
100
third/designer/lib/shared/formlayoutmenu_p.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 FORMLAYOUTMENU
|
||||
#define FORMLAYOUTMENU
|
||||
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#include "shared_global_p.h"
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QPointer>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerFormWindowInterface;
|
||||
|
||||
class QAction;
|
||||
class QWidget;
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
// Task menu to be used for form layouts. Offers an options "Add row" which
|
||||
// pops up a dialog in which the user can specify label name, text and buddy.
|
||||
class QDESIGNER_SHARED_EXPORT FormLayoutMenu : public QObject
|
||||
{
|
||||
Q_DISABLE_COPY(FormLayoutMenu)
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef QList<QAction *> ActionList;
|
||||
|
||||
explicit FormLayoutMenu(QObject *parent);
|
||||
|
||||
// Populate a list of actions with the form layout actions.
|
||||
void populate(QWidget *w, QDesignerFormWindowInterface *fw, ActionList &actions);
|
||||
// For implementing QDesignerTaskMenuExtension::preferredEditAction():
|
||||
// Return appropriate action for double clicking.
|
||||
QAction *preferredEditAction(QWidget *w, QDesignerFormWindowInterface *fw);
|
||||
|
||||
private slots:
|
||||
void slotAddRow();
|
||||
|
||||
private:
|
||||
QAction *m_separator1;
|
||||
QAction *m_populateFormAction;
|
||||
QAction *m_separator2;
|
||||
QPointer<QWidget> m_widget;
|
||||
};
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // FORMLAYOUTMENU
|
||||
166
third/designer/lib/shared/formlayoutrowdialog.ui
Normal file
166
third/designer/lib/shared/formlayoutrowdialog.ui
Normal file
@@ -0,0 +1,166 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FormLayoutRowDialog</class>
|
||||
<widget class="QDialog" name="FormLayoutRowDialog">
|
||||
<property name="windowTitle">
|
||||
<string>Add Form Layout Row</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelTextLabel">
|
||||
<property name="text">
|
||||
<string>&Label text:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>labelTextLineEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="labelTextLineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="labelNameLineEdit"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="fieldClassLabel">
|
||||
<property name="text">
|
||||
<string>Field &type:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>fieldClassComboBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="fieldClassComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="fieldNameLabel">
|
||||
<property name="text">
|
||||
<string>&Field name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>fieldNameLineEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="buddyLabel">
|
||||
<property name="text">
|
||||
<string>&Buddy:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>buddyCheckBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="buddyCheckBox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="rowLabel">
|
||||
<property name="text">
|
||||
<string>&Row:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>rowSpinBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="rowSpinBox"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="fieldNameLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelNameLabel">
|
||||
<property name="text">
|
||||
<string>Label &name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>labelNameLineEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>FormLayoutRowDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>FormLayoutRowDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
502
third/designer/lib/shared/formwindowbase.cpp
Normal file
502
third/designer/lib/shared/formwindowbase.cpp
Normal file
@@ -0,0 +1,502 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "formwindowbase_p.h"
|
||||
#include "connectionedit_p.h"
|
||||
#include "qdesigner_command_p.h"
|
||||
#include "qdesigner_propertysheet_p.h"
|
||||
#include "qdesigner_propertyeditor_p.h"
|
||||
#include "qdesigner_menu_p.h"
|
||||
#include "qdesigner_menubar_p.h"
|
||||
#include "shared_settings_p.h"
|
||||
#include "grid_p.h"
|
||||
#include "deviceprofile_p.h"
|
||||
#include "qdesigner_utils_p.h"
|
||||
|
||||
#include "qsimpleresource_p.h"
|
||||
|
||||
#include <QtDesigner/QDesignerFormEditorInterface>
|
||||
#include <QtDesigner/QDesignerContainerExtension>
|
||||
#include <QtDesigner/QExtensionManager>
|
||||
#include <QtDesigner/QDesignerTaskMenuExtension>
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QListWidget>
|
||||
#include <QtGui/QTreeWidget>
|
||||
#include <QtGui/QTableWidget>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QtGui/QTabWidget>
|
||||
#include <QtGui/QToolBox>
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QStatusBar>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QLabel>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
class FormWindowBasePrivate {
|
||||
public:
|
||||
explicit FormWindowBasePrivate(QDesignerFormEditorInterface *core);
|
||||
|
||||
static Grid m_defaultGrid;
|
||||
|
||||
QDesignerFormWindowInterface::Feature m_feature;
|
||||
Grid m_grid;
|
||||
bool m_hasFormGrid;
|
||||
DesignerPixmapCache *m_pixmapCache;
|
||||
DesignerIconCache *m_iconCache;
|
||||
QtResourceSet *m_resourceSet;
|
||||
QMap<QDesignerPropertySheet *, QMap<int, bool> > m_reloadableResources; // bool is dummy, QMap used as QSet
|
||||
QMap<QDesignerPropertySheet *, QObject *> m_reloadablePropertySheets;
|
||||
const DeviceProfile m_deviceProfile;
|
||||
FormWindowBase::LineTerminatorMode m_lineTerminatorMode;
|
||||
FormWindowBase::SaveResourcesBehaviour m_saveResourcesBehaviour;
|
||||
};
|
||||
|
||||
FormWindowBasePrivate::FormWindowBasePrivate(QDesignerFormEditorInterface *core) :
|
||||
m_feature(QDesignerFormWindowInterface::DefaultFeature),
|
||||
m_grid(m_defaultGrid),
|
||||
m_hasFormGrid(false),
|
||||
m_pixmapCache(0),
|
||||
m_iconCache(0),
|
||||
m_resourceSet(0),
|
||||
m_deviceProfile(QDesignerSharedSettings(core).currentDeviceProfile()),
|
||||
m_lineTerminatorMode(FormWindowBase::NativeLineTerminator),
|
||||
m_saveResourcesBehaviour(FormWindowBase::SaveAll)
|
||||
{
|
||||
}
|
||||
|
||||
Grid FormWindowBasePrivate::m_defaultGrid;
|
||||
|
||||
FormWindowBase::FormWindowBase(QDesignerFormEditorInterface *core, QWidget *parent, Qt::WindowFlags flags) :
|
||||
QDesignerFormWindowInterface(parent, flags),
|
||||
m_d(new FormWindowBasePrivate(core))
|
||||
{
|
||||
syncGridFeature();
|
||||
m_d->m_pixmapCache = new DesignerPixmapCache(this);
|
||||
m_d->m_iconCache = new DesignerIconCache(m_d->m_pixmapCache, this);
|
||||
}
|
||||
|
||||
FormWindowBase::~FormWindowBase()
|
||||
{
|
||||
delete m_d;
|
||||
}
|
||||
|
||||
DesignerPixmapCache *FormWindowBase::pixmapCache() const
|
||||
{
|
||||
return m_d->m_pixmapCache;
|
||||
}
|
||||
|
||||
DesignerIconCache *FormWindowBase::iconCache() const
|
||||
{
|
||||
return m_d->m_iconCache;
|
||||
}
|
||||
|
||||
QtResourceSet *FormWindowBase::resourceSet() const
|
||||
{
|
||||
return m_d->m_resourceSet;
|
||||
}
|
||||
|
||||
void FormWindowBase::setResourceSet(QtResourceSet *resourceSet)
|
||||
{
|
||||
m_d->m_resourceSet = resourceSet;
|
||||
}
|
||||
|
||||
void FormWindowBase::addReloadableProperty(QDesignerPropertySheet *sheet, int index)
|
||||
{
|
||||
m_d->m_reloadableResources[sheet][index] = true;
|
||||
}
|
||||
|
||||
void FormWindowBase::removeReloadableProperty(QDesignerPropertySheet *sheet, int index)
|
||||
{
|
||||
m_d->m_reloadableResources[sheet].remove(index);
|
||||
if (m_d->m_reloadableResources[sheet].count() == 0)
|
||||
m_d->m_reloadableResources.remove(sheet);
|
||||
}
|
||||
|
||||
void FormWindowBase::addReloadablePropertySheet(QDesignerPropertySheet *sheet, QObject *object)
|
||||
{
|
||||
if (qobject_cast<QTreeWidget *>(object) ||
|
||||
qobject_cast<QTableWidget *>(object) ||
|
||||
qobject_cast<QListWidget *>(object) ||
|
||||
qobject_cast<QComboBox *>(object))
|
||||
m_d->m_reloadablePropertySheets[sheet] = object;
|
||||
}
|
||||
|
||||
void FormWindowBase::removeReloadablePropertySheet(QDesignerPropertySheet *sheet)
|
||||
{
|
||||
m_d->m_reloadablePropertySheets.remove(sheet);
|
||||
}
|
||||
|
||||
void FormWindowBase::reloadProperties()
|
||||
{
|
||||
pixmapCache()->clear();
|
||||
iconCache()->clear();
|
||||
QMapIterator<QDesignerPropertySheet *, QMap<int, bool> > itSheet(m_d->m_reloadableResources);
|
||||
while (itSheet.hasNext()) {
|
||||
QDesignerPropertySheet *sheet = itSheet.next().key();
|
||||
QMapIterator<int, bool> itIndex(itSheet.value());
|
||||
while (itIndex.hasNext()) {
|
||||
const int index = itIndex.next().key();
|
||||
const QVariant newValue = sheet->property(index);
|
||||
if (qobject_cast<QLabel *>(sheet->object()) && sheet->propertyName(index) == QLatin1String("text")) {
|
||||
const PropertySheetStringValue newString = qVariantValue<PropertySheetStringValue>(newValue);
|
||||
// optimize a bit, reset only if the text value might contain a reference to qt resources
|
||||
// (however reloading of icons other than taken from resources might not work here)
|
||||
if (newString.value().contains(QLatin1String(":/"))) {
|
||||
const QVariant resetValue = qVariantFromValue(PropertySheetStringValue());
|
||||
sheet->setProperty(index, resetValue);
|
||||
}
|
||||
}
|
||||
sheet->setProperty(index, newValue);
|
||||
}
|
||||
if (QTabWidget *tabWidget = qobject_cast<QTabWidget *>(sheet->object())) {
|
||||
const int count = tabWidget->count();
|
||||
const int current = tabWidget->currentIndex();
|
||||
const QString currentTabIcon = QLatin1String("currentTabIcon");
|
||||
for (int i = 0; i < count; i++) {
|
||||
tabWidget->setCurrentIndex(i);
|
||||
const int index = sheet->indexOf(currentTabIcon);
|
||||
sheet->setProperty(index, sheet->property(index));
|
||||
}
|
||||
tabWidget->setCurrentIndex(current);
|
||||
} else if (QToolBox *toolBox = qobject_cast<QToolBox *>(sheet->object())) {
|
||||
const int count = toolBox->count();
|
||||
const int current = toolBox->currentIndex();
|
||||
const QString currentItemIcon = QLatin1String("currentItemIcon");
|
||||
for (int i = 0; i < count; i++) {
|
||||
toolBox->setCurrentIndex(i);
|
||||
const int index = sheet->indexOf(currentItemIcon);
|
||||
sheet->setProperty(index, sheet->property(index));
|
||||
}
|
||||
toolBox->setCurrentIndex(current);
|
||||
}
|
||||
}
|
||||
QMapIterator<QDesignerPropertySheet *, QObject *> itSh(m_d->m_reloadablePropertySheets);
|
||||
while (itSh.hasNext()) {
|
||||
QObject *object = itSh.next().value();
|
||||
reloadIconResources(iconCache(), object);
|
||||
}
|
||||
}
|
||||
|
||||
void FormWindowBase::resourceSetActivated(QtResourceSet *resource, bool resourceSetChanged)
|
||||
{
|
||||
if (resource == resourceSet() && resourceSetChanged) {
|
||||
reloadProperties();
|
||||
emit pixmapCache()->reloaded();
|
||||
emit iconCache()->reloaded();
|
||||
if (QDesignerPropertyEditor *propertyEditor = qobject_cast<QDesignerPropertyEditor *>(core()->propertyEditor()))
|
||||
propertyEditor->reloadResourceProperties();
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap FormWindowBase::formData()
|
||||
{
|
||||
QVariantMap rc;
|
||||
if (m_d->m_hasFormGrid)
|
||||
m_d->m_grid.addToVariantMap(rc, true);
|
||||
return rc;
|
||||
}
|
||||
|
||||
void FormWindowBase::setFormData(const QVariantMap &vm)
|
||||
{
|
||||
Grid formGrid;
|
||||
m_d->m_hasFormGrid = formGrid.fromVariantMap(vm);
|
||||
if (m_d->m_hasFormGrid)
|
||||
m_d->m_grid = formGrid;
|
||||
}
|
||||
|
||||
QPoint FormWindowBase::grid() const
|
||||
{
|
||||
return QPoint(m_d->m_grid.deltaX(), m_d->m_grid.deltaY());
|
||||
}
|
||||
|
||||
void FormWindowBase::setGrid(const QPoint &grid)
|
||||
{
|
||||
m_d->m_grid.setDeltaX(grid.x());
|
||||
m_d->m_grid.setDeltaY(grid.y());
|
||||
}
|
||||
|
||||
bool FormWindowBase::hasFeature(Feature f) const
|
||||
{
|
||||
return f & m_d->m_feature;
|
||||
}
|
||||
|
||||
static void recursiveUpdate(QWidget *w)
|
||||
{
|
||||
w->update();
|
||||
|
||||
const QObjectList &l = w->children();
|
||||
const QObjectList::const_iterator cend = l.constEnd();
|
||||
for (QObjectList::const_iterator it = l.constBegin(); it != cend; ++it) {
|
||||
if (QWidget *w = qobject_cast<QWidget*>(*it))
|
||||
recursiveUpdate(w);
|
||||
}
|
||||
}
|
||||
|
||||
void FormWindowBase::setFeatures(Feature f)
|
||||
{
|
||||
m_d->m_feature = f;
|
||||
const bool enableGrid = f & GridFeature;
|
||||
m_d->m_grid.setVisible(enableGrid);
|
||||
m_d->m_grid.setSnapX(enableGrid);
|
||||
m_d->m_grid.setSnapY(enableGrid);
|
||||
emit featureChanged(f);
|
||||
recursiveUpdate(this);
|
||||
}
|
||||
|
||||
FormWindowBase::Feature FormWindowBase::features() const
|
||||
{
|
||||
return m_d->m_feature;
|
||||
}
|
||||
|
||||
bool FormWindowBase::gridVisible() const
|
||||
{
|
||||
return m_d->m_grid.visible() && currentTool() == 0;
|
||||
}
|
||||
|
||||
FormWindowBase::SaveResourcesBehaviour FormWindowBase::saveResourcesBehaviour() const
|
||||
{
|
||||
return m_d->m_saveResourcesBehaviour;
|
||||
}
|
||||
|
||||
void FormWindowBase::setSaveResourcesBehaviour(SaveResourcesBehaviour behaviour)
|
||||
{
|
||||
m_d->m_saveResourcesBehaviour = behaviour;
|
||||
}
|
||||
|
||||
void FormWindowBase::syncGridFeature()
|
||||
{
|
||||
if (m_d->m_grid.snapX() || m_d->m_grid.snapY())
|
||||
m_d->m_feature |= GridFeature;
|
||||
else
|
||||
m_d->m_feature &= ~GridFeature;
|
||||
}
|
||||
|
||||
void FormWindowBase::setDesignerGrid(const Grid& grid)
|
||||
{
|
||||
m_d->m_grid = grid;
|
||||
syncGridFeature();
|
||||
recursiveUpdate(this);
|
||||
}
|
||||
|
||||
const Grid &FormWindowBase::designerGrid() const
|
||||
{
|
||||
return m_d->m_grid;
|
||||
}
|
||||
|
||||
bool FormWindowBase::hasFormGrid() const
|
||||
{
|
||||
return m_d->m_hasFormGrid;
|
||||
}
|
||||
|
||||
void FormWindowBase::setHasFormGrid(bool b)
|
||||
{
|
||||
m_d->m_hasFormGrid = b;
|
||||
}
|
||||
|
||||
void FormWindowBase::setDefaultDesignerGrid(const Grid& grid)
|
||||
{
|
||||
FormWindowBasePrivate::m_defaultGrid = grid;
|
||||
}
|
||||
|
||||
const Grid &FormWindowBase::defaultDesignerGrid()
|
||||
{
|
||||
return FormWindowBasePrivate::m_defaultGrid;
|
||||
}
|
||||
|
||||
QMenu *FormWindowBase::initializePopupMenu(QWidget * /*managedWidget*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Widget under mouse for finding the Widget to highlight
|
||||
// when doing DnD. Restricts to pages by geometry if a container with
|
||||
// a container extension (or one of its helper widgets) is hit; otherwise
|
||||
// returns the widget as such (be it managed/unmanaged)
|
||||
|
||||
QWidget *FormWindowBase::widgetUnderMouse(const QPoint &formPos, WidgetUnderMouseMode /* wum */)
|
||||
{
|
||||
// widget_under_mouse might be some temporary thing like the dropLine. We need
|
||||
// the actual widget that's part of the edited GUI.
|
||||
QWidget *rc = widgetAt(formPos);
|
||||
if (!rc || qobject_cast<ConnectionEdit*>(rc))
|
||||
return 0;
|
||||
|
||||
if (rc == mainContainer()) {
|
||||
// Refuse main container areas if the main container has a container extension,
|
||||
// for example when hitting QToolBox/QTabWidget empty areas.
|
||||
if (qt_extension<QDesignerContainerExtension*>(core()->extensionManager(), rc))
|
||||
return 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
// If we hit on container extension type container, make sure
|
||||
// we use the top-most current page
|
||||
if (QWidget *container = findContainer(rc, false))
|
||||
if (QDesignerContainerExtension *c = qt_extension<QDesignerContainerExtension*>(core()->extensionManager(), container)) {
|
||||
// For container that do not have a "stacked" nature (QToolBox, QMdiArea),
|
||||
// make sure the position is within the current page
|
||||
const int ci = c->currentIndex();
|
||||
if (ci < 0)
|
||||
return 0;
|
||||
QWidget *page = c->widget(ci);
|
||||
QRect pageGeometry = page->geometry();
|
||||
pageGeometry.moveTo(page->mapTo(this, pageGeometry.topLeft()));
|
||||
if (!pageGeometry.contains(formPos))
|
||||
return 0;
|
||||
return page;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
void FormWindowBase::deleteWidgetList(const QWidgetList &widget_list)
|
||||
{
|
||||
// We need a macro here even for single widgets because the some components (for example,
|
||||
// the signal slot editor are connected to widgetRemoved() and add their
|
||||
// own commands (for example, to delete w's connections)
|
||||
const QString description = widget_list.size() == 1 ?
|
||||
tr("Delete '%1'").arg(widget_list.front()->objectName()) : tr("Delete");
|
||||
|
||||
commandHistory()->beginMacro(description);
|
||||
foreach (QWidget *w, widget_list) {
|
||||
emit widgetRemoved(w);
|
||||
DeleteWidgetCommand *cmd = new DeleteWidgetCommand(this);
|
||||
cmd->init(w);
|
||||
commandHistory()->push(cmd);
|
||||
}
|
||||
commandHistory()->endMacro();
|
||||
}
|
||||
|
||||
QMenu *FormWindowBase::createExtensionTaskMenu(QDesignerFormWindowInterface *fw, QObject *o, bool trailingSeparator)
|
||||
{
|
||||
typedef QList<QAction *> ActionList;
|
||||
ActionList actions;
|
||||
// 1) Standard public extension
|
||||
QExtensionManager *em = fw->core()->extensionManager();
|
||||
if (const QDesignerTaskMenuExtension *extTaskMenu = qt_extension<QDesignerTaskMenuExtension*>(em, o))
|
||||
actions += extTaskMenu->taskActions();
|
||||
if (const QDesignerTaskMenuExtension *intTaskMenu = qobject_cast<QDesignerTaskMenuExtension *>(em->extension(o, QLatin1String("QDesignerInternalTaskMenuExtension")))) {
|
||||
if (!actions.empty()) {
|
||||
QAction *a = new QAction(fw);
|
||||
a->setSeparator(true);
|
||||
actions.push_back(a);
|
||||
}
|
||||
actions += intTaskMenu->taskActions();
|
||||
}
|
||||
if (actions.empty())
|
||||
return 0;
|
||||
if (trailingSeparator && !actions.back()->isSeparator()) {
|
||||
QAction *a = new QAction(fw);
|
||||
a->setSeparator(true);
|
||||
actions.push_back(a);
|
||||
}
|
||||
QMenu *rc = new QMenu;
|
||||
const ActionList::const_iterator cend = actions.constEnd();
|
||||
for (ActionList::const_iterator it = actions.constBegin(); it != cend; ++it)
|
||||
rc->addAction(*it);
|
||||
return rc;
|
||||
}
|
||||
|
||||
void FormWindowBase::emitObjectRemoved(QObject *o)
|
||||
{
|
||||
emit objectRemoved(o);
|
||||
}
|
||||
|
||||
DeviceProfile FormWindowBase::deviceProfile() const
|
||||
{
|
||||
return m_d->m_deviceProfile;
|
||||
}
|
||||
|
||||
QString FormWindowBase::styleName() const
|
||||
{
|
||||
return m_d->m_deviceProfile.isEmpty() ? QString() : m_d->m_deviceProfile.style();
|
||||
}
|
||||
|
||||
void FormWindowBase::emitWidgetRemoved(QWidget *w)
|
||||
{
|
||||
emit widgetRemoved(w);
|
||||
}
|
||||
|
||||
QString FormWindowBase::deviceProfileName() const
|
||||
{
|
||||
return m_d->m_deviceProfile.isEmpty() ? QString() : m_d->m_deviceProfile.name();
|
||||
}
|
||||
|
||||
void FormWindowBase::setLineTerminatorMode(FormWindowBase::LineTerminatorMode mode)
|
||||
{
|
||||
m_d->m_lineTerminatorMode = mode;
|
||||
}
|
||||
|
||||
FormWindowBase::LineTerminatorMode FormWindowBase::lineTerminatorMode() const
|
||||
{
|
||||
return m_d->m_lineTerminatorMode;
|
||||
}
|
||||
|
||||
void FormWindowBase::triggerDefaultAction(QWidget *widget)
|
||||
{
|
||||
if (QAction *action = qdesigner_internal::preferredEditAction(core(), widget))
|
||||
QTimer::singleShot(0, action, SIGNAL(triggered()));
|
||||
}
|
||||
|
||||
void FormWindowBase::setupDefaultAction(QDesignerFormWindowInterface *fw)
|
||||
{
|
||||
QObject::connect(fw, SIGNAL(activated(QWidget*)), fw, SLOT(triggerDefaultAction(QWidget*)));
|
||||
}
|
||||
|
||||
QString FormWindowBase::fileContents() const
|
||||
{
|
||||
const bool oldValue = QSimpleResource::setWarningsEnabled(false);
|
||||
const QString rc = contents();
|
||||
QSimpleResource::setWarningsEnabled(oldValue);
|
||||
return rc;
|
||||
}
|
||||
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
205
third/designer/lib/shared/formwindowbase_p.h
Normal file
205
third/designer/lib/shared/formwindowbase_p.h
Normal file
@@ -0,0 +1,205 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 FORMWINDOWBASE_H
|
||||
#define FORMWINDOWBASE_H
|
||||
|
||||
#include "shared_global_p.h"
|
||||
|
||||
#include <QtDesigner/QDesignerFormWindowInterface>
|
||||
|
||||
#include <QtCore/QVariantMap>
|
||||
#include <QtCore/QList>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesignerDnDItemInterface;
|
||||
class QMenu;
|
||||
class QtResourceSet;
|
||||
class QDesignerPropertySheet;
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
class QEditorFormBuilder;
|
||||
class DeviceProfile;
|
||||
class Grid;
|
||||
|
||||
class DesignerPixmapCache;
|
||||
class DesignerIconCache;
|
||||
class FormWindowBasePrivate;
|
||||
|
||||
class QDESIGNER_SHARED_EXPORT FormWindowBase: public QDesignerFormWindowInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum HighlightMode { Restore, Highlight };
|
||||
enum SaveResourcesBehaviour { SaveAll, SaveOnlyUsedQrcFiles, DontSaveQrcFiles };
|
||||
|
||||
explicit FormWindowBase(QDesignerFormEditorInterface *core, QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
virtual ~FormWindowBase();
|
||||
|
||||
QVariantMap formData();
|
||||
void setFormData(const QVariantMap &vm);
|
||||
|
||||
// Return contents without warnings. Should be 'contents(bool quiet)'
|
||||
QString fileContents() const;
|
||||
|
||||
// Return the widget containing the form. This is used to
|
||||
// apply embedded design settings to that are inherited (for example font).
|
||||
// These are meant to be applied to the form only and not to the other editors
|
||||
// in the widget stack.
|
||||
virtual QWidget *formContainer() const = 0;
|
||||
|
||||
// Deprecated
|
||||
virtual QPoint grid() const;
|
||||
|
||||
// Deprecated
|
||||
virtual void setGrid(const QPoint &grid);
|
||||
|
||||
virtual bool hasFeature(Feature f) const;
|
||||
virtual Feature features() const;
|
||||
virtual void setFeatures(Feature f);
|
||||
|
||||
const Grid &designerGrid() const;
|
||||
void setDesignerGrid(const Grid& grid);
|
||||
|
||||
bool hasFormGrid() const;
|
||||
void setHasFormGrid(bool b);
|
||||
|
||||
bool gridVisible() const;
|
||||
|
||||
SaveResourcesBehaviour saveResourcesBehaviour() const;
|
||||
void setSaveResourcesBehaviour(SaveResourcesBehaviour behaviour);
|
||||
|
||||
static const Grid &defaultDesignerGrid();
|
||||
static void setDefaultDesignerGrid(const Grid& grid);
|
||||
|
||||
// Overwrite to initialize and return a full popup menu for a managed widget
|
||||
virtual QMenu *initializePopupMenu(QWidget *managedWidget);
|
||||
// Helper to create a basic popup menu from task menu extensions (internal/public)
|
||||
static QMenu *createExtensionTaskMenu(QDesignerFormWindowInterface *fw, QObject *o, bool trailingSeparator = true);
|
||||
|
||||
virtual bool dropWidgets(const QList<QDesignerDnDItemInterface*> &item_list, QWidget *target,
|
||||
const QPoint &global_mouse_pos) = 0;
|
||||
|
||||
// Helper to find the widget at the mouse position with some flags.
|
||||
enum WidgetUnderMouseMode { FindSingleSelectionDropTarget, FindMultiSelectionDropTarget };
|
||||
QWidget *widgetUnderMouse(const QPoint &formPos, WidgetUnderMouseMode m);
|
||||
|
||||
virtual QWidget *widgetAt(const QPoint &pos) = 0;
|
||||
virtual QWidget *findContainer(QWidget *w, bool excludeLayout) const = 0;
|
||||
|
||||
void deleteWidgetList(const QWidgetList &widget_list);
|
||||
|
||||
virtual void highlightWidget(QWidget *w, const QPoint &pos, HighlightMode mode = Highlight) = 0;
|
||||
|
||||
enum PasteMode { PasteAll, PasteActionsOnly };
|
||||
virtual void paste(PasteMode pasteMode) = 0;
|
||||
|
||||
// Factory method to create a form builder
|
||||
virtual QEditorFormBuilder *createFormBuilder() = 0;
|
||||
|
||||
virtual bool blockSelectionChanged(bool blocked) = 0;
|
||||
virtual void emitSelectionChanged() = 0;
|
||||
|
||||
DesignerPixmapCache *pixmapCache() const;
|
||||
DesignerIconCache *iconCache() const;
|
||||
QtResourceSet *resourceSet() const;
|
||||
void setResourceSet(QtResourceSet *resourceSet);
|
||||
void addReloadableProperty(QDesignerPropertySheet *sheet, int index);
|
||||
void removeReloadableProperty(QDesignerPropertySheet *sheet, int index);
|
||||
void addReloadablePropertySheet(QDesignerPropertySheet *sheet, QObject *object);
|
||||
void removeReloadablePropertySheet(QDesignerPropertySheet *sheet);
|
||||
void reloadProperties();
|
||||
|
||||
void emitWidgetRemoved(QWidget *w);
|
||||
void emitObjectRemoved(QObject *o);
|
||||
|
||||
DeviceProfile deviceProfile() const;
|
||||
QString styleName() const;
|
||||
QString deviceProfileName() const;
|
||||
|
||||
enum LineTerminatorMode {
|
||||
LFLineTerminator,
|
||||
CRLFLineTerminator,
|
||||
NativeLineTerminator =
|
||||
#if defined (Q_OS_WIN)
|
||||
CRLFLineTerminator
|
||||
#else
|
||||
LFLineTerminator
|
||||
#endif
|
||||
};
|
||||
|
||||
void setLineTerminatorMode(LineTerminatorMode mode);
|
||||
LineTerminatorMode lineTerminatorMode() const;
|
||||
|
||||
// Connect the 'activated' (doubleclicked) signal of the form window to a
|
||||
// slot triggering the default action (of the task menu)
|
||||
static void setupDefaultAction(QDesignerFormWindowInterface *fw);
|
||||
|
||||
public slots:
|
||||
void resourceSetActivated(QtResourceSet *resourceSet, bool resourceSetChanged);
|
||||
|
||||
private slots:
|
||||
void triggerDefaultAction(QWidget *w);
|
||||
|
||||
private:
|
||||
void syncGridFeature();
|
||||
|
||||
FormWindowBasePrivate *m_d;
|
||||
};
|
||||
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // FORMWINDOWBASE_H
|
||||
186
third/designer/lib/shared/grid.cpp
Normal file
186
third/designer/lib/shared/grid.cpp
Normal file
@@ -0,0 +1,186 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "grid_p.h"
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QVector>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/qevent.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static const bool defaultSnap = true;
|
||||
static const bool defaultVisible = true;
|
||||
static const int DEFAULT_GRID = 10;
|
||||
static const char* KEY_VISIBLE = "gridVisible";
|
||||
static const char* KEY_SNAPX = "gridSnapX";
|
||||
static const char* KEY_SNAPY = "gridSnapY";
|
||||
static const char* KEY_DELTAX = "gridDeltaX";
|
||||
static const char* KEY_DELTAY = "gridDeltaY";
|
||||
|
||||
// Insert a value into the serialization map unless default
|
||||
template <class T>
|
||||
static inline void valueToVariantMap(T value, T defaultValue, const QString &key, QVariantMap &v, bool forceKey) {
|
||||
if (forceKey || value != defaultValue)
|
||||
v.insert(key, QVariant(value));
|
||||
}
|
||||
|
||||
// Obtain a value form QVariantMap
|
||||
template <class T>
|
||||
static inline bool valueFromVariantMap(const QVariantMap &v, const QString &key, T &value) {
|
||||
const QVariantMap::const_iterator it = v.constFind(key);
|
||||
const bool found = it != v.constEnd();
|
||||
if (found)
|
||||
value = qVariantValue<T>(it.value());
|
||||
return found;
|
||||
}
|
||||
|
||||
namespace qdesigner_internal
|
||||
{
|
||||
|
||||
Grid::Grid() :
|
||||
m_visible(defaultVisible),
|
||||
m_snapX(defaultSnap),
|
||||
m_snapY(defaultSnap),
|
||||
m_deltaX(DEFAULT_GRID),
|
||||
m_deltaY(DEFAULT_GRID)
|
||||
{
|
||||
}
|
||||
|
||||
bool Grid::fromVariantMap(const QVariantMap& vm)
|
||||
{
|
||||
*this = Grid();
|
||||
valueFromVariantMap(vm, QLatin1String(KEY_VISIBLE), m_visible);
|
||||
valueFromVariantMap(vm, QLatin1String(KEY_SNAPX), m_snapX);
|
||||
valueFromVariantMap(vm, QLatin1String(KEY_SNAPY), m_snapY);
|
||||
valueFromVariantMap(vm, QLatin1String(KEY_DELTAX), m_deltaX);
|
||||
return valueFromVariantMap(vm, QLatin1String(KEY_DELTAY), m_deltaY);
|
||||
}
|
||||
|
||||
QVariantMap Grid::toVariantMap(bool forceKeys) const
|
||||
{
|
||||
QVariantMap rc;
|
||||
addToVariantMap(rc, forceKeys);
|
||||
return rc;
|
||||
}
|
||||
|
||||
void Grid::addToVariantMap(QVariantMap& vm, bool forceKeys) const
|
||||
{
|
||||
valueToVariantMap(m_visible, defaultVisible, QLatin1String(KEY_VISIBLE), vm, forceKeys);
|
||||
valueToVariantMap(m_snapX, defaultSnap, QLatin1String(KEY_SNAPX), vm, forceKeys);
|
||||
valueToVariantMap(m_snapY, defaultSnap, QLatin1String(KEY_SNAPY), vm, forceKeys);
|
||||
valueToVariantMap(m_deltaX, DEFAULT_GRID, QLatin1String(KEY_DELTAX), vm, forceKeys);
|
||||
valueToVariantMap(m_deltaY, DEFAULT_GRID, QLatin1String(KEY_DELTAY), vm, forceKeys);
|
||||
}
|
||||
|
||||
void Grid::paint(QWidget *widget, QPaintEvent *e) const
|
||||
{
|
||||
QPainter p(widget);
|
||||
paint(p, widget, e);
|
||||
}
|
||||
|
||||
void Grid::paint(QPainter &p, const QWidget *widget, QPaintEvent *e) const
|
||||
{
|
||||
p.setPen(widget->palette().dark().color());
|
||||
|
||||
if (m_visible) {
|
||||
const int xstart = (e->rect().x() / m_deltaX) * m_deltaX;
|
||||
const int ystart = (e->rect().y() / m_deltaY) * m_deltaY;
|
||||
|
||||
const int xend = e->rect().right();
|
||||
const int yend = e->rect().bottom();
|
||||
|
||||
typedef QVector<QPointF> Points;
|
||||
static Points points;
|
||||
points.clear();
|
||||
|
||||
for (int x = xstart; x <= xend; x += m_deltaX) {
|
||||
points.reserve((yend - ystart) / m_deltaY + 1);
|
||||
for (int y = ystart; y <= yend; y += m_deltaY)
|
||||
points.push_back(QPointF(x, y));
|
||||
p.drawPoints( &(*points.begin()), points.count());
|
||||
points.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Grid::snapValue(int value, int grid) const
|
||||
{
|
||||
const int rest = value % grid;
|
||||
const int absRest = (rest < 0) ? -rest : rest;
|
||||
int offset = 0;
|
||||
if (2 * absRest > grid)
|
||||
offset = 1;
|
||||
if (rest < 0)
|
||||
offset *= -1;
|
||||
return (value / grid + offset) * grid;
|
||||
}
|
||||
|
||||
QPoint Grid::snapPoint(const QPoint &p) const
|
||||
{
|
||||
const int sx = m_snapX ? snapValue(p.x(), m_deltaX) : p.x();
|
||||
const int sy = m_snapY ? snapValue(p.y(), m_deltaY) : p.y();
|
||||
return QPoint(sx, sy);
|
||||
}
|
||||
|
||||
int Grid::widgetHandleAdjustX(int x) const
|
||||
{
|
||||
return m_snapX ? (x / m_deltaX) * m_deltaX + 1 : x;
|
||||
}
|
||||
|
||||
int Grid::widgetHandleAdjustY(int y) const
|
||||
{
|
||||
return m_snapY ? (y / m_deltaY) * m_deltaY + 1 : y;
|
||||
}
|
||||
|
||||
bool Grid::equals(const Grid &rhs) const
|
||||
{
|
||||
return m_visible == rhs.m_visible &&
|
||||
m_snapX == rhs.m_snapX &&
|
||||
m_snapY == rhs.m_snapY &&
|
||||
m_deltaX == rhs.m_deltaX &&
|
||||
m_deltaY == rhs.m_deltaY;
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
118
third/designer/lib/shared/grid_p.h
Normal file
118
third/designer/lib/shared/grid_p.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 QDESIGNER_GRID_H
|
||||
#define QDESIGNER_GRID_H
|
||||
|
||||
#include "shared_global_p.h"
|
||||
|
||||
#include <QtCore/QVariantMap>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWidget;
|
||||
class QPaintEvent;
|
||||
class QPainter;
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
// Designer grid which is able to serialize to QVariantMap
|
||||
class QDESIGNER_SHARED_EXPORT Grid
|
||||
{
|
||||
public:
|
||||
Grid();
|
||||
|
||||
bool fromVariantMap(const QVariantMap& vm);
|
||||
|
||||
void addToVariantMap(QVariantMap& vm, bool forceKeys = false) const;
|
||||
QVariantMap toVariantMap(bool forceKeys = false) const;
|
||||
|
||||
inline bool visible() const { return m_visible; }
|
||||
void setVisible(bool visible) { m_visible = visible; }
|
||||
|
||||
inline bool snapX() const { return m_snapX; }
|
||||
void setSnapX(bool snap) { m_snapX = snap; }
|
||||
|
||||
inline bool snapY() const { return m_snapY; }
|
||||
void setSnapY(bool snap) { m_snapY = snap; }
|
||||
|
||||
inline int deltaX() const { return m_deltaX; }
|
||||
void setDeltaX(int dx) { m_deltaX = dx; }
|
||||
|
||||
inline int deltaY() const { return m_deltaY; }
|
||||
void setDeltaY(int dy) { m_deltaY = dy; }
|
||||
|
||||
void paint(QWidget *widget, QPaintEvent *e) const;
|
||||
void paint(QPainter &p, const QWidget *widget, QPaintEvent *e) const;
|
||||
|
||||
QPoint snapPoint(const QPoint &p) const;
|
||||
|
||||
int widgetHandleAdjustX(int x) const;
|
||||
int widgetHandleAdjustY(int y) const;
|
||||
|
||||
inline bool operator==(const Grid &rhs) const { return equals(rhs); }
|
||||
inline bool operator!=(const Grid &rhs) const { return !equals(rhs); }
|
||||
|
||||
private:
|
||||
bool equals(const Grid &rhs) const;
|
||||
int snapValue(int value, int grid) const;
|
||||
bool m_visible;
|
||||
bool m_snapX;
|
||||
bool m_snapY;
|
||||
int m_deltaX;
|
||||
int m_deltaY;
|
||||
};
|
||||
} // namespace qdesigner_internal
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDESIGNER_GRID_H
|
||||
121
third/designer/lib/shared/gridpanel.cpp
Normal file
121
third/designer/lib/shared/gridpanel.cpp
Normal file
@@ -0,0 +1,121 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "gridpanel_p.h"
|
||||
#include "ui_gridpanel.h"
|
||||
#include "grid_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace qdesigner_internal {
|
||||
|
||||
GridPanel::GridPanel(QWidget *parentWidget) :
|
||||
QWidget(parentWidget)
|
||||
{
|
||||
m_ui = new Ui::GridPanel;
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->m_resetButton, SIGNAL(clicked()), this, SLOT(reset()));
|
||||
}
|
||||
|
||||
GridPanel::~GridPanel()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void GridPanel::setGrid(const Grid &g)
|
||||
{
|
||||
m_ui->m_deltaXSpinBox->setValue(g.deltaX());
|
||||
m_ui->m_deltaYSpinBox->setValue(g.deltaY());
|
||||
m_ui->m_visibleCheckBox->setCheckState(g.visible() ? Qt::Checked : Qt::Unchecked);
|
||||
m_ui->m_snapXCheckBox->setCheckState(g.snapX() ? Qt::Checked : Qt::Unchecked);
|
||||
m_ui->m_snapYCheckBox->setCheckState(g.snapY() ? Qt::Checked : Qt::Unchecked);
|
||||
}
|
||||
|
||||
void GridPanel::setTitle(const QString &title)
|
||||
{
|
||||
m_ui->m_gridGroupBox->setTitle(title);
|
||||
}
|
||||
|
||||
Grid GridPanel::grid() const
|
||||
{
|
||||
Grid rc;
|
||||
rc.setDeltaX(m_ui->m_deltaXSpinBox->value());
|
||||
rc.setDeltaY(m_ui->m_deltaYSpinBox->value());
|
||||
rc.setSnapX(m_ui->m_snapXCheckBox->checkState() == Qt::Checked);
|
||||
rc.setSnapY(m_ui->m_snapYCheckBox->checkState() == Qt::Checked);
|
||||
rc.setVisible(m_ui->m_visibleCheckBox->checkState() == Qt::Checked);
|
||||
return rc;
|
||||
}
|
||||
|
||||
void GridPanel::reset()
|
||||
{
|
||||
setGrid(Grid());
|
||||
}
|
||||
|
||||
void GridPanel::setCheckable (bool c)
|
||||
{
|
||||
m_ui->m_gridGroupBox->setCheckable(c);
|
||||
}
|
||||
|
||||
bool GridPanel::isCheckable () const
|
||||
{
|
||||
return m_ui->m_gridGroupBox->isCheckable ();
|
||||
}
|
||||
|
||||
bool GridPanel::isChecked () const
|
||||
{
|
||||
return m_ui->m_gridGroupBox->isChecked ();
|
||||
}
|
||||
|
||||
void GridPanel::setChecked(bool c)
|
||||
{
|
||||
m_ui->m_gridGroupBox->setChecked(c);
|
||||
}
|
||||
|
||||
void GridPanel::setResetButtonVisible(bool v)
|
||||
{
|
||||
m_ui->m_resetButton->setVisible(v);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user