summaryrefslogtreecommitdiffstats
path: root/ksysv/ksvdrag.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
commit37333bf25ad9a4c538250f5af2f9f1d666362883 (patch)
treec45e8df5b9efbffe07eb3d9340df7811c7e16943 /ksysv/ksvdrag.cpp
downloadtdeadmin-37333bf25ad9a4c538250f5af2f9f1d666362883.tar.gz
tdeadmin-37333bf25ad9a4c538250f5af2f9f1d666362883.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/kdeadmin@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksysv/ksvdrag.cpp')
-rw-r--r--ksysv/ksvdrag.cpp102
1 files changed, 102 insertions, 0 deletions
diff --git a/ksysv/ksvdrag.cpp b/ksysv/ksvdrag.cpp
new file mode 100644
index 0000000..1f24417
--- /dev/null
+++ b/ksysv/ksvdrag.cpp
@@ -0,0 +1,102 @@
+// (c) 2000 Peter Putzer
+
+#include <qstring.h>
+#include <qcstring.h>
+
+#include <kurl.h>
+
+#include "Data.h"
+#include "ksvdraglist.h"
+#include "ksvdrag.h"
+
+class KSVDrag::Private
+{
+public:
+ QByteArray mNative;
+ QString mText;
+ KURL mURL;
+};
+
+KSVDrag::KSVDrag (const KSVData& item, QWidget* source, const char* name)
+ : QDragObject (source, name),
+ d (new Private())
+{
+ QDataStream ds (d->mNative, IO_ReadWrite);
+ ds << item;
+
+ d->mText = item.filenameAndPath ();
+ d->mURL.setPath (item.path() + "/" + item.filename());
+}
+
+KSVDrag::KSVDrag (const KSVItem& item, QWidget* source, const char* name)
+ : QDragObject (source, name),
+ d (new Private())
+{
+ QDataStream ds (d->mNative, IO_ReadWrite);
+ ds << *item.data();
+
+ d->mText = item.toString();
+ d->mURL.setPath (item.path() + "/" + item.filename());
+}
+
+KSVDrag::~KSVDrag ()
+{
+ delete d;
+}
+
+const char* KSVDrag::format (int i) const
+{
+ switch (i)
+ {
+ case Native:
+ return "application/x-ksysv";
+ break;
+
+ case Text:
+ return "text/plain";
+ break;
+
+ case URL:
+ return "text/uri-list";
+ break;
+
+ default:
+ return 0L;
+ }
+}
+
+QByteArray KSVDrag::encodedData (const char* format) const
+{
+ QByteArray res;
+
+ if (!strcmp (format, "application/x-ksysv"))
+ {
+ res = d->mNative;
+ }
+ else if (!strcmp (format, "text/plain"))
+ {
+ QDataStream ds (res, IO_ReadWrite);
+ ds << d->mText;
+ }
+ else if (!strcmp (format, "text/uri-list"))
+ {
+ res = QCString(d->mURL.url().latin1()).copy();
+ }
+
+ return res;
+}
+
+bool KSVDrag::decodeNative (const QMimeSource* mime, KSVData& data)
+{
+ if (mime && mime->provides ("application/x-ksysv"))
+ {
+ QDataStream ds (mime->encodedData ("application/x-ksysv"), IO_ReadOnly);
+ ds >> data;
+
+ return true;
+ }
+
+ return false;
+}
+
+#include "ksvdrag.moc"