No longer honours following status in JSON, instead relies solely on following list.
[larjonas-pumpa.git] / src / aswidget.h
blob8f3c3e42a605cf4d05aed09d8a070d97ce348e0e
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 WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 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 _ASWIDGET_H_
21 #define _ASWIDGET_H_
23 #include "qactivitystreams.h"
24 #include "objectwidgetwithsignals.h"
26 #include <QWidget>
27 #include <QScrollArea>
28 #include <QVBoxLayout>
30 //------------------------------------------------------------------------------
32 class ASWidget : public QScrollArea {
33 Q_OBJECT
35 public:
36 ASWidget(QWidget* parent, int widgetLimit=-1, int purgeWait=10);
37 virtual void refreshTimeLabels();
38 virtual void fetchNewer();
39 virtual void fetchOlder(int count=-1);
40 void refresh();
41 void setEndpoint(QString endpoint, QObject* parent, int asMode=-1);
42 QString url() const { return m_list->url(); }
44 int count() const { return m_object_set.size(); }
45 const QList<QASAbstractObject*>& newObjects() { return m_newObjects; }
46 virtual bool hasObject(QASAbstractObject* obj) {
47 return m_object_set.contains(obj);
50 bool linksInitialised() const { return !m_list->firstTime(); }
52 signals:
53 void highlightMe();
54 void hasNewObjects();
55 void request(QString, int);
56 void newReply(QASObject*, QASObjectList*, QASObjectList*);
57 void linkHovered(const QString&);
58 void like(QASObject*);
59 void share(QASObject*);
60 void showContext(QASObject*);
61 void follow(QString, bool);
62 void deleteObject(QASObject*);
63 void editObject(QASObject*);
65 protected slots:
66 virtual void update();
68 protected:
69 virtual QASAbstractObjectList* initList(QString endpoint, QObject* parent);
71 QASAbstractObject* objectAt(int idx);
72 ObjectWidgetWithSignals* widgetAt(int idx);
73 virtual ObjectWidgetWithSignals* createWidget(QASAbstractObject*);
74 virtual void changeWidgetObject(ObjectWidgetWithSignals*, QASAbstractObject*);
75 virtual bool countAsNew(QASAbstractObject*) { return true; }
77 void keyPressEvent(QKeyEvent* event);
78 virtual void clear();
80 void refreshObject(QASAbstractObject* obj);
82 QVBoxLayout* m_itemLayout;
83 QWidget* m_listContainer;
84 bool m_firstTime;
86 QSet<QASAbstractObject*> m_object_set;
87 QASAbstractObjectList* m_list;
89 int m_asMode;
91 bool m_reuseWidgets;
92 int m_purgeWait;
93 int m_purgeCounter;
94 int m_widgetLimit;
96 QList<QASAbstractObject*> m_newObjects;
99 #endif /* _ASWIDGET_H_ */