summaryrefslogtreecommitdiffstats
path: root/sigmodr/PokemodTree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sigmodr/PokemodTree.cpp')
-rw-r--r--sigmodr/PokemodTree.cpp156
1 files changed, 0 insertions, 156 deletions
diff --git a/sigmodr/PokemodTree.cpp b/sigmodr/PokemodTree.cpp
deleted file mode 100644
index bd3dcd65..00000000
--- a/sigmodr/PokemodTree.cpp
+++ /dev/null
@@ -1,156 +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 "PokemodTree.h"
-
-// Model includes
-#include "models/BaseModel.h"
-
-// Pokemodr includes
-#include "ObjectUI.h"
-#include "PokemodTreeModel.h"
-
-// Pokemod includes
-#include "../pokemod/Object.h"
-#include "../pokemod/Pokemod.h"
-
-// Qt includes
-#include <QtGui/QHeaderView>
-
-Pokemodr::PokemodTree::PokemodTree(QWidget* parent) :
- QTreeView(parent)
-{
- header()->hide();
- setModel(new Pokemodr::PokemodTreeModel(this));
- setRootIndex(model()->index(-1, 0, QModelIndex()));
-}
-
-QString Pokemodr::PokemodTree::description(const QModelIndex& index)
-{
- return QString("%1: %2").arg(model()->data(index, Pokemodr::BaseModel::TypeRole).toString(), model()->data(index, Qt::DisplayRole).toString());
-}
-
-Pokemodr::ObjectUI* Pokemodr::PokemodTree::editorWidget(const QModelIndex& index)
-{
- Pokemodr::ObjectUI* widget = qobject_cast<Pokemodr::ObjectUI*>(model()->data(index, Pokemodr::BaseModel::WidgetRole).value<QWidget*>());
- return widget;
-}
-
-KMenu* Pokemodr::PokemodTree::contextMenu(const QModelIndex& index)
-{
- return model()->data(index, Pokemodr::BaseModel::ContextMenuRole).value<KMenu*>();
-}
-
-const Pokemod::Pokemod* Pokemodr::PokemodTree::currentPokemod() const
-{
- QModelIndex index = currentIndex();
- if (index.isValid())
- {
- const Pokemod::Object* object = static_cast<BaseModel*>(index.internalPointer())->object();
- if (object)
- return qobject_cast<const Pokemod::Pokemod*>(object->pokemod());
- }
- return NULL;
-}
-
-QDomDocument Pokemodr::PokemodTree::copy(const QModelIndex& index)
-{
- QDomDocument xml;
- xml.setContent(model()->data(index, Pokemodr::BaseModel::XmlRole).toString());
- return xml;
-}
-
-void Pokemodr::PokemodTree::paste(const QModelIndex& index, const QDomDocument& data)
-{
- model()->setData(index, data.toString(), Pokemodr::BaseModel::XmlRole);
-}
-
-QList<const Pokemod::Pokemod*> Pokemodr::PokemodTree::openedPokemods() const
-{
- return m_pokemods.keys();
-}
-
-void Pokemodr::PokemodTree::addPokemod(Pokemod::Pokemod* pokemod)
-{
- qobject_cast<PokemodTreeModel*>(model())->addPokemod(pokemod);
- m_pokemods[pokemod] = UrlDirty(KUrl(), false);
-}
-
-void Pokemodr::PokemodTree::addPokemod(Pokemod::Pokemod* pokemod, const KUrl& url)
-{
- qobject_cast<PokemodTreeModel*>(model())->addPokemod(pokemod);
- m_pokemods[pokemod] = UrlDirty(url, false);
-}
-
-void Pokemodr::PokemodTree::deletePokemod(const Pokemod::Pokemod* pokemod)
-{
- if (m_pokemods.contains(pokemod))
- {
- qobject_cast<PokemodTreeModel*>(model())->deletePokemod(pokemod);
- m_pokemods.remove(pokemod);
- }
-}
-
-bool Pokemodr::PokemodTree::isOpen(const KUrl& url) const
-{
- foreach (UrlDirty pair, m_pokemods.values())
- {
- if (url == pair.first)
- return true;
- }
- return false;
-}
-
-KUrl Pokemodr::PokemodTree::url(const Pokemod::Pokemod* pokemod) const
-{
- if (m_pokemods.contains(pokemod))
- return m_pokemods[pokemod].first;
- return KUrl();
-}
-
-QStringList Pokemodr::PokemodTree::urls() const
-{
- QStringList urls;
- foreach (UrlDirty pair, m_pokemods.values())
- urls << pair.first.prettyUrl();
- return urls;
-}
-
-void Pokemodr::PokemodTree::setUrl(const Pokemod::Pokemod* pokemod, const KUrl& url)
-{
- if (m_pokemods.contains(pokemod))
- m_pokemods[pokemod] = UrlDirty(url, false);
-}
-
-bool Pokemodr::PokemodTree::dirty(const Pokemod::Pokemod* pokemod) const
-{
- if (m_pokemods.contains(pokemod))
- return m_pokemods[pokemod].second;
- return false;
-}
-
-void Pokemodr::PokemodTree::setDirty(const Pokemod::Pokemod* pokemod, const bool dirty)
-{
- if (m_pokemods.contains(pokemod))
- m_pokemods[pokemod].second = dirty;
-}
-
-void Pokemodr::PokemodTree::setDirty()
-{
- setDirty(currentPokemod(), true);
-}