mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2026-05-19 10:35:16 +00:00
WIP: Slowly bringing back viewmodels
This commit is contained in:
parent
9abee12658
commit
228f81984b
17 changed files with 292 additions and 96 deletions
|
|
@ -62,7 +62,7 @@ void BaseModelLoader::setApiClient(ApiClient *newApiClient) {
|
|||
void BaseModelLoader::setLimit(int newLimit) {
|
||||
int oldLimit = this->m_limit;
|
||||
m_limit = newLimit;
|
||||
if (oldLimit != this->m_limit) {
|
||||
if (oldLimit != newLimit) {
|
||||
emit limitChanged(this->m_limit);
|
||||
}
|
||||
}
|
||||
|
|
@ -76,6 +76,7 @@ void BaseModelLoader::setAutoReload(bool newAutoReload) {
|
|||
|
||||
bool BaseModelLoader::canReload() const {
|
||||
return m_apiClient != nullptr
|
||||
&& !m_isBeingParsed
|
||||
// If the loader for this model needs authentication (almost every one does)
|
||||
// block if the ApiClient is not authenticated yet.
|
||||
&& (!m_needsAuthentication || m_apiClient->authenticated())
|
||||
|
|
@ -88,6 +89,8 @@ void BaseApiModel::reload() {
|
|||
qWarning() << " BaseApiModel slot called instead of overloaded method";
|
||||
}
|
||||
|
||||
// Parameters injectors and result extractors
|
||||
|
||||
template <>
|
||||
bool setRequestStartIndex(Loader::GetUserViewsParams ¶ms, int startIndex) {
|
||||
// Not supported
|
||||
|
|
@ -112,6 +115,28 @@ int extractTotalRecordCount(const DTO::BaseItemDtoQueryResult &result) {
|
|||
return result.totalRecordCount();
|
||||
}
|
||||
|
||||
template <>
|
||||
QList<DTO::BaseItemDto> extractRecords(const QList<DTO::BaseItemDto> &result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
template <>
|
||||
int extractTotalRecordCount(const QList<DTO::BaseItemDto> &result) {
|
||||
return result.size();
|
||||
}
|
||||
|
||||
template<>
|
||||
void setRequestLimit(Loader::GetLatestMediaParams ¶ms, int limit) {
|
||||
params.setLimit(limit);
|
||||
}
|
||||
|
||||
template<>
|
||||
bool setRequestStartIndex(Loader::GetLatestMediaParams ¶ms, int offset) {
|
||||
Q_UNUSED(params)
|
||||
Q_UNUSED(offset)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void registerModels(const char *URI) {
|
||||
Q_UNUSED(URI)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue