@@ -127,7 +127,7 @@ MainWindow::MainWindow()
127127 // Create filesystem model
128128 bool realMime = settings->value (" realMimeTypes" , true ).toBool ();
129129 modelList = new myModel (realMime, mimeUtils);
130- connect (modelList, SIGNAL (reloadDir ()), this , SLOT (dirLoaded ( )));
130+ connect (modelList, SIGNAL (reloadDir (QString )), this , SLOT (handleReloadDir (QString )));
131131
132132 dockTree = new QDockWidget (tr (" Tree" ),this ,Qt::SubWindow);
133133 dockTree->setObjectName (" treeDock" );
@@ -243,6 +243,7 @@ MainWindow::MainWindow()
243243 show ();
244244
245245 trashDir = Common::trashDir ();
246+ ignoreReload = false ;
246247
247248 QTimer::singleShot (0 , this , SLOT (lateStart ()));
248249}
@@ -378,8 +379,8 @@ void MainWindow::lateStart() {
378379 connect (detailTree, SIGNAL (pressed (QModelIndex)),
379380 this , SLOT (listItemPressed (QModelIndex)));
380381
381- connect (modelList, SIGNAL (thumbUpdate ()),
382- this , SLOT (thumbUpdate ()));
382+ connect (modelList, SIGNAL (thumbUpdate (QString )),
383+ this , SLOT (thumbUpdate (QString )));
383384
384385 qApp->setKeyboardInputInterval (1000 );
385386
@@ -667,19 +668,20 @@ void MainWindow::treeSelectionChanged(QModelIndex current, QModelIndex previous)
667668
668669 listSelectionModel->blockSignals (0 );
669670 updateGrid ();
671+ qDebug () << " trigger dirloaded on tree selection changed" ;
670672 QTimer::singleShot (30 ,this ,SLOT (dirLoaded ()));
671673}
672674
673675// ---------------------------------------------------------------------------
674- void MainWindow::dirLoaded ()
676+ void MainWindow::dirLoaded (bool thumbs )
675677{
676678
677679 if (backIndex.isValid ()) {
678680 backIndex = QModelIndex ();
679681 return ;
680682 }
681683
682- qDebug () << " dirLoaded" ;
684+ qDebug () << " dirLoaded triggered, thumbs? " << thumbs ;
683685 qint64 bytes = 0 ;
684686 QModelIndexList items;
685687 bool includeHidden = hiddenAct->isChecked ();
@@ -704,12 +706,32 @@ void MainWindow::dirLoaded()
704706 statusSize->setText (QString (" %1 items" ).arg (items.count ()));
705707 statusDate->setText (QString (" %1" ).arg (total));
706708
707- if (thumbsAct->isChecked ()) { QtConcurrent::run (modelList,&myModel::loadThumbs,items); }
709+ if (thumbsAct->isChecked () && thumbs ) { QtConcurrent::run (modelList,&myModel::loadThumbs,items); }
708710 updateGrid ();
709711}
710712
711- void MainWindow::thumbUpdate ()
713+ void MainWindow::updateDir ()
712714{
715+ dirLoaded (false /* dont refresh thumb*/ );
716+ }
717+
718+ void MainWindow::handleReloadDir (const QString &path)
719+ {
720+ if (ignoreReload) {
721+ qDebug () << " ignore reload" ;
722+ return ;
723+ }
724+ ignoreReload = true ;
725+ qDebug () << " handle reload dir" << path << modelList->getRootPath ();
726+ if (path != modelList->getRootPath ()) { return ; }
727+ dirLoaded ();
728+ QTimer::singleShot (500 , this , SLOT (enableReload ()));
729+ }
730+
731+ void MainWindow::thumbUpdate (const QString &path)
732+ {
733+ qDebug () << " thumbupdate" << path << modelList->getRootPath ();
734+ if (path != modelList->getRootPath ()) { return ; }
713735 refresh (false , false );
714736}
715737
@@ -1534,12 +1556,21 @@ void MainWindow::refresh(bool modelRefresh, bool loadDir)
15341556 qDebug () << " refresh" ;
15351557 if (modelRefresh) {
15361558 modelList->refreshItems ();
1537- modelList->update ();
1559+ modelList->forceRefresh ();
15381560 }
15391561 QModelIndex baseIndex = modelView->mapFromSource (modelList->index (pathEdit->currentText ()));
15401562 if (currentView == 2 ) { detailTree->setRootIndex (baseIndex); }
15411563 else { list->setRootIndex (baseIndex); }
1542- if (loadDir) { dirLoaded (); }
1564+ if (loadDir) {
1565+ qDebug () << " trigger dirloaded from refresh" ;
1566+ dirLoaded ();
1567+ }
1568+ }
1569+
1570+ void MainWindow::enableReload ()
1571+ {
1572+ qDebug () << " enable reload" ;
1573+ ignoreReload = false ;
15431574}
15441575// ---------------------------------------------------------------------------
15451576
@@ -1840,6 +1871,7 @@ void MainWindow::actionMapper(QString cmd)
18401871// ---------------------------------------------------------------------------------
18411872void MainWindow::clearCutItems ()
18421873{
1874+ qDebug () << " clearCutItems" ;
18431875 // this refreshes existing items, sizes etc but doesn't re-sort
18441876 modelList->clearCutItems ();
18451877 modelList->update ();
@@ -1848,8 +1880,9 @@ void MainWindow::clearCutItems()
18481880
18491881 if (currentView == 2 ) { detailTree->setRootIndex (baseIndex); }
18501882 else { list->setRootIndex (baseIndex); }
1851- QTimer::singleShot (50 ,this ,SLOT (dirLoaded ()));
1852- return ;
1883+
1884+ qDebug () << " trigger updateDir from clearCutItems" ;
1885+ QTimer::singleShot (50 ,this ,SLOT (updateDir ()));
18531886}
18541887
18551888// ---------------------------------------------------------------------------------
0 commit comments