Warning, file /utilities/telly-skout/src/group.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // SPDX-FileCopyrightText: 2022 Plata Hill <plata.hill@kdemail.net> 0002 // SPDX-License-Identifier: LGPL-2.1-or-later 0003 0004 #include "group.h" 0005 0006 #include "channelsmodel.h" 0007 #include "fetcher.h" 0008 0009 #include <QDebug> 0010 0011 Group::Group(const GroupData &data) 0012 : QObject(nullptr) 0013 , m_data(data) 0014 { 0015 connect(&Fetcher::instance(), &Fetcher::startedFetchingGroup, this, [this](const GroupId &id) { 0016 if (id == m_data.m_id) { 0017 setRefreshing(true); 0018 } 0019 }); 0020 connect(&Fetcher::instance(), &Fetcher::groupUpdated, this, [this](const GroupId &id) { 0021 if (id == m_data.m_id) { 0022 setRefreshing(false); 0023 } 0024 }); 0025 connect(&Fetcher::instance(), &Fetcher::errorFetchingGroup, this, [this](const GroupId &id, const Error &error) { 0026 if (id == m_data.m_id) { 0027 setError(error); 0028 setRefreshing(false); 0029 } 0030 }); 0031 0032 m_channels = new ChannelsModel(this); 0033 } 0034 0035 Group::~Group() 0036 { 0037 } 0038 0039 QString Group::id() const 0040 { 0041 return m_data.m_id.value(); 0042 } 0043 0044 QString Group::name() const 0045 { 0046 return m_data.m_name; 0047 } 0048 0049 QString Group::url() const 0050 { 0051 return m_data.m_url; 0052 } 0053 0054 bool Group::refreshing() const 0055 { 0056 return m_refreshing; 0057 } 0058 0059 int Group::errorId() const 0060 { 0061 return m_error.m_id; 0062 } 0063 0064 QString Group::errorString() const 0065 { 0066 return m_error.m_message; 0067 } 0068 0069 void Group::setName(const QString &name) 0070 { 0071 m_data.m_name = name; 0072 Q_EMIT nameChanged(m_data.m_name); 0073 } 0074 0075 void Group::setRefreshing(bool refreshing) 0076 { 0077 m_refreshing = refreshing; 0078 Q_EMIT refreshingChanged(m_refreshing); 0079 } 0080 0081 void Group::setError(const Error &error) 0082 { 0083 m_error = error; 0084 Q_EMIT errorIdChanged(m_error.m_id); 0085 Q_EMIT errorStringChanged(m_error.m_message); 0086 }