summaryrefslogtreecommitdiffstats
path: root/quanta/parts/kafka/kafkadragobject.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite9ae80694875f869892f13f4fcaf1170a00dea41 (patch)
treeaa2f8d8a217e2d376224c8d46b7397b68d35de2d /quanta/parts/kafka/kafkadragobject.cpp
downloadtdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz
tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'quanta/parts/kafka/kafkadragobject.cpp')
-rw-r--r--quanta/parts/kafka/kafkadragobject.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/quanta/parts/kafka/kafkadragobject.cpp b/quanta/parts/kafka/kafkadragobject.cpp
new file mode 100644
index 00000000..652ea6f2
--- /dev/null
+++ b/quanta/parts/kafka/kafkadragobject.cpp
@@ -0,0 +1,90 @@
+/***************************************************************************
+ kafkadragobject.h
+ -------------------
+
+ copyright : (C) 2004 - Paulo Moura Guedes
+ email : moura@kdewebdev.org
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <kdebug.h>
+
+#include <qdom.h>
+#include <qtextstream.h>
+
+#include "kafkadragobject.h"
+#include "node.h"
+#include "kafkacommon.h" // for debug only
+
+char const* KafkaDragObject::m_mimetype = "application/kafka-nodeselection";
+
+KafkaDragObject::KafkaDragObject(Node const* item, QWidget* dragSource, const char* name)
+ : QStoredDrag(m_mimetype, dragSource, name), m_item(item)
+{
+ QDomDocument doc("KafkaSelection");
+ QString docstart = "<KafkaSelection/>";
+ doc.setContent(docstart);
+ QDomElement itemsElement = doc.createElement("Items");
+ doc.documentElement().appendChild(itemsElement);
+ //kdDebug(25001) << doc.toString() << endl;
+ item->save(itemsElement);
+ //QDataStream s(m_array, IO_WriteOnly);
+ QTextStream s(m_array, IO_WriteOnly);
+ s << doc.toString();
+ //s << "biltre";
+ /*
+ kdDebug(25001) << m_array.size() << endl;
+ kdDebug(25001) << doc.toString() << endl;
+ kdDebug(25001) << QString(m_array) << endl;
+ */
+ //setEncodedData(m_array);
+}
+
+KafkaDragObject::~KafkaDragObject()
+{}
+
+QByteArray KafkaDragObject::encodedData(const char* mimetype) const
+{
+ if(m_mimetype == mimetype)
+ return m_array;
+
+ return QByteArray();
+}
+
+Node const* KafkaDragObject::getItem() const
+{
+ return m_item;
+}
+
+bool KafkaDragObject::canDecode(QMimeSource *e)
+{
+ return e->provides(m_mimetype);
+}
+
+bool KafkaDragObject::decode(QMimeSource* e, Node* node)
+{
+ if(!node || !e->provides(m_mimetype))
+ return false;
+
+ QByteArray data = e->encodedData(m_mimetype);
+ //kdDebug(25001) << QString(data) << endl;
+ QDomDocument doc;
+ doc.setContent(data, false);
+ //kdDebug(25001) << doc.toString() << endl;
+ node->load(doc.documentElement().firstChild().toElement());
+
+ kdDebug(25001) << "Load: " << endl;
+ kafkaCommon::coutTree(node, 3);
+
+ return node;
+}
+
+#include "kafkadragobject.moc"