If using list/grid view and model is reset, then navigate to top
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user