diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2009-05-01 22:27:01 -0400 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2009-05-01 22:27:01 -0400 |
| commit | 7bfa5c29faf7f593b81e6917f81364da1837a73a (patch) | |
| tree | b62dadecafa3838e80177062d399513abd2012c8 /sigmodr/tree/TreeModel.cpp | |
| parent | 87a5d67b907add0dca4cb8482374f99414fe4dba (diff) | |
| download | sigen-7bfa5c29faf7f593b81e6917f81364da1837a73a.tar.gz sigen-7bfa5c29faf7f593b81e6917f81364da1837a73a.tar.xz sigen-7bfa5c29faf7f593b81e6917f81364da1837a73a.zip | |
Basic model for the new tree
Diffstat (limited to 'sigmodr/tree/TreeModel.cpp')
| -rw-r--r-- | sigmodr/tree/TreeModel.cpp | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/sigmodr/tree/TreeModel.cpp b/sigmodr/tree/TreeModel.cpp new file mode 100644 index 00000000..801fbdb7 --- /dev/null +++ b/sigmodr/tree/TreeModel.cpp @@ -0,0 +1,99 @@ +/* + * Copyright 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 "TreeModel.h" + +// Sigmodr tree includes +#include "RootTreeItem.h" + +using namespace Sigmodr::Tree; + +TreeModel::TreeModel(QObject* parent) : + QAbstractItemModel(parent) +{ +} + +TreeModel::~TreeModel() +{ + delete m_root; +} + +QVariant TreeModel::data(const QModelIndex& index, const int role) const +{ +} + +QModelIndex TreeModel::index(const int row, const int column, const QModelIndex& parent) const +{ + if (!parent.isValid()) + return QModelIndex(); + TreeItem* item = static_cast<TreeItem*>(parent.internalPointer()); + if (column || (row < 0) || (item->childCount() <= row)) + return QModelIndex(); + return createIndex(row, 0, item->childAt(row)); +} + +QModelIndex TreeModel::parent(const QModelIndex& child) const +{ + if (!child.isValid()) + return QModelIndex(); + TreeItem* item = static_cast<TreeItem*>(child.internalPointer()); + return createIndex(item->row(), 0, item->parent()); +} + +bool TreeModel::hasChildren(const QModelIndex& parent) const +{ + if (!parent.isValid()) + return false; + TreeItem* item = static_cast<TreeItem*>(parent.internalPointer()); + return item->childCount(); +} + +int TreeModel::rowCount(const QModelIndex& parent) const +{ + if (!parent.isValid()) + return 0; + return static_cast<TreeItem*>(parent.internalPointer())->childCount(); +} + +int TreeModel::columnCount(const QModelIndex& parent) const +{ + return 1; +} + +Qt::ItemFlags TreeModel::flags(const QModelIndex& index) const +{ + if (!index.isValid()) + return Qt::ItemFlags(); + return static_cast<TreeItem*>(index.internalPointer())->flags(); +} + +QStringList TreeModel::mimeTypes() const +{ +} + +QMimeData* TreeModel::mimeData(const QModelIndexList& indexes) const +{ +} + +bool TreeModel::dropMimeData(const QMimeData* data, Qt::DropAction action, const int row, const int column, const QModelIndex& parent) +{ +} + +Qt::DropActions TreeModel::supportedDropActions() const +{ +} |
