diff --git a/src/localLister.cpp b/src/localLister.cpp index 36a56fb7aa20ac2ebc8a5df2a7529341b10cd65c..16fb3cedb1004ceada7c661d5b22e7265d551e13 100644 --- a/src/localLister.cpp +++ b/src/localLister.cpp @@ -189,13 +189,15 @@ LocalLister::scan(const QByteArray &path, const QByteArray &dirname) continue; } - if (S_ISREG(statbuf.st_mode)) //file + if (S_ISREG(statbuf.st_mode)) { //file #ifndef Q_OS_WIN - cwd->append(ent->d_name, (statbuf.st_blocks * S_BLKSIZE)); + const size_t size = (statbuf.st_blocks * S_BLKSIZE); #else - cwd->append(ent->d_name, statbuf.st_size); + const size_t size = statbuf.st_size; #endif - + cwd->append(ent->d_name, size); + m_parent->m_totalSize += size; + } else if (S_ISDIR(statbuf.st_mode)) //folder { Folder *d = nullptr; diff --git a/src/progressBox.cpp b/src/progressBox.cpp index 458017d7260ac3766566a59fab688086b5b7e5c6..4f926694889c17513336df8b051976e241c90f5e 100644 --- a/src/progressBox.cpp +++ b/src/progressBox.cpp @@ -25,6 +25,7 @@ #include "mainWindow.h" #include +#include #include #include @@ -45,7 +46,7 @@ ProgressBox::ProgressBox(QWidget *parent, Filelight::MainWindow *mainWindow, Fil setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - setText(999999); + setText(999999, 0); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); setMinimumSize(300, 300); @@ -66,7 +67,7 @@ ProgressBox::start() //slot void ProgressBox::report() //slot { - setText(m_manager->files()); + setText(m_manager->files(), m_manager->totalSize()); update(); //repaint(); } @@ -85,9 +86,9 @@ ProgressBox::halt() } void -ProgressBox::setText(int files) +ProgressBox::setText(int files, size_t totalSize) { - m_text = i18np("%1 File", "%1 Files", files); + m_text = i18ncp("Scanned number of files and size so far", "%1 File, %2", "%1 Files, %2", files, KFormat().formatByteSize(totalSize)); m_textWidth = fontMetrics().boundingRect(m_text).width(); m_textHeight = fontMetrics().height(); } diff --git a/src/progressBox.h b/src/progressBox.h index 2f29ab3125d871f93f0317dfad57ee0ab9090170..d9525a5816a9fd00021213c0ceb6220495551685 100644 --- a/src/progressBox.h +++ b/src/progressBox.h @@ -38,7 +38,7 @@ class ProgressBox : public QWidget public: ProgressBox(QWidget *parent, Filelight::MainWindow *mainWindow, Filelight::ScanManager *scanManager); - void setText(int); + void setText(int files, size_t totalSize); public Q_SLOTS: void start(); diff --git a/src/remoteLister.cpp b/src/remoteLister.cpp index 27f0ff35556e98cbf2048c1d6867c1aef0afcf25..fd9ca05ae827f874f0e59a1e9cf9cf3dcf3653c2 100644 --- a/src/remoteLister.cpp +++ b/src/remoteLister.cpp @@ -112,10 +112,12 @@ void RemoteLister::onCompleted() const KFileItemList items = KDirLister::items(); for (KFileItemList::ConstIterator it = items.begin(), end = items.end(); it != end; ++it) { - if (it->isDir()) + if (it->isDir()) { m_store->stores += new Store(it->url(), it->name(), m_store); - else + } else { m_store->folder->append(it->name().toUtf8().constData(), it->size()); + m_manager->m_totalSize += it->size(); + } m_manager->m_files++; } diff --git a/src/scan.h b/src/scan.h index 4af468e18371d8596e0aa091625c59e6b57df10a..e1d2d443617771e794435baa0877daecfc5e8de8 100644 --- a/src/scan.h +++ b/src/scan.h @@ -47,8 +47,11 @@ public: bool start(const QUrl& path); bool running() const; - uint files() const { - return m_files; + int files() const { + return m_files.loadRelaxed(); + } + size_t totalSize() const { + return m_totalSize.loadRelaxed(); } void invalidateCacheFor(const QUrl &url); @@ -66,7 +69,8 @@ Q_SIGNALS: private: bool m_abort; - uint m_files; + QAtomicInt m_files; + QAtomicInteger m_totalSize; QMutex m_mutex; LocalLister *m_thread;