diff options
Diffstat (limited to 'Swift/QtUI/Roster/RosterDelegate.cpp')
-rw-r--r-- | Swift/QtUI/Roster/RosterDelegate.cpp | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/Swift/QtUI/Roster/RosterDelegate.cpp b/Swift/QtUI/Roster/RosterDelegate.cpp index c5bb290..061982e 100644 --- a/Swift/QtUI/Roster/RosterDelegate.cpp +++ b/Swift/QtUI/Roster/RosterDelegate.cpp @@ -1,83 +1,83 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ -#include "RosterDelegate.h" +#include <Swift/QtUI/Roster/RosterDelegate.h> #include <QApplication> -#include <QPainter> -#include <QColor> +#include <QBitmap> #include <QBrush> +#include <QColor> +#include <QDebug> #include <QFontMetrics> +#include <QPainter> #include <QPainterPath> #include <QPolygon> -#include <qdebug.h> -#include <QBitmap> -#include "Swift/Controllers/Roster/ContactRosterItem.h" -#include "Swift/Controllers/Roster/GroupRosterItem.h" +#include <Swift/Controllers/Roster/ContactRosterItem.h> +#include <Swift/Controllers/Roster/GroupRosterItem.h> -#include "QtTreeWidget.h" -#include "RosterModel.h" +#include <Swift/QtUI/Roster/QtTreeWidget.h> +#include <Swift/QtUI/Roster/RosterModel.h> namespace Swift { RosterDelegate::RosterDelegate(QtTreeWidget* tree, bool compact) : compact_(compact) { - tree_ = tree; - groupDelegate_ = new GroupItemDelegate(); + tree_ = tree; + groupDelegate_ = new GroupItemDelegate(); } RosterDelegate::~RosterDelegate() { - delete groupDelegate_; + delete groupDelegate_; } void RosterDelegate::setCompact(bool compact) { - compact_ = compact; - emit sizeHintChanged(QModelIndex()); + compact_ = compact; + emit sizeHintChanged(QModelIndex()); } - + QSize RosterDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index ) const { - RosterItem* item = static_cast<RosterItem*>(index.internalPointer()); - if (dynamic_cast<GroupRosterItem*>(item)) { - return groupDelegate_->sizeHint(option, index); - } - return contactSizeHint(option, index); + RosterItem* item = static_cast<RosterItem*>(index.internalPointer()); + if (dynamic_cast<GroupRosterItem*>(item)) { + return groupDelegate_->sizeHint(option, index); + } + return contactSizeHint(option, index); } QSize RosterDelegate::contactSizeHint(const QStyleOptionViewItem& option, const QModelIndex& index ) const { - return common_.contactSizeHint(option, index, compact_); + return common_.contactSizeHint(option, index, compact_); } void RosterDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { - RosterItem* item = static_cast<RosterItem*>(index.internalPointer()); - if (dynamic_cast<GroupRosterItem*>(item)) { - paintGroup(painter, option, index); - } else { - paintContact(painter, option, index); - } + RosterItem* item = static_cast<RosterItem*>(index.internalPointer()); + if (dynamic_cast<GroupRosterItem*>(item)) { + paintGroup(painter, option, index); + } else { + paintContact(painter, option, index); + } } void RosterDelegate::paintGroup(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { - if (index.isValid()) { - groupDelegate_->paint(painter, option, index.data(Qt::DisplayRole).toString(), index.data(ChildCountRole).toInt(), tree_->isExpanded(index)); - } + if (index.isValid()) { + groupDelegate_->paint(painter, option, index.data(Qt::DisplayRole).toString(), index.data(ChildCountRole).toInt(), tree_->isExpanded(index)); + } } void RosterDelegate::paintContact(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { - QColor nameColor = index.data(Qt::TextColorRole).value<QColor>(); - QString avatarPath; - if (index.data(AvatarRole).isValid() && !index.data(AvatarRole).value<QString>().isNull()) { - avatarPath = index.data(AvatarRole).value<QString>(); - } - QIcon presenceIcon = index.data(PresenceIconRole).isValid() && !index.data(PresenceIconRole).value<QIcon>().isNull() - ? index.data(PresenceIconRole).value<QIcon>() - : QIcon(":/icons/offline.png"); - bool isIdle = index.data(IdleRole).isValid() ? index.data(IdleRole).toBool() : false; - QString name = index.data(Qt::DisplayRole).toString(); - QString statusText = index.data(StatusTextRole).toString(); - common_.paintContact(painter, option, nameColor, avatarPath, presenceIcon, name, statusText, isIdle, 0, compact_); + QColor nameColor = index.data(Qt::TextColorRole).value<QColor>(); + QString avatarPath; + if (index.data(AvatarRole).isValid() && !index.data(AvatarRole).value<QString>().isNull()) { + avatarPath = index.data(AvatarRole).value<QString>(); + } + QIcon presenceIcon = index.data(PresenceIconRole).isValid() && !index.data(PresenceIconRole).value<QIcon>().isNull() + ? index.data(PresenceIconRole).value<QIcon>() + : QIcon(":/icons/offline.png"); + bool isIdle = index.data(IdleRole).isValid() ? index.data(IdleRole).toBool() : false; + QString name = index.data(Qt::DisplayRole).toString(); + QString statusText = index.data(StatusTextRole).toString(); + common_.paintContact(painter, option, nameColor, avatarPath, presenceIcon, name, statusText, isIdle, 0, compact_); } } |