summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/Roster')
-rw-r--r--Swift/QtUI/Roster/QtOccupantListWidget.cpp15
-rw-r--r--Swift/QtUI/Roster/QtOccupantListWidget.h11
-rw-r--r--Swift/QtUI/Roster/QtRosterWidget.cpp2
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.cpp30
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.h22
-rw-r--r--Swift/QtUI/Roster/RosterModel.cpp12
-rw-r--r--Swift/QtUI/Roster/RosterModel.h6
7 files changed, 69 insertions, 29 deletions
diff --git a/Swift/QtUI/Roster/QtOccupantListWidget.cpp b/Swift/QtUI/Roster/QtOccupantListWidget.cpp
index 12dc1e4..4f1baf3 100644
--- a/Swift/QtUI/Roster/QtOccupantListWidget.cpp
+++ b/Swift/QtUI/Roster/QtOccupantListWidget.cpp
@@ -1,3 +1,3 @@
/*
- * Copyright (c) 2011-2012 Kevin Smith
+ * Copyright (c) 2011-2014 Kevin Smith
* Licensed under the GNU General Public License v3.
@@ -7,3 +7,3 @@
-#include "Roster/QtOccupantListWidget.h"
+#include <Swift/QtUI/Roster/QtOccupantListWidget.h>
@@ -14,6 +14,7 @@
-#include "Swift/Controllers/Roster/ContactRosterItem.h"
-#include "Swift/Controllers/Roster/GroupRosterItem.h"
-#include "Swift/Controllers/UIEvents/UIEventStream.h"
-#include "QtSwiftUtil.h"
+#include <Swift/Controllers/Roster/ContactRosterItem.h>
+#include <Swift/Controllers/Roster/GroupRosterItem.h>
+#include <Swift/Controllers/UIEvents/UIEventStream.h>
+
+#include <Swift/QtUI/QtSwiftUtil.h>
@@ -21,3 +22,3 @@ namespace Swift {
-QtOccupantListWidget::QtOccupantListWidget(UIEventStream* eventStream, SettingsProvider* settings, QWidget* parent) : QtTreeWidget(eventStream, settings, parent) {
+QtOccupantListWidget::QtOccupantListWidget(UIEventStream* eventStream, SettingsProvider* settings, MessageTarget privateMessageTarget, QWidget* parent) : QtTreeWidget(eventStream, settings, privateMessageTarget, parent) {
diff --git a/Swift/QtUI/Roster/QtOccupantListWidget.h b/Swift/QtUI/Roster/QtOccupantListWidget.h
index 729115a..c944658 100644
--- a/Swift/QtUI/Roster/QtOccupantListWidget.h
+++ b/Swift/QtUI/Roster/QtOccupantListWidget.h
@@ -1,3 +1,3 @@
/*
- * Copyright (c) 2011-2012 Kevin Smith
+ * Copyright (c) 2011-2014 Kevin Smith
* Licensed under the GNU General Public License v3.
@@ -8,6 +8,7 @@
-#include "Swift/QtUI/Roster/QtTreeWidget.h"
+#include <Swift/QtUI/Roster/QtTreeWidget.h>
-#include "Swiften/Base/boost_bsignals.h"
-#include "Swift/Controllers/UIInterfaces/ChatWindow.h"
+#include <Swiften/Base/boost_bsignals.h>
+
+#include <Swift/Controllers/UIInterfaces/ChatWindow.h>
@@ -19,3 +20,3 @@ class QtOccupantListWidget : public QtTreeWidget {
public:
- QtOccupantListWidget(UIEventStream* eventStream, SettingsProvider* settings, QWidget* parent = 0);
+ QtOccupantListWidget(UIEventStream* eventStream, SettingsProvider* settings, MessageTarget privateMessageTarget, QWidget* parent = NULL);
virtual ~QtOccupantListWidget();
diff --git a/Swift/QtUI/Roster/QtRosterWidget.cpp b/Swift/QtUI/Roster/QtRosterWidget.cpp
index 1436c7c..fff0ccd 100644
--- a/Swift/QtUI/Roster/QtRosterWidget.cpp
+++ b/Swift/QtUI/Roster/QtRosterWidget.cpp
@@ -30,3 +30,3 @@ namespace Swift {
-QtRosterWidget::QtRosterWidget(UIEventStream* eventStream, SettingsProvider* settings, QWidget* parent) : QtTreeWidget(eventStream, settings, parent) {
+QtRosterWidget::QtRosterWidget(UIEventStream* eventStream, SettingsProvider* settings, QWidget* parent) : QtTreeWidget(eventStream, settings, MessageDefaultJID, parent) {
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp
index 91e9a33..ed76a6f 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidget.cpp
@@ -28,3 +28,3 @@
#include <Swift/QtUI/QtUISettingConstants.h>
-
+#include <Swift/QtUI/Roster/RosterModel.h>
#include <QtSwiftUtil.h>
@@ -33,3 +33,3 @@ namespace Swift {
-QtTreeWidget::QtTreeWidget(UIEventStream* eventStream, SettingsProvider* settings, QWidget* parent) : QTreeView(parent), tooltipShown_(false) {
+QtTreeWidget::QtTreeWidget(UIEventStream* eventStream, SettingsProvider* settings, MessageTarget messageTarget, QWidget* parent) : QTreeView(parent), messageTarget_(messageTarget), tooltipShown_(false) {
eventStream_ = eventStream;
@@ -139,8 +139,20 @@ void QtTreeWidget::currentChanged(const QModelIndex& current, const QModelIndex&
-
void QtTreeWidget::handleItemActivated(const QModelIndex& index) {
- RosterItem* item = static_cast<RosterItem*>(index.internalPointer());
- ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
- if (contact) {
- eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(contact->getJID())));
+ switch (messageTarget_) {
+ case MessageDisplayJID: {
+ QString indexJID = index.data(DisplayJIDRole).toString();
+ if (!indexJID.isEmpty()) {
+ JID target = JID(Q2PSTRING(indexJID)).toBare();
+ eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(target)));
+ break;
+ }
+ }
+ case MessageDefaultJID: {
+ QString indexJID = index.data(JIDRole).toString();
+ if (!indexJID.isEmpty()) {
+ JID target = JID(Q2PSTRING(indexJID));
+ eventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(target)));
+ }
+ break;
+ }
}
@@ -232,2 +244,6 @@ void QtTreeWidget::show() {
+void QtTreeWidget::setMessageTarget(MessageTarget messageTarget) {
+ messageTarget_ = messageTarget;
+}
+
}
diff --git a/Swift/QtUI/Roster/QtTreeWidget.h b/Swift/QtUI/Roster/QtTreeWidget.h
index 8884a40..29e985d 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.h
+++ b/Swift/QtUI/Roster/QtTreeWidget.h
@@ -1,3 +1,3 @@
/*
- * Copyright (c) 2010-2012 Kevin Smith
+ * Copyright (c) 2010-2014 Kevin Smith
* Licensed under the GNU General Public License v3.
@@ -8,4 +8,2 @@
-#include <QTreeView>
-#include <QModelIndex>
#include <QDragEnterEvent>
@@ -13,5 +11,9 @@
#include <QDragMoveEvent>
+#include <QModelIndex>
+#include <QTreeView>
-#include <Swift/QtUI/Roster/RosterModel.h>
#include <Swift/QtUI/Roster/RosterDelegate.h>
+#include <Swift/QtUI/Roster/RosterModel.h>
+
+#include <Swift/Controllers/UIInterfaces/ChatWindow.h>
@@ -21,6 +23,8 @@ class SettingsProvider;
-class QtTreeWidget : public QTreeView{
+class QtTreeWidget : public QTreeView {
Q_OBJECT
public:
- QtTreeWidget(UIEventStream* eventStream, SettingsProvider* settings, QWidget* parent = 0);
+ enum MessageTarget {MessageDefaultJID, MessageDisplayJID};
+
+ QtTreeWidget(UIEventStream* eventStream, SettingsProvider* settings, MessageTarget messageTarget, QWidget* parent = 0);
~QtTreeWidget();
@@ -31,2 +35,4 @@ class QtTreeWidget : public QTreeView{
void refreshTooltip();
+ void setMessageTarget(MessageTarget messageTarget);
+ public:
boost::signal<void (RosterItem*)> onSomethingSelectedChanged;
@@ -47,5 +53,4 @@ class QtTreeWidget : public QTreeView{
bool event(QEvent* event);
-
- protected:
QModelIndexList getSelectedIndexes() const;
+
private:
@@ -65,2 +70,3 @@ class QtTreeWidget : public QTreeView{
bool tooltipShown_;
+ MessageTarget messageTarget_;
};
diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp
index fa8c393..2bd0d09 100644
--- a/Swift/QtUI/Roster/RosterModel.cpp
+++ b/Swift/QtUI/Roster/RosterModel.cpp
@@ -104,2 +104,4 @@ QVariant RosterModel::data(const QModelIndex& index, int role) const {
case IdleRole: return getIsIdle(item);
+ case JIDRole: return getJID(item);
+ case DisplayJIDRole: return getDisplayJID(item);
default: return QVariant();
@@ -183,2 +185,12 @@ QString RosterModel::getStatusText(RosterItem* item) const {
+QString RosterModel::getJID(RosterItem* item) const {
+ ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
+ return contact ? P2QSTRING(contact->getJID().toString()) : QString();
+}
+
+QString RosterModel::getDisplayJID(RosterItem* item) const {
+ ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item);
+ return contact ? P2QSTRING(contact->getDisplayJID().toString()) : QString();
+}
+
QIcon RosterModel::getPresenceIcon(RosterItem* item) const {
diff --git a/Swift/QtUI/Roster/RosterModel.h b/Swift/QtUI/Roster/RosterModel.h
index 7f6cdd2..2b05044 100644
--- a/Swift/QtUI/Roster/RosterModel.h
+++ b/Swift/QtUI/Roster/RosterModel.h
@@ -22,3 +22,5 @@ namespace Swift {
ChildCountRole = Qt::UserRole + 4,
- IdleRole = Qt::UserRole + 5
+ IdleRole = Qt::UserRole + 5,
+ JIDRole = Qt::UserRole + 6,
+ DisplayJIDRole = Qt::UserRole + 7
};
@@ -54,2 +56,4 @@ namespace Swift {
QString getStatusText(RosterItem* item) const;
+ QString getJID(RosterItem* item) const;
+ QString getDisplayJID(RosterItem* item) const;
QIcon getPresenceIcon(RosterItem* item) const;