refactor(RD): move BaseInstance dep. to subclasses of ResourceModel
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
b3330cb0da
commit
e62e1d9701
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace ResourceDownload {
|
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 ********/
|
/******** Make data requests ********/
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
|
#include "BaseInstance.h"
|
||||||
|
|
||||||
#include "modplatform/ModIndex.h"
|
#include "modplatform/ModIndex.h"
|
||||||
#include "modplatform/ResourceAPI.h"
|
#include "modplatform/ResourceAPI.h"
|
||||||
|
|
||||||
@ -38,6 +40,8 @@ class ModModel : public ResourceModel {
|
|||||||
auto documentToArray(QJsonDocument& obj) const -> QJsonArray override = 0;
|
auto documentToArray(QJsonDocument& obj) const -> QJsonArray override = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
const BaseInstance& m_base_instance;
|
||||||
|
|
||||||
std::shared_ptr<ModFilterWidget::Filter> m_filter = nullptr;
|
std::shared_ptr<ModFilterWidget::Filter> m_filter = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ namespace ResourceDownload {
|
|||||||
|
|
||||||
QHash<ResourceModel*, bool> ResourceModel::s_running_models;
|
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);
|
s_running_models.insert(this, true);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
#include "QObjectPtr.h"
|
#include "QObjectPtr.h"
|
||||||
#include "BaseInstance.h"
|
|
||||||
|
|
||||||
#include "modplatform/ResourceAPI.h"
|
#include "modplatform/ResourceAPI.h"
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ class ResourceModel : public QAbstractListModel {
|
|||||||
Q_PROPERTY(QString search_term MEMBER m_search_term WRITE setSearchTerm)
|
Q_PROPERTY(QString search_term MEMBER m_search_term WRITE setSearchTerm)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ResourceModel(BaseInstance const&, ResourceAPI* api);
|
ResourceModel(ResourceAPI* api);
|
||||||
~ResourceModel() override;
|
~ResourceModel() override;
|
||||||
|
|
||||||
[[nodiscard]] auto data(const QModelIndex&, int role) const -> QVariant 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&);
|
virtual void loadIndexedPackVersions(ModPlatform::IndexedPack&, QJsonArray&);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const BaseInstance& m_base_instance;
|
|
||||||
|
|
||||||
/* Basic search parameters */
|
/* Basic search parameters */
|
||||||
enum class SearchState { None, CanFetchMore, ResetRequested, Finished } m_search_state = SearchState::None;
|
enum class SearchState { None, CanFetchMore, ResetRequested, Finished } m_search_state = SearchState::None;
|
||||||
int m_next_search_offset = 0;
|
int m_next_search_offset = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user