+ - FEATURE: Now remembers filtered pieces in a torrent on restart

+    - FEATURE: Now updating pieces progress in real time in torrent properties
+    - BUGFIX: Fixed memory leaks in torrent properties
Updated italian and German translation
This commit is contained in:
Christophe Dumez 2006-10-06 18:07:01 +00:00
parent e83b872c4b
commit 117448fb0b
11 changed files with 325 additions and 310 deletions

View file

@ -14,6 +14,8 @@
- FEATURE: Individual share ratio is now displayed in each torrent properties.
- FEATURE: Tuned default settings to improve download speed
- FEATURE: Downloading from an URL will retry 10 times if too many users.
- FEATURE: Now remembers filtered pieces in a torrent on restart
- FEATURE: Now updating pieces progress in real time in torrent properties
- I18N: Added Norwegian translation
- BUGFIX: Fixed a memory leak when pressing OK in torrent properties
- BUGFIX: Improved code so that GUI never freeze during downloading from an url
@ -30,7 +32,8 @@
- BUGFIX: Fixed Isohunt search engine
- BUGFIX: Fixed download from URL function (was buggy)
- BUGFIX: Fixed download button in search engine
- BUGFIX: Switched to full allocation mode to fix selective download
- BUGFIX: Fixed selective download
- BUGFIX: Fixed memory leaks in torrent properties
- COSMETIC: Now displaying the number of downloads in tab title
- COSMETIC: Redesigned download from url dialog
- COSMETIC: Added a message to warn user that we started download from an url

5
TODO
View file

@ -34,9 +34,6 @@
// Before 0.7.0
- Test tracker authentication
- Wait for libtorrent v0.11rc release
- Fix this when deletingSelection sometimes:
terminate called after throwing an instance of 'libtorrent::invalid_handle'
what(): invalid torrent handle used
Abandon
- Fix selective download

View file

