summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-08-26 22:07:59 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-08-26 22:07:59 (GMT)
commit0087712586d5651e1fe8fe9e76b2e8cff3b1f602 (patch)
treeeab2781125fd2dd749feba10dba846960fd4ec76 /Swift
parentfe14787ccaa95c4c85d5a8418a0ec812eddc959c (diff)
downloadswift-contrib-0087712586d5651e1fe8fe9e76b2e8cff3b1f602.zip
swift-contrib-0087712586d5651e1fe8fe9e76b2e8cff3b1f602.tar.bz2
Round the group corners and stop group highlighting in the roster
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/Roster/RosterDelegate.cpp23
-rw-r--r--Swift/QtUI/Roster/RosterDelegate.h3
2 files changed, 24 insertions, 2 deletions
diff --git a/Swift/QtUI/Roster/RosterDelegate.cpp b/Swift/QtUI/Roster/RosterDelegate.cpp
index 778345e..1b7857e 100644
--- a/Swift/QtUI/Roster/RosterDelegate.cpp
+++ b/Swift/QtUI/Roster/RosterDelegate.cpp
@@ -5,6 +5,7 @@
#include <QColor>
#include <QBrush>
#include <QFontMetrics>
+#include <QPainterPath>
#include <qdebug.h>
#include "QtTreeWidgetItem.h"
@@ -32,12 +33,30 @@ QSize RosterDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelI
return QSize(150, sizeByText > sizeByAvatar ? sizeByText : sizeByAvatar);
}
+
+
void RosterDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
QtTreeWidgetItem* item = static_cast<QtTreeWidgetItem*>(index.internalPointer());
if (item && !item->isContact()) {
- QStyledItemDelegate::paint(painter, option, index);
- return;
+ paintGroup(painter, option, index);
+ } else {
+ paintContact(painter, option, index);
}
+}
+
+void RosterDelegate::paintGroup(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
+ painter->save();
+ //QLinearGradient
+ QBrush backgroundBrush = QBrush(index.data(Qt::BackgroundColorRole).value<QColor>(), Qt::SolidPattern);
+ painter->setPen(QPen(index.data(Qt::TextColorRole).value<QColor>()));
+ QPainterPath roundedPath;
+ roundedPath.addRoundedRect(option.rect, 5, 5);
+ painter->fillPath(roundedPath, backgroundBrush);
+ painter->drawText(option.rect.adjusted(margin_, 0, -1 * margin_, 0), Qt::AlignTop, index.data(Qt::DisplayRole).toString());
+ painter->restore();
+}
+
+void RosterDelegate::paintContact(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
//qDebug() << "painting" << index.data(Qt::DisplayRole).toString();
painter->save();
//QStyledItemDelegate::paint(painter, option, index);
diff --git a/Swift/QtUI/Roster/RosterDelegate.h b/Swift/QtUI/Roster/RosterDelegate.h
index dcbb665..1d1f0ce 100644
--- a/Swift/QtUI/Roster/RosterDelegate.h
+++ b/Swift/QtUI/Roster/RosterDelegate.h
@@ -5,12 +5,15 @@
#include <QFont>
namespace Swift {
+ class QtTreeWidgetItem;
class RosterDelegate : public QStyledItemDelegate {
public:
RosterDelegate();
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
private:
+ void paintGroup(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
+ void paintContact(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
QFont nameFont_;
QFont statusFont_;
static const int avatarSize_ = 28;