summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-05-25 09:32:01 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-05-25 10:10:13 +0000
commit1086610cb8daf4ffc0e57f30ae65d8ef6b8edfd4 (patch)
treeeceed9cda7a5b1d8dfd8554e5b84755b88469435
parentbbd2b971123353a35923ebe03cae31b4c35ab260 (diff)
Qt Designer: Fix some clazy/Axivion warnings about QMap with pointer keys
Use QHash instead. As drive-by, replace a QMap<int,bool> used as QSet. Change-Id: I3fc3c6074b356a5d75baf7f1e4e442f80aedf1c7 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> (cherry picked from commit d18d046847a2be3b557df1d7964fedccf2a1ea7b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/designer/src/components/formeditor/formwindow.cpp2
-rw-r--r--src/designer/src/components/formeditor/formwindow.h4
-rw-r--r--src/designer/src/components/propertyeditor/propertyeditor.cpp6
-rw-r--r--src/designer/src/components/propertyeditor/propertyeditor.h2
-rw-r--r--src/designer/src/lib/shared/formwindowbase.cpp10
-rw-r--r--src/designer/src/lib/shared/layout.cpp4
-rw-r--r--src/designer/src/lib/shared/qdesigner_introspection.cpp2
-rw-r--r--src/designer/src/lib/shared/qdesigner_introspection_p.h7
-rw-r--r--src/designer/src/lib/shared/qdesigner_propertycommand.cpp8
-rw-r--r--src/designer/src/lib/shared/qdesigner_propertycommand_p.h4
-rw-r--r--src/designer/src/lib/shared/qdesigner_propertysheet.cpp4
-rw-r--r--src/designer/src/lib/shared/qdesigner_tabwidget_p.h3
-rw-r--r--src/designer/src/lib/shared/qdesigner_toolbox_p.h2
-rw-r--r--src/designer/src/lib/shared/qlayout_widget.cpp14
14 files changed, 32 insertions, 40 deletions
diff --git a/src/designer/src/components/formeditor/formwindow.cpp b/src/designer/src/components/formeditor/formwindow.cpp
index 74e80cfa6..a364e8083 100644
--- a/src/designer/src/components/formeditor/formwindow.cpp
+++ b/src/designer/src/components/formeditor/formwindow.cpp
@@ -2485,7 +2485,7 @@ void FormWindow::highlightWidget(QWidget *widget, const QPoint &pos, HighlightMo
return;
if (mode == Restore) {
- const WidgetPaletteMap::iterator pit = m_palettesBeforeHighlight.find(container);
+ const auto pit = m_palettesBeforeHighlight.find(container);
if (pit != m_palettesBeforeHighlight.end()) {
container->setPalette(pit.value().first);
container->setAutoFillBackground(pit.value().second);
diff --git a/src/designer/src/components/formeditor/formwindow.h b/src/designer/src/components/formeditor/formwindow.h
index 15e8108d4..42071cd17 100644
--- a/src/designer/src/components/formeditor/formwindow.h
+++ b/src/designer/src/components/formeditor/formwindow.h
@@ -11,7 +11,6 @@
#include <QtGui/qundostack.h>
#include <QtCore/qhash.h>
#include <QtCore/qlist.h>
-#include <QtCore/qmap.h>
#include <QtCore/qset.h>
#include <QtCore/qpointer.h>
@@ -316,8 +315,7 @@ private:
QString m_fileName;
using PaletteAndFill = QPair<QPalette ,bool>;
- using WidgetPaletteMap = QMap<QWidget*, PaletteAndFill>;
- WidgetPaletteMap m_palettesBeforeHighlight;
+ QHash<QWidget *, PaletteAndFill> m_palettesBeforeHighlight;
QRubberBand *m_rubberBand = nullptr;
diff --git a/src/designer/src/components/propertyeditor/propertyeditor.cpp b/src/designer/src/components/propertyeditor/propertyeditor.cpp
index 294357196..2a464b5d4 100644
--- a/src/designer/src/components/propertyeditor/propertyeditor.cpp
+++ b/src/designer/src/components/propertyeditor/propertyeditor.cpp
@@ -411,7 +411,7 @@ void PropertyEditor::storePropertiesExpansionState(const QList<QtBrowserItem *>
if (!propertyItem->children().isEmpty()) {
QtProperty *property = propertyItem->property();
const QString propertyName = property->propertyName();
- const QMap<QtProperty *, QString>::const_iterator itGroup = m_propertyToGroup.constFind(property);
+ const auto itGroup = m_propertyToGroup.constFind(property);
if (itGroup != m_propertyToGroup.constEnd()) {
const QString key = itGroup.value() + u'|' + propertyName;
m_expansionState[key] = isExpanded(propertyItem);
@@ -451,7 +451,7 @@ void PropertyEditor::applyPropertiesExpansionState(const QList<QtBrowserItem *>
const QMap<QString, bool>::const_iterator excend = m_expansionState.constEnd();
QtProperty *property = propertyItem->property();
const QString propertyName = property->propertyName();
- const QMap<QtProperty *, QString>::const_iterator itGroup = m_propertyToGroup.constFind(property);
+ const auto itGroup = m_propertyToGroup.constFind(property);
if (itGroup != m_propertyToGroup.constEnd()) {
const QString key = itGroup.value() + u'|' + propertyName;
const QMap<QString, bool>::const_iterator pit = m_expansionState.constFind(key);
@@ -542,7 +542,7 @@ QColor PropertyEditor::propertyColor(QtProperty *property) const
QtProperty *groupProperty = property;
- QMap<QtProperty *, QString>::ConstIterator itProp = m_propertyToGroup.constFind(property);
+ const auto itProp = m_propertyToGroup.constFind(property);
if (itProp != m_propertyToGroup.constEnd())
groupProperty = m_nameToGroup.value(itProp.value());
diff --git a/src/designer/src/components/propertyeditor/propertyeditor.h b/src/designer/src/components/propertyeditor/propertyeditor.h
index 3bebc9373..45c468c16 100644
--- a/src/designer/src/components/propertyeditor/propertyeditor.h
+++ b/src/designer/src/components/propertyeditor/propertyeditor.h
@@ -130,7 +130,7 @@ private:
DesignerEditorFactory *m_groupFactory;
QPointer<QObject> m_object;
QMap<QString, QtVariantProperty*> m_nameToProperty;
- QMap<QtProperty*, QString> m_propertyToGroup;
+ QHash<QtProperty *, QString> m_propertyToGroup;
QMap<QString, QtVariantProperty*> m_nameToGroup;
QList<QtProperty *> m_groups;
QtProperty *m_dynamicGroup = nullptr;
diff --git a/src/designer/src/lib/shared/formwindowbase.cpp b/src/designer/src/lib/shared/formwindowbase.cpp
index 7d93f7098..17dde0409 100644
--- a/src/designer/src/lib/shared/formwindowbase.cpp
+++ b/src/designer/src/lib/shared/formwindowbase.cpp
@@ -35,6 +35,7 @@
#include <QtGui/qaction.h>
#include <QtCore/qdebug.h>
+#include <QtCore/qhash.h>
#include <QtCore/qlist.h>
#include <QtCore/qset.h>
#include <QtCore/qtimer.h>
@@ -57,8 +58,8 @@ public:
DesignerPixmapCache *m_pixmapCache;
DesignerIconCache *m_iconCache;
QtResourceSet *m_resourceSet;
- QMap<QDesignerPropertySheet *, QMap<int, bool> > m_reloadableResources; // bool is dummy, QMap used as QSet
- QMap<QDesignerPropertySheet *, QObject *> m_reloadablePropertySheets;
+ QHash<QDesignerPropertySheet *, QSet<int>> m_reloadableResources;
+ QHash<QDesignerPropertySheet *, QObject *> m_reloadablePropertySheets;
const DeviceProfile m_deviceProfile;
FormWindowBase::LineTerminatorMode m_lineTerminatorMode;
FormWindowBase::ResourceFileSaveMode m_saveResourcesBehaviour;
@@ -134,7 +135,7 @@ void FormWindowBase::setResourceSet(QtResourceSet *resourceSet)
void FormWindowBase::addReloadableProperty(QDesignerPropertySheet *sheet, int index)
{
connectSheet(sheet);
- m_d->m_reloadableResources[sheet][index] = true;
+ m_d->m_reloadableResources[sheet].insert(index);
}
void FormWindowBase::removeReloadableProperty(QDesignerPropertySheet *sheet, int index)
@@ -206,8 +207,7 @@ void FormWindowBase::reloadProperties()
iconCache()->clear();
for (auto it = m_d->m_reloadableResources.cbegin(), end = m_d->m_reloadableResources.cend(); it != end; ++it) {
QDesignerPropertySheet *sheet = it.key();
- for (auto jt = it.value().begin(), end = it.value().end(); jt != end; ++jt) {
- const int index = jt.key();
+ for (int index : it.value()) {
const QVariant newValue = sheet->property(index);
if (qobject_cast<QLabel *>(sheet->object()) && sheet->propertyName(index) == "text"_L1) {
const PropertySheetStringValue newString = qvariant_cast<PropertySheetStringValue>(newValue);
diff --git a/src/designer/src/lib/shared/layout.cpp b/src/designer/src/lib/shared/layout.cpp
index 9c4be81a3..46c8f635a 100644
--- a/src/designer/src/lib/shared/layout.cpp
+++ b/src/designer/src/lib/shared/layout.cpp
@@ -18,6 +18,7 @@
#include <QtDesigner/qextensionmanager.h>
#include <QtCore/qdebug.h>
+#include <QtCore/qhash.h>
#include <QtCore/qlist.h>
#include <QtCore/qset.h>
@@ -342,8 +343,7 @@ void Layout::undoLayout()
void Layout::breakLayout()
{
- typedef QMap<QWidget *, QRect> WidgetRectMap;
- WidgetRectMap rects;
+ QHash<QWidget *, QRect> rects;
/* Store the geometry of the widgets. The idea is to give the user space
* to rearrange them, so, we do a adjustSize() on them, unless they want
* to grow (expanding widgets like QTextEdit), in which the geometry is
diff --git a/src/designer/src/lib/shared/qdesigner_introspection.cpp b/src/designer/src/lib/shared/qdesigner_introspection.cpp
index 8c2dd3736..9ccf876bf 100644
--- a/src/designer/src/lib/shared/qdesigner_introspection.cpp
+++ b/src/designer/src/lib/shared/qdesigner_introspection.cpp
@@ -320,7 +320,7 @@ namespace qdesigner_internal {
const QDesignerMetaObjectInterface* QDesignerIntrospection::metaObjectForQMetaObject(const QMetaObject *metaObject) const
{
- MetaObjectMap::iterator it = m_metaObjectMap.find(metaObject);
+ auto it = m_metaObjectMap.find(metaObject);
if (it == m_metaObjectMap.end())
it = m_metaObjectMap.insert(metaObject, new QDesignerMetaObject(this, metaObject));
return it.value();
diff --git a/src/designer/src/lib/shared/qdesigner_introspection_p.h b/src/designer/src/lib/shared/qdesigner_introspection_p.h
index 0607c3a48..1cdf0aa4f 100644
--- a/src/designer/src/lib/shared/qdesigner_introspection_p.h
+++ b/src/designer/src/lib/shared/qdesigner_introspection_p.h
@@ -17,7 +17,7 @@
#include "shared_global_p.h"
#include <abstractintrospection_p.h>
-#include <QtCore/qmap.h>
+#include <QtCore/qhash.h>
QT_BEGIN_NAMESPACE
@@ -34,10 +34,9 @@ namespace qdesigner_internal {
const QDesignerMetaObjectInterface* metaObject(const QObject *object) const override;
const QDesignerMetaObjectInterface* metaObjectForQMetaObject(const QMetaObject *metaObject) const;
- private:
- using MetaObjectMap = QMap<const QMetaObject*, QDesignerMetaObjectInterface*>;
- mutable MetaObjectMap m_metaObjectMap;
+ private:
+ mutable QHash<const QMetaObject *, QDesignerMetaObjectInterface *> m_metaObjectMap;
};
}
diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp
index 20d387eda..2e277e4e7 100644
--- a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp
+++ b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp
@@ -1478,8 +1478,7 @@ bool RemoveDynamicPropertyCommand::init(const QObjectList &selection, QObject *c
void RemoveDynamicPropertyCommand::redo()
{
QDesignerFormEditorInterface *core = formWindow()->core();
- QMap<QObject *, QPair<QVariant, bool> >::ConstIterator it = m_objectToValueAndChanged.constBegin();
- while (it != m_objectToValueAndChanged.constEnd()) {
+ for (auto it = m_objectToValueAndChanged.cbegin(), end = m_objectToValueAndChanged.cend(); it != end; ++it) {
QObject *obj = it.key();
QDesignerDynamicPropertySheetExtension *dynamicSheet = qt_extension<QDesignerDynamicPropertySheetExtension*>(core->extensionManager(), obj);
QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), obj);
@@ -1488,15 +1487,13 @@ void RemoveDynamicPropertyCommand::redo()
if (propertyEditor->object() == obj)
propertyEditor->setObject(obj);
}
- ++it;
}
}
void RemoveDynamicPropertyCommand::undo()
{
QDesignerFormEditorInterface *core = formWindow()->core();
- QMap<QObject *, QPair<QVariant, bool> >::ConstIterator it = m_objectToValueAndChanged.constBegin();
- while (it != m_objectToValueAndChanged.constEnd()) {
+ for (auto it = m_objectToValueAndChanged.cbegin(), end = m_objectToValueAndChanged.cend(); it != end; ++it) {
QObject *obj = it.key();
QDesignerPropertySheetExtension *propertySheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), obj);
QDesignerDynamicPropertySheetExtension *dynamicSheet = qt_extension<QDesignerDynamicPropertySheetExtension*>(core->extensionManager(), obj);
@@ -1506,7 +1503,6 @@ void RemoveDynamicPropertyCommand::undo()
if (propertyEditor->object() == obj)
propertyEditor->setObject(obj);
}
- ++it;
}
}
diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand_p.h b/src/designer/src/lib/shared/qdesigner_propertycommand_p.h
index de5ea31b1..527716c6c 100644
--- a/src/designer/src/lib/shared/qdesigner_propertycommand_p.h
+++ b/src/designer/src/lib/shared/qdesigner_propertycommand_p.h
@@ -18,8 +18,8 @@
#include "qdesigner_formwindowcommand_p.h"
#include <QtCore/qvariant.h>
+#include <QtCore/qhash.h>
#include <QtCore/qlist.h>
-#include <QtCore/qmap.h>
#include <QtCore/qpair.h>
#include <QtCore/qsharedpointer.h>
@@ -261,7 +261,7 @@ public:
private:
void setDescription();
QString m_propertyName;
- QMap<QObject *, QPair<QVariant, bool> > m_objectToValueAndChanged;
+ QHash<QObject *, QPair<QVariant, bool> > m_objectToValueAndChanged;
};
} // namespace qdesigner_internal
diff --git a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp
index 710da6e87..dc6850f6f 100644
--- a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp
+++ b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp
@@ -31,6 +31,7 @@
#include <QtGui/qaction.h>
#include <QtCore/qdebug.h>
+#include <QtCore/qhash.h>
QT_BEGIN_NAMESPACE
@@ -1633,8 +1634,7 @@ struct QDesignerAbstractPropertySheetFactory::PropertySheetFactoryPrivate {
const QString m_propertySheetId;
const QString m_dynamicPropertySheetId;
- using ExtensionMap = QMap<QObject*, QObject*>;
- ExtensionMap m_extensions;
+ QHash<QObject *, QObject *> m_extensions;
};
QDesignerAbstractPropertySheetFactory::PropertySheetFactoryPrivate::PropertySheetFactoryPrivate() :
diff --git a/src/designer/src/lib/shared/qdesigner_tabwidget_p.h b/src/designer/src/lib/shared/qdesigner_tabwidget_p.h
index 63a218206..c83d93aed 100644
--- a/src/designer/src/lib/shared/qdesigner_tabwidget_p.h
+++ b/src/designer/src/lib/shared/qdesigner_tabwidget_p.h
@@ -19,6 +19,7 @@
#include "qdesigner_propertysheet_p.h"
#include "qdesigner_utils_p.h"
+#include <QtCore/qhash.h>
#include <QtCore/qpointer.h>
#include <QtGui/qicon.h>
@@ -105,7 +106,7 @@ private:
qdesigner_internal::PropertySheetStringValue whatsthis;
qdesigner_internal::PropertySheetIconValue icon;
};
- QMap<QWidget *, PageData> m_pageToData;
+ QHash<QWidget *, PageData> m_pageToData;
};
using QTabWidgetPropertySheetFactory = QDesignerPropertySheetFactory<QTabWidget, QTabWidgetPropertySheet>;
diff --git a/src/designer/src/lib/shared/qdesigner_toolbox_p.h b/src/designer/src/lib/shared/qdesigner_toolbox_p.h
index 6f76b6655..8a86e23e6 100644
--- a/src/designer/src/lib/shared/qdesigner_toolbox_p.h
+++ b/src/designer/src/lib/shared/qdesigner_toolbox_p.h
@@ -92,7 +92,7 @@ private:
qdesigner_internal::PropertySheetStringValue tooltip;
qdesigner_internal::PropertySheetIconValue icon;
};
- QMap<QWidget *, PageData> m_pageToData;
+ QHash<QWidget *, PageData> m_pageToData;
};
using QToolBoxWidgetPropertySheetFactory = QDesignerPropertySheetFactory<QToolBox, QToolBoxWidgetPropertySheet>;
diff --git a/src/designer/src/lib/shared/qlayout_widget.cpp b/src/designer/src/lib/shared/qlayout_widget.cpp
index 6e7ebe5ec..d11d340e2 100644
--- a/src/designer/src/lib/shared/qlayout_widget.cpp
+++ b/src/designer/src/lib/shared/qlayout_widget.cpp
@@ -23,6 +23,7 @@
#include <QtCore/qdebug.h>
#include <QtCore/qalgorithms.h>
+#include <QtCore/qhash.h>
#include <QtCore/qmap.h>
#include <QtCore/qstack.h>
#include <QtCore/qpair.h>
@@ -584,11 +585,8 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const
// [column1, column2,...] (address as row * columnCount + col)
static CellStates cellStates(const QList<QRect> &rects, int numRows, int numColumns);
- typedef QMap<QWidget *, QRect> WidgetItemMap;
- typedef QMap<QWidget *, Qt::Alignment> WidgetAlignmentMap;
-
- WidgetItemMap widgetItemMap;
- WidgetAlignmentMap widgetAlignmentMap;
+ QHash<QWidget *, QRect> widgetItemMap;
+ QHash<QWidget *, Qt::Alignment> widgetAlignmentMap;
int rowCount = 0;
int colCount = 0;
@@ -603,8 +601,8 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const
str << "GridLayoutState: " << gs.rowCount << " rows x " << gs.colCount
<< " cols " << gs.widgetItemMap.size() << " items\n";
- const GridLayoutState::WidgetItemMap::const_iterator wcend = gs.widgetItemMap.constEnd();
- for (GridLayoutState::WidgetItemMap::const_iterator it = gs.widgetItemMap.constBegin(); it != wcend; ++it)
+ const auto wcend = gs.widgetItemMap.constEnd();
+ for (auto it = gs.widgetItemMap.constBegin(); it != wcend; ++it)
str << "Item " << it.key() << it.value() << '\n';
return str;
}
@@ -676,7 +674,7 @@ QRect LayoutHelper::itemInfo(QLayout *lt, const QWidget *widget) const
QLayoutItem *item = grid->takeAt(0);
if (!LayoutInfo::isEmptyItem(item)) {
QWidget *itemWidget = item->widget();
- const WidgetItemMap::const_iterator it = widgetItemMap.constFind(itemWidget);
+ const auto it = widgetItemMap.constFind(itemWidget);
if (it == widgetItemMap.constEnd())
qFatal("GridLayoutState::applyToLayout: Attempt to apply to a layout that has a widget '%s'/'%s' added after saving the state.",
itemWidget->metaObject()->className(), itemWidget->objectName().toUtf8().constData());