From b2d0dd2d6c686b1fdebbd4949a2e46e55a2d3787 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 10 Mar 2020 23:10:20 +1000 Subject: [PATCH] Qt/GameList: Update entry rather than ignoring same directory added twice --- src/duckstation-qt/gamelistsettingswidget.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/duckstation-qt/gamelistsettingswidget.cpp b/src/duckstation-qt/gamelistsettingswidget.cpp index 9350098d0..cad030167 100644 --- a/src/duckstation-qt/gamelistsettingswidget.cpp +++ b/src/duckstation-qt/gamelistsettingswidget.cpp @@ -4,7 +4,6 @@ #include "core/game_list.h" #include "qthostinterface.h" #include "qtutils.h" -#include #include #include #include @@ -17,6 +16,7 @@ #include #include #include +#include static constexpr char REDUMP_DOWNLOAD_URL[] = "http://redump.org/datfile/psx/serial,version,description"; @@ -104,15 +104,19 @@ public: void addEntry(const QString& path, bool recursive) { - if (std::find_if(m_entries.begin(), m_entries.end(), [path](const Entry& e) { return e.path == path; }) != - m_entries.end()) + auto existing = std::find_if(m_entries.begin(), m_entries.end(), [path](const Entry& e) { return e.path == path; }); + if (existing != m_entries.end()) { - return; + const int row = static_cast(existing - m_entries.begin()); + existing->recursive = recursive; + dataChanged(index(row, 1), index(row, 1), QVector{Qt::CheckStateRole}); + } + else + { + beginInsertRows(QModelIndex(), static_cast(m_entries.size()), static_cast(m_entries.size())); + m_entries.push_back({path, recursive}); + endInsertRows(); } - - beginInsertRows(QModelIndex(), static_cast(m_entries.size()), static_cast(m_entries.size())); - m_entries.push_back({path, recursive}); - endInsertRows(); saveToSettings(); m_host_interface->refreshGameList(false);