diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-04-25 19:06:47 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-04-25 19:06:47 +0000 |
| commit | 74c06767a1a698705e8c486d77ccf11838c87a4d (patch) | |
| tree | 34519f082aac35aef9321756e0a3dce0a87c5419 /pokemodr/models/CoinListModel.cpp | |
| parent | dd643ee61d9166761c50803cd379c9343099385c (diff) | |
| download | sigen-74c06767a1a698705e8c486d77ccf11838c87a4d.tar.gz sigen-74c06767a1a698705e8c486d77ccf11838c87a4d.tar.xz sigen-74c06767a1a698705e8c486d77ccf11838c87a4d.zip | |
[FIX] Cleaner setting of model data
[FIX] Fleshed out the GroupModel classes for Pokemod
[FIX] Tree for pokemod is now draggable
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@108 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/models/CoinListModel.cpp')
| -rw-r--r-- | pokemodr/models/CoinListModel.cpp | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/pokemodr/models/CoinListModel.cpp b/pokemodr/models/CoinListModel.cpp index 483fdc20..fcbadf4b 100644 --- a/pokemodr/models/CoinListModel.cpp +++ b/pokemodr/models/CoinListModel.cpp @@ -65,32 +65,11 @@ bool CoinListModel::setData(const QVariant& value, int role) { if (role == Qt::UserRole) { - if (value.canConvert<void*>()) - { - clearData(); - *static_cast<CoinList*>(m_object) = *static_cast<CoinList*>(value.value<void*>()); - setupData(); - return true; - } - else if (value.canConvert<QString>()) + if (value.canConvert<QString>()) { QFile file(value.toString()); QDomDocument xml; - if (file.open(QIODevice::ReadOnly)) - { - if (xml.setContent(&file)) - { - if (xml.doctype().name() == m_object->className()) - { - clearData(); - m_object->load(xml.documentElement()); - setupData(); - return true; - } - } - file.close(); - } - else if (xml.setContent(value.toString())) + if ((file.open(QIODevice::ReadOnly) && xml.setContent(&file)) || xml.setContent(value.toString())) { if (xml.doctype().name() == m_object->className()) { @@ -99,6 +78,7 @@ bool CoinListModel::setData(const QVariant& value, int role) setupData(); return true; } + file.close(); } } } |
