diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-09-16 06:36:17 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-09-16 06:36:17 +0000 |
| commit | b5e31868dc0d4d5094752ab2dba127311434e66f (patch) | |
| tree | 9ffa57312ec216426059ec16d011865e4c1af72f /sigmodr/models/TrainerGroupModel.cpp | |
| parent | 0f0dbfb0395810c1c205a1dc10cf1f226669fd00 (diff) | |
| download | sigen-b5e31868dc0d4d5094752ab2dba127311434e66f.tar.gz sigen-b5e31868dc0d4d5094752ab2dba127311434e66f.tar.xz sigen-b5e31868dc0d4d5094752ab2dba127311434e66f.zip | |
[FIX] Refactored out some code to ObjectModel
[FIX] Drag and drop now accepts URLs
[FIX] The main window can now accept drops
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@265 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'sigmodr/models/TrainerGroupModel.cpp')
| -rw-r--r-- | sigmodr/models/TrainerGroupModel.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/sigmodr/models/TrainerGroupModel.cpp b/sigmodr/models/TrainerGroupModel.cpp index fbf45700..88fb98ef 100644 --- a/sigmodr/models/TrainerGroupModel.cpp +++ b/sigmodr/models/TrainerGroupModel.cpp @@ -28,9 +28,6 @@ // KDE includes #include <KMenu> -// Qt includes -#include <QtCore/QFile> - Sigmodr::TrainerGroupModel::TrainerGroupModel(BaseModel* parent, Sigmod::Sigmod* sigmod) : GroupModel(parent, sigmod, "Trainers") { @@ -57,18 +54,14 @@ bool Sigmodr::TrainerGroupModel::setData(const QVariant& value, int role) { if (role == Sigmodr::BaseModel::XmlRole) { - if (value.canConvert<QString>()) + QString data = value.toString(); + if (!data.isEmpty()) { - QFile file(value.toString()); QDomDocument xml; - if ((file.open(QIODevice::ReadOnly) && xml.setContent(&file)) || xml.setContent(value.toString())) + if (loadFromData(data, &xml) && (xml.doctype().name() == "Trainer")) { - if (xml.doctype().name() == "Trainer") - { - addObject(qobject_cast<Sigmod::Sigmod*>(m_object)->newTrainer(xml.documentElement())); - return true; - } - file.close(); + addObject(qobject_cast<Sigmod::Sigmod*>(m_object)->newTrainer(xml.documentElement())); + return true; } } } |
