summaryrefslogtreecommitdiffstats
path: root/smtreemodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'smtreemodel.cpp')
-rw-r--r--smtreemodel.cpp14
1 files changed, 14 insertions, 0 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;