diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-03-21 22:33:09 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-03-22 14:54:54 (GMT) |
commit | f5c2750f56c78d115bb9e8a7c5d50316da98b6d5 (patch) | |
tree | 661c761e7ebb526e1d71848c127046605e036729 /Swift/QtUI/EventViewer/EventModel.cpp | |
parent | 37a3ff6afe96c39bbf075d05da72e5f2c684dfa4 (diff) | |
download | swift-contrib-f5c2750f56c78d115bb9e8a7c5d50316da98b6d5.zip swift-contrib-f5c2750f56c78d115bb9e8a7c5d50316da98b6d5.tar.bz2 |
Lots of plumbing for event view.
This isn't ready yet, but clicking on a message in the event view will now cause the chat to pop up, and the plumbing is there for doing something with subscription requests - I just don't, yet.
Diffstat (limited to 'Swift/QtUI/EventViewer/EventModel.cpp')
-rw-r--r-- | Swift/QtUI/EventViewer/EventModel.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Swift/QtUI/EventViewer/EventModel.cpp b/Swift/QtUI/EventViewer/EventModel.cpp index f75fe74..902004b 100644 --- a/Swift/QtUI/EventViewer/EventModel.cpp +++ b/Swift/QtUI/EventViewer/EventModel.cpp @@ -16,14 +16,16 @@ EventModel::~EventModel() { } } +QtEvent* EventModel::getItem(int row) const { + return row < activeEvents_.size() ? activeEvents_[row] : inactiveEvents_[row - activeEvents_.size()]; +} + QVariant EventModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) { return QVariant(); } - int row = index.row(); - QtEvent* item = index.row() < activeEvents_.size() ? activeEvents_[row] : inactiveEvents_[row - activeEvents_.size()]; + QtEvent* item = getItem(index.row()); QVariant result = item ? item->data(role) : QVariant(); - qDebug() << "Asked for data of " << index << ", " << role << " returning " << result; return result; } @@ -33,8 +35,7 @@ int EventModel::rowCount(const QModelIndex& parent) const { return count; } -void EventModel::addEvent(boost::shared_ptr<Event> event, bool active) { - qDebug() << " Adding Event"; +void EventModel::addEvent(boost::shared_ptr<StanzaEvent> event, bool active) { if (active) { activeEvents_.push_front(new QtEvent(event, active)); emit dataChanged(createIndex(0, 0), createIndex(1, 0)); @@ -48,7 +49,7 @@ void EventModel::addEvent(boost::shared_ptr<Event> event, bool active) { emit layoutChanged(); } -void EventModel::removeEvent(boost::shared_ptr<Event> event) { +void EventModel::removeEvent(boost::shared_ptr<StanzaEvent> event) { for (int i = inactiveEvents_.size() - 1; i >= 0; i--) { if (event == inactiveEvents_[i]->getEvent()) { inactiveEvents_.removeAt(i); |