If using list/grid view and model is reset, then navigate to top

This commit is contained in:
Craig Drummond
2015-06-08 21:08:40 +01:00
parent c09f12e669
commit d02304e5c8
2 changed files with 14 additions and 0 deletions

View File

@@ -934,11 +934,17 @@ QAbstractItemView * ItemView::view() const
void ItemView::setModel(QAbstractItemModel *m)
{
bool needtToInit=!itemModel;
if (itemModel) {
disconnect(itemModel, SIGNAL(modelReset()), this, SLOT(modelReset()));
}
itemModel=m;
if (needtToInit) {
mode=Mode_List;
setMode(Mode_SimpleTree);
}
if (m) {
connect(m, SIGNAL(modelReset()), this, SLOT(modelReset()));
}
view()->setModel(m);
}
@@ -1386,6 +1392,13 @@ void ItemView::activateItem(const QModelIndex &index, bool emitRootSet)
}
}
void ItemView::modelReset()
{
if (Mode_List==mode || Mode_IconTop==mode) {
goToTop();
}
}
void ItemView::delaySearchItems()
{
if (searchWidget->text().isEmpty()) {

View File

@@ -174,6 +174,7 @@ private Q_SLOTS:
void doSearch();
void searchActive(bool a);
void activateItem(const QModelIndex &index, bool emitRootSet=true);
void modelReset();
private:
void collapseToLevel();