diff options
author | Tobias Markmann <tm@ayena.de> | 2015-07-09 08:30:11 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2015-07-10 14:00:16 (GMT) |
commit | 7af21fdd59af3b3112cff69996301605859af84c (patch) | |
tree | 5a1c79ac5d8c3a5521b098f68ae6c190a291455c /Swift/QtUI/EventViewer | |
parent | a23d903d67f05257f0e9376a212b83045ea768f1 (diff) | |
download | swift-7af21fdd59af3b3112cff69996301605859af84c.zip swift-7af21fdd59af3b3112cff69996301605859af84c.tar.bz2 |
Create notice events for incoming file-transfers
Test-Information:
Send a file from one Swift instance to another. The UX is similar to
that of a MUC invite, clicking the notice will bring the relevant chat
in front.
Change-Id: Ief3cd7371ae01b2b38b6d1af36189df961eacef4
Diffstat (limited to 'Swift/QtUI/EventViewer')
-rw-r--r-- | Swift/QtUI/EventViewer/EventDelegate.cpp | 26 | ||||
-rw-r--r-- | Swift/QtUI/EventViewer/EventDelegate.h | 9 | ||||
-rw-r--r-- | Swift/QtUI/EventViewer/QtEvent.cpp | 24 | ||||
-rw-r--r-- | Swift/QtUI/EventViewer/QtEventWindow.cpp | 28 |
4 files changed, 57 insertions, 30 deletions
diff --git a/Swift/QtUI/EventViewer/EventDelegate.cpp b/Swift/QtUI/EventViewer/EventDelegate.cpp index 7bbfee2..cd657b8 100644 --- a/Swift/QtUI/EventViewer/EventDelegate.cpp +++ b/Swift/QtUI/EventViewer/EventDelegate.cpp @@ -1,21 +1,27 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ -#include "EventDelegate.h" +#include <Swift/QtUI/EventViewer/EventDelegate.h> #include <QDebug> -#include "Swift/Controllers/XMPPEvents/MessageEvent.h" -#include "Swift/Controllers/XMPPEvents/ErrorEvent.h" -#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h" -#include "Swift/Controllers/XMPPEvents/MUCInviteEvent.h" +#include <Swift/Controllers/XMPPEvents/ErrorEvent.h> +#include <Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h> +#include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h> +#include <Swift/Controllers/XMPPEvents/MessageEvent.h> +#include <Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h> namespace Swift { -EventDelegate::EventDelegate() : QStyledItemDelegate(), messageDelegate_(QtEvent::SenderRole, Qt::DisplayRole, false), subscriptionDelegate_(QtEvent::SenderRole, Qt::DisplayRole, true), errorDelegate_(QtEvent::SenderRole, Qt::DisplayRole, true), mucInviteDelegate_(QtEvent::SenderRole, Qt::DisplayRole, false) { +EventDelegate::EventDelegate() : QStyledItemDelegate(), + messageDelegate_(QtEvent::SenderRole, Qt::DisplayRole, false), + subscriptionDelegate_(QtEvent::SenderRole, Qt::DisplayRole, true), + errorDelegate_(QtEvent::SenderRole, Qt::DisplayRole, true), + mucInviteDelegate_(QtEvent::SenderRole, Qt::DisplayRole, false), + incomingFileTransferDelegate_(QtEvent::SenderRole, Qt::DisplayRole, false) { } @@ -29,6 +35,7 @@ QSize EventDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIn case SubscriptionEventType: return subscriptionDelegate_.sizeHint(option, item); case ErrorEventType: return errorDelegate_.sizeHint(option, item); case MUCInviteEventType: return mucInviteDelegate_.sizeHint(option, item); + case IncomingFileTransferEventType: return incomingFileTransferDelegate_.sizeHint(option, item); } assert(false); return QSize(); @@ -45,6 +52,7 @@ void EventDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, case SubscriptionEventType: subscriptionDelegate_.paint(painter, option, item);break; case ErrorEventType: errorDelegate_.paint(painter, option, item);break; case MUCInviteEventType: mucInviteDelegate_.paint(painter, option, item);break; + case IncomingFileTransferEventType: incomingFileTransferDelegate_.paint(painter, option, item);break; } } @@ -65,6 +73,10 @@ EventType EventDelegate::getEventType(boost::shared_ptr<StanzaEvent> event) cons if (mucInviteEvent) { return MUCInviteEventType; } + boost::shared_ptr<IncomingFileTransferEvent> incomingFileTransferEvent = boost::dynamic_pointer_cast<IncomingFileTransferEvent>(event); + if (incomingFileTransferEvent) { + return IncomingFileTransferEventType; + } //I don't know what this is. assert(false); return MessageEventType; diff --git a/Swift/QtUI/EventViewer/EventDelegate.h b/Swift/QtUI/EventViewer/EventDelegate.h index f5dd196..6ab96e4 100644 --- a/Swift/QtUI/EventViewer/EventDelegate.h +++ b/Swift/QtUI/EventViewer/EventDelegate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -8,11 +8,11 @@ #include <QStyledItemDelegate> -#include "Swift/QtUI/Roster/DelegateCommons.h" -#include "Swift/QtUI/EventViewer/TwoLineDelegate.h" +#include <Swift/QtUI/EventViewer/TwoLineDelegate.h> +#include <Swift/QtUI/Roster/DelegateCommons.h> namespace Swift { - enum EventType {MessageEventType, SubscriptionEventType, ErrorEventType, MUCInviteEventType}; + enum EventType {MessageEventType, SubscriptionEventType, ErrorEventType, MUCInviteEventType, IncomingFileTransferEventType}; class EventDelegate : public QStyledItemDelegate { Q_OBJECT public: @@ -26,6 +26,7 @@ namespace Swift { TwoLineDelegate subscriptionDelegate_; TwoLineDelegate errorDelegate_; TwoLineDelegate mucInviteDelegate_; + TwoLineDelegate incomingFileTransferDelegate_; }; } diff --git a/Swift/QtUI/EventViewer/QtEvent.cpp b/Swift/QtUI/EventViewer/QtEvent.cpp index a84a440..4d90bd9 100644 --- a/Swift/QtUI/EventViewer/QtEvent.cpp +++ b/Swift/QtUI/EventViewer/QtEvent.cpp @@ -1,18 +1,19 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ -#include "Swift/QtUI/EventViewer/QtEvent.h" +#include <Swift/QtUI/EventViewer/QtEvent.h> -#include <QDateTime> #include <QColor> +#include <QDateTime> -#include "Swift/Controllers/XMPPEvents/MessageEvent.h" -#include "Swift/Controllers/XMPPEvents/ErrorEvent.h" -#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h" -#include "Swift/Controllers/XMPPEvents/MUCInviteEvent.h" +#include <Swift/Controllers/XMPPEvents/ErrorEvent.h> +#include <Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h> +#include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h> +#include <Swift/Controllers/XMPPEvents/MessageEvent.h> +#include <Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h> #include "Swift/QtUI/QtSwiftUtil.h" @@ -53,6 +54,10 @@ QString QtEvent::sender() { if (mucInviteEvent) { return P2QSTRING(mucInviteEvent->getInviter().toString()); } + boost::shared_ptr<IncomingFileTransferEvent> incomingFTEvent = boost::dynamic_pointer_cast<IncomingFileTransferEvent>(event_); + if (incomingFTEvent) { + return P2QSTRING(incomingFTEvent->getSender().toString()); + } return ""; } @@ -82,6 +87,11 @@ QString QtEvent::text() { QString message = QString(QObject::tr("%1 has invited you to enter the %2 room.")).arg(P2QSTRING(mucInviteEvent->getInviter().toBare().toString())).arg(P2QSTRING(mucInviteEvent->getRoomJID().toString())); return message; } + boost::shared_ptr<IncomingFileTransferEvent> incomingFTEvent = boost::dynamic_pointer_cast<IncomingFileTransferEvent>(event_); + if (incomingFTEvent) { + QString message = QString(QObject::tr("%1 would like to send a file to you.")).arg(P2QSTRING(incomingFTEvent->getSender().toBare().toString())); + return message; + } return ""; } diff --git a/Swift/QtUI/EventViewer/QtEventWindow.cpp b/Swift/QtUI/EventViewer/QtEventWindow.cpp index 3072497..f92cd07 100644 --- a/Swift/QtUI/EventViewer/QtEventWindow.cpp +++ b/Swift/QtUI/EventViewer/QtEventWindow.cpp @@ -1,27 +1,27 @@ - /* * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ -#include "Swift/QtUI/EventViewer/QtEventWindow.h" +#include <Swift/QtUI/EventViewer/QtEventWindow.h> -#include <QtDebug> #include <QBoxLayout> -#include <QPushButton> #include <QMessageBox> +#include <QPushButton> +#include <QtDebug> -#include "Swift/Controllers/XMPPEvents/MessageEvent.h" -#include "Swift/Controllers/XMPPEvents/ErrorEvent.h" -#include "Swift/QtUI/QtSubscriptionRequestWindow.h" -#include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h" -#include "Swift/Controllers/XMPPEvents/MUCInviteEvent.h" -#include "Swift/Controllers/UIEvents/RequestChatUIEvent.h" -#include "Swift/Controllers/UIEvents/JoinMUCUIEvent.h" +#include <Swiften/Base/Platform.h> +#include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h> +#include <Swift/Controllers/UIEvents/RequestChatUIEvent.h> +#include <Swift/Controllers/XMPPEvents/ErrorEvent.h> +#include <Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h> +#include <Swift/Controllers/XMPPEvents/MUCInviteEvent.h> +#include <Swift/Controllers/XMPPEvents/MessageEvent.h> +#include <Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h> -#include "Swiften/Base/Platform.h" +#include <Swift/QtUI/QtSubscriptionRequestWindow.h> namespace Swift { @@ -76,6 +76,7 @@ void QtEventWindow::handleItemActivated(const QModelIndex& item) { boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(event->getEvent()); boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(event->getEvent()); boost::shared_ptr<MUCInviteEvent> mucInviteEvent = boost::dynamic_pointer_cast<MUCInviteEvent>(event->getEvent()); + boost::shared_ptr<IncomingFileTransferEvent> incomingFTEvent = boost::dynamic_pointer_cast<IncomingFileTransferEvent>(event->getEvent()); boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(event->getEvent()); if (messageEvent) { @@ -90,6 +91,9 @@ void QtEventWindow::handleItemActivated(const QModelIndex& item) { } else if (mucInviteEvent) { eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(mucInviteEvent->getInviter()))); mucInviteEvent->conclude(); + } else if (incomingFTEvent) { + eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(incomingFTEvent->getSender()))); + incomingFTEvent->conclude(); } else { if (errorEvent) { errorEvent->conclude(); |