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 "qasobjectlist.h"
27 //------------------------------------------------------------------------------
29 QMap
<QString
, QASObjectList
*> QASObjectList::s_objectLists
;
30 void QASObjectList::clearCache() { deleteMap
<QASObjectList
*>(s_objectLists
); }
32 //------------------------------------------------------------------------------
34 QASObjectList::QASObjectList(QString url
, QObject
* parent
) :
35 QASAbstractObjectList(QAS_OBJECTLIST
, url
, parent
),
39 qDebug() << "new ObjectList" << m_url
;
43 //------------------------------------------------------------------------------
45 QASAbstractObject
* QASObjectList::getAbstractObject(QVariantMap json
,
47 if (json
["objectType"].toString() == "person")
48 return QASActor::getActor(json
, parent
);
49 return QASObject::getObject(json
, parent
);
53 //------------------------------------------------------------------------------
55 QASObjectList
* QASObjectList::initObjectList(QString url
, QObject
* parent
) {
56 if (s_objectLists
.contains(url
))
57 return s_objectLists
[url
];
59 QASObjectList
* ol
= new QASObjectList(url
, parent
);
60 s_objectLists
.insert(url
, ol
);
65 //------------------------------------------------------------------------------
67 QASObjectList
* QASObjectList::getObjectList(QVariantMap json
, QObject
* parent
,
69 QString url
= json
["url"].toString();
73 QASObjectList
* ol
= s_objectLists
.contains(url
) ? s_objectLists
[url
] :
74 new QASObjectList(url
, parent
);
76 s_objectLists
.insert(url
, ol
);
78 ol
->update(json
, id
& QAS_OLDER
);
82 //------------------------------------------------------------------------------
84 QASObjectList
* QASObjectList::getObjectList(QVariantList json
, QObject
* parent
,
87 jmap
["totalItems"] = json
.size();
90 return getObjectList(jmap
, parent
, id
);
93 //------------------------------------------------------------------------------
95 void QASObjectList::update(QVariantMap json
, bool older
, bool) {
96 // if (m_isReplies && json.contains("items")) {
97 // m_item_set.clear();
100 QASAbstractObjectList::update(json
, older
);
103 //------------------------------------------------------------------------------
105 RecipientList
QASObjectList::toRecipientList() const {
107 for (size_t i
=0; i
<size(); ++i
)
112 //------------------------------------------------------------------------------
114 bool QASObjectList::containsYou() const {
115 for (size_t i
=0; i
<size(); ++i
) {
116 QASActor
* actor
= at(i
)->asActor();
117 if (actor
&& actor
->isYou())