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
|
#include <kiconloader.h>
#include "listboxlink.h"
#include <tqpainter.h>
#include <tqbitmap.h>
#include "eject.xbm"
#include "lock.xbm"
static TQBitmap eject = TQBitmap( eject_width, eject_height, eject_bits, true );
static TQBitmap locked = TQBitmap( lock_width, lock_height, lock_bits, true );
ListBoxLink::ListBoxLink( const TQString & icon, uint size, const TQString & title, const TQString & url): TQListBoxPixmap(KGlobal::iconLoader()->loadIcon(icon, KIcon::Desktop, size), title),url_(url),icon_(icon)
{
}
ListBoxLink::ListBoxLink( const TQPixmap & pixmap, const TQString & title, const TQString & url) : TQListBoxPixmap(pixmap, title), url_(url), icon_(0)
{
}
ListBoxLink::ListBoxLink(ListBoxLink & link) : TQListBoxPixmap(*link.pixmap(), link.text()), url_(link.URL()), icon_(link.icon())
{
}
ListBoxLink::~ListBoxLink()
{
}
void ListBoxLink::setURL(const TQString & url)
{
url_ = url;
}
void ListBoxLink::setIcon(const TQString & icon)
{
icon_ = icon;
}
int ListBoxLink::height ( const TQListBox * lb ) const
{
return (TQListBoxPixmap::height ( lb ) + 4);
}
ListBoxDevice::ListBoxDevice(const TQString & icon, uint size, const TQString & title, const TQString & url, const TQString & name, const TQString & mountPoint, bool mounted, bool ejectable, bool removable, int id) : ListBoxLink(icon, size, title, url), name_(name), mountPoint_(mountPoint), mounted_(mounted), ejectable_(ejectable), removable_(removable),id_(id)
{
if (!eject.mask())
eject.setMask(eject);
if (!locked.mask())
locked.setMask(locked);
}
ListBoxDevice::ListBoxDevice(const TQPixmap & pixmap, const TQString & title, const TQString & url, const TQString & name, const TQString & mountPoint, bool mounted, bool ejectable, bool removable, int id) : ListBoxLink(pixmap, title, url), name_(name), mountPoint_(mountPoint), mounted_(mounted), ejectable_(ejectable), removable_(removable),id_(id)
{
if (!eject.mask())
eject.setMask(eject);
if (!locked.mask())
locked.setMask(locked);
}
int ListBoxDevice::width ( const TQListBox * lb ) const
{
if (ejectable_ && mounted_ && lb)
return lb->width();
return ListBoxLink::width(lb);
}
void ListBoxDevice::paint( TQPainter * p )
{
if ((ejectable_ || removable_) && mounted_)
{
p->save();
ListBoxLink::paint(p);
p->setBrush(isSelected()?listBox()->colorGroup().highlightedText():listBox()->colorGroup().text());
p->drawPixmap(listBox()->width()-22, 11, ejectable_?eject:locked);
p->restore();
}
else
ListBoxLink::paint(p);
}
|