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
|
/***************************************************************************
sq_treeviewitem.cpp - description
-------------------
begin : Feb 22 2007
copyright : (C) 2007 by Baryshev Dmitry
email : ksquirrel.iv@gmail.com
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <tqpainter.h>
#include "sq_treeviewitem.h"
SQ_TreeViewItem::SQ_TreeViewItem(KFileTreeViewItem *tqparentItem, KFileItem *fileItem, KFileTreeBranch *tqparentBranch)
: KFileTreeViewItem(tqparentItem, fileItem, tqparentBranch),
m_checked(false), count_files(0), count_dirs(0), use_c1(false), use_c2(false)
{}
SQ_TreeViewItem::SQ_TreeViewItem(KFileTreeView *tqparent, KFileItem *fileItem, KFileTreeBranch *tqparentBranch)
: KFileTreeViewItem(tqparent, fileItem, tqparentBranch),
m_checked(false), count_files(0), count_dirs(0), use_c1(false), use_c2(false)
{}
SQ_TreeViewItem::~SQ_TreeViewItem()
{}
void SQ_TreeViewItem::paintFocus(TQPainter *, const TQColorGroup &, const TQRect &)
{}
void SQ_TreeViewItem::paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int tqalignment)
{
KListView *klv = static_cast<KListView *>(listView());
// mark item
if(column)
{
int h = height();
int w = klv->columnWidth(1);
const int m = 6;
const int marg = 2;
p->fillRect(0,0,w,h,cg.base());
p->setPen(black);
p->setBrush(cg.base());
p->drawRect(marg, marg, w-marg*2, h-marg*2);
if(m_checked)
p->fillRect((w-m)/2, (h-m)/2, m, m, cg.highlight());
}
else // file name and pixmap
{
TQColorGroup cc = cg;
if(m_checked)
{
if(klv->viewport()->backgroundMode() == TQt::FixedColor)
cc.setColor(TQColorGroup::Background, cg.highlight());
else
cc.setColor(TQColorGroup::Base, cg.highlight());
}
else if(isAlternate())
{
if(klv->viewport()->backgroundMode() == TQt::FixedColor)
cc.setColor(TQColorGroup::Background, klv->alternateBackground());
else
cc.setColor(TQColorGroup::Base, klv->alternateBackground());
}
TQListViewItem::paintCell(p, cc, column, width, tqalignment);
}
}
void SQ_TreeViewItem::setCount(int c1, int c2)
{
count_files = c1 < 0 ? 0 : c1;
count_dirs = c2 < 0 ? 0 : c2;
setText(0, fileItem()->name());
}
void SQ_TreeViewItem::setText(int column, const TQString &text)
{
TQString s;
if(use_c1 && use_c2) // files + dirs: show these two values anyway
s = TQString::tqfromLatin1(" [%1/%2]").tqarg(count_dirs).tqarg(count_files);
else if(use_c1 && count_files) // files, file count is > 0
s = TQString::tqfromLatin1(" [%1]").tqarg(count_files);
else if(use_c2 && count_dirs) // dirs, dir count is > 0
s = TQString::tqfromLatin1(" [%1]").tqarg(count_dirs);
KFileTreeViewItem::setText(column, text + s);
}
|