mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2025-09-04 01:42:44 +00:00
Add UserLoader back + misc regression fixes
This commit is contained in:
parent
bb1e3ea21d
commit
e04ec364c1
15 changed files with 406 additions and 21 deletions
|
@ -252,6 +252,8 @@ extern template int extractTotalRecordCount(const QList<DTO::BaseItemDto> &resul
|
|||
extern template void setRequestLimit(Loader::GetLatestMediaParams ¶ms, int limit);
|
||||
extern template bool setRequestStartIndex(Loader::GetLatestMediaParams ¶ms, int offset);
|
||||
|
||||
extern template QList<DTO::UserDto> extractRecords(const QList<DTO::UserDto> &result);
|
||||
extern template int extractTotalRecordCount(const QList<DTO::UserDto> &result);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#include "viewmodel/modelstatus.h"
|
||||
#include "viewmodel/playbackmanager.h"
|
||||
#include "viewmodel/userdata.h"
|
||||
#include "viewmodel/usermodel.h"
|
||||
#include "viewmodel/user.h"
|
||||
|
||||
namespace Jellyfin {
|
||||
|
||||
|
|
39
core/include/JellyfinQt/model/user.h
Normal file
39
core/include/JellyfinQt/model/user.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Sailfin: a Jellyfin client written using Qt
|
||||
* Copyright (C) 2021 Chris Josten and the Sailfin Contributors.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef JELLYFIN_MODEL_USER_H
|
||||
#define JELLYFIN_MODEL_USER_H
|
||||
|
||||
#include "../dto/userdto.h"
|
||||
|
||||
namespace Jellyfin {
|
||||
namespace Model {
|
||||
|
||||
class User : public DTO::UserDto {
|
||||
|
||||
public:
|
||||
User();
|
||||
User(const DTO::UserDto &data, ApiClient *apiClient = nullptr);
|
||||
|
||||
bool sameAs(const DTO::UserDto &other);
|
||||
};
|
||||
|
||||
}
|
||||
} // NS Jellyfin
|
||||
|
||||
#endif // JELLYFIN_MODEL_USER_H
|
|
@ -323,7 +323,6 @@ public:
|
|||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QSharedPointer<Model::Item> itemAt(int index);
|
||||
};
|
||||
|
||||
#undef JFRN
|
||||
|
||||
} // NS Jellyfin
|
||||
|
|
94
core/include/JellyfinQt/viewmodel/user.h
Normal file
94
core/include/JellyfinQt/viewmodel/user.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Sailfin: a Jellyfin client written using Qt
|
||||
* Copyright (C) 2021 Chris Josten and the Sailfin Contributors.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef JELLYFIN_VIEWMODEL_USER_H
|
||||
#define JELLYFIN_VIEWMODEL_USER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QString>
|
||||
|
||||
#include "../loader/http/getitem.h"
|
||||
#include "../loader/requesttypes.h"
|
||||
#include "../model/user.h"
|
||||
#include "loader.h"
|
||||
|
||||
namespace Jellyfin {
|
||||
|
||||
namespace ViewModel {
|
||||
|
||||
class User : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit User(QObject *parent = nullptr, QSharedPointer<Model::User> data = QSharedPointer<Model::User>::create());
|
||||
|
||||
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
||||
Q_PROPERTY(QString serverId READ serverId NOTIFY serverIdChanged)
|
||||
Q_PROPERTY(QString serverName READ serverName NOTIFY serverNameChanged)
|
||||
Q_PROPERTY(QString userId READ userId NOTIFY userIdChanged)
|
||||
Q_PROPERTY(QString primaryImageTag READ primaryImageTag NOTIFY primaryImageTagChanged)
|
||||
Q_PROPERTY(bool hasPassword READ hasPassword NOTIFY hasPasswordChanged)
|
||||
Q_PROPERTY(bool hasConfiguredPassword READ hasConfiguredPassword NOTIFY hasConfiguredPasswordChanged)
|
||||
Q_PROPERTY(bool hasConfiguredEasyPassword READ hasConfiguredEasyPassword NOTIFY hasConfiguredEasyPasswordChanged)
|
||||
|
||||
QString name() const { return m_data->name(); }
|
||||
QString serverId() const { return m_data->serverId(); }
|
||||
QString serverName() const { return m_data->serverName(); }
|
||||
QString userId() const { return m_data->jellyfinId(); }
|
||||
QString primaryImageTag() const { return m_data->primaryImageTag(); }
|
||||
bool hasPassword() const { return m_data->hasPassword(); }
|
||||
bool hasConfiguredPassword() const { return m_data->hasConfiguredPassword(); }
|
||||
bool hasConfiguredEasyPassword() const { return m_data->hasConfiguredEasyPassword(); }
|
||||
|
||||
QSharedPointer<Model::User> data() const { return m_data; }
|
||||
void setData(QSharedPointer<Model::User> newData);
|
||||
|
||||
signals:
|
||||
void nameChanged(QString newName);
|
||||
void serverIdChanged(QString newServerId);
|
||||
void serverNameChanged(QString newServerName);
|
||||
void userIdChanged(QString newUserId);
|
||||
void primaryImageTagChanged(QString newPrimaryImageTag);
|
||||
void hasPasswordChanged(bool newHasPassword);
|
||||
void hasConfiguredPasswordChanged(bool newHasConfiguredPassword);
|
||||
void hasConfiguredEasyPasswordChanged(bool newHasConfiguredEasyPasswordChanged);
|
||||
|
||||
private:
|
||||
QSharedPointer<Model::User> m_data;
|
||||
|
||||
};
|
||||
|
||||
using UserLoaderBase = Loader<ViewModel::User, DTO::UserDto, Jellyfin::Loader::GetUserByIdParams>;
|
||||
class UserLoader : public UserLoaderBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UserLoader(QObject *parent = nullptr);
|
||||
Q_PROPERTY(QString userId READ userId WRITE setUserId NOTIFY userIdChanged)
|
||||
|
||||
QString userId() const { return m_parameters.userId(); }
|
||||
void setUserId(QString newUserId);
|
||||
virtual bool canReload() const override;
|
||||
|
||||
signals:
|
||||
void userIdChanged(const QString &newUserId) const;
|
||||
};
|
||||
|
||||
}
|
||||
} // NS Jellyfin
|
||||
|
||||
#endif // JELLYFIN_VIEWMODEL_USER_H
|
75
core/include/JellyfinQt/viewmodel/usermodel.h
Normal file
75
core/include/JellyfinQt/viewmodel/usermodel.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Sailfin: a Jellyfin client written using Qt
|
||||
* Copyright (C) 2021 Chris Josten and the Sailfin Contributors.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef JELLYFIN_VIEWMODEL_USERMODEL_H
|
||||
#define JELLYFIN_VIEWMODEL_USERMODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QByteArray>
|
||||
#include <QHash>
|
||||
|
||||
#include "../loader/http/getpublicusers.h"
|
||||
#include "../loader/requesttypes.h"
|
||||
#include "../model/user.h"
|
||||
#include "../apimodel.h"
|
||||
#include "propertyhelper.h"
|
||||
|
||||
|
||||
namespace Jellyfin {
|
||||
namespace ViewModel {
|
||||
|
||||
// Jellyfin Forward Read/Write Property
|
||||
#define FWDPROP(type, propName, propSetName) JF_FWD_RW_PROP(type, propName, propSetName, this->m_parameters)
|
||||
|
||||
class UserModel : public ApiModel<Model::User> {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum RoleNames {
|
||||
userId = Qt::UserRole + 1,
|
||||
name,
|
||||
hasPassword,
|
||||
primaryImageTag,
|
||||
};
|
||||
|
||||
explicit UserModel (QObject *parent = nullptr);
|
||||
|
||||
virtual QHash<int, QByteArray> roleNames() const override {
|
||||
return {
|
||||
{ RoleNames::userId, "userId" },
|
||||
{ RoleNames::name, "name" },
|
||||
{ RoleNames::hasPassword, "hasPassword" },
|
||||
{ RoleNames::primaryImageTag, "primaryImageTag" },
|
||||
};
|
||||
}
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
};
|
||||
|
||||
using PublicUsersLoaderBase = LoaderModelLoader<Model::User, DTO::UserDto, QList<DTO::UserDto>, Jellyfin::Loader::GetPublicUsersParams>;
|
||||
class PublicUsersLoader : public PublicUsersLoaderBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PublicUsersLoader(QObject *parent = nullptr);
|
||||
bool canReload() const override;
|
||||
};
|
||||
|
||||
#undef FWDPROP
|
||||
|
||||
} // NS ViewModel
|
||||
} // NS Jellyfin
|
||||
|
||||
#endif // JELLYFIN_VIEWMODEL_USERMODEL_H
|
Loading…
Add table
Add a link
Reference in a new issue