akregator/src

folderitem.cpp
1 /*
2  This file is part of Akregator.
3 
4  Copyright (C) 2004 Frank Osterfeld <frank.osterfeld at kdemail.net>
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 TQt, and distribute the resulting executable,
22  without including the source code for TQt in the source distribution.
23 */
24 
25 #include "actionmanager.h"
26 #include "folder.h"
27 #include "folderitem.h"
28 #include "treenode.h"
29 
30 #include <tqpopupmenu.h>
31 #include <tdeaction.h>
32 #include <kiconloader.h>
33 
34 namespace Akregator {
35 
36 FolderItem::FolderItem(FolderItem* parent, Folder* node) : TreeNodeItem(parent, node)
37 {
38  initialize(node);
39 }
40 
41 FolderItem::FolderItem(FolderItem* parent, TreeNodeItem* after, Folder* node) : TreeNodeItem(parent, after, node)
42 {
43  initialize(node);
44 }
45 
46 FolderItem::FolderItem(TDEListView* parent, Folder* node) : TreeNodeItem(parent, node)
47 {
48  initialize(node);
49 }
50 
51 FolderItem::FolderItem(TDEListView* parent, TreeNodeItem* after, Folder* node) : TreeNodeItem(parent, after, node)
52 {
53  initialize(node);
54 }
55 
56 void FolderItem::initialize(Folder* node)
57 {
58  setOpen(node->isOpen());
59  setPixmap ( 0, TDEGlobal::iconLoader()->loadIcon("folder", TDEIcon::Small) );
60  if (node)
61  setText(0, node->title());
62 }
63 
64 Folder* FolderItem::node()
65 {
66  return static_cast<Folder*> (m_node);
67 }
68 
69 void FolderItem::setOpen(bool open)
70 {
71  node()->setOpen(open);
72  TDEListViewItem::setOpen(open);
73 }
74 
75 FolderItem::~FolderItem()
76 {}
77 
78 
79 void FolderItem::showContextMenu(const TQPoint& p)
80 {
81  TQWidget* w = ActionManager::getInstance()->container("feedgroup_popup");
82  if (w)
83  static_cast<TQPopupMenu *>(w)->exec(p);
84 }
85 
86 } // namespace Akregator