summaryrefslogtreecommitdiffstats
path: root/pokemodr/PokemodTreeModel.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-09-05 20:41:05 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-09-05 20:41:05 +0000
commitb81f5bffa2772eb9bd3c67fb35485ab1ee2d96e7 (patch)
tree6609f31b1635d948cf7a216c7fea72cfb3c905a0 /pokemodr/PokemodTreeModel.cpp
parentb99ffef4aa68dd5f0af64de9aec0f610e267d8cc (diff)
downloadsigen-b81f5bffa2772eb9bd3c67fb35485ab1ee2d96e7.tar.gz
sigen-b81f5bffa2772eb9bd3c67fb35485ab1ee2d96e7.tar.xz
sigen-b81f5bffa2772eb9bd3c67fb35485ab1ee2d96e7.zip
[FIX] Moving stuff for the move to the new name, Sigma Game Engine (sigen for short)
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@249 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/PokemodTreeModel.cpp')
-rw-r--r--pokemodr/PokemodTreeModel.cpp159
1 files changed, 0 insertions, 159 deletions
diff --git a/pokemodr/PokemodTreeModel.cpp b/pokemodr/PokemodTreeModel.cpp
deleted file mode 100644
index 17d2af93..00000000
--- a/pokemodr/PokemodTreeModel.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2008 Ben Boeckel <MathStuf@gmail.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-// Header include
-#include "PokemodTreeModel.h"
-
-// Model includes
-#include "models/RootModel.h"
-
-// Qt includes
-#include <QtCore/QMimeData>
-#include <QtCore/QStringList>
-#include <QtXml/QDomDocument>
-
-Pokemodr::PokemodTreeModel::PokemodTreeModel(QObject* parent) :
- QAbstractItemModel(parent),
- m_root(new RootModel)
-{
-}
-
-Pokemodr::PokemodTreeModel::~PokemodTreeModel()
-{
- delete m_root;
-}
-
-QVariant Pokemodr::PokemodTreeModel::data(const QModelIndex& index, int role) const
-{
- if (!index.isValid())
- return QVariant();
- BaseModel* object = static_cast<BaseModel*>(index.internalPointer());
- return object->data(role);
-}
-
-QVariant Pokemodr::PokemodTreeModel::headerData(int /*section*/, Qt::Orientation /*orientation*/, int /*role = Qt::DisplayRole*/) const
-{
- return QVariant();
-}
-
-QModelIndex Pokemodr::PokemodTreeModel::index(int row, int column, const QModelIndex& parent) const
-{
- if ((row < -1) || (column < -1))
- return QModelIndex();
- if (row == -1)
- return createIndex(row, 0, m_root);
- BaseModel* model = getItem(parent);
- if ((model->rowCount() <= row) || (1 <= column))
- return QModelIndex();
- BaseModel* object = model->childItem(row);
- return createIndex(row, 0, object);
-}
-
-QModelIndex Pokemodr::PokemodTreeModel::parent(const QModelIndex& index) const
-{
- if (!index.isValid())
- return QModelIndex();
- BaseModel* parent = static_cast<BaseModel*>(index.internalPointer())->parent();
- if (!parent || (parent == m_root))
- return QModelIndex();
- return createIndex(parent->indexNumber(), 0, parent);
-}
-
-int Pokemodr::PokemodTreeModel::rowCount(const QModelIndex& parent) const
-{
- BaseModel* object = getItem(parent);
- return object->rowCount();
-}
-
-int Pokemodr::PokemodTreeModel::columnCount(const QModelIndex& /*parent*/) const
-{
- return 1;
-}
-
-Qt::ItemFlags Pokemodr::PokemodTreeModel::flags(const QModelIndex& index) const
-{
- if (!index.isValid())
- return 0;
- BaseModel* object = static_cast<BaseModel*>(index.internalPointer());
- return object->flags();
-}
-
-bool Pokemodr::PokemodTreeModel::setData(const QModelIndex& index, const QVariant& value, int role)
-{
- if (!index.isValid())
- return false;
- BaseModel* object = static_cast<BaseModel*>(index.internalPointer());
- emit(layoutAboutToBeChanged());
- bool success = object->setData(value, role);
- emit(dataChanged(index, index));
- emit(layoutChanged());
- return success;
-}
-
-Pokemodr::BaseModel* Pokemodr::PokemodTreeModel::getItem(const QModelIndex& index) const
-{
- if (index.isValid())
- {
- BaseModel* object = static_cast<BaseModel*>(index.internalPointer());
- if (object)
- return object;
- }
- return m_root;
-}
-
-QStringList Pokemodr::PokemodTreeModel::mimeTypes() const
-{
- return QStringList() << "application/x-pokemod+xml";
-}
-
-QMimeData* Pokemodr::PokemodTreeModel::mimeData(const QModelIndexList& indexes) const
-{
- QMimeData *mimeData = new QMimeData();
- if ((indexes.size() == 1) && indexes[0].isValid())
- {
- QDomDocument xml;
- xml.setContent(data(indexes[0], Pokemodr::BaseModel::XmlRole).toString());
- mimeData->setData("application/x-pokemod+xml", xml.toByteArray());
- }
- return mimeData;
-}
-
-bool Pokemodr::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"), Pokemodr::BaseModel::XmlRole);
- emit(layoutAboutToBeChanged());
- bool success = m_root->setData(data->data("application/x-pokemod+xml"), Pokemodr::BaseModel::XmlRole);
- emit(layoutChanged());
- return success;
-}
-
-void Pokemodr::PokemodTreeModel::addPokemod(Pokemod::Pokemod* pokemod)
-{
- m_root->addPokemod(pokemod);
- emit(reset());
-}
-
-void Pokemodr::PokemodTreeModel::deletePokemod(const Pokemod::Pokemod* pokemod)
-{
- m_root->deletePokemod(pokemod);
- emit(reset());
-}