summaryrefslogtreecommitdiffstats
path: root/akregator/src/tagnode.h
blob: efe54ae9c079ee607db45286bc7b41e59ba5da00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
    /*
        This file is part of Akregator.
    
        Copyright (C) 2005 Frank Osterfeld <frank.osterfeld at kdemail.net>
    
        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.
    
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
        GNU General Public License for more details.
    
        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    
        As a special exception, permission is given to link this program
        with any edition of Qt, and distribute the resulting executable,
        without including the source code for Qt in the source distribution.
    */

#ifndef AKREGATOR_TAGNODE_H
#define AKREGATOR_TAGNODE_H

#include <treenode.h>

class TQDomDocument;
class TQDomElement;
class TQString;
class TQStringList;
template <class T> class TQValueList;

namespace Akregator 
{

class Article;
class Folder;
class FetchQueue;
class Tag;
class TreeNodeVisitor;

class TagNode : public TreeNode
{
Q_OBJECT

public:

    /** creates a tag node, showing articles with a specific tag, from a given node.
        @param tagId the identifier of the tag, as stored in the archive
        @param observed the tag node will list the tagged articles of @c observed (usually "All Feeds" root node)
     
    */
    TagNode(const Tag& tag, TreeNode* observed);
    
    virtual ~TagNode();

    virtual bool accept(TreeNodeVisitor* visitor);

    virtual Tag tag() const;

    virtual TQString icon() const;
    
    /** The unread count, returns the number of new/unread articles in the node (for groups: the accumulated count of the subtree)
    @return number of new/unread articles */

    virtual int unread() const;
    

    /** returns the number of total articles in the node (for groups: the accumulated count of the subtree)
    @return number of articles */
    
    virtual int totalCount() const;

    
    /** Returns a sequence of the articles this node contains. For feed groups, this returns a concatenated list of all articles in the sub tree.
    If @c tag is not null, only articles tagged with @c tag are returned
    @return sequence of articles */
    
    virtual TQValueList<Article> articles(const TQString& tag=TQString::null);

    /** returns a list of all tags occurring in this node (sub tree for folders) */

    virtual TQStringList tags() const;
    
    /** Helps the rest of the app to decide if node should be handled as group or not. Only use where necessary, use polymorphism where possible.
    @return whether the node is a feed group or not */
    
    virtual bool isGroup() const {return false;}

    /** reimplemented to return an invalid element */
    
    virtual TQDomElement toOPML( TQDomElement parent, TQDomDocument document ) const;
    
    /** returns the next node in the tree.
        Calling next() unless it returns 0 iterates through the tree in pre-order
     */ 
    virtual TreeNode* next(); 

    virtual void setTitle(const TQString& title);

    /** called by @c TagNodeList when the tag of this node was changed */    
    virtual void tagChanged();

public slots:
    

    /** does nothing for TagNode */  
    virtual void slotDeleteExpiredArticles();

    /** marks all articles as read */
    virtual void slotMarkAllArticlesAsRead();

    /** does nothing for TagNode */
    virtual void slotAddToFetchQueue(FetchQueue* queue, bool intervalFetchOnly=false);
    
    virtual void slotArticlesAdded(TreeNode* node, const TQValueList<Article>& list);
    virtual void slotArticlesUpdated(TreeNode* node, const TQValueList<Article>& list);
    virtual void slotArticlesRemoved(TreeNode* node, const TQValueList<Article>& list);
    virtual void slotObservedDestroyed(TreeNode* node);

protected:

    virtual void doArticleNotification();
    virtual void calcUnread();
    
private:
    class TagNodePrivate;
    TagNodePrivate* d;
};

}

#endif // AKREGATOR_TAGNODE_H