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/QtEventWindow.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/QtEventWindow.cpp')
-rw-r--r-- | Swift/QtUI/EventViewer/QtEventWindow.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/Swift/QtUI/EventViewer/QtEventWindow.cpp b/Swift/QtUI/EventViewer/QtEventWindow.cpp index fda957d..91eb2c1 100644 --- a/Swift/QtUI/EventViewer/QtEventWindow.cpp +++ b/Swift/QtUI/EventViewer/QtEventWindow.cpp @@ -1,10 +1,17 @@ #include "Swift/QtUI/EventViewer/QtEventWindow.h" +#include <qdebug> + +#include "Swiften/Events/MessageEvent.h" +#include "Swiften/Events/SubscriptionRequestEvent.h" +#include "Swift/Controllers/UIEvents/RequestChatUIEvent.h" + #include "Swiften/Base/Platform.h" namespace Swift { -QtEventWindow::QtEventWindow(QWidget* parent) : QTreeView(parent) { +QtEventWindow::QtEventWindow(UIEventStream* eventStream, QWidget* parent) : QTreeView(parent) { + eventStream_ = eventStream; model_ = new EventModel(); setModel(model_); delegate_ = new EventDelegate(); @@ -16,6 +23,7 @@ QtEventWindow::QtEventWindow(QWidget* parent) : QTreeView(parent) { setAnimated(true); setIndentation(0); setRootIsDecorated(true); + connect(this, SIGNAL(activated(const QModelIndex&)), this, SLOT(handleItemActivated(const QModelIndex&))); } QtEventWindow::~QtEventWindow() { @@ -23,11 +31,27 @@ QtEventWindow::~QtEventWindow() { delete delegate_; } -void QtEventWindow::addEvent(boost::shared_ptr<Event> event, bool active) { +void QtEventWindow::handleItemActivated(const QModelIndex& item) { + QtEvent* event = model_->getItem(item.row()); + boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(event->getEvent()); + boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(event->getEvent()); + + if (messageEvent) { + eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(messageEvent->getStanza()->getFrom()))); + } else if (subscriptionEvent) { + printf("Subscription activated\n"); + //FIXME: do something + } else { + qWarning() << "Trying to activate an unexpected event"; + } + +} + +void QtEventWindow::addEvent(boost::shared_ptr<StanzaEvent> event, bool active) { model_->addEvent(event, active); } -void QtEventWindow::removeEvent(boost::shared_ptr<Event> event) { +void QtEventWindow::removeEvent(boost::shared_ptr<StanzaEvent> event) { model_->removeEvent(event); } |