summaryrefslogtreecommitdiffstats
path: root/torrentwidget.cpp
diff options
context:
space:
mode:
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();
}