summaryrefslogtreecommitdiffstats
path: root/sidebar/listboxlink.cpp
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2016-03-21 20:35:05 +0100
committerSlávek Banko <slavek.banko@axis.cz>2016-03-21 20:35:05 +0100
commit066aaaeb73a8bb908b1c0d8c45f110b2f799f7ce (patch)
tree4cb26eb8ace976f7d0c8607dc2d3de2b5107670c /sidebar/listboxlink.cpp
downloadtde-style-baghira-066aaaeb73a8bb908b1c0d8c45f110b2f799f7ce.tar.gz
tde-style-baghira-066aaaeb73a8bb908b1c0d8c45f110b2f799f7ce.zip
Initial import of baghira 0.8
Diffstat (limited to 'sidebar/listboxlink.cpp')
-rw-r--r--sidebar/listboxlink.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/sidebar/listboxlink.cpp b/sidebar/listboxlink.cpp
new file mode 100644
index 0000000..47adb88
--- /dev/null
+++ b/sidebar/listboxlink.cpp
@@ -0,0 +1,78 @@
+
+#include <kiconloader.h>
+#include "listboxlink.h"
+#include <qpainter.h>
+#include <qbitmap.h>
+#include "eject.xbm"
+#include "lock.xbm"
+
+static QBitmap eject = QBitmap( eject_width, eject_height, eject_bits, true );
+static QBitmap locked = QBitmap( lock_width, lock_height, lock_bits, true );
+
+ListBoxLink::ListBoxLink( const QString & icon, uint size, const QString & title, const QString & url): QListBoxPixmap(KGlobal::iconLoader()->loadIcon(icon, KIcon::Desktop, size), title),url_(url),icon_(icon)
+{
+}
+
+ListBoxLink::ListBoxLink( const QPixmap & pixmap, const QString & title, const QString & url) : QListBoxPixmap(pixmap, title), url_(url), icon_(0)
+{
+}
+
+ListBoxLink::ListBoxLink(ListBoxLink & link) : QListBoxPixmap(*link.pixmap(), link.text()), url_(link.URL()), icon_(link.icon())
+{
+}
+
+ListBoxLink::~ListBoxLink()
+{
+}
+
+void ListBoxLink::setURL(const QString & url)
+{
+ url_ = url;
+}
+
+void ListBoxLink::setIcon(const QString & icon)
+{
+ icon_ = icon;
+}
+
+int ListBoxLink::height ( const QListBox * lb ) const
+{
+ return (QListBoxPixmap::height ( lb ) + 4);
+}
+
+ListBoxDevice::ListBoxDevice(const QString & icon, uint size, const QString & title, const QString & url, const QString & name, const QString & 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 QPixmap & pixmap, const QString & title, const QString & url, const QString & name, const QString & 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 QListBox * lb ) const
+{
+ if (ejectable_ && mounted_ && lb)
+ return lb->width();
+ return ListBoxLink::width(lb);
+}
+
+void ListBoxDevice::paint( QPainter * 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);
+}