diff options
Diffstat (limited to 'src/designer/src/components/objectinspector/objectinspectormodel.cpp')
-rw-r--r-- | src/designer/src/components/objectinspector/objectinspectormodel.cpp | 78 |
1 files changed, 25 insertions, 53 deletions
diff --git a/src/designer/src/components/objectinspector/objectinspectormodel.cpp b/src/designer/src/components/objectinspector/objectinspectormodel.cpp index 3f8c6a665..5168d4ff8 100644 --- a/src/designer/src/components/objectinspector/objectinspectormodel.cpp +++ b/src/designer/src/components/objectinspector/objectinspectormodel.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 "objectinspectormodel_p.h" @@ -55,6 +30,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { enum { DataRole = 1000 }; } @@ -63,11 +40,6 @@ static inline QObject *objectOfItem(const QStandardItem *item) { return qvariant_cast<QObject *>(item->data(DataRole)); } -static bool sortEntry(const QObject *a, const QObject *b) -{ - return a->objectName() < b->objectName(); -} - static bool sameIcon(const QIcon &i1, const QIcon &i2) { if (i1.isNull() && i2.isNull()) @@ -77,8 +49,10 @@ static bool sameIcon(const QIcon &i1, const QIcon &i2) return i1.cacheKey() == i2.cacheKey(); } -static inline bool isNameColumnEditable(const QObject *) +static inline bool isNameColumnEditable(const QObject *o) { + if (auto *action = qobject_cast<const QAction *>(o)) + return !action->isSeparator(); return true; } @@ -117,7 +91,7 @@ namespace qdesigner_internal { }; ModelRecursionContext::ModelRecursionContext(QDesignerFormEditorInterface *c, const QString &sepName) : - designerPrefix(QStringLiteral("QDesigner")), + designerPrefix(u"QDesigner"_s), separator(sepName), core(c), db(c->widgetDataBase()), @@ -141,7 +115,7 @@ namespace qdesigner_internal { ObjectData::ObjectData(QObject *parent, QObject *object, const ModelRecursionContext &ctx) : m_parent(parent), m_object(object), - m_className(QLatin1String(object->metaObject()->className())), + m_className(QLatin1StringView(object->metaObject()->className())), m_objectName(object->objectName()) { @@ -187,7 +161,7 @@ namespace qdesigner_internal { if (const QLayout *layout = w->layout()) { m_type = LayoutWidget; m_managedLayoutType = LayoutInfo::layoutType(ctx.core, layout); - m_className = QLatin1String(layout->metaObject()->className()); + m_className = QLatin1StringView(layout->metaObject()->className()); m_objectName = layout->objectName(); } return; @@ -289,9 +263,7 @@ namespace qdesigner_internal { if (!object->children().isEmpty()) { ButtonGroupList buttonGroups; - QObjectList children = object->children(); - std::sort(children.begin(), children.end(), sortEntry); - for (QObject *childObject : qAsConst(children)) { + for (QObject *childObject : object->children()) { // Managed child widgets unless we had a container extension if (childObject->isWidgetType()) { if (!containerExtension) { @@ -308,7 +280,7 @@ namespace qdesigner_internal { } // Add button groups if (!buttonGroups.isEmpty()) { - for (QButtonGroup *group : qAsConst(buttonGroups)) + for (QButtonGroup *group : std::as_const(buttonGroups)) createModelRecursion(fwi, object, group, model, ctx); } } // has children @@ -337,13 +309,13 @@ namespace qdesigner_internal { setColumnCount(NumColumns); setHorizontalHeaderLabels(headers); // Icons - m_icons.layoutIcons[LayoutInfo::NoLayout] = createIconSet(QStringLiteral("editbreaklayout.png")); - m_icons.layoutIcons[LayoutInfo::HSplitter] = createIconSet(QStringLiteral("edithlayoutsplit.png")); - m_icons.layoutIcons[LayoutInfo::VSplitter] = createIconSet(QStringLiteral("editvlayoutsplit.png")); - m_icons.layoutIcons[LayoutInfo::HBox] = createIconSet(QStringLiteral("edithlayout.png")); - m_icons.layoutIcons[LayoutInfo::VBox] = createIconSet(QStringLiteral("editvlayout.png")); - m_icons.layoutIcons[LayoutInfo::Grid] = createIconSet(QStringLiteral("editgrid.png")); - m_icons.layoutIcons[LayoutInfo::Form] = createIconSet(QStringLiteral("editform.png")); + m_icons.layoutIcons[LayoutInfo::NoLayout] = createIconSet("editbreaklayout.png"_L1); + m_icons.layoutIcons[LayoutInfo::HSplitter] = createIconSet("edithlayoutsplit.png"_L1); + m_icons.layoutIcons[LayoutInfo::VSplitter] = createIconSet("editvlayoutsplit.png"_L1); + m_icons.layoutIcons[LayoutInfo::HBox] = createIconSet("edithlayout.png"_L1); + m_icons.layoutIcons[LayoutInfo::VBox] = createIconSet("editvlayout.png"_L1); + m_icons.layoutIcons[LayoutInfo::Grid] = createIconSet("editgrid.png"_L1); + m_icons.layoutIcons[LayoutInfo::Form] = createIconSet("editform.png"_L1); } void ObjectInspectorModel::clearItems() @@ -411,8 +383,8 @@ namespace qdesigner_internal { if (newModel.isEmpty()) return; - const ObjectModel::const_iterator mcend = newModel.constEnd(); - ObjectModel::const_iterator it = newModel.constBegin(); + const auto mcend = newModel.cend(); + auto it = newModel.cbegin(); // Set up root element StandardItemList rootRow = createModelRow(it->object()); it->setItems(rootRow, m_icons); @@ -439,10 +411,10 @@ namespace qdesigner_internal { QObjectSet changedObjects; - const int size = newModel.size(); + const auto size = newModel.size(); Q_ASSERT(oldModel.size() == size); - for (int i = 0; i < size; i++) { - const ObjectData &newEntry = newModel[i]; + for (qsizetype i = 0; i < size; ++i) { + const ObjectData &newEntry = newModel.at(i); ObjectData &entry = oldModel[i]; // Has some data changed? if (const unsigned changedMask = entry.compare(newEntry)) { @@ -482,7 +454,7 @@ namespace qdesigner_internal { if (!object) return false; // Is this a layout widget? - const QString nameProperty = isQLayoutWidget(object) ? QStringLiteral("layoutName") : QStringLiteral("objectName"); + const QString nameProperty = isQLayoutWidget(object) ? u"layoutName"_s : u"objectName"_s; m_formWindow->commandHistory()->push(createTextPropertyCommand(nameProperty, value.toString(), object, m_formWindow)); return true; } |