diff options
-rw-r--r-- | filesystemwidget.cpp | 26 | ||||
-rw-r--r-- | filesystemwidget.h | 4 | ||||
-rw-r--r-- | smdirmodel.h | 3 | ||||
-rw-r--r-- | smdirwatcher.cpp | 2 | ||||
-rw-r--r-- | smdirwatcher.h | 2 |
5 files changed, 37 insertions, 0 deletions
diff --git a/filesystemwidget.cpp b/filesystemwidget.cpp index 317d9c2..24d9ec3 100644 --- a/filesystemwidget.cpp +++ b/filesystemwidget.cpp @@ -19,6 +19,7 @@ #include <QMimeData> #include <QUrl> #include <QTimer> +#include <QProgressDialog> #include "filesystemwidget.h" #include "filesystemdirproxy.h" @@ -42,6 +43,10 @@ FilesystemWidget::FilesystemWidget(QWidget *parent) : QWidget(parent), mClipboar mFileModel = new SmDirModel(fHeaders, this); connect(mFileModel, SIGNAL(needResize()), this, SLOT(resizeFileView())); + mProgressDlg = 0; + connect(mFileModel->collector(), SIGNAL(totalFiles(int)), this, SLOT(setupProgressDlg(int))); + connect(mFileModel->collector(), SIGNAL(progress()), this, SLOT(progress())); + mDirProxy = new FilesystemDirProxy; mDirProxy->setSourceModel(mModel); mDirView = new SmTreeView; @@ -431,6 +436,27 @@ void FilesystemWidget::setWindowTitle(){ emit windowTitle(mWindowTitle); } +void FilesystemWidget::setupProgressDlg(int max){ + if(max <= 0){ + return; + } + if(!mProgressDlg){ + mProgressDlg = new QProgressDialog(this); + mProgressDlg->setLabel(new QLabel(tr("Gathering data... please wait!"))); + } + mProgressDlg->setMinimum(1); + mProgressDlg->setMaximum(max); + Helper::centerWidget(mProgressDlg); + mProgressDlg->show(); +} + +void FilesystemWidget::progress(){ + mProgressDlg->setValue(mProgressDlg->value() + 1); + if(mProgressDlg->value() >= mProgressDlg->maximum()){ + mProgressDlg->hide(); + } +} + void FilesystemWidget::deleteRecursive(const QFileInfo &start){ if(start.isDir()){ QDir curDir = QDir(start.absoluteFilePath());; diff --git a/filesystemwidget.h b/filesystemwidget.h index c8f7931..b9f082d 100644 --- a/filesystemwidget.h +++ b/filesystemwidget.h @@ -18,6 +18,7 @@ class FilesystemDirProxy; class FileView; class FilesystemFileProxy; class QLineEdit; +class QProgressDialog; class PictureViewer2; class FileSystemModel; class SheMovIconProvider; @@ -59,6 +60,8 @@ class FilesystemWidget : public QWidget { void moveToArchive(); void selectAllPV(); void setWindowTitle(); + void setupProgressDlg(int max); + void progress(); private slots: void dirExpanded(const QModelIndex &idx); @@ -83,6 +86,7 @@ class FilesystemWidget : public QWidget { FilesystemDirProxy *mDirProxy; FilesystemFileProxy *mFileProxy; QLineEdit *mDirEdit; + QProgressDialog *mProgressDlg; QString mWindowTitle; QString mTemplate; qint64 mSize; diff --git a/smdirmodel.h b/smdirmodel.h index 192992a..02ad608 100644 --- a/smdirmodel.h +++ b/smdirmodel.h @@ -31,6 +31,7 @@ class SmDirModel : public SmTreeModel { virtual QVariant data(const QModelIndex &index, int role) const; virtual bool setData(const QModelIndex &index, const QVariant &value, int role); bool isDir(const QModelIndex &idx) const; + SmDataColletor *collector() const { return mCollector; } QDir dir() const; QFileInfo fileInfo(const QModelIndex &idx) const; QTimer *refresTimer() { return mRefreshTimer; } @@ -48,6 +49,8 @@ class SmDirModel : public SmTreeModel { signals: void needResize(); + void totalFiles(int numFiles); + void progress(); private: SmDirWatcher *mWatch; diff --git a/smdirwatcher.cpp b/smdirwatcher.cpp index 3143212..2b03179 100644 --- a/smdirwatcher.cpp +++ b/smdirwatcher.cpp @@ -154,7 +154,9 @@ void SmDataColletor::run(){ SmTreeItem * SmDataColletor::populate(const QString &dir){ SmTreeItem *retval = new SmTreeItem(mNumFields); QDir d = QDir(dir); + emit totalFiles(d.entryInfoList().size()); foreach(QFileInfo fi, d.entryInfoList()){ + emit progress(); if(fi.fileName() == "."){ continue; } diff --git a/smdirwatcher.h b/smdirwatcher.h index fda828b..fccc1ed 100644 --- a/smdirwatcher.h +++ b/smdirwatcher.h @@ -65,6 +65,8 @@ class SmDataColletor : public QThread { void newData(const QList<QVariant>,int); void population(SmTreeItem*); void needRefresh(); + void totalFiles(int numFiles); + void progress(); private: SmTreeItem *populate(const QString &dir); |