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 "contextwidget.h"
21 #include "pumpa_defines.h"
22 #include "activitywidget.h"
26 //------------------------------------------------------------------------------
28 ContextWidget::ContextWidget(QWidget
* parent
) :
34 //------------------------------------------------------------------------------
36 void ContextWidget::setObject(QASObject
* obj
) {
39 m_asMode
= QAS_OBJECT
;
42 connect(m_object
, SIGNAL(changed()), this, SLOT(update()),
43 Qt::UniqueConnection
);
45 ObjectWidget
* ow
= new ObjectWidget(m_object
, this);
46 ow
->disableLessButton();
47 ObjectWidgetWithSignals::connectSignals(ow
, this);
48 connect(ow
, SIGNAL(showContext(QASObject
*)),
49 this, SIGNAL(showContext(QASObject
*)));
51 m_itemLayout
->insertWidget(0, ow
);
52 m_itemLayout
->addStretch();
54 refreshObject(m_object
);
55 refreshObject(m_object
->replies());
61 //------------------------------------------------------------------------------
63 void ContextWidget::fetchNewer() {
65 emit
request(m_object
->urlOrProxy(), m_asMode
| QAS_NEWER
);
68 //------------------------------------------------------------------------------
70 bool ContextWidget::updateNumReplies() {
71 int oldNr
= m_numReplies
;
72 m_numReplies
= m_object
->replies() ? m_object
->replies()->size() : -1;
74 return oldNr
!= m_numReplies
;
78 //------------------------------------------------------------------------------
80 void ContextWidget::update() {
81 if (!isVisible() && updateNumReplies())