summaryrefslogtreecommitdiffstats
path: root/ksquirrel/sidebar/sq_treeviewitem.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-22 19:31:25 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-22 19:31:25 +0000
commit6afd9d8dddbe9e450690e05d498a503c00333a5e (patch)
treeee3eaca74e8e33dd66f24f5fb6c1431d7a9ff429 /ksquirrel/sidebar/sq_treeviewitem.cpp
downloadksquirrel-6afd9d8dddbe9e450690e05d498a503c00333a5e.tar.gz
ksquirrel-6afd9d8dddbe9e450690e05d498a503c00333a5e.zip
Added KDE3 version of ksquirrel photo manager
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ksquirrel@1094446 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksquirrel/sidebar/sq_treeviewitem.cpp')
-rw-r--r--ksquirrel/sidebar/sq_treeviewitem.cpp107
1 files changed, 107 insertions, 0 deletions
diff --git a/ksquirrel/sidebar/sq_treeviewitem.cpp b/ksquirrel/sidebar/sq_treeviewitem.cpp
new file mode 100644
index 0000000..9f6508c
--- /dev/null
+++ b/ksquirrel/sidebar/sq_treeviewitem.cpp
@@ -0,0 +1,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 <qpainter.h>
+
+#include "sq_treeviewitem.h"
+
+SQ_TreeViewItem::SQ_TreeViewItem(KFileTreeViewItem *parentItem, KFileItem *fileItem, KFileTreeBranch *parentBranch)
+ : KFileTreeViewItem(parentItem, fileItem, parentBranch),
+ m_checked(false), count_files(0), count_dirs(0), use_c1(false), use_c2(false)
+{}
+
+SQ_TreeViewItem::SQ_TreeViewItem(KFileTreeView *parent, KFileItem *fileItem, KFileTreeBranch *parentBranch)
+ : KFileTreeViewItem(parent, fileItem, parentBranch),
+ m_checked(false), count_files(0), count_dirs(0), use_c1(false), use_c2(false)
+{}
+
+SQ_TreeViewItem::~SQ_TreeViewItem()
+{}
+
+void SQ_TreeViewItem::paintFocus(QPainter *, const QColorGroup &, const QRect &)
+{}
+
+void SQ_TreeViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
+{
+ 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
+ {
+ QColorGroup cc = cg;
+
+ if(m_checked)
+ {
+ if(klv->viewport()->backgroundMode() == Qt::FixedColor)
+ cc.setColor(QColorGroup::Background, cg.highlight());
+ else
+ cc.setColor(QColorGroup::Base, cg.highlight());
+ }
+ else if(isAlternate())
+ {
+ if(klv->viewport()->backgroundMode() == Qt::FixedColor)
+ cc.setColor(QColorGroup::Background, klv->alternateBackground());
+ else
+ cc.setColor(QColorGroup::Base, klv->alternateBackground());
+ }
+
+ QListViewItem::paintCell(p, cc, column, width, alignment);
+ }
+}
+
+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 QString &text)
+{
+ QString s;
+
+ if(use_c1 && use_c2) // files + dirs: show these two values anyway
+ s = QString::fromLatin1(" [%1/%2]").arg(count_dirs).arg(count_files);
+ else if(use_c1 && count_files) // files, file count is > 0
+ s = QString::fromLatin1(" [%1]").arg(count_files);
+ else if(use_c2 && count_dirs) // dirs, dir count is > 0
+ s = QString::fromLatin1(" [%1]").arg(count_dirs);
+
+ KFileTreeViewItem::setText(column, text + s);
+}
+