Further implemented auto-checking / unchecking of dependencies

This commit is contained in:
graffy76 2013-09-23 22:01:44 -05:00
parent d7cff6361e
commit 9d358dd44c

View file

@ -458,17 +458,51 @@ bool ContentSelectorModel::ContentModel::isChecked(const QString& name) const
return false; return false;
} }
void ContentSelectorModel::ContentModel::setCheckState(const QString &name, bool isChecked) void ContentSelectorModel::ContentModel::setCheckState(const QString &name, bool checkState)
{ {
if (name.isEmpty()) if (name.isEmpty())
return; return;
Qt::CheckState state = Qt::Unchecked; Qt::CheckState state = Qt::Unchecked;
if (isChecked) if (checkState)
state = Qt::Checked; state = Qt::Checked;
mCheckStates[name] = state; 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 ContentSelectorModel::ContentFileList ContentSelectorModel::ContentModel::checkedItems() const