• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

akregator

  • sources
  • kde-4.12
  • kdepim
  • akregator
  • src
treenode.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Akregator.
3 
4  Copyright (C) 2004 Frank Osterfeld <osterfeld@kde.org>
5 
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.
10 
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.
15 
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.
19 
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.
23 */
24 
25 #include "treenode.h"
26 #include "folder.h"
27 #include "articlejobs.h"
28 #include "article.h"
29 
30 #include <QPoint>
31 #include <QString>
32 #include <QList>
33 
34 #include <kdebug.h>
35 
36 #include <cassert>
37 
38 namespace Akregator {
39 
40 class TreeNode::TreeNodePrivate
41 {
42  public:
43  TreeNodePrivate();
44  bool doNotify;
45  bool nodeChangeOccurred;
46  bool articleChangeOccurred;
47  QString title;
48  Folder* parent;
49  uint id;
50  bool signalDestroyedEmitted;
51  QPoint scrollBarPositions;
52 };
53 
54 TreeNode::TreeNodePrivate::TreeNodePrivate() : doNotify( true ),
55  nodeChangeOccurred( false ),
56  articleChangeOccurred( false ),
57  title(),
58  parent( 0 ),
59  id ( 0 ),
60  signalDestroyedEmitted( false )
61 {
62 }
63 
64 TreeNode::TreeNode()
65  : QObject(0), d(new TreeNodePrivate)
66 {
67 }
68 
69 void TreeNode::emitSignalDestroyed()
70 {
71  if (!d->signalDestroyedEmitted)
72  {
73  if ( parent() )
74  parent()->removeChild( this );
75  emit signalDestroyed(this);
76  d->signalDestroyedEmitted = true;
77  }
78 }
79 
80 TreeNode::~TreeNode()
81 {
82  assert( d->signalDestroyedEmitted || !"TreeNode subclasses must call emitSignalDestroyed in their destructor" );
83  delete d;
84  d = 0;
85 }
86 
87 QString TreeNode::title() const
88 {
89  return d->title;
90 }
91 
92 void TreeNode::setTitle(const QString& title)
93 {
94 
95  if (d->title != title)
96  {
97  d->title = title;
98  nodeModified();
99  }
100 }
101 
102 TreeNode* TreeNode::nextSibling()
103 {
104  if (!d->parent)
105  return 0;
106  const QList<TreeNode*> children = parent()->children();
107  const int idx = children.indexOf( this );
108 
109  return (idx+1 < children.size()) ? children.at(idx+1) : 0L;
110 }
111 
112 const TreeNode* TreeNode::nextSibling() const
113 {
114  if (!d->parent)
115  return 0;
116  const QList<const TreeNode*> children = parent()->children();
117  const int idx = children.indexOf( this );
118 
119  return (idx+1 < children.size()) ? children.at(idx+1) : 0L;
120 }
121 
122 TreeNode* TreeNode::prevSibling()
123 {
124  if (!d->parent)
125  return 0;
126  const QList<TreeNode*> children = parent()->children();
127 
128  const int idx = children.indexOf( this );
129  return (idx > 0) ? children.at(idx-1) : 0L;
130 }
131 
132 const TreeNode* TreeNode::prevSibling() const
133 {
134  if (!d->parent)
135  return 0;
136  const QList<const TreeNode*> children = parent()->children();
137  const int idx = children.indexOf( this );
138  return (idx > 0) ? children.at(idx-1) : 0L;
139 }
140 
141 const Folder* TreeNode::parent() const
142 {
143  return d->parent;
144 }
145 
146 Folder* TreeNode::parent()
147 {
148  return d->parent;
149 }
150 
151 QList<const TreeNode*> TreeNode::children() const
152 {
153  return QList<const TreeNode*>();
154 }
155 
156 QList<TreeNode*> TreeNode::children()
157 {
158  return QList<TreeNode*>();
159 }
160 
161 const TreeNode* TreeNode::childAt( int pos ) const
162 {
163  Q_UNUSED( pos )
164  return 0;
165 }
166 
167 TreeNode* TreeNode::childAt( int pos )
168 {
169  Q_UNUSED( pos )
170  return 0;
171 }
172 
173 void TreeNode::setParent(Folder* parent)
174 {
175  d->parent = parent;
176 }
177 
178 void TreeNode::setNotificationMode( bool doNotify )
179 {
180  if ( doNotify && !d->doNotify ) // turned on
181  {
182  d->doNotify = true;
183  if ( d->nodeChangeOccurred )
184  emit signalChanged( this );
185  if ( d->articleChangeOccurred )
186  doArticleNotification();
187  d->nodeChangeOccurred = false;
188  d->articleChangeOccurred = false;
189  }
190  else if ( !doNotify && d->doNotify ) //turned off
191  {
192  d->nodeChangeOccurred = false;
193  d->articleChangeOccurred = false;
194  d->doNotify = false;
195  }
196 }
197 
198 uint TreeNode::id() const
199 {
200  return d->id;
201 }
202 
203 void TreeNode::setId(uint id)
204 {
205  d->id = id;
206 }
207 
208 void TreeNode::nodeModified()
209 {
210  if (d->doNotify)
211  emit signalChanged(this);
212  else
213  d->nodeChangeOccurred = true;
214 }
215 
216 void TreeNode::articlesModified()
217 {
218  if (d->doNotify)
219  doArticleNotification();
220  else
221  d->articleChangeOccurred = true;
222 }
223 
224 void TreeNode::doArticleNotification()
225 {
226 }
227 
228 QPoint TreeNode::listViewScrollBarPositions() const
229 {
230  return d->scrollBarPositions;
231 }
232 
233 void TreeNode::setListViewScrollBarPositions( const QPoint& pos )
234 {
235  d->scrollBarPositions = pos;
236 }
237 
238 ArticleListJob* TreeNode::createListJob() {
239  return new ArticleListJob( this );
240 }
241 
242 } // namespace Akregator
243 
244 #include "treenode.moc"
treenode.h
Akregator::TreeNode::childAt
virtual TreeNode * childAt(int pos)
Definition: treenode.cpp:167
Akregator::TreeNode::children
virtual QList< const TreeNode * > children() const
returns the (direct) children of this node.
Definition: treenode.cpp:151
Akregator::TreeNode::title
QString title() const
Get title of node.
Definition: treenode.cpp:87
articlejobs.h
uint
unsigned int uint
Definition: article.h:39
Akregator::TreeNode::createListJob
ArticleListJob * createListJob()
Definition: treenode.cpp:238
Akregator::TreeNode::setId
virtual void setId(uint id)
sets the ID
Definition: treenode.cpp:203
Akregator::Folder::removeChild
void removeChild(TreeNode *node)
remove node from children.
Definition: folder.cpp:249
QObject
Akregator::TreeNode::TreeNode
TreeNode()
Standard constructor.
Definition: treenode.cpp:64
Akregator::TreeNode::signalDestroyed
void signalDestroyed(Akregator::TreeNode *)
Emitted when this object is deleted.
Akregator::TreeNode::parent
virtual const Folder * parent() const
Returns the parent node.
Definition: treenode.cpp:141
Akregator::TreeNode::~TreeNode
virtual ~TreeNode()
Standard destructor.
Definition: treenode.cpp:80
Akregator::TreeNode::nodeModified
virtual void nodeModified()
call this if you modified the actual node (title, unread count).
Definition: treenode.cpp:208
Akregator::ArticleListJob
Definition: articlejobs.h:108
Akregator::TreeNode::setTitle
void setTitle(const QString &title)
Sets the title of the node.
Definition: treenode.cpp:92
Akregator::Folder::children
QList< const TreeNode * > children() const
returns the (direct) children of this node.
Definition: folder.cpp:124
article.h
Akregator::TreeNode::setParent
virtual void setParent(Folder *parent)
Sets parent node; Don't call this directly, is done automatically by insertChild-methods in Folder...
Definition: treenode.cpp:173
folder.h
Akregator::TreeNode::signalChanged
void signalChanged(Akregator::TreeNode *)
Notification mechanism: emitted, when the node was modified and notification is enabled.
Akregator::TreeNode::doArticleNotification
virtual void doArticleNotification()
reimplement this in subclasses to do the actual notification called by articlesModified ...
Definition: treenode.cpp:224
Akregator::TreeNode::listViewScrollBarPositions
QPoint listViewScrollBarPositions() const
Definition: treenode.cpp:228
Akregator::TreeNode::emitSignalDestroyed
void emitSignalDestroyed()
Definition: treenode.cpp:69
Akregator::TreeNode::nextSibling
virtual const TreeNode * nextSibling() const
Get the next sibling.
Definition: treenode.cpp:112
Akregator::Folder
Represents a folder (containing feeds and/or other folders)
Definition: folder.h:44
Akregator::TreeNode::prevSibling
virtual const TreeNode * prevSibling() const
Get the previous sibling.
Definition: treenode.cpp:132
Akregator::TreeNode::articlesModified
virtual void articlesModified()
call this if the articles in the node were changed.
Definition: treenode.cpp:216
Akregator::TreeNode::setListViewScrollBarPositions
void setListViewScrollBarPositions(const QPoint &pos)
Definition: treenode.cpp:233
Akregator::TreeNode
Abstract base class for all kind of elements in the feed tree, like feeds and feed groups (and search...
Definition: treenode.h:59
Akregator::TreeNode::id
virtual uint id() const
returns the ID of this node.
Definition: treenode.cpp:198
Akregator::TreeNode::setNotificationMode
virtual void setNotificationMode(bool doNotify)
Definition: treenode.cpp:178
QList
Definition: article.h:39
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:14 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akregator

Skip menu "akregator"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal