Skip to content

Commit

Permalink
QMap with multiple values for identical keys is deprecated, port to Q…
Browse files Browse the repository at this point in the history
…MultiMap

Signed-off-by: Matthew J. Milner <[email protected]>
  • Loading branch information
matterhorn103 committed Oct 24, 2024
1 parent 90b311d commit 474927d
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions avogadro/qtgui/scriptloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ bool ScriptLoader::queryProgramName(const QString& scriptFilePath,
return true;
}

QMap<QString, QString> ScriptLoader::scriptList(const QString& type)
QMultiMap<QString, QString> ScriptLoader::scriptList(const QString& type)
{
// List of directories to check.
/// @todo Custom script locations
QStringList dirs;
QMap<QString, QString> scriptList;
QMultiMap<QString, QString> scriptList;

// add the default paths
QStringList stdPaths =
Expand Down Expand Up @@ -136,10 +136,10 @@ QMap<QString, QString> ScriptLoader::scriptList(const QString& type)
if (scriptList.contains(displayName)) {
// check the last-modified-time of the existing case
QFileInfo file(filePath);
QFileInfo existingFile(scriptList[displayName]);
QFileInfo existingFile(scriptList.value(displayName));
if (file.lastModified() > existingFile.lastModified()) {
// replace existing with this new entry
scriptList.insert(displayName, filePath);
scriptList.replace(displayName, filePath);
}
} else // new entry
scriptList.insert(displayName, filePath);
Expand Down
2 changes: 1 addition & 1 deletion avogadro/qtgui/scriptloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AVOGADROQTGUI_EXPORT ScriptLoader : public QObject
/**
* @return A map of name -> path for all scripts of the requested @arg type
*/
static QMap<QString, QString> scriptList(const QString& type);
static QMultiMap<QString, QString> scriptList(const QString& type);

static bool queryProgramName(const QString& scriptFilePath,
QString& displayName);
Expand Down
2 changes: 1 addition & 1 deletion avogadro/qtplugins/commandscripts/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private slots:
QProgressDialog* m_progress;

// maps program name --> script file path
QMap<QString, QString> m_commandScripts;
QMultiMap<QString, QString> m_commandScripts;

const Io::FileFormat* m_outputFormat;
QString m_outputFileName;
Expand Down
2 changes: 1 addition & 1 deletion avogadro/qtplugins/forcefield/forcefield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ void Forcefield::refreshScripts()
qDeleteAll(m_scripts);
m_scripts.clear();

QMap<QString, QString> scriptPaths =
QMultiMap<QString, QString> scriptPaths =
QtGui::ScriptLoader::scriptList("energy");
foreach (const QString& filePath, scriptPaths) {
auto* model = new ScriptEnergy(filePath);
Expand Down
2 changes: 1 addition & 1 deletion avogadro/qtplugins/quantuminput/quantuminput.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private slots:
QMap<QString, MoleQueue::InputGeneratorDialog*> m_dialogs;

// maps program name --> script file path
QMap<QString, QString> m_inputGeneratorScripts;
QMultiMap<QString, QString> m_inputGeneratorScripts;

const Io::FileFormat* m_outputFormat;
QString m_outputFileName;
Expand Down
2 changes: 1 addition & 1 deletion avogadro/qtplugins/scriptcharges/scriptcharges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void ScriptCharges::refreshModels()
qDeleteAll(m_models);
m_models.clear();

QMap<QString, QString> scriptPaths =
QMultiMap<QString, QString> scriptPaths =
QtGui::ScriptLoader::scriptList("charges");
foreach (const QString& filePath, scriptPaths) {
auto* model = new ScriptChargeModel(filePath);
Expand Down
2 changes: 1 addition & 1 deletion avogadro/qtplugins/scriptfileformats/scriptfileformats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void ScriptFileFormats::refreshFileFormats()
qDeleteAll(m_formats);
m_formats.clear();

QMap<QString, QString> scriptPaths =
QMultiMap<QString, QString> scriptPaths =
QtGui::ScriptLoader::scriptList("formatScripts");
foreach (const QString& filePath, scriptPaths) {
auto* format = new FileFormatScript(filePath);
Expand Down

0 comments on commit 474927d

Please sign in to comment.