diff options
Diffstat (limited to 'src/shared/qtpropertybrowser')
17 files changed, 1405 insertions, 2054 deletions
diff --git a/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp b/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp index edef8564e..9b1a1ff5a 100644 --- a/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp +++ b/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.cpp @@ -1,50 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qtbuttonpropertybrowser.h" -#include <QtCore/QSet> + +#include <QtCore/QHash> #include <QtWidgets/QGridLayout> #include <QtWidgets/QLabel> -#include <QtCore/QTimer> -#include <QtCore/QMap> #include <QtWidgets/QToolButton> -#include <QtWidgets/QStyle> QT_BEGIN_NAMESPACE @@ -88,10 +50,10 @@ private: void setExpanded(WidgetItem *item, bool expanded); QToolButton *createButton(QWidget *panret = 0) const; - QMap<QtBrowserItem *, WidgetItem *> m_indexToItem; - QMap<WidgetItem *, QtBrowserItem *> m_itemToIndex; - QMap<QWidget *, WidgetItem *> m_widgetToItem; - QMap<QObject *, WidgetItem *> m_buttonToItem; + QHash<QtBrowserItem *, WidgetItem *> m_indexToItem; + QHash<WidgetItem *, QtBrowserItem *> m_itemToIndex; + QHash<QWidget *, WidgetItem *> m_widgetToItem; + QHash<QObject *, WidgetItem *> m_buttonToItem; QGridLayout *m_mainLayout; QList<WidgetItem *> m_children; QList<WidgetItem *> m_recreateQueue; @@ -99,7 +61,7 @@ private: QToolButton *QtButtonPropertyBrowserPrivate::createButton(QWidget *parent) const { - QToolButton *button = new QToolButton(parent); + auto *button = new QToolButton(parent); button->setCheckable(true); button->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); @@ -123,7 +85,7 @@ int QtButtonPropertyBrowserPrivate::gridRow(WidgetItem *item) const siblings = m_children; int row = 0; - for (WidgetItem *sibling : qAsConst(siblings)) { + for (WidgetItem *sibling : std::as_const(siblings)) { if (sibling == item) return row; row += gridSpan(sibling); @@ -142,25 +104,24 @@ void QtButtonPropertyBrowserPrivate::init(QWidget *parent) { m_mainLayout = new QGridLayout(); parent->setLayout(m_mainLayout); - QLayoutItem *item = new QSpacerItem(0, 0, - QSizePolicy::Fixed, QSizePolicy::Expanding); + auto *item = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding); m_mainLayout->addItem(item, 0, 0); } void QtButtonPropertyBrowserPrivate::slotEditorDestroyed() { - QWidget *editor = qobject_cast<QWidget *>(q_ptr->sender()); + auto *editor = qobject_cast<QWidget *>(q_ptr->sender()); if (!editor) return; if (!m_widgetToItem.contains(editor)) return; - m_widgetToItem[editor]->widget = 0; + m_widgetToItem[editor]->widget = nullptr; m_widgetToItem.remove(editor); } void QtButtonPropertyBrowserPrivate::slotUpdate() { - for (WidgetItem *item : qAsConst(m_recreateQueue)) { + for (WidgetItem *item : std::as_const(m_recreateQueue)) { WidgetItem *parent = item->parent; QWidget *w = nullptr; QGridLayout *l = nullptr; @@ -232,7 +193,7 @@ void QtButtonPropertyBrowserPrivate::slotToggled(bool checked) void QtButtonPropertyBrowserPrivate::updateLater() { - QTimer::singleShot(0, q_ptr, SLOT(slotUpdate())); + QMetaObject::invokeMethod(q_ptr, [this] { slotUpdate(); }, Qt::QueuedConnection); } void QtButtonPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex) @@ -240,7 +201,7 @@ void QtButtonPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBr WidgetItem *afterItem = m_indexToItem.value(afterIndex); WidgetItem *parentItem = m_indexToItem.value(index->parent()); - WidgetItem *newItem = new WidgetItem(); + auto *newItem = new WidgetItem(); newItem->parent = parentItem; QGridLayout *layout = nullptr; @@ -274,13 +235,14 @@ void QtButtonPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBr } else { l = m_mainLayout; } - QFrame *container = new QFrame(); + auto *container = new QFrame(); container->setFrameShape(QFrame::Panel); container->setFrameShadow(QFrame::Raised); parentItem->container = container; parentItem->button = createButton(); m_buttonToItem[parentItem->button] = parentItem; - q_ptr->connect(parentItem->button, SIGNAL(toggled(bool)), q_ptr, SLOT(slotToggled(bool))); + q_ptr->connect(parentItem->button, &QAbstractButton::toggled, + q_ptr, [this](bool checked) { slotToggled(checked); }); parentItem->layout = new QGridLayout(); container->setLayout(parentItem->layout); if (parentItem->label) { @@ -302,7 +264,8 @@ void QtButtonPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBr newItem->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); newItem->widget = createEditor(index->property(), parentWidget); if (newItem->widget) { - QObject::connect(newItem->widget, SIGNAL(destroyed()), q_ptr, SLOT(slotEditorDestroyed())); + QObject::connect(newItem->widget, &QWidget::destroyed, + q_ptr, [this] { slotEditorDestroyed(); }); m_widgetToItem[newItem->widget] = newItem; } else if (index->property()->hasValue()) { newItem->widgetLabel = new QLabel(parentWidget); @@ -360,7 +323,7 @@ void QtButtonPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) removeRow(m_mainLayout, row); if (colSpan > 1) removeRow(m_mainLayout, row); - } else if (parentItem->children.count() != 0) { + } else if (parentItem->children.size() != 0) { removeRow(parentItem->layout, row); if (colSpan > 1) removeRow(parentItem->layout, row); @@ -397,7 +360,7 @@ void QtButtonPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) void QtButtonPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) const { - QMap<QLayoutItem *, QRect> itemToPos; + QHash<QLayoutItem *, QRect> itemToPos; int idx = 0; while (idx < layout->count()) { int r, c, rs, cs; @@ -417,7 +380,7 @@ void QtButtonPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) con void QtButtonPropertyBrowserPrivate::removeRow(QGridLayout *layout, int row) const { - QMap<QLayoutItem *, QRect> itemToPos; + QHash<QLayoutItem *, QRect> itemToPos; int idx = 0; while (idx < layout->count()) { int r, c, rs, cs; @@ -553,8 +516,7 @@ QtButtonPropertyBrowser::QtButtonPropertyBrowser(QWidget *parent) */ QtButtonPropertyBrowser::~QtButtonPropertyBrowser() { - const QMap<QtButtonPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator icend = d_ptr->m_itemToIndex.constEnd(); - for (QMap<QtButtonPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator it = d_ptr->m_itemToIndex.constBegin(); it != icend; ++it) + for (auto it = d_ptr->m_itemToIndex.cbegin(), icend = d_ptr->m_itemToIndex.cend(); it != icend; ++it) delete it.key(); } diff --git a/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.h b/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.h index f76d476c5..2a02405aa 100644 --- a/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.h +++ b/src/shared/qtpropertybrowser/qtbuttonpropertybrowser.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTBUTTONPROPERTYBROWSER_H #define QTBUTTONPROPERTYBROWSER_H @@ -50,7 +14,6 @@ class QtButtonPropertyBrowser : public QtAbstractPropertyBrowser { Q_OBJECT public: - QtButtonPropertyBrowser(QWidget *parent = 0); ~QtButtonPropertyBrowser(); @@ -58,7 +21,6 @@ public: bool isExpanded(QtBrowserItem *item) const; Q_SIGNALS: - void collapsed(QtBrowserItem *item); void expanded(QtBrowserItem *item); @@ -68,14 +30,9 @@ protected: void itemChanged(QtBrowserItem *item) override; private: - QScopedPointer<QtButtonPropertyBrowserPrivate> d_ptr; Q_DECLARE_PRIVATE(QtButtonPropertyBrowser) Q_DISABLE_COPY_MOVE(QtButtonPropertyBrowser) - Q_PRIVATE_SLOT(d_func(), void slotUpdate()) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed()) - Q_PRIVATE_SLOT(d_func(), void slotToggled(bool)) - }; QT_END_NAMESPACE diff --git a/src/shared/qtpropertybrowser/qteditorfactory.cpp b/src/shared/qtpropertybrowser/qteditorfactory.cpp index 31211333e..1f51f2ba7 100644 --- a/src/shared/qtpropertybrowser/qteditorfactory.cpp +++ b/src/shared/qtpropertybrowser/qteditorfactory.cpp @@ -1,63 +1,28 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qteditorfactory.h" #include "qtpropertybrowserutils_p.h" -#include <QtWidgets/QSpinBox> -#include <QtWidgets/QScrollBar> -#include <QtWidgets/QComboBox> -#include <QtWidgets/QAbstractItemView> -#include <QtWidgets/QLineEdit> -#include <QtWidgets/QDateTimeEdit> -#include <QtWidgets/QHBoxLayout> -#include <QtWidgets/QMenu> + +#include <QtCore/QHash> +#include <QtCore/QRegularExpression> #include <QtGui/QKeyEvent> #include <QtGui/QRegularExpressionValidator> +#include <QtWidgets/QAbstractItemView> #include <QtWidgets/QApplication> -#include <QtWidgets/QLabel> -#include <QtWidgets/QToolButton> +#include <QtWidgets/QBoxLayout> #include <QtWidgets/QColorDialog> +#include <QtWidgets/QComboBox> +#include <QtWidgets/QDateTimeEdit> #include <QtWidgets/QFontDialog> -#include <QtWidgets/QSpacerItem> #include <QtWidgets/QKeySequenceEdit> -#include <QtCore/QMap> -#include <QtCore/QRegularExpression> +#include <QtWidgets/QLabel> +#include <QtWidgets/QLineEdit> +#include <QtWidgets/QMenu> +#include <QtWidgets/QScrollBar> +#include <QtWidgets/QSpacerItem> +#include <QtWidgets/QSpinBox> +#include <QtWidgets/QToolButton> #if defined(Q_CC_MSVC) # pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */ @@ -85,9 +50,9 @@ class EditorFactoryPrivate { public: - typedef QList<Editor *> EditorList; - typedef QMap<QtProperty *, EditorList> PropertyToEditorListMap; - typedef QMap<Editor *, QtProperty *> EditorToPropertyMap; + using EditorList = QList<Editor *>; + using PropertyToEditorListMap = QHash<QtProperty *, EditorList>; + using EditorToPropertyMap = QHash<Editor *, QtProperty *>; Editor *createEditor(QtProperty *property, QWidget *parent); void initializeEditor(QtProperty *property, Editor *e); @@ -100,7 +65,7 @@ public: template <class Editor> Editor *EditorFactoryPrivate<Editor>::createEditor(QtProperty *property, QWidget *parent) { - Editor *editor = new Editor(parent); + auto *editor = new Editor(parent); initializeEditor(property, editor); return editor; } @@ -108,7 +73,7 @@ Editor *EditorFactoryPrivate<Editor>::createEditor(QtProperty *property, QWidget template <class Editor> void EditorFactoryPrivate<Editor>::initializeEditor(QtProperty *property, Editor *editor) { - typename PropertyToEditorListMap::iterator it = m_createdEditors.find(property); + auto it = m_createdEditors.find(property); if (it == m_createdEditors.end()) it = m_createdEditors.insert(property, EditorList()); it.value().append(editor); @@ -118,12 +83,12 @@ void EditorFactoryPrivate<Editor>::initializeEditor(QtProperty *property, Editor template <class Editor> void EditorFactoryPrivate<Editor>::slotEditorDestroyed(QObject *object) { - const typename EditorToPropertyMap::iterator ecend = m_editorToProperty.end(); - for (typename EditorToPropertyMap::iterator itEditor = m_editorToProperty.begin(); itEditor != ecend; ++itEditor) { + const auto ecend = m_editorToProperty.end(); + for (auto itEditor = m_editorToProperty.begin(); itEditor != ecend; ++itEditor) { if (itEditor.key() == object) { Editor *editor = itEditor.key(); QtProperty *property = itEditor.value(); - const typename PropertyToEditorListMap::iterator pit = m_createdEditors.find(property); + const auto pit = m_createdEditors.find(property); if (pit != m_createdEditors.end()) { pit.value().removeAll(editor); if (pit.value().isEmpty()) @@ -196,8 +161,7 @@ void QtSpinBoxFactoryPrivate::slotSingleStepChanged(QtProperty *property, int st void QtSpinBoxFactoryPrivate::slotSetValue(int value) { QObject *object = q_ptr->sender(); - const QMap<QSpinBox *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QSpinBox *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) { + for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor) { if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtIntPropertyManager *manager = q_ptr->propertyManager(property); @@ -246,12 +210,15 @@ QtSpinBoxFactory::~QtSpinBoxFactory() */ void QtSpinBoxFactory::connectPropertyManager(QtIntPropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotPropertyChanged(QtProperty*,int))); - connect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)), - this, SLOT(slotRangeChanged(QtProperty*,int,int))); - connect(manager, SIGNAL(singleStepChanged(QtProperty*,int)), - this, SLOT(slotSingleStepChanged(QtProperty*,int))); + connect(manager, &QtIntPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotPropertyChanged(property, value); }); + connect(manager, &QtIntPropertyManager::rangeChanged, + this, [this](QtProperty *property, int min, int max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(manager, &QtIntPropertyManager::singleStepChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotSingleStepChanged(property, value); }); } /*! @@ -268,9 +235,10 @@ QWidget *QtSpinBoxFactory::createEditor(QtIntPropertyManager *manager, QtPropert editor->setValue(manager->value(property)); editor->setKeyboardTracking(false); - connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QSpinBox::valueChanged, + this, [this](int value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -281,12 +249,9 @@ QWidget *QtSpinBoxFactory::createEditor(QtIntPropertyManager *manager, QtPropert */ void QtSpinBoxFactory::disconnectPropertyManager(QtIntPropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotPropertyChanged(QtProperty*,int))); - disconnect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)), - this, SLOT(slotRangeChanged(QtProperty*,int,int))); - disconnect(manager, SIGNAL(singleStepChanged(QtProperty*,int)), - this, SLOT(slotSingleStepChanged(QtProperty*,int))); + disconnect(manager, &QtIntPropertyManager::valueChanged, this, nullptr); + disconnect(manager, &QtIntPropertyManager::rangeChanged, this, nullptr); + disconnect(manager, &QtIntPropertyManager::singleStepChanged, this, nullptr); } // QtSliderFactory @@ -347,8 +312,7 @@ void QtSliderFactoryPrivate::slotSingleStepChanged(QtProperty *property, int ste void QtSliderFactoryPrivate::slotSetValue(int value) { QObject *object = q_ptr->sender(); - const QMap<QSlider *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QSlider *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor ) { + for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor ) { if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtIntPropertyManager *manager = q_ptr->propertyManager(property); @@ -397,12 +361,15 @@ QtSliderFactory::~QtSliderFactory() */ void QtSliderFactory::connectPropertyManager(QtIntPropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotPropertyChanged(QtProperty*,int))); - connect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)), - this, SLOT(slotRangeChanged(QtProperty*,int,int))); - connect(manager, SIGNAL(singleStepChanged(QtProperty*,int)), - this, SLOT(slotSingleStepChanged(QtProperty*,int))); + connect(manager, &QtIntPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotPropertyChanged(property, value); }); + connect(manager, &QtIntPropertyManager::rangeChanged, + this, [this](QtProperty *property, int min, int max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(manager, &QtIntPropertyManager::singleStepChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotSingleStepChanged(property, value); }); } /*! @@ -413,15 +380,16 @@ void QtSliderFactory::connectPropertyManager(QtIntPropertyManager *manager) QWidget *QtSliderFactory::createEditor(QtIntPropertyManager *manager, QtProperty *property, QWidget *parent) { - QSlider *editor = new QSlider(Qt::Horizontal, parent); + auto *editor = new QSlider(Qt::Horizontal, parent); d_ptr->initializeEditor(property, editor); editor->setSingleStep(manager->singleStep(property)); editor->setRange(manager->minimum(property), manager->maximum(property)); editor->setValue(manager->value(property)); - connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QSlider::valueChanged, + this, [this](int value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -432,12 +400,9 @@ QWidget *QtSliderFactory::createEditor(QtIntPropertyManager *manager, QtProperty */ void QtSliderFactory::disconnectPropertyManager(QtIntPropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotPropertyChanged(QtProperty*,int))); - disconnect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)), - this, SLOT(slotRangeChanged(QtProperty*,int,int))); - disconnect(manager, SIGNAL(singleStepChanged(QtProperty*,int)), - this, SLOT(slotSingleStepChanged(QtProperty*,int))); + disconnect(manager, &QtIntPropertyManager::valueChanged, this, nullptr); + disconnect(manager, &QtIntPropertyManager::rangeChanged, this, nullptr); + disconnect(manager, &QtIntPropertyManager::singleStepChanged, this, nullptr); } // QtSliderFactory @@ -499,8 +464,7 @@ void QtScrollBarFactoryPrivate::slotSingleStepChanged(QtProperty *property, int void QtScrollBarFactoryPrivate::slotSetValue(int value) { QObject *object = q_ptr->sender(); - const QMap<QScrollBar *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QScrollBar *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor) if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtIntPropertyManager *manager = q_ptr->propertyManager(property); @@ -548,12 +512,15 @@ QtScrollBarFactory::~QtScrollBarFactory() */ void QtScrollBarFactory::connectPropertyManager(QtIntPropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotPropertyChanged(QtProperty*,int))); - connect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)), - this, SLOT(slotRangeChanged(QtProperty*,int,int))); - connect(manager, SIGNAL(singleStepChanged(QtProperty*,int)), - this, SLOT(slotSingleStepChanged(QtProperty*,int))); + connect(manager, &QtIntPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotPropertyChanged(property, value); }); + connect(manager, &QtIntPropertyManager::rangeChanged, + this, [this](QtProperty *property, int min, int max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(manager, &QtIntPropertyManager::singleStepChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotSingleStepChanged(property, value); }); } /*! @@ -564,14 +531,15 @@ void QtScrollBarFactory::connectPropertyManager(QtIntPropertyManager *manager) QWidget *QtScrollBarFactory::createEditor(QtIntPropertyManager *manager, QtProperty *property, QWidget *parent) { - QScrollBar *editor = new QScrollBar(Qt::Horizontal, parent); + auto *editor = new QScrollBar(Qt::Horizontal, parent); d_ptr->initializeEditor(property, editor); editor->setSingleStep(manager->singleStep(property)); editor->setRange(manager->minimum(property), manager->maximum(property)); editor->setValue(manager->value(property)); - connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QScrollBar::valueChanged, + this, [this](int value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -582,12 +550,9 @@ QWidget *QtScrollBarFactory::createEditor(QtIntPropertyManager *manager, QtPrope */ void QtScrollBarFactory::disconnectPropertyManager(QtIntPropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotPropertyChanged(QtProperty*,int))); - disconnect(manager, SIGNAL(rangeChanged(QtProperty*,int,int)), - this, SLOT(slotRangeChanged(QtProperty*,int,int))); - disconnect(manager, SIGNAL(singleStepChanged(QtProperty*,int)), - this, SLOT(slotSingleStepChanged(QtProperty*,int))); + disconnect(manager, &QtIntPropertyManager::valueChanged, this, nullptr); + disconnect(manager, &QtIntPropertyManager::rangeChanged, this, nullptr); + disconnect(manager, &QtIntPropertyManager::singleStepChanged, this, nullptr); } // QtCheckBoxFactory @@ -618,8 +583,7 @@ void QtCheckBoxFactoryPrivate::slotSetValue(bool value) { QObject *object = q_ptr->sender(); - const QMap<QtBoolEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QtBoolEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor) if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtBoolPropertyManager *manager = q_ptr->propertyManager(property); @@ -667,8 +631,9 @@ QtCheckBoxFactory::~QtCheckBoxFactory() */ void QtCheckBoxFactory::connectPropertyManager(QtBoolPropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,bool)), - this, SLOT(slotPropertyChanged(QtProperty*,bool))); + connect(manager, &QtBoolPropertyManager::valueChanged, + this, [this](QtProperty *property, bool value) + { d_ptr->slotPropertyChanged(property, value); }); } /*! @@ -682,9 +647,10 @@ QWidget *QtCheckBoxFactory::createEditor(QtBoolPropertyManager *manager, QtPrope QtBoolEdit *editor = d_ptr->createEditor(property, parent); editor->setChecked(manager->value(property)); - connect(editor, SIGNAL(toggled(bool)), this, SLOT(slotSetValue(bool))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QtBoolEdit::toggled, + this, [this](bool value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -695,8 +661,7 @@ QWidget *QtCheckBoxFactory::createEditor(QtBoolPropertyManager *manager, QtPrope */ void QtCheckBoxFactory::disconnectPropertyManager(QtBoolPropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,bool)), - this, SLOT(slotPropertyChanged(QtProperty*,bool))); + disconnect(manager, &QtBoolPropertyManager::valueChanged, this, nullptr); } // QtDoubleSpinBoxFactory @@ -785,8 +750,7 @@ void QtDoubleSpinBoxFactoryPrivate::slotDecimalsChanged(QtProperty *property, in void QtDoubleSpinBoxFactoryPrivate::slotSetValue(double value) { QObject *object = q_ptr->sender(); - const QMap<QDoubleSpinBox *, QtProperty *>::ConstIterator itcend = m_editorToProperty.constEnd(); - for (QMap<QDoubleSpinBox *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != itcend; ++itEditor) { + for (auto itEditor = m_editorToProperty.cbegin(), itcend = m_editorToProperty.cend(); itEditor != itcend; ++itEditor) { if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtDoublePropertyManager *manager = q_ptr->propertyManager(property); @@ -834,14 +798,18 @@ QtDoubleSpinBoxFactory::~QtDoubleSpinBoxFactory() */ void QtDoubleSpinBoxFactory::connectPropertyManager(QtDoublePropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,double)), - this, SLOT(slotPropertyChanged(QtProperty*,double))); - connect(manager, SIGNAL(rangeChanged(QtProperty*,double,double)), - this, SLOT(slotRangeChanged(QtProperty*,double,double))); - connect(manager, SIGNAL(singleStepChanged(QtProperty*,double)), - this, SLOT(slotSingleStepChanged(QtProperty*,double))); - connect(manager, SIGNAL(decimalsChanged(QtProperty*,int)), - this, SLOT(slotDecimalsChanged(QtProperty*,int))); + connect(manager, &QtDoublePropertyManager::valueChanged, + this, [this](QtProperty *property, double value) + { d_ptr->slotPropertyChanged(property, value); }); + connect(manager, &QtDoublePropertyManager::rangeChanged, + this, [this](QtProperty *property, double min, double max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(manager, &QtDoublePropertyManager::singleStepChanged, + this, [this](QtProperty *property, double value) + { d_ptr->slotSingleStepChanged(property, value); }); + connect(manager, &QtDoublePropertyManager::decimalsChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotDecimalsChanged(property, value); }); } /*! @@ -859,9 +827,10 @@ QWidget *QtDoubleSpinBoxFactory::createEditor(QtDoublePropertyManager *manager, editor->setValue(manager->value(property)); editor->setKeyboardTracking(false); - connect(editor, SIGNAL(valueChanged(double)), this, SLOT(slotSetValue(double))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QDoubleSpinBox::valueChanged, + this, [this](double value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -872,14 +841,10 @@ QWidget *QtDoubleSpinBoxFactory::createEditor(QtDoublePropertyManager *manager, */ void QtDoubleSpinBoxFactory::disconnectPropertyManager(QtDoublePropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,double)), - this, SLOT(slotPropertyChanged(QtProperty*,double))); - disconnect(manager, SIGNAL(rangeChanged(QtProperty*,double,double)), - this, SLOT(slotRangeChanged(QtProperty*,double,double))); - disconnect(manager, SIGNAL(singleStepChanged(QtProperty*,double)), - this, SLOT(slotSingleStepChanged(QtProperty*,double))); - disconnect(manager, SIGNAL(decimalsChanged(QtProperty*,int)), - this, SLOT(slotDecimalsChanged(QtProperty*,int))); + disconnect(manager, &QtDoublePropertyManager::valueChanged, this, nullptr); + disconnect(manager, &QtDoublePropertyManager::rangeChanged, this, nullptr); + disconnect(manager, &QtDoublePropertyManager::singleStepChanged, this, nullptr); + disconnect(manager, &QtDoublePropertyManager::decimalsChanged, this, nullptr); } // QtLineEditFactory @@ -936,8 +901,7 @@ void QtLineEditFactoryPrivate::slotRegExpChanged(QtProperty *property, void QtLineEditFactoryPrivate::slotSetValue(const QString &value) { QObject *object = q_ptr->sender(); - const QMap<QLineEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QLineEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor) if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtStringPropertyManager *manager = q_ptr->propertyManager(property); @@ -985,10 +949,12 @@ QtLineEditFactory::~QtLineEditFactory() */ void QtLineEditFactory::connectPropertyManager(QtStringPropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,QString)), - this, SLOT(slotPropertyChanged(QtProperty*,QString))); - connect(manager, SIGNAL(regExpChanged(QtProperty*,QRegularExpression)), - this, SLOT(slotRegExpChanged(QtProperty*,QRegularExpression))); + connect(manager, &QtStringPropertyManager::valueChanged, + this, [this](QtProperty *property, const QString &value) + { d_ptr->slotPropertyChanged(property, value); }); + connect(manager, &QtStringPropertyManager::regExpChanged, + this, [this](QtProperty *property, const QRegularExpression &value) + { d_ptr->slotRegExpChanged(property, value); }); } /*! @@ -999,19 +965,18 @@ void QtLineEditFactory::connectPropertyManager(QtStringPropertyManager *manager) QWidget *QtLineEditFactory::createEditor(QtStringPropertyManager *manager, QtProperty *property, QWidget *parent) { - QLineEdit *editor = d_ptr->createEditor(property, parent); QRegularExpression regExp = manager->regExp(property); if (regExp.isValid() && !regExp.pattern().isEmpty()) { - QValidator *validator = new QRegularExpressionValidator(regExp, editor); + auto *validator = new QRegularExpressionValidator(regExp, editor); editor->setValidator(validator); } editor->setText(manager->value(property)); - connect(editor, SIGNAL(textEdited(QString)), - this, SLOT(slotSetValue(QString))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QLineEdit::textEdited, + this, [this](const QString &value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -1022,10 +987,8 @@ QWidget *QtLineEditFactory::createEditor(QtStringPropertyManager *manager, */ void QtLineEditFactory::disconnectPropertyManager(QtStringPropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,QString)), - this, SLOT(slotPropertyChanged(QtProperty*,QString))); - disconnect(manager, SIGNAL(regExpChanged(QtProperty*,QRegularExpression)), - this, SLOT(slotRegExpChanged(QtProperty*,QRegularExpression))); + disconnect(manager, &QtStringPropertyManager::valueChanged, this, nullptr); + disconnect(manager, &QtStringPropertyManager::regExpChanged, this, nullptr); } // QtDateEditFactory @@ -1074,8 +1037,7 @@ void QtDateEditFactoryPrivate::slotRangeChanged(QtProperty *property, QDate min, void QtDateEditFactoryPrivate::slotSetValue(QDate value) { QObject *object = q_ptr->sender(); - const QMap<QDateEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QDateEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor) if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtDatePropertyManager *manager = q_ptr->propertyManager(property); @@ -1123,10 +1085,12 @@ QtDateEditFactory::~QtDateEditFactory() */ void QtDateEditFactory::connectPropertyManager(QtDatePropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,QDate)), - this, SLOT(slotPropertyChanged(QtProperty*,QDate))); - connect(manager, SIGNAL(rangeChanged(QtProperty*,QDate,QDate)), - this, SLOT(slotRangeChanged(QtProperty*,QDate,QDate))); + connect(manager, &QtDatePropertyManager::valueChanged, + this, [this](QtProperty *property, const QDate &value) + { d_ptr->slotPropertyChanged(property, value); }); + connect(manager, &QtDatePropertyManager::rangeChanged, + this, [this](QtProperty *property, const QDate &min, const QDate &max) + { d_ptr->slotRangeChanged(property, min, max); }); } /*! @@ -1143,10 +1107,10 @@ QWidget *QtDateEditFactory::createEditor(QtDatePropertyManager *manager, QtPrope editor->setDateRange(manager->minimum(property), manager->maximum(property)); editor->setDate(manager->value(property)); - connect(editor, SIGNAL(dateChanged(QDate)), - this, SLOT(slotSetValue(QDate))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QDateEdit::dateChanged, + this, [this](const QDate &value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -1157,10 +1121,8 @@ QWidget *QtDateEditFactory::createEditor(QtDatePropertyManager *manager, QtPrope */ void QtDateEditFactory::disconnectPropertyManager(QtDatePropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,QDate)), - this, SLOT(slotPropertyChanged(QtProperty*,QDate))); - disconnect(manager, SIGNAL(rangeChanged(QtProperty*,QDate,QDate)), - this, SLOT(slotRangeChanged(QtProperty*,QDate,QDate))); + disconnect(manager, &QtDatePropertyManager::valueChanged, this, nullptr); + disconnect(manager, &QtDatePropertyManager::rangeChanged, this, nullptr); } // QtTimeEditFactory @@ -1190,8 +1152,7 @@ void QtTimeEditFactoryPrivate::slotPropertyChanged(QtProperty *property, QTime v void QtTimeEditFactoryPrivate::slotSetValue(QTime value) { QObject *object = q_ptr->sender(); - const QMap<QTimeEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QTimeEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor) if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtTimePropertyManager *manager = q_ptr->propertyManager(property); @@ -1239,8 +1200,9 @@ QtTimeEditFactory::~QtTimeEditFactory() */ void QtTimeEditFactory::connectPropertyManager(QtTimePropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,QTime)), - this, SLOT(slotPropertyChanged(QtProperty*,QTime))); + connect(manager, &QtTimePropertyManager::valueChanged, + this, [this](QtProperty *property, const QTime &value) + { d_ptr->slotPropertyChanged(property, value); }); } /*! @@ -1255,10 +1217,10 @@ QWidget *QtTimeEditFactory::createEditor(QtTimePropertyManager *manager, QtPrope editor->setDisplayFormat(QtPropertyBrowserUtils::timeFormat()); editor->setTime(manager->value(property)); - connect(editor, SIGNAL(timeChanged(QTime)), - this, SLOT(slotSetValue(QTime))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QTimeEdit::timeChanged, + this, [this](const QTime &value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -1269,8 +1231,7 @@ QWidget *QtTimeEditFactory::createEditor(QtTimePropertyManager *manager, QtPrope */ void QtTimeEditFactory::disconnectPropertyManager(QtTimePropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,QTime)), - this, SLOT(slotPropertyChanged(QtProperty*,QTime))); + disconnect(manager, &QtTimePropertyManager::valueChanged, this, nullptr); } // QtDateTimeEditFactory @@ -1303,8 +1264,7 @@ void QtDateTimeEditFactoryPrivate::slotPropertyChanged(QtProperty *property, void QtDateTimeEditFactoryPrivate::slotSetValue(const QDateTime &value) { QObject *object = q_ptr->sender(); - const QMap<QDateTimeEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QDateTimeEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor) if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtDateTimePropertyManager *manager = q_ptr->propertyManager(property); @@ -1352,8 +1312,9 @@ QtDateTimeEditFactory::~QtDateTimeEditFactory() */ void QtDateTimeEditFactory::connectPropertyManager(QtDateTimePropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,QDateTime)), - this, SLOT(slotPropertyChanged(QtProperty*,QDateTime))); + connect(manager, &QtDateTimePropertyManager::valueChanged, + this, [this](QtProperty *property, const QDateTime &value) + { d_ptr->slotPropertyChanged(property, value); }); } /*! @@ -1368,10 +1329,10 @@ QWidget *QtDateTimeEditFactory::createEditor(QtDateTimePropertyManager *manager, editor->setDisplayFormat(QtPropertyBrowserUtils::dateTimeFormat()); editor->setDateTime(manager->value(property)); - connect(editor, SIGNAL(dateTimeChanged(QDateTime)), - this, SLOT(slotSetValue(QDateTime))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QDateTimeEdit::dateTimeChanged, + this, [this](const QDateTime &value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -1382,8 +1343,7 @@ QWidget *QtDateTimeEditFactory::createEditor(QtDateTimePropertyManager *manager, */ void QtDateTimeEditFactory::disconnectPropertyManager(QtDateTimePropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,QDateTime)), - this, SLOT(slotPropertyChanged(QtProperty*,QDateTime))); + disconnect(manager, &QtDateTimePropertyManager::valueChanged, this, nullptr); } // QtKeySequenceEditorFactory @@ -1415,8 +1375,7 @@ void QtKeySequenceEditorFactoryPrivate::slotPropertyChanged(QtProperty *property void QtKeySequenceEditorFactoryPrivate::slotSetValue(const QKeySequence &value) { QObject *object = q_ptr->sender(); - const QMap<QKeySequenceEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QKeySequenceEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor) if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtKeySequencePropertyManager *manager = q_ptr->propertyManager(property); @@ -1464,8 +1423,9 @@ QtKeySequenceEditorFactory::~QtKeySequenceEditorFactory() */ void QtKeySequenceEditorFactory::connectPropertyManager(QtKeySequencePropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,QKeySequence)), - this, SLOT(slotPropertyChanged(QtProperty*,QKeySequence))); + connect(manager, &QtKeySequencePropertyManager::valueChanged, + this, [this](QtProperty *property, const QKeySequence &value) + { d_ptr->slotPropertyChanged(property, value); }); } /*! @@ -1479,10 +1439,10 @@ QWidget *QtKeySequenceEditorFactory::createEditor(QtKeySequencePropertyManager * QKeySequenceEdit *editor = d_ptr->createEditor(property, parent); editor->setKeySequence(manager->value(property)); - connect(editor, SIGNAL(keySequenceChanged(QKeySequence)), - this, SLOT(slotSetValue(QKeySequence))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QKeySequenceEdit::keySequenceChanged, + this, [this](const QKeySequence &value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -1493,8 +1453,7 @@ QWidget *QtKeySequenceEditorFactory::createEditor(QtKeySequencePropertyManager * */ void QtKeySequenceEditorFactory::disconnectPropertyManager(QtKeySequencePropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,QKeySequence)), - this, SLOT(slotPropertyChanged(QtProperty*,QKeySequence))); + disconnect(manager, &QtKeySequencePropertyManager::valueChanged, this, nullptr); } // QtCharEdit @@ -1529,7 +1488,7 @@ private: QtCharEdit::QtCharEdit(QWidget *parent) : QWidget(parent), m_lineEdit(new QLineEdit(this)) { - QHBoxLayout *layout = new QHBoxLayout(this); + auto *layout = new QHBoxLayout(this); layout->addWidget(m_lineEdit); layout->setContentsMargins(QMargins()); m_lineEdit->installEventFilter(this); @@ -1550,17 +1509,17 @@ bool QtCharEdit::eventFilter(QObject *o, QEvent *e) QString actionString = action->text(); const int pos = actionString.lastIndexOf(QLatin1Char('\t')); if (pos > 0) - actionString = actionString.remove(pos, actionString.length() - pos); + actionString = actionString.remove(pos, actionString.size() - pos); action->setText(actionString); } QAction *actionBefore = nullptr; - if (actions.count() > 0) + if (actions.size() > 0) actionBefore = actions[0]; - QAction *clearAction = new QAction(tr("Clear Char"), menu); + auto *clearAction = new QAction(tr("Clear Char"), menu); menu->insertAction(actionBefore, clearAction); menu->insertSeparator(actionBefore); clearAction->setEnabled(!m_value.isNull()); - connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearChar())); + connect(clearAction, &QAction::triggered, this, &QtCharEdit::slotClearChar); menu->exec(c->globalPos()); delete menu; e->accept(); @@ -1594,7 +1553,7 @@ void QtCharEdit::handleKeyEvent(QKeyEvent *e) } const QString text = e->text(); - if (text.count() != 1) + if (text.size() != 1) return; const QChar c = text.at(0); @@ -1694,8 +1653,7 @@ void QtCharEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, void QtCharEditorFactoryPrivate::slotSetValue(const QChar &value) { QObject *object = q_ptr->sender(); - const QMap<QtCharEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QtCharEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor) if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtCharPropertyManager *manager = q_ptr->propertyManager(property); @@ -1743,8 +1701,9 @@ QtCharEditorFactory::~QtCharEditorFactory() */ void QtCharEditorFactory::connectPropertyManager(QtCharPropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,QChar)), - this, SLOT(slotPropertyChanged(QtProperty*,QChar))); + connect(manager, &QtCharPropertyManager::valueChanged, + this, [this](QtProperty *property, const QChar &value) + { d_ptr->slotPropertyChanged(property, value); }); } /*! @@ -1758,10 +1717,10 @@ QWidget *QtCharEditorFactory::createEditor(QtCharPropertyManager *manager, QtCharEdit *editor = d_ptr->createEditor(property, parent); editor->setValue(manager->value(property)); - connect(editor, SIGNAL(valueChanged(QChar)), - this, SLOT(slotSetValue(QChar))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QtCharEdit::valueChanged, + this, [this](const QChar &value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -1772,8 +1731,7 @@ QWidget *QtCharEditorFactory::createEditor(QtCharPropertyManager *manager, */ void QtCharEditorFactory::disconnectPropertyManager(QtCharPropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,QChar)), - this, SLOT(slotPropertyChanged(QtProperty*,QChar))); + disconnect(manager, &QtCharPropertyManager::valueChanged, this, nullptr); } // QtEnumEditorFactory @@ -1820,7 +1778,7 @@ void QtEnumEditorFactoryPrivate::slotEnumNamesChanged(QtProperty *property, editor->blockSignals(true); editor->clear(); editor->addItems(enumNames); - const int nameCount = enumNames.count(); + const int nameCount = enumNames.size(); for (int i = 0; i < nameCount; i++) editor->setItemIcon(i, enumIcons.value(i)); editor->setCurrentIndex(manager->value(property)); @@ -1842,7 +1800,7 @@ void QtEnumEditorFactoryPrivate::slotEnumIconsChanged(QtProperty *property, const QStringList enumNames = manager->enumNames(property); for (QComboBox *editor : it.value()) { editor->blockSignals(true); - const int nameCount = enumNames.count(); + const int nameCount = enumNames.size(); for (int i = 0; i < nameCount; i++) editor->setItemIcon(i, enumIcons.value(i)); editor->setCurrentIndex(manager->value(property)); @@ -1853,8 +1811,7 @@ void QtEnumEditorFactoryPrivate::slotEnumIconsChanged(QtProperty *property, void QtEnumEditorFactoryPrivate::slotSetValue(int value) { QObject *object = q_ptr->sender(); - const QMap<QComboBox *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QComboBox *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor) if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtEnumPropertyManager *manager = q_ptr->propertyManager(property); @@ -1902,10 +1859,12 @@ QtEnumEditorFactory::~QtEnumEditorFactory() */ void QtEnumEditorFactory::connectPropertyManager(QtEnumPropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotPropertyChanged(QtProperty*,int))); - connect(manager, SIGNAL(enumNamesChanged(QtProperty*,QStringList)), - this, SLOT(slotEnumNamesChanged(QtProperty*,QStringList))); + connect(manager, &QtEnumPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotPropertyChanged(property, value); }); + connect(manager, &QtEnumPropertyManager::enumNamesChanged, + this, [this](QtProperty *property, const QStringList &value) + { d_ptr->slotEnumNamesChanged(property, value); }); } /*! @@ -1922,14 +1881,15 @@ QWidget *QtEnumEditorFactory::createEditor(QtEnumPropertyManager *manager, QtPro QStringList enumNames = manager->enumNames(property); editor->addItems(enumNames); QMap<int, QIcon> enumIcons = manager->enumIcons(property); - const int enumNamesCount = enumNames.count(); + const int enumNamesCount = enumNames.size(); for (int i = 0; i < enumNamesCount; i++) editor->setItemIcon(i, enumIcons.value(i)); editor->setCurrentIndex(manager->value(property)); - connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetValue(int))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QComboBox::currentIndexChanged, + this, [this](int value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -1940,16 +1900,12 @@ QWidget *QtEnumEditorFactory::createEditor(QtEnumPropertyManager *manager, QtPro */ void QtEnumEditorFactory::disconnectPropertyManager(QtEnumPropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotPropertyChanged(QtProperty*,int))); - disconnect(manager, SIGNAL(enumNamesChanged(QtProperty*,QStringList)), - this, SLOT(slotEnumNamesChanged(QtProperty*,QStringList))); + disconnect(manager, &QtEnumPropertyManager::valueChanged, this, nullptr); + disconnect(manager, &QtEnumPropertyManager::enumNamesChanged, this, nullptr); } // QtCursorEditorFactory -Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase) - class QtCursorEditorFactoryPrivate { QtCursorEditorFactory *q_ptr; @@ -1964,10 +1920,10 @@ public: QtEnumEditorFactory *m_enumEditorFactory; QtEnumPropertyManager *m_enumPropertyManager; - QMap<QtProperty *, QtProperty *> m_propertyToEnum; - QMap<QtProperty *, QtProperty *> m_enumToProperty; - QMap<QtProperty *, QWidgetList > m_enumToEditors; - QMap<QWidget *, QtProperty *> m_editorToEnum; + QHash<QtProperty *, QtProperty *> m_propertyToEnum; + QHash<QtProperty *, QtProperty *> m_enumToProperty; + QHash<QtProperty *, QWidgetList > m_enumToEditors; + QHash<QWidget *, QtProperty *> m_editorToEnum; bool m_updatingEnum; }; @@ -1985,7 +1941,8 @@ void QtCursorEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, con return; m_updatingEnum = true; - m_enumPropertyManager->setValue(enumProp, cursorDatabase()->cursorToValue(cursor)); + auto *cdb = QtCursorDatabase::instance(); + m_enumPropertyManager->setValue(enumProp, cdb->cursorToValue(cursor)); m_updatingEnum = false; } @@ -2001,7 +1958,8 @@ void QtCursorEditorFactoryPrivate::slotEnumChanged(QtProperty *property, int val if (!cursorManager) return; #ifndef QT_NO_CURSOR - cursorManager->setValue(prop, QCursor(cursorDatabase()->valueToCursor(value))); + auto *cdb = QtCursorDatabase::instance(); + cursorManager->setValue(prop, QCursor(cdb->valueToCursor(value))); #endif } @@ -2010,8 +1968,7 @@ void QtCursorEditorFactoryPrivate::slotEditorDestroyed(QObject *object) // remove from m_editorToEnum map; // remove from m_enumToEditors map; // if m_enumToEditors doesn't contains more editors delete enum property; - const QMap<QWidget *, QtProperty *>::ConstIterator ecend = m_editorToEnum.constEnd(); - for (QMap<QWidget *, QtProperty *>::ConstIterator itEditor = m_editorToEnum.constBegin(); itEditor != ecend; ++itEditor) + for (auto itEditor = m_editorToEnum.cbegin(), ecend = m_editorToEnum.cend(); itEditor != ecend; ++itEditor) if (itEditor.key() == object) { QWidget *editor = itEditor.key(); QtProperty *enumProp = itEditor.value(); @@ -2050,8 +2007,9 @@ QtCursorEditorFactory::QtCursorEditorFactory(QObject *parent) d_ptr->m_enumEditorFactory = new QtEnumEditorFactory(this); d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); - connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotEnumChanged(QtProperty*,int))); + connect(d_ptr->m_enumPropertyManager, &QtEnumPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotEnumChanged(property, value); }); d_ptr->m_enumEditorFactory->addPropertyManager(d_ptr->m_enumPropertyManager); } @@ -2069,8 +2027,9 @@ QtCursorEditorFactory::~QtCursorEditorFactory() */ void QtCursorEditorFactory::connectPropertyManager(QtCursorPropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,QCursor)), - this, SLOT(slotPropertyChanged(QtProperty*,QCursor))); + connect(manager, &QtCursorPropertyManager::valueChanged, + this, [this](QtProperty *property, const QCursor &value) + { d_ptr->slotPropertyChanged(property, value); }); } /*! @@ -2086,10 +2045,11 @@ QWidget *QtCursorEditorFactory::createEditor(QtCursorPropertyManager *manager, Q enumProp = d_ptr->m_propertyToEnum[property]; } else { enumProp = d_ptr->m_enumPropertyManager->addProperty(property->propertyName()); - d_ptr->m_enumPropertyManager->setEnumNames(enumProp, cursorDatabase()->cursorShapeNames()); - d_ptr->m_enumPropertyManager->setEnumIcons(enumProp, cursorDatabase()->cursorShapeIcons()); + auto *cdb = QtCursorDatabase::instance(); + d_ptr->m_enumPropertyManager->setEnumNames(enumProp, cdb->cursorShapeNames()); + d_ptr->m_enumPropertyManager->setEnumIcons(enumProp, cdb->cursorShapeIcons()); #ifndef QT_NO_CURSOR - d_ptr->m_enumPropertyManager->setValue(enumProp, cursorDatabase()->cursorToValue(manager->value(property))); + d_ptr->m_enumPropertyManager->setValue(enumProp, cdb->cursorToValue(manager->value(property))); #endif d_ptr->m_propertyToEnum[property] = enumProp; d_ptr->m_enumToProperty[enumProp] = property; @@ -2098,8 +2058,8 @@ QWidget *QtCursorEditorFactory::createEditor(QtCursorPropertyManager *manager, Q QWidget *editor = af->createEditor(enumProp, parent); d_ptr->m_enumToEditors[enumProp].append(editor); d_ptr->m_editorToEnum[editor] = enumProp; - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -2110,8 +2070,7 @@ QWidget *QtCursorEditorFactory::createEditor(QtCursorPropertyManager *manager, Q */ void QtCursorEditorFactory::disconnectPropertyManager(QtCursorPropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,QCursor)), - this, SLOT(slotPropertyChanged(QtProperty*,QCursor))); + disconnect(manager, &QtCursorPropertyManager::valueChanged, this, nullptr); } // QtColorEditWidget @@ -2146,7 +2105,7 @@ QtColorEditWidget::QtColorEditWidget(QWidget *parent) : m_label(new QLabel), m_button(new QToolButton) { - QHBoxLayout *lt = new QHBoxLayout(this); + auto *lt = new QHBoxLayout(this); setupTreeViewEditorMargin(lt); lt->setSpacing(0); lt->addWidget(m_pixmapLabel); @@ -2159,7 +2118,7 @@ QtColorEditWidget::QtColorEditWidget(QWidget *parent) : setFocusPolicy(m_button->focusPolicy()); m_button->setText(tr("...")); m_button->installEventFilter(this); - connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked())); + connect(m_button, &QAbstractButton::clicked, this, &QtColorEditWidget::buttonClicked); lt->addWidget(m_button); m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::brushValuePixmap(QBrush(m_color))); m_label->setText(QtPropertyBrowserUtils::colorValueText(m_color)); @@ -2222,7 +2181,7 @@ public: void QtColorEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, const QColor &value) { - const PropertyToEditorListMap::const_iterator it = m_createdEditors.constFind(property); + const auto it = m_createdEditors.constFind(property); if (it == m_createdEditors.constEnd()) return; @@ -2233,8 +2192,7 @@ void QtColorEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, void QtColorEditorFactoryPrivate::slotSetValue(const QColor &value) { QObject *object = q_ptr->sender(); - const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor) if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtColorPropertyManager *manager = q_ptr->propertyManager(property); @@ -2282,8 +2240,9 @@ QtColorEditorFactory::~QtColorEditorFactory() */ void QtColorEditorFactory::connectPropertyManager(QtColorPropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,QColor)), - this, SLOT(slotPropertyChanged(QtProperty*,QColor))); + connect(manager, &QtColorPropertyManager::valueChanged, + this, [this](QtProperty *property, const QColor &value) + { d_ptr->slotPropertyChanged(property, value); }); } /*! @@ -2296,8 +2255,10 @@ QWidget *QtColorEditorFactory::createEditor(QtColorPropertyManager *manager, { QtColorEditWidget *editor = d_ptr->createEditor(property, parent); editor->setValue(manager->value(property)); - connect(editor, SIGNAL(valueChanged(QColor)), this, SLOT(slotSetValue(QColor))); - connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QtColorEditWidget::valueChanged, + this, [this](const QColor &value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -2308,7 +2269,7 @@ QWidget *QtColorEditorFactory::createEditor(QtColorPropertyManager *manager, */ void QtColorEditorFactory::disconnectPropertyManager(QtColorPropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,QColor)), this, SLOT(slotPropertyChanged(QtProperty*,QColor))); + disconnect(manager, &QtColorPropertyManager::valueChanged, this, nullptr); } // QtFontEditWidget @@ -2343,7 +2304,7 @@ QtFontEditWidget::QtFontEditWidget(QWidget *parent) : m_label(new QLabel), m_button(new QToolButton) { - QHBoxLayout *lt = new QHBoxLayout(this); + auto *lt = new QHBoxLayout(this); setupTreeViewEditorMargin(lt); lt->setSpacing(0); lt->addWidget(m_pixmapLabel); @@ -2356,7 +2317,7 @@ QtFontEditWidget::QtFontEditWidget(QWidget *parent) : setFocusPolicy(m_button->focusPolicy()); m_button->setText(tr("...")); m_button->installEventFilter(this); - connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked())); + connect(m_button, &QAbstractButton::clicked, this, &QtFontEditWidget::buttonClicked); lt->addWidget(m_button); m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::fontValuePixmap(m_font)); m_label->setText(QtPropertyBrowserUtils::fontValueText(m_font)); @@ -2434,7 +2395,7 @@ public: void QtFontEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, const QFont &value) { - const PropertyToEditorListMap::const_iterator it = m_createdEditors.constFind(property); + const auto it = m_createdEditors.constFind(property); if (it == m_createdEditors.constEnd()) return; @@ -2445,8 +2406,7 @@ void QtFontEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, void QtFontEditorFactoryPrivate::slotSetValue(const QFont &value) { QObject *object = q_ptr->sender(); - const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) + for (auto itEditor = m_editorToProperty.cbegin(), ecend = m_editorToProperty.cend(); itEditor != ecend; ++itEditor) if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtFontPropertyManager *manager = q_ptr->propertyManager(property); @@ -2494,8 +2454,9 @@ QtFontEditorFactory::~QtFontEditorFactory() */ void QtFontEditorFactory::connectPropertyManager(QtFontPropertyManager *manager) { - connect(manager, SIGNAL(valueChanged(QtProperty*,QFont)), - this, SLOT(slotPropertyChanged(QtProperty*,QFont))); + connect(manager, &QtFontPropertyManager::valueChanged, + this, [this](QtProperty *property, const QFont &value) + { d_ptr->slotPropertyChanged(property, value); }); } /*! @@ -2508,8 +2469,10 @@ QWidget *QtFontEditorFactory::createEditor(QtFontPropertyManager *manager, { QtFontEditWidget *editor = d_ptr->createEditor(property, parent); editor->setValue(manager->value(property)); - connect(editor, SIGNAL(valueChanged(QFont)), this, SLOT(slotSetValue(QFont))); - connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QtFontEditWidget::valueChanged, + this, [this](const QFont &value) { d_ptr->slotSetValue(value); }); + connect(editor, &QObject::destroyed, + this, [this](QObject *object) { d_ptr->slotEditorDestroyed(object); }); return editor; } @@ -2520,7 +2483,7 @@ QWidget *QtFontEditorFactory::createEditor(QtFontPropertyManager *manager, */ void QtFontEditorFactory::disconnectPropertyManager(QtFontPropertyManager *manager) { - disconnect(manager, SIGNAL(valueChanged(QtProperty*,QFont)), this, SLOT(slotPropertyChanged(QtProperty*,QFont))); + disconnect(manager, &QtFontPropertyManager::valueChanged, this, nullptr); } QT_END_NAMESPACE diff --git a/src/shared/qtpropertybrowser/qteditorfactory.h b/src/shared/qtpropertybrowser/qteditorfactory.h index 84cd797cd..bc848f777 100644 --- a/src/shared/qtpropertybrowser/qteditorfactory.h +++ b/src/shared/qtpropertybrowser/qteditorfactory.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTEDITORFACTORY_H #define QTEDITORFACTORY_H @@ -63,11 +27,6 @@ private: QScopedPointer<QtSpinBoxFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtSpinBoxFactory) Q_DISABLE_COPY_MOVE(QtSpinBoxFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtSliderFactoryPrivate; @@ -87,11 +46,6 @@ private: QScopedPointer<QtSliderFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtSliderFactory) Q_DISABLE_COPY_MOVE(QtSliderFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtScrollBarFactoryPrivate; @@ -111,11 +65,6 @@ private: QScopedPointer<QtScrollBarFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtScrollBarFactory) Q_DISABLE_COPY_MOVE(QtScrollBarFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtCheckBoxFactoryPrivate; @@ -135,9 +84,6 @@ private: QScopedPointer<QtCheckBoxFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtCheckBoxFactory) Q_DISABLE_COPY_MOVE(QtCheckBoxFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, bool)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(bool)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtDoubleSpinBoxFactoryPrivate; @@ -157,12 +103,6 @@ private: QScopedPointer<QtDoubleSpinBoxFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtDoubleSpinBoxFactory) Q_DISABLE_COPY_MOVE(QtDoubleSpinBoxFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(double)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtLineEditFactoryPrivate; @@ -182,10 +122,6 @@ private: QScopedPointer<QtLineEditFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtLineEditFactory) Q_DISABLE_COPY_MOVE(QtLineEditFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QString &)) - Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegularExpression &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QString &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtDateEditFactoryPrivate; @@ -205,10 +141,6 @@ private: QScopedPointer<QtDateEditFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtDateEditFactory) Q_DISABLE_COPY_MOVE(QtDateEditFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, QDate)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, QDate, QDate)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(QDate)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtTimeEditFactoryPrivate; @@ -228,9 +160,6 @@ private: QScopedPointer<QtTimeEditFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtTimeEditFactory) Q_DISABLE_COPY_MOVE(QtTimeEditFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, QTime)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(QTime)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtDateTimeEditFactoryPrivate; @@ -250,9 +179,6 @@ private: QScopedPointer<QtDateTimeEditFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtDateTimeEditFactory) Q_DISABLE_COPY_MOVE(QtDateTimeEditFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QDateTime &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QDateTime &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtKeySequenceEditorFactoryPrivate; @@ -272,9 +198,6 @@ private: QScopedPointer<QtKeySequenceEditorFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtKeySequenceEditorFactory) Q_DISABLE_COPY_MOVE(QtKeySequenceEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QKeySequence &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QKeySequence &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtCharEditorFactoryPrivate; @@ -294,9 +217,6 @@ private: QScopedPointer<QtCharEditorFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtCharEditorFactory) Q_DISABLE_COPY_MOVE(QtCharEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QChar &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QChar &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtEnumEditorFactoryPrivate; @@ -316,13 +236,6 @@ private: QScopedPointer<QtEnumEditorFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtEnumEditorFactory) Q_DISABLE_COPY_MOVE(QtEnumEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty *, - const QStringList &)) - Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *, - const QMap<int, QIcon> &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtCursorEditorFactoryPrivate; @@ -342,9 +255,6 @@ private: QScopedPointer<QtCursorEditorFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtCursorEditorFactory) Q_DISABLE_COPY_MOVE(QtCursorEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QCursor &)) - Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtColorEditorFactoryPrivate; @@ -364,9 +274,6 @@ private: QScopedPointer<QtColorEditorFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtColorEditorFactory) Q_DISABLE_COPY_MOVE(QtColorEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QColor &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QColor &)) }; class QtFontEditorFactoryPrivate; @@ -386,9 +293,6 @@ private: QScopedPointer<QtFontEditorFactoryPrivate> d_ptr; Q_DECLARE_PRIVATE(QtFontEditorFactory) Q_DISABLE_COPY_MOVE(QtFontEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QFont &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QFont &)) }; QT_END_NAMESPACE diff --git a/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp b/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp index 43ca132d8..9f08f67a9 100644 --- a/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp +++ b/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.cpp @@ -1,49 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qtgroupboxpropertybrowser.h" -#include <QtCore/QSet> + +#include <QtCore/QHash> #include <QtWidgets/QGridLayout> -#include <QtWidgets/QLabel> #include <QtWidgets/QGroupBox> -#include <QtCore/QTimer> -#include <QtCore/QMap> +#include <QtWidgets/QLabel> QT_BEGIN_NAMESPACE @@ -83,9 +46,9 @@ private: bool hasHeader(WidgetItem *item) const; - QMap<QtBrowserItem *, WidgetItem *> m_indexToItem; - QMap<WidgetItem *, QtBrowserItem *> m_itemToIndex; - QMap<QWidget *, WidgetItem *> m_widgetToItem; + QHash<QtBrowserItem *, WidgetItem *> m_indexToItem; + QHash<WidgetItem *, QtBrowserItem *> m_itemToIndex; + QHash<QWidget *, WidgetItem *> m_widgetToItem; QGridLayout *m_mainLayout; QList<WidgetItem *> m_children; QList<WidgetItem *> m_recreateQueue; @@ -95,25 +58,24 @@ void QtGroupBoxPropertyBrowserPrivate::init(QWidget *parent) { m_mainLayout = new QGridLayout(); parent->setLayout(m_mainLayout); - QLayoutItem *item = new QSpacerItem(0, 0, - QSizePolicy::Fixed, QSizePolicy::Expanding); + auto *item = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding); m_mainLayout->addItem(item, 0, 0); } void QtGroupBoxPropertyBrowserPrivate::slotEditorDestroyed() { - QWidget *editor = qobject_cast<QWidget *>(q_ptr->sender()); + auto *editor = qobject_cast<QWidget *>(q_ptr->sender()); if (!editor) return; if (!m_widgetToItem.contains(editor)) return; - m_widgetToItem[editor]->widget = 0; + m_widgetToItem[editor]->widget = nullptr; m_widgetToItem.remove(editor); } void QtGroupBoxPropertyBrowserPrivate::slotUpdate() { - for (WidgetItem *item : qAsConst(m_recreateQueue)) { + for (WidgetItem *item : std::as_const(m_recreateQueue)) { WidgetItem *par = item->parent; QWidget *w = nullptr; QGridLayout *l = nullptr; @@ -155,7 +117,7 @@ void QtGroupBoxPropertyBrowserPrivate::slotUpdate() void QtGroupBoxPropertyBrowserPrivate::updateLater() { - QTimer::singleShot(0, q_ptr, SLOT(slotUpdate())); + QMetaObject::invokeMethod(q_ptr, [this] { slotUpdate(); }, Qt::QueuedConnection); } void QtGroupBoxPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex) @@ -163,7 +125,7 @@ void QtGroupBoxPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, Qt WidgetItem *afterItem = m_indexToItem.value(afterIndex); WidgetItem *parentItem = m_indexToItem.value(index->parent()); - WidgetItem *newItem = new WidgetItem(); + auto *newItem = new WidgetItem(); newItem->parent = parentItem; QGridLayout *layout = nullptr; @@ -244,7 +206,8 @@ void QtGroupBoxPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, Qt if (!newItem->widget) { newItem->widgetLabel = new QLabel(parentWidget); } else { - QObject::connect(newItem->widget, SIGNAL(destroyed()), q_ptr, SLOT(slotEditorDestroyed())); + QObject::connect(newItem->widget, &QWidget::destroyed, + q_ptr, [this] { slotEditorDestroyed(); }); m_widgetToItem[newItem->widget] = newItem; } @@ -296,22 +259,11 @@ void QtGroupBoxPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) if (!parentItem) { removeRow(m_mainLayout, row); - } else if (parentItem->children.count() != 0) { + } else if (parentItem->children.size() != 0) { removeRow(parentItem->layout, row); } else { WidgetItem *par = parentItem->parent; - QGridLayout *l = nullptr; - int oldRow = -1; - if (!par) { - l = m_mainLayout; - oldRow = m_children.indexOf(parentItem); - } else { - l = par->layout; - oldRow = par->children.indexOf(parentItem); - if (hasHeader(par)) - oldRow += 2; - } - + QGridLayout *l = (par ? par->layout : m_mainLayout); if (parentItem->widget) { parentItem->widget->hide(); parentItem->widget->setParent(0); @@ -337,7 +289,7 @@ void QtGroupBoxPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) void QtGroupBoxPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) const { - QMap<QLayoutItem *, QRect> itemToPos; + QHash<QLayoutItem *, QRect> itemToPos; int idx = 0; while (idx < layout->count()) { int r, c, rs, cs; @@ -349,8 +301,7 @@ void QtGroupBoxPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) c } } - const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd(); - for (QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) { + for (auto it = itemToPos.cbegin(), icend = itemToPos.cend(); it != icend; ++it) { const QRect r = it.value(); layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); } @@ -358,7 +309,7 @@ void QtGroupBoxPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) c void QtGroupBoxPropertyBrowserPrivate::removeRow(QGridLayout *layout, int row) const { - QMap<QLayoutItem *, QRect> itemToPos; + QHash<QLayoutItem *, QRect> itemToPos; int idx = 0; while (idx < layout->count()) { int r, c, rs, cs; @@ -370,8 +321,7 @@ void QtGroupBoxPropertyBrowserPrivate::removeRow(QGridLayout *layout, int row) c } } - const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd(); - for (QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) { + for (auto it = itemToPos.cbegin(), icend = itemToPos.cend(); it != icend; ++it) { const QRect r = it.value(); layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); } @@ -379,9 +329,7 @@ void QtGroupBoxPropertyBrowserPrivate::removeRow(QGridLayout *layout, int row) c bool QtGroupBoxPropertyBrowserPrivate::hasHeader(WidgetItem *item) const { - if (item->widget) - return true; - return false; + return item->widget; } void QtGroupBoxPropertyBrowserPrivate::propertyChanged(QtBrowserItem *index) @@ -486,8 +434,7 @@ QtGroupBoxPropertyBrowser::QtGroupBoxPropertyBrowser(QWidget *parent) */ QtGroupBoxPropertyBrowser::~QtGroupBoxPropertyBrowser() { - const QMap<QtGroupBoxPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator icend = d_ptr->m_itemToIndex.constEnd(); - for (QMap<QtGroupBoxPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator it = d_ptr->m_itemToIndex.constBegin(); it != icend; ++it) + for (auto it = d_ptr->m_itemToIndex.cbegin(), icend = d_ptr->m_itemToIndex.cend(); it != icend; ++it) delete it.key(); } diff --git a/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.h b/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.h index a42b8cf1d..44b790989 100644 --- a/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.h +++ b/src/shared/qtpropertybrowser/qtgroupboxpropertybrowser.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTGROUPBOXPROPERTYBROWSER_H #define QTGROUPBOXPROPERTYBROWSER_H @@ -50,7 +14,6 @@ class QtGroupBoxPropertyBrowser : public QtAbstractPropertyBrowser { Q_OBJECT public: - QtGroupBoxPropertyBrowser(QWidget *parent = 0); ~QtGroupBoxPropertyBrowser(); @@ -60,13 +23,9 @@ protected: void itemChanged(QtBrowserItem *item) override; private: - QScopedPointer<QtGroupBoxPropertyBrowserPrivate> d_ptr; Q_DECLARE_PRIVATE(QtGroupBoxPropertyBrowser) Q_DISABLE_COPY_MOVE(QtGroupBoxPropertyBrowser) - Q_PRIVATE_SLOT(d_func(), void slotUpdate()) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed()) - }; QT_END_NAMESPACE diff --git a/src/shared/qtpropertybrowser/qtpropertybrowser.cpp b/src/shared/qtpropertybrowser/qtpropertybrowser.cpp index bc86d2879..2803e2860 100644 --- a/src/shared/qtpropertybrowser/qtpropertybrowser.cpp +++ b/src/shared/qtpropertybrowser/qtpropertybrowser.cpp @@ -1,45 +1,8 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qtpropertybrowser.h" -#include <QtCore/QSet> -#include <QtCore/QMap> +#include <QtCore/QHash> #include <QtGui/QIcon> #if defined(Q_CC_MSVC) @@ -161,15 +124,15 @@ QtProperty::QtProperty(QtAbstractPropertyManager *manager) */ QtProperty::~QtProperty() { - for (QtProperty *property : qAsConst(d_ptr->m_parentItems)) + for (QtProperty *property : std::as_const(d_ptr->m_parentItems)) property->d_ptr->m_manager->d_ptr->propertyRemoved(this, property); d_ptr->m_manager->d_ptr->propertyDestroyed(this); - for (QtProperty *property : qAsConst(d_ptr->m_subItems)) + for (QtProperty *property : std::as_const(d_ptr->m_subItems)) property->d_ptr->m_parentItems.remove(this); - for (QtProperty *property : qAsConst(d_ptr->m_parentItems)) + for (QtProperty *property : std::as_const(d_ptr->m_parentItems)) property->d_ptr->m_subItems.removeAll(this); } @@ -424,7 +387,7 @@ void QtProperty::setModified(bool modified) void QtProperty::addSubProperty(QtProperty *property) { QtProperty *after = nullptr; - if (d_ptr->m_subItems.count() > 0) + if (d_ptr->m_subItems.size() > 0) after = d_ptr->m_subItems.last(); insertSubProperty(property, after); } @@ -453,7 +416,7 @@ void QtProperty::insertSubProperty(QtProperty *property, // traverse all children of item. if this item is a child of item then cannot add. auto pendingList = property->subProperties(); - QMap<QtProperty *, bool> visited; + QHash<QtProperty *, bool> visited; while (!pendingList.isEmpty()) { QtProperty *i = pendingList.first(); if (i == this) @@ -469,7 +432,7 @@ void QtProperty::insertSubProperty(QtProperty *property, int pos = 0; int newPos = 0; QtProperty *properAfterProperty = nullptr; - while (pos < pendingList.count()) { + while (pos < pendingList.size()) { QtProperty *i = pendingList.at(pos); if (i == property) return; // if item is already inserted in this item then cannot add. @@ -501,7 +464,7 @@ void QtProperty::removeSubProperty(QtProperty *property) auto pendingList = subProperties(); int pos = 0; - while (pos < pendingList.count()) { + while (pos < pendingList.size()) { if (pendingList.at(pos) == property) { d_ptr->m_subItems.removeAt(pos); property->d_ptr->m_parentItems.remove(this); @@ -729,7 +692,7 @@ bool QtAbstractPropertyManager::hasValue(const QtProperty *property) const QIcon QtAbstractPropertyManager::valueIcon(const QtProperty *property) const { Q_UNUSED(property); - return QIcon(); + return {}; } /*! @@ -744,7 +707,7 @@ QIcon QtAbstractPropertyManager::valueIcon(const QtProperty *property) const QString QtAbstractPropertyManager::valueText(const QtProperty *property) const { Q_UNUSED(property); - return QString(); + return {}; } /*! @@ -1203,10 +1166,11 @@ QtBrowserItem::~QtBrowserItem() //////////////////////////////////// -typedef QMap<QtAbstractPropertyBrowser *, QMap<QtAbstractPropertyManager *, - QtAbstractEditorFactoryBase *> > Map1; -typedef QMap<QtAbstractPropertyManager *, QMap<QtAbstractEditorFactoryBase *, - QList<QtAbstractPropertyBrowser *> > > Map2; +using Map1 = QHash<QtAbstractPropertyBrowser *, + QHash<QtAbstractPropertyManager *, QtAbstractEditorFactoryBase *>>; +using Map2 = QHash<QtAbstractPropertyManager *, + QHash<QtAbstractEditorFactoryBase *, QList<QtAbstractPropertyBrowser *>>>; + Q_GLOBAL_STATIC(Map1, m_viewToManagerToFactory) Q_GLOBAL_STATIC(Map2, m_managerToFactoryToViews) @@ -1234,12 +1198,12 @@ public: void slotPropertyDataChanged(QtProperty *property); QList<QtProperty *> m_subItems; - QMap<QtAbstractPropertyManager *, QList<QtProperty *> > m_managerToProperties; - QMap<QtProperty *, QList<QtProperty *> > m_propertyToParents; + QHash<QtAbstractPropertyManager *, QList<QtProperty *> > m_managerToProperties; + QHash<QtProperty *, QList<QtProperty *> > m_propertyToParents; - QMap<QtProperty *, QtBrowserItem *> m_topLevelPropertyToIndex; + QHash<QtProperty *, QtBrowserItem *> m_topLevelPropertyToIndex; QList<QtBrowserItem *> m_topLevelIndexes; - QMap<QtProperty *, QList<QtBrowserItem *> > m_propertyToIndexes; + QHash<QtProperty *, QList<QtBrowserItem *> > m_propertyToIndexes; QtBrowserItem *m_currentItem; }; @@ -1264,17 +1228,16 @@ void QtAbstractPropertyBrowserPrivate::insertSubTree(QtProperty *property, QtAbstractPropertyManager *manager = property->propertyManager(); if (m_managerToProperties[manager].isEmpty()) { // connect manager's signals - q_ptr->connect(manager, SIGNAL(propertyInserted(QtProperty *, - QtProperty *, QtProperty *)), - q_ptr, SLOT(slotPropertyInserted(QtProperty *, - QtProperty *, QtProperty *))); - q_ptr->connect(manager, SIGNAL(propertyRemoved(QtProperty *, - QtProperty *)), - q_ptr, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*))); - q_ptr->connect(manager, SIGNAL(propertyDestroyed(QtProperty*)), - q_ptr, SLOT(slotPropertyDestroyed(QtProperty*))); - q_ptr->connect(manager, SIGNAL(propertyChanged(QtProperty*)), - q_ptr, SLOT(slotPropertyDataChanged(QtProperty*))); + q_ptr->connect(manager, &QtAbstractPropertyManager::propertyInserted, + q_ptr, [this](QtProperty *property, QtProperty *parent, QtProperty *after) + { slotPropertyInserted(property, parent, after); }); + q_ptr->connect(manager, &QtAbstractPropertyManager::propertyRemoved, + q_ptr, [this](QtProperty *property, QtProperty *parent) + { slotPropertyRemoved(property, parent); }); + q_ptr->connect(manager, &QtAbstractPropertyManager::propertyDestroyed, + q_ptr, [this](QtProperty *property) { slotPropertyDestroyed(property); }); + q_ptr->connect(manager, &QtAbstractPropertyManager::propertyChanged, + q_ptr, [this](QtProperty *property) { slotPropertyDataChanged(property); }); } m_managerToProperties[manager].append(property); m_propertyToParents[property].append(parentProperty); @@ -1301,17 +1264,10 @@ void QtAbstractPropertyBrowserPrivate::removeSubTree(QtProperty *property, m_managerToProperties[manager].removeAll(property); if (m_managerToProperties[manager].isEmpty()) { // disconnect manager's signals - q_ptr->disconnect(manager, SIGNAL(propertyInserted(QtProperty *, - QtProperty *, QtProperty *)), - q_ptr, SLOT(slotPropertyInserted(QtProperty *, - QtProperty *, QtProperty *))); - q_ptr->disconnect(manager, SIGNAL(propertyRemoved(QtProperty *, - QtProperty *)), - q_ptr, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*))); - q_ptr->disconnect(manager, SIGNAL(propertyDestroyed(QtProperty*)), - q_ptr, SLOT(slotPropertyDestroyed(QtProperty*))); - q_ptr->disconnect(manager, SIGNAL(propertyChanged(QtProperty*)), - q_ptr, SLOT(slotPropertyDataChanged(QtProperty*))); + q_ptr->disconnect(manager, &QtAbstractPropertyManager::propertyInserted, q_ptr, nullptr); + q_ptr->disconnect(manager, &QtAbstractPropertyManager::propertyRemoved, q_ptr, nullptr); + q_ptr->disconnect(manager, &QtAbstractPropertyManager::propertyDestroyed, q_ptr, nullptr); + q_ptr->disconnect(manager, &QtAbstractPropertyManager::propertyChanged, q_ptr, nullptr); m_managerToProperties.remove(manager); } @@ -1323,7 +1279,7 @@ void QtAbstractPropertyBrowserPrivate::removeSubTree(QtProperty *property, void QtAbstractPropertyBrowserPrivate::createBrowserIndexes(QtProperty *property, QtProperty *parentProperty, QtProperty *afterProperty) { - QMap<QtBrowserItem *, QtBrowserItem *> parentToAfter; + QHash<QtBrowserItem *, QtBrowserItem *> parentToAfter; if (afterProperty) { const auto it = m_propertyToIndexes.constFind(afterProperty); if (it == m_propertyToIndexes.constEnd()) @@ -1340,20 +1296,19 @@ void QtAbstractPropertyBrowserPrivate::createBrowserIndexes(QtProperty *property return; for (QtBrowserItem *idx : it.value()) - parentToAfter[idx] = 0; + parentToAfter[idx] = nullptr; } else { - parentToAfter[0] = 0; + parentToAfter[nullptr] = nullptr; } - const QMap<QtBrowserItem *, QtBrowserItem *>::ConstIterator pcend = parentToAfter.constEnd(); - for (QMap<QtBrowserItem *, QtBrowserItem *>::ConstIterator it = parentToAfter.constBegin(); it != pcend; ++it) + for (auto it = parentToAfter.cbegin(), pcend = parentToAfter.cend(); it != pcend; ++it) createBrowserIndex(property, it.key(), it.value()); } QtBrowserItem *QtAbstractPropertyBrowserPrivate::createBrowserIndex(QtProperty *property, QtBrowserItem *parentIndex, QtBrowserItem *afterIndex) { - QtBrowserItem *newIndex = new QtBrowserItem(q_ptr, property, parentIndex); + auto *newIndex = new QtBrowserItem(q_ptr, property, parentIndex); if (parentIndex) { parentIndex->d_ptr->addChild(newIndex, afterIndex); } else { @@ -1384,14 +1339,14 @@ void QtAbstractPropertyBrowserPrivate::removeBrowserIndexes(QtProperty *property toRemove.append(idx); } - for (QtBrowserItem *index : qAsConst(toRemove)) + for (QtBrowserItem *index : std::as_const(toRemove)) removeBrowserIndex(index); } void QtAbstractPropertyBrowserPrivate::removeBrowserIndex(QtBrowserItem *index) { const auto children = index->children(); - for (int i = children.count(); i > 0; i--) { + for (int i = children.size(); i > 0; i--) { removeBrowserIndex(children.at(i - 1)); } @@ -1606,7 +1561,7 @@ void QtAbstractPropertyBrowserPrivate::slotPropertyDataChanged(QtProperty *prope \a item of the property as parameters. The passed \a item is deleted just after this call is finished. - If the the parent of \a item is 0, the removed \a item was a + If the parent of \a item is 0, the removed \a item was a top level property in this editor. This function must be reimplemented in derived classes. Note that @@ -1743,7 +1698,7 @@ void QtAbstractPropertyBrowser::clear() QtBrowserItem *QtAbstractPropertyBrowser::addProperty(QtProperty *property) { QtProperty *afterProperty = nullptr; - if (d_ptr->m_subItems.count() > 0) + if (d_ptr->m_subItems.size() > 0) afterProperty = d_ptr->m_subItems.last(); return insertProperty(property, afterProperty); } @@ -1768,16 +1723,16 @@ QtBrowserItem *QtAbstractPropertyBrowser::insertProperty(QtProperty *property, QtProperty *afterProperty) { if (!property) - return 0; + return nullptr; // if item is already inserted in this item then cannot add. auto pendingList = properties(); int pos = 0; int newPos = 0; - while (pos < pendingList.count()) { + while (pos < pendingList.size()) { QtProperty *prop = pendingList.at(pos); if (prop == property) - return 0; + return nullptr; if (prop == afterProperty) { newPos = pos + 1; } @@ -1811,7 +1766,7 @@ void QtAbstractPropertyBrowser::removeProperty(QtProperty *property) auto pendingList = properties(); int pos = 0; - while (pos < pendingList.count()) { + while (pos < pendingList.size()) { if (pendingList.at(pos) == property) { d_ptr->m_subItems.removeAt(pos); //perhaps this two lines d_ptr->removeSubTree(property, 0); //should be moved down after propertyRemoved call. @@ -1858,7 +1813,7 @@ QWidget *QtAbstractPropertyBrowser::createEditor(QtProperty *property, } if (!factory) - return 0; + return nullptr; QWidget *w = factory->createEditor(property, parent); // Since some editors can be QComboBoxes, and we changed their focus policy in Qt 5 // to make them feel more native on Mac, we need to relax the focus policy to something diff --git a/src/shared/qtpropertybrowser/qtpropertybrowser.h b/src/shared/qtpropertybrowser/qtpropertybrowser.h index 697ee4c7d..623ea5d67 100644 --- a/src/shared/qtpropertybrowser/qtpropertybrowser.h +++ b/src/shared/qtpropertybrowser/qtpropertybrowser.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTPROPERTYBROWSER_H #define QTPROPERTYBROWSER_H @@ -105,9 +69,7 @@ public: QtProperty *addProperty(const QString &name = QString()); Q_SIGNALS: - - void propertyInserted(QtProperty *property, - QtProperty *parent, QtProperty *after); + void propertyInserted(QtProperty *property, QtProperty *parent, QtProperty *after); void propertyChanged(QtProperty *property); void propertyRemoved(QtProperty *property, QtProperty *parent); void propertyDestroyed(QtProperty *property); @@ -148,7 +110,7 @@ public: explicit QtAbstractEditorFactory(QObject *parent) : QtAbstractEditorFactoryBase(parent) {} QWidget *createEditor(QtProperty *property, QWidget *parent) override { - for (PropertyManager *manager : qAsConst(m_managers)) { + for (PropertyManager *manager : std::as_const(m_managers)) { if (manager == property->propertyManager()) { return createEditor(manager, property, parent); } @@ -161,15 +123,15 @@ public: return; m_managers.insert(manager); connectPropertyManager(manager); - connect(manager, SIGNAL(destroyed(QObject *)), - this, SLOT(managerDestroyed(QObject *))); + connect(manager, &QObject::destroyed, + this, &QtAbstractEditorFactory<PropertyManager>::managerDestroyed); } void removePropertyManager(PropertyManager *manager) { if (!m_managers.contains(manager)) return; - disconnect(manager, SIGNAL(destroyed(QObject *)), - this, SLOT(managerDestroyed(QObject *))); + disconnect(manager, &QObject::destroyed, + this, &QtAbstractEditorFactory<PropertyManager>::managerDestroyed); disconnectPropertyManager(manager); m_managers.remove(manager); } @@ -180,7 +142,7 @@ public: PropertyManager *propertyManager(QtProperty *property) const { QtAbstractPropertyManager *manager = property->propertyManager(); - for (PropertyManager *m : qAsConst(m_managers)) { + for (PropertyManager *m : std::as_const(m_managers)) { if (m == manager) { return m; } @@ -194,7 +156,7 @@ protected: virtual void disconnectPropertyManager(PropertyManager *manager) = 0; void managerDestroyed(QObject *manager) override { - for (PropertyManager *m : qAsConst(m_managers)) { + for (PropertyManager *m : std::as_const(m_managers)) { if (m == manager) { m_managers.remove(m); return; @@ -204,7 +166,7 @@ protected: private: void breakConnection(QtAbstractPropertyManager *manager) override { - for (PropertyManager *m : qAsConst(m_managers)) { + for (PropertyManager *m : std::as_const(m_managers)) { if (m == manager) { removePropertyManager(m); return; @@ -289,13 +251,6 @@ private: QScopedPointer<QtAbstractPropertyBrowserPrivate> d_ptr; Q_DECLARE_PRIVATE(QtAbstractPropertyBrowser) Q_DISABLE_COPY_MOVE(QtAbstractPropertyBrowser) - Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, - QtProperty *, QtProperty *)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, - QtProperty *)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDataChanged(QtProperty *)) - }; QT_END_NAMESPACE diff --git a/src/shared/qtpropertybrowser/qtpropertybrowser.qrc b/src/shared/qtpropertybrowser/qtpropertybrowser.qrc deleted file mode 100644 index a7d37dd10..000000000 --- a/src/shared/qtpropertybrowser/qtpropertybrowser.qrc +++ /dev/null @@ -1,23 +0,0 @@ -<RCC version="1.0"> - <qresource prefix="/qt-project.org/qtpropertybrowser"> - <file>images/cursor-arrow.png</file> - <file>images/cursor-busy.png</file> - <file>images/cursor-closedhand.png</file> - <file>images/cursor-cross.png</file> - <file>images/cursor-forbidden.png</file> - <file>images/cursor-hand.png</file> - <file>images/cursor-hsplit.png</file> - <file>images/cursor-ibeam.png</file> - <file>images/cursor-openhand.png</file> - <file>images/cursor-sizeall.png</file> - <file>images/cursor-sizeb.png</file> - <file>images/cursor-sizef.png</file> - <file>images/cursor-sizeh.png</file> - <file>images/cursor-sizev.png</file> - <file>images/cursor-uparrow.png</file> - <file>images/cursor-vsplit.png</file> - <file>images/cursor-wait.png</file> - <file>images/cursor-whatsthis.png</file> - </qresource> -</RCC> - diff --git a/src/shared/qtpropertybrowser/qtpropertybrowserutils.cpp b/src/shared/qtpropertybrowser/qtpropertybrowserutils.cpp index 9602b10d0..9d6aca901 100644 --- a/src/shared/qtpropertybrowser/qtpropertybrowserutils.cpp +++ b/src/shared/qtpropertybrowser/qtpropertybrowserutils.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qtpropertybrowserutils_p.h" #include <QtWidgets/QApplication> @@ -49,46 +13,57 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + +// Make sure icons are removed as soon as QApplication is destroyed, otherwise, +// handles are leaked on X11. +static void clearCursorDatabase() +{ + QtCursorDatabase::instance()->clear(); +} + QtCursorDatabase::QtCursorDatabase() { + qAddPostRoutine(clearCursorDatabase); + appendCursor(Qt::ArrowCursor, QCoreApplication::translate("QtCursorDatabase", "Arrow"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-arrow.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-arrow.png"_L1)); appendCursor(Qt::UpArrowCursor, QCoreApplication::translate("QtCursorDatabase", "Up Arrow"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-uparrow.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-uparrow.png"_L1)); appendCursor(Qt::CrossCursor, QCoreApplication::translate("QtCursorDatabase", "Cross"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-cross.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-cross.png"_L1)); appendCursor(Qt::WaitCursor, QCoreApplication::translate("QtCursorDatabase", "Wait"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-wait.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-wait.png"_L1)); appendCursor(Qt::IBeamCursor, QCoreApplication::translate("QtCursorDatabase", "IBeam"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-ibeam.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-ibeam.png"_L1)); appendCursor(Qt::SizeVerCursor, QCoreApplication::translate("QtCursorDatabase", "Size Vertical"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizev.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizev.png"_L1)); appendCursor(Qt::SizeHorCursor, QCoreApplication::translate("QtCursorDatabase", "Size Horizontal"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizeh.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizeh.png"_L1)); appendCursor(Qt::SizeFDiagCursor, QCoreApplication::translate("QtCursorDatabase", "Size Backslash"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizef.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizef.png"_L1)); appendCursor(Qt::SizeBDiagCursor, QCoreApplication::translate("QtCursorDatabase", "Size Slash"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizeb.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizeb.png"_L1)); appendCursor(Qt::SizeAllCursor, QCoreApplication::translate("QtCursorDatabase", "Size All"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizeall.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-sizeall.png"_L1)); appendCursor(Qt::BlankCursor, QCoreApplication::translate("QtCursorDatabase", "Blank"), QIcon()); appendCursor(Qt::SplitVCursor, QCoreApplication::translate("QtCursorDatabase", "Split Vertical"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-vsplit.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-vsplit.png"_L1)); appendCursor(Qt::SplitHCursor, QCoreApplication::translate("QtCursorDatabase", "Split Horizontal"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-hsplit.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-hsplit.png"_L1)); appendCursor(Qt::PointingHandCursor, QCoreApplication::translate("QtCursorDatabase", "Pointing Hand"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-hand.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-hand.png"_L1)); appendCursor(Qt::ForbiddenCursor, QCoreApplication::translate("QtCursorDatabase", "Forbidden"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-forbidden.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-forbidden.png"_L1)); appendCursor(Qt::OpenHandCursor, QCoreApplication::translate("QtCursorDatabase", "Open Hand"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-openhand.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-openhand.png"_L1)); appendCursor(Qt::ClosedHandCursor, QCoreApplication::translate("QtCursorDatabase", "Closed Hand"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-closedhand.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-closedhand.png"_L1)); appendCursor(Qt::WhatsThisCursor, QCoreApplication::translate("QtCursorDatabase", "What's This"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-whatsthis.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-whatsthis.png"_L1)); appendCursor(Qt::BusyCursor, QCoreApplication::translate("QtCursorDatabase", "Busy"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-busy.png"))); + QIcon(":/qt-project.org/qtpropertybrowser/images/cursor-busy.png"_L1)); } void QtCursorDatabase::clear() @@ -103,7 +78,7 @@ void QtCursorDatabase::appendCursor(Qt::CursorShape shape, const QString &name, { if (m_cursorShapeToValue.contains(shape)) return; - const int value = m_cursorNames.count(); + const int value = m_cursorNames.size(); m_cursorNames.append(name); m_cursorIcons.insert(value, icon); m_valueToCursorShape.insert(value, shape); @@ -125,7 +100,7 @@ QString QtCursorDatabase::cursorToShapeName(const QCursor &cursor) const int val = cursorToValue(cursor); if (val >= 0) return m_cursorNames.at(val); - return QString(); + return {}; } QIcon QtCursorDatabase::cursorToShapeIcon(const QCursor &cursor) const @@ -149,10 +124,17 @@ QCursor QtCursorDatabase::valueToCursor(int value) const { if (m_valueToCursorShape.contains(value)) return QCursor(m_valueToCursorShape[value]); - return QCursor(); + return {}; } #endif +Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase) + +QtCursorDatabase *QtCursorDatabase::instance() +{ + return cursorDatabase(); +} + QPixmap QtPropertyBrowserUtils::brushValuePixmap(const QBrush &b) { QImage img(16, 16, QImage::Format_ARGB32_Premultiplied); @@ -217,7 +199,7 @@ QString QtPropertyBrowserUtils::dateFormat() QString format = loc.dateFormat(QLocale::ShortFormat); // Change dd.MM.yy, MM/dd/yy to 4 digit years if (format.count(QLatin1Char('y')) == 2) - format.insert(format.indexOf(QLatin1Char('y')), QLatin1String("yy")); + format.insert(format.indexOf(QLatin1Char('y')), "yy"_L1); return format; } @@ -241,14 +223,14 @@ QtBoolEdit::QtBoolEdit(QWidget *parent) : m_checkBox(new QCheckBox(this)), m_textVisible(true) { - QHBoxLayout *lt = new QHBoxLayout; + auto *lt = new QHBoxLayout; if (QApplication::layoutDirection() == Qt::LeftToRight) lt->setContentsMargins(4, 0, 0, 0); else lt->setContentsMargins(0, 0, 4, 0); lt->addWidget(m_checkBox); setLayout(lt); - connect(m_checkBox, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); + connect(m_checkBox, &QAbstractButton::toggled, this, &QtBoolEdit::toggled); setFocusProxy(m_checkBox); m_checkBox->setText(tr("True")); } diff --git a/src/shared/qtpropertybrowser/qtpropertybrowserutils_p.h b/src/shared/qtpropertybrowser/qtpropertybrowserutils_p.h index 08de7f0d7..60d19c26d 100644 --- a/src/shared/qtpropertybrowser/qtpropertybrowserutils_p.h +++ b/src/shared/qtpropertybrowser/qtpropertybrowserutils_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only // // W A R N I N G @@ -76,6 +40,9 @@ public: #ifndef QT_NO_CURSOR QCursor valueToCursor(int value) const; #endif + + static QtCursorDatabase *instance(); + private: void appendCursor(Qt::CursorShape shape, const QString &name, const QIcon &icon); QStringList m_cursorNames; diff --git a/src/shared/qtpropertybrowser/qtpropertymanager.cpp b/src/shared/qtpropertybrowser/qtpropertymanager.cpp index 728b0b1e0..e5ed1bf41 100644 --- a/src/shared/qtpropertybrowser/qtpropertymanager.cpp +++ b/src/shared/qtpropertybrowser/qtpropertymanager.cpp @@ -1,68 +1,55 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qtpropertymanager.h" #include "qtpropertybrowserutils_p.h" + #include <QtCore/QDateTime> +#include <QtCore/QHash> #include <QtCore/QLocale> #include <QtCore/QMap> -#include <QtCore/QTimer> -#include <QtCore/QRegularExpression> -#include <QtGui/QIcon> #include <QtCore/QMetaEnum> +#include <QtCore/QRegularExpression> +#include <QtCore/QTimer> #include <QtGui/QFontDatabase> -#include <QtWidgets/QStyleOption> -#include <QtWidgets/QStyle> -#include <QtWidgets/QApplication> +#include <QtGui/QIcon> #include <QtGui/QPainter> +#include <QtWidgets/QApplication> #include <QtWidgets/QLabel> +#include <QtWidgets/QStyle> +#include <QtWidgets/QStyleOption> #include <limits> #include <limits.h> #include <float.h> +#include <algorithm> +#include <utility> + #if defined(Q_CC_MSVC) # pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */ #endif QT_BEGIN_NAMESPACE +using DisambiguatedTranslation = std::pair<const char *, const char *>; + +static const QFont::Weight weightValues[] = { + QFont::Thin, QFont::ExtraLight, QFont::Light, QFont::Normal, QFont::Medium, QFont::DemiBold, + QFont::Bold, QFont::ExtraBold, QFont::Black +}; + +static int indexOfFontWeight(QFont::Weight w) +{ + auto it = std::find(std::begin(weightValues), std::end(weightValues), w); + return int(it - std::begin(weightValues)); +} + +static inline QFont::Weight weightFromIndex(int i) +{ + return weightValues[i]; +} + template <class PrivateData, class Value> static void setSimpleMinimumData(PrivateData *data, const Value &minVal) { @@ -185,7 +172,7 @@ void orderBorders(QSizeF &minVal, QSizeF &maxVal) //////// template <class Value, class PrivateData> -static Value getData(const QMap<const QtProperty *, PrivateData> &propertyMap, +static Value getData(const QHash<const QtProperty *, PrivateData> &propertyMap, Value PrivateData::*data, const QtProperty *property, const Value &defaultValue = Value()) { @@ -196,28 +183,28 @@ static Value getData(const QMap<const QtProperty *, PrivateData> &propertyMap, } template <class Value, class PrivateData> -static Value getValue(const QMap<const QtProperty *, PrivateData> &propertyMap, +static Value getValue(const QHash<const QtProperty *, PrivateData> &propertyMap, const QtProperty *property, const Value &defaultValue = Value()) { return getData<Value>(propertyMap, &PrivateData::val, property, defaultValue); } template <class Value, class PrivateData> -static Value getMinimum(const QMap<const QtProperty *, PrivateData> &propertyMap, +static Value getMinimum(const QHash<const QtProperty *, PrivateData> &propertyMap, const QtProperty *property, const Value &defaultValue = Value()) { return getData<Value>(propertyMap, &PrivateData::minVal, property, defaultValue); } template <class Value, class PrivateData> -static Value getMaximum(const QMap<const QtProperty *, PrivateData> &propertyMap, +static Value getMaximum(const QHash<const QtProperty *, PrivateData> &propertyMap, const QtProperty *property, const Value &defaultValue = Value()) { return getData<Value>(propertyMap, &PrivateData::maxVal, property, defaultValue); } template <class ValueChangeParameter, class Value, class PropertyManager> -static void setSimpleValue(QMap<const QtProperty *, Value> &propertyMap, +static void setSimpleValue(QHash<const QtProperty *, Value> &propertyMap, PropertyManager *manager, void (PropertyManager::*propertyChangedSignal)(QtProperty *), void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter), @@ -386,33 +373,35 @@ public: QStringList policyEnumNames() const { return m_policyEnumNames; } QStringList languageEnumNames() const { return m_languageEnumNames; } - QStringList countryEnumNames(QLocale::Language language) const { return m_countryEnumNames.value(language); } + QStringList territoryEnumNames(QLocale::Language language) const { return m_territoryEnumNames.value(language); } QSizePolicy::Policy indexToSizePolicy(int index) const; int sizePolicyToIndex(QSizePolicy::Policy policy) const; - void indexToLocale(int languageIndex, int countryIndex, QLocale::Language *language, QLocale::Country *country) const; - void localeToIndex(QLocale::Language language, QLocale::Country country, int *languageIndex, int *countryIndex) const; + void indexToLocale(int languageIndex, int territoryIndex, QLocale::Language *language, QLocale::Territory *territory) const; + void localeToIndex(QLocale::Language language, QLocale::Territory territory, int *languageIndex, int *territoryIndex) const; private: void initLocale(); QStringList m_policyEnumNames; QStringList m_languageEnumNames; - QMap<QLocale::Language, QStringList> m_countryEnumNames; + QMap<QLocale::Language, QStringList> m_territoryEnumNames; QMap<int, QLocale::Language> m_indexToLanguage; QMap<QLocale::Language, int> m_languageToIndex; - QMap<int, QMap<int, QLocale::Country> > m_indexToCountry; - QMap<QLocale::Language, QMap<QLocale::Country, int> > m_countryToIndex; + QMap<int, QMap<int, QLocale::Territory> > m_indexToTerritory; + QMap<QLocale::Language, QMap<QLocale::Territory, int> > m_territoryToIndex; QMetaEnum m_policyEnum; }; -static QList<QLocale::Country> sortCountries(const QList<QLocale::Country> &countries) +static QList<QLocale::Territory> sortedTerritories(const QList<QLocale> &locales) { - QMultiMap<QString, QLocale::Country> nameToCountry; - for (QLocale::Country country : countries) - nameToCountry.insert(QLocale::countryToString(country), country); - return nameToCountry.values(); + QMultiMap<QString, QLocale::Territory> nameToTerritory; + for (const QLocale &locale : locales) { + const auto territory = locale.territory(); + nameToTerritory.insert(QLocale::territoryToString(territory), territory); + } + return nameToTerritory.values(); } void QtMetaEnumProvider::initLocale() @@ -431,26 +420,24 @@ void QtMetaEnumProvider::initLocale() const auto languages = nameToLanguage.values(); for (QLocale::Language language : languages) { - QList<QLocale::Country> countries; - countries = QLocale::countriesForLanguage(language); - if (countries.isEmpty() && language == system.language()) - countries << system.country(); - - if (!countries.isEmpty() && !m_languageToIndex.contains(language)) { - countries = sortCountries(countries); - int langIdx = m_languageEnumNames.count(); + auto locales = QLocale::matchingLocales(language, QLocale::AnyScript, + QLocale::AnyTerritory); + + if (!locales.isEmpty() && !m_languageToIndex.contains(language)) { + const auto territories = sortedTerritories(locales); + int langIdx = m_languageEnumNames.size(); m_indexToLanguage[langIdx] = language; m_languageToIndex[language] = langIdx; - QStringList countryNames; - int countryIdx = 0; - for (QLocale::Country country : qAsConst(countries)) { - countryNames << QLocale::countryToString(country); - m_indexToCountry[langIdx][countryIdx] = country; - m_countryToIndex[language][country] = countryIdx; - ++countryIdx; + QStringList territoryNames; + int territoryIdx = 0; + for (QLocale::Territory territory : territories) { + territoryNames << QLocale::territoryToString(territory); + m_indexToTerritory[langIdx][territoryIdx] = territory; + m_territoryToIndex[language][territory] = territoryIdx; + ++territoryIdx; } m_languageEnumNames << QLocale::languageToString(language); - m_countryEnumNames[language] = countryNames; + m_territoryEnumNames[language] = territoryNames; } } } @@ -464,7 +451,7 @@ QtMetaEnumProvider::QtMetaEnumProvider() m_policyEnum = p.enumerator(); const int keyCount = m_policyEnum.keyCount(); for (int i = 0; i < keyCount; i++) - m_policyEnumNames << QLatin1String(m_policyEnum.key(i)); + m_policyEnumNames << QLatin1StringView(m_policyEnum.key(i)); initLocale(); } @@ -483,35 +470,35 @@ int QtMetaEnumProvider::sizePolicyToIndex(QSizePolicy::Policy policy) const return -1; } -void QtMetaEnumProvider::indexToLocale(int languageIndex, int countryIndex, QLocale::Language *language, QLocale::Country *country) const +void QtMetaEnumProvider::indexToLocale(int languageIndex, int territoryIndex, QLocale::Language *language, QLocale::Territory *territory) const { QLocale::Language l = QLocale::C; - QLocale::Country c = QLocale::AnyCountry; + QLocale::Territory c = QLocale::AnyTerritory; if (m_indexToLanguage.contains(languageIndex)) { l = m_indexToLanguage[languageIndex]; - if (m_indexToCountry.contains(languageIndex) && m_indexToCountry[languageIndex].contains(countryIndex)) - c = m_indexToCountry[languageIndex][countryIndex]; + if (m_indexToTerritory.contains(languageIndex) && m_indexToTerritory[languageIndex].contains(territoryIndex)) + c = m_indexToTerritory[languageIndex][territoryIndex]; } if (language) *language = l; - if (country) - *country = c; + if (territory) + *territory = c; } -void QtMetaEnumProvider::localeToIndex(QLocale::Language language, QLocale::Country country, int *languageIndex, int *countryIndex) const +void QtMetaEnumProvider::localeToIndex(QLocale::Language language, QLocale::Territory territory, int *languageIndex, int *territoryIndex) const { int l = -1; int c = -1; if (m_languageToIndex.contains(language)) { l = m_languageToIndex[language]; - if (m_countryToIndex.contains(language) && m_countryToIndex[language].contains(country)) - c = m_countryToIndex[language][country]; + if (m_territoryToIndex.contains(language) && m_territoryToIndex[language].contains(territory)) + c = m_territoryToIndex[language][territory]; } if (languageIndex) *languageIndex = l; - if (countryIndex) - *countryIndex = c; + if (territoryIndex) + *territoryIndex = c; } Q_GLOBAL_STATIC(QtMetaEnumProvider, metaEnumProvider) @@ -593,8 +580,7 @@ public: void setMaximumValue(int newMaxVal) { setSimpleMaximumData(this, newMaxVal); } }; - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, Data> m_values; }; /*! @@ -719,9 +705,9 @@ int QtIntPropertyManager::singleStep(const QtProperty *property) const */ QString QtIntPropertyManager::valueText(const QtProperty *property) const { - const QtIntPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; return QString::number(it.value().val); } @@ -738,7 +724,7 @@ QString QtIntPropertyManager::valueText(const QtProperty *property) const */ void QtIntPropertyManager::setValue(QtProperty *property, int val) { - void (QtIntPropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, int) = 0; + void (QtIntPropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, int) = nullptr; setValueInRange<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>(this, d_ptr.data(), &QtIntPropertyManager::propertyChanged, &QtIntPropertyManager::valueChanged, @@ -797,7 +783,7 @@ void QtIntPropertyManager::setMaximum(QtProperty *property, int maxVal) */ void QtIntPropertyManager::setRange(QtProperty *property, int minVal, int maxVal) { - void (QtIntPropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, int, int, int) = 0; + void (QtIntPropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, int, int, int) = nullptr; setBorderValues<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>(this, d_ptr.data(), &QtIntPropertyManager::propertyChanged, &QtIntPropertyManager::valueChanged, @@ -814,7 +800,7 @@ void QtIntPropertyManager::setRange(QtProperty *property, int minVal, int maxVal */ void QtIntPropertyManager::setSingleStep(QtProperty *property, int step) { - const QtIntPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -870,8 +856,7 @@ public: void setMaximumValue(double newMaxVal) { setSimpleMaximumData(this, newMaxVal); } }; - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, Data> m_values; }; /*! @@ -1017,9 +1002,9 @@ int QtDoublePropertyManager::decimals(const QtProperty *property) const */ QString QtDoublePropertyManager::valueText(const QtProperty *property) const { - const QtDoublePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; return QString::number(it.value().val, 'f', it.value().decimals); } @@ -1036,7 +1021,7 @@ QString QtDoublePropertyManager::valueText(const QtProperty *property) const */ void QtDoublePropertyManager::setValue(QtProperty *property, double val) { - void (QtDoublePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, double) = 0; + void (QtDoublePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, double) = nullptr; setValueInRange<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(this, d_ptr.data(), &QtDoublePropertyManager::propertyChanged, &QtDoublePropertyManager::valueChanged, @@ -1052,7 +1037,7 @@ void QtDoublePropertyManager::setValue(QtProperty *property, double val) */ void QtDoublePropertyManager::setSingleStep(QtProperty *property, double step) { - const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -1082,7 +1067,7 @@ void QtDoublePropertyManager::setSingleStep(QtProperty *property, double step) */ void QtDoublePropertyManager::setDecimals(QtProperty *property, int prec) { - const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -1155,7 +1140,7 @@ void QtDoublePropertyManager::setMaximum(QtProperty *property, double maxVal) */ void QtDoublePropertyManager::setRange(QtProperty *property, double minVal, double maxVal) { - void (QtDoublePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, double, double, double) = 0; + void (QtDoublePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, double, double, double) = nullptr; setBorderValues<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(this, d_ptr.data(), &QtDoublePropertyManager::propertyChanged, &QtDoublePropertyManager::valueChanged, @@ -1193,8 +1178,7 @@ public: QRegularExpression regExp; }; - typedef QMap<const QtProperty *, Data> PropertyValueMap; - QMap<const QtProperty *, Data> m_values; + QHash<const QtProperty *, Data> m_values; }; /*! @@ -1288,9 +1272,9 @@ QRegularExpression QtStringPropertyManager::regExp(const QtProperty *property) c */ QString QtStringPropertyManager::valueText(const QtProperty *property) const { - const QtStringPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; return it.value().val; } @@ -1306,7 +1290,7 @@ QString QtStringPropertyManager::valueText(const QtProperty *property) const */ void QtStringPropertyManager::setValue(QtProperty *property, const QString &val) { - const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -1335,7 +1319,7 @@ void QtStringPropertyManager::setValue(QtProperty *property, const QString &val) */ void QtStringPropertyManager::setRegExp(QtProperty *property, const QRegularExpression ®Exp) { - const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -1405,7 +1389,7 @@ class QtBoolPropertyManagerPrivate public: QtBoolPropertyManagerPrivate(); - QMap<const QtProperty *, bool> m_values; + QHash<const QtProperty *, bool> m_values; const QIcon m_checkedIcon; const QIcon m_uncheckedIcon; }; @@ -1477,9 +1461,9 @@ bool QtBoolPropertyManager::value(const QtProperty *property) const */ QString QtBoolPropertyManager::valueText(const QtProperty *property) const { - const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; static const QString trueText = tr("True"); static const QString falseText = tr("False"); @@ -1491,9 +1475,9 @@ QString QtBoolPropertyManager::valueText(const QtProperty *property) const */ QIcon QtBoolPropertyManager::valueIcon(const QtProperty *property) const { - const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QIcon(); + return {}; return it.value() ? d_ptr->m_checkedIcon : d_ptr->m_uncheckedIcon; } @@ -1551,8 +1535,7 @@ public: QString m_format; - typedef QMap<const QtProperty *, Data> PropertyValueMap; - QMap<const QtProperty *, Data> m_values; + QHash<const QtProperty *, Data> m_values; }; QtDatePropertyManagerPrivate::QtDatePropertyManagerPrivate(QtDatePropertyManager *q) : @@ -1660,9 +1643,9 @@ QDate QtDatePropertyManager::maximum(const QtProperty *property) const */ QString QtDatePropertyManager::valueText(const QtProperty *property) const { - const QtDatePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; return it.value().val.toString(d_ptr->m_format); } @@ -1679,7 +1662,7 @@ QString QtDatePropertyManager::valueText(const QtProperty *property) const */ void QtDatePropertyManager::setValue(QtProperty *property, QDate val) { - void (QtDatePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, QDate) = 0; + void (QtDatePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, QDate) = nullptr; setValueInRange<QDate, QtDatePropertyManagerPrivate, QtDatePropertyManager, const QDate>(this, d_ptr.data(), &QtDatePropertyManager::propertyChanged, &QtDatePropertyManager::valueChanged, @@ -1738,7 +1721,7 @@ void QtDatePropertyManager::setMaximum(QtProperty *property, QDate maxVal) */ void QtDatePropertyManager::setRange(QtProperty *property, QDate minVal, QDate maxVal) { - void (QtDatePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, QDate, QDate, QDate) = 0; + void (QtDatePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, QDate, QDate, QDate) = nullptr; setBorderValues<QDate, QtDatePropertyManagerPrivate, QtDatePropertyManager, QDate>(this, d_ptr.data(), &QtDatePropertyManager::propertyChanged, &QtDatePropertyManager::valueChanged, @@ -1773,8 +1756,7 @@ public: const QString m_format; - typedef QMap<const QtProperty *, QTime> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, QTime> m_values; }; QtTimePropertyManagerPrivate::QtTimePropertyManagerPrivate(QtTimePropertyManager *q) : @@ -1845,9 +1827,9 @@ QTime QtTimePropertyManager::value(const QtProperty *property) const */ QString QtTimePropertyManager::valueText(const QtProperty *property) const { - const QtTimePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; return it.value().toString(d_ptr->m_format); } @@ -1893,8 +1875,7 @@ public: const QString m_format; - typedef QMap<const QtProperty *, QDateTime> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, QDateTime> m_values; }; QtDateTimePropertyManagerPrivate::QtDateTimePropertyManagerPrivate(QtDateTimePropertyManager *q) : @@ -1961,9 +1942,9 @@ QDateTime QtDateTimePropertyManager::value(const QtProperty *property) const */ QString QtDateTimePropertyManager::valueText(const QtProperty *property) const { - const QtDateTimePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; return it.value().toString(d_ptr->m_format); } @@ -2008,8 +1989,7 @@ public: QString m_format; - typedef QMap<const QtProperty *, QKeySequence> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, QKeySequence> m_values; }; /*! \class QtKeySequencePropertyManager @@ -2072,9 +2052,9 @@ QKeySequence QtKeySequencePropertyManager::value(const QtProperty *property) con */ QString QtKeySequencePropertyManager::valueText(const QtProperty *property) const { - const QtKeySequencePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; return it.value().toString(QKeySequence::NativeText); } @@ -2117,8 +2097,7 @@ class QtCharPropertyManagerPrivate Q_DECLARE_PUBLIC(QtCharPropertyManager) public: - typedef QMap<const QtProperty *, QChar> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, QChar> m_values; }; /*! \class QtCharPropertyManager @@ -2181,9 +2160,9 @@ QChar QtCharPropertyManager::value(const QtProperty *property) const */ QString QtCharPropertyManager::valueText(const QtProperty *property) const { - const QtCharPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; const QChar c = it.value(); return c.isNull() ? QString() : QString(c); } @@ -2227,54 +2206,47 @@ class QtLocalePropertyManagerPrivate Q_DECLARE_PUBLIC(QtLocalePropertyManager) public: - QtLocalePropertyManagerPrivate(); - void slotEnumChanged(QtProperty *property, int value); void slotPropertyDestroyed(QtProperty *property); - typedef QMap<const QtProperty *, QLocale> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, QLocale> m_values; - QtEnumPropertyManager *m_enumPropertyManager; + QtEnumPropertyManager *m_enumPropertyManager = nullptr; - QMap<const QtProperty *, QtProperty *> m_propertyToLanguage; - QMap<const QtProperty *, QtProperty *> m_propertyToCountry; + QHash<const QtProperty *, QtProperty *> m_propertyToLanguage; + QHash<const QtProperty *, QtProperty *> m_propertyToTerritory; - QMap<const QtProperty *, QtProperty *> m_languageToProperty; - QMap<const QtProperty *, QtProperty *> m_countryToProperty; + QHash<const QtProperty *, QtProperty *> m_languageToProperty; + QHash<const QtProperty *, QtProperty *> m_territoryToProperty; }; -QtLocalePropertyManagerPrivate::QtLocalePropertyManagerPrivate() -{ -} - void QtLocalePropertyManagerPrivate::slotEnumChanged(QtProperty *property, int value) { - if (QtProperty *prop = m_languageToProperty.value(property, 0)) { + if (QtProperty *prop = m_languageToProperty.value(property, nullptr)) { const QLocale loc = m_values[prop]; QLocale::Language newLanguage = loc.language(); - QLocale::Country newCountry = loc.country(); + QLocale::Territory newTerritory = loc.territory(); metaEnumProvider()->indexToLocale(value, 0, &newLanguage, 0); - QLocale newLoc(newLanguage, newCountry); + QLocale newLoc(newLanguage, newTerritory); q_ptr->setValue(prop, newLoc); - } else if (QtProperty *prop = m_countryToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_territoryToProperty.value(property, nullptr)) { const QLocale loc = m_values[prop]; QLocale::Language newLanguage = loc.language(); - QLocale::Country newCountry = loc.country(); - metaEnumProvider()->indexToLocale(m_enumPropertyManager->value(m_propertyToLanguage.value(prop)), value, &newLanguage, &newCountry); - QLocale newLoc(newLanguage, newCountry); + QLocale::Territory newTerritory = loc.territory(); + metaEnumProvider()->indexToLocale(m_enumPropertyManager->value(m_propertyToLanguage.value(prop)), value, &newLanguage, &newTerritory); + QLocale newLoc(newLanguage, newTerritory); q_ptr->setValue(prop, newLoc); } } void QtLocalePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { - if (QtProperty *subProp = m_languageToProperty.value(property, 0)) { - m_propertyToLanguage[subProp] = 0; + if (QtProperty *subProp = m_languageToProperty.value(property, nullptr)) { + m_propertyToLanguage[subProp] = nullptr; m_languageToProperty.remove(property); - } else if (QtProperty *subProp = m_countryToProperty.value(property, 0)) { - m_propertyToCountry[subProp] = 0; - m_countryToProperty.remove(property); + } else if (QtProperty *subProp = m_territoryToProperty.value(property, nullptr)) { + m_propertyToTerritory[subProp] = nullptr; + m_territoryToProperty.remove(property); } } @@ -2286,7 +2258,7 @@ void QtLocalePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) \brief The QtLocalePropertyManager provides and manages QLocale properties. - A locale property has nested \e language and \e country + A locale property has nested \e language and \e territory subproperties. The top-level property's value can be retrieved using the value() function, and set using the setValue() slot. @@ -2321,11 +2293,10 @@ QtLocalePropertyManager::QtLocalePropertyManager(QObject *parent) d_ptr->q_ptr = this; d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); - connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotEnumChanged(QtProperty*,int))); - - connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); + connect(d_ptr->m_enumPropertyManager, &QtEnumPropertyManager::valueChanged, this, + [this](QtProperty *property, int value) { d_ptr->slotEnumChanged(property, value); }); + connect(d_ptr->m_enumPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); } /*! @@ -2338,7 +2309,7 @@ QtLocalePropertyManager::~QtLocalePropertyManager() /*! Returns the manager that creates the nested \e language - and \e country subproperties. + and \e territory subproperties. In order to provide editing widgets for the mentioned subproperties in a property browser widget, this manager must be associated with @@ -2369,27 +2340,27 @@ QLocale QtLocalePropertyManager::value(const QtProperty *property) const */ QString QtLocalePropertyManager::valueText(const QtProperty *property) const { - const QtLocalePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; const QLocale loc = it.value(); int langIdx = 0; - int countryIdx = 0; + int territoryIdx = 0; const QtMetaEnumProvider *me = metaEnumProvider(); - me->localeToIndex(loc.language(), loc.country(), &langIdx, &countryIdx); + me->localeToIndex(loc.language(), loc.territory(), &langIdx, &territoryIdx); if (langIdx < 0) { qWarning("QtLocalePropertyManager::valueText: Unknown language %d", loc.language()); return tr("<Invalid>"); } const QString languageName = me->languageEnumNames().at(langIdx); - if (countryIdx < 0) { - qWarning("QtLocalePropertyManager::valueText: Unknown country %d for %s", loc.country(), qPrintable(languageName)); + if (territoryIdx < 0) { + qWarning("QtLocalePropertyManager::valueText: Unknown territory %d for %s", loc.territory(), qPrintable(languageName)); return languageName; } - const QString countryName = me->countryEnumNames(loc.language()).at(countryIdx); - return tr("%1, %2").arg(languageName, countryName); + const QString territoryName = me->territoryEnumNames(loc.language()).at(territoryIdx); + return tr("%1, %2").arg(languageName, territoryName); } /*! @@ -2402,7 +2373,7 @@ QString QtLocalePropertyManager::valueText(const QtProperty *property) const */ void QtLocalePropertyManager::setValue(QtProperty *property, const QLocale &val) { - const QtLocalePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -2413,14 +2384,14 @@ void QtLocalePropertyManager::setValue(QtProperty *property, const QLocale &val) it.value() = val; int langIdx = 0; - int countryIdx = 0; - metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx); + int territoryIdx = 0; + metaEnumProvider()->localeToIndex(val.language(), val.territory(), &langIdx, &territoryIdx); if (loc.language() != val.language()) { d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToLanguage.value(property), langIdx); - d_ptr->m_enumPropertyManager->setEnumNames(d_ptr->m_propertyToCountry.value(property), - metaEnumProvider()->countryEnumNames(val.language())); + d_ptr->m_enumPropertyManager->setEnumNames(d_ptr->m_propertyToTerritory.value(property), + metaEnumProvider()->territoryEnumNames(val.language())); } - d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToCountry.value(property), countryIdx); + d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToTerritory.value(property), territoryIdx); emit propertyChanged(property); emit valueChanged(property, val); @@ -2435,8 +2406,8 @@ void QtLocalePropertyManager::initializeProperty(QtProperty *property) d_ptr->m_values[property] = val; int langIdx = 0; - int countryIdx = 0; - metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx); + int territoryIdx = 0; + metaEnumProvider()->localeToIndex(val.language(), val.territory(), &langIdx, &territoryIdx); QtProperty *languageProp = d_ptr->m_enumPropertyManager->addProperty(); languageProp->setPropertyName(tr("Language")); @@ -2446,13 +2417,13 @@ void QtLocalePropertyManager::initializeProperty(QtProperty *property) d_ptr->m_languageToProperty[languageProp] = property; property->addSubProperty(languageProp); - QtProperty *countryProp = d_ptr->m_enumPropertyManager->addProperty(); - countryProp->setPropertyName(tr("Country")); - d_ptr->m_enumPropertyManager->setEnumNames(countryProp, metaEnumProvider()->countryEnumNames(val.language())); - d_ptr->m_enumPropertyManager->setValue(countryProp, countryIdx); - d_ptr->m_propertyToCountry[property] = countryProp; - d_ptr->m_countryToProperty[countryProp] = property; - property->addSubProperty(countryProp); + QtProperty *territoryProp = d_ptr->m_enumPropertyManager->addProperty(); + territoryProp->setPropertyName(tr("Territory")); + d_ptr->m_enumPropertyManager->setEnumNames(territoryProp, metaEnumProvider()->territoryEnumNames(val.language())); + d_ptr->m_enumPropertyManager->setValue(territoryProp, territoryIdx); + d_ptr->m_propertyToTerritory[property] = territoryProp; + d_ptr->m_territoryToProperty[territoryProp] = property; + property->addSubProperty(territoryProp); } /*! @@ -2467,12 +2438,12 @@ void QtLocalePropertyManager::uninitializeProperty(QtProperty *property) } d_ptr->m_propertyToLanguage.remove(property); - QtProperty *countryProp = d_ptr->m_propertyToCountry[property]; - if (countryProp) { - d_ptr->m_countryToProperty.remove(countryProp); - delete countryProp; + QtProperty *territoryProp = d_ptr->m_propertyToTerritory[property]; + if (territoryProp) { + d_ptr->m_territoryToProperty.remove(territoryProp); + delete territoryProp; } - d_ptr->m_propertyToCountry.remove(property); + d_ptr->m_propertyToTerritory.remove(property); d_ptr->m_values.remove(property); } @@ -2488,25 +2459,24 @@ public: void slotIntChanged(QtProperty *property, int value); void slotPropertyDestroyed(QtProperty *property); - typedef QMap<const QtProperty *, QPoint> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, QPoint> m_values; QtIntPropertyManager *m_intPropertyManager; - QMap<const QtProperty *, QtProperty *> m_propertyToX; - QMap<const QtProperty *, QtProperty *> m_propertyToY; + QHash<const QtProperty *, QtProperty *> m_propertyToX; + QHash<const QtProperty *, QtProperty *> m_propertyToY; - QMap<const QtProperty *, QtProperty *> m_xToProperty; - QMap<const QtProperty *, QtProperty *> m_yToProperty; + QHash<const QtProperty *, QtProperty *> m_xToProperty; + QHash<const QtProperty *, QtProperty *> m_yToProperty; }; void QtPointPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value) { - if (QtProperty *xprop = m_xToProperty.value(property, 0)) { + if (QtProperty *xprop = m_xToProperty.value(property, nullptr)) { QPoint p = m_values[xprop]; p.setX(value); q_ptr->setValue(xprop, p); - } else if (QtProperty *yprop = m_yToProperty.value(property, 0)) { + } else if (QtProperty *yprop = m_yToProperty.value(property, nullptr)) { QPoint p = m_values[yprop]; p.setY(value); q_ptr->setValue(yprop, p); @@ -2515,11 +2485,11 @@ void QtPointPropertyManagerPrivate::slotIntChanged(QtProperty *property, int val void QtPointPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { - if (QtProperty *pointProp = m_xToProperty.value(property, 0)) { - m_propertyToX[pointProp] = 0; + if (QtProperty *pointProp = m_xToProperty.value(property, nullptr)) { + m_propertyToX[pointProp] = nullptr; m_xToProperty.remove(property); - } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) { - m_propertyToY[pointProp] = 0; + } else if (QtProperty *pointProp = m_yToProperty.value(property, nullptr)) { + m_propertyToY[pointProp] = nullptr; m_yToProperty.remove(property); } } @@ -2566,10 +2536,10 @@ QtPointPropertyManager::QtPointPropertyManager(QObject *parent) d_ptr->q_ptr = this; d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotIntChanged(QtProperty*,int))); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); + connect(d_ptr->m_intPropertyManager, &QtIntPropertyManager::valueChanged, this, + [this](QtProperty *property, int value) { d_ptr->slotIntChanged(property, value); }); + connect(d_ptr->m_intPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); } /*! @@ -2613,12 +2583,11 @@ QPoint QtPointPropertyManager::value(const QtProperty *property) const */ QString QtPointPropertyManager::valueText(const QtProperty *property) const { - const QtPointPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; const QPoint v = it.value(); - return tr("(%1, %2)").arg(QString::number(v.x())) - .arg(QString::number(v.y())); + return tr("(%1, %2)").arg(v.x()).arg(v.y()); } /*! @@ -2631,7 +2600,7 @@ QString QtPointPropertyManager::valueText(const QtProperty *property) const */ void QtPointPropertyManager::setValue(QtProperty *property, const QPoint &val) { - const QtPointPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -2707,25 +2676,24 @@ public: void slotDoubleChanged(QtProperty *property, double value); void slotPropertyDestroyed(QtProperty *property); - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, Data> m_values; QtDoublePropertyManager *m_doublePropertyManager; - QMap<const QtProperty *, QtProperty *> m_propertyToX; - QMap<const QtProperty *, QtProperty *> m_propertyToY; + QHash<const QtProperty *, QtProperty *> m_propertyToX; + QHash<const QtProperty *, QtProperty *> m_propertyToY; - QMap<const QtProperty *, QtProperty *> m_xToProperty; - QMap<const QtProperty *, QtProperty *> m_yToProperty; + QHash<const QtProperty *, QtProperty *> m_xToProperty; + QHash<const QtProperty *, QtProperty *> m_yToProperty; }; void QtPointFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, double value) { - if (QtProperty *prop = m_xToProperty.value(property, 0)) { + if (QtProperty *prop = m_xToProperty.value(property, nullptr)) { QPointF p = m_values[prop].val; p.setX(value); q_ptr->setValue(prop, p); - } else if (QtProperty *prop = m_yToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_yToProperty.value(property, nullptr)) { QPointF p = m_values[prop].val; p.setY(value); q_ptr->setValue(prop, p); @@ -2734,11 +2702,11 @@ void QtPointFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, dou void QtPointFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { - if (QtProperty *pointProp = m_xToProperty.value(property, 0)) { - m_propertyToX[pointProp] = 0; + if (QtProperty *pointProp = m_xToProperty.value(property, nullptr)) { + m_propertyToX[pointProp] = nullptr; m_xToProperty.remove(property); - } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) { - m_propertyToY[pointProp] = 0; + } else if (QtProperty *pointProp = m_yToProperty.value(property, nullptr)) { + m_propertyToY[pointProp] = nullptr; m_yToProperty.remove(property); } } @@ -2795,10 +2763,10 @@ QtPointFPropertyManager::QtPointFPropertyManager(QObject *parent) d_ptr->q_ptr = this; d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this); - connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(QtProperty*,double)), - this, SLOT(slotDoubleChanged(QtProperty*,double))); - connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); + connect(d_ptr->m_doublePropertyManager, &QtDoublePropertyManager::valueChanged, this, + [this](QtProperty *property, double value) { d_ptr->slotDoubleChanged(property, value); }); + connect(d_ptr->m_doublePropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); } /*! @@ -2852,13 +2820,13 @@ int QtPointFPropertyManager::decimals(const QtProperty *property) const */ QString QtPointFPropertyManager::valueText(const QtProperty *property) const { - const QtPointFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; const QPointF v = it.value().val; const int dec = it.value().decimals; - return tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec)) - .arg(QString::number(v.y(), 'f', dec)); + return tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec), + QString::number(v.y(), 'f', dec)); } /*! @@ -2871,7 +2839,7 @@ QString QtPointFPropertyManager::valueText(const QtProperty *property) const */ void QtPointFPropertyManager::setValue(QtProperty *property, const QPointF &val) { - const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -2897,7 +2865,7 @@ void QtPointFPropertyManager::setValue(QtProperty *property, const QPointF &val) */ void QtPointFPropertyManager::setDecimals(QtProperty *property, int prec) { - const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -2991,25 +2959,24 @@ public: void setMaximumValue(const QSize &newMaxVal) { setSizeMaximumData(this, newMaxVal); } }; - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, Data> m_values; QtIntPropertyManager *m_intPropertyManager; - QMap<const QtProperty *, QtProperty *> m_propertyToW; - QMap<const QtProperty *, QtProperty *> m_propertyToH; + QHash<const QtProperty *, QtProperty *> m_propertyToW; + QHash<const QtProperty *, QtProperty *> m_propertyToH; - QMap<const QtProperty *, QtProperty *> m_wToProperty; - QMap<const QtProperty *, QtProperty *> m_hToProperty; + QHash<const QtProperty *, QtProperty *> m_wToProperty; + QHash<const QtProperty *, QtProperty *> m_hToProperty; }; void QtSizePropertyManagerPrivate::slotIntChanged(QtProperty *property, int value) { - if (QtProperty *prop = m_wToProperty.value(property, 0)) { + if (QtProperty *prop = m_wToProperty.value(property, nullptr)) { QSize s = m_values[prop].val; s.setWidth(value); q_ptr->setValue(prop, s); - } else if (QtProperty *prop = m_hToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_hToProperty.value(property, nullptr)) { QSize s = m_values[prop].val; s.setHeight(value); q_ptr->setValue(prop, s); @@ -3018,11 +2985,11 @@ void QtSizePropertyManagerPrivate::slotIntChanged(QtProperty *property, int valu void QtSizePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { - if (QtProperty *pointProp = m_wToProperty.value(property, 0)) { - m_propertyToW[pointProp] = 0; + if (QtProperty *pointProp = m_wToProperty.value(property, nullptr)) { + m_propertyToW[pointProp] = nullptr; m_wToProperty.remove(property); - } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) { - m_propertyToH[pointProp] = 0; + } else if (QtProperty *pointProp = m_hToProperty.value(property, nullptr)) { + m_propertyToH[pointProp] = nullptr; m_hToProperty.remove(property); } } @@ -3105,10 +3072,10 @@ QtSizePropertyManager::QtSizePropertyManager(QObject *parent) d_ptr->q_ptr = this; d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotIntChanged(QtProperty*,int))); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); + connect(d_ptr->m_intPropertyManager, &QtIntPropertyManager::valueChanged, this, + [this](QtProperty *property, int value) { d_ptr->slotIntChanged(property, value); }); + connect(d_ptr->m_intPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); } /*! @@ -3172,12 +3139,11 @@ QSize QtSizePropertyManager::maximum(const QtProperty *property) const */ QString QtSizePropertyManager::valueText(const QtProperty *property) const { - const QtSizePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; const QSize v = it.value().val; - return tr("%1 x %2").arg(QString::number(v.width())) - .arg(QString::number(v.height())); + return tr("%1 x %2").arg(v.width()).arg(v.height()); } /*! @@ -3336,25 +3302,24 @@ public: void setMaximumValue(const QSizeF &newMaxVal) { setSizeMaximumData(this, newMaxVal); } }; - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, Data> m_values; QtDoublePropertyManager *m_doublePropertyManager; - QMap<const QtProperty *, QtProperty *> m_propertyToW; - QMap<const QtProperty *, QtProperty *> m_propertyToH; + QHash<const QtProperty *, QtProperty *> m_propertyToW; + QHash<const QtProperty *, QtProperty *> m_propertyToH; - QMap<const QtProperty *, QtProperty *> m_wToProperty; - QMap<const QtProperty *, QtProperty *> m_hToProperty; + QHash<const QtProperty *, QtProperty *> m_wToProperty; + QHash<const QtProperty *, QtProperty *> m_hToProperty; }; void QtSizeFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, double value) { - if (QtProperty *prop = m_wToProperty.value(property, 0)) { + if (QtProperty *prop = m_wToProperty.value(property, nullptr)) { QSizeF s = m_values[prop].val; s.setWidth(value); q_ptr->setValue(prop, s); - } else if (QtProperty *prop = m_hToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_hToProperty.value(property, nullptr)) { QSizeF s = m_values[prop].val; s.setHeight(value); q_ptr->setValue(prop, s); @@ -3363,11 +3328,11 @@ void QtSizeFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, doub void QtSizeFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { - if (QtProperty *pointProp = m_wToProperty.value(property, 0)) { - m_propertyToW[pointProp] = 0; + if (QtProperty *pointProp = m_wToProperty.value(property, nullptr)) { + m_propertyToW[pointProp] = nullptr; m_wToProperty.remove(property); - } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) { - m_propertyToH[pointProp] = 0; + } else if (QtProperty *pointProp = m_hToProperty.value(property, nullptr)) { + m_propertyToH[pointProp] = nullptr; m_hToProperty.remove(property); } } @@ -3458,10 +3423,10 @@ QtSizeFPropertyManager::QtSizeFPropertyManager(QObject *parent) d_ptr->q_ptr = this; d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this); - connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(QtProperty*,double)), - this, SLOT(slotDoubleChanged(QtProperty*,double))); - connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); + connect(d_ptr->m_doublePropertyManager, &QtDoublePropertyManager::valueChanged, this, + [this](QtProperty *property, double value) { d_ptr->slotDoubleChanged(property, value); }); + connect(d_ptr->m_doublePropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); } /*! @@ -3535,13 +3500,13 @@ QSizeF QtSizeFPropertyManager::maximum(const QtProperty *property) const */ QString QtSizeFPropertyManager::valueText(const QtProperty *property) const { - const QtSizeFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; const QSizeF v = it.value().val; const int dec = it.value().decimals; - return tr("%1 x %2").arg(QString::number(v.width(), 'f', dec)) - .arg(QString::number(v.height(), 'f', dec)); + return tr("%1 x %2").arg(QString::number(v.width(), 'f', dec), + QString::number(v.height(), 'f', dec)); } /*! @@ -3574,7 +3539,7 @@ void QtSizeFPropertyManager::setValue(QtProperty *property, const QSizeF &val) */ void QtSizeFPropertyManager::setDecimals(QtProperty *property, int prec) { - const QtSizeFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -3728,25 +3693,24 @@ public: QRect constraint; }; - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, Data> m_values; QtIntPropertyManager *m_intPropertyManager; - QMap<const QtProperty *, QtProperty *> m_propertyToX; - QMap<const QtProperty *, QtProperty *> m_propertyToY; - QMap<const QtProperty *, QtProperty *> m_propertyToW; - QMap<const QtProperty *, QtProperty *> m_propertyToH; + QHash<const QtProperty *, QtProperty *> m_propertyToX; + QHash<const QtProperty *, QtProperty *> m_propertyToY; + QHash<const QtProperty *, QtProperty *> m_propertyToW; + QHash<const QtProperty *, QtProperty *> m_propertyToH; - QMap<const QtProperty *, QtProperty *> m_xToProperty; - QMap<const QtProperty *, QtProperty *> m_yToProperty; - QMap<const QtProperty *, QtProperty *> m_wToProperty; - QMap<const QtProperty *, QtProperty *> m_hToProperty; + QHash<const QtProperty *, QtProperty *> m_xToProperty; + QHash<const QtProperty *, QtProperty *> m_yToProperty; + QHash<const QtProperty *, QtProperty *> m_wToProperty; + QHash<const QtProperty *, QtProperty *> m_hToProperty; }; void QtRectPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value) { - if (QtProperty *prop = m_xToProperty.value(property, 0)) { + if (QtProperty *prop = m_xToProperty.value(property, nullptr)) { QRect r = m_values[prop].val; r.moveLeft(value); q_ptr->setValue(prop, r); @@ -3754,7 +3718,7 @@ void QtRectPropertyManagerPrivate::slotIntChanged(QtProperty *property, int valu QRect r = m_values[prop].val; r.moveTop(value); q_ptr->setValue(prop, r); - } else if (QtProperty *prop = m_wToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_wToProperty.value(property, nullptr)) { Data data = m_values[prop]; QRect r = data.val; r.setWidth(value); @@ -3762,7 +3726,7 @@ void QtRectPropertyManagerPrivate::slotIntChanged(QtProperty *property, int valu r.moveLeft(data.constraint.left() + data.constraint.width() - r.width()); } q_ptr->setValue(prop, r); - } else if (QtProperty *prop = m_hToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_hToProperty.value(property, nullptr)) { Data data = m_values[prop]; QRect r = data.val; r.setHeight(value); @@ -3775,17 +3739,17 @@ void QtRectPropertyManagerPrivate::slotIntChanged(QtProperty *property, int valu void QtRectPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { - if (QtProperty *pointProp = m_xToProperty.value(property, 0)) { - m_propertyToX[pointProp] = 0; + if (QtProperty *pointProp = m_xToProperty.value(property, nullptr)) { + m_propertyToX[pointProp] = nullptr; m_xToProperty.remove(property); - } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) { - m_propertyToY[pointProp] = 0; + } else if (QtProperty *pointProp = m_yToProperty.value(property, nullptr)) { + m_propertyToY[pointProp] = nullptr; m_yToProperty.remove(property); - } else if (QtProperty *pointProp = m_wToProperty.value(property, 0)) { - m_propertyToW[pointProp] = 0; + } else if (QtProperty *pointProp = m_wToProperty.value(property, nullptr)) { + m_propertyToW[pointProp] = nullptr; m_wToProperty.remove(property); - } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) { - m_propertyToH[pointProp] = 0; + } else if (QtProperty *pointProp = m_hToProperty.value(property, nullptr)) { + m_propertyToH[pointProp] = nullptr; m_hToProperty.remove(property); } } @@ -3871,10 +3835,10 @@ QtRectPropertyManager::QtRectPropertyManager(QObject *parent) d_ptr->q_ptr = this; d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotIntChanged(QtProperty*,int))); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); + connect(d_ptr->m_intPropertyManager, &QtIntPropertyManager::valueChanged, this, + [this](QtProperty *property, int value) { d_ptr->slotIntChanged(property, value); }); + connect(d_ptr->m_intPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); } /*! @@ -3928,14 +3892,12 @@ QRect QtRectPropertyManager::constraint(const QtProperty *property) const */ QString QtRectPropertyManager::valueText(const QtProperty *property) const { - const QtRectPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; const QRect v = it.value().val; - return tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x())) - .arg(QString::number(v.y())) - .arg(QString::number(v.width())) - .arg(QString::number(v.height())); + return tr("[(%1, %2), %3 x %4]").arg(v.x()) .arg(v.y()) + .arg(v.width()).arg(v.height()); } /*! @@ -3952,7 +3914,7 @@ QString QtRectPropertyManager::valueText(const QtProperty *property) const */ void QtRectPropertyManager::setValue(QtProperty *property, const QRect &val) { - const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -3997,7 +3959,7 @@ void QtRectPropertyManager::setValue(QtProperty *property, const QRect &val) */ void QtRectPropertyManager::setConstraint(QtProperty *property, const QRect &constraint) { - const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -4137,33 +4099,32 @@ public: int decimals{2}; }; - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, Data> m_values; QtDoublePropertyManager *m_doublePropertyManager; - QMap<const QtProperty *, QtProperty *> m_propertyToX; - QMap<const QtProperty *, QtProperty *> m_propertyToY; - QMap<const QtProperty *, QtProperty *> m_propertyToW; - QMap<const QtProperty *, QtProperty *> m_propertyToH; + QHash<const QtProperty *, QtProperty *> m_propertyToX; + QHash<const QtProperty *, QtProperty *> m_propertyToY; + QHash<const QtProperty *, QtProperty *> m_propertyToW; + QHash<const QtProperty *, QtProperty *> m_propertyToH; - QMap<const QtProperty *, QtProperty *> m_xToProperty; - QMap<const QtProperty *, QtProperty *> m_yToProperty; - QMap<const QtProperty *, QtProperty *> m_wToProperty; - QMap<const QtProperty *, QtProperty *> m_hToProperty; + QHash<const QtProperty *, QtProperty *> m_xToProperty; + QHash<const QtProperty *, QtProperty *> m_yToProperty; + QHash<const QtProperty *, QtProperty *> m_wToProperty; + QHash<const QtProperty *, QtProperty *> m_hToProperty; }; void QtRectFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, double value) { - if (QtProperty *prop = m_xToProperty.value(property, 0)) { + if (QtProperty *prop = m_xToProperty.value(property, nullptr)) { QRectF r = m_values[prop].val; r.moveLeft(value); q_ptr->setValue(prop, r); - } else if (QtProperty *prop = m_yToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_yToProperty.value(property, nullptr)) { QRectF r = m_values[prop].val; r.moveTop(value); q_ptr->setValue(prop, r); - } else if (QtProperty *prop = m_wToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_wToProperty.value(property, nullptr)) { Data data = m_values[prop]; QRectF r = data.val; r.setWidth(value); @@ -4171,7 +4132,7 @@ void QtRectFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, doub r.moveLeft(data.constraint.left() + data.constraint.width() - r.width()); } q_ptr->setValue(prop, r); - } else if (QtProperty *prop = m_hToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_hToProperty.value(property, nullptr)) { Data data = m_values[prop]; QRectF r = data.val; r.setHeight(value); @@ -4184,17 +4145,17 @@ void QtRectFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, doub void QtRectFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { - if (QtProperty *pointProp = m_xToProperty.value(property, 0)) { - m_propertyToX[pointProp] = 0; + if (QtProperty *pointProp = m_xToProperty.value(property, nullptr)) { + m_propertyToX[pointProp] = nullptr; m_xToProperty.remove(property); - } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) { - m_propertyToY[pointProp] = 0; + } else if (QtProperty *pointProp = m_yToProperty.value(property, nullptr)) { + m_propertyToY[pointProp] = nullptr; m_yToProperty.remove(property); - } else if (QtProperty *pointProp = m_wToProperty.value(property, 0)) { - m_propertyToW[pointProp] = 0; + } else if (QtProperty *pointProp = m_wToProperty.value(property, nullptr)) { + m_propertyToW[pointProp] = nullptr; m_wToProperty.remove(property); - } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) { - m_propertyToH[pointProp] = 0; + } else if (QtProperty *pointProp = m_hToProperty.value(property, nullptr)) { + m_propertyToH[pointProp] = nullptr; m_hToProperty.remove(property); } } @@ -4290,10 +4251,10 @@ QtRectFPropertyManager::QtRectFPropertyManager(QObject *parent) d_ptr->q_ptr = this; d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this); - connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(QtProperty*,double)), - this, SLOT(slotDoubleChanged(QtProperty*,double))); - connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); + connect(d_ptr->m_doublePropertyManager, &QtDoublePropertyManager::valueChanged, this, + [this](QtProperty *property, double value) { d_ptr->slotDoubleChanged(property, value); }); + connect(d_ptr->m_doublePropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); } /*! @@ -4357,15 +4318,15 @@ QRectF QtRectFPropertyManager::constraint(const QtProperty *property) const */ QString QtRectFPropertyManager::valueText(const QtProperty *property) const { - const QtRectFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; const QRectF v = it.value().val; const int dec = it.value().decimals; - return QString(tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x(), 'f', dec)) - .arg(QString::number(v.y(), 'f', dec)) - .arg(QString::number(v.width(), 'f', dec)) - .arg(QString::number(v.height(), 'f', dec))); + return QString(tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x(), 'f', dec), + QString::number(v.y(), 'f', dec), + QString::number(v.width(), 'f', dec), + QString::number(v.height(), 'f', dec))); } /*! @@ -4382,7 +4343,7 @@ QString QtRectFPropertyManager::valueText(const QtProperty *property) const */ void QtRectFPropertyManager::setValue(QtProperty *property, const QRectF &val) { - const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -4427,7 +4388,7 @@ void QtRectFPropertyManager::setValue(QtProperty *property, const QRectF &val) */ void QtRectFPropertyManager::setConstraint(QtProperty *property, const QRectF &constraint) { - const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -4485,7 +4446,7 @@ void QtRectFPropertyManager::setConstraint(QtProperty *property, const QRectF &c */ void QtRectFPropertyManager::setDecimals(QtProperty *property, int prec) { - const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -4603,8 +4564,7 @@ public: QMap<int, QIcon> enumIcons; }; - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, Data> m_values; }; /*! @@ -4719,16 +4679,16 @@ QMap<int, QIcon> QtEnumPropertyManager::enumIcons(const QtProperty *property) co */ QString QtEnumPropertyManager::valueText(const QtProperty *property) const { - const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; const QtEnumPropertyManagerPrivate::Data &data = it.value(); const int v = data.val; - if (v >= 0 && v < data.enumNames.count()) + if (v >= 0 && v < data.enumNames.size()) return data.enumNames.at(v); - return QString(); + return {}; } /*! @@ -4736,9 +4696,9 @@ QString QtEnumPropertyManager::valueText(const QtProperty *property) const */ QIcon QtEnumPropertyManager::valueIcon(const QtProperty *property) const { - const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QIcon(); + return {}; const QtEnumPropertyManagerPrivate::Data &data = it.value(); @@ -4758,16 +4718,16 @@ QIcon QtEnumPropertyManager::valueIcon(const QtProperty *property) const */ void QtEnumPropertyManager::setValue(QtProperty *property, int val) { - const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; QtEnumPropertyManagerPrivate::Data data = it.value(); - if (val >= data.enumNames.count()) + if (val >= data.enumNames.size()) return; - if (val < 0 && data.enumNames.count() > 0) + if (val < 0 && data.enumNames.size() > 0) return; if (val < 0) @@ -4796,7 +4756,7 @@ void QtEnumPropertyManager::setValue(QtProperty *property, int val) */ void QtEnumPropertyManager::setEnumNames(QtProperty *property, const QStringList &enumNames) { - const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -4809,7 +4769,7 @@ void QtEnumPropertyManager::setEnumNames(QtProperty *property, const QStringList data.val = -1; - if (enumNames.count() > 0) + if (enumNames.size() > 0) data.val = 0; it.value() = data; @@ -4830,7 +4790,7 @@ void QtEnumPropertyManager::setEnumNames(QtProperty *property, const QStringList */ void QtEnumPropertyManager::setEnumIcons(QtProperty *property, const QMap<int, QIcon> &enumIcons) { - const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -4874,20 +4834,19 @@ public: QStringList flagNames; }; - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, Data> m_values; QtBoolPropertyManager *m_boolPropertyManager; - QMap<const QtProperty *, QList<QtProperty *> > m_propertyToFlags; + QHash<const QtProperty *, QList<QtProperty *>> m_propertyToFlags; - QMap<const QtProperty *, QtProperty *> m_flagToProperty; + QHash<const QtProperty *, QtProperty *> m_flagToProperty; }; void QtFlagPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool value) { - QtProperty *prop = m_flagToProperty.value(property, 0); - if (prop == 0) + QtProperty *prop = m_flagToProperty.value(property, nullptr); + if (prop == nullptr) return; const auto pfit = m_propertyToFlags.constFind(prop); @@ -4911,8 +4870,8 @@ void QtFlagPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool va void QtFlagPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { - QtProperty *flagProperty = m_flagToProperty.value(property, 0); - if (flagProperty == 0) + QtProperty *flagProperty = m_flagToProperty.value(property, nullptr); + if (flagProperty == nullptr) return; m_propertyToFlags[flagProperty].replace(m_propertyToFlags[flagProperty].indexOf(property), 0); @@ -4982,10 +4941,10 @@ QtFlagPropertyManager::QtFlagPropertyManager(QObject *parent) d_ptr->q_ptr = this; d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this); - connect(d_ptr->m_boolPropertyManager, SIGNAL(valueChanged(QtProperty*,bool)), - this, SLOT(slotBoolChanged(QtProperty*,bool))); - connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); + connect(d_ptr->m_boolPropertyManager, &QtBoolPropertyManager::valueChanged, this, + [this](QtProperty *property, bool value) { d_ptr->slotBoolChanged(property, value); }); + connect(d_ptr->m_boolPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); } /*! @@ -5039,21 +4998,20 @@ QStringList QtFlagPropertyManager::flagNames(const QtProperty *property) const */ QString QtFlagPropertyManager::valueText(const QtProperty *property) const { - const QtFlagPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; const QtFlagPropertyManagerPrivate::Data &data = it.value(); QString str; int level = 0; const QChar bar = QLatin1Char('|'); - const QStringList::const_iterator fncend = data.flagNames.constEnd(); - for (QStringList::const_iterator it = data.flagNames.constBegin(); it != fncend; ++it) { + for (const auto &name : data.flagNames) { if (data.val & (1 << level)) { if (!str.isEmpty()) str += bar; - str += *it; + str += name; } level++; @@ -5076,7 +5034,7 @@ QString QtFlagPropertyManager::valueText(const QtProperty *property) const */ void QtFlagPropertyManager::setValue(QtProperty *property, int val) { - const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -5085,7 +5043,7 @@ void QtFlagPropertyManager::setValue(QtProperty *property, int val) if (data.val == val) return; - if (val > (1 << data.flagNames.count()) - 1) + if (val > (1 << data.flagNames.size()) - 1) return; if (val < 0) @@ -5118,7 +5076,7 @@ void QtFlagPropertyManager::setValue(QtProperty *property, int val) */ void QtFlagPropertyManager::setFlagNames(QtProperty *property, const QStringList &flagNames) { - const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -5134,7 +5092,7 @@ void QtFlagPropertyManager::setFlagNames(QtProperty *property, const QStringList const auto pfit = d_ptr->m_propertyToFlags.find(property); if (pfit != d_ptr->m_propertyToFlags.end()) { - for (QtProperty *prop : qAsConst(pfit.value())) { + for (QtProperty *prop : std::as_const(pfit.value())) { if (prop) { delete prop; d_ptr->m_flagToProperty.remove(prop); @@ -5174,7 +5132,7 @@ void QtFlagPropertyManager::uninitializeProperty(QtProperty *property) { const auto it = d_ptr->m_propertyToFlags.find(property); if (it != d_ptr->m_propertyToFlags.end()) { - for (QtProperty *prop : qAsConst(it.value())) { + for (QtProperty *prop : std::as_const(it.value())) { if (prop) { d_ptr->m_flagToProperty.remove(prop); delete prop; @@ -5200,21 +5158,20 @@ public: void slotEnumChanged(QtProperty *property, int value); void slotPropertyDestroyed(QtProperty *property); - typedef QMap<const QtProperty *, QSizePolicy> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, QSizePolicy> m_values; QtIntPropertyManager *m_intPropertyManager; QtEnumPropertyManager *m_enumPropertyManager; - QMap<const QtProperty *, QtProperty *> m_propertyToHPolicy; - QMap<const QtProperty *, QtProperty *> m_propertyToVPolicy; - QMap<const QtProperty *, QtProperty *> m_propertyToHStretch; - QMap<const QtProperty *, QtProperty *> m_propertyToVStretch; + QHash<const QtProperty *, QtProperty *> m_propertyToHPolicy; + QHash<const QtProperty *, QtProperty *> m_propertyToVPolicy; + QHash<const QtProperty *, QtProperty *> m_propertyToHStretch; + QHash<const QtProperty *, QtProperty *> m_propertyToVStretch; - QMap<const QtProperty *, QtProperty *> m_hPolicyToProperty; - QMap<const QtProperty *, QtProperty *> m_vPolicyToProperty; - QMap<const QtProperty *, QtProperty *> m_hStretchToProperty; - QMap<const QtProperty *, QtProperty *> m_vStretchToProperty; + QHash<const QtProperty *, QtProperty *> m_hPolicyToProperty; + QHash<const QtProperty *, QtProperty *> m_vPolicyToProperty; + QHash<const QtProperty *, QtProperty *> m_hStretchToProperty; + QHash<const QtProperty *, QtProperty *> m_vStretchToProperty; }; QtSizePolicyPropertyManagerPrivate::QtSizePolicyPropertyManagerPrivate() @@ -5223,11 +5180,11 @@ QtSizePolicyPropertyManagerPrivate::QtSizePolicyPropertyManagerPrivate() void QtSizePolicyPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value) { - if (QtProperty *prop = m_hStretchToProperty.value(property, 0)) { + if (QtProperty *prop = m_hStretchToProperty.value(property, nullptr)) { QSizePolicy sp = m_values[prop]; sp.setHorizontalStretch(value); q_ptr->setValue(prop, sp); - } else if (QtProperty *prop = m_vStretchToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_vStretchToProperty.value(property, nullptr)) { QSizePolicy sp = m_values[prop]; sp.setVerticalStretch(value); q_ptr->setValue(prop, sp); @@ -5236,11 +5193,11 @@ void QtSizePolicyPropertyManagerPrivate::slotIntChanged(QtProperty *property, in void QtSizePolicyPropertyManagerPrivate::slotEnumChanged(QtProperty *property, int value) { - if (QtProperty *prop = m_hPolicyToProperty.value(property, 0)) { + if (QtProperty *prop = m_hPolicyToProperty.value(property, nullptr)) { QSizePolicy sp = m_values[prop]; sp.setHorizontalPolicy(metaEnumProvider()->indexToSizePolicy(value)); q_ptr->setValue(prop, sp); - } else if (QtProperty *prop = m_vPolicyToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_vPolicyToProperty.value(property, nullptr)) { QSizePolicy sp = m_values[prop]; sp.setVerticalPolicy(metaEnumProvider()->indexToSizePolicy(value)); q_ptr->setValue(prop, sp); @@ -5249,17 +5206,17 @@ void QtSizePolicyPropertyManagerPrivate::slotEnumChanged(QtProperty *property, i void QtSizePolicyPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { - if (QtProperty *pointProp = m_hStretchToProperty.value(property, 0)) { - m_propertyToHStretch[pointProp] = 0; + if (QtProperty *pointProp = m_hStretchToProperty.value(property, nullptr)) { + m_propertyToHStretch[pointProp] = nullptr; m_hStretchToProperty.remove(property); - } else if (QtProperty *pointProp = m_vStretchToProperty.value(property, 0)) { - m_propertyToVStretch[pointProp] = 0; + } else if (QtProperty *pointProp = m_vStretchToProperty.value(property, nullptr)) { + m_propertyToVStretch[pointProp] = nullptr; m_vStretchToProperty.remove(property); - } else if (QtProperty *pointProp = m_hPolicyToProperty.value(property, 0)) { - m_propertyToHPolicy[pointProp] = 0; + } else if (QtProperty *pointProp = m_hPolicyToProperty.value(property, nullptr)) { + m_propertyToHPolicy[pointProp] = nullptr; m_hPolicyToProperty.remove(property); - } else if (QtProperty *pointProp = m_vPolicyToProperty.value(property, 0)) { - m_propertyToVPolicy[pointProp] = 0; + } else if (QtProperty *pointProp = m_vPolicyToProperty.value(property, nullptr)) { + m_propertyToVPolicy[pointProp] = nullptr; m_vPolicyToProperty.remove(property); } } @@ -5309,16 +5266,16 @@ QtSizePolicyPropertyManager::QtSizePolicyPropertyManager(QObject *parent) d_ptr->q_ptr = this; d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotIntChanged(QtProperty*,int))); - d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); - connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotEnumChanged(QtProperty*,int))); + connect(d_ptr->m_intPropertyManager, &QtIntPropertyManager::valueChanged, this, + [this](QtProperty *property, int value) { d_ptr->slotIntChanged(property, value); }); + connect(d_ptr->m_intPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); - connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); + d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); + connect(d_ptr->m_enumPropertyManager, &QtEnumPropertyManager::valueChanged, this, + [this](QtProperty *property, int value) { d_ptr->slotEnumChanged(property, value); }); + connect(d_ptr->m_enumPropertyManager, &QtEnumPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); } /*! @@ -5377,9 +5334,9 @@ QSizePolicy QtSizePolicyPropertyManager::value(const QtProperty *property) const */ QString QtSizePolicyPropertyManager::valueText(const QtProperty *property) const { - const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; const QSizePolicy sp = it.value(); const QtMetaEnumProvider *mep = metaEnumProvider(); @@ -5402,7 +5359,7 @@ QString QtSizePolicyPropertyManager::valueText(const QtProperty *property) const */ void QtSizePolicyPropertyManager::setValue(QtProperty *property, const QSizePolicy &val) { - const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -5529,28 +5486,29 @@ public: QStringList m_familyNames; - typedef QMap<const QtProperty *, QFont> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, QFont> m_values; QtIntPropertyManager *m_intPropertyManager; QtEnumPropertyManager *m_enumPropertyManager; QtBoolPropertyManager *m_boolPropertyManager; - QMap<const QtProperty *, QtProperty *> m_propertyToFamily; - QMap<const QtProperty *, QtProperty *> m_propertyToPointSize; - QMap<const QtProperty *, QtProperty *> m_propertyToBold; - QMap<const QtProperty *, QtProperty *> m_propertyToItalic; - QMap<const QtProperty *, QtProperty *> m_propertyToUnderline; - QMap<const QtProperty *, QtProperty *> m_propertyToStrikeOut; - QMap<const QtProperty *, QtProperty *> m_propertyToKerning; - - QMap<const QtProperty *, QtProperty *> m_familyToProperty; - QMap<const QtProperty *, QtProperty *> m_pointSizeToProperty; - QMap<const QtProperty *, QtProperty *> m_boldToProperty; - QMap<const QtProperty *, QtProperty *> m_italicToProperty; - QMap<const QtProperty *, QtProperty *> m_underlineToProperty; - QMap<const QtProperty *, QtProperty *> m_strikeOutToProperty; - QMap<const QtProperty *, QtProperty *> m_kerningToProperty; + QHash<const QtProperty *, QtProperty *> m_propertyToFamily; + QHash<const QtProperty *, QtProperty *> m_propertyToPointSize; + QHash<const QtProperty *, QtProperty *> m_propertyToBold; + QHash<const QtProperty *, QtProperty *> m_propertyToItalic; + QHash<const QtProperty *, QtProperty *> m_propertyToUnderline; + QHash<const QtProperty *, QtProperty *> m_propertyToStrikeOut; + QHash<const QtProperty *, QtProperty *> m_propertyToKerning; + QHash<const QtProperty *, QtProperty *> m_propertyToWeight; + + QHash<const QtProperty *, QtProperty *> m_familyToProperty; + QHash<const QtProperty *, QtProperty *> m_pointSizeToProperty; + QHash<const QtProperty *, QtProperty *> m_boldToProperty; + QHash<const QtProperty *, QtProperty *> m_italicToProperty; + QHash<const QtProperty *, QtProperty *> m_underlineToProperty; + QHash<const QtProperty *, QtProperty *> m_strikeOutToProperty; + QHash<const QtProperty *, QtProperty *> m_kerningToProperty; + QHash<const QtProperty *, QtProperty *> m_weightToProperty; bool m_settingValue; QTimer *m_fontDatabaseChangeTimer; @@ -5566,7 +5524,7 @@ void QtFontPropertyManagerPrivate::slotIntChanged(QtProperty *property, int valu { if (m_settingValue) return; - if (QtProperty *prop = m_pointSizeToProperty.value(property, 0)) { + if (QtProperty *prop = m_pointSizeToProperty.value(property, nullptr)) { QFont f = m_values[prop]; f.setPointSize(value); q_ptr->setValue(prop, f); @@ -5577,10 +5535,14 @@ void QtFontPropertyManagerPrivate::slotEnumChanged(QtProperty *property, int val { if (m_settingValue) return; - if (QtProperty *prop = m_familyToProperty.value(property, 0)) { + if (QtProperty *prop = m_familyToProperty.value(property, nullptr)) { QFont f = m_values[prop]; f.setFamily(m_familyNames.at(value)); q_ptr->setValue(prop, f); + } else if (auto *prop = m_weightToProperty.value(property, nullptr)) { + QFont f = m_values[prop]; + f.setWeight(weightFromIndex(value)); + q_ptr->setValue(prop, f); } } @@ -5588,23 +5550,23 @@ void QtFontPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool va { if (m_settingValue) return; - if (QtProperty *prop = m_boldToProperty.value(property, 0)) { + if (QtProperty *prop = m_boldToProperty.value(property, nullptr)) { QFont f = m_values[prop]; f.setBold(value); q_ptr->setValue(prop, f); - } else if (QtProperty *prop = m_italicToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_italicToProperty.value(property, nullptr)) { QFont f = m_values[prop]; f.setItalic(value); q_ptr->setValue(prop, f); - } else if (QtProperty *prop = m_underlineToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_underlineToProperty.value(property, nullptr)) { QFont f = m_values[prop]; f.setUnderline(value); q_ptr->setValue(prop, f); - } else if (QtProperty *prop = m_strikeOutToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_strikeOutToProperty.value(property, nullptr)) { QFont f = m_values[prop]; f.setStrikeOut(value); q_ptr->setValue(prop, f); - } else if (QtProperty *prop = m_kerningToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_kerningToProperty.value(property, nullptr)) { QFont f = m_values[prop]; f.setKerning(value); q_ptr->setValue(prop, f); @@ -5613,37 +5575,41 @@ void QtFontPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool va void QtFontPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { - if (QtProperty *pointProp = m_pointSizeToProperty.value(property, 0)) { - m_propertyToPointSize[pointProp] = 0; + if (QtProperty *pointProp = m_pointSizeToProperty.value(property, nullptr)) { + m_propertyToPointSize[pointProp] = nullptr; m_pointSizeToProperty.remove(property); - } else if (QtProperty *pointProp = m_familyToProperty.value(property, 0)) { - m_propertyToFamily[pointProp] = 0; + } else if (QtProperty *pointProp = m_familyToProperty.value(property, nullptr)) { + m_propertyToFamily[pointProp] = nullptr; m_familyToProperty.remove(property); - } else if (QtProperty *pointProp = m_boldToProperty.value(property, 0)) { - m_propertyToBold[pointProp] = 0; + } else if (QtProperty *pointProp = m_boldToProperty.value(property, nullptr)) { + m_propertyToBold[pointProp] = nullptr; m_boldToProperty.remove(property); - } else if (QtProperty *pointProp = m_italicToProperty.value(property, 0)) { - m_propertyToItalic[pointProp] = 0; + } else if (QtProperty *pointProp = m_italicToProperty.value(property, nullptr)) { + m_propertyToItalic[pointProp] = nullptr; m_italicToProperty.remove(property); - } else if (QtProperty *pointProp = m_underlineToProperty.value(property, 0)) { - m_propertyToUnderline[pointProp] = 0; + } else if (QtProperty *pointProp = m_underlineToProperty.value(property, nullptr)) { + m_propertyToUnderline[pointProp] = nullptr; m_underlineToProperty.remove(property); - } else if (QtProperty *pointProp = m_strikeOutToProperty.value(property, 0)) { - m_propertyToStrikeOut[pointProp] = 0; + } else if (QtProperty *pointProp = m_strikeOutToProperty.value(property, nullptr)) { + m_propertyToStrikeOut[pointProp] = nullptr; m_strikeOutToProperty.remove(property); - } else if (QtProperty *pointProp = m_kerningToProperty.value(property, 0)) { - m_propertyToKerning[pointProp] = 0; + } else if (QtProperty *pointProp = m_kerningToProperty.value(property, nullptr)) { + m_propertyToKerning[pointProp] = nullptr; m_kerningToProperty.remove(property); + } else if (QtProperty *weightProp = m_weightToProperty.value(property, nullptr)) { + m_propertyToWeight[weightProp] = nullptr; + m_weightToProperty.remove(property); } } -void QtFontPropertyManagerPrivate::slotFontDatabaseChanged() +void QtFontPropertyManagerPrivate::slotFontDatabaseChanged() { if (!m_fontDatabaseChangeTimer) { m_fontDatabaseChangeTimer = new QTimer(q_ptr); m_fontDatabaseChangeTimer->setInterval(0); m_fontDatabaseChangeTimer->setSingleShot(true); - QObject::connect(m_fontDatabaseChangeTimer, SIGNAL(timeout()), q_ptr, SLOT(slotFontDatabaseDelayedChange())); + QObject::connect(m_fontDatabaseChangeTimer, &QTimer::timeout, q_ptr, + [this] { slotFontDatabaseDelayedChange(); }); } if (!m_fontDatabaseChangeTimer->isActive()) m_fontDatabaseChangeTimer->start(); @@ -5651,16 +5617,13 @@ void QtFontPropertyManagerPrivate::slotFontDatabaseChanged() void QtFontPropertyManagerPrivate::slotFontDatabaseDelayedChange() { - typedef QMap<const QtProperty *, QtProperty *> PropertyPropertyMap; // rescan available font names const QStringList oldFamilies = m_familyNames; m_familyNames = QFontDatabase::families(); // Adapt all existing properties if (!m_propertyToFamily.isEmpty()) { - PropertyPropertyMap::const_iterator cend = m_propertyToFamily.constEnd(); - for (PropertyPropertyMap::const_iterator it = m_propertyToFamily.constBegin(); it != cend; ++it) { - QtProperty *familyProp = it.value(); + for (QtProperty *familyProp : std::as_const(m_propertyToFamily)) { const int oldIdx = m_enumPropertyManager->value(familyProp); int newIdx = m_familyNames.indexOf(oldFamilies.at(oldIdx)); if (newIdx < 0) @@ -5715,24 +5678,26 @@ QtFontPropertyManager::QtFontPropertyManager(QObject *parent) : QtAbstractPropertyManager(parent), d_ptr(new QtFontPropertyManagerPrivate) { d_ptr->q_ptr = this; - QObject::connect(qApp, SIGNAL(fontDatabaseChanged()), this, SLOT(slotFontDatabaseChanged())); + QObject::connect(qApp, &QGuiApplication::fontDatabaseChanged, this, + [this] { d_ptr->slotFontDatabaseChanged(); }); d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotIntChanged(QtProperty*,int))); + connect(d_ptr->m_intPropertyManager, &QtIntPropertyManager::valueChanged, this, + [this](QtProperty *property, int value) { d_ptr->slotIntChanged(property, value); }); + connect(d_ptr->m_intPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); + d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); - connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotEnumChanged(QtProperty*,int))); - d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this); - connect(d_ptr->m_boolPropertyManager, SIGNAL(valueChanged(QtProperty*,bool)), - this, SLOT(slotBoolChanged(QtProperty*,bool))); + connect(d_ptr->m_enumPropertyManager, &QtEnumPropertyManager::valueChanged, this, + [this](QtProperty *property, int value) { d_ptr->slotEnumChanged(property, value); }); + connect(d_ptr->m_enumPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); - connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); - connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); + d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this); + connect(d_ptr->m_boolPropertyManager, &QtBoolPropertyManager::valueChanged, this, + [this](QtProperty *property, bool value) { d_ptr->slotBoolChanged(property, value); }); + connect(d_ptr->m_boolPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); } /*! @@ -5805,9 +5770,9 @@ QFont QtFontPropertyManager::value(const QtProperty *property) const */ QString QtFontPropertyManager::valueText(const QtProperty *property) const { - const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; return QtPropertyBrowserUtils::fontValueText(it.value()); } @@ -5817,9 +5782,9 @@ QString QtFontPropertyManager::valueText(const QtProperty *property) const */ QIcon QtFontPropertyManager::valueIcon(const QtProperty *property) const { - const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QIcon(); + return {}; return QtPropertyBrowserUtils::fontValueIcon(it.value()); } @@ -5834,7 +5799,7 @@ QIcon QtFontPropertyManager::valueIcon(const QtProperty *property) const */ void QtFontPropertyManager::setValue(QtProperty *property, const QFont &val) { - const QtFontPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -5856,12 +5821,34 @@ void QtFontPropertyManager::setValue(QtProperty *property, const QFont &val) d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToUnderline[property], val.underline()); d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToStrikeOut[property], val.strikeOut()); d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToKerning[property], val.kerning()); + d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToWeight[property], + indexOfFontWeight(val.weight())); d_ptr->m_settingValue = settingValue; emit propertyChanged(property); emit valueChanged(property, val); } +static QStringList fontWeightNames() +{ + static const DisambiguatedTranslation weightsC[] = { + QT_TRANSLATE_NOOP3("FontPropertyManager", "Thin", "QFont::Weight combo"), + QT_TRANSLATE_NOOP3("FontPropertyManager", "ExtraLight", "QFont::Weight combo"), + QT_TRANSLATE_NOOP3("FontPropertyManager", "Light", "QFont::Weight combo"), + QT_TRANSLATE_NOOP3("FontPropertyManager", "Normal", "QFont::Weight combo"), + QT_TRANSLATE_NOOP3("FontPropertyManager", "Medium", "QFont::Weight combo"), + QT_TRANSLATE_NOOP3("FontPropertyManager", "DemiBold", "QFont::Weight combo"), + QT_TRANSLATE_NOOP3("FontPropertyManager", "Bold", "QFont::Weight combo"), + QT_TRANSLATE_NOOP3("FontPropertyManager", "ExtraBold", "QFont::Weight combo"), + QT_TRANSLATE_NOOP3("FontPropertyManager", "Black", "QFont::Weight combo") + }; + + QStringList result; + for (const auto &w : weightsC) + result.append(QCoreApplication::translate("FontPropertyManager", w.first, w.second)); + return result; +} + /*! \reimp */ @@ -5892,7 +5879,7 @@ void QtFontPropertyManager::initializeProperty(QtProperty *property) property->addSubProperty(pointSizeProp); QtProperty *boldProp = d_ptr->m_boolPropertyManager->addProperty(); - boldProp->setPropertyName(tr("Bold")); + boldProp->setPropertyName(tr("Bold", "Bold toggle")); d_ptr->m_boolPropertyManager->setValue(boldProp, val.bold()); d_ptr->m_propertyToBold[property] = boldProp; d_ptr->m_boldToProperty[boldProp] = property; @@ -5925,6 +5912,15 @@ void QtFontPropertyManager::initializeProperty(QtProperty *property) d_ptr->m_propertyToKerning[property] = kerningProp; d_ptr->m_kerningToProperty[kerningProp] = property; property->addSubProperty(kerningProp); + + auto *weightProp = d_ptr->m_enumPropertyManager->addProperty(); + weightProp->setPropertyName(tr("Weight")); + static const QStringList weightNames = fontWeightNames(); + d_ptr->m_enumPropertyManager->setEnumNames(weightProp, weightNames); + d_ptr->m_enumPropertyManager->setValue(weightProp, indexOfFontWeight(val.weight())); + d_ptr->m_propertyToWeight[property] = weightProp; + d_ptr->m_weightToProperty[weightProp] = property; + property->addSubProperty(weightProp); } /*! @@ -5981,6 +5977,11 @@ void QtFontPropertyManager::uninitializeProperty(QtProperty *property) } d_ptr->m_propertyToKerning.remove(property); + if (auto weightProp = d_ptr->m_propertyToWeight[property]) { + d_ptr->m_weightToProperty.remove(weightProp); + delete weightProp; + } + d_ptr->m_values.remove(property); } @@ -5995,37 +5996,36 @@ public: void slotIntChanged(QtProperty *property, int value); void slotPropertyDestroyed(QtProperty *property); - typedef QMap<const QtProperty *, QColor> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, QColor> m_values; QtIntPropertyManager *m_intPropertyManager; - QMap<const QtProperty *, QtProperty *> m_propertyToR; - QMap<const QtProperty *, QtProperty *> m_propertyToG; - QMap<const QtProperty *, QtProperty *> m_propertyToB; - QMap<const QtProperty *, QtProperty *> m_propertyToA; + QHash<const QtProperty *, QtProperty *> m_propertyToR; + QHash<const QtProperty *, QtProperty *> m_propertyToG; + QHash<const QtProperty *, QtProperty *> m_propertyToB; + QHash<const QtProperty *, QtProperty *> m_propertyToA; - QMap<const QtProperty *, QtProperty *> m_rToProperty; - QMap<const QtProperty *, QtProperty *> m_gToProperty; - QMap<const QtProperty *, QtProperty *> m_bToProperty; - QMap<const QtProperty *, QtProperty *> m_aToProperty; + QHash<const QtProperty *, QtProperty *> m_rToProperty; + QHash<const QtProperty *, QtProperty *> m_gToProperty; + QHash<const QtProperty *, QtProperty *> m_bToProperty; + QHash<const QtProperty *, QtProperty *> m_aToProperty; }; void QtColorPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value) { - if (QtProperty *prop = m_rToProperty.value(property, 0)) { + if (QtProperty *prop = m_rToProperty.value(property, nullptr)) { QColor c = m_values[prop]; c.setRed(value); q_ptr->setValue(prop, c); - } else if (QtProperty *prop = m_gToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_gToProperty.value(property, nullptr)) { QColor c = m_values[prop]; c.setGreen(value); q_ptr->setValue(prop, c); - } else if (QtProperty *prop = m_bToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_bToProperty.value(property, nullptr)) { QColor c = m_values[prop]; c.setBlue(value); q_ptr->setValue(prop, c); - } else if (QtProperty *prop = m_aToProperty.value(property, 0)) { + } else if (QtProperty *prop = m_aToProperty.value(property, nullptr)) { QColor c = m_values[prop]; c.setAlpha(value); q_ptr->setValue(prop, c); @@ -6034,17 +6034,17 @@ void QtColorPropertyManagerPrivate::slotIntChanged(QtProperty *property, int val void QtColorPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { - if (QtProperty *pointProp = m_rToProperty.value(property, 0)) { - m_propertyToR[pointProp] = 0; + if (QtProperty *pointProp = m_rToProperty.value(property, nullptr)) { + m_propertyToR[pointProp] = nullptr; m_rToProperty.remove(property); - } else if (QtProperty *pointProp = m_gToProperty.value(property, 0)) { - m_propertyToG[pointProp] = 0; + } else if (QtProperty *pointProp = m_gToProperty.value(property, nullptr)) { + m_propertyToG[pointProp] = nullptr; m_gToProperty.remove(property); - } else if (QtProperty *pointProp = m_bToProperty.value(property, 0)) { - m_propertyToB[pointProp] = 0; + } else if (QtProperty *pointProp = m_bToProperty.value(property, nullptr)) { + m_propertyToB[pointProp] = nullptr; m_bToProperty.remove(property); - } else if (QtProperty *pointProp = m_aToProperty.value(property, 0)) { - m_propertyToA[pointProp] = 0; + } else if (QtProperty *pointProp = m_aToProperty.value(property, nullptr)) { + m_propertyToA[pointProp] = nullptr; m_aToProperty.remove(property); } } @@ -6093,11 +6093,10 @@ QtColorPropertyManager::QtColorPropertyManager(QObject *parent) d_ptr->q_ptr = this; d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotIntChanged(QtProperty*,int))); - - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)), - this, SLOT(slotPropertyDestroyed(QtProperty*))); + connect(d_ptr->m_intPropertyManager, &QtIntPropertyManager::valueChanged, this, + [this](QtProperty *property, int value) { d_ptr->slotIntChanged(property, value); }); + connect(d_ptr->m_intPropertyManager, &QtAbstractPropertyManager::propertyDestroyed, this, + [this](QtProperty *property) { d_ptr->slotPropertyDestroyed(property); }); } /*! @@ -6142,9 +6141,9 @@ QColor QtColorPropertyManager::value(const QtProperty *property) const QString QtColorPropertyManager::valueText(const QtProperty *property) const { - const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; return QtPropertyBrowserUtils::colorValueText(it.value()); } @@ -6155,9 +6154,9 @@ QString QtColorPropertyManager::valueText(const QtProperty *property) const QIcon QtColorPropertyManager::valueIcon(const QtProperty *property) const { - const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QIcon(); + return {}; return QtPropertyBrowserUtils::brushValueIcon(QBrush(it.value())); } @@ -6171,7 +6170,7 @@ QIcon QtColorPropertyManager::valueIcon(const QtProperty *property) const */ void QtColorPropertyManager::setValue(QtProperty *property, const QColor &val) { - const QtColorPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; @@ -6268,32 +6267,12 @@ void QtColorPropertyManager::uninitializeProperty(QtProperty *property) // QtCursorPropertyManager -// Make sure icons are removed as soon as QApplication is destroyed, otherwise, -// handles are leaked on X11. -static void clearCursorDatabase(); -namespace { -struct CursorDatabase : public QtCursorDatabase -{ - CursorDatabase() - { - qAddPostRoutine(clearCursorDatabase); - } -}; -} -Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase) - -static void clearCursorDatabase() -{ - cursorDatabase()->clear(); -} - class QtCursorPropertyManagerPrivate { QtCursorPropertyManager *q_ptr; Q_DECLARE_PUBLIC(QtCursorPropertyManager) public: - typedef QMap<const QtProperty *, QCursor> PropertyValueMap; - PropertyValueMap m_values; + QHash<const QtProperty *, QCursor> m_values; }; /*! @@ -6360,11 +6339,11 @@ QCursor QtCursorPropertyManager::value(const QtProperty *property) const */ QString QtCursorPropertyManager::valueText(const QtProperty *property) const { - const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QString(); + return {}; - return cursorDatabase()->cursorToShapeName(it.value()); + return QtCursorDatabase::instance()->cursorToShapeName(it.value()); } /*! @@ -6372,11 +6351,11 @@ QString QtCursorPropertyManager::valueText(const QtProperty *property) const */ QIcon QtCursorPropertyManager::valueIcon(const QtProperty *property) const { - const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); + const auto it = d_ptr->m_values.constFind(property); if (it == d_ptr->m_values.constEnd()) - return QIcon(); + return {}; - return cursorDatabase()->cursorToShapeIcon(it.value()); + return QtCursorDatabase::instance()->cursorToShapeIcon(it.value()); } /*! @@ -6389,7 +6368,7 @@ QIcon QtCursorPropertyManager::valueIcon(const QtProperty *property) const void QtCursorPropertyManager::setValue(QtProperty *property, const QCursor &value) { #ifndef QT_NO_CURSOR - const QtCursorPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); + const auto it = d_ptr->m_values.find(property); if (it == d_ptr->m_values.end()) return; diff --git a/src/shared/qtpropertybrowser/qtpropertymanager.h b/src/shared/qtpropertybrowser/qtpropertymanager.h index d737fb06d..630f48e1c 100644 --- a/src/shared/qtpropertybrowser/qtpropertymanager.h +++ b/src/shared/qtpropertybrowser/qtpropertymanager.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTPROPERTYMANAGER_H #define QTPROPERTYMANAGER_H @@ -346,8 +310,6 @@ private: QScopedPointer<QtLocalePropertyManagerPrivate> d_ptr; Q_DECLARE_PRIVATE(QtLocalePropertyManager) Q_DISABLE_COPY_MOVE(QtLocalePropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtPointPropertyManagerPrivate; @@ -375,8 +337,6 @@ private: QScopedPointer<QtPointPropertyManagerPrivate> d_ptr; Q_DECLARE_PRIVATE(QtPointPropertyManager) Q_DISABLE_COPY_MOVE(QtPointPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtPointFPropertyManagerPrivate; @@ -407,8 +367,6 @@ private: QScopedPointer<QtPointFPropertyManagerPrivate> d_ptr; Q_DECLARE_PRIVATE(QtPointFPropertyManager) Q_DISABLE_COPY_MOVE(QtPointFPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtSizePropertyManagerPrivate; @@ -442,8 +400,6 @@ private: QScopedPointer<QtSizePropertyManagerPrivate> d_ptr; Q_DECLARE_PRIVATE(QtSizePropertyManager) Q_DISABLE_COPY_MOVE(QtSizePropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtSizeFPropertyManagerPrivate; @@ -480,8 +436,6 @@ private: QScopedPointer<QtSizeFPropertyManagerPrivate> d_ptr; Q_DECLARE_PRIVATE(QtSizeFPropertyManager) Q_DISABLE_COPY_MOVE(QtSizeFPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtRectPropertyManagerPrivate; @@ -512,8 +466,6 @@ private: QScopedPointer<QtRectPropertyManagerPrivate> d_ptr; Q_DECLARE_PRIVATE(QtRectPropertyManager) Q_DISABLE_COPY_MOVE(QtRectPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtRectFPropertyManagerPrivate; @@ -547,8 +499,6 @@ private: QScopedPointer<QtRectFPropertyManagerPrivate> d_ptr; Q_DECLARE_PRIVATE(QtRectFPropertyManager) Q_DISABLE_COPY_MOVE(QtRectFPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtEnumPropertyManagerPrivate; @@ -611,8 +561,6 @@ private: QScopedPointer<QtFlagPropertyManagerPrivate> d_ptr; Q_DECLARE_PRIVATE(QtFlagPropertyManager) Q_DISABLE_COPY_MOVE(QtFlagPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotBoolChanged(QtProperty *, bool)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtSizePolicyPropertyManagerPrivate; @@ -641,9 +589,6 @@ private: QScopedPointer<QtSizePolicyPropertyManagerPrivate> d_ptr; Q_DECLARE_PRIVATE(QtSizePolicyPropertyManager) Q_DISABLE_COPY_MOVE(QtSizePolicyPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtFontPropertyManagerPrivate; @@ -674,12 +619,6 @@ private: QScopedPointer<QtFontPropertyManagerPrivate> d_ptr; Q_DECLARE_PRIVATE(QtFontPropertyManager) Q_DISABLE_COPY_MOVE(QtFontPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotBoolChanged(QtProperty *, bool)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) - Q_PRIVATE_SLOT(d_func(), void slotFontDatabaseChanged()) - Q_PRIVATE_SLOT(d_func(), void slotFontDatabaseDelayedChange()) }; class QtColorPropertyManagerPrivate; @@ -708,8 +647,6 @@ private: QScopedPointer<QtColorPropertyManagerPrivate> d_ptr; Q_DECLARE_PRIVATE(QtColorPropertyManager) Q_DISABLE_COPY_MOVE(QtColorPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtCursorPropertyManagerPrivate; diff --git a/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp b/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp index bcf9e1022..073c8a04f 100644 --- a/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp +++ b/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp @@ -1,57 +1,33 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qttreepropertybrowser.h" -#include <QtCore/QSet> + +#include <QtCore/QOperatingSystemVersion> +#include <QtCore/QHash> +#include <QtGui/QFocusEvent> #include <QtGui/QIcon> -#include <QtWidgets/QTreeWidget> -#include <QtWidgets/QItemDelegate> -#include <QtWidgets/QHBoxLayout> -#include <QtWidgets/QHeaderView> #include <QtGui/QPainter> +#include <QtGui/QPalette> +#include <QtGui/QStyleHints> #include <QtWidgets/QApplication> -#include <QtGui/QFocusEvent> +#include <QtWidgets/QHBoxLayout> +#include <QtWidgets/QHeaderView> +#include <QtWidgets/QItemDelegate> #include <QtWidgets/QStyle> -#include <QtGui/QPalette> +#include <QtWidgets/QTreeWidget> QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + +static constexpr bool isWindows = QOperatingSystemVersion::currentType() == QOperatingSystemVersion::Windows; + +static inline bool isLightTheme() +{ + return QGuiApplication::styleHints()->colorScheme() != Qt::ColorScheme::Dark; +} + class QtPropertyEditorView; class QtTreePropertyBrowserPrivate @@ -96,10 +72,10 @@ public: private: void updateItem(QTreeWidgetItem *item); - QMap<QtBrowserItem *, QTreeWidgetItem *> m_indexToItem; - QMap<QTreeWidgetItem *, QtBrowserItem *> m_itemToIndex; + QHash<QtBrowserItem *, QTreeWidgetItem *> m_indexToItem; + QHash<QTreeWidgetItem *, QtBrowserItem *> m_itemToIndex; - QMap<QtBrowserItem *, QColor> m_indexToBackgroundColor; + QHash<QtBrowserItem *, QColor> m_indexToBackgroundColor; QtPropertyEditorView *m_treeWidget; @@ -137,7 +113,7 @@ QtPropertyEditorView::QtPropertyEditorView(QWidget *parent) : QTreeWidget(parent), m_editorPrivate(0) { - connect(header(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(resizeColumnToContents(int))); + connect(header(), &QHeaderView::sectionDoubleClicked, this, &QTreeView::resizeColumnToContents); } void QtPropertyEditorView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const @@ -250,10 +226,10 @@ private slots: private: int indentation(const QModelIndex &index) const; - typedef QMap<QWidget *, QtProperty *> EditorToPropertyMap; + using EditorToPropertyMap = QHash<QWidget *, QtProperty *>; mutable EditorToPropertyMap m_editorToProperty; - typedef QMap<QtProperty *, QWidget *> PropertyToEditorMap; + using PropertyToEditorMap = QHash<QtProperty *, QWidget *>; mutable PropertyToEditorMap m_propertyToEditor; QtTreePropertyBrowserPrivate *m_editorPrivate; mutable QTreeWidgetItem *m_editedItem; @@ -278,22 +254,22 @@ int QtPropertyEditorDelegate::indentation(const QModelIndex &index) const void QtPropertyEditorDelegate::slotEditorDestroyed(QObject *object) { - if (QWidget *w = qobject_cast<QWidget *>(object)) { - const EditorToPropertyMap::iterator it = m_editorToProperty.find(w); + if (auto *w = qobject_cast<QWidget *>(object)) { + const auto it = m_editorToProperty.find(w); if (it != m_editorToProperty.end()) { m_propertyToEditor.remove(it.value()); m_editorToProperty.erase(it); } if (m_editedWidget == w) { - m_editedWidget = 0; - m_editedItem = 0; + m_editedWidget = nullptr; + m_editedItem = nullptr; } } } void QtPropertyEditorDelegate::closeEditor(QtProperty *property) { - if (QWidget *w = m_propertyToEditor.value(property, 0)) + if (QWidget *w = m_propertyToEditor.value(property, nullptr)) w->deleteLater(); } @@ -307,8 +283,11 @@ QWidget *QtPropertyEditorDelegate::createEditor(QWidget *parent, QWidget *editor = m_editorPrivate->createEditor(property, parent); if (editor) { editor->setAutoFillBackground(true); + if (editor->palette().color(editor->backgroundRole()) == Qt::transparent) + editor->setBackgroundRole(QPalette::Window); editor->installEventFilter(const_cast<QtPropertyEditorDelegate *>(this)); - connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*))); + connect(editor, &QObject::destroyed, + this, &QtPropertyEditorDelegate::slotEditorDestroyed); m_propertyToEditor[property] = editor; m_editorToProperty[editor] = property; m_editedItem = item; @@ -317,7 +296,7 @@ QWidget *QtPropertyEditorDelegate::createEditor(QWidget *parent, return editor; } } - return 0; + return nullptr; } void QtPropertyEditorDelegate::updateEditorGeometry(QWidget *editor, @@ -347,7 +326,10 @@ void QtPropertyEditorDelegate::paint(QPainter *painter, const QStyleOptionViewIt QColor c; if (!hasValue && m_editorPrivate->markPropertiesWithoutValue()) { c = opt.palette.color(QPalette::Dark); - opt.palette.setColor(QPalette::Text, opt.palette.color(QPalette::BrightText)); + // Hardcode "white" for Windows/light which is otherwise blue + const QColor textColor = isWindows && isLightTheme() + ? QColor(Qt::white) : opt.palette.color(QPalette::BrightText); + opt.palette.setColor(QPalette::Text, textColor); } else { c = m_editorPrivate->calculatedBackgroundColor(m_editorPrivate->indexToBrowserItem(index)); if (c.isValid() && (opt.features & QStyleOptionViewItem::Alternate)) @@ -427,7 +409,7 @@ static QIcon drawIndicatorIcon(const QPalette &palette, QStyle *style) void QtTreePropertyBrowserPrivate::init(QWidget *parent) { - QHBoxLayout *layout = new QHBoxLayout(parent); + auto *layout = new QHBoxLayout(parent); layout->setContentsMargins(QMargins()); m_treeWidget = new QtPropertyEditorView(parent); m_treeWidget->setEditorPrivate(this); @@ -449,23 +431,27 @@ void QtTreePropertyBrowserPrivate::init(QWidget *parent) m_expandIcon = drawIndicatorIcon(q_ptr->palette(), q_ptr->style()); - QObject::connect(m_treeWidget, SIGNAL(collapsed(QModelIndex)), q_ptr, SLOT(slotCollapsed(QModelIndex))); - QObject::connect(m_treeWidget, SIGNAL(expanded(QModelIndex)), q_ptr, SLOT(slotExpanded(QModelIndex))); - QObject::connect(m_treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), q_ptr, SLOT(slotCurrentTreeItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); + QObject::connect(m_treeWidget, &QTreeView::collapsed, + q_ptr, [this](const QModelIndex &index) { slotCollapsed(index); }); + QObject::connect(m_treeWidget, &QTreeView::expanded, + q_ptr, [this](const QModelIndex &index) { slotExpanded(index); }); + QObject::connect(m_treeWidget, &QTreeWidget::currentItemChanged, + q_ptr, [this](QTreeWidgetItem *current, QTreeWidgetItem *previous) + { slotCurrentTreeItemChanged(current, previous); }); } QtBrowserItem *QtTreePropertyBrowserPrivate::currentItem() const { if (QTreeWidgetItem *treeItem = m_treeWidget->currentItem()) return m_itemToIndex.value(treeItem); - return 0; + return nullptr; } void QtTreePropertyBrowserPrivate::setCurrentItem(QtBrowserItem *browserItem, bool block) { const bool blocked = block ? m_treeWidget->blockSignals(true) : false; - if (browserItem == 0) - m_treeWidget->setCurrentItem(0); + if (browserItem == nullptr) + m_treeWidget->setCurrentItem(nullptr); else m_treeWidget->setCurrentItem(m_indexToItem.value(browserItem)); if (block) @@ -478,7 +464,7 @@ QtProperty *QtTreePropertyBrowserPrivate::indexToProperty(const QModelIndex &ind QtBrowserItem *idx = m_itemToIndex.value(item); if (idx) return idx->property(); - return 0; + return nullptr; } QtBrowserItem *QtTreePropertyBrowserPrivate::indexToBrowserItem(const QModelIndex &index) const @@ -621,14 +607,14 @@ void QtTreePropertyBrowserPrivate::updateItem(QTreeWidgetItem *item) QColor QtTreePropertyBrowserPrivate::calculatedBackgroundColor(QtBrowserItem *item) const { QtBrowserItem *i = item; - const QMap<QtBrowserItem *, QColor>::const_iterator itEnd = m_indexToBackgroundColor.constEnd(); + const auto itEnd = m_indexToBackgroundColor.constEnd(); while (i) { - QMap<QtBrowserItem *, QColor>::const_iterator it = m_indexToBackgroundColor.constFind(i); + auto it = m_indexToBackgroundColor.constFind(i); if (it != itEnd) return it.value(); i = i->parent(); } - return QColor(); + return {}; } void QtTreePropertyBrowserPrivate::slotCollapsed(const QModelIndex &index) @@ -668,7 +654,7 @@ QTreeWidgetItem *QtTreePropertyBrowserPrivate::editedItem() const void QtTreePropertyBrowserPrivate::editItem(QtBrowserItem *browserItem) { - if (QTreeWidgetItem *treeItem = m_indexToItem.value(browserItem, 0)) { + if (QTreeWidgetItem *treeItem = m_indexToItem.value(browserItem, nullptr)) { m_treeWidget->setCurrentItem (treeItem, 1); m_treeWidget->editItem(treeItem, 1); } @@ -729,7 +715,9 @@ QtTreePropertyBrowser::QtTreePropertyBrowser(QWidget *parent) d_ptr->q_ptr = this; d_ptr->init(this); - connect(this, SIGNAL(currentItemChanged(QtBrowserItem*)), this, SLOT(slotCurrentBrowserItemChanged(QtBrowserItem*))); + QObject::connect(this, &QtAbstractPropertyBrowser::currentItemChanged, + this, [this](QtBrowserItem *current) + { d_ptr->slotCurrentBrowserItemChanged(current); }); } /*! diff --git a/src/shared/qtpropertybrowser/qttreepropertybrowser.h b/src/shared/qtpropertybrowser/qttreepropertybrowser.h index ce2a04f04..f86e7b826 100644 --- a/src/shared/qtpropertybrowser/qttreepropertybrowser.h +++ b/src/shared/qtpropertybrowser/qttreepropertybrowser.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTTREEPROPERTYBROWSER_H #define QTTREEPROPERTYBROWSER_H @@ -58,7 +22,6 @@ class QtTreePropertyBrowser : public QtAbstractPropertyBrowser Q_PROPERTY(int splitterPosition READ splitterPosition WRITE setSplitterPosition) Q_PROPERTY(bool propertiesWithoutValueMarked READ propertiesWithoutValueMarked WRITE setPropertiesWithoutValueMarked) public: - enum ResizeMode { Interactive, @@ -105,7 +68,6 @@ public: void editItem(QtBrowserItem *item); Q_SIGNALS: - void collapsed(QtBrowserItem *item); void expanded(QtBrowserItem *item); @@ -115,16 +77,9 @@ protected: void itemChanged(QtBrowserItem *item) override; private: - QScopedPointer<QtTreePropertyBrowserPrivate> d_ptr; Q_DECLARE_PRIVATE(QtTreePropertyBrowser) Q_DISABLE_COPY_MOVE(QtTreePropertyBrowser) - - Q_PRIVATE_SLOT(d_func(), void slotCollapsed(const QModelIndex &)) - Q_PRIVATE_SLOT(d_func(), void slotExpanded(const QModelIndex &)) - Q_PRIVATE_SLOT(d_func(), void slotCurrentBrowserItemChanged(QtBrowserItem *)) - Q_PRIVATE_SLOT(d_func(), void slotCurrentTreeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)) - }; QT_END_NAMESPACE diff --git a/src/shared/qtpropertybrowser/qtvariantproperty.cpp b/src/shared/qtpropertybrowser/qtvariantproperty.cpp index c1a51044c..e3974a8dd 100644 --- a/src/shared/qtpropertybrowser/qtvariantproperty.cpp +++ b/src/shared/qtpropertybrowser/qtvariantproperty.cpp @@ -1,48 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qtvariantproperty.h" #include "qtpropertymanager.h" #include "qteditorfactory.h" + #include <QtCore/QVariant> -#include <QtGui/QIcon> #include <QtCore/QDate> +#include <QtCore/QHash> #include <QtCore/QLocale> #include <QtCore/QRegularExpression> @@ -52,6 +17,10 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + +using QtIconMap = QMap<int, QIcon>; + class QtEnumPropertyType { }; @@ -129,12 +98,13 @@ int QtVariantPropertyManager::iconMapTypeId() return qMetaTypeId<QtIconMap>(); } -typedef QMap<const QtProperty *, QtProperty *> PropertyMap; -Q_GLOBAL_STATIC(PropertyMap, propertyToWrappedProperty) +using PropertyPropertyMap = QHash<const QtProperty *, QtProperty *>; + +Q_GLOBAL_STATIC(PropertyPropertyMap, propertyToWrappedProperty) static QtProperty *wrappedProperty(QtProperty *property) { - return propertyToWrappedProperty()->value(property, 0); + return propertyToWrappedProperty()->value(property, nullptr); } class QtVariantPropertyPrivate @@ -338,12 +308,12 @@ public: QMap<int, QtAbstractPropertyManager *> m_typeToPropertyManager; QMap<int, QMap<QString, int> > m_typeToAttributeToAttributeType; - QMap<const QtProperty *, QPair<QtVariantProperty *, int> > m_propertyToType; + QHash<const QtProperty *, std::pair<QtVariantProperty *, int>> m_propertyToType; QMap<int, int> m_typeToValueType; - QMap<QtProperty *, QtVariantProperty *> m_internalToProperty; + QHash<QtProperty *, QtVariantProperty *> m_internalToProperty; const QString m_constraintAttribute; const QString m_singleStepAttribute; @@ -357,15 +327,15 @@ public: }; QtVariantPropertyManagerPrivate::QtVariantPropertyManagerPrivate() : - m_constraintAttribute(QLatin1String("constraint")), - m_singleStepAttribute(QLatin1String("singleStep")), - m_decimalsAttribute(QLatin1String("decimals")), - m_enumIconsAttribute(QLatin1String("enumIcons")), - m_enumNamesAttribute(QLatin1String("enumNames")), - m_flagNamesAttribute(QLatin1String("flagNames")), - m_maximumAttribute(QLatin1String("maximum")), - m_minimumAttribute(QLatin1String("minimum")), - m_regExpAttribute(QLatin1String("regExp")) + m_constraintAttribute("constraint"_L1), + m_singleStepAttribute("singleStep"_L1), + m_decimalsAttribute("decimals"_L1), + m_enumIconsAttribute("enumIcons"_L1), + m_enumNamesAttribute("enumNames"_L1), + m_flagNamesAttribute("flagNames"_L1), + m_maximumAttribute("maximum"_L1), + m_minimumAttribute("minimum"_L1), + m_regExpAttribute("regExp"_L1) { } @@ -427,13 +397,13 @@ void QtVariantPropertyManagerPrivate::slotPropertyInserted(QtProperty *property, if (m_creatingProperty) return; - QtVariantProperty *varParent = m_internalToProperty.value(parent, 0); + QtVariantProperty *varParent = m_internalToProperty.value(parent, nullptr); if (!varParent) return; QtVariantProperty *varAfter = nullptr; if (after) { - varAfter = m_internalToProperty.value(after, 0); + varAfter = m_internalToProperty.value(after, nullptr); if (!varAfter) return; } @@ -445,7 +415,7 @@ void QtVariantPropertyManagerPrivate::slotPropertyRemoved(QtProperty *property, { Q_UNUSED(parent); - QtVariantProperty *varProperty = m_internalToProperty.value(property, 0); + QtVariantProperty *varProperty = m_internalToProperty.value(property, nullptr); if (!varProperty) return; @@ -454,7 +424,7 @@ void QtVariantPropertyManagerPrivate::slotPropertyRemoved(QtProperty *property, void QtVariantPropertyManagerPrivate::valueChanged(QtProperty *property, const QVariant &val) { - QtVariantProperty *varProp = m_internalToProperty.value(property, 0); + QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr); if (!varProp) return; emit q_ptr->valueChanged(varProp, val); @@ -468,7 +438,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, int void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, int min, int max) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) { emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); } @@ -476,7 +446,7 @@ void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, int void QtVariantPropertyManagerPrivate::slotSingleStepChanged(QtProperty *property, int step) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, QVariant(step)); } @@ -487,7 +457,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, dou void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, double min, double max) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) { emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); } @@ -495,13 +465,13 @@ void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, dou void QtVariantPropertyManagerPrivate::slotSingleStepChanged(QtProperty *property, double step) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, QVariant(step)); } void QtVariantPropertyManagerPrivate::slotDecimalsChanged(QtProperty *property, int prec) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) emit q_ptr->attributeChanged(varProp, m_decimalsAttribute, QVariant(prec)); } @@ -517,7 +487,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con void QtVariantPropertyManagerPrivate::slotRegExpChanged(QtProperty *property, const QRegularExpression ®Exp) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) emit q_ptr->attributeChanged(varProp, m_regExpAttribute, QVariant(regExp)); } @@ -528,7 +498,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, QDa void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, QDate min, QDate max) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) { emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); } @@ -578,7 +548,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, const QSize &min, const QSize &max) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) { emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); } @@ -591,7 +561,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, const QSizeF &min, const QSizeF &max) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) { emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); } @@ -604,7 +574,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con void QtVariantPropertyManagerPrivate::slotConstraintChanged(QtProperty *property, const QRect &constraint) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) emit q_ptr->attributeChanged(varProp, m_constraintAttribute, QVariant(constraint)); } @@ -615,7 +585,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con void QtVariantPropertyManagerPrivate::slotConstraintChanged(QtProperty *property, const QRectF &constraint) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) emit q_ptr->attributeChanged(varProp, m_constraintAttribute, QVariant(constraint)); } @@ -626,13 +596,13 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con void QtVariantPropertyManagerPrivate::slotEnumNamesChanged(QtProperty *property, const QStringList &enumNames) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) emit q_ptr->attributeChanged(varProp, m_enumNamesAttribute, QVariant(enumNames)); } void QtVariantPropertyManagerPrivate::slotEnumIconsChanged(QtProperty *property, const QMap<int, QIcon> &enumIcons) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) { QVariant v; v.setValue(enumIcons); emit q_ptr->attributeChanged(varProp, m_enumIconsAttribute, v); @@ -658,7 +628,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con void QtVariantPropertyManagerPrivate::slotFlagNamesChanged(QtProperty *property, const QStringList &flagNames) { - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + if (QtVariantProperty *varProp = m_internalToProperty.value(property, nullptr)) emit q_ptr->attributeChanged(varProp, m_flagNamesAttribute, QVariant(flagNames)); } @@ -918,20 +888,23 @@ QtVariantPropertyManager::QtVariantPropertyManager(QObject *parent) d_ptr->m_propertyType = 0; // IntPropertyManager - QtIntPropertyManager *intPropertyManager = new QtIntPropertyManager(this); + auto *intPropertyManager = new QtIntPropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::Int] = intPropertyManager; d_ptr->m_typeToAttributeToAttributeType[QMetaType::Int][d_ptr->m_minimumAttribute] = QMetaType::Int; d_ptr->m_typeToAttributeToAttributeType[QMetaType::Int][d_ptr->m_maximumAttribute] = QMetaType::Int; d_ptr->m_typeToAttributeToAttributeType[QMetaType::Int][d_ptr->m_singleStepAttribute] = QMetaType::Int; d_ptr->m_typeToValueType[QMetaType::Int] = QMetaType::Int; - connect(intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotValueChanged(QtProperty*,int))); - connect(intPropertyManager, SIGNAL(rangeChanged(QtProperty*,int,int)), - this, SLOT(slotRangeChanged(QtProperty*,int,int))); - connect(intPropertyManager, SIGNAL(singleStepChanged(QtProperty*,int)), - this, SLOT(slotSingleStepChanged(QtProperty*,int))); + connect(intPropertyManager, &QtIntPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotValueChanged(property, value); }); + connect(intPropertyManager, &QtIntPropertyManager::rangeChanged, + this, [this](QtProperty *property, int min, int max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(intPropertyManager, &QtIntPropertyManager::singleStepChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotSingleStepChanged(property, value); }); // DoublePropertyManager - QtDoublePropertyManager *doublePropertyManager = new QtDoublePropertyManager(this); + auto *doublePropertyManager = new QtDoublePropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::Double] = doublePropertyManager; d_ptr->m_typeToAttributeToAttributeType[QMetaType::Double][d_ptr->m_minimumAttribute] = QMetaType::Double; @@ -942,128 +915,160 @@ QtVariantPropertyManager::QtVariantPropertyManager(QObject *parent) d_ptr->m_typeToAttributeToAttributeType[QMetaType::Double][d_ptr->m_decimalsAttribute] = QMetaType::Int; d_ptr->m_typeToValueType[QMetaType::Double] = QMetaType::Double; - connect(doublePropertyManager, SIGNAL(valueChanged(QtProperty*,double)), - this, SLOT(slotValueChanged(QtProperty*,double))); - connect(doublePropertyManager, SIGNAL(rangeChanged(QtProperty*,double,double)), - this, SLOT(slotRangeChanged(QtProperty*,double,double))); - connect(doublePropertyManager, SIGNAL(singleStepChanged(QtProperty*,double)), - this, SLOT(slotSingleStepChanged(QtProperty*,double))); - connect(doublePropertyManager, SIGNAL(decimalsChanged(QtProperty*,int)), - this, SLOT(slotDecimalsChanged(QtProperty*,int))); + connect(doublePropertyManager, &QtDoublePropertyManager::valueChanged, + this, [this](QtProperty *property, double value) + { d_ptr->slotValueChanged(property, value); }); + connect(doublePropertyManager, &QtDoublePropertyManager::rangeChanged, + this, [this](QtProperty *property, double min, double max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(doublePropertyManager, &QtDoublePropertyManager::singleStepChanged, + this, [this](QtProperty *property, double value) + { d_ptr->slotSingleStepChanged(property, value); }); + connect(doublePropertyManager, &QtDoublePropertyManager::decimalsChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotDecimalsChanged(property, value); }); // BoolPropertyManager - QtBoolPropertyManager *boolPropertyManager = new QtBoolPropertyManager(this); + auto *boolPropertyManager = new QtBoolPropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::Bool] = boolPropertyManager; d_ptr->m_typeToValueType[QMetaType::Bool] = QMetaType::Bool; - connect(boolPropertyManager, SIGNAL(valueChanged(QtProperty*,bool)), - this, SLOT(slotValueChanged(QtProperty*,bool))); + connect(boolPropertyManager, &QtBoolPropertyManager::valueChanged, + this, [this](QtProperty *property, bool value) + { d_ptr->slotValueChanged(property, value); }); // StringPropertyManager - QtStringPropertyManager *stringPropertyManager = new QtStringPropertyManager(this); + auto *stringPropertyManager = new QtStringPropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QString] = stringPropertyManager; d_ptr->m_typeToValueType[QMetaType::QString] = QMetaType::QString; d_ptr->m_typeToAttributeToAttributeType[QMetaType::QString][d_ptr->m_regExpAttribute] = QMetaType::QRegularExpression; - connect(stringPropertyManager, SIGNAL(valueChanged(QtProperty*,QString)), - this, SLOT(slotValueChanged(QtProperty*,QString))); - connect(stringPropertyManager, SIGNAL(regExpChanged(QtProperty*,QRegularExpression)), - this, SLOT(slotRegExpChanged(QtProperty*,QRegularExpression))); + connect(stringPropertyManager, &QtStringPropertyManager::valueChanged, + this, [this](QtProperty *property, const QString &value) + { d_ptr->slotValueChanged(property, value); }); + connect(stringPropertyManager, &QtStringPropertyManager::regExpChanged, + this, [this](QtProperty *property, const QRegularExpression &value) + { d_ptr->slotRegExpChanged(property, value); }); // DatePropertyManager - QtDatePropertyManager *datePropertyManager = new QtDatePropertyManager(this); + auto *datePropertyManager = new QtDatePropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QDate] = datePropertyManager; d_ptr->m_typeToValueType[QMetaType::QDate] = QMetaType::QDate; d_ptr->m_typeToAttributeToAttributeType[QMetaType::QDate][d_ptr->m_minimumAttribute] = QMetaType::QDate; d_ptr->m_typeToAttributeToAttributeType[QMetaType::QDate][d_ptr->m_maximumAttribute] = QMetaType::QDate; - connect(datePropertyManager, SIGNAL(valueChanged(QtProperty*,QDate)), - this, SLOT(slotValueChanged(QtProperty*,QDate))); - connect(datePropertyManager, SIGNAL(rangeChanged(QtProperty*,QDate,QDate)), - this, SLOT(slotRangeChanged(QtProperty*,QDate,QDate))); + connect(datePropertyManager, &QtDatePropertyManager::valueChanged, + this, [this](QtProperty *property, const QDate &value) + { d_ptr->slotValueChanged(property, value); }); + connect(datePropertyManager, &QtDatePropertyManager::rangeChanged, + this, [this](QtProperty *property, const QDate &min, const QDate &max) + { d_ptr->slotRangeChanged(property, min, max); }); // TimePropertyManager - QtTimePropertyManager *timePropertyManager = new QtTimePropertyManager(this); + auto *timePropertyManager = new QtTimePropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QTime] = timePropertyManager; d_ptr->m_typeToValueType[QMetaType::QTime] = QMetaType::QTime; - connect(timePropertyManager, SIGNAL(valueChanged(QtProperty*,QTime)), - this, SLOT(slotValueChanged(QtProperty*,QTime))); + connect(timePropertyManager, &QtTimePropertyManager::valueChanged, + this, [this](QtProperty *property, const QTime &value) + { d_ptr->slotValueChanged(property, value); }); // DateTimePropertyManager - QtDateTimePropertyManager *dateTimePropertyManager = new QtDateTimePropertyManager(this); + auto *dateTimePropertyManager = new QtDateTimePropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QDateTime] = dateTimePropertyManager; d_ptr->m_typeToValueType[QMetaType::QDateTime] = QMetaType::QDateTime; - connect(dateTimePropertyManager, SIGNAL(valueChanged(QtProperty*,QDateTime)), - this, SLOT(slotValueChanged(QtProperty*,QDateTime))); + connect(dateTimePropertyManager, &QtDateTimePropertyManager::valueChanged, + this, [this](QtProperty *property, const QDateTime &value) + { d_ptr->slotValueChanged(property, value); }); // KeySequencePropertyManager - QtKeySequencePropertyManager *keySequencePropertyManager = new QtKeySequencePropertyManager(this); + auto *keySequencePropertyManager = new QtKeySequencePropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QKeySequence] = keySequencePropertyManager; d_ptr->m_typeToValueType[QMetaType::QKeySequence] = QMetaType::QKeySequence; - connect(keySequencePropertyManager, SIGNAL(valueChanged(QtProperty*,QKeySequence)), - this, SLOT(slotValueChanged(QtProperty*,QKeySequence))); + connect(keySequencePropertyManager, &QtKeySequencePropertyManager::valueChanged, + this, [this](QtProperty *property, const QKeySequence &value) + { d_ptr->slotValueChanged(property, value); }); // CharPropertyManager - QtCharPropertyManager *charPropertyManager = new QtCharPropertyManager(this); + auto *charPropertyManager = new QtCharPropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QChar] = charPropertyManager; d_ptr->m_typeToValueType[QMetaType::QChar] = QMetaType::QChar; - connect(charPropertyManager, SIGNAL(valueChanged(QtProperty*,QChar)), - this, SLOT(slotValueChanged(QtProperty*,QChar))); + connect(charPropertyManager, &QtCharPropertyManager::valueChanged, + this, [this](QtProperty *property, const QChar &value) + { d_ptr->slotValueChanged(property, value); }); // LocalePropertyManager - QtLocalePropertyManager *localePropertyManager = new QtLocalePropertyManager(this); + auto *localePropertyManager = new QtLocalePropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QLocale] = localePropertyManager; d_ptr->m_typeToValueType[QMetaType::QLocale] = QMetaType::QLocale; - connect(localePropertyManager, SIGNAL(valueChanged(QtProperty*,QLocale)), - this, SLOT(slotValueChanged(QtProperty*,QLocale))); - connect(localePropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotValueChanged(QtProperty*,int))); - connect(localePropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*))); - connect(localePropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*))); + connect(localePropertyManager, &QtLocalePropertyManager::valueChanged, + this, [this](QtProperty *property, const QLocale &value) + { d_ptr->slotValueChanged(property, value); }); + connect(localePropertyManager->subEnumPropertyManager(), &QtEnumPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotValueChanged(property, value); }); + connect(localePropertyManager, &QtAbstractPropertyManager::propertyInserted, + this, [this](QtProperty *property, QtProperty *parent, QtProperty *after) + { d_ptr->slotPropertyInserted(property, parent, after); }); + connect(localePropertyManager, &QtAbstractPropertyManager::propertyRemoved, + this, [this](QtProperty *property, QtProperty *parent) + { d_ptr->slotPropertyRemoved(property, parent); }); // PointPropertyManager - QtPointPropertyManager *pointPropertyManager = new QtPointPropertyManager(this); + auto *pointPropertyManager = new QtPointPropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QPoint] = pointPropertyManager; d_ptr->m_typeToValueType[QMetaType::QPoint] = QMetaType::QPoint; - connect(pointPropertyManager, SIGNAL(valueChanged(QtProperty*,QPoint)), - this, SLOT(slotValueChanged(QtProperty*,QPoint))); - connect(pointPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotValueChanged(QtProperty*,int))); - connect(pointPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*))); - connect(pointPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*))); + connect(pointPropertyManager, &QtPointPropertyManager::valueChanged, + this, [this](QtProperty *property, const QPoint &value) + { d_ptr->slotValueChanged(property, value); }); + connect(pointPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotValueChanged(property, value); }); + connect(pointPropertyManager, &QtAbstractPropertyManager::propertyInserted, + this, [this](QtProperty *property, QtProperty *parent, QtProperty *after) + { d_ptr->slotPropertyInserted(property, parent, after); }); + connect(pointPropertyManager, &QtAbstractPropertyManager::propertyRemoved, + this, [this](QtProperty *property, QtProperty *parent) + { d_ptr->slotPropertyRemoved(property, parent); }); // PointFPropertyManager - QtPointFPropertyManager *pointFPropertyManager = new QtPointFPropertyManager(this); + auto *pointFPropertyManager = new QtPointFPropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QPointF] = pointFPropertyManager; d_ptr->m_typeToValueType[QMetaType::QPointF] = QMetaType::QPointF; d_ptr->m_typeToAttributeToAttributeType[QMetaType::QPointF][d_ptr->m_decimalsAttribute] = QMetaType::Int; - connect(pointFPropertyManager, SIGNAL(valueChanged(QtProperty*,QPointF)), - this, SLOT(slotValueChanged(QtProperty*,QPointF))); - connect(pointFPropertyManager, SIGNAL(decimalsChanged(QtProperty*,int)), - this, SLOT(slotDecimalsChanged(QtProperty*,int))); - connect(pointFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty*,double)), - this, SLOT(slotValueChanged(QtProperty*,double))); - connect(pointFPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*))); - connect(pointFPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*))); + connect(pointFPropertyManager, &QtPointFPropertyManager::valueChanged, + this, [this](QtProperty *property, const QPointF &value) + { d_ptr->slotValueChanged(property, value); }); + connect(pointFPropertyManager, &QtPointFPropertyManager::decimalsChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotDecimalsChanged(property, value); }); + connect(pointFPropertyManager->subDoublePropertyManager(), &QtDoublePropertyManager::valueChanged, + this, [this](QtProperty *property, double value) + { d_ptr->slotValueChanged(property, value); }); + connect(pointFPropertyManager, &QtAbstractPropertyManager::propertyInserted, + this, [this](QtProperty *property, QtProperty *parent, QtProperty *after) + { d_ptr->slotPropertyInserted(property, parent, after); }); + connect(pointFPropertyManager, &QtAbstractPropertyManager::propertyRemoved, + this, [this](QtProperty *property, QtProperty *parent) + { d_ptr->slotPropertyRemoved(property, parent); }); // SizePropertyManager - QtSizePropertyManager *sizePropertyManager = new QtSizePropertyManager(this); + auto *sizePropertyManager = new QtSizePropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QSize] = sizePropertyManager; d_ptr->m_typeToValueType[QMetaType::QSize] = QMetaType::QSize; d_ptr->m_typeToAttributeToAttributeType[QMetaType::QSize][d_ptr->m_minimumAttribute] = QMetaType::QSize; d_ptr->m_typeToAttributeToAttributeType[QMetaType::QSize][d_ptr->m_maximumAttribute] = QMetaType::QSize; - connect(sizePropertyManager, SIGNAL(valueChanged(QtProperty*,QSize)), - this, SLOT(slotValueChanged(QtProperty*,QSize))); - connect(sizePropertyManager, SIGNAL(rangeChanged(QtProperty*,QSize,QSize)), - this, SLOT(slotRangeChanged(QtProperty*,QSize,QSize))); - connect(sizePropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotValueChanged(QtProperty*,int))); - connect(sizePropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty*,int,int)), - this, SLOT(slotRangeChanged(QtProperty*,int,int))); - connect(sizePropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*))); - connect(sizePropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*))); + connect(sizePropertyManager, &QtSizePropertyManager::valueChanged, + this, [this](QtProperty *property, const QSize &value) + { d_ptr->slotValueChanged(property, value); }); + connect(sizePropertyManager, &QtSizePropertyManager::rangeChanged, + this, [this](QtProperty *property, const QSize &min, const QSize &max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(sizePropertyManager->subIntPropertyManager(), &QtIntPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotValueChanged(property, value); }); + connect(sizePropertyManager->subIntPropertyManager(), &QtIntPropertyManager::rangeChanged, + this, [this](QtProperty *property, int min, int max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(sizePropertyManager, &QtAbstractPropertyManager::propertyInserted, + this, [this](QtProperty *property, QtProperty *parent, QtProperty *after) + { d_ptr->slotPropertyInserted(property, parent, after); }); + connect(sizePropertyManager, &QtAbstractPropertyManager::propertyRemoved, + this, [this](QtProperty *property, QtProperty *parent) + { d_ptr->slotPropertyRemoved(property, parent); }); // SizeFPropertyManager - QtSizeFPropertyManager *sizeFPropertyManager = new QtSizeFPropertyManager(this); + auto *sizeFPropertyManager = new QtSizeFPropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QSizeF] = sizeFPropertyManager; d_ptr->m_typeToValueType[QMetaType::QSizeF] = QMetaType::QSizeF; d_ptr->m_typeToAttributeToAttributeType[QMetaType::QSizeF][d_ptr->m_minimumAttribute] = @@ -1072,153 +1077,193 @@ QtVariantPropertyManager::QtVariantPropertyManager(QObject *parent) QMetaType::QSizeF; d_ptr->m_typeToAttributeToAttributeType[QMetaType::QSizeF][d_ptr->m_decimalsAttribute] = QMetaType::Int; - connect(sizeFPropertyManager, SIGNAL(valueChanged(QtProperty*,QSizeF)), - this, SLOT(slotValueChanged(QtProperty*,QSizeF))); - connect(sizeFPropertyManager, SIGNAL(rangeChanged(QtProperty*,QSizeF,QSizeF)), - this, SLOT(slotRangeChanged(QtProperty*,QSizeF,QSizeF))); - connect(sizeFPropertyManager, SIGNAL(decimalsChanged(QtProperty*,int)), - this, SLOT(slotDecimalsChanged(QtProperty*,int))); - connect(sizeFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty*,double)), - this, SLOT(slotValueChanged(QtProperty*,double))); - connect(sizeFPropertyManager->subDoublePropertyManager(), SIGNAL(rangeChanged(QtProperty*,double,double)), - this, SLOT(slotRangeChanged(QtProperty*,double,double))); - connect(sizeFPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*))); - connect(sizeFPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*))); + connect(sizeFPropertyManager, &QtSizeFPropertyManager::valueChanged, + this, [this](QtProperty *property, const QSizeF &value) + { d_ptr->slotValueChanged(property, value); }); + connect(sizeFPropertyManager, &QtSizeFPropertyManager::rangeChanged, + this, [this](QtProperty *property, const QSizeF &min, const QSizeF &max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(sizeFPropertyManager->subDoublePropertyManager(), &QtDoublePropertyManager::valueChanged, + this, [this](QtProperty *property, double value) + { d_ptr->slotValueChanged(property, value); }); + connect(sizeFPropertyManager->subDoublePropertyManager(), &QtDoublePropertyManager::rangeChanged, + this, [this](QtProperty *property, double min, double max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(sizeFPropertyManager, &QtAbstractPropertyManager::propertyInserted, + this, [this](QtProperty *property, QtProperty *parent, QtProperty *after) + { d_ptr->slotPropertyInserted(property, parent, after); }); + connect(sizeFPropertyManager, &QtAbstractPropertyManager::propertyRemoved, + this, [this](QtProperty *property, QtProperty *parent) + { d_ptr->slotPropertyRemoved(property, parent); }); // RectPropertyManager - QtRectPropertyManager *rectPropertyManager = new QtRectPropertyManager(this); + auto *rectPropertyManager = new QtRectPropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QRect] = rectPropertyManager; d_ptr->m_typeToValueType[QMetaType::QRect] = QMetaType::QRect; d_ptr->m_typeToAttributeToAttributeType[QMetaType::QRect][d_ptr->m_constraintAttribute] = QMetaType::QRect; - connect(rectPropertyManager, SIGNAL(valueChanged(QtProperty*,QRect)), - this, SLOT(slotValueChanged(QtProperty*,QRect))); - connect(rectPropertyManager, SIGNAL(constraintChanged(QtProperty*,QRect)), - this, SLOT(slotConstraintChanged(QtProperty*,QRect))); - connect(rectPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotValueChanged(QtProperty*,int))); - connect(rectPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty*,int,int)), - this, SLOT(slotRangeChanged(QtProperty*,int,int))); - connect(rectPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*))); - connect(rectPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*))); + connect(rectPropertyManager, &QtRectPropertyManager::valueChanged, + this, [this](QtProperty *property, const QRect &value) + { d_ptr->slotValueChanged(property, value); }); + connect(rectPropertyManager, &QtRectPropertyManager::constraintChanged, + this, [this](QtProperty *property, const QRect &value) + { d_ptr->slotConstraintChanged(property, value); }); + connect(rectPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotValueChanged(property, value); }); + connect(rectPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::rangeChanged, + this, [this](QtProperty *property, int min, int max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(rectPropertyManager, &QtAbstractPropertyManager::propertyInserted, + this, [this](QtProperty *property, QtProperty *parent, QtProperty *after) + { d_ptr->slotPropertyInserted(property, parent, after); }); + connect(rectPropertyManager, &QtAbstractPropertyManager::propertyRemoved, + this, [this](QtProperty *property, QtProperty *parent) + { d_ptr->slotPropertyRemoved(property, parent); }); // RectFPropertyManager - QtRectFPropertyManager *rectFPropertyManager = new QtRectFPropertyManager(this); + auto *rectFPropertyManager = new QtRectFPropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QRectF] = rectFPropertyManager; d_ptr->m_typeToValueType[QMetaType::QRectF] = QMetaType::QRectF; d_ptr->m_typeToAttributeToAttributeType[QMetaType::QRectF][d_ptr->m_constraintAttribute] = QMetaType::QRectF; d_ptr->m_typeToAttributeToAttributeType[QMetaType::QRectF][d_ptr->m_decimalsAttribute] = QMetaType::Int; - connect(rectFPropertyManager, SIGNAL(valueChanged(QtProperty*,QRectF)), - this, SLOT(slotValueChanged(QtProperty*,QRectF))); - connect(rectFPropertyManager, SIGNAL(constraintChanged(QtProperty*,QRectF)), - this, SLOT(slotConstraintChanged(QtProperty*,QRectF))); - connect(rectFPropertyManager, SIGNAL(decimalsChanged(QtProperty*,int)), - this, SLOT(slotDecimalsChanged(QtProperty*,int))); - connect(rectFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty*,double)), - this, SLOT(slotValueChanged(QtProperty*,double))); - connect(rectFPropertyManager->subDoublePropertyManager(), SIGNAL(rangeChanged(QtProperty*,double,double)), - this, SLOT(slotRangeChanged(QtProperty*,double,double))); - connect(rectFPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*))); - connect(rectFPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*))); + connect(rectFPropertyManager, &QtRectFPropertyManager::valueChanged, + this, [this](QtProperty *property, const QRectF &value) + { d_ptr->slotValueChanged(property, value); }); + connect(rectFPropertyManager, &QtRectFPropertyManager::constraintChanged, + this, [this](QtProperty *property, const QRectF &value) + { d_ptr->slotConstraintChanged(property, value); }); + connect(rectFPropertyManager->subDoublePropertyManager(), &QtDoublePropertyManager::valueChanged, + this, [this](QtProperty *property, double value) + { d_ptr->slotValueChanged(property, value); }); + connect(rectFPropertyManager->subDoublePropertyManager(), &QtDoublePropertyManager::rangeChanged, + this, [this](QtProperty *property, double min, double max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(rectFPropertyManager, &QtAbstractPropertyManager::propertyInserted, + this, [this](QtProperty *property, QtProperty *parent, QtProperty *after) + { d_ptr->slotPropertyInserted(property, parent, after); }); + connect(rectFPropertyManager, &QtAbstractPropertyManager::propertyRemoved, + this, [this](QtProperty *property, QtProperty *parent) + { d_ptr->slotPropertyRemoved(property, parent); }); // ColorPropertyManager - QtColorPropertyManager *colorPropertyManager = new QtColorPropertyManager(this); + auto *colorPropertyManager = new QtColorPropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QColor] = colorPropertyManager; d_ptr->m_typeToValueType[QMetaType::QColor] = QMetaType::QColor; - connect(colorPropertyManager, SIGNAL(valueChanged(QtProperty*,QColor)), - this, SLOT(slotValueChanged(QtProperty*,QColor))); - connect(colorPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotValueChanged(QtProperty*,int))); - connect(colorPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*))); - connect(colorPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*))); + connect(colorPropertyManager, &QtColorPropertyManager::valueChanged, + this, [this](QtProperty *property, const QColor &value) + { d_ptr->slotValueChanged(property, value); }); + connect(colorPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotValueChanged(property, value); }); + connect(colorPropertyManager, &QtAbstractPropertyManager::propertyInserted, + this, [this](QtProperty *property, QtProperty *parent, QtProperty *after) + { d_ptr->slotPropertyInserted(property, parent, after); }); + connect(colorPropertyManager, &QtAbstractPropertyManager::propertyRemoved, + this, [this](QtProperty *property, QtProperty *parent) + { d_ptr->slotPropertyRemoved(property, parent); }); // EnumPropertyManager int enumId = enumTypeId(); - QtEnumPropertyManager *enumPropertyManager = new QtEnumPropertyManager(this); + auto *enumPropertyManager = new QtEnumPropertyManager(this); d_ptr->m_typeToPropertyManager[enumId] = enumPropertyManager; d_ptr->m_typeToValueType[enumId] = QMetaType::Int; d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumNamesAttribute] = QMetaType::QStringList; d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumIconsAttribute] = iconMapTypeId(); - connect(enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotValueChanged(QtProperty*,int))); - connect(enumPropertyManager, SIGNAL(enumNamesChanged(QtProperty*,QStringList)), - this, SLOT(slotEnumNamesChanged(QtProperty*,QStringList))); - connect(enumPropertyManager, SIGNAL(enumIconsChanged(QtProperty*,QMap<int,QIcon>)), - this, SLOT(slotEnumIconsChanged(QtProperty*,QMap<int,QIcon>))); + connect(enumPropertyManager, &QtEnumPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotValueChanged(property, value); }); + connect(enumPropertyManager, &QtEnumPropertyManager::enumNamesChanged, + this, [this](QtProperty *property, const QStringList &value) + { d_ptr->slotEnumNamesChanged(property, value); }); + connect(enumPropertyManager, &QtEnumPropertyManager::enumIconsChanged, + this, [this](QtProperty *property, const QMap<int,QIcon> &value) + { d_ptr->slotEnumIconsChanged(property, value); }); // SizePolicyPropertyManager - QtSizePolicyPropertyManager *sizePolicyPropertyManager = new QtSizePolicyPropertyManager(this); + auto *sizePolicyPropertyManager = new QtSizePolicyPropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QSizePolicy] = sizePolicyPropertyManager; d_ptr->m_typeToValueType[QMetaType::QSizePolicy] = QMetaType::QSizePolicy; - connect(sizePolicyPropertyManager, SIGNAL(valueChanged(QtProperty*,QSizePolicy)), - this, SLOT(slotValueChanged(QtProperty*,QSizePolicy))); - connect(sizePolicyPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotValueChanged(QtProperty*,int))); - connect(sizePolicyPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty*,int,int)), - this, SLOT(slotRangeChanged(QtProperty*,int,int))); - connect(sizePolicyPropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotValueChanged(QtProperty*,int))); - connect(sizePolicyPropertyManager->subEnumPropertyManager(), - SIGNAL(enumNamesChanged(QtProperty*,QStringList)), - this, SLOT(slotEnumNamesChanged(QtProperty*,QStringList))); - connect(sizePolicyPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*))); - connect(sizePolicyPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*))); + connect(sizePolicyPropertyManager, &QtSizePolicyPropertyManager::valueChanged, + this, [this](QtProperty *property, const QSizePolicy &value) + { d_ptr->slotValueChanged(property, value); }); + connect(sizePolicyPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotValueChanged(property, value); }); + connect(sizePolicyPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::rangeChanged, + this, [this](QtProperty *property, int min, int max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(sizePolicyPropertyManager->subEnumPropertyManager(), &QtEnumPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotValueChanged(property, value); }); + connect(sizePolicyPropertyManager->subEnumPropertyManager(), &QtEnumPropertyManager::enumNamesChanged, + this, [this](QtProperty *property, const QStringList &value) + { d_ptr->slotEnumNamesChanged(property, value); }); + connect(sizePolicyPropertyManager, &QtAbstractPropertyManager::propertyInserted, + this, [this](QtProperty *property, QtProperty *parent, QtProperty *after) + { d_ptr->slotPropertyInserted(property, parent, after); }); + connect(sizePolicyPropertyManager, &QtAbstractPropertyManager::propertyRemoved, + this, [this](QtProperty *property, QtProperty *parent) + { d_ptr->slotPropertyRemoved(property, parent); }); // FontPropertyManager - QtFontPropertyManager *fontPropertyManager = new QtFontPropertyManager(this); + auto *fontPropertyManager = new QtFontPropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QFont] = fontPropertyManager; d_ptr->m_typeToValueType[QMetaType::QFont] = QMetaType::QFont; - connect(fontPropertyManager, SIGNAL(valueChanged(QtProperty*,QFont)), - this, SLOT(slotValueChanged(QtProperty*,QFont))); - connect(fontPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotValueChanged(QtProperty*,int))); - connect(fontPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty*,int,int)), - this, SLOT(slotRangeChanged(QtProperty*,int,int))); - connect(fontPropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotValueChanged(QtProperty*,int))); - connect(fontPropertyManager->subEnumPropertyManager(), - SIGNAL(enumNamesChanged(QtProperty*,QStringList)), - this, SLOT(slotEnumNamesChanged(QtProperty*,QStringList))); - connect(fontPropertyManager->subBoolPropertyManager(), SIGNAL(valueChanged(QtProperty*,bool)), - this, SLOT(slotValueChanged(QtProperty*,bool))); - connect(fontPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*))); - connect(fontPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*))); + connect(fontPropertyManager, &QtFontPropertyManager::valueChanged, + this, [this](QtProperty *property, const QFont &value) + { d_ptr->slotValueChanged(property, value); }); + connect(fontPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotValueChanged(property, value); }); + connect(fontPropertyManager->subIntPropertyManager(), &QtIntPropertyManager::rangeChanged, + this, [this](QtProperty *property, int min, int max) + { d_ptr->slotRangeChanged(property, min, max); }); + connect(fontPropertyManager->subEnumPropertyManager(), &QtEnumPropertyManager::valueChanged, + this, [this](QtProperty *property, int value) + { d_ptr->slotValueChanged(property, value); }); + connect(fontPropertyManager->subEnumPropertyManager(), &QtEnumPropertyManager::enumNamesChanged, + this, [this](QtProperty *property, const QStringList &value) + { d_ptr->slotEnumNamesChanged(property, value); }); + connect(fontPropertyManager->subBoolPropertyManager(), &QtBoolPropertyManager::valueChanged, + this, [this](QtProperty *property, bool value) + { d_ptr->slotValueChanged(property, value); }); + connect(fontPropertyManager, &QtAbstractPropertyManager::propertyInserted, + this, [this](QtProperty *property, QtProperty *parent, QtProperty *after) + { d_ptr->slotPropertyInserted(property, parent, after); }); + connect(fontPropertyManager, &QtAbstractPropertyManager::propertyRemoved, + this, [this](QtProperty *property, QtProperty *parent) + { d_ptr->slotPropertyRemoved(property, parent); }); // CursorPropertyManager - QtCursorPropertyManager *cursorPropertyManager = new QtCursorPropertyManager(this); + auto *cursorPropertyManager = new QtCursorPropertyManager(this); d_ptr->m_typeToPropertyManager[QMetaType::QCursor] = cursorPropertyManager; d_ptr->m_typeToValueType[QMetaType::QCursor] = QMetaType::QCursor; - connect(cursorPropertyManager, SIGNAL(valueChanged(QtProperty*,QCursor)), - this, SLOT(slotValueChanged(QtProperty*,QCursor))); + connect(cursorPropertyManager, &QtCursorPropertyManager::valueChanged, + this, [this](QtProperty *property, const QCursor &value) + { d_ptr->slotValueChanged(property, value); }); // FlagPropertyManager int flagId = flagTypeId(); - QtFlagPropertyManager *flagPropertyManager = new QtFlagPropertyManager(this); + auto *flagPropertyManager = new QtFlagPropertyManager(this); d_ptr->m_typeToPropertyManager[flagId] = flagPropertyManager; d_ptr->m_typeToValueType[flagId] = QMetaType::Int; d_ptr->m_typeToAttributeToAttributeType[flagId][d_ptr->m_flagNamesAttribute] = QMetaType::QStringList; - connect(flagPropertyManager, SIGNAL(valueChanged(QtProperty*,int)), - this, SLOT(slotValueChanged(QtProperty*,int))); - connect(flagPropertyManager, SIGNAL(flagNamesChanged(QtProperty*,QStringList)), - this, SLOT(slotFlagNamesChanged(QtProperty*,QStringList))); - connect(flagPropertyManager->subBoolPropertyManager(), SIGNAL(valueChanged(QtProperty*,bool)), - this, SLOT(slotValueChanged(QtProperty*,bool))); - connect(flagPropertyManager, SIGNAL(propertyInserted(QtProperty*,QtProperty*,QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*,QtProperty*,QtProperty*))); - connect(flagPropertyManager, SIGNAL(propertyRemoved(QtProperty*,QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*,QtProperty*))); + connect(flagPropertyManager, &QtFlagPropertyManager::valueChanged, + this, [this](QtProperty *property, const QColor &value) + { d_ptr->slotValueChanged(property, value); }); + connect(flagPropertyManager, &QtFlagPropertyManager::flagNamesChanged, + this, [this](QtProperty *property, const QStringList &value) + { d_ptr->slotFlagNamesChanged(property, value); }); + connect(flagPropertyManager->subBoolPropertyManager(), &QtBoolPropertyManager::valueChanged, + this, [this](QtProperty *property, bool value) + { d_ptr->slotValueChanged(property, value); }); + connect(flagPropertyManager, &QtAbstractPropertyManager::propertyInserted, + this, [this](QtProperty *property, QtProperty *parent, QtProperty *after) + { d_ptr->slotPropertyInserted(property, parent, after); }); + connect(flagPropertyManager, &QtAbstractPropertyManager::propertyRemoved, + this, [this](QtProperty *property, QtProperty *parent) + { d_ptr->slotPropertyRemoved(property, parent); }); // FlagPropertyManager int groupId = groupTypeId(); - QtGroupPropertyManager *groupPropertyManager = new QtGroupPropertyManager(this); + auto *groupPropertyManager = new QtGroupPropertyManager(this); d_ptr->m_typeToPropertyManager[groupId] = groupPropertyManager; d_ptr->m_typeToValueType[groupId] = QMetaType::UnknownType; } @@ -1241,7 +1286,7 @@ QtVariantPropertyManager::~QtVariantPropertyManager() */ QtVariantProperty *QtVariantPropertyManager::variantProperty(const QtProperty *property) const { - const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::const_iterator it = d_ptr->m_propertyToType.constFind(property); + const auto it = d_ptr->m_propertyToType.constFind(property); if (it == d_ptr->m_propertyToType.constEnd()) return 0; return it.value().first; @@ -1302,60 +1347,60 @@ QtVariantProperty *QtVariantPropertyManager::addProperty(int propertyType, const */ QVariant QtVariantPropertyManager::value(const QtProperty *property) const { - QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); - if (internProp == 0) - return QVariant(); + QtProperty *internProp = propertyToWrappedProperty()->value(property, nullptr); + if (internProp == nullptr) + return {}; QtAbstractPropertyManager *manager = internProp->propertyManager(); - if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { + if (auto *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { return intManager->value(internProp); - } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { + } else if (auto *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { return doubleManager->value(internProp); - } else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) { + } else if (auto *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) { return boolManager->value(internProp); - } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { + } else if (auto *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { return stringManager->value(internProp); - } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { + } else if (auto *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { return dateManager->value(internProp); - } else if (QtTimePropertyManager *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) { + } else if (auto *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) { return timeManager->value(internProp); - } else if (QtDateTimePropertyManager *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) { + } else if (auto *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) { return dateTimeManager->value(internProp); - } else if (QtKeySequencePropertyManager *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) { + } else if (auto *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) { return QVariant::fromValue(keySequenceManager->value(internProp)); - } else if (QtCharPropertyManager *charManager = qobject_cast<QtCharPropertyManager *>(manager)) { + } else if (auto *charManager = qobject_cast<QtCharPropertyManager *>(manager)) { return charManager->value(internProp); - } else if (QtLocalePropertyManager *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) { + } else if (auto *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) { return localeManager->value(internProp); - } else if (QtPointPropertyManager *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) { + } else if (auto *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) { return pointManager->value(internProp); - } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { + } else if (auto *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { return pointFManager->value(internProp); - } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { + } else if (auto *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { return sizeManager->value(internProp); - } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { + } else if (auto *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { return sizeFManager->value(internProp); - } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { + } else if (auto *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { return rectManager->value(internProp); - } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { + } else if (auto *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { return rectFManager->value(internProp); - } else if (QtColorPropertyManager *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) { + } else if (auto *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) { return colorManager->value(internProp); - } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { + } else if (auto *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { return enumManager->value(internProp); } else if (QtSizePolicyPropertyManager *sizePolicyManager = qobject_cast<QtSizePolicyPropertyManager *>(manager)) { return sizePolicyManager->value(internProp); - } else if (QtFontPropertyManager *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) { + } else if (auto *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) { return fontManager->value(internProp); #ifndef QT_NO_CURSOR - } else if (QtCursorPropertyManager *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) { + } else if (auto *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) { return cursorManager->value(internProp); #endif - } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { + } else if (auto *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { return flagManager->value(internProp); } - return QVariant(); + return {}; } /*! @@ -1388,7 +1433,7 @@ int QtVariantPropertyManager::valueType(int propertyType) const */ int QtVariantPropertyManager::propertyType(const QtProperty *property) const { - const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::const_iterator it = d_ptr->m_propertyToType.constFind(property); + const auto it = d_ptr->m_propertyToType.constFind(property); if (it == d_ptr->m_propertyToType.constEnd()) return 0; return it.value().second; @@ -1408,32 +1453,31 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co { int propType = propertyType(property); if (!propType) - return QVariant(); + return {}; - QMap<int, QMap<QString, int> >::ConstIterator it = - d_ptr->m_typeToAttributeToAttributeType.find(propType); + const auto it = d_ptr->m_typeToAttributeToAttributeType.constFind(propType); if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd()) - return QVariant(); + return {}; - QMap<QString, int> attributes = it.value(); - QMap<QString, int>::ConstIterator itAttr = attributes.find(attribute); + const QMap<QString, int> &attributes = it.value(); + const auto itAttr = attributes.constFind(attribute); if (itAttr == attributes.constEnd()) - return QVariant(); + return {}; - QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); - if (internProp == 0) - return QVariant(); + QtProperty *internProp = propertyToWrappedProperty()->value(property, nullptr); + if (internProp == nullptr) + return {}; QtAbstractPropertyManager *manager = internProp->propertyManager(); - if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { + if (auto *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) return intManager->maximum(internProp); if (attribute == d_ptr->m_minimumAttribute) return intManager->minimum(internProp); if (attribute == d_ptr->m_singleStepAttribute) return intManager->singleStep(internProp); - return QVariant(); - } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { + return {}; + } else if (auto *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) return doubleManager->maximum(internProp); if (attribute == d_ptr->m_minimumAttribute) @@ -1442,46 +1486,46 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co return doubleManager->singleStep(internProp); if (attribute == d_ptr->m_decimalsAttribute) return doubleManager->decimals(internProp); - return QVariant(); - } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { + return {}; + } else if (auto *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { if (attribute == d_ptr->m_regExpAttribute) return stringManager->regExp(internProp); - return QVariant(); - } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { + return {}; + } else if (auto *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) return dateManager->maximum(internProp); if (attribute == d_ptr->m_minimumAttribute) return dateManager->minimum(internProp); - return QVariant(); - } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { + return {}; + } else if (auto *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { if (attribute == d_ptr->m_decimalsAttribute) return pointFManager->decimals(internProp); - return QVariant(); - } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { + return {}; + } else if (auto *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) return sizeManager->maximum(internProp); if (attribute == d_ptr->m_minimumAttribute) return sizeManager->minimum(internProp); - return QVariant(); - } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { + return {}; + } else if (auto *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) return sizeFManager->maximum(internProp); if (attribute == d_ptr->m_minimumAttribute) return sizeFManager->minimum(internProp); if (attribute == d_ptr->m_decimalsAttribute) return sizeFManager->decimals(internProp); - return QVariant(); - } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { + return {}; + } else if (auto *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { if (attribute == d_ptr->m_constraintAttribute) return rectManager->constraint(internProp); - return QVariant(); - } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { + return {}; + } else if (auto *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { if (attribute == d_ptr->m_constraintAttribute) return rectFManager->constraint(internProp); if (attribute == d_ptr->m_decimalsAttribute) return rectFManager->decimals(internProp); - return QVariant(); - } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { + return {}; + } else if (auto *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { if (attribute == d_ptr->m_enumNamesAttribute) return enumManager->enumNames(internProp); if (attribute == d_ptr->m_enumIconsAttribute) { @@ -1489,13 +1533,13 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co v.setValue(enumManager->enumIcons(internProp)); return v; } - return QVariant(); - } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { + return {}; + } else if (auto *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { if (attribute == d_ptr->m_flagNamesAttribute) return flagManager->flagNames(internProp); - return QVariant(); + return {}; } - return QVariant(); + return {}; } /*! @@ -1505,10 +1549,9 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co */ QStringList QtVariantPropertyManager::attributes(int propertyType) const { - QMap<int, QMap<QString, int> >::ConstIterator it = - d_ptr->m_typeToAttributeToAttributeType.find(propertyType); + const auto it = d_ptr->m_typeToAttributeToAttributeType.constFind(propertyType); if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd()) - return QStringList(); + return {}; return it.value().keys(); } @@ -1524,13 +1567,12 @@ QStringList QtVariantPropertyManager::attributes(int propertyType) const */ int QtVariantPropertyManager::attributeType(int propertyType, const QString &attribute) const { - QMap<int, QMap<QString, int> >::ConstIterator it = - d_ptr->m_typeToAttributeToAttributeType.find(propertyType); + const auto it = d_ptr->m_typeToAttributeToAttributeType.constFind(propertyType); if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd()) return 0; - QMap<QString, int> attributes = it.value(); - QMap<QString, int>::ConstIterator itAttr = attributes.find(attribute); + const QMap<QString, int> &attributes = it.value(); + const auto itAttr = attributes.constFind(attribute); if (itAttr == attributes.constEnd()) return 0; return itAttr.value(); @@ -1559,79 +1601,79 @@ void QtVariantPropertyManager::setValue(QtProperty *property, const QVariant &va if (propType != valType && !val.canConvert(QMetaType(valType))) return; - QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); - if (internProp == 0) + QtProperty *internProp = propertyToWrappedProperty()->value(property, nullptr); + if (internProp == nullptr) return; QtAbstractPropertyManager *manager = internProp->propertyManager(); - if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { + if (auto *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { intManager->setValue(internProp, qvariant_cast<int>(val)); return; - } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { + } else if (auto *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { doubleManager->setValue(internProp, qvariant_cast<double>(val)); return; - } else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) { + } else if (auto *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) { boolManager->setValue(internProp, qvariant_cast<bool>(val)); return; - } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { + } else if (auto *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { stringManager->setValue(internProp, qvariant_cast<QString>(val)); return; - } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { + } else if (auto *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { dateManager->setValue(internProp, qvariant_cast<QDate>(val)); return; - } else if (QtTimePropertyManager *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) { + } else if (auto *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) { timeManager->setValue(internProp, qvariant_cast<QTime>(val)); return; - } else if (QtDateTimePropertyManager *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) { + } else if (auto *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) { dateTimeManager->setValue(internProp, qvariant_cast<QDateTime>(val)); return; - } else if (QtKeySequencePropertyManager *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) { + } else if (auto *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) { keySequenceManager->setValue(internProp, qvariant_cast<QKeySequence>(val)); return; - } else if (QtCharPropertyManager *charManager = qobject_cast<QtCharPropertyManager *>(manager)) { + } else if (auto *charManager = qobject_cast<QtCharPropertyManager *>(manager)) { charManager->setValue(internProp, qvariant_cast<QChar>(val)); return; - } else if (QtLocalePropertyManager *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) { + } else if (auto *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) { localeManager->setValue(internProp, qvariant_cast<QLocale>(val)); return; - } else if (QtPointPropertyManager *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) { + } else if (auto *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) { pointManager->setValue(internProp, qvariant_cast<QPoint>(val)); return; - } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { + } else if (auto *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { pointFManager->setValue(internProp, qvariant_cast<QPointF>(val)); return; - } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { + } else if (auto *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { sizeManager->setValue(internProp, qvariant_cast<QSize>(val)); return; - } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { + } else if (auto *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { sizeFManager->setValue(internProp, qvariant_cast<QSizeF>(val)); return; - } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { + } else if (auto *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { rectManager->setValue(internProp, qvariant_cast<QRect>(val)); return; - } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { + } else if (auto *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { rectFManager->setValue(internProp, qvariant_cast<QRectF>(val)); return; - } else if (QtColorPropertyManager *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) { + } else if (auto *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) { colorManager->setValue(internProp, qvariant_cast<QColor>(val)); return; - } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { + } else if (auto *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { enumManager->setValue(internProp, qvariant_cast<int>(val)); return; } else if (QtSizePolicyPropertyManager *sizePolicyManager = qobject_cast<QtSizePolicyPropertyManager *>(manager)) { sizePolicyManager->setValue(internProp, qvariant_cast<QSizePolicy>(val)); return; - } else if (QtFontPropertyManager *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) { + } else if (auto *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) { fontManager->setValue(internProp, qvariant_cast<QFont>(val)); return; #ifndef QT_NO_CURSOR - } else if (QtCursorPropertyManager *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) { + } else if (auto *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) { cursorManager->setValue(internProp, qvariant_cast<QCursor>(val)); return; #endif - } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { + } else if (auto *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { flagManager->setValue(internProp, qvariant_cast<int>(val)); return; } @@ -1663,12 +1705,12 @@ void QtVariantPropertyManager::setAttribute(QtProperty *property, !value.canConvert(QMetaType(attrType))) return; - QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); - if (internProp == 0) + QtProperty *internProp = propertyToWrappedProperty()->value(property, nullptr); + if (internProp == nullptr) return; QtAbstractPropertyManager *manager = internProp->propertyManager(); - if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { + if (auto *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) intManager->setMaximum(internProp, qvariant_cast<int>(value)); else if (attribute == d_ptr->m_minimumAttribute) @@ -1676,7 +1718,7 @@ void QtVariantPropertyManager::setAttribute(QtProperty *property, else if (attribute == d_ptr->m_singleStepAttribute) intManager->setSingleStep(internProp, qvariant_cast<int>(value)); return; - } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { + } else if (auto *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) doubleManager->setMaximum(internProp, qvariant_cast<double>(value)); if (attribute == d_ptr->m_minimumAttribute) @@ -1686,27 +1728,27 @@ void QtVariantPropertyManager::setAttribute(QtProperty *property, if (attribute == d_ptr->m_decimalsAttribute) doubleManager->setDecimals(internProp, qvariant_cast<int>(value)); return; - } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { + } else if (auto *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { if (attribute == d_ptr->m_regExpAttribute) stringManager->setRegExp(internProp, qvariant_cast<QRegularExpression>(value)); return; - } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { + } else if (auto *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) dateManager->setMaximum(internProp, qvariant_cast<QDate>(value)); if (attribute == d_ptr->m_minimumAttribute) dateManager->setMinimum(internProp, qvariant_cast<QDate>(value)); return; - } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { + } else if (auto *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { if (attribute == d_ptr->m_decimalsAttribute) pointFManager->setDecimals(internProp, qvariant_cast<int>(value)); return; - } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { + } else if (auto *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) sizeManager->setMaximum(internProp, qvariant_cast<QSize>(value)); if (attribute == d_ptr->m_minimumAttribute) sizeManager->setMinimum(internProp, qvariant_cast<QSize>(value)); return; - } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { + } else if (auto *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { if (attribute == d_ptr->m_maximumAttribute) sizeFManager->setMaximum(internProp, qvariant_cast<QSizeF>(value)); if (attribute == d_ptr->m_minimumAttribute) @@ -1714,23 +1756,23 @@ void QtVariantPropertyManager::setAttribute(QtProperty *property, if (attribute == d_ptr->m_decimalsAttribute) sizeFManager->setDecimals(internProp, qvariant_cast<int>(value)); return; - } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { + } else if (auto *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { if (attribute == d_ptr->m_constraintAttribute) rectManager->setConstraint(internProp, qvariant_cast<QRect>(value)); return; - } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { + } else if (auto *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { if (attribute == d_ptr->m_constraintAttribute) rectFManager->setConstraint(internProp, qvariant_cast<QRectF>(value)); if (attribute == d_ptr->m_decimalsAttribute) rectFManager->setDecimals(internProp, qvariant_cast<int>(value)); return; - } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { + } else if (auto *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { if (attribute == d_ptr->m_enumNamesAttribute) enumManager->setEnumNames(internProp, qvariant_cast<QStringList>(value)); if (attribute == d_ptr->m_enumIconsAttribute) enumManager->setEnumIcons(internProp, qvariant_cast<QtIconMap>(value)); return; - } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { + } else if (auto *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { if (attribute == d_ptr->m_flagNamesAttribute) flagManager->setFlagNames(internProp, qvariant_cast<QStringList>(value)); return; @@ -1752,7 +1794,7 @@ bool QtVariantPropertyManager::hasValue(const QtProperty *property) const */ QString QtVariantPropertyManager::valueText(const QtProperty *property) const { - const QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); + const QtProperty *internProp = propertyToWrappedProperty()->value(property, nullptr); return internProp ? internProp->valueText() : QString(); } @@ -1761,7 +1803,7 @@ QString QtVariantPropertyManager::valueText(const QtProperty *property) const */ QIcon QtVariantPropertyManager::valueIcon(const QtProperty *property) const { - const QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); + const QtProperty *internProp = propertyToWrappedProperty()->value(property, nullptr); return internProp ? internProp->valueIcon() : QIcon(); } @@ -1774,8 +1816,7 @@ void QtVariantPropertyManager::initializeProperty(QtProperty *property) if (!varProp) return; - QMap<int, QtAbstractPropertyManager *>::ConstIterator it = - d_ptr->m_typeToPropertyManager.find(d_ptr->m_propertyType); + const auto it = d_ptr->m_typeToPropertyManager.constFind(d_ptr->m_propertyType); if (it != d_ptr->m_typeToPropertyManager.constEnd()) { QtProperty *internProp = nullptr; if (!d_ptr->m_creatingSubProperties) { @@ -1800,11 +1841,11 @@ void QtVariantPropertyManager::initializeProperty(QtProperty *property) */ void QtVariantPropertyManager::uninitializeProperty(QtProperty *property) { - const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::iterator type_it = d_ptr->m_propertyToType.find(property); + const auto type_it = d_ptr->m_propertyToType.find(property); if (type_it == d_ptr->m_propertyToType.end()) return; - PropertyMap::iterator it = propertyToWrappedProperty()->find(property); + const auto it = propertyToWrappedProperty()->find(property); if (it != propertyToWrappedProperty()->end()) { QtProperty *internProp = it.value(); if (internProp) { @@ -1826,8 +1867,8 @@ QtProperty *QtVariantPropertyManager::createProperty() if (!d_ptr->m_creatingProperty) return 0; - QtVariantProperty *property = new QtVariantProperty(this); - d_ptr->m_propertyToType.insert(property, qMakePair(property, d_ptr->m_propertyType)); + auto *property = new QtVariantProperty(this); + d_ptr->m_propertyToType.insert(property, {property, d_ptr->m_propertyType}); return property; } @@ -1854,7 +1895,7 @@ public: QtColorEditorFactory *m_colorEditorFactory; QtFontEditorFactory *m_fontEditorFactory; - QMap<QtAbstractEditorFactoryBase *, int> m_factoryToType; + QHash<QtAbstractEditorFactoryBase *, int> m_factoryToType; QMap<int, QtAbstractEditorFactoryBase *> m_typeToFactory; }; @@ -2100,7 +2141,7 @@ QWidget *QtVariantEditorFactory::createEditor(QtVariantPropertyManager *manager, QWidget *parent) { const int propType = manager->propertyType(property); - QtAbstractEditorFactoryBase *factory = d_ptr->m_typeToFactory.value(propType, 0); + QtAbstractEditorFactoryBase *factory = d_ptr->m_typeToFactory.value(propType, nullptr); if (!factory) return 0; return factory->createEditor(wrappedProperty(property), parent); diff --git a/src/shared/qtpropertybrowser/qtvariantproperty.h b/src/shared/qtpropertybrowser/qtvariantproperty.h index 77bc52681..5fe231744 100644 --- a/src/shared/qtpropertybrowser/qtvariantproperty.h +++ b/src/shared/qtpropertybrowser/qtvariantproperty.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTVARIANTPROPERTY_H #define QTVARIANTPROPERTY_H @@ -48,8 +12,6 @@ QT_BEGIN_NAMESPACE class QRegularExpression; -typedef QMap<int, QIcon> QtIconMap; - class QtVariantPropertyManager; class QtVariantProperty : public QtProperty @@ -112,43 +74,6 @@ protected: QtProperty *createProperty() override; private: QScopedPointer<class QtVariantPropertyManagerPrivate> d_ptr; - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, bool)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QString &)) - Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegularExpression &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, QDate)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, QDate, QDate)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, QTime)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDateTime &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QKeySequence &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QChar &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QLocale &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPoint &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPointF &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSize &)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSize &, const QSize &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizeF &)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSizeF &, const QSizeF &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRect &)) - Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRect &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRectF &)) - Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRectF &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QColor &)) - Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty *, const QStringList &)) - Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *, const QMap<int, QIcon> &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizePolicy &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QFont &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QCursor &)) - Q_PRIVATE_SLOT(d_func(), void slotFlagNamesChanged(QtProperty *, const QStringList &)) - - Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, QtProperty *)) Q_DECLARE_PRIVATE(QtVariantPropertyManager) Q_DISABLE_COPY_MOVE(QtVariantPropertyManager) }; @@ -172,6 +97,4 @@ private: QT_END_NAMESPACE -Q_DECLARE_METATYPE(QIcon) -Q_DECLARE_METATYPE(QtIconMap) #endif |