move resolution into update actions in task.

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers
2024-06-27 15:42:25 -07:00
parent 474effe7c7
commit a85d6cb1f2
6 changed files with 231 additions and 82 deletions

View File

@ -4,6 +4,7 @@
#include <QJsonDocument>
#include <QList>
#include <memory>
#include <optional>
#include "ProblemProvider.h"
#include "QObjectPtr.h"
#include "meta/JsonFormat.h"
@ -16,6 +17,26 @@ class VersionList;
} // namespace Meta
class VersionFile;
struct UpdateActionChangeVerison {
/// version to change to
QString targetVersion;
};
struct UpdateActionLatestRecommendedCompatable {
/// Parent uid
QString parentUid;
QString parentName;
/// Parent version
QString version;
///
};
struct UpdateActionRemove {};
struct UpdateActionImportantChanged {
QString oldVersion;
};
using UpdateAction =
std::variant<UpdateActionChangeVerison, UpdateActionLatestRecommendedCompatable, UpdateActionRemove, UpdateActionImportantChanged>;
class Component : public QObject, public ProblemProvider {
Q_OBJECT
public:
@ -58,6 +79,8 @@ class Component : public QObject, public ProblemProvider {
const QList<PatchProblem> getProblems() const override;
ProblemSeverity getProblemSeverity() const override;
void addComponentProblem(ProblemSeverity severity, const QString& description);
void resetComponentProblems();
void setVersion(const QString& version);
bool customize();
@ -67,6 +90,11 @@ class Component : public QObject, public ProblemProvider {
void waitLoadMeta();
void setUpdateAction(UpdateAction action);
void clearUpdateAction();
std::optional<UpdateAction> getUpdateAction();
std::optional<UpdateAction> takeUpdateAction();
signals:
void dataChanged();
@ -104,6 +132,11 @@ class Component : public QObject, public ProblemProvider {
std::shared_ptr<Meta::Version> m_metaVersion;
std::shared_ptr<VersionFile> m_file;
bool m_loaded = false;
private:
QList<PatchProblem> m_componentProblems;
ProblemSeverity m_componentProblemSeverity = ProblemSeverity::None;
std::optional<UpdateAction> m_updateAction = std::nullopt;
};
using ComponentPtr = shared_qobject_ptr<Component>;