25 #include "akregatorconfig.h"
28 #include "treenodeitem.h"
29 #include "folderitem.h"
32 #include <tqpainter.h>
35 #include <kstringhandler.h>
41 TreeNodeItem::TreeNodeItem(FolderItem* parent, TreeNode* node)
42 : TDEListViewItem(parent), m_node(node)
47 TreeNodeItem::TreeNodeItem(TDEListView* parent, TreeNode* node)
48 : TDEListViewItem(parent), m_node(node)
53 TreeNodeItem::TreeNodeItem(TDEListView* parent, TreeNodeItem* after, TreeNode* node) : TDEListViewItem(parent, after), m_node(node)
58 TreeNodeItem::TreeNodeItem(FolderItem* parent, TreeNodeItem* after, TreeNode* node)
59 : TDEListViewItem(parent, after), m_node(node)
64 void TreeNodeItem::initialize(TreeNode* node)
66 setRenameEnabled(0,
true);
68 setText(0, node->title() );
71 TreeNodeItem::~TreeNodeItem()
74 TQString TreeNodeItem::toolTip()
const
79 TreeNode* TreeNodeItem::node()
84 void TreeNodeItem::nodeChanged()
89 if (text(0) != node()->title())
90 setText(0, node()->title());
94 TreeNodeItem* TreeNodeItem::firstChild()
const
96 return static_cast<TreeNodeItem*
>(TDEListViewItem::firstChild());
99 TreeNodeItem* TreeNodeItem::nextSibling()
const
101 return static_cast<TreeNodeItem*
>(TDEListViewItem::nextSibling());
104 FolderItem* TreeNodeItem::parent()
const
106 return static_cast<FolderItem*
>(TDEListViewItem::parent());
111 void TreeNodeItem::paintCell( TQPainter * p,
const TQColorGroup & cg,
112 int column,
int width,
int align )
115 int u = node() ? node()->unread() : 0;
119 TDEListViewItem::paintCell(p,cg,column,width,align);
124 TQString oldText = text(column);
125 setText( column,
" " );
128 TDEListViewItem::paintCell(p,cg,column,width,align);
130 setText( column, oldText);
133 TQFont f = p->font();
134 f.setWeight(TQFont::Bold);
137 TQFontMetrics fm( p->fontMetrics() );
138 TQListView *lv = listView();
139 int x = lv ? lv->itemMargin() : 1;
141 const TQPixmap *icon = pixmap( column );
145 x += icon->width() + m;
147 TQString txt =
" (" + TQString::number(u) +
")";
148 int txtW=fm.width( txt );
150 if (fm.width( oldText ) + txtW + x > width)
151 oldText=KStringHandler::rPixelSqueeze(oldText,fm, width - txtW - x);
153 p->drawText( x, 0, width-m-x, height(), align | AlignVCenter, oldText, -1, &br );
156 p->setPen( Settings::unreadTextColor() );
158 p->drawText( br.right(), 0, width-m-br.right(), height(),
159 align | AlignVCenter, txt );