refactor(RD): decouple ResourceModels from ResourcePages
This makes it so that we don't need a reference to the parent page in the model. It will be useful once we change the page from a widget-based one to a QML page. It also makes tasks be created in the dialog instead of the page, so that the dialog can also have the necessary information to mark versions as selected / deselected easily. It also makes the task pointers into smart pointers. Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
@ -65,6 +65,9 @@ struct IndexedVersion {
|
||||
QString hash;
|
||||
bool is_preferred = true;
|
||||
QString changelog;
|
||||
|
||||
// For internal use, not provided by APIs
|
||||
bool is_currently_selected = false;
|
||||
};
|
||||
|
||||
struct ExtraPackData {
|
||||
@ -95,6 +98,23 @@ struct IndexedPack {
|
||||
// Don't load by default, since some modplatform don't have that info
|
||||
bool extraDataLoaded = true;
|
||||
ExtraPackData extraData;
|
||||
|
||||
// For internal use, not provided by APIs
|
||||
[[nodiscard]] bool isVersionSelected(size_t index) const
|
||||
{
|
||||
if (!versionsLoaded)
|
||||
return false;
|
||||
|
||||
return versions.at(index).is_currently_selected;
|
||||
}
|
||||
[[nodiscard]] bool isAnyVersionSelected() const
|
||||
{
|
||||
if (!versionsLoaded)
|
||||
return false;
|
||||
|
||||
return std::any_of(versions.constBegin(), versions.constEnd(),
|
||||
[](auto const& v) { return v.is_currently_selected; });
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ModPlatform
|
||||
|
Reference in New Issue
Block a user