From b85aad91e22a02f9ea14cd2009c718f8c64a7ef9 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 28 Aug 2015 13:00:19 -0400 Subject: Another minor increase in speed from the dir loader: only processEvents every 20 items, but be sure to processEvents after clearing the widget before the item loop is started (to ensure it is blanked out right away). --- lumina-fm/DirData.h | 2 +- lumina-fm/widgets/DirWidget.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lumina-fm/DirData.h b/lumina-fm/DirData.h index c82ee155..26cfb3ad 100644 --- a/lumina-fm/DirData.h +++ b/lumina-fm/DirData.h @@ -20,7 +20,7 @@ #define ZSNAPDIR QString("/.zfs/snapshot/") -#define DEBUG 1 +#define DEBUG 0 //Class used for keeping track of directory information in the HASH class LDirInfoList{ diff --git a/lumina-fm/widgets/DirWidget.cpp b/lumina-fm/widgets/DirWidget.cpp index 8d41d4c0..b4a6ca78 100644 --- a/lumina-fm/widgets/DirWidget.cpp +++ b/lumina-fm/widgets/DirWidget.cpp @@ -21,7 +21,9 @@ #include "../ScrollDialog.h" +#ifndef DEBUG #define DEBUG 0 +#endif DirWidget::DirWidget(QString objID, QWidget *parent) : QWidget(parent), ui(new Ui::DirWidget){ ui->setupUi(this); //load the designer file @@ -236,6 +238,7 @@ void DirWidget::LoadDir(QString dir, QList list){ if(lastbasedir != normalbasedir){ if(showDetails){ treeWidget->clear(); } else{ listWidget->clear(); } + QApplication::processEvents(); //make sure it is cleared right away }else{ //Need to be smarter about which items need to be removed // - compare the old/new lists and remove any items not in the new listing (new items taken care of below) @@ -248,7 +251,7 @@ void DirWidget::LoadDir(QString dir, QList list){ i--; } } - QApplication::processEvents(); + QApplication::processEvents(); //make sure the scrollbar is up to date after removals scrollpercent = treeWidget->verticalScrollBar()->value()/( (double) treeWidget->verticalScrollBar()->maximum()); }else{ for(int i=0; icount(); i++){ @@ -257,6 +260,7 @@ void DirWidget::LoadDir(QString dir, QList list){ i--; } } + QApplication::processEvents(); //make sure the scrollbar is up to date after removals scrollpercent = listWidget->horizontalScrollBar()->value()/( (double) listWidget->horizontalScrollBar()->maximum()); } } //end check for CDIR reload @@ -350,7 +354,7 @@ void DirWidget::LoadDir(QString dir, QList list){ listWidget->scrollToItem(it); } } - if(i%10==0){ QApplication::processEvents(); }//keep the UI snappy while loading a directory + if(i%20==0){ QApplication::processEvents(); }//keep the UI snappy while loading a directory if(DEBUG){ qDebug() << " - item finished:" << i << time.elapsed(); } } if(DEBUG){ qDebug() << "Done with item loop:" << time.elapsed() << list.length(); } -- cgit