diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-04-25 21:09:05 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-04-25 21:09:05 +0000 |
| commit | e13073c4357b2b85eba8a015f38e9f69f4d1799c (patch) | |
| tree | c301321da7066a8722469947f024b60a382ca77b /pokemodr/PokemodTreeModel.cpp | |
| parent | 74c06767a1a698705e8c486d77ccf11838c87a4d (diff) | |
| download | sigen-e13073c4357b2b85eba8a015f38e9f69f4d1799c.tar.gz sigen-e13073c4357b2b85eba8a015f38e9f69f4d1799c.tar.xz sigen-e13073c4357b2b85eba8a015f38e9f69f4d1799c.zip | |
[FIX] Drag/Drop should work (in theory)
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@109 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/PokemodTreeModel.cpp')
| -rw-r--r-- | pokemodr/PokemodTreeModel.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/pokemodr/PokemodTreeModel.cpp b/pokemodr/PokemodTreeModel.cpp index c2abd9a3..a06f9af9 100644 --- a/pokemodr/PokemodTreeModel.cpp +++ b/pokemodr/PokemodTreeModel.cpp @@ -15,6 +15,9 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +// Qt includes +#include <QMimeData> + // Header include #include "PokemodTreeModel.h" @@ -130,4 +133,30 @@ BaseModel* PokemodTreeModel::getItem(const QModelIndex& index) const return m_root; } +QStringList PokemodTreeModel::mimeTypes() const +{ + return QStringList() << "application/x-pokemod+xml"; +} +QMimeData* PokemodTreeModel::mimeData(const QModelIndexList& indexes) const +{ + QMimeData *mimeData = new QMimeData(); + if ((indexes.size() == 1) && indexes[0].isValid()) + { + QDomDocument xml; + xml.setContent(data(indexes[0], BaseModel::XmlRole).toString()); + mimeData->setData("application/x-pokemod+xml", xml.toByteArray()); + } + return mimeData; +} + +bool PokemodTreeModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) +{ + if (action == Qt::IgnoreAction) + return true; + if (!data->hasFormat("application/x-pokemod+xml")) + return false; + if (parent.isValid()) + return setData(parent, data->data("application/x-pokemod+xml"), BaseModel::XmlRole); + return m_root->setData(data->data("application/x-pokemod+xml"), BaseModel::XmlRole); +} |
