From 9d358dd44c4df478ac90650338809321aa837aa8 Mon Sep 17 00:00:00 2001 From: graffy76 Date: Mon, 23 Sep 2013 22:01:44 -0500 Subject: [PATCH] Further implemented auto-checking / unchecking of dependencies --- .../contentselector/model/contentmodel.cpp | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index c1394ef47..db6431810 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -458,17 +458,51 @@ bool ContentSelectorModel::ContentModel::isChecked(const QString& name) const return false; } -void ContentSelectorModel::ContentModel::setCheckState(const QString &name, bool isChecked) +void ContentSelectorModel::ContentModel::setCheckState(const QString &name, bool checkState) { if (name.isEmpty()) return; Qt::CheckState state = Qt::Unchecked; - if (isChecked) + if (checkState) state = Qt::Checked; mCheckStates[name] = state; + + const EsmFile *file = item(name); + + if (state == Qt::Checked) + { + foreach (const QString &upstreamName, file->gameFiles()) + { + const EsmFile *upstreamFile = item(upstreamName); + + if (!upstreamFile) + continue; + + if (!isChecked(upstreamName)) + { + mCheckStates[upstreamName] = Qt::Checked; + emit dataChanged(indexFromItem(upstreamFile), indexFromItem(upstreamFile)); + } + + } + } + else if (state == Qt::Unchecked) + { + foreach (const EsmFile *downstreamFile, mFiles) + { + if (downstreamFile->gameFiles().contains(name)) + { + if (mCheckStates.contains(downstreamFile->fileName())) + { + mCheckStates[downstreamFile->fileName()] = Qt::Unchecked; + emit dataChanged(indexFromItem(downstreamFile), indexFromItem(downstreamFile)); + } + } + } + } } ContentSelectorModel::ContentFileList ContentSelectorModel::ContentModel::checkedItems() const