No longer honours following status in JSON, instead relies solely on following list.
[larjonas-pumpa.git] / src / qasabstractobject.h
blob816c71429ee73d2bd1cc9bbebd8444f4614432a1
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 #ifndef _QASABSTRACTOBJECT_H_
21 #define _QASABSTRACTOBJECT_H_
23 #include <QObject>
24 #include <QDateTime>
25 #include <QVariantMap>
27 #include "pumpa_defines.h"
28 #include "json.h"
30 //------------------------------------------------------------------------------
32 class QASAbstractObject : public QObject {
33 Q_OBJECT
35 public:
36 // virtual void refresh();
37 virtual QString apiLink() const { return ""; }
38 int asType() const { return m_asType; }
39 virtual bool isDeleted() const { return false; }
41 QDateTime lastRefreshed() const { return m_lastRefreshed; }
42 void lastRefreshed(QDateTime dt) { m_lastRefreshed = dt; }
44 QVariantMap json() const { return m_json; }
46 signals:
47 void changed();
48 // void request(QString, int);
50 protected:
51 QASAbstractObject(int asType, QObject* parent);
52 virtual void connectSignals(QASAbstractObject* obj,
53 bool changed=true, bool req=true);
55 static qint64 sortIntByDateTime(QDateTime dt);
57 public:
58 static void updateVar(QVariantMap, QString&, QString, bool&);
59 static void updateVar(QVariantMap, bool&, QString, bool&);
60 static void updateVar(QVariantMap, double&, QString, bool&);
61 static void updateVar(QVariantMap, qulonglong&, QString, bool&,
62 bool ignoreDecrease=false);
63 static void updateVar(QVariantMap, QDateTime&, QString, bool&);
64 static void updateVar(QVariantMap, QString&, QString, QString, bool&);
65 static void updateVar(QVariantMap, bool&, QString, QString, bool&);
66 static void updateVar(QVariantMap, double&, QString, QString, bool&);
67 static void updateVar(QVariantMap, QString&, QString, QString, QString,
68 bool&);
69 static void addVar(QVariantMap&, QString, QString);
70 static void updateUrlOrProxy(QVariantMap, QString&, bool&);
72 protected:
73 QDateTime m_lastRefreshed;
74 int m_asType;
75 QVariantMap m_json;
78 #endif /* _QASABSTRACTOBJECT_H_ */