feat: track instance copies that use links

confirm deleations when other instances link to it

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers
2023-02-15 22:01:27 -07:00
parent 3ec92acfe7
commit 1ca2c59f2e
11 changed files with 213 additions and 2 deletions

View File

@ -40,6 +40,8 @@
#include <QDir>
#include <QDebug>
#include <QRegularExpression>
#include <QJsonDocument>
#include <QJsonObject>
#include "settings/INISettingsObject.h"
#include "settings/Setting.h"
@ -64,6 +66,8 @@ BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr s
m_settings->registerSetting("totalTimePlayed", 0);
m_settings->registerSetting("lastTimePlayed", 0);
m_settings->registerSetting("linkedInstancesList", "[]");
// Game time override
auto gameTimeOverride = m_settings->registerSetting("OverrideGameTime", false);
m_settings->registerOverride(globalSettings->getSetting("ShowGameTime"), gameTimeOverride);
@ -182,6 +186,38 @@ bool BaseInstance::shouldStopOnConsoleOverflow() const
return m_settings->get("ConsoleOverflowStop").toBool();
}
QStringList BaseInstance::getLinkedInstances() const
{
return m_settings->getList<QString>("linkedInstancesList");
}
void BaseInstance::setLinkedInstances(const QStringList& list)
{
auto linkedInstancesList = m_settings->getList<QString>("linkedInstancesList");
m_settings->setList("linkedInstancesList", list);
}
void BaseInstance::addLinkedInstanceId(const QString& id)
{
auto linkedInstancesList = m_settings->getList<QString>("linkedInstancesList");
linkedInstancesList.append(id);
setLinkedInstances(linkedInstancesList);
}
bool BaseInstance::removeLinkedInstanceId(const QString& id)
{
auto linkedInstancesList = m_settings->getList<QString>("linkedInstancesList");
int numRemoved = linkedInstancesList.removeAll(id);
setLinkedInstances(linkedInstancesList);
return numRemoved > 0;
}
bool BaseInstance::isLinkedToInstanceId(const QString& id) const
{
auto linkedInstancesList = m_settings->getList<QString>("linkedInstancesList");
return linkedInstancesList.contains(id);
}
void BaseInstance::iconUpdated(QString key)
{
if(iconKey() == key)