[education/rkward] rkward: Replace deprecated QMultiHash/Map::insertMulti()
Thomas Friedrichsmeier
null at kde.org
Mon May 23 20:40:02 BST 2022
Git commit e5ba8634fe6148746a95d5a21f3be270968b6cb7 by Thomas Friedrichsmeier.
Committed on 23/05/2022 at 19:39.
Pushed by tfry into branch 'master'.
Replace deprecated QMultiHash/Map::insertMulti()
M +2 -2 rkward/misc/rkxmlguisyncer.cpp
M +2 -5 rkward/plugin/rkcomponent.cpp
M +2 -2 rkward/plugin/rkcomponent.h
M +1 -1 rkward/plugin/rkoptionset.cpp
M +1 -1 rkward/windows/rkhtmlwindow.cpp
https://invent.kde.org/education/rkward/commit/e5ba8634fe6148746a95d5a21f3be270968b6cb7
diff --git a/rkward/misc/rkxmlguisyncer.cpp b/rkward/misc/rkxmlguisyncer.cpp
index 895e9f8b..3a7c1ed3 100644
--- a/rkward/misc/rkxmlguisyncer.cpp
+++ b/rkward/misc/rkxmlguisyncer.cpp
@@ -44,7 +44,7 @@ void RKXMLGUISyncer::watchXMLGUIClientUIrc (KXMLGUIClient *client, bool recursiv
d->file_watcher->addFile (local_xml_file);
}
- d->client_map.insertMulti (local_xml_file, ac);
+ d->client_map.insert(local_xml_file, ac);
d->connect (ac, &KActionCollection::destroyed, d, &RKXMLGUISyncerPrivate::actionCollectionDestroyed);
} // we simply ignore attempts to watch the same client twice
}
@@ -64,7 +64,7 @@ void RKXMLGUISyncer::registerChangeListener (KXMLGUIClient *watched_client, QObj
RKXMLGUISyncerNotifier *notifier = new RKXMLGUISyncerNotifier (0);
d->connect (notifier, SIGNAL (changed(KXMLGUIClient*)), receiver, method);
- d->notifier_map.insertMulti (ac, notifier);
+ d->notifier_map.insert(ac, notifier);
}
diff --git a/rkward/plugin/rkcomponent.cpp b/rkward/plugin/rkcomponent.cpp
index 2fdfb94e..57fbe36b 100644
--- a/rkward/plugin/rkcomponent.cpp
+++ b/rkward/plugin/rkcomponent.cpp
@@ -51,7 +51,7 @@ RKComponentPropertyBase* RKComponentBase::lookupProperty (const QString &identif
void RKComponentBase::addChild (const QString &id, RKComponentBase *child) {
RK_TRACE (PLUGIN);
- child_map.insertMulti (id, child); // no overwriting even on duplicate ("#noid#") ids
+ child_map.insert(id, child); // no overwriting even on duplicate ("#noid#") ids
}
void RKComponentBase::fetchPropertyValuesRecursive (PropertyValueMap *list, bool include_top_level, const QString &prefix, bool include_inactive_elements) const {
@@ -411,11 +411,8 @@ void RKComponent::removeFromParent () {
if (!parentComponent ()) return;
- // unfortunately, several items might hvae the same key, and there seems to be no way to selectively remove the current item only.
- // however, this function should only ever be called in cases of emergency and to prevent crashes. So we make extra sure to remove the child,
- // even if we remove a little more than necessary along the way.
QString key = getIdInParent ();
- while (parentComponent ()->child_map.remove (key)) {;}
+ child_map.remove(key, this);
_parent = 0;
}
diff --git a/rkward/plugin/rkcomponent.h b/rkward/plugin/rkcomponent.h
index 694a3faa..4780ef8a 100644
--- a/rkward/plugin/rkcomponent.h
+++ b/rkward/plugin/rkcomponent.h
@@ -8,7 +8,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
#ifndef RKCOMPONENT_H
#define RKCOMPONENT_H
-#include <QHash>
+#include <QMultiHash>
#include <qmap.h>
#include <qwidget.h>
@@ -128,7 +128,7 @@ public:
bool isInternal () const { return is_internal; };
protected:
friend class RKOptionSet;
- QHash<QString, RKComponentBase*> child_map;
+ QMultiHash<QString, RKComponentBase*> child_map;
bool required;
/** recursively fetch the current values of all properties present as direct or indirect children of this component. Used to transfer values e.g. when switching interfaces (or to store settings per plugin in the future). Values are placed in the dictionary provided (be sure to create one first!). Internal properties are ignored (@see RKComponentPropertyBase::isInternal ());
@param list the list to store the object values in
diff --git a/rkward/plugin/rkoptionset.cpp b/rkward/plugin/rkoptionset.cpp
index 1526db10..b7be14f0 100644
--- a/rkward/plugin/rkoptionset.cpp
+++ b/rkward/plugin/rkoptionset.cpp
@@ -152,7 +152,7 @@ RKOptionSet::RKOptionSet (const QDomElement &element, RKComponent *parent_compon
continue;
}
}
- columns_to_update.insertMulti (gov_prop, it.key ());
+ columns_to_update.insert(gov_prop, it.key());
connect (gov_prop, &RKComponentPropertyBase::valueChanged, this, &RKOptionSet::governingPropertyChanged);
} else {
RK_DEBUG (PLUGIN, DL_ERROR, "did not find governing property %s for column %s of optionset", qPrintable (ci.governor), qPrintable (ci.column_name));
diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index 40b5a83c..d26d59b7 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -1454,7 +1454,7 @@ void RKOutputWindowManager::registerWindow (RKHTMLWindow *window) {
}
}
- windows.insertMulti (file, window);
+ windows.insert(file, window);
connect (window, &QObject::destroyed, this, &RKOutputWindowManager::windowDestroyed);
} else {
RK_ASSERT (false);
More information about the rkward-tracker
mailing list