|
|
@ -128,7 +128,7 @@ Qt::ItemFlags ContentSelectorModel::ContentModel::flags(const QModelIndex& index
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
noGameFiles = false;
|
|
|
|
noGameFiles = false;
|
|
|
|
if (isChecked(depFile->filePath()))
|
|
|
|
if (mCheckedFiles.contains(depFile))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
gamefileChecked = true;
|
|
|
|
gamefileChecked = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -215,7 +215,7 @@ QVariant ContentSelectorModel::ContentModel::data(const QModelIndex& index, int
|
|
|
|
if (file == mGameFile)
|
|
|
|
if (file == mGameFile)
|
|
|
|
return QVariant();
|
|
|
|
return QVariant();
|
|
|
|
|
|
|
|
|
|
|
|
return mCheckStates[file->filePath()];
|
|
|
|
return mCheckedFiles.contains(file) ? Qt::Checked : Qt::Unchecked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case Qt::UserRole:
|
|
|
|
case Qt::UserRole:
|
|
|
@ -229,7 +229,7 @@ QVariant ContentSelectorModel::ContentModel::data(const QModelIndex& index, int
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case Qt::UserRole + 1:
|
|
|
|
case Qt::UserRole + 1:
|
|
|
|
return isChecked(file->filePath());
|
|
|
|
return mCheckedFiles.contains(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QVariant();
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -277,12 +277,12 @@ bool ContentSelectorModel::ContentModel::setData(const QModelIndex& index, const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int checkValue = value.toInt();
|
|
|
|
int checkValue = value.toInt();
|
|
|
|
bool setState = false;
|
|
|
|
bool setState = false;
|
|
|
|
if ((checkValue == Qt::Checked) && !isChecked(file->filePath()))
|
|
|
|
if (checkValue == Qt::Checked && !mCheckedFiles.contains(file))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setState = true;
|
|
|
|
setState = true;
|
|
|
|
success = true;
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((checkValue == Qt::Checked) && isChecked(file->filePath()))
|
|
|
|
else if (checkValue == Qt::Checked && mCheckedFiles.contains(file))
|
|
|
|
setState = true;
|
|
|
|
setState = true;
|
|
|
|
else if (checkValue == Qt::Unchecked)
|
|
|
|
else if (checkValue == Qt::Unchecked)
|
|
|
|
setState = true;
|
|
|
|
setState = true;
|
|
|
@ -628,14 +628,6 @@ void ContentSelectorModel::ContentModel::sortFiles()
|
|
|
|
emit layoutChanged();
|
|
|
|
emit layoutChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ContentSelectorModel::ContentModel::isChecked(const QString& filepath) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const auto it = mCheckStates.find(filepath);
|
|
|
|
|
|
|
|
if (it == mCheckStates.end())
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return it.value() == Qt::Checked;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ContentSelectorModel::ContentModel::isEnabled(const QModelIndex& index) const
|
|
|
|
bool ContentSelectorModel::ContentModel::isEnabled(const QModelIndex& index) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return (flags(index) & Qt::ItemIsEnabled);
|
|
|
|
return (flags(index) & Qt::ItemIsEnabled);
|
|
|
@ -723,7 +715,7 @@ QList<ContentSelectorModel::LoadOrderError> ContentSelectorModel::ContentModel::
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!isChecked(dependentFile->filePath()))
|
|
|
|
if (!mCheckedFiles.contains(dependentFile))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
errors.append(LoadOrderError(LoadOrderError::ErrorCode_InactiveDependency, dependentfileName));
|
|
|
|
errors.append(LoadOrderError(LoadOrderError::ErrorCode_InactiveDependency, dependentfileName));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -776,9 +768,13 @@ bool ContentSelectorModel::ContentModel::setCheckState(const QString& filepath,
|
|
|
|
Qt::CheckState state = Qt::Unchecked;
|
|
|
|
Qt::CheckState state = Qt::Unchecked;
|
|
|
|
|
|
|
|
|
|
|
|
if (checkState)
|
|
|
|
if (checkState)
|
|
|
|
|
|
|
|
{
|
|
|
|
state = Qt::Checked;
|
|
|
|
state = Qt::Checked;
|
|
|
|
|
|
|
|
mCheckedFiles.insert(file);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
mCheckedFiles.erase(file);
|
|
|
|
|
|
|
|
|
|
|
|
mCheckStates[filepath] = state;
|
|
|
|
|
|
|
|
emit dataChanged(indexFromItem(item(filepath)), indexFromItem(item(filepath)));
|
|
|
|
emit dataChanged(indexFromItem(item(filepath)), indexFromItem(item(filepath)));
|
|
|
|
|
|
|
|
|
|
|
|
if (file->isGameFile())
|
|
|
|
if (file->isGameFile())
|
|
|
@ -794,8 +790,7 @@ bool ContentSelectorModel::ContentModel::setCheckState(const QString& filepath,
|
|
|
|
if (!upstreamFile)
|
|
|
|
if (!upstreamFile)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
if (!isChecked(upstreamFile->filePath()))
|
|
|
|
mCheckedFiles.insert(upstreamFile);
|
|
|
|
mCheckStates[upstreamFile->filePath()] = Qt::Checked;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emit dataChanged(indexFromItem(upstreamFile), indexFromItem(upstreamFile));
|
|
|
|
emit dataChanged(indexFromItem(upstreamFile), indexFromItem(upstreamFile));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -810,8 +805,7 @@ bool ContentSelectorModel::ContentModel::setCheckState(const QString& filepath,
|
|
|
|
|
|
|
|
|
|
|
|
if (downstreamFile->gameFiles().contains(filename, Qt::CaseInsensitive))
|
|
|
|
if (downstreamFile->gameFiles().contains(filename, Qt::CaseInsensitive))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (mCheckStates.contains(downstreamFile->filePath()))
|
|
|
|
mCheckedFiles.erase(downstreamFile);
|
|
|
|
mCheckStates[downstreamFile->filePath()] = Qt::Unchecked;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emit dataChanged(indexFromItem(downstreamFile), indexFromItem(downstreamFile));
|
|
|
|
emit dataChanged(indexFromItem(downstreamFile), indexFromItem(downstreamFile));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -829,7 +823,7 @@ ContentSelectorModel::ContentFileList ContentSelectorModel::ContentModel::checke
|
|
|
|
// First search for game files and next addons,
|
|
|
|
// First search for game files and next addons,
|
|
|
|
// so we get more or less correct game files vs addons order.
|
|
|
|
// so we get more or less correct game files vs addons order.
|
|
|
|
for (EsmFile* file : mFiles)
|
|
|
|
for (EsmFile* file : mFiles)
|
|
|
|
if (isChecked(file->filePath()))
|
|
|
|
if (mCheckedFiles.contains(file))
|
|
|
|
list << file;
|
|
|
|
list << file;
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
@ -838,6 +832,6 @@ ContentSelectorModel::ContentFileList ContentSelectorModel::ContentModel::checke
|
|
|
|
void ContentSelectorModel::ContentModel::uncheckAll()
|
|
|
|
void ContentSelectorModel::ContentModel::uncheckAll()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
emit layoutAboutToBeChanged();
|
|
|
|
emit layoutAboutToBeChanged();
|
|
|
|
mCheckStates.clear();
|
|
|
|
mCheckedFiles.clear();
|
|
|
|
emit layoutChanged();
|
|
|
|
emit layoutChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|