Browse Source

- Updated Translation files

- Use fileHash as ID instead of fileName so that different torrents can have the same name
- WARNING: Changed a lot of code and it may include new bugs, please report them as soon as possible.
adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
17d880189f
  1. 1
      Changelog
  2. 1
      TODO
  3. 1
      src/DLListDelegate.h
  4. 205
      src/GUI.cpp
  5. 2
      src/GUI.h
  6. 2
      src/about_imp.h
  7. BIN
      src/lang/qbittorrent_bg.qm
  8. 408
      src/lang/qbittorrent_bg.ts
  9. BIN
      src/lang/qbittorrent_ca.qm
  10. 408
      src/lang/qbittorrent_ca.ts
  11. BIN
      src/lang/qbittorrent_de.qm
  12. 408
      src/lang/qbittorrent_de.ts
  13. BIN
      src/lang/qbittorrent_el.qm
  14. 408
      src/lang/qbittorrent_el.ts
  15. BIN
      src/lang/qbittorrent_en.qm
  16. 444
      src/lang/qbittorrent_en.ts
  17. BIN
      src/lang/qbittorrent_es.qm
  18. 408
      src/lang/qbittorrent_es.ts
  19. BIN
      src/lang/qbittorrent_fi.qm
  20. 408
      src/lang/qbittorrent_fi.ts
  21. BIN
      src/lang/qbittorrent_fr.qm
  22. 408
      src/lang/qbittorrent_fr.ts
  23. BIN
      src/lang/qbittorrent_it.qm
  24. 408
      src/lang/qbittorrent_it.ts
  25. BIN
      src/lang/qbittorrent_ko.qm
  26. 408
      src/lang/qbittorrent_ko.ts
  27. BIN
      src/lang/qbittorrent_nb.qm
  28. 408
      src/lang/qbittorrent_nb.ts
  29. BIN
      src/lang/qbittorrent_nl.qm
  30. 408
      src/lang/qbittorrent_nl.ts
  31. BIN
      src/lang/qbittorrent_pl.qm
  32. 408
      src/lang/qbittorrent_pl.ts
  33. BIN
      src/lang/qbittorrent_pt.qm
  34. 411
      src/lang/qbittorrent_pt.ts
  35. BIN
      src/lang/qbittorrent_ro.qm
  36. 408
      src/lang/qbittorrent_ro.ts
  37. BIN
      src/lang/qbittorrent_ru.qm
  38. 408
      src/lang/qbittorrent_ru.ts
  39. BIN
      src/lang/qbittorrent_sk.qm
  40. 408
      src/lang/qbittorrent_sk.ts
  41. BIN
      src/lang/qbittorrent_sv.qm
  42. 408
      src/lang/qbittorrent_sv.ts
  43. BIN
      src/lang/qbittorrent_tr.qm
  44. 408
      src/lang/qbittorrent_tr.ts
  45. BIN
      src/lang/qbittorrent_uk.qm
  46. 408
      src/lang/qbittorrent_uk.ts
  47. BIN
      src/lang/qbittorrent_zh.qm
  48. 412
      src/lang/qbittorrent_zh.ts
  49. BIN
      src/lang/qbittorrent_zh_HK.qm
  50. 441
      src/lang/qbittorrent_zh_HK.ts
  51. 1
      src/misc.h
  52. 11
      src/properties_imp.cpp
  53. 1
      src/properties_imp.h
  54. 14
      src/torrentAddition.h

1
Changelog

@ -9,6 +9,7 @@
- FEATURE: Improved the way parameters are passed between qBT instances (socket) - FEATURE: Improved the way parameters are passed between qBT instances (socket)
- FEATURE: User is warned when hard drive becomes full and downloads are paused - FEATURE: User is warned when hard drive becomes full and downloads are paused
- FEATURE: Number of complete/incomplete sources are now displayed in download list for each torrent - FEATURE: Number of complete/incomplete sources are now displayed in download list for each torrent
- BUGFIX: Two torrents can now have the same name although they are different
- BUGFIX: Fixed download from url that would fail sometimes - BUGFIX: Fixed download from url that would fail sometimes
- BUGFIX: Save directory was reset to default when filtering files in torrent - BUGFIX: Save directory was reset to default when filtering files in torrent
- BUGFIX: Force a refresh of download list when the window is shown (avoid delay) - BUGFIX: Force a refresh of download list when the window is shown (avoid delay)

1
TODO

@ -42,6 +42,5 @@
- UPnP support - UPnP support
// In v0.9.0 // In v0.9.0
- Two torrents with the same name are not necessarily the same (use sha1_hash?)
- Implement close to systray - Implement close to systray
- Wait for libtorrent v0.12 official release - Wait for libtorrent v0.12 official release

1
src/DLListDelegate.h

