summaryrefslogtreecommitdiffstats
path: root/torrentwidget.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2016-09-22 08:41:38 +0200
committerArno <arno@disconnect.de>2016-09-22 08:41:38 +0200
commit2e1c915cf2d9ec394c64ee0d6d7c705b06cce8cb (patch)
treefa2d7774987576c4d052be1a1a298afd2c7f2b41 /torrentwidget.cpp
parentbeb06f3603e569cfed7e0fd8bf71b4c9a8eac673 (diff)
downloadShemovCleaner-2e1c915cf2d9ec394c64ee0d6d7c705b06cce8cb.tar.gz
ShemovCleaner-2e1c915cf2d9ec394c64ee0d6d7c705b06cce8cb.tar.bz2
ShemovCleaner-2e1c915cf2d9ec394c64ee0d6d7c705b06cce8cb.zip
Give feedback on gathering data
Use the ProgressBar when gathering torrent data from a directory with many entries. Sprinkle processEvents() here and there to show the progress.
Diffstat (limited to 'torrentwidget.cpp')
-rw-r--r--torrentwidget.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/torrentwidget.cpp b/torrentwidget.cpp
index 28a86c1..08c9a86 100644
--- a/torrentwidget.cpp
+++ b/torrentwidget.cpp
@@ -20,6 +20,9 @@
#include <QToolBar>
#include <QMenuBar>
#include <QClipboard>
+#include <QCompleter>
+#include <QDirModel>
+#include <QProgressBar>
#include <QApplication>
#include "torrentwidget.h"
@@ -30,7 +33,6 @@
TorrentWidget::TorrentWidget(QWidget *parent) : QWidget(parent), mExt("*.torrent") {
setupGui();
- gatherData();
}
TorrentWidget::~TorrentWidget(){
@@ -40,6 +42,11 @@ TorrentWidget::~TorrentWidget(){
void TorrentWidget::setupGui(){
mDir = new QLineEdit;
+ QCompleter *torDirCompl = new QCompleter(this);
+ torDirCompl->setModel(new QDirModel(torDirCompl));
+ mDir->setCompleter(torDirCompl);
+ connect(mDir, SIGNAL(returnPressed()), this, SLOT(setDir()));
+
mSelDir = new QPushButton(tr("Browse..."));
connect(mSelDir, SIGNAL(clicked()), this, SLOT(selectDir()));
@@ -149,6 +156,11 @@ void TorrentWidget::gatherData(){
q.prepare("SELECT COUNT(*) FROM metadata WHERE tsubject = :fn");
QDir d(mDir->text());
QFileInfoList fl = d.entryInfoList(QStringList() << mExt, QDir::Files, QDir::Name);
+ mProgressBar->reset();
+ mProgressBar->setMinimum(0);
+ mProgressBar->setMaximum(fl.count() - 1);
+ int count = 0;
+ mFileView->setSortingEnabled(false);
mModel->clear();
QStandardItem *root = mModel->invisibleRootItem();
mModel->setHorizontalHeaderLabels(QStringList() << QChar(0x26A7) << tr("Name") << tr("Created"));
@@ -184,7 +196,10 @@ void TorrentWidget::gatherData(){
fData[NameColumn]->setForeground(redBrush);
}
root->appendRow(fData);
+ mProgressBar->setValue(++count);
}
+ qApp->processEvents();
+ mFileView->setSortingEnabled(true);
readHeaderData();
}
@@ -310,8 +325,18 @@ void TorrentWidget::contextMenuEvent(QContextMenuEvent *e){
}
void TorrentWidget::selectDir(){
- QString dir = QFileDialog::getExistingDirectory(this, tr("Select directory"), QDir::homePath());
- mDir->setText(QDir::toNativeSeparators(dir));
+ QSettings s;
+ QString sDir = s.value("dirs/torrentdir", QDir::homePath()).toString();
+ QString dir = QFileDialog::getExistingDirectory(this, tr("Select directory"), sDir);
+ if(!dir.isEmpty()){
+ mDir->setText(QDir::toNativeSeparators(dir));
+ setDir();
+ }
+}
+
+void TorrentWidget::setDir(){
+ QSettings s;
+ s.setValue("dirs/torrentdir", mDir->text());
gatherData();
}