diff options
author | Arno <am@disconnect.de> | 2010-06-12 10:15:04 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2010-06-12 10:15:04 +0200 |
commit | 3240cad2718ead169a07219e2a65ae84328b4485 (patch) | |
tree | 5f25343a56cbf4bd25cdd8f95eef5415451c97d9 /smtreemodel.cpp | |
parent | 1ec7610d1f9fb796e03876b8ba91cc32aea5dbeb (diff) | |
download | SheMov-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.
Diffstat (limited to 'smtreemodel.cpp')
-rw-r--r-- | smtreemodel.cpp | 14 |
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; |