summaryrefslogtreecommitdiffstats
path: root/sigmodr/tree/BaseModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sigmodr/tree/BaseModel.cpp')
-rw-r--r--sigmodr/tree/BaseModel.cpp143
1 files changed, 0 insertions, 143 deletions
diff --git a/sigmodr/tree/BaseModel.cpp b/sigmodr/tree/BaseModel.cpp
deleted file mode 100644
index 0dceeaa4..00000000
--- a/sigmodr/tree/BaseModel.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright 2008-2009 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 "BaseModel.h"
-
-// Sigmod includes
-#include <sigmod/Object.h>
-
-// KDE includes
-#include <KApplication>
-#include <KMessageBox>
-#include <KUrl>
-#include <KIO/NetAccess>
-
-// Qt includes
-#include <QtCore/QFile>
-#include <QtXml/QDomDocument>
-
-using namespace Sigmod;
-using namespace Sigmodr::Tree;
-
-const int BaseModel::TypeRole = Qt::UserRole;
-const int BaseModel::DropAcceptRole = Qt::UserRole + 1;
-const int BaseModel::XmlRole = Qt::UserRole + 2;
-const int BaseModel::WidgetRole = Qt::UserRole + 3;
-const int BaseModel::ContextMenuRole = Qt::UserRole + 4;
-
-BaseModel::BaseModel(BaseModel* parent, Object* object, const QString& name) :
- m_parent(parent),
- m_object(object),
- m_name(name)
-{
-}
-
-BaseModel::~BaseModel()
-{
-}
-
-QVariant BaseModel::data(const int role) const
-{
- if (role == TypeRole)
- return type();
- else if (role == DropAcceptRole)
- return types();
- return QVariant();
-}
-
-BaseModel* BaseModel::parent()
-{
- return m_parent;
-}
-
-int BaseModel::indexNumber() const
-{
- if (m_parent)
- return m_parent->findChild(const_cast<BaseModel*>(this));
- return -1;
-}
-
-QString BaseModel::type() const
-{
- return "";
-}
-
-const Object* BaseModel::object() const
-{
- return m_object;
-}
-
-bool BaseModel::loadFromData(const QString& data, QDomDocument* xml) const
-{
- bool loaded = false;
- QString error;
- int line;
- int column;
- KUrl url(data);
- if (url.isValid())
- {
- QString path;
- const bool local = url.isLocalFile();
- if (local)
- path = url.path();
- else
- {
- if (!KIO::NetAccess::download(url, path, KApplication::kApplication()->activeWindow()))
- {
- KMessageBox::error(KApplication::kApplication()->activeWindow(), KIO::NetAccess::lastErrorString(), "KIO Error");
- return false;
- }
- }
- QFile file(path);
- if (file.open(QIODevice::ReadOnly))
- {
- if (!xml->setContent(&file, &error, &line, &column))
- {
- KMessageBox::error(KApplication::kApplication()->activeWindow(), QString("%1 at line %2, column %3").arg(error).arg(line).arg(column), "XML Error");
- loaded = false;
- }
- }
- else
- {
- KMessageBox::error(KApplication::kApplication()->activeWindow(), file.errorString(), "File Error");
- loaded = false;
- }
- file.close();
- if (!local)
- KIO::NetAccess::removeTempFile(path);
- }
- else if (xml->setContent(data, &error, &line, &column))
- loaded = true;
- else
- KMessageBox::error(KApplication::kApplication()->activeWindow(), QString("%1 at line %2, column %3").arg(error).arg(line).arg(column), "XML Error");
- return loaded;
-}
-
-void BaseModel::childRowChanged(const int row, const Change change)
-{
- QList<int> indexes;
- indexes << indexNumber() << row;
- emit(rowsChanged(indexes, change));
-}
-
-void BaseModel::childRowsChanged(const QList<int>& rows, const Change change)
-{
- QList<int> indexes;
- indexes << indexNumber() << rows;
- emit(rowsChanged(indexes, change));
-}