summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2013-04-30 20:10:12 (GMT)
committerSwift Review <review@swift.im>2013-10-01 14:48:44 (GMT)
commitfd47dd7d5cec5155b9985959d2f0e0f3b386cd98 (patch)
treed4da57ce3f1c90f56701cab8757d75e089473c9e /Swift/QtUI/UserSearch/ContactListDelegate.cpp
parenta3781c5b770c03ff32c5cf8f1280b21c2a8e2626 (diff)
downloadswift-fd47dd7d5cec5155b9985959d2f0e0f3b386cd98.zip
swift-fd47dd7d5cec5155b9985959d2f0e0f3b386cd98.tar.bz2
Adding support for impromptu MUCs.
Change-Id: I363e9d740bbec311454827645f4ea6df8bb60bed License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swift/QtUI/UserSearch/ContactListDelegate.cpp')
-rw-r--r--Swift/QtUI/UserSearch/ContactListDelegate.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/Swift/QtUI/UserSearch/ContactListDelegate.cpp b/Swift/QtUI/UserSearch/ContactListDelegate.cpp
new file mode 100644
index 0000000..29cab83
--- /dev/null
+++ b/Swift/QtUI/UserSearch/ContactListDelegate.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2013 Tobias Markmann
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <Swift/QtUI/UserSearch/ContactListDelegate.h>
+#include <Swift/QtUI/UserSearch/ContactListModel.h>
+#include <Swift/Controllers/Contact.h>
+#include <Swift/QtUI/QtSwiftUtil.h>
+
+namespace Swift {
+
+ContactListDelegate::ContactListDelegate(bool compact) : compact_(compact) {
+}
+
+ContactListDelegate::~ContactListDelegate() {
+}
+
+void ContactListDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
+ if (!index.isValid()) {
+ return;
+ }
+ const Contact* contact = static_cast<Contact*>(index.internalPointer());
+ QColor nameColor = index.data(Qt::TextColorRole).value<QColor>();
+ QString avatarPath = index.data(ContactListModel::AvatarRole).value<QString>();
+ QIcon presenceIcon =index.data(ChatListRecentItem::PresenceIconRole).isValid() && !index.data(ChatListRecentItem::PresenceIconRole).value<QIcon>().isNull()
+ ? index.data(ChatListRecentItem::PresenceIconRole).value<QIcon>()
+ : QIcon(":/icons/offline.png");
+ QString name = P2QSTRING(contact->name);
+ QString statusText = P2QSTRING(contact->jid.toString());
+ common_.paintContact(painter, option, nameColor, avatarPath, presenceIcon, name, statusText, false, 0, compact_);
+}
+
+QSize ContactListDelegate::sizeHint(const QStyleOptionViewItem& /*option*/, const QModelIndex& /*index*/ ) const {
+ QFontMetrics nameMetrics(common_.nameFont);
+ QFontMetrics statusMetrics(common_.detailFont);
+ int sizeByText = 2 * common_.verticalMargin + nameMetrics.height() + statusMetrics.height();
+ return QSize(150, sizeByText);
+}
+
+void ContactListDelegate::setCompact(bool compact) {
+ compact_ = compact;
+}
+
+}