From d78c4858afaaf856ec95d45adf59916b6eaf032d Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Sat, 9 Jul 2011 20:15:47 +0100
Subject: Fix roster avatars


diff --git a/Swift/QtUI/ChatList/ChatListDelegate.cpp b/Swift/QtUI/ChatList/ChatListDelegate.cpp
index 520b40e..0c4356c 100644
--- a/Swift/QtUI/ChatList/ChatListDelegate.cpp
+++ b/Swift/QtUI/ChatList/ChatListDelegate.cpp
@@ -101,12 +101,13 @@ void ChatListDelegate::paintRecent(QPainter* painter, const QStyleOptionViewItem
 	QColor nameColor = item->data(Qt::TextColorRole).value<QColor>();
 	QString avatarPath;
 	if (item->data(ChatListRecentItem::AvatarRole).isValid() && !item->data(ChatListRecentItem::AvatarRole).value<QString>().isNull()) {
-		QString avatarPath = item->data(ChatListRecentItem::AvatarRole).value<QString>();
+		avatarPath = item->data(ChatListRecentItem::AvatarRole).value<QString>();
 	}
 	QIcon presenceIcon = item->data(ChatListRecentItem::PresenceIconRole).isValid() && !item->data(ChatListRecentItem::PresenceIconRole).value<QIcon>().isNull()
 			? item->data(ChatListRecentItem::PresenceIconRole).value<QIcon>()
 			: QIcon(":/icons/offline.png");
 	QString name = item->data(Qt::DisplayRole).toString();
+	//qDebug() << "Avatar for " << name << " = " << avatarPath;
 	QString statusText = item->data(ChatListRecentItem::DetailTextRole).toString();
 	common_.paintContact(painter, option, nameColor, avatarPath, presenceIcon, name, statusText);
 }
diff --git a/Swift/QtUI/ChatList/ChatListRecentItem.cpp b/Swift/QtUI/ChatList/ChatListRecentItem.cpp
index e7c9599..6c9807f 100644
--- a/Swift/QtUI/ChatList/ChatListRecentItem.cpp
+++ b/Swift/QtUI/ChatList/ChatListRecentItem.cpp
@@ -25,7 +25,7 @@ QVariant ChatListRecentItem::data(int role) const {
 		case Qt::BackgroundColorRole: return backgroundColor_;
 		case Qt::ToolTipRole: return isContact() ? toolTipString() : QVariant();
 		case StatusTextRole: return statusText_;*/
-		case AvatarRole: return chat_.avatarPath.string().c_str();
+		case AvatarRole: return QVariant(QString(chat_.avatarPath.string().c_str()));
 		case PresenceIconRole: return getPresenceIcon();
 		default: return QVariant();
 	}
diff --git a/Swift/QtUI/Roster/RosterDelegate.cpp b/Swift/QtUI/Roster/RosterDelegate.cpp
index 6914fc3..1adb9e3 100644
--- a/Swift/QtUI/Roster/RosterDelegate.cpp
+++ b/Swift/QtUI/Roster/RosterDelegate.cpp
@@ -64,7 +64,7 @@ void RosterDelegate::paintContact(QPainter* painter, const QStyleOptionViewItem&
 	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>();
+		avatarPath = index.data(AvatarRole).value<QString>();
 	}
 	QIcon presenceIcon = index.data(PresenceIconRole).isValid() && !index.data(PresenceIconRole).value<QIcon>().isNull()
 			? index.data(PresenceIconRole).value<QIcon>()
-- 
cgit v0.10.2-6-g49f6