Show webfinger if displayName is unknown for an author.
[larjonas-pumpa.git] / src / objectwidgetwithsignals.cpp
blob54c17f30eda1f3f023c5514f333fd86096100186
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 #include "objectwidgetwithsignals.h"
22 #include <QDebug>
24 //------------------------------------------------------------------------------
26 ObjectWidgetWithSignals::ObjectWidgetWithSignals(QWidget* parent) :
27 QFrame(parent) {}
29 //------------------------------------------------------------------------------
31 void ObjectWidgetWithSignals::connectSignals(ObjectWidgetWithSignals* ow,
32 QWidget* w)
34 connect(ow, SIGNAL(linkHovered(const QString&)),
35 w, SIGNAL(linkHovered(const QString&)));
36 connect(ow, SIGNAL(like(QASObject*)),
37 w, SIGNAL(like(QASObject*)));
38 connect(ow, SIGNAL(share(QASObject*)),
39 w, SIGNAL(share(QASObject*)));
40 connect(ow, SIGNAL(newReply(QASObject*, QASObjectList*, QASObjectList*)),
41 w, SIGNAL(newReply(QASObject*, QASObjectList*, QASObjectList*)));
42 connect(ow, SIGNAL(follow(QString, bool)),
43 w, SIGNAL(follow(QString, bool)));
44 connect(ow, SIGNAL(deleteObject(QASObject*)),
45 w, SIGNAL(deleteObject(QASObject*)));
46 connect(ow, SIGNAL(editObject(QASObject*)),
47 w, SIGNAL(editObject(QASObject*)));
48 connect(ow, SIGNAL(request(QString, int)),
49 w, SIGNAL(request(QString, int)));
52 //------------------------------------------------------------------------------
54 void ObjectWidgetWithSignals::disconnectSignals(ObjectWidgetWithSignals* ow,
55 QWidget* w)
57 disconnect(ow, SIGNAL(linkHovered(const QString&)),
58 w, SIGNAL(linkHovered(const QString&)));
59 disconnect(ow, SIGNAL(like(QASObject*)),
60 w, SIGNAL(like(QASObject*)));
61 disconnect(ow, SIGNAL(share(QASObject*)),
62 w, SIGNAL(share(QASObject*)));
63 disconnect(ow, SIGNAL(newReply(QASObject*, QASObjectList*, QASObjectList*)),
64 w, SIGNAL(newReply(QASObject*, QASObjectList*, QASObjectList*)));
65 disconnect(ow, SIGNAL(follow(QString, bool)),
66 w, SIGNAL(follow(QString, bool)));
67 disconnect(ow, SIGNAL(deleteObject(QASObject*)),
68 w, SIGNAL(deleteObject(QASObject*)));
69 disconnect(ow, SIGNAL(editObject(QASObject*)),
70 w, SIGNAL(editObject(QASObject*)));
71 disconnect(ow, SIGNAL(request(QString, int)),
72 w, SIGNAL(request(QString, int)));
75 //------------------------------------------------------------------------------
77 void ObjectWidgetWithSignals::refreshObject(QASAbstractObject* obj) {
78 if (!obj)
79 return;
81 QDateTime now = QDateTime::currentDateTime();
82 QDateTime lr = obj->lastRefreshed();
84 if (lr.isNull() || lr.secsTo(now) > 10) {
85 obj->lastRefreshed(now);
86 emit request(obj->apiLink(), obj->asType());