aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm/BackgroundWorker.cpp
diff options
context:
space:
mode:
authorwilliam <william.os4y@gmail.com>2015-03-25 22:57:32 +0100
committerwilliam <william.os4y@gmail.com>2015-03-25 22:57:32 +0100
commit553105d997c3a29e9983ef1f1995d9593273de55 (patch)
tree9404a1b1fac4d20ecdfc169b2c16c922d3295cb2 /lumina-fm/BackgroundWorker.cpp
parentupdate FileSystemCapacity for Linux, Freebsd and DragonflyBSD (diff)
downloadlumina-553105d997c3a29e9983ef1f1995d9593273de55.tar.gz
lumina-553105d997c3a29e9983ef1f1995d9593273de55.tar.bz2
lumina-553105d997c3a29e9983ef1f1995d9593273de55.zip
display some filesystem's information on the statusbar in a thread safe manier
Diffstat (limited to 'lumina-fm/BackgroundWorker.cpp')
-rw-r--r--lumina-fm/BackgroundWorker.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/lumina-fm/BackgroundWorker.cpp b/lumina-fm/BackgroundWorker.cpp
index 1438f71e..c8d7cb17 100644
--- a/lumina-fm/BackgroundWorker.cpp
+++ b/lumina-fm/BackgroundWorker.cpp
@@ -85,4 +85,31 @@ void BackgroundWorker::startDirChecks(QString path){
if(!snapDirs.isEmpty()){ emit SnapshotsAvailable(baseSnapDir, snapDirs); }
qDebug() << "Found snapshots";
}
-} \ No newline at end of file
+}
+
+
+void BackgroundWorker::createStatusBarMsg(QFileInfoList fileList, QString path, QString message){
+ //collect some statistics of dir and display them in statusbar
+ int i = 0;
+ qreal totalSizes = 0;
+ foreach (QFileInfo fileInfo, fileList )
+ {
+ if (fileInfo.isFile()) totalSizes += fileInfo.size();
+ i += 1;
+ }
+ QString msgStatusBar = QString(tr("%1: %2")).arg(message).arg(i);
+ if (i>0 and totalSizes>1024*1024*1024)
+ msgStatusBar += QString(tr(", size: %1 Gb")).arg(totalSizes/1024/1024/1024, 0,'f', 2);
+ else if (i>0 and totalSizes>1024*1024)
+ msgStatusBar += QString(tr(", size: %1 Mb")).arg(totalSizes/1024/1024, 0,'f',2);
+ else if (i>0 and totalSizes>1024)
+ msgStatusBar += QString(tr(", size: %1 Kb")).arg(totalSizes/1024, 0, 'f' , 2);
+ else
+ if (totalSizes > 0) { msgStatusBar += QString(tr(", size: %1 b")).arg(totalSizes, 0, 'f' , 2);}
+ if (!path.isEmpty()) { //path could be empty when fileList is based on user's selection
+ QString capacity = LOS::FileSystemCapacity(path) ;
+ if (msgStatusBar.isEmpty()) msgStatusBar += tr("Capacity: ") + capacity;
+ else msgStatusBar += tr(", Capacity: ") + capacity;
+ }
+ if (!msgStatusBar.isEmpty()) emit Si_DisplayStatusBar(msgStatusBar);
+}
bgstack15