2017-11-11 00:38:31 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QDateTime>
|
2023-08-14 17:16:53 +01:00
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QList>
|
|
|
|
#include <memory>
|
2017-11-11 00:38:31 +00:00
|
|
|
#include "ProblemProvider.h"
|
|
|
|
#include "QObjectPtr.h"
|
2023-08-14 17:16:53 +01:00
|
|
|
#include "meta/JsonFormat.h"
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2020-06-27 11:02:31 +01:00
|
|
|
class PackProfile;
|
2017-11-11 00:38:31 +00:00
|
|
|
class LaunchProfile;
|
2023-08-14 17:16:53 +01:00
|
|
|
namespace Meta {
|
|
|
|
class Version;
|
|
|
|
class VersionList;
|
|
|
|
} // namespace Meta
|
2017-11-11 00:38:31 +00:00
|
|
|
class VersionFile;
|
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
class Component : public QObject, public ProblemProvider {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
Component(PackProfile* parent, const QString& uid);
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
// DEPRECATED: remove these constructors?
|
2023-08-14 17:16:53 +01:00
|
|
|
Component(PackProfile* parent, std::shared_ptr<Meta::Version> version);
|
|
|
|
Component(PackProfile* parent, const QString& uid, std::shared_ptr<VersionFile> file);
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
virtual ~Component() {}
|
2023-06-04 22:59:37 +01:00
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
void applyTo(LaunchProfile* profile);
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
bool isEnabled();
|
2023-08-14 17:16:53 +01:00
|
|
|
bool setEnabled(bool state);
|
2018-07-15 13:51:05 +01:00
|
|
|
bool canBeDisabled();
|
2017-12-03 14:48:25 +00:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
bool isMoveable();
|
|
|
|
bool isCustomizable();
|
|
|
|
bool isRevertible();
|
|
|
|
bool isRemovable();
|
|
|
|
bool isCustom();
|
|
|
|
bool isVersionChangeable();
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
// DEPRECATED: explicit numeric order values, used for loading old non-component config. TODO: refactor and move to migration code
|
|
|
|
void setOrder(int order);
|
|
|
|
int getOrder();
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
QString getID();
|
|
|
|
QString getName();
|
|
|
|
QString getVersion();
|
|
|
|
std::shared_ptr<Meta::Version> getMeta();
|
|
|
|
QDateTime getReleaseDateTime();
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
QString getFilename();
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
std::shared_ptr<class VersionFile> getVersionFile() const;
|
|
|
|
std::shared_ptr<class Meta::VersionList> getVersionList() const;
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
void setImportant(bool state);
|
2017-12-03 14:48:25 +00:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
const QList<PatchProblem> getProblems() const override;
|
|
|
|
ProblemSeverity getProblemSeverity() const override;
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
void setVersion(const QString& version);
|
2018-07-15 13:51:05 +01:00
|
|
|
bool customize();
|
|
|
|
bool revert();
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
void updateCachedData();
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
signals:
|
2018-07-15 13:51:05 +01:00
|
|
|
void dataChanged();
|
2017-11-11 00:38:31 +00:00
|
|
|
|
2023-08-14 17:16:53 +01:00
|
|
|
public: /* data */
|
|
|
|
PackProfile* m_parent;
|
2018-07-15 13:51:05 +01:00
|
|
|
|
|
|
|
// BEGIN: persistent component list properties
|
|
|
|
/// ID of the component
|
|
|
|
QString m_uid;
|
|
|
|
/// version of the component - when there's a custom json override, this is also the version the component reverts to
|
|
|
|
QString m_version;
|
|
|
|
/// if true, this has been added automatically to satisfy dependencies and may be automatically removed
|
|
|
|
bool m_dependencyOnly = false;
|
|
|
|
/// if true, the component is either the main component of the instance, or otherwise important and cannot be removed.
|
|
|
|
bool m_important = false;
|
|
|
|
/// if true, the component is disabled
|
|
|
|
bool m_disabled = false;
|
|
|
|
|
|
|
|
/// cached name for display purposes, taken from the version file (meta or local override)
|
|
|
|
QString m_cachedName;
|
|
|
|
/// cached version for display AND other purposes, taken from the version file (meta or local override)
|
|
|
|
QString m_cachedVersion;
|
|
|
|
/// cached set of requirements, taken from the version file (meta or local override)
|
|
|
|
Meta::RequireSet m_cachedRequires;
|
|
|
|
Meta::RequireSet m_cachedConflicts;
|
|
|
|
/// if true, the component is volatile and may be automatically removed when no longer needed
|
|
|
|
bool m_cachedVolatile = false;
|
|
|
|
// END: persistent component list properties
|
|
|
|
|
|
|
|
// DEPRECATED: explicit numeric order values, used for loading old non-component config. TODO: refactor and move to migration code
|
|
|
|
bool m_orderOverride = false;
|
|
|
|
int m_order = 0;
|
|
|
|
|
|
|
|
// load state
|
|
|
|
std::shared_ptr<Meta::Version> m_metaVersion;
|
|
|
|
std::shared_ptr<VersionFile> m_file;
|
|
|
|
bool m_loaded = false;
|
2017-11-11 00:38:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef shared_qobject_ptr<Component> ComponentPtr;
|