summaryrefslogtreecommitdiffstats
path: root/pokemodr/models/MapGroupModel.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-05-26 17:48:19 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-05-26 17:48:19 +0000
commitc4a3724a2b981e8dbc20f5d319a80bf364f2c7b7 (patch)
tree4887d64b9941ce8460ba6adb8d96569835af24ae /pokemodr/models/MapGroupModel.cpp
parent9200ed0568719fc3ffbf9c1f2fd07a667097b875 (diff)
downloadsigen-c4a3724a2b981e8dbc20f5d319a80bf364f2c7b7.tar.gz
sigen-c4a3724a2b981e8dbc20f5d319a80bf364f2c7b7.tar.xz
sigen-c4a3724a2b981e8dbc20f5d319a80bf364f2c7b7.zip
[FIX] GroupModels will now add an item to itself if pasted to
[FIX] Actions are now correctly done git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@177 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/models/MapGroupModel.cpp')
-rw-r--r--pokemodr/models/MapGroupModel.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/pokemodr/models/MapGroupModel.cpp b/pokemodr/models/MapGroupModel.cpp
index cd65b202..70641808 100644
--- a/pokemodr/models/MapGroupModel.cpp
+++ b/pokemodr/models/MapGroupModel.cpp
@@ -25,6 +25,9 @@
#include "../../pokemod/Map.h"
#include "../../pokemod/Pokemod.h"
+// Qt includes
+#include <QFile>
+
// KDE includes
#include <KMenu>
@@ -50,6 +53,28 @@ QVariant MapGroupModel::data(const int role) const
return GroupModel::data(role);
}
+bool MapGroupModel::setData(const QVariant& value, int role)
+{
+ if (role == BaseModel::XmlRole)
+ {
+ if (value.canConvert<QString>())
+ {
+ QFile file(value.toString());
+ QDomDocument xml;
+ if ((file.open(QIODevice::ReadOnly) && xml.setContent(&file)) || xml.setContent(value.toString()))
+ {
+ if (xml.doctype().name() == "Map")
+ {
+ addObject(static_cast<Pokemod*>(m_object)->newMap(xml.documentElement()));
+ return true;
+ }
+ file.close();
+ }
+ }
+ }
+ return false;
+}
+
void MapGroupModel::addObject(Object* object)
{
if (!object)