NOISSUE do not lose selection on mod enable/disable toggle

This commit is contained in:
Petr Mrázek
2019-08-05 00:44:56 +02:00
parent dfb30d9139
commit c291946d2a
7 changed files with 99 additions and 60 deletions

View File

@ -18,6 +18,7 @@
#include "Mod.h"
#include <QDebug>
#include <FileSystem.h>
namespace {
@ -100,34 +101,15 @@ bool Mod::enable(bool value)
if (!foo.rename(path))
return false;
}
m_file = QFileInfo(path);
repath(QFileInfo(path));
m_enabled = value;
return true;
}
bool Mod::destroy()
{
if (m_type == MOD_FOLDER)
{
QDir d(m_file.filePath());
if (d.removeRecursively())
{
m_type = MOD_UNKNOWN;
return true;
}
return false;
}
else if (m_type == MOD_SINGLEFILE || m_type == MOD_ZIPFILE || m_type == MOD_LITEMOD)
{
QFile f(m_file.filePath());
if (f.remove())
{
m_type = MOD_UNKNOWN;
return true;
}
return false;
}
return true;
m_type = MOD_UNKNOWN;
return FS::deletePath(m_file.filePath());
}