@ -719,6 +719,56 @@ void GUI::saveWindowSize() const{
}
}
bool GUI::loadFilteredPieces(torrent_handle &h){
bool has_filtered_pieces = false;
torrent_info torrentInfo = h.get_torrent_info();
QString fileName = QString(torrentInfo.name().c_str());
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".pieces");
// Read saved file
if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){
return has_filtered_pieces;
}
QByteArray pieces_selection = pieces_file.readAll();
pieces_file.close();
QList<QByteArray> pieces_selection_list = pieces_selection.split('\n');
if(pieces_selection_list.size() != torrentInfo.num_files()+1){
std::cout << "Error: Corrupted pieces file\n";
return has_filtered_pieces;
}
for(int i=0; i<torrentInfo.num_files(); ++i){
int isFiltered = pieces_selection_list.at(i).toInt();
if( isFiltered < 0 || isFiltered > 1){
isFiltered = 0;
}
h.filter_piece(i, pieces_selection_list.at(i).toInt());
if(isFiltered){
has_filtered_pieces = true;
}
}
return has_filtered_pieces;
}
bool GUI::hasFilteredPieces(const QString& fileName){
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".pieces");
// Read saved file
if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){
return false;
}
QByteArray pieces_selection = pieces_file.readAll();
pieces_file.close();
QList<QByteArray> pieces_selection_list = pieces_selection.split('\n');
for(int i=0; i<pieces_selection_list.size()-1; ++i){
int isFiltered = pieces_selection_list.at(i).toInt();
if( isFiltered < 0 || isFiltered > 1){
isFiltered = 0;
}
if(isFiltered){
return true;
}
}
return false;
}
void GUI::loadWindowSize(){
qDebug("Loading window size");
QFile lastWindowSize(misc::qBittorrentPath()+"lastWindowSize.txt");
@ -1075,6 +1125,8 @@ void GUI::saveFastResumeData() const{
bencode(std::ostream_iterator<char>(out), resumeData);
}
}
// Remove torrent
s->remove_torrent(h);
}
qDebug("Fast resume data saved");
}
@ -1111,7 +1163,7 @@ void GUI::deleteAll(){
torrents = torrentBackup.entryList();
QString torrent;
foreach(torrent, torrents){
if(torrent.endsWith(".fastresume") || torrent.endsWith(".torrent") || torrent.endsWith(".paused") || torrent.endsWith(".incremental")){
if(torrent.endsWith(".fastresume") || torrent.endsWith(".torrent") || torrent.endsWith(".pieces") || torrent.endsWith(".paused") || torrent.endsWith(".incremental")){
torrentBackup.remove(torrent);
}
}
@ -1175,6 +1227,7 @@ void GUI::deleteSelection(){
torrentBackup.remove(fileName+".fastresume");
torrentBackup.remove(fileName+".paused");
torrentBackup.remove(fileName+".incremental");
torrentBackup.remove(fileName+".pieces");
// Update info bar
setInfoBar("'" + fileName +"' "+tr("removed.", "<file> removed."));
--nbTorrents;
@ -1276,9 +1329,17 @@ void GUI::addTorrents(const QStringList& pathsList, bool fromScanDir, const QStr
}
int row = DLListModel->rowCount();
// Adding files to bittorrent session
h = s->add_torrent(t, fs::path(saveDir.path().toStdString()), resume_data, false);
if(hasFilteredPieces(QString(t.name().c_str()))){
h = s->add_torrent(t, fs::path(saveDir.path().toStdString()), resume_data, false);
qDebug("Full allocation mode");
}else{
h = s->add_torrent(t, fs::path(saveDir.path().toStdString()), resume_data, true);
qDebug("Compact allocation mode");
}
h.set_max_connections(60);
h.set_max_uploads(-1);
// Load filtered pieces
loadFilteredPieces(h);
//qDebug("Added to session");
torrent_status torrentStatus = h.status();
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)torrentStatus.progress));
@ -1378,6 +1439,88 @@ void GUI::addTorrents(const QStringList& pathsList, bool fromScanDir, const QStr
}
}
void GUI::reloadTorrent(const torrent_handle &h, bool compact_mode){
QDir saveDir(options->getSavePath()), torrentBackup(misc::qBittorrentPath() + "BT_backup");
QString fileName = QString(h.get_torrent_info().name().c_str());
qDebug("Reloading torrent: %s", fileName.toStdString().c_str());
torrent_handle new_h;
entry resumeData;
torrent_info t = h.get_torrent_info();
// Checking if torrentBackup Dir exists
// create it if it is not
if(! torrentBackup.exists()){
torrentBackup.mkpath(torrentBackup.path());
}
// Write fast resume data
// Pause download (needed before fast resume writing)
h.pause();
// Extracting resume data
if (h.has_metadata()){
// get fast resume data
resumeData = h.write_resume_data();
}
int row = -1;
// Delete item from download list
for(int i=0; i<DLListModel->rowCount(); ++i){
if(DLListModel->data(DLListModel->index(i, NAME)).toString()==fileName){
row = i;
break;
}
}
Q_ASSERT(row != -1);
DLListModel->removeRow(row);
// Remove torrent
s->remove_torrent(h);
handles.remove(fileName);
// Add torrent again to session
unsigned short timeout = 0;
while(h.is_valid() && timeout < 6){
SleeperThread::msleep(1000);
++timeout;
}
if(h.is_valid()){
std::cout << "Error: Couldn't reload the torrent\n";
return;
}
new_h = s->add_torrent(t, fs::path(saveDir.path().toStdString()), resumeData, compact_mode);
if(compact_mode){
qDebug("Using compact allocation mode");
}else{
qDebug("Using full allocation mode");
}
handles.insert(QString(t.name().c_str()), new_h);
new_h.set_max_connections(60);
new_h.set_max_uploads(-1);
// Load filtered pieces
loadFilteredPieces(new_h);
// Adding torrent to download list
DLListModel->insertRow(row);
DLListModel->setData(DLListModel->index(row, NAME), QVariant(t.name().c_str()));
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)t.total_size()));
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.));
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.));
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
// Pause torrent if it was paused last time
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+QString(t.name().c_str())+".paused")){
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused")));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
setRowColor(row, "red");
}else{
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting...")));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
setRowColor(row, "grey");
}
// Pause torrent if it was paused last time
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".paused")){
new_h.pause();
}
// Incremental download
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".incremental")){
qDebug("Incremental download enabled for %s", fileName.toStdString().c_str());
new_h.set_sequenced_download_threshold(15);
}
}
// As program parameters, we can get paths or urls.
// This function parse the parameters and call
// the right addTorrent function, considering
@ -1409,6 +1552,7 @@ void GUI::showProperties(const QModelIndex &index){
torrent_handle h = handles.value(fileName);
QStringList errors = trackerErrors.value(fileName, QStringList(tr("None")));
properties *prop = new properties(this, h, errors);
connect(prop, SIGNAL(changedFilteredPieces(torrent_handle, bool)), this, SLOT(reloadTorrent(torrent_handle, bool)));
prop->show();
}

View file

@ -153,6 +153,9 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void addUnauthenticatedTracker(QPair<torrent_handle,std::string> tracker);
void processDownloadedFile(QString url, QString file_path, int return_code, QString errorBuffer);
void downloadFromURLList(const QStringList& url_list);
bool loadFilteredPieces(torrent_handle &h);
bool hasFilteredPieces(const QString& fileName);
void reloadTorrent(const torrent_handle &h, bool compact_mode = true);
// Search slots
void on_search_button_clicked();
void on_stop_search_button_clicked();

View file

