From 13d170e92dc2c8c649956ac5af9800172fbfd4f9 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 8 Oct 2015 11:21:38 -0400 Subject: Ensure that item selection is preserved when switching between basic/detailed list modes in lumina-fm. --- lumina-fm/widgets/DirWidget.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lumina-fm/widgets/DirWidget.cpp') diff --git a/lumina-fm/widgets/DirWidget.cpp b/lumina-fm/widgets/DirWidget.cpp index ccca4c17..728adc96 100644 --- a/lumina-fm/widgets/DirWidget.cpp +++ b/lumina-fm/widgets/DirWidget.cpp @@ -98,6 +98,10 @@ QString DirWidget::currentDir(){ } void DirWidget::setShowDetails(bool show){ + if(show!=showDetails){ + //View about to change - ensure the selection gets transferred too + tmpSel = currentSelection(); + } showDetails = show; listWidget->setVisible(!showDetails); treeWidget->setVisible(showDetails); @@ -383,6 +387,7 @@ void DirWidget::LoadDir(QString dir, QList list){ } } if(addnew){ treeWidget->addTopLevelItem(it); } + if(tmpSel.contains(list[i].absoluteFilePath())){ it->setSelected(true); } if(lastdir == CDIR+"/"+list[i].fileName()){ treeWidget->setCurrentItem(it); treeWidget->scrollToItem(it); @@ -412,6 +417,7 @@ void DirWidget::LoadDir(QString dir, QList list){ it->setIcon(LXDG::findIcon(list[i].iconfile(),"unknown") ); } listWidget->addItem(it); + if(tmpSel.contains(list[i].absoluteFilePath())){ it->setSelected(true); } if(lastdir == CDIR+"/"+list[i].fileName()){ listWidget->setCurrentItem(it); listWidget->scrollToItem(it); @@ -420,6 +426,7 @@ void DirWidget::LoadDir(QString dir, QList list){ if(i%15==0){ QApplication::processEvents(); }//keep the UI snappy while loading a directory if(DEBUG){ qDebug() << " - item finished:" << i << time.elapsed(); } } + tmpSel.clear(); if(DEBUG){ qDebug() << "Done with item loop:" << time.elapsed() << list.length(); } ui->actionStopLoad->setVisible(false); //Another check to ensure the current item is visible (or return to the same scroll position) -- cgit