@ -39,6 +39,7 @@
#define SEEDSLEECH 5 #define SEEDSLEECH 5
#define STATUS 6 #define STATUS 6
#define ETA 7 #define ETA 7
#define HASH 8
class DLListDelegate: public QAbstractItemDelegate { class DLListDelegate: public QAbstractItemDelegate {
Q_OBJECT Q_OBJECT

205
src/GUI.cpp

@ -100,7 +100,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
// Fix Tool bar layout // Fix Tool bar layout
toolBar->layout()->setSpacing(7); toolBar->layout()->setSpacing(7);
// Set Download list model // Set Download list model
DLListModel = new QStandardItemModel(0,8); DLListModel = new QStandardItemModel(0,9);
DLListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name")); DLListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name"));
DLListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size")); DLListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size"));
DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress")); DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress"));
@ -112,6 +112,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
downloadList->setModel(DLListModel); downloadList->setModel(DLListModel);
DLDelegate = new DLListDelegate(); DLDelegate = new DLListDelegate();
downloadList->setItemDelegate(DLDelegate); downloadList->setItemDelegate(DLDelegate);
// Hide hash column
downloadList->hideColumn(HASH);
// Load last columns width for download list // Load last columns width for download list
if(!loadColWidthDLList()){ if(!loadColWidthDLList()){
downloadList->header()->resizeSection(0, 200); downloadList->header()->resizeSection(0, 200);
@ -338,8 +340,8 @@ void GUI::readParamsOnSocket(){
void GUI::togglePausedState(const QModelIndex& index){ void GUI::togglePausedState(const QModelIndex& index){
int row = index.row(); int row = index.row();
QString fileName = DLListModel->data(DLListModel->index(row, NAME)).toString(); QString fileHash = DLListModel->data(DLListModel->index(row, HASH)).toString();
torrent_handle h = handles.value(fileName); torrent_handle h = handles.value(fileHash);
if(h.is_paused()){ if(h.is_paused()){
startSelection(); startSelection();
}else{ }else{
@ -353,8 +355,8 @@ void GUI::previewFileSelection(){
foreach(index, selectedIndexes){ foreach(index, selectedIndexes){
if(index.column() == NAME){ if(index.column() == NAME){
// Get the file name // Get the file name
QString fileName = index.data().toString(); QString fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
torrent_handle h = handles.value(fileName); torrent_handle h = handles.value(fileHash);
previewSelection = new previewSelect(this, h); previewSelection = new previewSelect(this, h);
break; break;
} }
@ -373,9 +375,9 @@ void GUI::displayDLListMenu(const QPoint& pos){
foreach(index, selectedIndexes){ foreach(index, selectedIndexes){
if(index.column() == NAME){ if(index.column() == NAME){
// Get the file name // Get the file name
QString fileName = index.data().toString(); QString fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
// Get handle and pause the torrent // Get handle and pause the torrent
torrent_handle h = handles.value(fileName); torrent_handle h = handles.value(fileHash);
if(h.is_paused()){ if(h.is_paused()){
myDLLlistMenu.addAction(actionStart); myDLLlistMenu.addAction(actionStart);
}else{ }else{
@ -443,6 +445,7 @@ void GUI::displayInfoBarMenu(const QPoint& pos){
// get information from torrent handles and // get information from torrent handles and
// update download list accordingly // update download list accordingly
void GUI::updateDlList(bool force){ void GUI::updateDlList(bool force){
qDebug("Updating download list");
torrent_handle h; torrent_handle h;
char tmp[MAX_CHAR_TMP]; char tmp[MAX_CHAR_TMP];
char tmp2[MAX_CHAR_TMP]; char tmp2[MAX_CHAR_TMP];
@ -458,12 +461,12 @@ void GUI::updateDlList(bool force){
LCD_UpSpeed->display(tmp); // UP LCD LCD_UpSpeed->display(tmp); // UP LCD
LCD_DownSpeed->display(tmp2); // DL LCD LCD_DownSpeed->display(tmp2); // DL LCD
// browse handles // browse handles
foreach(h, handles){ foreach(h, handles.values()){
try{ try{
torrent_status torrentStatus = h.status(); torrent_status torrentStatus = h.status();
QString fileName = QString(h.get_torrent_info().name().c_str()); QString fileHash = QString(misc::toString(h.info_hash()).c_str());
if(!h.is_paused()){ if(!h.is_paused()){
int row = getRowFromName(fileName); int row = getRowFromHash(fileHash);
if(row == -1){ if(row == -1){
std::cerr << "Error: Could not find filename in download list..\n"; std::cerr << "Error: Could not find filename in download list..\n";
continue; continue;
@ -532,6 +535,7 @@ void GUI::updateDlList(bool force){
continue; continue;
} }
} }
qDebug("Updated Download list");
} }
bool GUI::isFilePreviewPossible(const torrent_handle& h) const{ bool GUI::isFilePreviewPossible(const torrent_handle& h) const{
@ -713,8 +717,8 @@ QPoint GUI::screenCenter(){
bool GUI::loadFilteredFiles(torrent_handle &h){ bool GUI::loadFilteredFiles(torrent_handle &h){
bool has_filtered_files = false; bool has_filtered_files = false;
torrent_info torrentInfo = h.get_torrent_info(); torrent_info torrentInfo = h.get_torrent_info();
QString fileName = QString(torrentInfo.name().c_str()); QString fileHash = QString(misc::toString(torrentInfo.info_hash()).c_str());
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".pieces"); QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".pieces");
// Read saved file // Read saved file
if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){
return has_filtered_files; return has_filtered_files;
@ -742,8 +746,8 @@ bool GUI::loadFilteredFiles(torrent_handle &h){
return has_filtered_files; return has_filtered_files;
} }
bool GUI::hasFilteredFiles(const QString& fileName){ bool GUI::hasFilteredFiles(const QString& fileHash){
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".pieces"); QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".pieces");
// Read saved file // Read saved file
if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){
return false; return false;
@ -1003,18 +1007,18 @@ void GUI::saveFastResumeData() const{
torrentBackup.mkpath(torrentBackup.path()); torrentBackup.mkpath(torrentBackup.path());
} }
// Write fast resume data // Write fast resume data
foreach(torrent_handle h, handles){ foreach(torrent_handle h, handles.values()){
// Pause download (needed before fast resume writing) // Pause download (needed before fast resume writing)
h.pause(); h.pause();
// Extracting resume data // Extracting resume data
if (h.has_metadata()){ if (h.has_metadata()){
QString fileName = QString(h.get_torrent_info().name().c_str()); QString fileHash = QString(misc::toString(h.info_hash()).c_str());
if(QFile::exists(torrentBackup.path()+QDir::separator()+fileName+".torrent")){ if(QFile::exists(torrentBackup.path()+QDir::separator()+fileHash+".torrent")){
// Remove old .fastresume data in case it exists // Remove old .fastresume data in case it exists
QFile::remove(fileName + ".fastresume"); QFile::remove(fileHash + ".fastresume");
// Write fast resume data // Write fast resume data
entry resumeData = h.write_resume_data(); entry resumeData = h.write_resume_data();
file = fileName + ".fastresume"; file = fileHash + ".fastresume";
boost::filesystem::ofstream out(fs::path((const char*)torrentBackup.path().toUtf8()) / (const char*)file.toUtf8(), std::ios_base::binary); boost::filesystem::ofstream out(fs::path((const char*)torrentBackup.path().toUtf8()) / (const char*)file.toUtf8(), std::ios_base::binary);
out.unsetf(std::ios_base::skipws); out.unsetf(std::ios_base::skipws);
bencode(std::ostream_iterator<char>(out), resumeData); bencode(std::ostream_iterator<char>(out), resumeData);
@ -1058,29 +1062,32 @@ void GUI::deletePermanently(){
foreach(sortedIndex, sortedIndexes){ foreach(sortedIndex, sortedIndexes){
qDebug("deleting row: %d, %d, col: %d", sortedIndex.first, sortedIndex.second.row(), sortedIndex.second.column()); qDebug("deleting row: %d, %d, col: %d", sortedIndex.first, sortedIndex.second.row(), sortedIndex.second.column());
// Get the file name // Get the file name
QString fileName = sortedIndex.second.data().toString(); QString fileHash = DLListModel->data(DLListModel->index(sortedIndex.second.row(), HASH)).toString();
QString savePath; QString savePath;
// Delete item from download list // Delete item from download list
DLListModel->removeRow(sortedIndex.first); DLListModel->removeRow(sortedIndex.first);
// Get handle and remove the torrent // Get handle and remove the torrent
QHash<QString, torrent_handle>::iterator it = handles.find(fileName); QHash<QString, torrent_handle>::iterator it = handles.find(fileHash);
if(it != handles.end() && it.key() == fileName) { if(it != handles.end() && it.key() == fileHash) {
torrent_handle h = it.value(); torrent_handle h = it.value();
QString fileName = QString(h.name().c_str());
savePath = QString::fromUtf8(h.save_path().string().c_str()); savePath = QString::fromUtf8(h.save_path().string().c_str());
s->remove_torrent(h);
// Remove torrent from handles // Remove torrent from handles
qDebug(("There are " + misc::toString(handles.size()) + " items in handles").c_str());
handles.erase(it); handles.erase(it);
qDebug(("After removing, there are still " + misc::toString(handles.size()) + " items in handles").c_str());
s->remove_torrent(h);
// remove it from scan dir or it will start again // remove it from scan dir or it will start again
if(isScanningDir){ if(isScanningDir){
QFile::remove(scan_dir+fileName+".torrent"); QFile::remove(scan_dir+fileHash+".torrent");
} }
// Remove it from torrent backup directory // Remove it from torrent backup directory
torrentBackup.remove(fileName+".torrent"); torrentBackup.remove(fileHash+".torrent");
torrentBackup.remove(fileName+".fastresume"); torrentBackup.remove(fileHash+".fastresume");
torrentBackup.remove(fileName+".paused"); torrentBackup.remove(fileHash+".paused");
torrentBackup.remove(fileName+".incremental"); torrentBackup.remove(fileHash+".incremental");
torrentBackup.remove(fileName+".pieces"); torrentBackup.remove(fileHash+".pieces");
torrentBackup.remove(fileName+".savepath"); torrentBackup.remove(fileHash+".savepath");
// Remove from Hard drive // Remove from Hard drive
qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName)); qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName));
// Deleting in a thread to avoid GUI freeze // Deleting in a thread to avoid GUI freeze
@ -1141,29 +1148,29 @@ void GUI::deleteSelection(){
foreach(sortedIndex, sortedIndexes){ foreach(sortedIndex, sortedIndexes){
qDebug("deleting row: %d, %d, col: %d", sortedIndex.first, sortedIndex.second.row(), sortedIndex.second.column()); qDebug("deleting row: %d, %d, col: %d", sortedIndex.first, sortedIndex.second.row(), sortedIndex.second.column());
// Get the file name // Get the file name
QString fileName = sortedIndex.second.data().toString(); QString fileHash = DLListModel->data(DLListModel->index(sortedIndex.second.row(), HASH)).toString();
// Delete item from download list // Delete item from download list
DLListModel->removeRow(sortedIndex.first); DLListModel->removeRow(sortedIndex.first);
// Get handle and remove the torrent // Get handle and remove the torrent
QHash<QString, torrent_handle>::iterator it = handles.find(fileName); QHash<QString, torrent_handle>::iterator it = handles.find(fileHash);
if(it != handles.end() && it.key() == fileName) { if(it != handles.end() && it.key() == fileHash) {
torrent_handle h = it.value(); torrent_handle h = it.value();
s->remove_torrent(h);
// Remove torrent from handles // Remove torrent from handles
handles.erase(it); handles.erase(it);
s->remove_torrent(h);
// remove it from scan dir or it will start again // remove it from scan dir or it will start again
if(isScanningDir){ if(isScanningDir){
QFile::remove(scan_dir+fileName+".torrent"); QFile::remove(scan_dir+fileHash+".torrent");
} }
// Remove it from torrent backup directory // Remove it from torrent backup directory
torrentBackup.remove(fileName+".torrent"); torrentBackup.remove(fileHash+".torrent");
torrentBackup.remove(fileName+".fastresume"); torrentBackup.remove(fileHash+".fastresume");
torrentBackup.remove(fileName+".paused"); torrentBackup.remove(fileHash+".paused");
torrentBackup.remove(fileName+".incremental"); torrentBackup.remove(fileHash+".incremental");
torrentBackup.remove(fileName+".pieces"); torrentBackup.remove(fileHash+".pieces");
torrentBackup.remove(fileName+".savepath"); torrentBackup.remove(fileHash+".savepath");
// Update info bar // Update info bar
setInfoBar("'" + fileName +"' "+tr("removed.", "<file> removed.")); setInfoBar("'" + QString(h.name().c_str()) +"' "+tr("removed.", "<file> removed."));
--nbTorrents; --nbTorrents;
tabs->setTabText(0, tr("Transfers") +" ("+QString(misc::toString(nbTorrents).c_str())+")"); tabs->setTabText(0, tr("Transfers") +" ("+QString(misc::toString(nbTorrents).c_str())+")");
}else{ }else{
@ -1222,11 +1229,10 @@ void GUI::addTorrent(const QString& path, bool fromScanDir, const QString& from_
try{ try{
// Decode torrent file // Decode torrent file
entry e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>()); entry e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>());
//qDebug("Entry bdecoded");
// Getting torrent file informations // Getting torrent file informations
torrent_info t(e); torrent_info t(e);
//qDebug("Got torrent infos"); QString hash = QString(misc::toString(t.info_hash()).c_str());
if(handles.contains(QString(t.name().c_str()))){ if(handles.contains(hash)){
// Update info Bar // Update info Bar
if(!fromScanDir){ if(!fromScanDir){
if(!from_url.isNull()){ if(!from_url.isNull()){
@ -1240,11 +1246,21 @@ void GUI::addTorrent(const QString& path, bool fromScanDir, const QString& from_
} }
return; return;
} }
// TODO: Remove this in a few releases
if(torrentBackup.exists(QString(t.name().c_str())+".torrent")){
QFile::rename(torrentBackup.path()+QDir::separator()+QString(t.name().c_str())+".torrent", torrentBackup.path()+QDir::separator()+hash+".torrent");
QFile::rename(torrentBackup.path()+QDir::separator()+QString(t.name().c_str())+".fastresume", torrentBackup.path()+QDir::separator()+hash+".fastresume");
QFile::rename(torrentBackup.path()+QDir::separator()+QString(t.name().c_str())+".pieces", torrentBackup.path()+QDir::separator()+hash+".pieces");
QFile::rename(torrentBackup.path()+QDir::separator()+QString(t.name().c_str())+".savepath", torrentBackup.path()+QDir::separator()+hash+".savepath");
QFile::rename(torrentBackup.path()+QDir::separator()+QString(t.name().c_str())+".paused", torrentBackup.path()+QDir::separator()+hash+".paused");
QFile::rename(torrentBackup.path()+QDir::separator()+QString(t.name().c_str())+".incremental", torrentBackup.path()+QDir::separator()+hash+".incremental");
file = torrentBackup.path() + QDir::separator() + hash + ".torrent";
}
//Getting fast resume data if existing //Getting fast resume data if existing
if(torrentBackup.exists(QString::QString(t.name().c_str())+".fastresume")){ if(torrentBackup.exists(hash+".fastresume")){
try{ try{
std::stringstream strStream; std::stringstream strStream;
strStream << t.name() << ".fastresume"; strStream << hash.toStdString() << ".fastresume";
boost::filesystem::ifstream resume_file(fs::path((const char*)torrentBackup.path().toUtf8()) / strStream.str(), std::ios_base::binary); boost::filesystem::ifstream resume_file(fs::path((const char*)torrentBackup.path().toUtf8()) / strStream.str(), std::ios_base::binary);
resume_file.unsetf(std::ios_base::skipws); resume_file.unsetf(std::ios_base::skipws);
resume_data = bdecode(std::istream_iterator<char>(resume_file), std::istream_iterator<char>()); resume_data = bdecode(std::istream_iterator<char>(resume_file), std::istream_iterator<char>());
@ -1253,10 +1269,10 @@ void GUI::addTorrent(const QString& path, bool fromScanDir, const QString& from_
catch (fs::filesystem_error&) {} catch (fs::filesystem_error&) {}
//qDebug("Got fast resume data"); //qDebug("Got fast resume data");
} }
QString savePath = getSavePath(QString(t.name().c_str())); QString savePath = getSavePath(hash);
int row = DLListModel->rowCount(); int row = DLListModel->rowCount();
// Adding files to bittorrent session // Adding files to bittorrent session
if(hasFilteredFiles(QString(t.name().c_str()))){ if(hasFilteredFiles(hash)){
h = s->add_torrent(t, fs::path((const char*)savePath.toUtf8()), resume_data, false); h = s->add_torrent(t, fs::path((const char*)savePath.toUtf8()), resume_data, false);
qDebug("Full allocation mode"); qDebug("Full allocation mode");
}else{ }else{
@ -1266,13 +1282,14 @@ void GUI::addTorrent(const QString& path, bool fromScanDir, const QString& from_
// Is this really useful and appropriate ? // Is this really useful and appropriate ?
//h.set_max_connections(60); //h.set_max_connections(60);
h.set_max_uploads(-1); h.set_max_uploads(-1);
qDebug("Torrent hash is " + hash.toUtf8());
// Load filtered files // Load filtered files
loadFilteredFiles(h); loadFilteredFiles(h);
//qDebug("Added to session"); //qDebug("Added to session");
torrent_status torrentStatus = h.status(); torrent_status torrentStatus = h.status();
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)torrentStatus.progress)); DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)torrentStatus.progress));
handles.insert(QString(t.name().c_str()), h); handles.insert(hash, h);
QString newFile = torrentBackup.path() + QDir::separator() + QString(t.name().c_str())+".torrent"; QString newFile = torrentBackup.path() + QDir::separator() + hash + ".torrent";
if(file != newFile){ if(file != newFile){
// Delete file from torrentBackup directory in case it exists because // Delete file from torrentBackup directory in case it exists because
// QFile::copy() do not overwrite // QFile::copy() do not overwrite
@ -1287,7 +1304,7 @@ void GUI::addTorrent(const QString& path, bool fromScanDir, const QString& from_
scan_dir += QDir::separator(); scan_dir += QDir::separator();
} }
//rename torrent file to match file name and find it easily later //rename torrent file to match file name and find it easily later
dest_file = scan_dir+t.name().c_str()+".torrent"; dest_file = scan_dir+hash.toUtf8()+".torrent";
if(!QFile::exists(dest_file)){ if(!QFile::exists(dest_file)){
QFile::rename(file, dest_file); QFile::rename(file, dest_file);
} }
@ -1300,8 +1317,9 @@ void GUI::addTorrent(const QString& path, bool fromScanDir, const QString& from_
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.)); DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.));
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant("0/0")); DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant("0/0"));
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1)); DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
// Pause torrent if it was paused last time // Pause torrent if it was paused last time
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+QString(t.name().c_str())+".paused")){ if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")){
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused"))); DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused")));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole); DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
setRowColor(row, "red"); setRowColor(row, "red");
@ -1312,11 +1330,11 @@ void GUI::addTorrent(const QString& path, bool fromScanDir, const QString& from_
} }
//qDebug("Added to download list"); //qDebug("Added to download list");
// Pause torrent if it was paused last time // Pause torrent if it was paused last time
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+QString(t.name().c_str())+".paused")){ if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")){
h.pause(); h.pause();
} }
// Incremental download // Incremental download
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+QString(t.name().c_str())+".incremental")){ if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental")){
qDebug("Incremental download enabled for %s", t.name().c_str()); qDebug("Incremental download enabled for %s", t.name().c_str());
h.set_sequenced_download_threshold(15); h.set_sequenced_download_threshold(15);
} }
@ -1373,8 +1391,8 @@ void GUI::addTorrent(const QString& path, bool fromScanDir, const QString& from_
} }
} }
QString GUI::getSavePath(QString fileName){ QString GUI::getSavePath(QString hash){
QFile savepath_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".savepath"); QFile savepath_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".savepath");
QByteArray line; QByteArray line;
QString savePath; QString savePath;
if(savepath_file.open(QIODevice::ReadOnly | QIODevice::Text)){ if(savepath_file.open(QIODevice::ReadOnly | QIODevice::Text)){
@ -1401,7 +1419,8 @@ QString GUI::getSavePath(QString fileName){
void GUI::reloadTorrent(const torrent_handle &h, bool compact_mode){ void GUI::reloadTorrent(const torrent_handle &h, bool compact_mode){
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup"); QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
fs::path saveDir = h.save_path(); fs::path saveDir = h.save_path();
QString fileName = QString(h.get_torrent_info().name().c_str()); QString fileName = QString(h.name().c_str());
QString fileHash = QString(misc::toString(h.info_hash()).c_str());
qDebug("Reloading torrent: %s", (const char*)fileName.toUtf8()); qDebug("Reloading torrent: %s", (const char*)fileName.toUtf8());
torrent_handle new_h; torrent_handle new_h;
entry resumeData; entry resumeData;
@ -1422,7 +1441,7 @@ void GUI::reloadTorrent(const torrent_handle &h, bool compact_mode){
int row = -1; int row = -1;
// Delete item from download list // Delete item from download list
for(int i=0; i<DLListModel->rowCount(); ++i){ for(int i=0; i<DLListModel->rowCount(); ++i){
if(DLListModel->data(DLListModel->index(i, NAME)).toString()==fileName){ if(DLListModel->data(DLListModel->index(i, HASH)).toString()==fileHash){
row = i; row = i;
break; break;
} }
@ -1431,7 +1450,7 @@ void GUI::reloadTorrent(const torrent_handle &h, bool compact_mode){
DLListModel->removeRow(row); DLListModel->removeRow(row);
// Remove torrent // Remove torrent
s->remove_torrent(h); s->remove_torrent(h);
handles.remove(fileName); handles.remove(fileHash);
// Add torrent again to session // Add torrent again to session
unsigned short timeout = 0; unsigned short timeout = 0;
while(h.is_valid() && timeout < 6){ while(h.is_valid() && timeout < 6){
@ -1448,7 +1467,7 @@ void GUI::reloadTorrent(const torrent_handle &h, bool compact_mode){
}else{ }else{
qDebug("Using full allocation mode"); qDebug("Using full allocation mode");
} }
handles.insert(QString(t.name().c_str()), new_h); handles.insert(fileHash, new_h);
new_h.set_max_connections(60); new_h.set_max_connections(60);
new_h.set_max_uploads(-1); new_h.set_max_uploads(-1);
// Load filtered Files // Load filtered Files
@ -1471,11 +1490,11 @@ void GUI::reloadTorrent(const torrent_handle &h, bool compact_mode){
setRowColor(row, "grey"); setRowColor(row, "grey");
} }
// Pause torrent if it was paused last time // Pause torrent if it was paused last time
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".paused")){ if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused")){
new_h.pause(); new_h.pause();
} }
// Incremental download // Incremental download
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".incremental")){ if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".incremental")){
qDebug("Incremental download enabled for %s", (const char*)fileName.toUtf8()); qDebug("Incremental download enabled for %s", (const char*)fileName.toUtf8());
new_h.set_sequenced_download_threshold(15); new_h.set_sequenced_download_threshold(15);
} }
@ -1515,9 +1534,9 @@ void GUI::setGlobalRatio(float ratio){
// Show torrent properties dialog // Show torrent properties dialog
void GUI::showProperties(const QModelIndex &index){ void GUI::showProperties(const QModelIndex &index){
int row = index.row(); int row = index.row();
QString fileName = DLListModel->data(DLListModel->index(row, NAME)).toString(); QString fileHash = DLListModel->data(DLListModel->index(row, HASH)).toString();
torrent_handle h = handles.value(fileName); torrent_handle h = handles.value(fileHash);
QStringList errors = trackerErrors.value(fileName, QStringList(tr("None"))); QStringList errors = trackerErrors.value(fileHash, QStringList(tr("None")));
properties *prop = new properties(this, h, errors); properties *prop = new properties(this, h, errors);
connect(prop, SIGNAL(changedFilteredFiles(torrent_handle, bool)), this, SLOT(reloadTorrent(torrent_handle, bool))); connect(prop, SIGNAL(changedFilteredFiles(torrent_handle, bool)), this, SLOT(reloadTorrent(torrent_handle, bool)));
prop->show(); prop->show();
@ -1643,20 +1662,20 @@ void GUI::configureSession(){
// Pause All Downloads in DL list // Pause All Downloads in DL list
void GUI::pauseAll(){ void GUI::pauseAll(){
QString fileName; QString fileHash;
bool changes=false; bool changes=false;
// Browse Handles to pause all downloads // Browse Handles to pause all downloads
foreach(torrent_handle h, handles){ foreach(torrent_handle h, handles){
if(!h.is_paused()){ if(!h.is_paused()){
fileName = QString(h.get_torrent_info().name().c_str()); fileHash = QString(misc::toString(h.info_hash()).c_str());
changes=true; changes=true;
h.pause(); h.pause();
// Create .paused file // Create .paused file
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".paused"); QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
paused_file.open(QIODevice::WriteOnly | QIODevice::Text); paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
paused_file.close(); paused_file.close();
// update DL Status // update DL Status
int row = getRowFromName(fileName); int row = getRowFromHash(fileHash);
if(row == -1){ if(row == -1){
std::cerr << "Error: Filename could not be found in download list...\n"; std::cerr << "Error: Filename could not be found in download list...\n";
continue; continue;
@ -1682,13 +1701,13 @@ void GUI::pauseSelection(){
foreach(index, selectedIndexes){ foreach(index, selectedIndexes){
if(index.column() == NAME){ if(index.column() == NAME){
// Get the file name // Get the file name
QString fileName = index.data().toString(); QString fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
// Get handle and pause the torrent // Get handle and pause the torrent
torrent_handle h = handles.value(fileName); torrent_handle h = handles.value(fileHash);
if(!h.is_paused()){ if(!h.is_paused()){
h.pause(); h.pause();
// Create .paused file // Create .paused file
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".paused"); QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
paused_file.open(QIODevice::WriteOnly | QIODevice::Text); paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
paused_file.close(); paused_file.close();
// Update DL status // Update DL status
@ -1697,7 +1716,7 @@ void GUI::pauseSelection(){
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0)); DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0));
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused"))); DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused")));
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1)); DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
setInfoBar("'"+ fileName +"' "+tr("paused.", "<file> paused.")); setInfoBar("'"+ QString(h.name().c_str()) +"' "+tr("paused.", "<file> paused."));
DLListModel->setData(DLListModel->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole); DLListModel->setData(DLListModel->index(row, NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
setRowColor(row, "red"); setRowColor(row, "red");
} }
@ -1707,18 +1726,18 @@ void GUI::pauseSelection(){
// Start All Downloads in DL list // Start All Downloads in DL list
void GUI::startAll(){ void GUI::startAll(){
QString fileName; QString fileHash;
bool changes=false; bool changes=false;
// Browse Handles to pause all downloads // Browse Handles to pause all downloads
foreach(torrent_handle h, handles){ foreach(torrent_handle h, handles){
if(h.is_paused()){ if(h.is_paused()){
fileName = QString(h.get_torrent_info().name().c_str()); fileHash = QString(misc::toString(h.info_hash()).c_str());
changes=true; changes=true;
h.resume(); h.resume();
// Delete .paused file // Delete .paused file
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".paused"); QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
// update DL Status // update DL Status
int row = getRowFromName(fileName); int row = getRowFromHash(fileHash);
if(row == -1){ if(row == -1){
std::cerr << "Error: Filename could not be found in download list...\n"; std::cerr << "Error: Filename could not be found in download list...\n";
continue; continue;
@ -1741,17 +1760,17 @@ void GUI::startSelection(){
foreach(index, selectedIndexes){ foreach(index, selectedIndexes){
if(index.column() == NAME){ if(index.column() == NAME){
// Get the file name // Get the file name
QString fileName = index.data().toString(); QString fileHash = DLListModel->data(DLListModel->index(index.row(), HASH)).toString();
// Get handle and pause the torrent // Get handle and pause the torrent
torrent_handle h = handles.value(fileName); torrent_handle h = handles.value(fileHash);
if(h.is_paused()){ if(h.is_paused()){
h.resume(); h.resume();
// Delete .paused file // Delete .paused file
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".paused"); QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
// Update DL status // Update DL status
int row = index.row(); int row = index.row();
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting..."))); DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Connecting...")));
setInfoBar("'"+ fileName +"' "+tr("resumed.", "<file> resumed.")); setInfoBar("'"+ QString(h.name().c_str()) +"' "+tr("resumed.", "<file> resumed."));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole); DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/connecting.png")), Qt::DecorationRole);
setRowColor(row, "grey"); setRowColor(row, "grey");
} }
@ -1825,6 +1844,7 @@ void GUI::checkConnectionStatus(){
while (a.get()){ while (a.get()){
if (torrent_finished_alert* p = dynamic_cast<torrent_finished_alert*>(a.get())){ if (torrent_finished_alert* p = dynamic_cast<torrent_finished_alert*>(a.get())){
QString fileName = QString(p->handle.get_torrent_info().name().c_str()); QString fileName = QString(p->handle.get_torrent_info().name().c_str());
QString fileHash = QString(misc::toString(p->handle.info_hash()).c_str());
// Level: info // Level: info
setInfoBar(fileName+tr(" has finished downloading.")); setInfoBar(fileName+tr(" has finished downloading."));
if(options->getUseOSDAlways() || (options->getUseOSDWhenHiddenOnly() && (isMinimized() || isHidden()))) { if(options->getUseOSDAlways() || (options->getUseOSDWhenHiddenOnly() && (isMinimized() || isHidden()))) {
@ -1838,19 +1858,20 @@ void GUI::checkConnectionStatus(){
// Remove it from torrentBackup directory // Remove it from torrentBackup directory
// No need to resume it // No need to resume it
if(options->getClearFinishedOnExit()){ if(options->getClearFinishedOnExit()){
QFile::remove(fileName+".torrent"); QFile::remove(fileHash+".torrent");
QFile::remove(fileName+".fastresume"); QFile::remove(fileHash+".fastresume");
if(isScanningDir){ if(isScanningDir){
QFile::remove(scan_dir+fileName+".torrent"); QFile::remove(scan_dir+fileHash+".torrent");
} }
} }
} }
else if (file_error_alert* p = dynamic_cast<file_error_alert*>(a.get())){ else if (file_error_alert* p = dynamic_cast<file_error_alert*>(a.get())){
QString fileName = QString(p->handle.get_torrent_info().name().c_str()); QString fileName = QString(p->handle.get_torrent_info().name().c_str());
QString fileHash = QString(misc::toString(p->handle.info_hash()).c_str());
if(options->getUseOSDAlways() || (options->getUseOSDWhenHiddenOnly() && (isMinimized() || isHidden()))) { if(options->getUseOSDAlways() || (options->getUseOSDWhenHiddenOnly() && (isMinimized() || isHidden()))) {
myTrayIcon->showMessage(tr("I/O Error"), tr("An error occured when trying to read or write ")+ fileName+"."+tr("The disk is probably full, download has been paused"), QSystemTrayIcon::Critical, TIME_TRAY_BALLOON); myTrayIcon->showMessage(tr("I/O Error"), tr("An error occured when trying to read or write ")+ fileName+"."+tr("The disk is probably full, download has been paused"), QSystemTrayIcon::Critical, TIME_TRAY_BALLOON);
// Download will be pausedby libtorrent. Updating GUI information accordingly // Download will be pausedby libtorrent. Updating GUI information accordingly
int row = getRowFromName(fileName); int row = getRowFromHash(fileHash);
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0)); DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)0.0));
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0)); DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.0));
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused"))); DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused")));
@ -1866,10 +1887,10 @@ void GUI::checkConnectionStatus(){
} }
else if (tracker_alert* p = dynamic_cast<tracker_alert*>(a.get())){ else if (tracker_alert* p = dynamic_cast<tracker_alert*>(a.get())){
// Level: fatal // Level: fatal
QString filename = QString(p->handle.get_torrent_info().name().c_str()); QString fileHash = QString(misc::toString(p->handle.info_hash()).c_str());
QStringList errors = trackerErrors.value(filename, QStringList()); QStringList errors = trackerErrors.value(fileHash, QStringList());
errors.append("<font color='grey'>"+QTime::currentTime().toString("hh:mm:ss")+"</font> - <font color='red'>"+QString(a->msg().c_str())+"</font>"); errors.append("<font color='grey'>"+QTime::currentTime().toString("hh:mm:ss")+"</font> - <font color='red'>"+QString(a->msg().c_str())+"</font>");
trackerErrors.insert(filename, errors); trackerErrors.insert(fileHash, errors);
// Authentication // Authentication
if(p->status_code == 401){ if(p->status_code == 401){
if(unauthenticated_trackers.indexOf(QPair<torrent_handle,std::string>(p->handle, p->handle.status().current_tracker)) < 0){ if(unauthenticated_trackers.indexOf(QPair<torrent_handle,std::string>(p->handle, p->handle.status().current_tracker)) < 0){
@ -2257,10 +2278,10 @@ void GUI::setRowColor(int row, const QString& color, bool inDLList){
} }
// return the row of in data model // return the row of in data model
// corresponding to the given filename // corresponding to the given the filehash
int GUI::getRowFromName(const QString& name) const{ int GUI::getRowFromHash(const QString& hash) const{
for(int i=0; i<DLListModel->rowCount(); ++i){ for(int i=0; i<DLListModel->rowCount(); ++i){
if(DLListModel->data(DLListModel->index(i, NAME)) == name){ if(DLListModel->data(DLListModel->index(i, HASH)) == hash){
return i; return i;
} }
} }

2
src/GUI.h

@ -195,7 +195,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList()); GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
~GUI(); ~GUI();
// Methods // Methods
int getRowFromName(const QString& name) const; int getRowFromHash(const QString& name) const;
float getNovaVersion(const QString& novaPath) const; float getNovaVersion(const QString& novaPath) const;
QByteArray getNovaChangelog(const QString& novaPath) const; QByteArray getNovaChangelog(const QString& novaPath) const;
void updateNova() const; void updateNova() const;

2
src/about_imp.h

@ -23,7 +23,7 @@
#define ABOUT_H #define ABOUT_H
#include "ui_about.h" #include "ui_about.h"
#define VERSION "v0.9.0beta1" #define VERSION "v0.9.0beta2"
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 9 #define VERSION_MINOR 9
#define VERSION_BUGFIX 0 #define VERSION_BUGFIX 0

BIN
src/lang/qbittorrent_bg.qm

Binary file not shown.

408
src/lang/qbittorrent_bg.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_ca.qm

Binary file not shown.

408
src/lang/qbittorrent_ca.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_de.qm

Binary file not shown.

408
src/lang/qbittorrent_de.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_el.qm

Binary file not shown.

408
src/lang/qbittorrent_el.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_en.qm

Binary file not shown.

444
src/lang/qbittorrent_en.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_es.qm

Binary file not shown.

408
src/lang/qbittorrent_es.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_fi.qm

Binary file not shown.

408
src/lang/qbittorrent_fi.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_fr.qm

Binary file not shown.

408
src/lang/qbittorrent_fr.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_it.qm

Binary file not shown.

408
src/lang/qbittorrent_it.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_ko.qm

Binary file not shown.

408
src/lang/qbittorrent_ko.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_nb.qm

Binary file not shown.

408
src/lang/qbittorrent_nb.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_nl.qm

Binary file not shown.

408
src/lang/qbittorrent_nl.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_pl.qm

Binary file not shown.

408
src/lang/qbittorrent_pl.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_pt.qm

Binary file not shown.

411
src/lang/qbittorrent_pt.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_ro.qm

Binary file not shown.

408
src/lang/qbittorrent_ro.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_ru.qm

Binary file not shown.

408
src/lang/qbittorrent_ru.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_sk.qm

Binary file not shown.

408
src/lang/qbittorrent_sk.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_sv.qm

Binary file not shown.

408
src/lang/qbittorrent_sv.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_tr.qm

Binary file not shown.

408
src/lang/qbittorrent_tr.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_uk.qm

Binary file not shown.

408
src/lang/qbittorrent_uk.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_zh.qm

Binary file not shown.

412
src/lang/qbittorrent_zh.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_zh_HK.qm

Binary file not shown.

441
src/lang/qbittorrent_zh_HK.ts

File diff suppressed because it is too large Load Diff

1
src/misc.h

@ -102,6 +102,7 @@ class misc : public QObject{
} }
static bool removePath(QString path){ static bool removePath(QString path){
qDebug((QString("file to delete:") + path).toUtf8());
if(!QFile::remove(path)){ if(!QFile::remove(path)){
// Probably a folder // Probably a folder
QDir current_dir(path); QDir current_dir(path);

11
src/properties_imp.cpp

@ -43,6 +43,7 @@ properties::properties(QWidget *parent, torrent_handle h, QStringList trackerErr
connect(filesList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(toggleSelectedState(const QModelIndex&))); connect(filesList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(toggleSelectedState(const QModelIndex&)));
// get Infos from torrent handle // get Infos from torrent handle
save_path->setText(QString(h.save_path().string().c_str())); save_path->setText(QString(h.save_path().string().c_str()));
fileHash = QString(misc::toString(h.info_hash()).c_str());
torrent_status torrentStatus = h.status(); torrent_status torrentStatus = h.status();
torrent_info torrentInfo = h.get_torrent_info(); torrent_info torrentInfo = h.get_torrent_info();
fileName->setText(torrentInfo.name().c_str()); fileName->setText(torrentInfo.name().c_str());
@ -88,7 +89,7 @@ properties::properties(QWidget *parent, torrent_handle h, QStringList trackerErr
} }
loadFilteredFiles(); loadFilteredFiles();
// Incremental download // Incremental download
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+QString(torrentInfo.name().c_str())+".incremental")){ if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".incremental")){
incrementalDownload->setChecked(true); incrementalDownload->setChecked(true);
}else{ }else{
incrementalDownload->setChecked(false); incrementalDownload->setChecked(false);
@ -107,7 +108,7 @@ properties::~properties(){
void properties::loadFilteredFiles(){ void properties::loadFilteredFiles(){
torrent_info torrentInfo = h.get_torrent_info(); torrent_info torrentInfo = h.get_torrent_info();
QString fileName = QString(torrentInfo.name().c_str()); QString fileName = QString(torrentInfo.name().c_str());
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".pieces"); QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".pieces");
has_filtered_files = false; has_filtered_files = false;
qDebug("Loading filtered state of files"); qDebug("Loading filtered state of files");
// Read saved file // Read saved file
@ -205,12 +206,12 @@ void properties::on_incrementalDownload_stateChanged(int){
torrent_info torrentInfo = h.get_torrent_info(); torrent_info torrentInfo = h.get_torrent_info();
if(incrementalDownload->isChecked()){ if(incrementalDownload->isChecked()){
// Create .incremental file // Create .incremental file
QFile incremental_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+QString(torrentInfo.name().c_str())+".incremental"); QFile incremental_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".incremental");
incremental_file.open(QIODevice::WriteOnly | QIODevice::Text); incremental_file.open(QIODevice::WriteOnly | QIODevice::Text);
incremental_file.close(); incremental_file.close();
h.set_sequenced_download_threshold(15); h.set_sequenced_download_threshold(15);
}else{ }else{
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+QString(torrentInfo.name().c_str())+".incremental"); QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".incremental");
h.set_sequenced_download_threshold(100); h.set_sequenced_download_threshold(100);
} }
} }
@ -271,7 +272,7 @@ void properties::saveFilteredFiles(){
torrent_info torrentInfo = h.get_torrent_info(); torrent_info torrentInfo = h.get_torrent_info();
bool hasFilteredFiles = false; bool hasFilteredFiles = false;
QString fileName = QString(torrentInfo.name().c_str()); QString fileName = QString(torrentInfo.name().c_str());
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".pieces"); QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".pieces");
// First, remove old file // First, remove old file
pieces_file.remove(); pieces_file.remove();
// Write new files // Write new files

1
src/properties_imp.h

@ -35,6 +35,7 @@ class properties : public QDialog, private Ui::properties{
Q_OBJECT Q_OBJECT
private: private:
torrent_handle h; torrent_handle h;
QString fileHash;
PropListDelegate *PropDelegate; PropListDelegate *PropDelegate;
QStandardItemModel *PropListModel; QStandardItemModel *PropListModel;
QTimer *updateProgressTimer; QTimer *updateProgressTimer;

14
src/torrentAddition.h

@ -50,6 +50,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
private: private:
QString fileName; QString fileName;
QString fileHash;
QString filePath; QString filePath;
QList<bool> selection; QList<bool> selection;
bool fromScanDir; bool fromScanDir;
@ -84,6 +85,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
torrent_info t(e); torrent_info t(e);
// Setting file name // Setting file name
fileName = QString(t.name().c_str()); fileName = QString(t.name().c_str());
fileHash = QString(misc::toString(t.info_hash()).c_str());
fileNameLbl->setText("<center><b>"+fileName+"</b></center>"); fileNameLbl->setText("<center><b>"+fileName+"</b></center>");
// List files in torrent // List files in torrent
for(int i=0; i<t.num_files(); ++i){ for(int i=0; i<t.num_files(); ++i){
@ -198,7 +200,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
} }
void saveFilteredFiles(){ void saveFilteredFiles(){
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".pieces"); QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".pieces");
// First, remove old file // First, remove old file
pieces_file.remove(); pieces_file.remove();
// Write new files // Write new files
@ -237,7 +239,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
} }
} }
// Save savepath // Save savepath
QFile savepath_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".savepath"); QFile savepath_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".savepath");
savepath_file.open(QIODevice::WriteOnly | QIODevice::Text); savepath_file.open(QIODevice::WriteOnly | QIODevice::Text);
savepath_file.write(savePath.path().toUtf8()); savepath_file.write(savePath.path().toUtf8());
savepath_file.close(); savepath_file.close();
@ -246,19 +248,19 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
settings.setValue("LastDirTorrentAdd", savePathTxt->text()); settings.setValue("LastDirTorrentAdd", savePathTxt->text());
// Create .incremental file if necessary // Create .incremental file if necessary
if(checkIncrementalDL->isChecked()){ if(checkIncrementalDL->isChecked()){
QFile incremental_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".incremental"); QFile incremental_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".incremental");
incremental_file.open(QIODevice::WriteOnly | QIODevice::Text); incremental_file.open(QIODevice::WriteOnly | QIODevice::Text);
incremental_file.close(); incremental_file.close();
}else{ }else{
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".incremental"); QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".incremental");
} }
// Create .paused file if necessary // Create .paused file if necessary
if(addInPause->isChecked()){ if(addInPause->isChecked()){
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".paused"); QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
paused_file.open(QIODevice::WriteOnly | QIODevice::Text); paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
paused_file.close(); paused_file.close();
}else{ }else{
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".paused"); QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".paused");
} }
// Check if there is at least one selected file // Check if there is at least one selected file
bool selected_file = false; bool selected_file = false;

Loading…
Cancel
Save