summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/UserSearch/ContactListModel.cpp')
-rw-r--r--Swift/QtUI/UserSearch/ContactListModel.cpp43
1 files changed, 6 insertions, 37 deletions
diff --git a/Swift/QtUI/UserSearch/ContactListModel.cpp b/Swift/QtUI/UserSearch/ContactListModel.cpp
index 4c4a3ea..907142f 100644
--- a/Swift/QtUI/UserSearch/ContactListModel.cpp
+++ b/Swift/QtUI/UserSearch/ContactListModel.cpp
@@ -1,15 +1,21 @@
/*
* Copyright (c) 2013 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2014 Kevin Smith and Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
#include <Swift/QtUI/UserSearch/ContactListModel.h>
#include <QMimeData>
#include <Swiften/Base/Path.h>
#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/StatusShow.h>
#include <Swift/QtUI/QtSwiftUtil.h>
@@ -76,55 +82,18 @@ QVariant ContactListModel::data(const QModelIndex& index, int role) const {
if (role == Qt::EditRole) {
return P2QSTRING(contact.jid.toString());
}
return dataForContact(contact, role);
} else {
return QVariant();
}
}
-bool ContactListModel::dropMimeData(const QMimeData* data, Qt::DropAction /*action*/, int /*row*/, int /*column*/, const QModelIndex& /*parent*/) {
- if (!data->hasFormat("application/vnd.swift.contact-jid")) {
- return false;
- }
-
- QByteArray dataBytes = data->data("application/vnd.swift.contact-jid");
- QDataStream dataStream(&dataBytes, QIODevice::ReadOnly);
- QString jidString;
- QString displayName;
- QString statusText;
- StatusShow::Type statusType;
- QString avatarPath;
-
- dataStream >> jidString;
- dataStream >> displayName;
- dataStream >> statusText;
- dataStream >> statusType;
- dataStream >> avatarPath;
-
- JID jid = JID(Q2PSTRING(jidString));
-
- foreach(const Contact& contact, contacts_) {
- if (contact.jid == jid) {
- return false;
- }
- }
-
- emit layoutAboutToBeChanged();
- contacts_.push_back(Contact(Q2PSTRING(displayName), jid, statusType, Q2PSTRING(avatarPath)));
- emit layoutChanged();
-
- onJIDsDropped(std::vector<JID>(1, jid));
- onListChanged(getList());
-
- return true;
-}
-
QModelIndex ContactListModel::index(int row, int column, const QModelIndex& parent) const {
if (!hasIndex(row, column, parent)) {
return QModelIndex();
}
return boost::numeric_cast<size_t>(row) < contacts_.size() ? createIndex(row, column, (void*)&(contacts_[row])) : QModelIndex();
}
QModelIndex ContactListModel::parent(const QModelIndex& index) const {