Show webfinger if displayName is unknown for an author.
[larjonas-pumpa.git] / src / qascollection.cpp
blob2e0812f8bf7453bbd98d696bb7dadc622d7919b0
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 "qascollection.h"
22 #include "util.h"
24 #include <QDebug>
26 //------------------------------------------------------------------------------
28 QMap<QString, QASCollection*> QASCollection::s_collections;
30 void QASCollection::clearCache() { deleteMap<QASCollection*>(s_collections); }
32 //------------------------------------------------------------------------------
34 QASCollection::QASCollection(QString url, QObject* parent) :
35 QASAbstractObjectList(QAS_COLLECTION, url, parent)
37 #ifdef DEBUG_QAS
38 qDebug() << "new Collection" << m_url;
39 #endif
42 //------------------------------------------------------------------------------
44 QASAbstractObject* QASCollection::getAbstractObject(QVariantMap json,
45 QObject* parent) {
46 return QASActivity::getActivity(json, parent);
49 //------------------------------------------------------------------------------
51 QASCollection* QASCollection::getCollection(QVariantMap json, QObject* parent,
52 int id) {
53 QString url = json["url"].toString();
54 if (url.isEmpty())
55 url = json["id"].toString();
56 // if (url.isEmpty())
57 // return NULL;
59 QASCollection* coll = s_collections.contains(url) ? s_collections[url] :
60 new QASCollection(url, parent);
61 s_collections.insert(url, coll);
63 coll->update(json, id & QAS_OLDER, id & QAS_UPDATE_ONLY);
64 return coll;
67 //------------------------------------------------------------------------------
69 QASCollection* QASCollection::initCollection(QString url, QObject* parent) {
70 if (s_collections.contains(url))
71 return s_collections[url];
73 QASCollection* coll = new QASCollection(url, parent);
74 s_collections.insert(url, coll);
76 return coll;