summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/Roster/RosterModel.cpp')
-rw-r--r--Swift/QtUI/Roster/RosterModel.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp
index 1b93047..3791ffa 100644
--- a/Swift/QtUI/Roster/RosterModel.cpp
+++ b/Swift/QtUI/Roster/RosterModel.cpp
@@ -10,6 +10,7 @@
#include <QColor>
#include <QIcon>
+#include <QMimeData>
#include <qdebug.h>
#include "Swiften/Elements/StatusShow.h"
@@ -55,7 +56,7 @@ void RosterModel::reLayout() {
void RosterModel::handleChildrenChanged(GroupRosterItem* /*group*/) {
reLayout();
-}
+}
void RosterModel::handleDataChanged(RosterItem* item) {
Q_ASSERT(item);
@@ -65,6 +66,14 @@ void RosterModel::handleDataChanged(RosterItem* item) {
}
}
+Qt::ItemFlags RosterModel::flags(const QModelIndex& index) const {
+ Qt::ItemFlags flags = QAbstractItemModel::flags(index);
+ if (dynamic_cast<GroupRosterItem*>(getItem(index)) == NULL) {
+ flags |= Qt::ItemIsDragEnabled;
+ }
+ return flags;
+}
+
int RosterModel::columnCount(const QModelIndex& /*parent*/) const {
return 1;
}
@@ -230,4 +239,25 @@ int RosterModel::rowCount(const QModelIndex& parent) const {
return count;
}
+QMimeData* RosterModel::mimeData(const QModelIndexList& indexes) const {
+ QMimeData* data = QAbstractItemModel::mimeData(indexes);
+
+ ContactRosterItem *item = dynamic_cast<ContactRosterItem*>(getItem(indexes.first()));
+ if (item == NULL) {
+ return data;
+ }
+
+ QByteArray itemData;
+ QDataStream dataStream(&itemData, QIODevice::WriteOnly);
+
+ // jid, chatName, activity, statusType, avatarPath
+ dataStream << P2QSTRING(item->getJID().toString());
+ dataStream << P2QSTRING(item->getDisplayName());
+ dataStream << P2QSTRING(item->getStatusText());
+ dataStream << item->getSimplifiedStatusShow();
+ dataStream << P2QSTRING(item->getAvatarPath().string());
+ data->setData("application/vnd.swift.contact-jid", itemData);
+ return data;
+}
+
}