No longer honours following status in JSON, instead relies solely on following list.
[larjonas-pumpa.git] / src / qasactorlist.cpp
blobd1efe24972ac7943b787d4c622261c843529c652
1 /*
2 Copyright 2013-2015 Mats Sjöberg
4 This file is part of the Pumpa programme.
6 Pumpa is free software: you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 Pumpa is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Pumpa. If not, see <http://www.gnu.org/licenses/>.
20 #include "qasactorlist.h"
22 #include "util.h"
24 #include <QDebug>
26 //------------------------------------------------------------------------------
28 QMap<QString, QASActorList*> QASActorList::s_actorLists;
29 void QASActorList::clearCache() { deleteMap<QASActorList*>(s_actorLists); }
31 //------------------------------------------------------------------------------
33 QASActorList::QASActorList(QString url, QObject* parent) :
34 QASObjectList(url, parent)
36 m_asType = QAS_OBJECTLIST;
37 #ifdef DEBUG_QAS
38 qDebug() << "new ActorList" << m_url;
39 #endif
42 //------------------------------------------------------------------------------
44 QASActorList* QASActorList::getActorList(QVariantMap json, QObject* parent,
45 int id) {
46 QString url = json["url"].toString();
47 if (url.isEmpty())
48 return NULL;
50 QASActorList* ol = s_actorLists.contains(url) ? s_actorLists[url] :
51 new QASActorList(url, parent);
52 s_actorLists.insert(url, ol);
54 ol->update(json, id & QAS_OLDER);
55 return ol;
58 //------------------------------------------------------------------------------
60 QASActor* QASActorList::at(size_t i) const {
61 if (i >= size())
62 return NULL;
63 return QASObjectList::at(i)->asActor();
66 //------------------------------------------------------------------------------
68 QString QASActorList::actorNames() const {
69 QString text;
70 for (size_t i=0; i<size(); i++) {
71 QASActor* a = at(i);
72 text += QString("<a href=\"%1\">%2</a>")
73 .arg(a->url())
74 .arg(a->displayNameOrYou());
75 if (i != size()-1)
76 text += ", ";
78 return text;