refactor(RD): move BaseInstance dep. to subclasses of ResourceModel

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2023-01-03 12:48:22 -03:00
parent b3330cb0da
commit e62e1d9701
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
4 changed files with 7 additions and 6 deletions

View File

@ -7,7 +7,7 @@
namespace ResourceDownload {
ModModel::ModModel(BaseInstance const& base_inst, ResourceAPI* api) : ResourceModel(base_inst, api) {}
ModModel::ModModel(BaseInstance const& base_inst, ResourceAPI* api) : ResourceModel(api), m_base_instance(base_inst) {}
/******** Make data requests ********/

View File

@ -2,6 +2,8 @@
#include <QAbstractListModel>
#include "BaseInstance.h"
#include "modplatform/ModIndex.h"
#include "modplatform/ResourceAPI.h"
@ -38,6 +40,8 @@ class ModModel : public ResourceModel {
auto documentToArray(QJsonDocument& obj) const -> QJsonArray override = 0;
protected:
const BaseInstance& m_base_instance;
std::shared_ptr<ModFilterWidget::Filter> m_filter = nullptr;
};

View File

@ -21,7 +21,7 @@ namespace ResourceDownload {
QHash<ResourceModel*, bool> ResourceModel::s_running_models;
ResourceModel::ResourceModel(BaseInstance const& base_inst, ResourceAPI* api) : QAbstractListModel(), m_base_instance(base_inst), m_api(api)
ResourceModel::ResourceModel(ResourceAPI* api) : QAbstractListModel(), m_api(api)
{
s_running_models.insert(this, true);
}

View File

@ -5,7 +5,6 @@
#include <QAbstractListModel>
#include "QObjectPtr.h"
#include "BaseInstance.h"
#include "modplatform/ResourceAPI.h"
@ -26,7 +25,7 @@ class ResourceModel : public QAbstractListModel {
Q_PROPERTY(QString search_term MEMBER m_search_term WRITE setSearchTerm)
public:
ResourceModel(BaseInstance const&, ResourceAPI* api);
ResourceModel(ResourceAPI* api);
~ResourceModel() override;
[[nodiscard]] auto data(const QModelIndex&, int role) const -> QVariant override;
@ -103,8 +102,6 @@ class ResourceModel : public QAbstractListModel {
virtual void loadIndexedPackVersions(ModPlatform::IndexedPack&, QJsonArray&);
protected:
const BaseInstance& m_base_instance;
/* Basic search parameters */
enum class SearchState { None, CanFetchMore, ResetRequested, Finished } m_search_state = SearchState::None;
int m_next_search_offset = 0;