1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2024-05-11 16:42:42 +00:00
harbour-sailfin/core/src/model/item.cpp
Chris Josten 7b6c272aa9 Rewire more of Sailfish frontend into new backend
This should encompass most simple things, besides some larger, trickier
things, like the video streams and the now-broken userdata
2021-08-11 23:35:33 +02:00

60 lines
1.9 KiB
C++

/*
* 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
*/
#include <JellyfinQt/model/item.h>
namespace Jellyfin {
namespace Model {
Item::Item(QObject *parent)
: Item(DTO::BaseItemDto(), nullptr, parent) { }
Item::Item(const DTO::BaseItemDto &data, ApiClient *apiClient, QObject *parent)
: DTO::BaseItemDto(data),
QObject(parent),
m_apiClient(nullptr) {
setApiClient(apiClient);
}
bool Item::sameAs(const DTO::BaseItemDto &other) {
return jellyfinId() == other.jellyfinId();
}
void Item::setApiClient(ApiClient *apiClient) {
if (m_apiClient != nullptr) {
disconnect(m_apiClient->eventbus(), &EventBus::itemUserDataUpdated,
this, &Item::updateUserData);
}
this->m_apiClient = apiClient;
if (apiClient != nullptr) {
QObject::connect(m_apiClient->eventbus(), &EventBus::itemUserDataUpdated,
this, &Item::updateUserData);
}
}
void Item::updateUserData(const QString &itemId, const DTO::UserItemDataDto &userData) {
if (itemId == this->jellyfinId()) {
emit userDataChanged(userData);
}
}
}
}