summaryrefslogtreecommitdiffstats
path: root/akregator/src/feedlistview.h
blob: 8d4394e10828855bbe8394a0888b030544309579 (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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
    This file is part of Akregator.

    Copyright (C) 2004 Stanislav Karchebny <Stanislav.Karchebny@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 TQt, and distribute the resulting executable,
    without including the source code for TQt in the source distribution.
*/
#ifndef AKREGATORFEEDLISTVIEW_H
#define AKREGATORFEEDLISTVIEW_H

#include <klistview.h>
#include <kurl.h>

namespace Akregator
{
class Feed;
class Folder;
class NodeList;
class TreeNode;
class TreeNodeItem;
class TagNodeList;

class NodeListView : public KListView
{
Q_OBJECT
  TQ_OBJECT
public:
    NodeListView( TQWidget *parent = 0, const char *name = 0 );
    virtual ~NodeListView();
    
    /** sets the feed list to show. Disconnects from the old feed list, if there is any. */
    void setNodeList(NodeList* nodeList);

    /** Returns root node ("All Feeds").
        * @return root node
        */
    Folder* rootNode();
    
    /** Returns the currently selected node, @c null when no one is selected.
        @return selected node
        */
    TreeNode* selectedNode();

    /** selects @c node, if it exists
        * @param node the node to select
        */
    void setSelectedNode(TreeNode* node);

    /** Find first node with title @c title
        returns 0 if no node was found
    @param title
    @return node
        */ 
    TreeNode* findNodeByTitle(const TQString& title);

    /** ensures that @c node is visible. */
    void ensureNodeVisible(TreeNode* node);

    /** activates in-place renaming for the item of @c node */
    void startNodeRenaming(TreeNode* node);
    
    
    /** reimplemented: clears the view and creates the root node ("All Feeds") */
    virtual void clear();

    /** if enabled, the view shows tag folders */
    void setShowTagFolders(bool enabled);

public slots:
    
    /** go one item up */
    void slotItemUp();
    /** go one item down */
    void slotItemDown();
    /** select the first item in the list */
    void slotItemBegin();
    /** select last item in the list */
    void slotItemEnd();
    /** go to parent item */
    void slotItemLeft();
    /** go to first child */
    void slotItemRight();

    void slotPrevFeed();
    void slotNextFeed();
    void slotPrevUnreadFeed();
    void slotNextUnreadFeed();
    
signals:
    void signalDropped (KURL::List &, TreeNode*, Folder*);
    void signalNodeSelected(TreeNode*);
    void signalRootNodeChanged(NodeListView*, TreeNode*);
    void signalContextMenu(KListView*, TreeNode*, const TQPoint&);

public:         // compat with KDE-3.x assertions, remove for KDE 4
// protected:

    /** Find item belonging to tree node @c node, @c null when node is not in tree
    @return item representing node
    @param node a tree node */

    TreeNodeItem* findNodeItem(TreeNode* node);

    /** reimplemented to return TreeNodeItem* */
    virtual TreeNodeItem* findItemByTitle(const TQString& text, int column, ComparisonFlags compare = ExactMatch | CaseSensitive ) const;

    /** observe @c node: connect status change signals of @c node to slots */
    virtual void connectToNode(TreeNode* node);

    /** stop observing @c node: disconnect from status change signals of @c node */
    virtual void disconnectFromNode(TreeNode* node);

    virtual void connectToNodeList(NodeList* list);
    virtual void disconnectFromNodeList(NodeList* list);
    
    virtual void drawContentsOffset( TQPainter * p, int ox, int oy,
                                        int cx, int cy, int cw, int ch );
    virtual void contentsDragMoveEvent(TQDragMoveEvent* event);
    virtual bool acceptDrag(TQDropEvent *event) const;
    virtual void movableDropEvent(TQListViewItem* parent, TQListViewItem* afterme);

    virtual TQDragObject *dragObject();
            

protected slots:
    

    void slotDropped(TQDropEvent *e, TQListViewItem* after);
    void slotRootNodeChanged(TreeNode*);
    virtual void slotSelectionChanged(TQListViewItem* item);
    virtual void slotContextMenu(KListView* list, TQListViewItem* item, const TQPoint& p);
    virtual void slotItemRenamed(TQListViewItem* item, int col, const TQString& text);
    virtual void slotFeedFetchStarted(Feed* feed);
    virtual void slotFeedFetchAborted(Feed* feed);
    virtual void slotFeedFetchError(Feed* feed);
    virtual void slotFeedFetchCompleted(Feed* feed);
    void openFolder();

    /** called when a node is added to the tree. If no item for the node exists, it will be created */
    virtual void slotNodeAdded(TreeNode* node);
    
    /** Called when a node in the tree is taken out of the tree (parent->removeChild()) 
    
    Removes a node and its children from the tree. Note that it doesn't delete the corresponding view items (get deleted only when the node itself gets deleted) */
    virtual void slotNodeRemoved(Folder* parent, TreeNode* node);
    
    /** deletes the item belonging to the deleted node */
    virtual void slotNodeDestroyed(TreeNode* node);
    
    /** update the item belonging to the node */
    virtual void slotNodeChanged(TreeNode* node);

    virtual void slotNodeListDestroyed(NodeList*);

public:         // compat with KDE-3.x assertions, remove for KDE 4
// private:
    friend class ConnectNodeVisitor;
    class ConnectNodeVisitor;
    
    friend class DisconnectNodeVisitor;
    class DisconnectNodeVisitor;

    friend class CreateItemVisitor;
    class CreateItemVisitor;

    friend class DeleteItemVisitor;
    class DeleteItemVisitor;
    
    friend class DragAndDropVisitor;
    class DragAndDropVisitor;

    class NodeListViewPrivate;
    NodeListViewPrivate* d;
};


class TagNodeListView : public NodeListView
{
    Q_OBJECT
  TQ_OBJECT
    public:
        TagNodeListView(TQWidget *parent = 0, const char *name = 0) {} 
        virtual ~TagNodeListView() {}

    private:
        class TagNodeListViewPrivate;
        TagNodeListViewPrivate* d;
};

} // namespace Akregator

#endif