mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Don't precompute load order errors after every change
It's much slower than doing it on demand as it only takes a microsecond, but for a really big load order, there are hundreds of thousands of intermediate calls before everything's set up and we can draw the GUI.
This commit is contained in:
parent
d6b61f1f54
commit
894ea4ba62
3 changed files with 7 additions and 31 deletions
|
@ -307,7 +307,6 @@ bool ContentSelectorModel::ContentModel::setData(const QModelIndex& index, const
|
|||
{
|
||||
setCheckState(file->filePath(), success);
|
||||
emit dataChanged(index, index);
|
||||
checkForLoadOrderErrors();
|
||||
}
|
||||
else
|
||||
return success;
|
||||
|
@ -422,7 +421,6 @@ bool ContentSelectorModel::ContentModel::dropMimeData(
|
|||
|
||||
dataChanged(index(minRow, 0), index(maxRow, 0));
|
||||
// at this point we know that drag and drop has finished.
|
||||
checkForLoadOrderErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -702,12 +700,13 @@ void ContentSelectorModel::ContentModel::setNonUserContent(const QStringList& fi
|
|||
|
||||
bool ContentSelectorModel::ContentModel::isLoadOrderError(const EsmFile* file) const
|
||||
{
|
||||
return mPluginsWithLoadOrderError.contains(file->filePath());
|
||||
int index = indexFromItem(file).row();
|
||||
auto errors = checkForLoadOrderErrors(file, index);
|
||||
return !errors.empty();
|
||||
}
|
||||
|
||||
void ContentSelectorModel::ContentModel::setContentList(const QStringList& fileList)
|
||||
{
|
||||
mPluginsWithLoadOrderError.clear();
|
||||
int previousPosition = -1;
|
||||
for (const QString& filepath : fileList)
|
||||
{
|
||||
|
@ -727,27 +726,9 @@ void ContentSelectorModel::ContentModel::setContentList(const QStringList& fileL
|
|||
}
|
||||
}
|
||||
}
|
||||
checkForLoadOrderErrors();
|
||||
emit dataChanged(index(0, 0), index(rowCount(), columnCount()));
|
||||
}
|
||||
|
||||
void ContentSelectorModel::ContentModel::checkForLoadOrderErrors()
|
||||
{
|
||||
for (int row = 0; row < mFiles.count(); ++row)
|
||||
{
|
||||
EsmFile* file = mFiles.at(row);
|
||||
bool isRowInError = checkForLoadOrderErrors(file, row).count() != 0;
|
||||
if (isRowInError)
|
||||
{
|
||||
mPluginsWithLoadOrderError.insert(file->filePath());
|
||||
}
|
||||
else
|
||||
{
|
||||
mPluginsWithLoadOrderError.remove(file->filePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QList<ContentSelectorModel::LoadOrderError> ContentSelectorModel::ContentModel::checkForLoadOrderErrors(
|
||||
const EsmFile* file, int row) const
|
||||
{
|
||||
|
@ -786,11 +767,12 @@ QList<ContentSelectorModel::LoadOrderError> ContentSelectorModel::ContentModel::
|
|||
|
||||
QString ContentSelectorModel::ContentModel::toolTip(const EsmFile* file) const
|
||||
{
|
||||
if (isLoadOrderError(file))
|
||||
int index = indexFromItem(file).row();
|
||||
auto errors = checkForLoadOrderErrors(file, index);
|
||||
if (!errors.empty())
|
||||
{
|
||||
QString text("<b>");
|
||||
int index = indexFromItem(item(file->filePath())).row();
|
||||
for (const LoadOrderError& error : checkForLoadOrderErrors(file, index))
|
||||
for (const LoadOrderError& error : errors)
|
||||
{
|
||||
assert(error.errorCode() != LoadOrderError::ErrorCode::ErrorCode_None);
|
||||
|
||||
|
|
|
@ -69,9 +69,6 @@ namespace ContentSelectorModel
|
|||
|
||||
void refreshModel();
|
||||
|
||||
/// Checks all plug-ins for load order errors and updates mPluginsWithLoadOrderError with plug-ins with issues
|
||||
void checkForLoadOrderErrors();
|
||||
|
||||
private:
|
||||
void addFile(EsmFile* file);
|
||||
|
||||
|
@ -89,7 +86,6 @@ namespace ContentSelectorModel
|
|||
QStringList mNonUserContent;
|
||||
std::set<const EsmFile*> mCheckedFiles;
|
||||
QHash<QString, bool> mNewFiles;
|
||||
QSet<QString> mPluginsWithLoadOrderError;
|
||||
QString mEncoding;
|
||||
QIcon mWarningIcon;
|
||||
QIcon mErrorIcon;
|
||||
|
|
|
@ -211,7 +211,6 @@ void ContentSelectorView::ContentSelector::addFiles(const QString& path, bool ne
|
|||
ui->gameFileView->setCurrentIndex(0);
|
||||
|
||||
mContentModel->uncheckAll();
|
||||
mContentModel->checkForLoadOrderErrors();
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::sortFiles()
|
||||
|
@ -254,7 +253,6 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i
|
|||
oldIndex = index;
|
||||
|
||||
setGameFileSelected(index, true);
|
||||
mContentModel->checkForLoadOrderErrors();
|
||||
}
|
||||
|
||||
emit signalCurrentGamefileIndexChanged(index);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue