diff options
author | Arno <arno@disconnect.de> | 2016-08-19 17:51:10 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2016-08-19 17:51:10 +0200 |
commit | 8ab990b7c6fb5348b09f451878a80e2c70695876 (patch) | |
tree | 8a90c848308c09e729d9256a6af921abfeb786b3 /shemovcleaner.cpp | |
parent | cead61f9598302a83fa72e99f82f7bfa2c0b19cb (diff) | |
download | ShemovCleaner-8ab990b7c6fb5348b09f451878a80e2c70695876.tar.gz ShemovCleaner-8ab990b7c6fb5348b09f451878a80e2c70695876.tar.bz2 ShemovCleaner-8ab990b7c6fb5348b09f451878a80e2c70695876.zip |
Added torrent support
The BEncode parser is loosely based on this:
https://github.com/jif/Bencode/blob/master/bencode.cpp
Not perfect, but enough to display all the essential data in the shiny
new TorrentDisplay dialog.
Diffstat (limited to 'shemovcleaner.cpp')
-rw-r--r-- | shemovcleaner.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/shemovcleaner.cpp b/shemovcleaner.cpp index 9625db1..beb5baf 100644 --- a/shemovcleaner.cpp +++ b/shemovcleaner.cpp @@ -22,6 +22,8 @@ #include "shemovcleaner.h" #include "filesorter.h" +#include "torrentparser.h" +#include "torrentdisplay.h" ShemovCleaner::ShemovCleaner(QWidget *parent) : QMainWindow(parent){ QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL", "shemovdb"); @@ -76,10 +78,13 @@ void ShemovCleaner::setupGui(){ connect(mDelete, SIGNAL(clicked()), this, SLOT(deleteFiles())); mMove = new QPushButton(tr("Move...")); connect(mMove, SIGNAL(clicked()), this, SLOT(moveFiles())); + mInfo = new QPushButton(tr("Torrent...")); + connect(mInfo, SIGNAL(clicked()), this, SLOT(torrentInfo())); QHBoxLayout *buttonL2 = new QHBoxLayout; buttonL2->addStretch(); buttonL2->addWidget(mMove); buttonL2->addWidget(mDelete); + buttonL2->addWidget(mInfo); buttonL2->addStretch(); QWidget *mainWidget = new QWidget; @@ -94,6 +99,7 @@ void ShemovCleaner::setupGui(){ setCentralWidget(mainWidget); createStatusbar(); + mTorrentDisplay = new TorrentDisplay(this); connect(mFileView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(fileSelectionChanged(QItemSelection,QItemSelection))); } @@ -189,6 +195,21 @@ void ShemovCleaner::moveFiles(){ } } +void ShemovCleaner::torrentInfo(){ + QModelIndexList sel = mFileView->selectionModel()->selectedRows(1); + if(sel.isEmpty()){ + return; + } + QString fn = sel.first().data(Qt::UserRole + 1).toString(); + TorrentParser p(fn, this); + QList<QVariant> tData = p.parse(); + tData.removeAll(QVariant()); + tData.removeAll(0); + mTorrentDisplay->setData(tData); + mTorrentDisplay->show(); + return; +} + void ShemovCleaner::selectDir(){ QString dir = QFileDialog::getExistingDirectory(this, tr("Select directory"), QDir::homePath()); mDir->setText(QDir::toNativeSeparators(dir)); |