summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/Roster')
-rw-r--r--Swift/QtUI/Roster/DelegateCommons.cpp88
-rw-r--r--Swift/QtUI/Roster/DelegateCommons.h11
-rw-r--r--Swift/QtUI/Roster/QtTreeWidgetItem.cpp242
-rw-r--r--Swift/QtUI/Roster/QtTreeWidgetItem.h86
-rw-r--r--Swift/QtUI/Roster/RosterDelegate.cpp81
-rw-r--r--Swift/QtUI/Roster/RosterDelegate.h4
6 files changed, 106 insertions, 406 deletions
diff --git a/Swift/QtUI/Roster/DelegateCommons.cpp b/Swift/QtUI/Roster/DelegateCommons.cpp
index 164b80f..290794d 100644
--- a/Swift/QtUI/Roster/DelegateCommons.cpp
+++ b/Swift/QtUI/Roster/DelegateCommons.cpp
@@ -6,18 +6,102 @@
#include "DelegateCommons.h"
+#include <QtScaledAvatarCache.h>
+#include <QFileInfo>
+
namespace Swift {
-void DelegateCommons::drawElidedText(QPainter* painter, const QRect& region, const QString& text) {
+void DelegateCommons::drawElidedText(QPainter* painter, const QRect& region, const QString& text, int flags) {
QString adjustedText(painter->fontMetrics().elidedText(text, Qt::ElideRight, region.width(), Qt::TextShowMnemonic));
- painter->drawText(region, Qt::AlignTop, adjustedText);
+ painter->drawText(region, flags, adjustedText);
}
+void DelegateCommons::paintContact(QPainter* painter, const QStyleOptionViewItem& option, const QColor& nameColor, const QString& avatarPath, const QIcon& presenceIcon, const QString& name, const QString& statusText, int unreadCount) const {
+ painter->save();
+ QRect fullRegion(option.rect);
+ if ( option.state & QStyle::State_Selected ) {
+ painter->fillRect(fullRegion, option.palette.highlight());
+ painter->setPen(option.palette.highlightedText().color());
+ } else {
+ painter->setPen(QPen(nameColor));
+ }
+
+ QRect presenceIconRegion(QPoint(farLeftMargin, fullRegion.top()), QSize(presenceIconWidth, fullRegion.height() - verticalMargin));
+
+ int calculatedAvatarSize = presenceIconRegion.height();
+ //This overlaps the presenceIcon, so must be painted first
+ QRect avatarRegion(QPoint(presenceIconRegion.right() - presenceIconWidth / 2, presenceIconRegion.top()), QSize(calculatedAvatarSize, calculatedAvatarSize));
+
+ QPixmap avatarPixmap;
+ if (!avatarPath.isEmpty()) {
+ QString scaledAvatarPath = QtScaledAvatarCache(avatarRegion.height()).getScaledAvatarPath(avatarPath);
+ if (QFileInfo(scaledAvatarPath).exists()) {
+ avatarPixmap.load(scaledAvatarPath);
+ }
+ }
+ if (avatarPixmap.isNull()) {
+ avatarPixmap = QPixmap(":/icons/avatar.png").scaled(avatarRegion.height(), avatarRegion.width(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ }
+
+ painter->drawPixmap(avatarRegion.topLeft() + QPoint(((avatarRegion.width() - avatarPixmap.width()) / 2), (avatarRegion.height() - avatarPixmap.height()) / 2), avatarPixmap);
+
+ //Paint the presence icon over the top of the avatar
+ presenceIcon.paint(painter, presenceIconRegion, Qt::AlignBottom | Qt::AlignHCenter);
+
+ QFontMetrics nameMetrics(nameFont);
+ painter->setFont(nameFont);
+ int extraFontWidth = nameMetrics.width("H");
+ int leftOffset = avatarRegion.right() + horizontalMargin * 2 + extraFontWidth / 2;
+ QRect textRegion(fullRegion.adjusted(leftOffset, 0, 0/*-leftOffset*/, 0));
+
+ int nameHeight = nameMetrics.height() + verticalMargin;
+ QRect nameRegion(textRegion.adjusted(0, verticalMargin, 0, 0));
+
+ DelegateCommons::drawElidedText(painter, nameRegion, name);
+
+
+ painter->setFont(detailFont);
+ painter->setPen(QPen(QColor(160,160,160)));
+
+ QRect statusTextRegion(textRegion.adjusted(0, nameHeight, 0, 0));
+ DelegateCommons::drawElidedText(painter, statusTextRegion, statusText);
+
+ if (unreadCount > 0) {
+ QRect unreadRect(fullRegion.right() - unreadCountSize - horizontalMargin, fullRegion.top() + (fullRegion.height() - unreadCountSize) / 2, unreadCountSize, unreadCountSize);
+ QPen pen(QColor("black"));
+ pen.setWidth(1);
+ painter->setRenderHint(QPainter::Antialiasing, true);
+ painter->setPen(pen);
+ painter->setBrush(QBrush(QColor("red"), Qt::SolidPattern));
+ //painter->setBackgroundMode(Qt::OpaqueMode);
+ painter->drawEllipse(unreadRect);
+ painter->setBackgroundMode(Qt::TransparentMode);
+ painter->setPen(QColor("white"));
+ drawElidedText(painter, unreadRect, QString("%1").arg(unreadCount), Qt::AlignCenter);
+ }
+
+ painter->restore();
+}
+
+QSize DelegateCommons::contactSizeHint(const QStyleOptionViewItem& /*option*/, const QModelIndex& /*index*/ ) const {
+ int heightByAvatar = avatarSize + verticalMargin * 2;
+ QFontMetrics nameMetrics(nameFont);
+ QFontMetrics statusMetrics(detailFont);
+ int sizeByText = 2 * verticalMargin + nameMetrics.height() + statusMetrics.height();
+ //Doesn't work, yay! FIXME: why?
+ //QSize size = (option.state & QStyle::State_Selected) ? QSize(150, 80) : QSize(150, avatarSize_ + margin_ * 2);
+ //qDebug() << "Returning size" << size;
+ return QSize(150, sizeByText > heightByAvatar ? sizeByText : heightByAvatar);
+}
const int DelegateCommons::horizontalMargin = 2;
const int DelegateCommons::verticalMargin = 2;
const int DelegateCommons::farLeftMargin = 2;
+const int DelegateCommons::avatarSize = 20;
+const int DelegateCommons::presenceIconHeight = 16;
+const int DelegateCommons::presenceIconWidth = 16;
+const int DelegateCommons::unreadCountSize = 16;
diff --git a/Swift/QtUI/Roster/DelegateCommons.h b/Swift/QtUI/Roster/DelegateCommons.h
index 9213ef5..e5e4ff9 100644
--- a/Swift/QtUI/Roster/DelegateCommons.h
+++ b/Swift/QtUI/Roster/DelegateCommons.h
@@ -11,6 +11,8 @@
#include <QPainter>
#include <QRect>
#include <QString>
+#include <QIcon>
+#include <QStyleOptionViewItem>
namespace Swift {
class DelegateCommons {
@@ -21,7 +23,10 @@ namespace Swift {
detailFont.setPointSize(nameFont.pointSize() - detailFontSizeDrop);
}
- static void drawElidedText(QPainter* painter, const QRect& region, const QString& text);
+ static void drawElidedText(QPainter* painter, const QRect& region, const QString& text, int flags = Qt::AlignTop);
+
+ QSize contactSizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
+ void paintContact(QPainter* painter, const QStyleOptionViewItem& option, const QColor& nameColor, const QString& avatarPath, const QIcon& presenceIcon, const QString& name, const QString& statusText, int unreadCount) const;
int detailFontSizeDrop;
QFont nameFont;
@@ -29,5 +34,9 @@ namespace Swift {
static const int horizontalMargin;
static const int verticalMargin;
static const int farLeftMargin;
+ static const int avatarSize;
+ static const int presenceIconHeight;
+ static const int presenceIconWidth;
+ static const int unreadCountSize;
};
}
diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
deleted file mode 100644
index fcd8691..0000000
--- a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 2010 Kevin Smith
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include "Swift/QtUI/Roster/QtTreeWidgetItem.h"
-#include "Swift/QtUI/Roster/QtTreeWidget.h"
-
-#include <qdebug.h>
-#include <QtAlgorithms>
-#include <algorithm>
-
-namespace Swift {
-
-QtTreeWidgetItem::QtTreeWidgetItem(QtTreeWidgetItem* parentItem) : QObject(), textColor_(0,0,0), backgroundColor_(255,255,255) {
- parent_ = parentItem;
- shown_ = true;
- expanded_ = true;
-}
-
-
-void QtTreeWidgetItem::setText(const std::string& text) {
- displayName_ = P2QSTRING(text);
- displayNameLower_ = displayName_.toLower();
- emit changed(this);
-}
-
-void QtTreeWidgetItem::setStatusText(const std::string& text) {
- statusText_ = P2QSTRING(text);
- emit changed(this);
-}
-
-void QtTreeWidgetItem::setAvatarPath(const std::string& path) {
- avatar_ = QIcon(P2QSTRING(path));
- emit changed(this);
-}
-
-void QtTreeWidgetItem::setStatusShow(StatusShow::Type show) {
- statusShowType_ = show;
- int color = 0;
- switch (show) {
- case StatusShow::Online: color = 0x000000; mergedShowType_ = StatusShow::Online; break;
- case StatusShow::Away: color = 0x336699; mergedShowType_ = StatusShow::Away; break;
- case StatusShow::XA: color = 0x336699; mergedShowType_ = StatusShow::Away; break;
- case StatusShow::FFC: color = 0x000000; mergedShowType_ = StatusShow::Online; break;
- case StatusShow::DND: color = 0x990000; mergedShowType_ = show; break;
- case StatusShow::None: color = 0x7F7F7F; mergedShowType_ = show; break;
- }
- setTextColor(color);
- emit changed(this);
-}
-
-void QtTreeWidgetItem::setTextColor(unsigned long color) {
- textColor_ = QColor(
- ((color & 0xFF0000)>>16),
- ((color & 0xFF00)>>8),
- (color & 0xFF));
-}
-
-void QtTreeWidgetItem::setBackgroundColor(unsigned long color) {
- backgroundColor_ = QColor(
- ((color & 0xFF0000)>>16),
- ((color & 0xFF00)>>8),
- (color & 0xFF));
-}
-
-void QtTreeWidgetItem::setExpanded(bool expanded) {
- expanded_ = expanded;
- emit changed(this);
-}
-
-void QtTreeWidgetItem::hide() {
- shown_ = false;
- emit changed(this);
-}
-
-void QtTreeWidgetItem::show() {
- shown_ = true;
- emit changed(this);
-}
-
-bool QtTreeWidgetItem::isShown() {
- return isContact() ? shown_ : shownChildren_.size() > 0;
-}
-
-QWidget* QtTreeWidgetItem::getCollapsedRosterWidget() {
- QWidget* widget = new QWidget();
- return widget;
-}
-
-QWidget* QtTreeWidgetItem::getExpandedRosterWidget() {
- QWidget* widget = new QWidget();
- return widget;
-}
-
-QtTreeWidgetItem::~QtTreeWidgetItem() {
- //It's possible (due to the way the roster deletes items in unknown order when it is deleted)
- // That the children will be deleted before the groups, or that the groups are deleted
- // before the children. If the children are deleted first, they will let the parent know that
- // They've been deleted. If the parent is deleted first, it must tell the children not to
- // tell it when they're deleted. Everything will be deleted in the end, because all the
- // widgets are owned by the Roster in Swiften.
- if (parent_) {
- parent_->removeChild(this);
- }
-
- for (int i = 0; i < children_.size(); i++) {
- children_[i]->parentItemHasBeenDeleted();
- }
-}
-
-void QtTreeWidgetItem::parentItemHasBeenDeleted() {
- parent_ = NULL;
-}
-
-QtTreeWidgetItem* QtTreeWidgetItem::getParentItem() {
- return parent_;
-}
-
-void QtTreeWidgetItem::addChild(QtTreeWidgetItem* child) {
- children_.append(child);
- connect(child, SIGNAL(changed(QtTreeWidgetItem*)), this, SLOT(handleChanged(QtTreeWidgetItem*)));
- handleChanged(child);
-}
-
-void QtTreeWidgetItem::removeChild(QtTreeWidgetItem* child) {
- children_.removeAll(child);
- handleChanged(this);
-}
-
-void bubbleSort(QList<QtTreeWidgetItem*>& list) {
- bool done = false;
- for (int i = 0; i < list.size() - 1 && !done; i++) {
- done = true;
- for (int j = i + 1; j < list.size(); j++) {
- if (*(list[j]) < *(list[j - 1])) {
- done = false;
- QtTreeWidgetItem* lower = list[j];
- list[j] = list[j - 1];
- list[j - 1] = lower;
- }
- }
- }
-}
-
-void QtTreeWidgetItem::handleChanged(QtTreeWidgetItem* child) {
- /*We don't use the much faster qStableSort because it causes changed(child) and all sorts of nasty recursion*/
- //qStableSort(children_.begin(), children_.end(), itemLessThan);
- //bubbleSort(children_);
- std::stable_sort(children_.begin(), children_.end(), itemLessThan);
- shownChildren_.clear();
- for (int i = 0; i < children_.size(); i++) {
- if (children_[i]->isShown()) {
- shownChildren_.append(children_[i]);
- }
- }
- emit changed(child);
-}
-
-int QtTreeWidgetItem::rowCount() {
- //qDebug() << "Returning size of " << children_.size() << " for item " << displayName_;
- return shownChildren_.size();
-}
-
-int QtTreeWidgetItem::rowOf(QtTreeWidgetItem* item) {
- return shownChildren_.indexOf(item);
-}
-
-int QtTreeWidgetItem::row() {
- return parent_ ? parent_->rowOf(this) : 0;
-}
-
-QtTreeWidgetItem* QtTreeWidgetItem::getItem(int row) {
- //qDebug() << "Returning row " << row << " from item " << displayName_;
- Q_ASSERT(row >= 0);
- Q_ASSERT(row < rowCount());
- return shownChildren_[row];
-}
-
-
-QVariant QtTreeWidgetItem::data(int role) {
- if (!isContact()) {
- setTextColor(0xFFFFFF);
- setBackgroundColor(0x969696);
- }
- switch (role) {
- case Qt::DisplayRole: return displayName_;
- case Qt::TextColorRole: return textColor_;
- case Qt::BackgroundColorRole: return backgroundColor_;
- case Qt::ToolTipRole: return isContact() ? toolTipString() : QVariant();
- case StatusTextRole: return statusText_;
- case AvatarRole: return avatar_;
- case PresenceIconRole: return getPresenceIcon();
- default: return QVariant();
- }
-}
-
-QString QtTreeWidgetItem::toolTipString() {
- return displayName_ + "\n " + statusText_;
-}
-
-QIcon QtTreeWidgetItem::getPresenceIcon() {
- QString iconString;
- switch (statusShowType_) {
- case StatusShow::Online: iconString = "online";break;
- case StatusShow::Away: iconString = "away";break;
- case StatusShow::XA: iconString = "away";break;
- case StatusShow::FFC: iconString = "online";break;
- case StatusShow::DND: iconString = "dnd";break;
- case StatusShow::None: iconString = "offline";break;
- }
- return QIcon(":/icons/" + iconString + ".png");
-}
-
-bool QtTreeWidgetItem::isContact() const {
- return children_.size() == 0;
-}
-
-bool QtTreeWidgetItem::isExpanded() {
- return expanded_;
-}
-
-bool QtTreeWidgetItem::operator<(const QtTreeWidgetItem& item) const {
- if (isContact()) {
- if (!item.isContact()) {
- return false;
- }
- return getStatusShowMerged() == item.getStatusShowMerged() ? getLowerName() < item.getLowerName() : getStatusShowMerged() < item.getStatusShowMerged();
- } else {
- if (item.isContact()) {
- return true;
- }
- return getLowerName() < item.getLowerName();
- }
-}
-
-bool itemLessThan(QtTreeWidgetItem* left, QtTreeWidgetItem* right) {
- return *left < *right;
-}
-
-}
diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.h b/Swift/QtUI/Roster/QtTreeWidgetItem.h
deleted file mode 100644
index 6855989..0000000
--- a/Swift/QtUI/Roster/QtTreeWidgetItem.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2010 Kevin Smith
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include <QColor>
-#include <QVariant>
-#include <string>
-
-#include "Swiften/Roster/TreeWidgetFactory.h"
-#include "Swiften/Roster/TreeWidget.h"
-#include "Swiften/Roster/TreeWidgetItem.h"
-#include "Swift/QtUI/QtSwiftUtil.h"
-
-namespace Swift {
- enum RosterRoles {
- StatusTextRole = Qt::UserRole,
- AvatarRole = Qt::UserRole + 1,
- PresenceIconRole = Qt::UserRole + 2,
- StatusShowTypeRole = Qt::UserRole + 3
- };
-
-class QtTreeWidget;
-class QtTreeWidgetItem : public QObject, public TreeWidgetItem {
- Q_OBJECT
- public:
- ~QtTreeWidgetItem();
- void addChild(QtTreeWidgetItem* child);
- void removeChild(QtTreeWidgetItem* child);
- QtTreeWidgetItem* getParentItem();
- int rowCount();
- int rowOf(QtTreeWidgetItem* item);
- int row();
- QtTreeWidgetItem* getItem(int row);
- QVariant data(int role);
- QIcon getPresenceIcon();
- QtTreeWidgetItem(QtTreeWidgetItem* parentItem);
- void setText(const std::string& text);
- void setAvatarPath(const std::string& path);
- void setStatusText(const std::string& text);
- void setStatusShow(StatusShow::Type show);
- void setTextColor(unsigned long color);
- void setBackgroundColor(unsigned long color);
- void setExpanded(bool b);
- void parentItemHasBeenDeleted();
- void hide();
- void show();
- bool isShown();
- bool isContact() const;
- bool isExpanded();
- const QString& getName() const {return displayName_;};
- const QString& getLowerName() const {return displayNameLower_;};
- StatusShow::Type getStatusShow() const {return statusShowType_;};
- StatusShow::Type getStatusShowMerged() const {return mergedShowType_;};
-
- QWidget* getCollapsedRosterWidget();
- QWidget* getExpandedRosterWidget();
- bool operator<(const QtTreeWidgetItem& item) const;
-
- signals:
- void changed(QtTreeWidgetItem*);
- private slots:
- void handleChanged(QtTreeWidgetItem* item);
- private:
- QString toolTipString();
- QList<QtTreeWidgetItem*> children_;
- QList<QtTreeWidgetItem*> shownChildren_;
- QtTreeWidgetItem* parent_;
- QString displayName_;
- QString displayNameLower_;
- QString statusText_;
- QColor textColor_;
- QColor backgroundColor_;
- QVariant avatar_;
- bool shown_;
- bool expanded_;
- StatusShow::Type statusShowType_;
- StatusShow::Type mergedShowType_;
-};
-
-bool itemLessThan(QtTreeWidgetItem* left, QtTreeWidgetItem* right);
-
-}
diff --git a/Swift/QtUI/Roster/RosterDelegate.cpp b/Swift/QtUI/Roster/RosterDelegate.cpp
index aaa6236..e40907a 100644
--- a/Swift/QtUI/Roster/RosterDelegate.cpp
+++ b/Swift/QtUI/Roster/RosterDelegate.cpp
@@ -12,7 +12,6 @@
#include <QBrush>
#include <QFontMetrics>
#include <QPainterPath>
-#include <QFileInfo>
#include <QPolygon>
#include <qdebug.h>
#include <QBitmap>
@@ -22,7 +21,6 @@
#include "QtTreeWidget.h"
#include "RosterModel.h"
-#include "QtScaledAvatarCache.h"
namespace Swift {
@@ -43,15 +41,8 @@ QSize RosterDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelI
return contactSizeHint(option, index);
}
-QSize RosterDelegate::contactSizeHint(const QStyleOptionViewItem& /*option*/, const QModelIndex& /*index*/ ) const {
- int heightByAvatar = avatarSize_ + common_.verticalMargin * 2;
- QFontMetrics nameMetrics(common_.nameFont);
- QFontMetrics statusMetrics(common_.detailFont);
- int sizeByText = 2 * common_.verticalMargin + nameMetrics.height() + statusMetrics.height();
- //Doesn't work, yay! FIXME: why?
- //QSize size = (option.state & QStyle::State_Selected) ? QSize(150, 80) : QSize(150, avatarSize_ + margin_ * 2);
- //qDebug() << "Returning size" << size;
- return QSize(150, sizeByText > heightByAvatar ? sizeByText : heightByAvatar);
+QSize RosterDelegate::contactSizeHint(const QStyleOptionViewItem& option, const QModelIndex& index ) const {
+ return common_.contactSizeHint(option, index);
}
void RosterDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
@@ -70,70 +61,18 @@ void RosterDelegate::paintGroup(QPainter* painter, const QStyleOptionViewItem& o
}
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);
- //initStyleOption(option, index);
- QRect fullRegion(option.rect);
- if ( option.state & QStyle::State_Selected ) {
- painter->fillRect(fullRegion, option.palette.highlight());
- painter->setPen(option.palette.highlightedText().color());
- } else {
- QColor nameColor = index.data(Qt::TextColorRole).value<QColor>();
- painter->setPen(QPen(nameColor));
- }
-
- QRect presenceIconRegion(QPoint(common_.farLeftMargin, fullRegion.top()), QSize(presenceIconWidth_, fullRegion.height() - common_.verticalMargin));
-
- int calculatedAvatarSize = presenceIconRegion.height();
- //This overlaps the presenceIcon, so must be painted first
- QRect avatarRegion(QPoint(presenceIconRegion.right() - presenceIconWidth_ / 2, presenceIconRegion.top()), QSize(calculatedAvatarSize, calculatedAvatarSize));
-
- QPixmap avatarPixmap;
+ QColor nameColor = index.data(Qt::TextColorRole).value<QColor>();
+ QString avatarPath;
if (index.data(AvatarRole).isValid() && !index.data(AvatarRole).value<QString>().isNull()) {
- QString avatarPath = index.data(AvatarRole).value<QString>();
- QString scaledAvatarPath = QtScaledAvatarCache(avatarRegion.height()).getScaledAvatarPath(avatarPath);
- if (QFileInfo(scaledAvatarPath).exists()) {
- avatarPixmap.load(scaledAvatarPath);
- }
+ avatarPath = index.data(AvatarRole).value<QString>();
}
- if (avatarPixmap.isNull()) {
- avatarPixmap = QPixmap(":/icons/avatar.png").scaled(avatarRegion.height(), avatarRegion.width(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
- }
-
- painter->drawPixmap(avatarRegion.topLeft() + QPoint(((avatarRegion.width() - avatarPixmap.width()) / 2), (avatarRegion.height() - avatarPixmap.height()) / 2), avatarPixmap);
-
- //Paint the presence icon over the top of the avatar
QIcon presenceIcon = index.data(PresenceIconRole).isValid() && !index.data(PresenceIconRole).value<QIcon>().isNull()
- ? index.data(PresenceIconRole).value<QIcon>()
- : QIcon(":/icons/offline.png");
- presenceIcon.paint(painter, presenceIconRegion, Qt::AlignBottom | Qt::AlignHCenter);
-
- QFontMetrics nameMetrics(common_.nameFont);
- painter->setFont(common_.nameFont);
- int extraFontWidth = nameMetrics.width("H");
- int leftOffset = avatarRegion.right() + common_.horizontalMargin * 2 + extraFontWidth / 2;
- QRect textRegion(fullRegion.adjusted(leftOffset, 0, 0/*-leftOffset*/, 0));
-
- int nameHeight = nameMetrics.height() + common_.verticalMargin;
- QRect nameRegion(textRegion.adjusted(0, common_.verticalMargin, 0, 0));
-
- DelegateCommons::drawElidedText(painter, nameRegion, index.data(Qt::DisplayRole).toString());
-
-
- painter->setFont(common_.detailFont);
- painter->setPen(QPen(QColor(160,160,160)));
-
- QRect statusTextRegion(textRegion.adjusted(0, nameHeight, 0, 0));
- DelegateCommons::drawElidedText(painter, statusTextRegion, index.data(StatusTextRole).toString());
-
- painter->restore();
+ ? index.data(PresenceIconRole).value<QIcon>()
+ : QIcon(":/icons/offline.png");
+ QString name = index.data(Qt::DisplayRole).toString();
+ QString statusText = index.data(StatusTextRole).toString();
+ common_.paintContact(painter, option, nameColor, avatarPath, presenceIcon, name, statusText, 0);
}
-
-const int RosterDelegate::avatarSize_ = 20;
-const int RosterDelegate::presenceIconHeight_ = 16;
-const int RosterDelegate::presenceIconWidth_ = 16;
-
}
diff --git a/Swift/QtUI/Roster/RosterDelegate.h b/Swift/QtUI/Roster/RosterDelegate.h
index e6a16f2..253c11a 100644
--- a/Swift/QtUI/Roster/RosterDelegate.h
+++ b/Swift/QtUI/Roster/RosterDelegate.h
@@ -28,9 +28,5 @@ namespace Swift {
DelegateCommons common_;
GroupItemDelegate* groupDelegate_;
QtTreeWidget* tree_;
- static const int avatarSize_;
- static const int presenceIconHeight_;
- static const int presenceIconWidth_;
-
};
}