aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm/widgets/DirWidget.cpp
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2015-08-28 09:56:42 -0400
committerKen Moore <moorekou@gmail.com>2015-08-28 09:56:42 -0400
commit5d10603fffb598d9ccbcda0e59766707e3f43870 (patch)
treecbec0dfbda33913f5ce61bed868562adeb491837 /lumina-fm/widgets/DirWidget.cpp
parentRemove the LFileInfo class from lumina-fm (in LuminaXDG instead) (diff)
downloadlumina-5d10603fffb598d9ccbcda0e59766707e3f43870.tar.gz
lumina-5d10603fffb598d9ccbcda0e59766707e3f43870.tar.bz2
lumina-5d10603fffb598d9ccbcda0e59766707e3f43870.zip
Add a couple tiny timing fixes for the lumina-fm backend:
1) Rollback the directory checked timestamp by 1/2 second from teh current time when doing a sync (just in case multiple fast changes to the dir). 2) Activate the dir watcher on all the files as well (not just the dir), and send all those signals into a collection timer with a 1/10 second delay to combine any simultaneous signals/changes into a single update call.
Diffstat (limited to 'lumina-fm/widgets/DirWidget.cpp')
-rw-r--r--lumina-fm/widgets/DirWidget.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lumina-fm/widgets/DirWidget.cpp b/lumina-fm/widgets/DirWidget.cpp
index 255bb461..d10028e1 100644
--- a/lumina-fm/widgets/DirWidget.cpp
+++ b/lumina-fm/widgets/DirWidget.cpp
@@ -54,6 +54,9 @@ DirWidget::DirWidget(QString objID, QWidget *parent) : QWidget(parent), ui(new U
refreshShort = new QShortcut( QKeySequence(tr("F5")), this);
//Create the filesystem watcher
watcher = new QFileSystemWatcher(this);
+ synctimer = new QTimer(this);
+ synctimer->setInterval(100); // 1/10 second pause (combine simultaneous signals from the watcher)
+ synctimer->setSingleShot(true);
//Now update the rest of the UI
canmodify = false; //initial value
contextMenu = new QMenu(this);
@@ -260,7 +263,7 @@ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){
//Update statistics
if(list[i].isDir()){ numdirs++; }
else{ filebytes += list[i].size(); }
- //watcher->addPath(list[i].absoluteFilePath());
+ watcher->addPath(list[i].absoluteFilePath());
if(showDetails){
//Now create all the individual items for the details tree
QTreeWidgetItem *it;
@@ -474,8 +477,9 @@ void DirWidget::setupConnections(){
connect(deleteFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_rm_clicked() ) );
connect(refreshShort, SIGNAL(activated()), this, SLOT( refresh()) );
//Filesystem Watcher
- connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(refresh()) );
- connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(refresh()) ); //just in case
+ connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(startSync()) );
+ connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(startSync()) ); //just in case
+ connect(synctimer, SIGNAL(timeout()), this, SLOT(refresh()) );
}
QStringList DirWidget::currentSelection(){
@@ -820,3 +824,8 @@ void DirWidget::SelectionChanged(){
ui->tool_act_run->setEnabled(hasselection);
ui->tool_act_runwith->setEnabled(hasselection);
}
+
+void DirWidget::startSync(){
+ if(synctimer->isActive()){ synctimer->stop(); }
+ synctimer->start();
+} \ No newline at end of file
bgstack15