summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/EventViewer')
-rw-r--r--Swift/QtUI/EventViewer/EventDelegate.cpp36
-rw-r--r--Swift/QtUI/EventViewer/QtEvent.cpp5
-rw-r--r--Swift/QtUI/EventViewer/QtEvent.h2
3 files changed, 26 insertions, 17 deletions
diff --git a/Swift/QtUI/EventViewer/EventDelegate.cpp b/Swift/QtUI/EventViewer/EventDelegate.cpp
index 9ecdd34..c0904b3 100644
--- a/Swift/QtUI/EventViewer/EventDelegate.cpp
+++ b/Swift/QtUI/EventViewer/EventDelegate.cpp
@@ -25,12 +25,13 @@ QSize EventDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIn
return QStyledItemDelegate::sizeHint(option, index);
}
switch (getEventType(item->getEvent())) {
- case MessageEventType: return messageDelegate_.sizeHint(option, item);
- case SubscriptionEventType: return subscriptionDelegate_.sizeHint(option, item);
- case ErrorEventType: return errorDelegate_.sizeHint(option, item);
- case MUCInviteEventType: return mucInviteDelegate_.sizeHint(option, item);
- default: return QStyledItemDelegate::sizeHint(option, index);
+ case MessageEventType: return messageDelegate_.sizeHint(option, item);
+ case SubscriptionEventType: return subscriptionDelegate_.sizeHint(option, item);
+ case ErrorEventType: return errorDelegate_.sizeHint(option, item);
+ case MUCInviteEventType: return mucInviteDelegate_.sizeHint(option, item);
}
+ assert(false);
+ return QSize();
}
void EventDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
@@ -40,23 +41,30 @@ void EventDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
return;
}
switch (getEventType(item->getEvent())) {
- case MessageEventType: messageDelegate_.paint(painter, option, item);break;
- case SubscriptionEventType: subscriptionDelegate_.paint(painter, option, item);break;
- case ErrorEventType: errorDelegate_.paint(painter, option, item);break;
- case MUCInviteEventType: mucInviteDelegate_.paint(painter, option, item);break;
- default: QStyledItemDelegate::paint(painter, option, index);
+ case MessageEventType: messageDelegate_.paint(painter, option, item);break;
+ case SubscriptionEventType: subscriptionDelegate_.paint(painter, option, item);break;
+ case ErrorEventType: errorDelegate_.paint(painter, option, item);break;
+ case MUCInviteEventType: mucInviteDelegate_.paint(painter, option, item);break;
}
}
EventType EventDelegate::getEventType(boost::shared_ptr<StanzaEvent> event) const {
boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(event);
- if (messageEvent) return MessageEventType;
+ if (messageEvent) {
+ return MessageEventType;
+ }
boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(event);
- if (subscriptionEvent) return SubscriptionEventType;
+ if (subscriptionEvent) {
+ return SubscriptionEventType;
+ }
boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(event);
- if (errorEvent) return ErrorEventType;
+ if (errorEvent) {
+ return ErrorEventType;
+ }
boost::shared_ptr<MUCInviteEvent> mucInviteEvent = boost::dynamic_pointer_cast<MUCInviteEvent>(event);
- if (mucInviteEvent) return MUCInviteEventType;
+ if (mucInviteEvent) {
+ return MUCInviteEventType;
+ }
//I don't know what this is.
assert(false);
return MessageEventType;
diff --git a/Swift/QtUI/EventViewer/QtEvent.cpp b/Swift/QtUI/EventViewer/QtEvent.cpp
index 3c6f16c..c3ff944 100644
--- a/Swift/QtUI/EventViewer/QtEvent.cpp
+++ b/Swift/QtUI/EventViewer/QtEvent.cpp
@@ -7,6 +7,7 @@
#include "Swift/QtUI/EventViewer/QtEvent.h"
#include <QDateTime>
+#include <QColor>
#include "Swift/Controllers/XMPPEvents/MessageEvent.h"
#include "Swift/Controllers/XMPPEvents/ErrorEvent.h"
@@ -25,8 +26,8 @@ QVariant QtEvent::data(int role) {
switch (role) {
case Qt::ToolTipRole: return QVariant(text()).toString() + "\n" + B2QDATE(event_->getTime()).toString();
case Qt::DisplayRole: return QVariant(text());
- case Qt::TextColorRole: return active_ ? Qt::black : Qt::darkGray;
- case Qt::BackgroundColorRole: return active_ ? Qt::white : Qt::lightGray;
+ case Qt::TextColorRole: return QColor(active_ ? Qt::black : Qt::darkGray);
+ case Qt::BackgroundColorRole: return QColor(active_ ? Qt::white : Qt::lightGray);
case SenderRole: return QVariant(sender());
/*case StatusTextRole: return statusText_;
case AvatarRole: return avatar_;
diff --git a/Swift/QtUI/EventViewer/QtEvent.h b/Swift/QtUI/EventViewer/QtEvent.h
index f5e3dee..11efd60 100644
--- a/Swift/QtUI/EventViewer/QtEvent.h
+++ b/Swift/QtUI/EventViewer/QtEvent.h
@@ -17,7 +17,7 @@ namespace Swift {
public:
QtEvent(boost::shared_ptr<StanzaEvent> event, bool active);
QVariant data(int role);
- boost::shared_ptr<StanzaEvent> getEvent() { return event_; };
+ boost::shared_ptr<StanzaEvent> getEvent() { return event_; }
enum EventRoles {
SenderRole = Qt::UserRole