diff options
author | Arno <am@disconnect.de> | 2013-06-02 00:43:09 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2013-06-02 00:43:09 +0200 |
commit | 459f58c57bfa1021783134b11853e8e4140055f3 (patch) | |
tree | 48c8bebb968eac10ced310ec33e204b17dee32f8 /archivemodel.cpp | |
parent | 6fec376f7f44145efa509668927a0179c8ffa65e (diff) | |
download | SheMov-459f58c57bfa1021783134b11853e8e4140055f3.tar.gz SheMov-459f58c57bfa1021783134b11853e8e4140055f3.tar.bz2 SheMov-459f58c57bfa1021783134b11853e8e4140055f3.zip |
Remember expanded Items
For the current SortOrder the expanded items are written to the config
file and read on startup.
Diffstat (limited to 'archivemodel.cpp')
-rw-r--r-- | archivemodel.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/archivemodel.cpp b/archivemodel.cpp index c317c32..de95328 100644 --- a/archivemodel.cpp +++ b/archivemodel.cpp @@ -57,6 +57,31 @@ QVariant ArchiveModel::data(const QModelIndex &index, int role) const{ return SmTreeModel::data(index, role); } +QStringList ArchiveModel::indexToPath(const QModelIndex &idx) const { + QStringList retval; + SmTreeItem *item = itemAt(idx); + while (item) { + retval << item->data(Name).toString(); + item = item->parent(); + } + std::reverse(retval.begin(), retval.end()); + return retval; +} + +QModelIndexList ArchiveModel::pathToIndex(const QStringList &path) const { + QModelIndexList retval; + QModelIndex parentIdx = QModelIndex(); + for(int i = 0; i < path.count(); ++i){ + QString curItem = path.at(i); + QModelIndex found = find(curItem, Name, parentIdx); + if(found.isValid()){ + retval << found; + parentIdx = found; + } + } + return retval; +} + void ArchiveModel::setOrder(int order) { mOrder = order; SmTreeItem *rootItem = new SmTreeItem(NumFields); |