summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/QtUI/Roster/QtTreeWidgetItem.cpp29
-rw-r--r--Swift/QtUI/Roster/QtTreeWidgetItem.h5
-rw-r--r--Swift/QtUI/Roster/RosterDelegate.h1
-rw-r--r--Swiften/Roster/ContactRosterItem.cpp11
-rw-r--r--Swiften/Roster/GroupRosterItem.h2
-rw-r--r--Swiften/Roster/TreeWidgetItem.h6
6 files changed, 38 insertions, 16 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 {
diff --git a/Swiften/Roster/ContactRosterItem.cpp b/Swiften/Roster/ContactRosterItem.cpp
index 2f2f787..968f7f1 100644
--- a/Swiften/Roster/ContactRosterItem.cpp
+++ b/Swiften/Roster/ContactRosterItem.cpp
@@ -22,16 +22,7 @@ StatusShow::Type ContactRosterItem::getStatusShow() {
void ContactRosterItem::setStatusShow(StatusShow::Type show) {
statusShow_ = show;
- int colour = 0;
- switch (show) {
- case StatusShow::Online: colour = 0x000000;break;
- case StatusShow::Away: colour = 0x336699;break;
- case StatusShow::XA: colour = 0x336699;break;
- case StatusShow::FFC: colour = 0x000000;break;
- case StatusShow::DND: colour = 0x990000;break;
- case StatusShow::None: colour = 0x7F7F7F;break;
- }
- widget_->setTextColor(colour);
+ widget_->setStatusShow(show);
}
void ContactRosterItem::setStatusText(const String& status) {
diff --git a/Swiften/Roster/GroupRosterItem.h b/Swiften/Roster/GroupRosterItem.h
index 4065fdb..2ab59ea 100644
--- a/Swiften/Roster/GroupRosterItem.h
+++ b/Swiften/Roster/GroupRosterItem.h
@@ -18,8 +18,6 @@ class GroupRosterItem : public RosterItem {
widget_ = factory->createTreeWidgetItem(tree);
widget_->setExpanded(true);
widget_->setText(name);
- widget_->setTextColor(0xFFFFFF);
- widget_->setBackgroundColor(0x969696);
}
~GroupRosterItem() {
diff --git a/Swiften/Roster/TreeWidgetItem.h b/Swiften/Roster/TreeWidgetItem.h
index 4e20050..4124546 100644
--- a/Swiften/Roster/TreeWidgetItem.h
+++ b/Swiften/Roster/TreeWidgetItem.h
@@ -3,6 +3,7 @@
#include "Swiften/Base/String.h"
#include "Swiften/Roster/UserRosterAction.h"
+#include "Swiften/Elements/StatusShow.h"
#include <boost/signal.hpp>
#include <boost/shared_ptr.hpp>
@@ -16,8 +17,9 @@ class TreeWidgetItem {
virtual void setStatusText(const String& text) = 0;
virtual void setAvatarPath(const String& path) = 0;
virtual void setExpanded(bool b) = 0;
- virtual void setTextColor(unsigned long color) = 0;
- virtual void setBackgroundColor(unsigned long color) = 0;
+ //virtual void setTextColor(unsigned long color) = 0;
+ virtual void setStatusShow(StatusShow::Type show) = 0;
+ //virtual void setBackgroundColor(unsigned long color) = 0;
boost::signal<void (boost::shared_ptr<UserRosterAction>)> onUserAction;
virtual void show() = 0;
virtual void hide() = 0;