summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2010-06-12 10:15:04 +0200
committerArno <am@disconnect.de>2010-06-12 10:15:04 +0200
commit3240cad2718ead169a07219e2a65ae84328b4485 (patch)
tree5f25343a56cbf4bd25cdd8f95eef5415451c97d9
parent1ec7610d1f9fb796e03876b8ba91cc32aea5dbeb (diff)
downloadSheMov-3240cad2718ead169a07219e2a65ae84328b4485.tar.gz
SheMov-3240cad2718ead169a07219e2a65ae84328b4485.tar.bz2
SheMov-3240cad2718ead169a07219e2a65ae84328b4485.zip
Implemented SmTreeModel::parent
Forgot to implement SmTreeModel::parent. Thus it was a pure abstract class and not instantiable.
-rw-r--r--smtreemodel.cpp14
-rw-r--r--smtreemodel.h3
2 files changed, 16 insertions, 1 deletions
diff --git a/smtreemodel.cpp b/smtreemodel.cpp
index 2c7a2d6..fe5482c 100644
--- a/smtreemodel.cpp
+++ b/smtreemodel.cpp
@@ -39,6 +39,20 @@ QModelIndex SmTreeModel::index(int row, int column, const QModelIndex &parent) c
return QModelIndex();
}
+QModelIndex SmTreeModel::parent(const QModelIndex &child) const{
+ if(!child.isValid()){
+ return QModelIndex();
+ }
+
+ SmTreeItem *childItem = itemAt(child);
+ SmTreeItem *parentItem = childItem->parent();
+
+ if(parentItem == mRootItem){
+ return QModelIndex();
+ }
+ return createIndex(parentItem->row(), 0, parentItem);
+}
+
Qt::ItemFlags SmTreeModel::flags(const QModelIndex &index) const{
if(!index.isValid()){
return 0;
diff --git a/smtreemodel.h b/smtreemodel.h
index 46f852f..698a2ce 100644
--- a/smtreemodel.h
+++ b/smtreemodel.h
@@ -23,8 +23,9 @@ class SmTreeModel : public QAbstractItemModel {
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
- // index and flags
+ // index, parent and flags
QModelIndex index(int row, int column, const QModelIndex &parent) const;
+ QModelIndex parent(const QModelIndex &child) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
// headers + data