2 This file is part of Akregator.
4 Copyright (C) 2004 Frank Osterfeld <osterfeld@kde.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution.
27 #include "articlejobs.h"
34 #include "akregator_debug.h"
41 class TreeNode::TreeNodePrivate
46 bool nodeChangeOccurred
;
47 bool articleChangeOccurred
;
51 bool signalDestroyedEmitted
;
52 QPoint scrollBarPositions
;
55 TreeNode::TreeNodePrivate::TreeNodePrivate() : doNotify(true),
56 nodeChangeOccurred(false),
57 articleChangeOccurred(false),
61 signalDestroyedEmitted(false)
66 : QObject(0), d(new TreeNodePrivate
)
70 void TreeNode::emitSignalDestroyed()
72 if (!d
->signalDestroyedEmitted
) {
74 parent()->removeChild(this);
76 Q_EMIT
signalDestroyed(this);
77 d
->signalDestroyedEmitted
= true;
83 Q_ASSERT(d
->signalDestroyedEmitted
|| !"TreeNode subclasses must call emitSignalDestroyed in their destructor");
88 QString
TreeNode::title() const
93 void TreeNode::setTitle(const QString
&title
)
96 if (d
->title
!= title
) {
102 TreeNode
*TreeNode::nextSibling()
107 const QList
<TreeNode
*> children
= parent()->children();
108 const int idx
= children
.indexOf(this);
110 return (idx
+ 1 < children
.size()) ? children
.at(idx
+ 1) : Q_NULLPTR
;
113 const TreeNode
*TreeNode::nextSibling() const
118 const QList
<const TreeNode
*> children
= parent()->children();
119 const int idx
= children
.indexOf(this);
121 return (idx
+ 1 < children
.size()) ? children
.at(idx
+ 1) : Q_NULLPTR
;
124 TreeNode
*TreeNode::prevSibling()
129 const QList
<TreeNode
*> children
= parent()->children();
131 const int idx
= children
.indexOf(this);
132 return (idx
> 0) ? children
.at(idx
- 1) : Q_NULLPTR
;
135 const TreeNode
*TreeNode::prevSibling() const
140 const QList
<const TreeNode
*> children
= parent()->children();
141 const int idx
= children
.indexOf(this);
142 return (idx
> 0) ? children
.at(idx
- 1) : Q_NULLPTR
;
145 const Folder
*TreeNode::parent() const
150 Folder
*TreeNode::parent()
155 QList
<const TreeNode
*> TreeNode::children() const
157 return QList
<const TreeNode
*>();
160 QList
<TreeNode
*> TreeNode::children()
162 return QList
<TreeNode
*>();
165 const TreeNode
*TreeNode::childAt(int pos
) const
171 TreeNode
*TreeNode::childAt(int pos
)
177 void TreeNode::setParent(Folder
*parent
)
182 void TreeNode::setNotificationMode(bool doNotify
)
184 if (doNotify
&& !d
->doNotify
) { // turned on
186 if (d
->nodeChangeOccurred
) {
187 Q_EMIT
signalChanged(this);
189 if (d
->articleChangeOccurred
) {
190 doArticleNotification();
192 d
->nodeChangeOccurred
= false;
193 d
->articleChangeOccurred
= false;
194 } else if (!doNotify
&& d
->doNotify
) { //turned off
195 d
->nodeChangeOccurred
= false;
196 d
->articleChangeOccurred
= false;
201 uint
TreeNode::id() const
206 void TreeNode::setId(uint id
)
211 void TreeNode::nodeModified()
214 Q_EMIT
signalChanged(this);
216 d
->nodeChangeOccurred
= true;
220 void TreeNode::articlesModified()
223 doArticleNotification();
225 d
->articleChangeOccurred
= true;
229 void TreeNode::doArticleNotification()
233 QPoint
TreeNode::listViewScrollBarPositions() const
235 return d
->scrollBarPositions
;
238 void TreeNode::setListViewScrollBarPositions(const QPoint
&pos
)
240 d
->scrollBarPositions
= pos
;
243 ArticleListJob
*TreeNode::createListJob()
245 return new ArticleListJob(this);
248 } // namespace Akregator