1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Smarter double-click

This commit is contained in:
nordsoft 2023-09-01 17:40:52 +04:00
parent 31956549e6
commit 5875dc6b8f

View File

@ -894,28 +894,45 @@ void CModListView::on_allModsView_doubleClicked(const QModelIndex &index)
if(!index.isValid())
return;
auto mod = modModel->getMod(index.data(ModRoles::ModNameRole).toString());
auto modName = index.data(ModRoles::ModNameRole).toString();
auto mod = modModel->getMod(modName);
if(mod.isAvailable() && !mod.getName().contains('.'))
bool hasInvalidDeps = !findInvalidDependencies(modName).empty();
bool hasBlockingMods = !findBlockingMods(modName).empty();
bool hasDependentMods = !findDependentMods(modName, true).empty();
if(!hasInvalidDeps && mod.isAvailable() && !mod.getName().contains('.'))
{
on_installButton_clicked();
return;
}
if(mod.isUpdateable())
if(!hasInvalidDeps && !hasDependentMods && mod.isUpdateable() && index.column() == ModFields::STATUS_UPDATE)
{
on_updateButton_clicked();
return;
}
if(mod.isDisabled())
if(index.column() == ModFields::NAME)
{
if(ui->allModsView->isExpanded(index))
ui->allModsView->collapse(index);
else
ui->allModsView->expand(index);
return;
}
if(!hasBlockingMods && !hasInvalidDeps && mod.isDisabled())
{
on_enableButton_clicked();
return;
}
if(mod.isEnabled())
if(!hasDependentMods && !mod.isEssential() && mod.isEnabled())
{
on_disableButton_clicked();
return;
}
}