diff options
Diffstat (limited to 'tools/designer/src')
15 files changed, 191 insertions, 47 deletions
diff --git a/tools/designer/src/components/formeditor/brushmanagerproxy.cpp b/tools/designer/src/components/formeditor/brushmanagerproxy.cpp index 543e8c9..bb89cf6 100644 --- a/tools/designer/src/components/formeditor/brushmanagerproxy.cpp +++ b/tools/designer/src/components/formeditor/brushmanagerproxy.cpp @@ -146,14 +146,12 @@ QString BrushManagerProxyPrivate::uniqueBrushFileName(const QString &brushName) BrushManagerProxy::BrushManagerProxy(QDesignerFormEditorInterface *core, QObject *parent) - : QObject(parent) + : QObject(parent), d_ptr(new BrushManagerProxyPrivate(this, core)) { - d_ptr = new BrushManagerProxyPrivate(this, core); } BrushManagerProxy::~BrushManagerProxy() { - delete d_ptr; } void BrushManagerProxy::setBrushManager(QtBrushManager *manager) diff --git a/tools/designer/src/components/formeditor/brushmanagerproxy.h b/tools/designer/src/components/formeditor/brushmanagerproxy.h index 03bf56b..bfd95e5 100644 --- a/tools/designer/src/components/formeditor/brushmanagerproxy.h +++ b/tools/designer/src/components/formeditor/brushmanagerproxy.h @@ -63,7 +63,7 @@ public: void setBrushManager(QtBrushManager *manager); private: - BrushManagerProxyPrivate *d_ptr; + QScopedPointer<BrushManagerProxyPrivate> d_ptr; Q_DECLARE_PRIVATE(BrushManagerProxy) Q_DISABLE_COPY(BrushManagerProxy) Q_PRIVATE_SLOT(d_func(), void brushAdded(const QString &, const QBrush &)) diff --git a/tools/designer/src/components/formeditor/qtbrushmanager.cpp b/tools/designer/src/components/formeditor/qtbrushmanager.cpp index 5a5ab8b..20de1df 100644 --- a/tools/designer/src/components/formeditor/qtbrushmanager.cpp +++ b/tools/designer/src/components/formeditor/qtbrushmanager.cpp @@ -57,16 +57,13 @@ public: }; QtBrushManager::QtBrushManager(QObject *parent) - : QDesignerBrushManagerInterface(parent) + : QDesignerBrushManagerInterface(parent), d_ptr(new QtBrushManagerPrivate) { - d_ptr = new QtBrushManagerPrivate; d_ptr->q_ptr = this; - } QtBrushManager::~QtBrushManager() { - delete d_ptr; } QBrush QtBrushManager::brush(const QString &name) const diff --git a/tools/designer/src/components/formeditor/qtbrushmanager.h b/tools/designer/src/components/formeditor/qtbrushmanager.h index 1f3dc5b..4884c577 100644 --- a/tools/designer/src/components/formeditor/qtbrushmanager.h +++ b/tools/designer/src/components/formeditor/qtbrushmanager.h @@ -77,7 +77,7 @@ signals: void currentBrushChanged(const QString &name, const QBrush &brush); private: - QtBrushManagerPrivate *d_ptr; + QScopedPointer<QtBrushManagerPrivate> d_ptr; Q_DECLARE_PRIVATE(QtBrushManager) Q_DISABLE_COPY(QtBrushManager) }; diff --git a/tools/designer/src/lib/shared/iconselector.cpp b/tools/designer/src/lib/shared/iconselector.cpp index a6b37ed..b7ab216 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 9b650cd..9190d54 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 4b21eb3..0a0e3d7 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 157d181..6eac2b8 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 45e6c27..b4895d6 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 236e35a..e9f1c93 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 40be3e6..2fc43cd 100644 --- a/tools/designer/src/lib/shared/qtresourceview.cpp +++ b/tools/designer/src/lib/shared/qtresourceview.cpp @@ -636,8 +636,6 @@ QtResourceView::~QtResourceView() { if (!d_ptr->m_settingsKey.isEmpty()) d_ptr->saveSettings(); - - delete d_ptr; } bool QtResourceView::event(QEvent *event) @@ -874,8 +872,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 fb8fb83..0484686 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 65ea375..5a6e1f5 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); diff --git a/tools/designer/src/uitools/quiloader.cpp b/tools/designer/src/uitools/quiloader.cpp index 5387c2d..83d3089 100644 --- a/tools/designer/src/uitools/quiloader.cpp +++ b/tools/designer/src/uitools/quiloader.cpp @@ -647,7 +647,6 @@ QUiLoader::QUiLoader(QObject *parent) */ QUiLoader::~QUiLoader() { - delete d_ptr; } /*! diff --git a/tools/designer/src/uitools/quiloader.h b/tools/designer/src/uitools/quiloader.h index dd3d32a..40b5010 100644 --- a/tools/designer/src/uitools/quiloader.h +++ b/tools/designer/src/uitools/quiloader.h @@ -43,6 +43,7 @@ #define QUILOADER_H #include <QtCore/QObject> +#include <QtCore/QScopedPointer> QT_BEGIN_HEADER @@ -90,7 +91,7 @@ public: bool isTranslationEnabled() const; private: - QUiLoaderPrivate *d_ptr; + QScopedPointer<QUiLoaderPrivate> d_ptr; Q_DECLARE_PRIVATE(QUiLoader) Q_DISABLE_COPY(QUiLoader) }; |