diff options
author | Kevin Smith <git@kismith.co.uk> | 2009-08-24 19:42:19 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2009-08-24 19:42:19 (GMT) |
commit | 0a6875c0f26e9f487e8e245bba569a262246e78d (patch) | |
tree | 1a34ec40f922de1835f437067692936f7309e089 /Swift/QtUI/Roster | |
parent | 1f7d4ab55ffeaf14c66dcf4f3fb41961916a1192 (diff) | |
download | swift-contrib-0a6875c0f26e9f487e8e245bba569a262246e78d.zip swift-contrib-0a6875c0f26e9f487e8e245bba569a262246e78d.tar.bz2 |
Status icons in the roster show correct status.
Diffstat (limited to 'Swift/QtUI/Roster')
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidgetItem.cpp | 29 | ||||
-rw-r--r-- | Swift/QtUI/Roster/QtTreeWidgetItem.h | 5 | ||||
-rw-r--r-- | Swift/QtUI/Roster/RosterDelegate.h | 1 |
3 files changed, 33 insertions, 2 deletions
diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp index e49c87f..c9693eb 100644 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp +++ b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp @@ -23,6 +23,20 @@ void QtTreeWidgetItem::setAvatarPath(const String& path) { avatar_ = QIcon(P2QSTRING(path)); } +void QtTreeWidgetItem::setStatusShow(StatusShow::Type show) { + statusShowType_ = show; + int color = 0; + switch (show) { + case StatusShow::Online: color = 0x000000;break; + case StatusShow::Away: color = 0x336699;break; + case StatusShow::XA: color = 0x336699;break; + case StatusShow::FFC: color = 0x000000;break; + case StatusShow::DND: color = 0x990000;break; + case StatusShow::None: color = 0x7F7F7F;break; + } + setTextColor(color); +} + void QtTreeWidgetItem::setTextColor(unsigned long color) { textColor_ = QColor( ((color & 0xFF0000)>>16), @@ -133,6 +147,10 @@ QtTreeWidgetItem* QtTreeWidgetItem::getItem(int row) { QVariant QtTreeWidgetItem::data(int role) { + if (!isContact()) { + setTextColor(0xFFFFFF); + setBackgroundColor(0x969696); + } switch (role) { case Qt::DisplayRole: return displayName_; case Qt::TextColorRole: return textColor_; @@ -145,7 +163,16 @@ QVariant QtTreeWidgetItem::data(int role) { } QIcon QtTreeWidgetItem::getPresenceIcon() { - return QIcon(":/icons/online.png"); + 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() { diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.h b/Swift/QtUI/Roster/QtTreeWidgetItem.h index 9c3b0ad..7a459d5 100644 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.h +++ b/Swift/QtUI/Roster/QtTreeWidgetItem.h @@ -18,7 +18,8 @@ namespace Swift { enum RosterRoles { StatusTextRole = Qt::UserRole, AvatarRole = Qt::UserRole + 1, - PresenceIconRole = Qt::UserRole + 2 + PresenceIconRole = Qt::UserRole + 2, + StatusShowTypeRole = Qt::UserRole + 3 }; class QtTreeWidget; @@ -39,6 +40,7 @@ class QtTreeWidgetItem : public QObject, public TreeWidgetItem { void setText(const String& text); void setAvatarPath(const String& path); void setStatusText(const String& text); + void setStatusShow(StatusShow::Type show); void setTextColor(unsigned long color); void setBackgroundColor(unsigned long color); void setExpanded(bool b); @@ -67,6 +69,7 @@ class QtTreeWidgetItem : public QObject, public TreeWidgetItem { QVariant avatar_; bool shown_; bool expanded_; + StatusShow::Type statusShowType_; }; } diff --git a/Swift/QtUI/Roster/RosterDelegate.h b/Swift/QtUI/Roster/RosterDelegate.h index 5986ab2..55775cf 100644 --- a/Swift/QtUI/Roster/RosterDelegate.h +++ b/Swift/QtUI/Roster/RosterDelegate.h @@ -1,6 +1,7 @@ #pragma once #include <QStyledItemDelegate> +#include <QColor> namespace Swift { class RosterDelegate : public QStyledItemDelegate { |