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"
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
)
38 qDebug() << "new Collection" << m_url
;
42 //------------------------------------------------------------------------------
44 QASAbstractObject
* QASCollection::getAbstractObject(QVariantMap json
,
46 return QASActivity::getActivity(json
, parent
);
49 //------------------------------------------------------------------------------
51 QASCollection
* QASCollection::getCollection(QVariantMap json
, QObject
* parent
,
53 QString url
= json
["url"].toString();
55 url
= json
["id"].toString();
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
);
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
);