Unlimited back depth
This commit is contained in:
@@ -893,6 +893,7 @@ void ItemView::setLevel(int l, bool haveChildren)
|
||||
if (isVisible()) {
|
||||
backAction->setEnabled(0!=currentLevel);
|
||||
}
|
||||
if (!currentLevel) prevTopIndex.clear();
|
||||
|
||||
if (Mode_IconTop==mode) {
|
||||
if (0==currentLevel || haveChildren) {
|
||||
@@ -1325,13 +1326,15 @@ void ItemView::backActivated()
|
||||
emit rootIndexSet(listView->rootIndex().parent());
|
||||
setTitle();
|
||||
|
||||
if (prevTopIndex.isEmpty()) return;
|
||||
QModelIndex prevTop = prevTopIndex.takeLast();
|
||||
if (qobject_cast<QSortFilterProxyModel *>(listView->model())) {
|
||||
QModelIndex idx=static_cast<QSortFilterProxyModel *>(listView->model())->mapFromSource(prevTopIndex[currentLevel]);
|
||||
QModelIndex idx=static_cast<QSortFilterProxyModel *>(listView->model())->mapFromSource(prevTop);
|
||||
if (idx.isValid()) {
|
||||
listView->scrollTo(idx, QAbstractItemView::PositionAtTop);
|
||||
}
|
||||
} else {
|
||||
listView->scrollTo(prevTopIndex[currentLevel], QAbstractItemView::PositionAtTop);
|
||||
listView->scrollTo(prevTop, QAbstractItemView::PositionAtTop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1394,10 +1397,11 @@ void ItemView::activateItem(const QModelIndex &index, bool emitRootSet)
|
||||
return;
|
||||
}
|
||||
|
||||
prevTopIndex[currentLevel]=listView->indexAt(QPoint(8, 8));
|
||||
QModelIndex curTop=listView->indexAt(QPoint(8, 8));
|
||||
if (qobject_cast<QSortFilterProxyModel *>(listView->model())) {
|
||||
prevTopIndex[currentLevel] =static_cast<QSortFilterProxyModel *>(listView->model())->mapToSource(prevTopIndex[currentLevel]);
|
||||
curTop=static_cast<QSortFilterProxyModel *>(listView->model())->mapToSource(curTop);
|
||||
}
|
||||
prevTopIndex.append(curTop);
|
||||
setLevel(currentLevel+1, itemModel->canFetchMore(fistChild) || fistChild.child(0, 0).isValid());
|
||||
listView->setRootIndex(index);
|
||||
setTitle();
|
||||
|
||||
@@ -199,7 +199,7 @@ private:
|
||||
QAbstractItemModel *itemModel;
|
||||
int currentLevel;
|
||||
Mode mode;
|
||||
QModelIndex prevTopIndex[3]; //max 4 levels - last one
|
||||
QModelIndexList prevTopIndex;
|
||||
QSize iconGridSize;
|
||||
QSize listGridSize;
|
||||
GroupedView *groupedView;
|
||||
|
||||
Reference in New Issue
Block a user