From 3240cad2718ead169a07219e2a65ae84328b4485 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 12 Jun 2010 10:15:04 +0200 Subject: Implemented SmTreeModel::parent Forgot to implement SmTreeModel::parent. Thus it was a pure abstract class and not instantiable. --- smtreemodel.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'smtreemodel.cpp') 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; -- cgit v1.2.3-70-g09d2