diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-04-25 00:08:22 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-04-25 00:08:22 +0000 |
| commit | dd643ee61d9166761c50803cd379c9343099385c (patch) | |
| tree | 30d935e81896f3680d5d1c232669e180088d3f37 /pokemodr/models/AbilityEffectModel.cpp | |
| parent | 446fcd9248d4cef74e905c485ef767a94a8463ec (diff) | |
| download | sigen-dd643ee61d9166761c50803cd379c9343099385c.tar.gz sigen-dd643ee61d9166761c50803cd379c9343099385c.tar.xz sigen-dd643ee61d9166761c50803cd379c9343099385c.zip | |
[FIX] Fleshed out a lot more Model classes
[ADD] New intermediate classes for Objects with subclasses and those without
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@107 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/models/AbilityEffectModel.cpp')
| -rw-r--r-- | pokemodr/models/AbilityEffectModel.cpp | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/pokemodr/models/AbilityEffectModel.cpp b/pokemodr/models/AbilityEffectModel.cpp index dd52ec92..eb795b45 100644 --- a/pokemodr/models/AbilityEffectModel.cpp +++ b/pokemodr/models/AbilityEffectModel.cpp @@ -32,7 +32,6 @@ AbilityEffectModel::AbilityEffectModel(BaseModel* parent, Object* object) : AbilityEffectModel::~AbilityEffectModel() { - // TODO: destruct } QVariant AbilityEffectModel::data(int role) const @@ -41,25 +40,49 @@ QVariant AbilityEffectModel::data(int role) const return AbilityEffect::EffectStr[static_cast<AbilityEffect*>(m_object)->effect()]; else if (role == Qt::UserRole) { + // TODO: AbilityEffectUI // QWidget* widget = new AbilityEffectUI(static_cast<AbilityEffect*>(m_object), NULL); // return QVariant::fromValue(widget); } return QVariant(); } -int AbilityEffectModel::rowCount() const -{ - return 0; -} - bool AbilityEffectModel::setData(const QVariant& value, int role) { - // TODO: set data -} - -BaseModel* AbilityEffectModel::childItem(const int /*row*/) -{ - return NULL; + if (role == Qt::UserRole) + { + if (value.canConvert<void*>()) + { + *static_cast<AbilityEffect*>(m_object) = *static_cast<AbilityEffect*>(value.value<void*>()); + return true; + } + else 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()) + { + m_object->load(xml.documentElement()); + return true; + } + } + file.close(); + } + else if (xml.setContent(value.toString())) + { + if (xml.doctype().name() == m_object->className()) + { + m_object->load(xml.documentElement()); + return true; + } + } + } + } + return false; } int AbilityEffectModel::indexNumber() const @@ -67,26 +90,6 @@ int AbilityEffectModel::indexNumber() const // TODO: get effect index } -bool AbilityEffectModel::canInsertRows() const -{ - return false; -} - -bool AbilityEffectModel::insertRows(const int /*rows*/) -{ - return false; -} - -bool AbilityEffectModel::canRemoveRows() const -{ - return false; -} - -bool AbilityEffectModel::removeRows(const int /*position*/, const int /*rows*/) -{ - return false; -} - // bool AbilityEffectModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column) // { // // TODO: drag/drop |