@ -119,7 +119,7 @@ class downloadThread : public QThread {
QFile::remove(filePath.c_str());
return;
}
int retries = 0;
unsigned short retries = 0;
bool to_many_users = false;
do{
// Perform Download

Binary file not shown.

View file

@ -99,19 +99,19 @@ Copyright (c) 2006 Christophe Dumez&lt;br&gt;
</message>
<message>
<source>Birthday:</source>
<translation type="unfinished"></translation>
<translation>Geburtstag:</translation>
</message>
<message>
<source>Occupation:</source>
<translation type="unfinished"></translation>
<translation>Beschäftigung:</translation>
</message>
<message>
<source>03/05/1985</source>
<translation type="unfinished">03/05/1985</translation>
<translation>03.05.1985</translation>
</message>
<message>
<source>Student in computer science</source>
<translation type="unfinished"></translation>
<translation>Informatikstudent</translation>
</message>
</context>
<context>
@ -361,23 +361,23 @@ Copyright (c) 2006 Christophe Dumez&lt;br&gt;
</message>
<message>
<source>DHT (Trackerless):</source>
<translation type="unfinished"></translation>
<translation>DHT (Trackerlos):</translation>
</message>
<message>
<source>Disable DHT (Trackerless) support</source>
<translation type="unfinished"></translation>
<translation>Deaktiviere DHT (Trackerlos) Unterstützung</translation>
</message>
<message>
<source>Automatically clear finished downloads</source>
<translation type="unfinished"></translation>
<translation>Abgeschlossene Downloads automatisch beseitigen</translation>
</message>
<message>
<source>Preview program</source>
<translation type="unfinished"></translation>
<translation>Vorschau Programm</translation>
</message>
<message>
<source>Audio/Video player:</source>
<translation type="unfinished"></translation>
<translation>Audio/Video Player:</translation>
</message>
</context>
<context>
@ -759,35 +759,36 @@ Changelog:
</message>
<message>
<source>Preview process already running</source>
<translation type="unfinished"></translation>
<translation>Preview Prozess läuft bereits</translation>
</message>
<message>
<source>There is already another preview process running.
Please close the other one first.</source>
<translation type="unfinished"></translation>
<translation>Ein anderer Preview Prozess läuft zu Zeit.
Bitte schliessen Sie diesen zuerst.</translation>
</message>
<message>
<source>Couldn&apos;t download</source>
<comment>Couldn&apos;t download &lt;file&gt;</comment>
<translation type="unfinished"></translation>
<translation>Konnte Datei nicht downloaden</translation>
</message>
<message>
<source>reason:</source>
<comment>Reason why the download failed</comment>
<translation type="unfinished"></translation>
<translation>Grund:</translation>
</message>
<message>
<source>Downloading</source>
<comment>Example: Downloading www.example.com/test.torrent</comment>
<translation type="unfinished">Lade</translation>
<translation>Lade</translation>
</message>
<message>
<source>Please wait...</source>
<translation type="unfinished"></translation>
<translation>Bitte warten...</translation>
</message>
<message>
<source>Transfers</source>
<translation type="unfinished"></translation>
<translation type="unfinished">Transfer</translation>
</message>
</context>
<context>
@ -982,15 +983,15 @@ Please close the other one first.</source>
</message>
<message>
<source>Transfers</source>
<translation type="unfinished"></translation>
<translation>Transfer</translation>
</message>
<message>
<source>Preview file</source>
<translation type="unfinished"></translation>
<translation>Vorschau Datei</translation>
</message>
<message>
<source>Clear log</source>
<translation type="unfinished"></translation>
<translation>Log löschen</translation>
</message>
</context>
<context>
@ -1043,62 +1044,62 @@ Please close the other one first.</source>
</message>
<message>
<source>Preview impossible</source>
<translation type="unfinished"></translation>
<translation>Vorschau unmöglich</translation>
</message>
<message>
<source>Sorry, we can&apos;t preview this file</source>
<translation type="unfinished"></translation>
<translation>Bedauere, wir können keine Vorschau für diese Datei erstellen</translation>
</message>
<message>
<source>Name</source>
<translation type="unfinished">Name</translation>
<translation>Name</translation>
</message>
<message>
<source>Size</source>
<translation type="unfinished">Grösse</translation>
<translation>Grösse</translation>
</message>
<message>
<source>Progress</source>
<translation type="unfinished">Fortschritt</translation>
<translation>Fortschritt</translation>
</message>
<message>
<source>No URL entered</source>
<translation type="unfinished"></translation>
<translation>Keine URL eingegeben</translation>
</message>
<message>
<source>Please type at least one URL.</source>
<translation type="unfinished"></translation>
<translation>Bitte geben Sie mindestens eine URL an.</translation>
</message>
</context>
<context>
<name>authentication</name>
<message>
<source>Tracker authentication</source>
<translation type="unfinished"></translation>
<translation>Tracker Authentifizierung</translation>
</message>
<message>
<source>Tracker:</source>
<translation type="unfinished"></translation>
<translation>Tracker:</translation>
</message>
<message>
<source>Login</source>
<translation type="unfinished"></translation>
<translation>Login</translation>
</message>
<message>
<source>Username:</source>
<translation type="unfinished"></translation>
<translation>Benutzername:</translation>
</message>
<message>
<source>Password:</source>
<translation type="unfinished">Kennwort:</translation>
<translation>Kennwort:</translation>
</message>
<message>
<source>Log in</source>
<translation type="unfinished"></translation>
<translation>Einloggen</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Abbrechen</translation>
<translation>Abbrechen</translation>
</message>
</context>
<context>
@ -1211,23 +1212,23 @@ Please close the other one first.</source>
<name>downloadFromURL</name>
<message>
<source>Download Torrents from URLs</source>
<translation type="unfinished"></translation>
<translation>Torrents von URLs laden</translation>
</message>
<message>
<source>Only one URL per line</source>
<translation type="unfinished"></translation>
<translation>Nur eine URL pro Zeile</translation>
</message>
<message>
<source>Download</source>
<translation type="unfinished"></translation>
<translation>Lade</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Abbrechen</translation>
<translation>Abbrechen</translation>
</message>
<message>
<source>Download from urls</source>
<translation type="unfinished"></translation>
<translation>Von URLs laden</translation>
</message>
</context>
<context>
@ -1373,30 +1374,30 @@ Please close the other one first.</source>
</message>
<message>
<source>Choose your favourite preview program</source>
<translation type="unfinished"></translation>
<translation>Wählen Sie ihr bevorzugtes Vorschau Programm</translation>
</message>
</context>
<context>
<name>preview</name>
<message>
<source>Preview selection</source>
<translation type="unfinished"></translation>
<translation>Vorschau auswahl</translation>
</message>
<message>
<source>File preview</source>
<translation type="unfinished"></translation>
<translation>Datei vorschauen</translation>
</message>
<message>
<source>The following files support previewing, &lt;br&gt;please select one of them:</source>
<translation type="unfinished"></translation>
<translation>Die folgenden Dateien unterstützen Vorschau, &lt;br&gt;bitte wählen Sie eine:</translation>
</message>
<message>
<source>Preview</source>
<translation type="unfinished"></translation>
<translation>Vorschau</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished">Abbrechen</translation>
<translation>Abbrechen</translation>
</message>
</context>
<context>
@ -1615,15 +1616,15 @@ Please close the other one first.</source>
</message>
<message>
<source>Options</source>
<translation type="unfinished">Optionen</translation>
<translation>Optionen</translation>
</message>
<message>
<source>Download in correct order (slower but good for previewing)</source>
<translation type="unfinished"></translation>
<translation>In richtiger Reihenfolge herunterladen (langsamer, aber besser zum Vorschauen)</translation>
</message>
<message>
<source>Share Ratio:</source>
<translation type="unfinished"></translation>
<translation>Share Verhältnis:</translation>
</message>
</context>
</TS>

Binary file not shown.

View file

@ -66,26 +66,18 @@
&lt;br&gt;
Copyright &#xa9; 2006 by Christophe Dumez&lt;br&gt;
&lt;br&gt; &lt;u&gt;Home Page:&lt;/u&gt; &lt;i&gt;http://www.qbittorrent.org&lt;/i&gt;&lt;br&gt;</source>
<translation type="obsolete">Un client bittorrent in Qt4 e libtorrent. Scritto in c++.&lt;br&gt;&lt;br&gt;Copyright © 2006 di Christophe Dumez&lt;br&gt;
&lt;br&gt; &lt;u&gt;Home Page:&lt;/u&gt; &lt;i&gt;http://www.qbittorrent.org&lt;/i&gt;&lt;br&gt;</translation>
</message>
<message encoding="UTF-8">
<source>A bittorrent client using Qt4 and libtorrent, programmed in C++.&lt;br&gt;
&lt;br&gt;
Copyright © 2006 by Christophe Dumez&lt;br&gt;
&lt;br&gt; &lt;u&gt;Home Page:&lt;/u&gt; &lt;i&gt;http://www.qbittorrent.org&lt;/i&gt;&lt;br&gt;</source>
<translation>Un client bittorrent in Qt4 e libtorrent. Scritto in C++.&lt;br&gt;
<translation type="obsolete">Un client bittorrent in Qt4 e libtorrent. Scritto in C++.&lt;br&gt;
&lt;br&gt;
Copyright © 2006 di Christophe Dumez&lt;br&gt;
&lt;br&gt; &lt;u&gt;Home Page:&lt;/u&gt; &lt;i&gt;http://www.qbittorrent.org&lt;/i&gt;&lt;br&gt;</translation>
</message>
<message>
<source>Birthday:</source>
<translation type="unfinished"></translation>
<translation>Compleanno:</translation>
</message>
<message>
<source>Occupation:</source>
<translation type="unfinished"></translation>
<translation>Occupazione:</translation>
</message>
<message>
<source>03/05/1985</source>
@ -93,6 +85,13 @@ Copyright © 2006 di Christophe Dumez&lt;br&gt;
</message>
<message>
<source>Student in computer science</source>
<translation>Studente di informatica</translation>
</message>
<message encoding="UTF-8">
<source>A bittorrent client using Qt4 and libtorrent, programmed in C++.&lt;br&gt;
&lt;br&gt;
Copyright © 2006 by Christophe Dumez&lt;br&gt;
&lt;br&gt; &lt;u&gt;Home Page:&lt;/u&gt; &lt;i&gt;http://www.qbittorrent.org&lt;/i&gt;&lt;br&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -141,10 +140,6 @@ Copyright © 2006 di Christophe Dumez&lt;br&gt;
<source>...</source>
<translation>...</translation>
</message>
<message>
<source>Kb/s</source>
<translation type="obsolete">Kb/s</translation>
</message>
<message>
<source>Disable</source>
<translation>Disabilitare</translation>
@ -217,14 +212,6 @@ Copyright © 2006 di Christophe Dumez&lt;br&gt;
<source>Share ratio:</source>
<translation>Percentuale di condivisione:</translation>
</message>
<message>
<source>1 KB DL = </source>
<translation type="obsolete">1 KB DL = </translation>
</message>
<message>
<source>KB UP max.</source>
<translation type="obsolete">KB UP max.</translation>
</message>
<message>
<source>Activate IP Filtering</source>
<translation>Attivare filtraggio IP</translation>
@ -289,10 +276,6 @@ Copyright © 2006 di Christophe Dumez&lt;br&gt;
<source>Ask for confirmation on exit</source>
<translation>Chiedi conferma ed esci</translation>
</message>
<message>
<source>Clear finished downloads on exit</source>
<translation type="obsolete">Cancella i download finiti all&apos;uscita</translation>
</message>
<message>
<source>Go to systray when minimizing window</source>
<translation>Riduci alla systray quando si minimizza la finestra</translation>
@ -327,23 +310,23 @@ Copyright © 2006 di Christophe Dumez&lt;br&gt;
</message>
<message>
<source>DHT (Trackerless):</source>
<translation type="unfinished"></translation>
<translation>DHT (senza tracker):</translation>
</message>
<message>
<source>Disable DHT (Trackerless) support</source>
<translation type="unfinished"></translation>
<translation>Disabilita il supporto DHT</translation>
</message>
<message>
<source>Automatically clear finished downloads</source>
<translation type="unfinished"></translation>
<translation>Cancella automaticamente i download terminati</translation>
</message>
<message>
<source>Preview program</source>
<translation type="unfinished"></translation>
<translation>Programma di anteprima</translation>
</message>
<message>
<source>Audio/Video player:</source>
<translation type="unfinished"></translation>
<translation>Player audio/video:</translation>
</message>
</context>
<context>
@ -352,10 +335,6 @@ Copyright © 2006 di Christophe Dumez&lt;br&gt;
<source>Open Torrent Files</source>
<translation>Apri file torrent</translation>
</message>
<message>
<source>Unknown</source>
<translation type="obsolete">Sconosciuto</translation>
</message>
<message>
<source>This file is either corrupted or this isn&apos;t a torrent.</source>
<translation>Questo file è corrotto o non è un torrent</translation>
@ -376,14 +355,6 @@ Copyright © 2006 di Christophe Dumez&lt;br&gt;
<source>Are you sure you want to delete the selected item(s) in download list?</source>
<translation>Sei sicuro di voler cancellare gli elementi selezionati dalla lista dei download?</translation>
</message>
<message>
<source>paused</source>
<translation type="obsolete">In pausa</translation>
</message>
<message>
<source>started</source>
<translation type="obsolete">Iniziato</translation>
</message>
<message>
<source>Finished</source>
<translation>Finito</translation>
@ -412,10 +383,6 @@ Copyright © 2006 di Christophe Dumez&lt;br&gt;
<source>All Downloads Resumed.</source>
<translation>Tutti i download ripresi.</translation>
</message>
<message>
<source>DL Speed: </source>
<translation type="obsolete">Velocità Download:</translation>
</message>
<message>
<source> started.</source>
<translation>Iniziato.</translation>
@ -472,10 +439,6 @@ Copyright © 2006 di Christophe Dumez&lt;br&gt;
<source>qBittorrent </source>
<translation>qBittorrent </translation>
</message>
<message>
<source>qBittorrent</source>
<translation type="obsolete">qBittorrent</translation>
</message>
<message>
<source>Are you sure? -- qBittorrent</source>
<translation>Sei sicuro? -- qBittorrent</translation>
@ -528,22 +491,6 @@ Copyright © 2006 di Christophe Dumez&lt;br&gt;
<source>Searching...</source>
<translation>Ricerca...</translation>
</message>
<message>
<source>Could not create search plugin.</source>
<translation type="obsolete">Impossibile creare il plugin di ricerca</translation>
</message>
<message>
<source>Stopped</source>
<translation type="obsolete">Fermato</translation>
</message>
<message>
<source>Torrent file URL</source>
<translation type="obsolete">URL del file Torrent</translation>
</message>
<message>
<source>Torrent file URL:</source>
<translation type="obsolete">URL del file Torrent</translation>
</message>
<message>
<source>Are you sure you want to quit? -- qBittorrent</source>
<translation>Sicuro di voler uscire? -- qBittorrent</translation>
@ -552,26 +499,10 @@ Copyright © 2006 di Christophe Dumez&lt;br&gt;
<source>Are you sure you want to quit qbittorrent?</source>
<translation>Sicuro di voler uscire da qBittorrent?</translation>
</message>
<message>
<source>Timed out</source>
<translation type="obsolete">Time out</translation>
</message>
<message>
<source>Error during search...</source>
<translation type="obsolete">Errore nella ricerca...</translation>
</message>
<message>
<source>KiB/s</source>
<translation>Kb/s</translation>
</message>
<message>
<source> KiB/s</source>
<translation type="obsolete">Kb/s</translation>
</message>
<message>
<source>Stalled</source>
<translation type="obsolete">In stallo</translation>
</message>
<message>
<source>Search is finished</source>
<translation>Ricerca completata</translation>
@ -588,10 +519,6 @@ Copyright © 2006 di Christophe Dumez&lt;br&gt;
<source>Search returned no results</source>
<translation>La ricerca non ha prodotto risultati</translation>
</message>
<message>
<source>Search is Finished</source>
<translation type="obsolete">Ricerca finita</translation>
</message>
<message>
<source>Search plugin update -- qBittorrent</source>
<translation>Aggiornamento del plugin di ricerca -- qBittorrent</translation>
@ -668,36 +595,42 @@ Changelog:</translation>
</message>
<message>
<source>Preview process already running</source>
<translation type="unfinished"></translation>
<translation>Processo di anteprima già in esecuzione</translation>
</message>
<message>
<source>There is already another preview process running.
Please close the other one first.</source>
<translation type="unfinished"></translation>
<translation>C&apos;è già un altro processo di anteprima avviato. Per favore chiuderlo.</translation>
</message>
<message>
<source>Couldn&apos;t download</source>
<comment>Couldn&apos;t download &lt;file&gt;</comment>
<translation type="unfinished"></translation>
<translation>Impossibile scaricare</translation>
</message>
<message>
<source>reason:</source>
<comment>Reason why the download failed</comment>
<translation type="unfinished"></translation>
<translation>motivo:</translation>
</message>
<message>
<source>Downloading</source>
<comment>
Example: Downloading www.example.com/test.torrent</comment>
<translation type="obsolete">Scaricando</translation>
</message>
<message>
<source>Please wait...</source>
<translation>Attendere prego...</translation>
</message>
<message>
<source>Transfers</source>
<translation type="unfinished">Trasferimenti</translation>
</message>
<message>
<source>Downloading</source>
<comment>Example: Downloading www.example.com/test.torrent</comment>
<translation type="unfinished">Scaricando</translation>
</message>
<message>
<source>Please wait...</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Transfers</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWindow</name>
@ -713,34 +646,6 @@ Please close the other one first.</source>
<source>Total UP Speed:</source>
<translation>Velocità totale upload:</translation>
</message>
<message>
<source>Name</source>
<translation type="obsolete">Nome</translation>
</message>
<message>
<source>Size</source>
<translation type="obsolete">Dimensione</translation>
</message>
<message>
<source>% DL</source>
<translation type="obsolete">% scaricato</translation>
</message>
<message>
<source>DL Speed</source>
<translation type="obsolete">Velocità download</translation>
</message>
<message>
<source>UP Speed</source>
<translation type="obsolete">velocità upload</translation>
</message>
<message>
<source>Status</source>
<translation type="obsolete">Status</translation>
</message>
<message>
<source>ETA</source>
<translation type="obsolete">ETA</translation>
</message>
<message>
<source>&amp;Options</source>
<translation>&amp;Opzioni</translation>
@ -809,10 +714,6 @@ Please close the other one first.</source>
<source>Connection Status</source>
<translation>Status connessione</translation>
</message>
<message>
<source>Downloads</source>
<translation type="obsolete">Downloads</translation>
</message>
<message>
<source>Search</source>
<translation>Ricerca</translation>
@ -841,18 +742,6 @@ Please close the other one first.</source>
<source>Stop</source>
<translation>Stop</translation>
</message>
<message>
<source>Seeds</source>
<translation type="obsolete">Seeds</translation>
</message>
<message>
<source>Leechers</source>
<translation type="obsolete">Leechers</translation>
</message>
<message>
<source>Search Engine</source>
<translation type="obsolete">Motore di ricerca</translation>
</message>
<message>
<source>Download from URL</source>
<translation>Download da URL</translation>
@ -873,10 +762,6 @@ Please close the other one first.</source>
<source>Create torrent</source>
<translation>Crea torrent</translation>
</message>
<message>
<source>Ratio: </source>
<translation type="obsolete">Percentuale: </translation>
</message>
<message>
<source>Update search plugin</source>
<translation>Aggiorna plugin di ricerca</translation>
@ -887,15 +772,15 @@ Please close the other one first.</source>
</message>
<message>
<source>Transfers</source>
<translation type="unfinished"></translation>
<translation>Trasferimenti</translation>
</message>
<message>
<source>Preview file</source>
<translation type="unfinished"></translation>
<translation>Anteprima file</translation>
</message>
<message>
<source>Clear log</source>
<translation type="unfinished"></translation>
<translation>Cancella log</translation>
</message>
</context>
<context>
@ -909,13 +794,6 @@ Please close the other one first.</source>
<translation type="unfinished">Vero</translation>
</message>
</context>
<context>
<name>QTextEdit</name>
<message>
<source>Clear</source>
<translation type="obsolete">Pulisci</translation>
</message>
</context>
<context>
<name>Ui</name>
<message>
@ -930,21 +808,13 @@ Please close the other one first.</source>
<source>I would like to thank the following people who volunteered to translate qBittorrent:</source>
<translation>Vorrei ringraziare le seguenti persone che si sono rese volontarie per tradurre qBittorrent:</translation>
</message>
<message>
<source>&lt;ul&gt;&lt;li&gt;I would like to thank sourceforge.net for hosting qBittorrent project.&lt;/li&gt;</source>
<translation type="obsolete">&lt;ul&gt;&lt;li&gt;Voglio inoltre ringraziare Sourceforge.Net per ospitare i files relativi al progetto.&lt;/li&gt;</translation>
</message>
<message>
<source>&lt;li&gt;I also like to thank Jeffery Fernandez (developer@jefferyfernandez.id.au), our RPM packager, for his great work.&lt;/li&gt;&lt;/ul&gt;</source>
<translation type="obsolete">&lt;li&gt;Voglio anche ringraziare Jeffery Fernandez (developer@jefferyfernandez.id.au), il nostro creatore di RPM, per il suo grande lavoro.&lt;/li&gt;&lt;/ul&gt;</translation>
</message>
<message>
<source>Preview impossible</source>
<translation type="unfinished"></translation>
<translation>Anteprima impossibile</translation>
</message>
<message>
<source>Sorry, we can&apos;t preview this file</source>
<translation type="unfinished"></translation>
<translation>Spiacenti, non è possibile fare un&apos;anteprima di questo file</translation>
</message>
<message>
<source>Name</source>
@ -960,30 +830,30 @@ Please close the other one first.</source>
</message>
<message>
<source>No URL entered</source>
<translation type="unfinished"></translation>
<translation>Nessuna URL inserita </translation>
</message>
<message>
<source>Please type at least one URL.</source>
<translation type="unfinished"></translation>
<translation>Per favore inserire almeno un URL.</translation>
</message>
</context>
<context>
<name>authentication</name>
<message>
<source>Tracker authentication</source>
<translation type="unfinished"></translation>
<translation>Autenticazione del tracker</translation>
</message>
<message>
<source>Tracker:</source>
<translation type="unfinished"></translation>
<translation>Tracker:</translation>
</message>
<message>
<source>Login</source>
<translation type="unfinished"></translation>
<translation>Login</translation>
</message>
<message>
<source>Username:</source>
<translation type="unfinished"></translation>
<translation>Nome utente:</translation>
</message>
<message>
<source>Password:</source>
@ -991,11 +861,11 @@ Please close the other one first.</source>
</message>
<message>
<source>Log in</source>
<translation type="unfinished"></translation>
<translation>Log in</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
<translation>Annulla</translation>
</message>
</context>
<context>
@ -1008,22 +878,6 @@ Please close the other one first.</source>
<source>Create Torrent file</source>
<translation>Crea file torrent</translation>
</message>
<message>
<source>Destination torrent file:</source>
<translation type="obsolete">Torrent file di destinazione:</translation>
</message>
<message>
<source>Input file or directory:</source>
<translation type="obsolete">File o directory di input:</translation>
</message>
<message>
<source>Announce url (Tracker):</source>
<translation type="obsolete">URL del tracker:</translation>
</message>
<message>
<source>Comment:</source>
<translation type="obsolete">Commento:</translation>
</message>
<message>
<source>...</source>
<translation>...</translation>
@ -1108,11 +962,11 @@ Please close the other one first.</source>
<name>downloadFromURL</name>
<message>
<source>Download Torrents from URLs</source>
<translation type="unfinished"></translation>
<translation>Scarica torrent da URL</translation>
</message>
<message>
<source>Only one URL per line</source>
<translation type="unfinished"></translation>
<translation>Solo un URL per linea</translation>
</message>
<message>
<source>Download</source>
@ -1120,11 +974,11 @@ Please close the other one first.</source>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
<translation>Annulla</translation>
</message>
<message>
<source>Download from urls</source>
<translation type="unfinished"></translation>
<translation>Download da URL</translation>
</message>
</context>
<context>
@ -1154,12 +1008,6 @@ Please close the other one first.</source>
<comment>tebibytes (1024 gibibytes)</comment>
<translation>Tb</translation>
</message>
<message>
<source>m</source>
<comment>
minutes</comment>
<translation type="obsolete">m</translation>
</message>
<message>
<source>h</source>
<comment>hours</comment>
@ -1170,12 +1018,6 @@ minutes</comment>
<comment>days</comment>
<translation>gg</translation>
</message>
<message>
<source>h </source>
<comment>
hours</comment>
<translation type="obsolete">h </translation>
</message>
<message>
<source>Unknown</source>
<translation>Sconosciuto</translation>
@ -1277,30 +1119,30 @@ hours</comment>
</message>
<message>
<source>Choose your favourite preview program</source>
<translation type="unfinished"></translation>
<translation>Scegliere il programma d&apos;anteprima preferito</translation>
</message>
</context>
<context>
<name>preview</name>
<message>
<source>Preview selection</source>
<translation type="unfinished"></translation>
<translation>Anteprima della selezione</translation>
</message>
<message>
<source>File preview</source>
<translation type="unfinished"></translation>
<translation>Anteprima del file</translation>
</message>
<message>
<source>The following files support previewing, &lt;br&gt;please select one of them:</source>
<translation type="unfinished"></translation>
<translation>I seguenti files supportano l&apos;anteprima, &lt;br&gt;per favore scegliere uno d&apos;essi:</translation>
</message>
<message>
<source>Preview</source>
<translation type="unfinished"></translation>
<translation>Anteprima</translation>
</message>
<message>
<source>Cancel</source>
<translation type="unfinished"></translation>
<translation>Annulla</translation>
</message>
</context>
<context>
@ -1309,10 +1151,6 @@ hours</comment>
<source>Torrent Properties</source>
<translation>Proprietà del torrent</translation>
</message>
<message>
<source>Main Infos</source>
<translation type="obsolete">Informazioni principali</translation>
</message>
<message>
<source>File Name</source>
<translation>Nome del file</translation>
@ -1321,38 +1159,14 @@ hours</comment>
<source>Current Session</source>
<translation>Sessione corrente</translation>
</message>
<message>
<source>Total Uploaded:</source>
<translation type="obsolete">Totale Upload:</translation>
</message>
<message>
<source>Total Downloaded:</source>
<translation type="obsolete">Totale Download:</translation>
</message>
<message>
<source>Download state:</source>
<translation>Stato download:</translation>
</message>
<message>
<source>Current Tracker:</source>
<translation type="obsolete">Tracker corrente:</translation>
</message>
<message>
<source>Number of Peers:</source>
<translation type="obsolete">Numero di peer:</translation>
</message>
<message>
<source>Torrent Content</source>
<translation type="obsolete">Contenuto del torrent</translation>
</message>
<message>
<source>OK</source>
<translation>OK</translation>
</message>
<message>
<source>Total Failed:</source>
<translation type="obsolete">Totale fallito:</translation>
</message>
<message>
<source>Finished</source>
<translation>Finito</translation>
@ -1421,14 +1235,6 @@ hours</comment>
<source>You can select here precisely which files you want to download in current torrent.</source>
<translation>Qua puoi scegliere quali file del torrent scaricare.</translation>
</message>
<message>
<source>False</source>
<translation type="obsolete">Falso</translation>
</message>
<message>
<source>True</source>
<translation type="obsolete">Vero</translation>
</message>
<message>
<source>Tracker</source>
<translation>Tracker</translation>
@ -1483,11 +1289,11 @@ hours</comment>
</message>
<message>
<source>Download in correct order (slower but good for previewing)</source>
<translation type="unfinished"></translation>
<translation>Scarica nel giusto ordine (più lento ma migliore per le anteprime)</translation>
</message>
<message>
<source>Share Ratio:</source>
<translation type="unfinished"></translation>
<translation>Percentuale di condivisione:</translation>
</message>
</context>
</TS>

View file

@ -24,14 +24,13 @@
#include "PropListDelegate.h"
// Constructor
properties::properties(QWidget *parent, torrent_handle h, QStringList trackerErrors): QDialog(parent){
properties::properties(QWidget *parent, torrent_handle h, QStringList trackerErrors): QDialog(parent), h(h){
setupUi(this);
// set icons
unselect->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png")));
select->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png")));
setAttribute(Qt::WA_DeleteOnClose);
this->h = h;
// Set Properties list model
PropListModel = new QStandardItemModel(0,4);
PropListModel->setHeaderData(NAME, Qt::Horizontal, tr("File Name"));
@ -145,6 +144,30 @@ properties::properties(QWidget *parent, torrent_handle h, QStringList trackerErr
}else{
incrementalDownload->setChecked(false);
}
updateProgressTimer = new QTimer(this);
connect(updateProgressTimer, SIGNAL(timeout()), this, SLOT(updateProgress()));
updateProgressTimer->start(2000);
std::vector<bool> filters = h.filtered_pieces();
// std::cout << "filtered pieces: ";
// for(int i=0; i<torrentInfo.num_files(); ++i){
// std::cout << filters.at(i) << " ";
// }
// std::cout << '\n';
}
properties::~properties(){
delete updateProgressTimer;
delete PropDelegate;
delete PropListModel;
}
void properties::updateProgress(){
std::vector<float> fp;
h.file_progress(fp);
torrent_info torrentInfo = h.get_torrent_info();
for(int i=0; i<torrentInfo.num_files(); ++i){
PropListModel->setData(PropListModel->index(i, PROGRESS), QVariant((double)fp[i]));
}
}
// Set the color of a row in data model
@ -171,6 +194,8 @@ void properties::toggleSelectedState(const QModelIndex& index){
setRowColor(row, "red");
PropListModel->setData(PropListModel->index(row, SELECTED), QVariant(false));
}
// Save filtered pieces to a file to remember them
saveFilteredPieces();
}
void properties::on_incrementalDownload_stateChanged(int){
@ -204,6 +229,8 @@ void properties::on_select_clicked(){
}
}
}
// Save filtered pieces to a file to remember them
saveFilteredPieces();
}
void properties::on_okButton_clicked(){
@ -226,4 +253,30 @@ void properties::on_unselect_clicked(){
}
}
}
// Save filtered pieces to a file to remember them
saveFilteredPieces();
}
void properties::saveFilteredPieces(){
torrent_info torrentInfo = h.get_torrent_info();
bool hasFilteredPieces = false;
QString fileName = QString(torrentInfo.name().c_str());
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".pieces");
// First, remove old file
pieces_file.remove();
// Write new files
if(!pieces_file.open(QIODevice::WriteOnly | QIODevice::Text)){
std::cout << "Error: Could not save filtered pieces\n";
return;
}
for(int i=0; i<torrentInfo.num_files(); ++i){
if(h.is_piece_filtered(i)){
pieces_file.write(QByteArray("1\n"));
hasFilteredPieces = true;
}else{
pieces_file.write(QByteArray("0\n"));
}
}
pieces_file.close();
emit changedFilteredPieces(h, !hasFilteredPieces);
}

View file

@ -25,6 +25,7 @@
#include "ui_properties.h"
#include <libtorrent/session.hpp>
#include <QStandardItemModel>
#include <QTimer>
class PropListDelegate;
@ -36,6 +37,7 @@ class properties : public QDialog, private Ui::properties{
torrent_handle h;
PropListDelegate *PropDelegate;
QStandardItemModel *PropListModel;
QTimer *updateProgressTimer;
protected slots:
void on_select_clicked();
@ -44,10 +46,16 @@ class properties : public QDialog, private Ui::properties{
void on_incrementalDownload_stateChanged(int);
void setRowColor(int row, QString color);
void toggleSelectedState(const QModelIndex& index);
void saveFilteredPieces();
void updateProgress();
signals:
void changedFilteredPieces(torrent_handle h, bool compact_mode);
public:
// Constructor
properties(QWidget *parent = 0, torrent_handle h = torrent_handle(), QStringList trackerErrors = QStringList());
properties(QWidget *parent, torrent_handle h, QStringList trackerErrors = QStringList());
~properties();
};
#endif