diff options
Diffstat (limited to 'src/designer/src/components/propertyeditor/brushpropertymanager.cpp')
-rw-r--r-- | src/designer/src/components/propertyeditor/brushpropertymanager.cpp | 67 |
1 files changed, 23 insertions, 44 deletions
diff --git a/src/designer/src/components/propertyeditor/brushpropertymanager.cpp b/src/designer/src/components/propertyeditor/brushpropertymanager.cpp index aa94e17f3..2356e3843 100644 --- a/src/designer/src/components/propertyeditor/brushpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/brushpropertymanager.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** 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-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "brushpropertymanager.h" #include "qtpropertymanager.h" @@ -55,6 +30,8 @@ QT_TRANSLATE_NOOP("BrushPropertyManager", "Crossing diagonal"), QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { BrushPropertyManager::BrushPropertyManager() = default; @@ -124,7 +101,7 @@ static void clearBrushIcons() brushIcons()->clear(); } -const BrushPropertyManager::EnumIndexIconMap &BrushPropertyManager::brushStyleIcons() +const QMap<int, QIcon> &BrushPropertyManager::brushStyleIcons() { // Create a map of icons for the brush style editor if (brushIcons()->empty()) { @@ -145,6 +122,8 @@ QString BrushPropertyManager::brushStyleIndexToString(int brushStyleIndex) return brushStyleIndex < brushStyleCount ? QCoreApplication::translate("BrushPropertyManager", brushStyles[brushStyleIndex]) : QString(); } +BrushPropertyManager::~BrushPropertyManager() = default; + void BrushPropertyManager::initializeProperty(QtVariantPropertyManager *vm, QtProperty *property, int enumTypeId) { m_brushValues.insert(property, QBrush()); @@ -154,8 +133,8 @@ void BrushPropertyManager::initializeProperty(QtVariantPropertyManager *vm, QtPr QStringList styles; for (const char *brushStyle : brushStyles) styles.push_back(QCoreApplication::translate("BrushPropertyManager", brushStyle)); - styleSubProperty->setAttribute(QStringLiteral("enumNames"), styles); - styleSubProperty->setAttribute(QStringLiteral("enumIcons"), QVariant::fromValue(brushStyleIcons())); + styleSubProperty->setAttribute(u"enumNames"_s, styles); + styleSubProperty->setAttribute(u"enumIcons"_s, QVariant::fromValue(brushStyleIcons())); m_brushPropertyToStyleSubProperty.insert(property, styleSubProperty); m_brushStyleSubPropertyToProperty.insert(styleSubProperty, property); // color @@ -168,24 +147,24 @@ void BrushPropertyManager::initializeProperty(QtVariantPropertyManager *vm, QtPr bool BrushPropertyManager::uninitializeProperty(QtProperty *property) { - const PropertyBrushMap::iterator brit = m_brushValues.find(property); // Brushes + const auto brit = m_brushValues.find(property); // Brushes if (brit == m_brushValues.end()) return false; m_brushValues.erase(brit); // style - PropertyToPropertyMap::iterator subit = m_brushPropertyToStyleSubProperty.find(property); - if (subit != m_brushPropertyToStyleSubProperty.end()) { - QtProperty *styleProp = subit.value(); + const auto styleIt = m_brushPropertyToStyleSubProperty.find(property); + if (styleIt != m_brushPropertyToStyleSubProperty.end()) { + QtProperty *styleProp = styleIt .value(); m_brushStyleSubPropertyToProperty.remove(styleProp); - m_brushPropertyToStyleSubProperty.erase(subit); + m_brushPropertyToStyleSubProperty.erase(styleIt ); delete styleProp; } // color - subit = m_brushPropertyToColorSubProperty.find(property); - if (subit != m_brushPropertyToColorSubProperty.end()) { - QtProperty *colorProp = subit.value(); + const auto colorIt = m_brushPropertyToColorSubProperty.find(property); + if (colorIt != m_brushPropertyToColorSubProperty.end()) { + QtProperty *colorProp = colorIt .value(); m_brushColorSubPropertyToProperty.remove(colorProp); - m_brushPropertyToColorSubProperty.erase(subit); + m_brushPropertyToColorSubProperty.erase(colorIt ); delete colorProp; } return true; @@ -193,7 +172,7 @@ bool BrushPropertyManager::uninitializeProperty(QtProperty *property) void BrushPropertyManager::slotPropertyDestroyed(QtProperty *property) { - PropertyToPropertyMap::iterator subit = m_brushStyleSubPropertyToProperty.find(property); + auto subit = m_brushStyleSubPropertyToProperty.find(property); if (subit != m_brushStyleSubPropertyToProperty.end()) { m_brushPropertyToStyleSubProperty[subit.value()] = 0; m_brushStyleSubPropertyToProperty.erase(subit); @@ -242,7 +221,7 @@ int BrushPropertyManager::setValue(QtVariantPropertyManager *vm, QtProperty *pro { if (value.metaType().id() != QMetaType::QBrush) return DesignerPropertyManager::NoMatch; - const PropertyBrushMap::iterator brit = m_brushValues.find(property); + const auto brit = m_brushValues.find(property); if (brit == m_brushValues.end()) return DesignerPropertyManager::NoMatch; @@ -260,7 +239,7 @@ int BrushPropertyManager::setValue(QtVariantPropertyManager *vm, QtProperty *pro bool BrushPropertyManager::valueText(const QtProperty *property, QString *text) const { - const PropertyBrushMap::const_iterator brit = m_brushValues.constFind(const_cast<QtProperty *>(property)); + const auto brit = m_brushValues.constFind(property); if (brit == m_brushValues.constEnd()) return false; const QBrush &brush = brit.value(); @@ -272,7 +251,7 @@ bool BrushPropertyManager::valueText(const QtProperty *property, QString *text) bool BrushPropertyManager::valueIcon(const QtProperty *property, QIcon *icon) const { - const PropertyBrushMap::const_iterator brit = m_brushValues.constFind(const_cast<QtProperty *>(property)); + const auto brit = m_brushValues.constFind(property); if (brit == m_brushValues.constEnd()) return false; *icon = QtPropertyBrowserUtils::brushValueIcon(brit.value()); @@ -281,7 +260,7 @@ bool BrushPropertyManager::valueIcon(const QtProperty *property, QIcon *icon) co bool BrushPropertyManager::value(const QtProperty *property, QVariant *v) const { - const PropertyBrushMap::const_iterator brit = m_brushValues.constFind(const_cast<QtProperty *>(property)); + const auto brit = m_brushValues.constFind(property); if (brit == m_brushValues.constEnd()) return false; v->setValue(brit.value()); |