From ebe5448816532c55b9c19ded462b8e65701bd8bb Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Thu, 16 May 2019 00:15:21 +0300 Subject: [PATCH] Content selector: drop duplicates of the added file (bug #2395) --- CHANGELOG.md | 1 + components/contentselector/model/contentmodel.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5c6a0885..3658b839a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ------ Bug #1515: Opening console masks dialogue, inventory menu + Bug #2395: Duplicated plugins in the launcher when multiple data directories provide the same plugin Bug #2969: Scripted items can stack Bug #2987: Editor: some chance and AI data fields can overflow Bug #3006: 'else if' operator breaks script compilation diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index 7a4558d57..ef27f938d 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -408,6 +408,17 @@ bool ContentSelectorModel::ContentModel::dropMimeData(const QMimeData *data, Qt: void ContentSelectorModel::ContentModel::addFile(EsmFile *file) { + for (int row = 0; row < mFiles.size(); row++) + { + if (mFiles.at(row)->fileName() == file->fileName()) + { + beginRemoveRows(QModelIndex(), row, row); + mFiles.removeAt(row); + endRemoveRows(); + emit dataChanged(index(row, 0), index(mFiles.size(), 0)); + break; + } + } beginInsertRows(QModelIndex(), mFiles.count(), mFiles.count()); mFiles.append(file); endInsertRows();