summaryrefslogtreecommitdiffstats
path: root/sigmodr/SigmodTree.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-02-23 11:34:15 -0500
committerBen Boeckel <MathStuf@gmail.com>2009-02-23 11:34:15 -0500
commit18efef142da109d395d3d9761225a4936dee9e4d (patch)
treefc86c72b59cd2739a4c63e0cfbaf5e864c08b4d7 /sigmodr/SigmodTree.cpp
parent7aff48012c3040a675543a0ff3d23af6cb8a8638 (diff)
downloadsigen-18efef142da109d395d3d9761225a4936dee9e4d.tar.gz
sigen-18efef142da109d395d3d9761225a4936dee9e4d.tar.xz
sigen-18efef142da109d395d3d9761225a4936dee9e4d.zip
Moved the tree for sigmods in sigmodr to a library
Diffstat (limited to 'sigmodr/SigmodTree.cpp')
-rw-r--r--sigmodr/SigmodTree.cpp161
1 files changed, 0 insertions, 161 deletions
diff --git a/sigmodr/SigmodTree.cpp b/sigmodr/SigmodTree.cpp
deleted file mode 100644
index 9437a0e6..00000000
--- a/sigmodr/SigmodTree.cpp
+++ /dev/null
@@ -1,161 +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 "SigmodTree.h"
-
-// Model includes
-#include "models/BaseModel.h"
-
-// Sigmodr includes
-#include "ObjectUI.h"
-#include "SigmodTreeModel.h"
-
-// Sigmod includes
-#include "../sigmod/Object.h"
-#include "../sigmod/Sigmod.h"
-
-// Qt includes
-#include <QtGui/QHeaderView>
-
-Sigmodr::SigmodTree::SigmodTree(QWidget* parent) :
- QTreeView(parent)
-{
- SigmodTreeModel* model = new SigmodTreeModel(this);
- connect(model, SIGNAL(dirty(const Sigmod::Sigmod*, bool)), this, SLOT(setDirty(const Sigmod::Sigmod*, bool)));
- header()->hide();
- setModel(model);
- setRootIndex(model->index(-1, 0, QModelIndex()));
-}
-
-QString Sigmodr::SigmodTree::description(const QModelIndex& index)
-{
- QString type = model()->data(index, BaseModel::TypeRole).toString();
- QString name = model()->data(index, Qt::DisplayRole).toString();
- if (type.isEmpty() && name.isEmpty())
- return "";
- return QString("%1: %2").arg(type).arg(name);
-}
-
-Sigmodr::ObjectUI* Sigmodr::SigmodTree::editorWidget(const QModelIndex& index)
-{
- Sigmodr::ObjectUI* widget = qobject_cast<ObjectUI*>(model()->data(index, BaseModel::WidgetRole).value<QWidget*>());
- return widget;
-}
-
-KMenu* Sigmodr::SigmodTree::contextMenu(const QModelIndex& index)
-{
- return model()->data(index, BaseModel::ContextMenuRole).value<KMenu*>();
-}
-
-const Sigmod::Sigmod* Sigmodr::SigmodTree::currentSigmod() const
-{
- QModelIndex index = currentIndex();
- if (index.isValid())
- {
- const Sigmod::Object* object = static_cast<BaseModel*>(index.internalPointer())->object();
- if (object)
- return object->sigmod();
- }
- return NULL;
-}
-
-QDomDocument Sigmodr::SigmodTree::copy(const QModelIndex& index)
-{
- QDomDocument xml;
- xml.setContent(model()->data(index, BaseModel::XmlRole).toString());
- return xml;
-}
-
-void Sigmodr::SigmodTree::paste(const QModelIndex& index, const QDomDocument& data)
-{
- model()->setData(index, data.toString(), BaseModel::XmlRole);
-}
-
-QList<const Sigmod::Sigmod*> Sigmodr::SigmodTree::openedSigmods() const
-{
- return m_sigmods.keys();
-}
-
-void Sigmodr::SigmodTree::addSigmod(Sigmod::Sigmod* sigmod, const KUrl& url)
-{
- qobject_cast<SigmodTreeModel*>(model())->addSigmod(sigmod);
- m_sigmods[sigmod] = UrlDirty(url, false);
-}
-
-void Sigmodr::SigmodTree::deleteSigmod(const Sigmod::Sigmod* sigmod)
-{
- if (m_sigmods.contains(sigmod))
- {
- qobject_cast<SigmodTreeModel*>(model())->deleteSigmod(sigmod);
- m_sigmods.remove(sigmod);
- }
-}
-
-bool Sigmodr::SigmodTree::isOpen(const KUrl& url) const
-{
- foreach (const UrlDirty& pair, m_sigmods.values())
- {
- if (url == pair.first)
- return true;
- }
- return false;
-}
-
-KUrl Sigmodr::SigmodTree::url(const Sigmod::Sigmod* sigmod) const
-{
- if (m_sigmods.contains(sigmod))
- return m_sigmods[sigmod].first;
- return KUrl();
-}
-
-QStringList Sigmodr::SigmodTree::urls() const
-{
- QStringList urls;
- foreach (const UrlDirty& pair, m_sigmods.values())
- urls << pair.first.prettyUrl();
- return urls;
-}
-
-void Sigmodr::SigmodTree::setUrl(const Sigmod::Sigmod* sigmod, const KUrl& url)
-{
- if (m_sigmods.contains(sigmod))
- m_sigmods[sigmod] = UrlDirty(url, false);
-}
-
-bool Sigmodr::SigmodTree::dirty(const Sigmod::Sigmod* sigmod) const
-{
- if (m_sigmods.contains(sigmod))
- return m_sigmods[sigmod].second;
- return false;
-}
-
-bool Sigmodr::SigmodTree::dirty() const
-{
- return dirty(currentSigmod());
-}
-
-void Sigmodr::SigmodTree::setDirty(const Sigmod::Sigmod* sigmod, const bool dirty)
-{
- if (m_sigmods.contains(sigmod))
- m_sigmods[sigmod].second = dirty;
-}
-
-void Sigmodr::SigmodTree::setDirty()
-{
- setDirty(currentSigmod(), true);
-}