summaryrefslogtreecommitdiffstats
path: root/sigmodr/tree
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-05-03 01:32:20 -0400
committerBen Boeckel <MathStuf@gmail.com>2009-05-03 01:32:20 -0400
commit74a7cca66437258e9f54b163228e553de47f3282 (patch)
treee3c76d58d55e22e9a7e22a9fd654b5e4f682bca2 /sigmodr/tree
parent7d6cd1f3629b8c521e87abe6904410caca16a34b (diff)
downloadsigen-74a7cca66437258e9f54b163228e553de47f3282.tar.gz
sigen-74a7cca66437258e9f54b163228e553de47f3282.tar.xz
sigen-74a7cca66437258e9f54b163228e553de47f3282.zip
Add a basic TreeWidget (copied from the old widget)
Diffstat (limited to 'sigmodr/tree')
-rw-r--r--sigmodr/tree/CMakeLists.txt3
-rw-r--r--sigmodr/tree/TreeWidget.cpp155
-rw-r--r--sigmodr/tree/TreeWidget.h84
3 files changed, 242 insertions, 0 deletions
diff --git a/sigmodr/tree/CMakeLists.txt b/sigmodr/tree/CMakeLists.txt
index 49043004..62e95828 100644
--- a/sigmodr/tree/CMakeLists.txt
+++ b/sigmodr/tree/CMakeLists.txt
@@ -3,11 +3,14 @@ project(sigmodrtree)
set(sigmodrtree_HEADERS
Global.h
SigmodrTree.h
+ TreeWidget.h
)
set(sigmodrtree_SRCS
RootTreeItem.cpp
TreeItem.cpp
TreeModel.cpp
+ TreeWidget.cpp
+
AbilityGroupModel.cpp
AbilityModel.cpp
AuthorGroupModel.cpp
diff --git a/sigmodr/tree/TreeWidget.cpp b/sigmodr/tree/TreeWidget.cpp
new file mode 100644
index 00000000..8a7aaa9f
--- /dev/null
+++ b/sigmodr/tree/TreeWidget.cpp
@@ -0,0 +1,155 @@
+/*
+ * 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 "TreeWidget.h"
+
+// Sigmodr tree includes
+#include "TreeModel.h"
+
+// Sigmod includes
+#include <sigmod/Game.h>
+#include <sigmod/Object.h>
+
+// Qt includes
+#include <QtGui/QHeaderView>
+
+using namespace Sigmod;
+using namespace Sigmodr::Widgets;
+using namespace Sigmodr::Tree;
+
+TreeWidget::TreeWidget(QWidget* parent) :
+ QTreeView(parent)
+{
+ TreeModel* model = new TreeModel(this);
+// connect(model, SIGNAL(dirty(const Sigmod::Game*, bool)), this, SLOT(setDirty(const Sigmod::Game*, bool)));
+ header()->hide();
+ setModel(model);
+ setRootIndex(model->index(-1, -1, QModelIndex()));
+}
+
+// QString TreeWidget::description(const QModelIndex& index) const
+// {
+// QString type = typeOf(index);
+// QString name = model()->data(index, Qt::DisplayRole).toString();
+// if (type.isEmpty() && name.isEmpty())
+// return "";
+// return QString("%1: %2").arg(type).arg(name);
+// }
+//
+// QString TreeWidget::typeOf(const QModelIndex& index) const
+// {
+// return model()->data(index, BaseModel::TypeRole).toString();
+// }
+//
+// QStringList TreeWidget::dropTypes(const QModelIndex& index) const
+// {
+// return model()->data(index, BaseModel::DropAcceptRole).toString().split(';');
+// }
+//
+// ObjectUI* TreeWidget::editorWidget(const QModelIndex& index)
+// {
+// ObjectUI* widget = qobject_cast<ObjectUI*>(model()->data(index, BaseModel::WidgetRole).value<QWidget*>());
+// return widget;
+// }
+//
+// KMenu* TreeWidget::contextMenu(const QModelIndex& index)
+// {
+// return model()->data(index, BaseModel::ContextMenuRole).value<KMenu*>();
+// }
+//
+// const Game* TreeWidget::currentGame() const
+// {
+// QModelIndex index = currentIndex();
+// if (index.isValid())
+// {
+// const Object* object = static_cast<BaseModel*>(index.internalPointer())->object();
+// if (object)
+// return object->game();
+// }
+// return NULL;
+// }
+//
+// QDomDocument TreeWidget::copy(const QModelIndex& index)
+// {
+// QDomDocument xml;
+// xml.setContent(model()->data(index, BaseModel::XmlRole).toString());
+// return xml;
+// }
+//
+// void TreeWidget::paste(const QModelIndex& index, const QDomDocument& data)
+// {
+// model()->setData(index, data.toString(), BaseModel::XmlRole);
+// }
+//
+// QList<const Game*> TreeWidget::openedGames() const
+// {
+// return m_games.keys();
+// }
+//
+// void TreeWidget::addGame(Game* game, const KUrl& url)
+// {
+// qobject_cast<TreeWidgetModel*>(model())->addGame(game);
+// m_games[game] = UrlDirty(url, false);
+// }
+//
+// void TreeWidget::deleteGame(const Game* game)
+// {
+// if (m_games.contains(game))
+// {
+// qobject_cast<TreeWidgetModel*>(model())->deleteGame(game);
+// m_games.remove(game);
+// }
+// }
+//
+// bool TreeWidget::isOpen(const KUrl& url) const
+// {
+// foreach (const UrlDirty& pair, m_games.values())
+// {
+// if (url == pair.first)
+// return true;
+// }
+// return false;
+// }
+//
+// KUrl TreeWidget::url(const Game* game) const
+// {
+// if (m_games.contains(game))
+// return m_games[game].first;
+// return KUrl();
+// }
+//
+// QStringList TreeWidget::urls() const
+// {
+// QStringList urls;
+// foreach (const UrlDirty& pair, m_games.values())
+// urls << pair.first.prettyUrl();
+// return urls;
+// }
+//
+// void TreeWidget::setUrl(const Game* game, const KUrl& url)
+// {
+// if (m_games.contains(game))
+// m_games[game] = UrlDirty(url, false);
+// }
+//
+// bool TreeWidget::dirty(const Game* game) const
+// {
+// if (m_games.contains(game))
+// return m_games[game].second;
+// return false;
+// }
diff --git a/sigmodr/tree/TreeWidget.h b/sigmodr/tree/TreeWidget.h
new file mode 100644
index 00000000..da2148e0
--- /dev/null
+++ b/sigmodr/tree/TreeWidget.h
@@ -0,0 +1,84 @@
+/*
+ * 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/>.
+ */
+
+#ifndef SIGMODRTREE_TREEWIDGET
+#define SIGMODRTREE_TREEWIDGET
+
+// Sigmodr tree includes
+#include "Global.h"
+
+// KDE includes
+#include <KUrl>
+
+// Qt includes
+#include <QtCore/QMap>
+#include <QtGui/QTreeView>
+#include <QtXml/QDomDocument>
+
+// Forward declarations
+namespace Sigmod
+{
+class Game;
+}
+
+namespace Sigmodr
+{
+namespace Widgets
+{
+class ObjectUI;
+}
+
+namespace Tree
+{
+class SIGMODRTREE_EXPORT TreeWidget : public QTreeView
+{
+ Q_OBJECT
+
+ public:
+ TreeWidget(QWidget* parent = 0);
+
+// QString description(const QModelIndex& index) const;
+// QString typeOf(const QModelIndex& index) const;
+// QStringList dropTypes(const QModelIndex& index) const;
+// Widgets::ObjectUI* editorWidget(const QModelIndex& index);
+//
+// const Sigmod::Game* currentGame() const;
+//
+// QDomDocument copy(const QModelIndex& index);
+// void paste(const QModelIndex& index, const QDomDocument& data);
+//
+// QList<const Sigmod::Game*> openedGames() const;
+// void addGame(Sigmod::Game* game, const KUrl& url = KUrl());
+// void deleteGame(const Sigmod::Game* game);
+// void deleteAllGames();
+//
+// bool isOpen(const KUrl& url) const;
+//
+// KUrl url(const Sigmod::Game* game) const;
+// QStringList urls() const;
+// void setUrl(const Sigmod::Game* game, const KUrl& url);
+
+ bool dirty(const Sigmod::Game* game = NULL) const;
+ private:
+ typedef QPair<KUrl, bool> UrlDirty;
+
+ QMap<const Sigmod::Game*, UrlDirty> m_games;
+};
+}
+}
+
+#endif