diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index 81095db196..9280b6f9c0 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -278,7 +278,7 @@ bool ContentSelectorModel::ContentModel::setData(const QModelIndex& index, const if (success) { - success = setCheckState(file->filePath(), value.toBool()); + success = setCheckState(file, value.toBool()); emit dataChanged(index, index); } } @@ -305,7 +305,7 @@ bool ContentSelectorModel::ContentModel::setData(const QModelIndex& index, const if (setState) { - setCheckState(file->filePath(), success); + setCheckState(file, success); emit dataChanged(index, index); } else @@ -710,11 +710,11 @@ void ContentSelectorModel::ContentModel::setContentList(const QStringList& fileL int previousPosition = -1; for (const QString& filepath : fileList) { - if (setCheckState(filepath, true)) + const EsmFile* file = item(filepath); + if (setCheckState(file, true)) { // setCheckState already gracefully handles builtIn and fromAnotherConfigFile // as necessary, move plug-ins in visible list to match sequence of supplied filelist - const EsmFile* file = item(filepath); int filePosition = indexFromItem(file).row(); if (filePosition < previousPosition) { @@ -795,13 +795,8 @@ void ContentSelectorModel::ContentModel::refreshModel() emit dataChanged(index(0, 0), index(rowCount() - 1, 0)); } -bool ContentSelectorModel::ContentModel::setCheckState(const QString& filepath, bool checkState) +bool ContentSelectorModel::ContentModel::setCheckState(const EsmFile* file, bool checkState) { - if (filepath.isEmpty()) - return false; - - const EsmFile* file = item(filepath); - if (!file || file->builtIn() || file->fromAnotherConfigFile()) return false; @@ -810,7 +805,7 @@ bool ContentSelectorModel::ContentModel::setCheckState(const QString& filepath, else mCheckedFiles.erase(file); - emit dataChanged(indexFromItem(item(filepath)), indexFromItem(item(filepath))); + emit dataChanged(indexFromItem(file), indexFromItem(file)); if (file->isGameFile()) refreshModel(); diff --git a/components/contentselector/model/contentmodel.hpp b/components/contentselector/model/contentmodel.hpp index 3eba939125..19b2e6cceb 100644 --- a/components/contentselector/model/contentmodel.hpp +++ b/components/contentselector/model/contentmodel.hpp @@ -59,7 +59,7 @@ namespace ContentSelectorModel void setCurrentGameFile(const EsmFile* file); bool isEnabled(const QModelIndex& index) const; - bool setCheckState(const QString& filepath, bool isChecked); + bool setCheckState(const EsmFile* file, bool isChecked); bool isNew(const QString& filepath) const; void setNew(const QString& filepath, bool isChecked); void setNonUserContent(const QStringList& fileList); diff --git a/components/contentselector/view/contentselector.cpp b/components/contentselector/view/contentselector.cpp index 0be6e7c023..42851e1e21 100644 --- a/components/contentselector/view/contentselector.cpp +++ b/components/contentselector/view/contentselector.cpp @@ -156,7 +156,7 @@ void ContentSelectorView::ContentSelector::setGameFile(const QString& filename) index = ui->gameFileView->findText(file->fileName()); // verify that the current index is also checked in the model - if (!mContentModel->setCheckState(filename, true)) + if (!mContentModel->setCheckState(file, true)) { // throw error in case file not found? return;