1
/* This file is part of the KDE project
2
Copyright (C) 2002, 2003 Joseph Wenninger <jowenn@kde.org>
3
Copyright (C) 2005 Jarosław Staniek <staniek@kde.org>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
21
#include "kexidragobjects.h"
23
#include <QDataStream>
24
#include <QStringList>
25
#include <QDragMoveEvent>
26
#include <QDomDocument>
31
bool KexiFieldDrag::canDecode(QDropEvent *e)
33
return e->mimeData()->hasFormat("kexi/fields");
36
bool KexiFieldDrag::decode(QDropEvent* e, QString *sourceMimeType,
37
QString *sourceName, QStringList *fields)
39
Q_ASSERT(sourceMimeType);
43
QByteArray payload(e->mimeData()->data("kexi/fields"));
44
if (payload.isEmpty()) {//try single
48
QDataStream stream1(&payload, QIODevice::ReadOnly);
50
stream1 >> *sourceMimeType;
51
stream1 >> *sourceName;
53
// qDebug() << "decoded:" << sourceMimeType<<"/"<<sourceName<<"/"<<fields;
59
KexiDataProviderDrag::KexiDataProviderDrag(const QString& sourceMimeType, const QString& sourceName,
63
QMimeData *mimedata = new QMimeData();
65
QDataStream stream1(&data, QIODevice::WriteOnly);
67
stream1 << sourceMimeType << sourceName;
68
mimedata->setData("kexi/dataprovider", data);
69
setMimeData(mimedata);
72
KexiDataProviderDrag::~KexiDataProviderDrag()
76
bool KexiDataProviderDrag::canDecode(QDragMoveEvent *e)
78
return e->mimeData()->hasFormat("kexi/dataprovider");
81
bool KexiDataProviderDrag::decode(QDropEvent* e, QString* sourceMimeType, QString *sourceName)
83
QByteArray payload = e->mimeData()->data("kexidataprovider");
84
if (payload.isEmpty()) {
88
QDataStream stream1(&payload, QIODevice::ReadOnly);
89
stream1 >> *sourceMimeType;
90
stream1 >> *sourceName;
91
// qDebug() << "decoded:" << sourceMimeType <<"/"<<sourceName;