summaryrefslogtreecommitdiffstats
path: root/tools/designer/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/designer/src/lib')
-rw-r--r--tools/designer/src/lib/shared/iconselector.cpp5
-rw-r--r--tools/designer/src/lib/shared/iconselector_p.h4
-rw-r--r--tools/designer/src/lib/shared/qtresourceeditordialog.cpp5
-rw-r--r--tools/designer/src/lib/shared/qtresourceeditordialog_p.h3
-rw-r--r--tools/designer/src/lib/shared/qtresourcemodel.cpp2
-rw-r--r--tools/designer/src/lib/shared/qtresourcemodel_p.h5
-rw-r--r--tools/designer/src/lib/shared/qtresourceview.cpp4
-rw-r--r--tools/designer/src/lib/shared/qtresourceview_p.h4
-rw-r--r--tools/designer/src/lib/uilib/abstractformbuilder.cpp189
9 files changed, 185 insertions, 36 deletions
diff --git a/tools/designer/src/lib/shared/iconselector.cpp b/tools/designer/src/lib/shared/iconselector.cpp
index 8995126..b6d57a3 100644
--- a/tools/designer/src/lib/shared/iconselector.cpp
+++ b/tools/designer/src/lib/shared/iconselector.cpp
@@ -157,7 +157,6 @@ LanguageResourceDialog::LanguageResourceDialog(QDesignerResourceBrowserInterface
LanguageResourceDialog::~LanguageResourceDialog()
{
- delete d_ptr;
}
void LanguageResourceDialog::setCurrentPath(const QString &filePath)
@@ -427,9 +426,8 @@ void IconSelectorPrivate::slotResetAllActivated()
// ------------- IconSelector
IconSelector::IconSelector(QWidget *parent) :
- QWidget(parent)
+ QWidget(parent), d_ptr(new IconSelectorPrivate())
{
- d_ptr = new IconSelectorPrivate();
d_ptr->q_ptr = this;
d_ptr->m_stateComboBox = new QComboBox(this);
@@ -500,7 +498,6 @@ IconSelector::IconSelector(QWidget *parent) :
IconSelector::~IconSelector()
{
- delete d_ptr;
}
void IconSelector::setIcon(const PropertySheetIconValue &icon)
diff --git a/tools/designer/src/lib/shared/iconselector_p.h b/tools/designer/src/lib/shared/iconselector_p.h
index 0ba313c..b2cfb3c 100644
--- a/tools/designer/src/lib/shared/iconselector_p.h
+++ b/tools/designer/src/lib/shared/iconselector_p.h
@@ -87,7 +87,7 @@ public:
QString currentPath() const;
private:
- class LanguageResourceDialogPrivate *d_ptr;
+ QScopedPointer<class LanguageResourceDialogPrivate> d_ptr;
Q_DECLARE_PRIVATE(LanguageResourceDialog)
Q_DISABLE_COPY(LanguageResourceDialog)
Q_PRIVATE_SLOT(d_func(), void slotAccepted())
@@ -120,7 +120,7 @@ public:
signals:
void iconChanged(const PropertySheetIconValue &icon);
private:
- class IconSelectorPrivate *d_ptr;
+ QScopedPointer<class IconSelectorPrivate> d_ptr;
Q_DECLARE_PRIVATE(IconSelector)
Q_DISABLE_COPY(IconSelector)
diff --git a/tools/designer/src/lib/shared/qtresourceeditordialog.cpp b/tools/designer/src/lib/shared/qtresourceeditordialog.cpp
index 04411fa..e8f5ccd 100644
--- a/tools/designer/src/lib/shared/qtresourceeditordialog.cpp
+++ b/tools/designer/src/lib/shared/qtresourceeditordialog.cpp
@@ -1949,9 +1949,8 @@ bool QtResourceEditorDialogPrivate::saveQrcFile(const QtQrcFileData &qrcFileData
}
QtResourceEditorDialog::QtResourceEditorDialog(QDesignerFormEditorInterface *core, QDesignerDialogGuiInterface *dlgGui, QWidget *parent)
- : QDialog(parent)
+ : QDialog(parent), d_ptr(new QtResourceEditorDialogPrivate())
{
- d_ptr = new QtResourceEditorDialogPrivate();
d_ptr->q_ptr = this;
d_ptr->m_ui.setupUi(this);
d_ptr->m_qrcManager = new QtQrcManager(this);
@@ -2085,8 +2084,6 @@ QtResourceEditorDialog::~QtResourceEditorDialog()
settings->setValue(QLatin1String(SplitterPosition), d_ptr->m_ui.splitter->saveState());
settings->setValue(QLatin1String(Geometry), geometry());
settings->endGroup();
-
- delete d_ptr;
}
QtResourceModel *QtResourceEditorDialog::model() const
diff --git a/tools/designer/src/lib/shared/qtresourceeditordialog_p.h b/tools/designer/src/lib/shared/qtresourceeditordialog_p.h
index d67e6ab6..0676551 100644
--- a/tools/designer/src/lib/shared/qtresourceeditordialog_p.h
+++ b/tools/designer/src/lib/shared/qtresourceeditordialog_p.h
@@ -53,6 +53,7 @@
#ifndef QTRESOURCEEDITOR_H
#define QTRESOURCEEDITOR_H
+#include <QtCore/QScopedPointer>
#include <QtGui/QDialog>
QT_BEGIN_NAMESPACE
@@ -83,7 +84,7 @@ private:
QtResourceEditorDialog(QDesignerFormEditorInterface *core, QDesignerDialogGuiInterface *dlgGui, QWidget *parent = 0);
~QtResourceEditorDialog();
- class QtResourceEditorDialogPrivate *d_ptr;
+ QScopedPointer<class QtResourceEditorDialogPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtResourceEditorDialog)
Q_DISABLE_COPY(QtResourceEditorDialog)
diff --git a/tools/designer/src/lib/shared/qtresourcemodel.cpp b/tools/designer/src/lib/shared/qtresourcemodel.cpp
index fd3b7c6..9cad683 100644
--- a/tools/designer/src/lib/shared/qtresourcemodel.cpp
+++ b/tools/designer/src/lib/shared/qtresourcemodel.cpp
@@ -141,7 +141,6 @@ QtResourceSet::QtResourceSet(QtResourceModel *model) :
QtResourceSet::~QtResourceSet()
{
- delete d_ptr;
}
QStringList QtResourceSet::activeQrcPaths() const
@@ -489,7 +488,6 @@ QtResourceModel::~QtResourceModel()
while (it.hasNext())
removeResourceSet(it.next());
blockSignals(false);
- delete d_ptr;
}
QStringList QtResourceModel::loadedQrcFiles() const
diff --git a/tools/designer/src/lib/shared/qtresourcemodel_p.h b/tools/designer/src/lib/shared/qtresourcemodel_p.h
index 8212bba..0cee88a 100644
--- a/tools/designer/src/lib/shared/qtresourcemodel_p.h
+++ b/tools/designer/src/lib/shared/qtresourcemodel_p.h
@@ -56,6 +56,7 @@
#include "shared_global_p.h"
#include <QtCore/QMap>
#include <QtCore/QObject>
+#include <QtCore/QScopedPointer>
QT_BEGIN_NAMESPACE
@@ -87,7 +88,7 @@ private:
~QtResourceSet();
friend class QtResourceModel;
- class QtResourceSetPrivate *d_ptr;
+ QScopedPointer<class QtResourceSetPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtResourceSet)
Q_DISABLE_COPY(QtResourceSet)
};
@@ -132,7 +133,7 @@ signals:
private:
friend class QtResourceSet;
- class QtResourceModelPrivate *d_ptr;
+ QScopedPointer<class QtResourceModelPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtResourceModel)
Q_DISABLE_COPY(QtResourceModel)
diff --git a/tools/designer/src/lib/shared/qtresourceview.cpp b/tools/designer/src/lib/shared/qtresourceview.cpp
index df105fa..60e6a3f 100644
--- a/tools/designer/src/lib/shared/qtresourceview.cpp
+++ b/tools/designer/src/lib/shared/qtresourceview.cpp
@@ -640,8 +640,6 @@ QtResourceView::~QtResourceView()
{
if (!d_ptr->m_settingsKey.isEmpty())
d_ptr->saveSettings();
-
- delete d_ptr;
}
bool QtResourceView::event(QEvent *event)
@@ -878,8 +876,6 @@ QtResourceViewDialog::~QtResourceViewDialog()
settings->setValue(QLatin1String(Geometry), geometry());
settings->endGroup();
-
- delete d_ptr;
}
QString QtResourceViewDialog::selectedResource() const
diff --git a/tools/designer/src/lib/shared/qtresourceview_p.h b/tools/designer/src/lib/shared/qtresourceview_p.h
index 6d7bc3f..8bec69a 100644
--- a/tools/designer/src/lib/shared/qtresourceview_p.h
+++ b/tools/designer/src/lib/shared/qtresourceview_p.h
@@ -102,7 +102,7 @@ protected:
private:
- class QtResourceViewPrivate *d_ptr;
+ QScopedPointer<class QtResourceViewPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtResourceView)
Q_DISABLE_COPY(QtResourceView)
Q_PRIVATE_SLOT(d_func(), void slotResourceSetActivated(QtResourceSet *))
@@ -130,7 +130,7 @@ public:
void setResourceEditingEnabled(bool enable);
private:
- class QtResourceViewDialogPrivate *d_ptr;
+ QScopedPointer<class QtResourceViewDialogPrivate> d_ptr;
Q_DECLARE_PRIVATE(QtResourceViewDialog)
Q_DISABLE_COPY(QtResourceViewDialog)
Q_PRIVATE_SLOT(d_func(), void slotResourceSelected(const QString &))
diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp
index 2abe5da..8c0d379 100644
--- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp
+++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp
@@ -1698,6 +1698,24 @@ public:
};
template<class T>
+static void storeItemFlags(const T *item, QList<DomProperty*> *properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ static const Qt::ItemFlags defaultFlags = T().flags();
+ static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags");
+
+ if (item->flags() != defaultFlags) {
+ DomProperty *p = new DomProperty;
+ p->setAttributeName(strings.flagsAttribute);
+ p->setElementSet(QString::fromAscii(itemFlags_enum.valueToKeys(item->flags())));
+ properties->append(p);
+ }
+}
+
+#ifndef Q_CC_RVCT
+// RVCT does not accept static inline functions if one argument is templated type
+// For this reason all necessary function variants are explicityly written for it.
+template<class T>
static void storeItemProps(QAbstractFormBuilder *abstractFormBuilder, const T *item,
QList<DomProperty*> *properties)
{
@@ -1723,21 +1741,6 @@ static void storeItemProps(QAbstractFormBuilder *abstractFormBuilder, const T *i
}
template<class T>
-static void storeItemFlags(const T *item, QList<DomProperty*> *properties)
-{
- static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
- static const Qt::ItemFlags defaultFlags = T().flags();
- static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags");
-
- if (item->flags() != defaultFlags) {
- DomProperty *p = new DomProperty;
- p->setAttributeName(strings.flagsAttribute);
- p->setElementSet(QString::fromAscii(itemFlags_enum.valueToKeys(item->flags())));
- properties->append(p);
- }
-}
-
-template<class T>
static void storeItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, const T *item,
QList<DomProperty*> *properties)
{
@@ -1790,6 +1793,158 @@ static void loadItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, T *it
item->setFlags(enumKeysToValue<Qt::ItemFlags>(itemFlags_enum, p->elementSet().toAscii()));
}
+#else
+
+static void storeItemProps(QAbstractFormBuilder *abstractFormBuilder, const QTableWidgetItem *item,
+ QList<DomProperty*> *properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder);
+
+ DomProperty *p;
+ QVariant v;
+
+ foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles)
+ if ((p = formBuilder->saveText(it.second, item->data(it.first.second))))
+ properties->append(p);
+
+ foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles)
+ if ((v = item->data(it.first)).isValid() &&
+ (p = variantToDomProperty(abstractFormBuilder,
+ static_cast<const QMetaObject *>(&QAbstractFormBuilderGadget::staticMetaObject),
+ it.second, v)))
+ properties->append(p);
+
+ if ((p = formBuilder->saveResource(item->data(Qt::DecorationPropertyRole))))
+ properties->append(p);
+}
+
+static void storeItemProps(QAbstractFormBuilder *abstractFormBuilder, const QListWidgetItem *item,
+ QList<DomProperty*> *properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder);
+
+ DomProperty *p;
+ QVariant v;
+
+ foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles)
+ if ((p = formBuilder->saveText(it.second, item->data(it.first.second))))
+ properties->append(p);
+
+ foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles)
+ if ((v = item->data(it.first)).isValid() &&
+ (p = variantToDomProperty(abstractFormBuilder,
+ static_cast<const QMetaObject *>(&QAbstractFormBuilderGadget::staticMetaObject),
+ it.second, v)))
+ properties->append(p);
+
+ if ((p = formBuilder->saveResource(item->data(Qt::DecorationPropertyRole))))
+ properties->append(p);
+}
+
+static void storeItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, const QTableWidgetItem *item,
+ QList<DomProperty*> *properties)
+{
+ storeItemProps(abstractFormBuilder, item, properties);
+ storeItemFlags(item, properties);
+}
+
+static void storeItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, const QListWidgetItem *item,
+ QList<DomProperty*> *properties)
+{
+ storeItemProps(abstractFormBuilder, item, properties);
+ storeItemFlags(item, properties);
+}
+
+static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QTableWidgetItem *item,
+ const QHash<QString, DomProperty*> &properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder);
+
+ DomProperty *p;
+ QVariant v;
+
+ foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles)
+ if ((p = properties.value(it.second))) {
+ v = formBuilder->textBuilder()->loadText(p);
+ QVariant nativeValue = formBuilder->textBuilder()->toNativeValue(v);
+ item->setData(it.first.first, qVariantValue<QString>(nativeValue));
+ item->setData(it.first.second, v);
+ }
+
+ foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles)
+ if ((p = properties.value(it.second)) &&
+ (v = formBuilder->toVariant(&QAbstractFormBuilderGadget::staticMetaObject, p)).isValid())
+ item->setData(it.first, v);
+
+ if ((p = properties.value(strings.iconAttribute))) {
+ v = formBuilder->resourceBuilder()->loadResource(formBuilder->workingDirectory(), p);
+ QVariant nativeValue = formBuilder->resourceBuilder()->toNativeValue(v);
+ item->setIcon(qVariantValue<QIcon>(nativeValue));
+ item->setData(Qt::DecorationPropertyRole, v);
+ }
+}
+
+static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QListWidgetItem *item,
+ const QHash<QString, DomProperty*> &properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder);
+
+ DomProperty *p;
+ QVariant v;
+
+ foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles)
+ if ((p = properties.value(it.second))) {
+ v = formBuilder->textBuilder()->loadText(p);
+ QVariant nativeValue = formBuilder->textBuilder()->toNativeValue(v);
+ item->setData(it.first.first, qVariantValue<QString>(nativeValue));
+ item->setData(it.first.second, v);
+ }
+
+ foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles)
+ if ((p = properties.value(it.second)) &&
+ (v = formBuilder->toVariant(&QAbstractFormBuilderGadget::staticMetaObject, p)).isValid())
+ item->setData(it.first, v);
+
+ if ((p = properties.value(strings.iconAttribute))) {
+ v = formBuilder->resourceBuilder()->loadResource(formBuilder->workingDirectory(), p);
+ QVariant nativeValue = formBuilder->resourceBuilder()->toNativeValue(v);
+ item->setIcon(qVariantValue<QIcon>(nativeValue));
+ item->setData(Qt::DecorationPropertyRole, v);
+ }
+}
+
+static void loadItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, QTableWidgetItem *item,
+ const QHash<QString, DomProperty*> &properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags");
+
+ loadItemProps(abstractFormBuilder, item, properties);
+
+ DomProperty *p;
+ if ((p = properties.value(strings.flagsAttribute)) && p->kind() == DomProperty::Set)
+ item->setFlags(enumKeysToValue<Qt::ItemFlags>(itemFlags_enum, p->elementSet().toAscii()));
+}
+
+static void loadItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, QListWidgetItem *item,
+ const QHash<QString, DomProperty*> &properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags");
+
+ loadItemProps(abstractFormBuilder, item, properties);
+
+ DomProperty *p;
+ if ((p = properties.value(strings.flagsAttribute)) && p->kind() == DomProperty::Set)
+ item->setFlags(enumKeysToValue<Qt::ItemFlags>(itemFlags_enum, p->elementSet().toAscii()));
+}
+
+#endif
+
/*!
\internal
*/
@@ -2142,7 +2297,11 @@ void QAbstractFormBuilder::loadListWidgetExtraInfo(DomWidget *ui_widget, QListWi
foreach (DomItem *ui_item, ui_widget->elementItem()) {
const DomPropertyHash properties = propertyMap(ui_item->elementProperty());
QListWidgetItem *item = new QListWidgetItem(listWidget);
+#ifndef Q_CC_RVCT
loadItemPropsNFlags<QListWidgetItem>(this, item, properties);
+#else
+ loadItemPropsNFlags(this, item, properties);
+#endif
}
DomProperty *currentRow = propertyMap(ui_widget->elementProperty()).value(strings.currentRowProperty);