Browse Source

- Saving trackers file only when necessary

- Avoid code duplication for showProperties()
adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
c8b944508b
  1. 8
      src/FinishedTorrents.cpp
  2. 3
      src/bittorrent.cpp
  3. 8
      src/downloadingTorrents.cpp
  4. 4
      src/properties_imp.cpp
  5. 2
      src/properties_imp.h

8
src/FinishedTorrents.cpp

@ -310,18 +310,14 @@ void FinishedTorrents::deleteTorrent(QString hash){ @@ -310,18 +310,14 @@ void FinishedTorrents::deleteTorrent(QString hash){
// Show torrent properties dialog
void FinishedTorrents::showProperties(const QModelIndex &index){
int row = index.row();
QString hash = finishedListModel->data(finishedListModel->index(row, F_HASH)).toString();
QTorrentHandle h = BTSession->getTorrentHandle(hash);
properties *prop = new properties(this, BTSession, h);
connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSize(QString)));
prop->show();
showPropertiesFromHash(finishedListModel->data(finishedListModel->index(index.row(), F_HASH)).toString());
}
void FinishedTorrents::showPropertiesFromHash(QString hash){
QTorrentHandle h = BTSession->getTorrentHandle(hash);
properties *prop = new properties(this, BTSession, h);
connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSize(QString)));
connect(prop, SIGNAL(trackersChanged(QString)), BTSession, SLOT(saveTrackerFile(QString)));
prop->show();
}

3
src/bittorrent.cpp

@ -858,8 +858,6 @@ void bittorrent::saveFastResumeAndRatioData() { @@ -858,8 +858,6 @@ void bittorrent::saveFastResumeAndRatioData() {
}
// Save ratio data
saveDownloadUploadForTorrent(hash);
// Save trackers
saveTrackerFile(hash);
}
}
qDebug("Fast resume and ratio data saved");
@ -1005,6 +1003,7 @@ bool bittorrent::loadTrackerFile(QString hash) { @@ -1005,6 +1003,7 @@ bool bittorrent::loadTrackerFile(QString hash) {
}
void bittorrent::saveTrackerFile(QString hash) {
qDebug("Saving tracker file for %s", hash.toUtf8().data());
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
QFile tracker_file(torrentBackup.path()+QDir::separator()+ hash + ".trackers");
if(tracker_file.exists()) {

8
src/downloadingTorrents.cpp

@ -168,18 +168,14 @@ void DownloadingTorrents::setBottomTabEnabled(unsigned int index, bool b){ @@ -168,18 +168,14 @@ void DownloadingTorrents::setBottomTabEnabled(unsigned int index, bool b){
// Show torrent properties dialog
void DownloadingTorrents::showProperties(const QModelIndex &index) {
int row = index.row();
QString hash = DLListModel->data(DLListModel->index(row, HASH)).toString();
QTorrentHandle h = BTSession->getTorrentHandle(hash);
properties *prop = new properties(this, BTSession, h);
connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSizeAndProgress(QString)));
prop->show();
showPropertiesFromHash(DLListModel->data(DLListModel->index(index.row(), HASH)).toString());
}
void DownloadingTorrents::showPropertiesFromHash(QString hash) {
QTorrentHandle h = BTSession->getTorrentHandle(hash);
properties *prop = new properties(this, BTSession, h);
connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSizeAndProgress(QString)));
connect(prop, SIGNAL(trackersChanged(QString)), BTSession, SLOT(saveTrackerFile(QString)));
prop->show();
}

4
src/properties_imp.cpp

@ -502,6 +502,7 @@ void properties::askForTracker(){ @@ -502,6 +502,7 @@ void properties::askForTracker(){
h.force_reannounce();
// Reload Trackers
loadTrackers();
emit trackersChanged(h.hash());
}
void properties::deleteSelectedUrlSeeds(){
@ -550,6 +551,7 @@ void properties::deleteSelectedTrackers(){ @@ -550,6 +551,7 @@ void properties::deleteSelectedTrackers(){
h.force_reannounce();
// Reload Trackers
loadTrackers();
emit trackersChanged(h.hash());
}
void properties::riseSelectedTracker(){
@ -583,6 +585,7 @@ void properties::riseSelectedTracker(){ @@ -583,6 +585,7 @@ void properties::riseSelectedTracker(){
// Reload Trackers
loadTrackers();
trackersURLS->item(i-1)->setSelected(true);
emit trackersChanged(h.hash());
}
}
@ -617,6 +620,7 @@ void properties::lowerSelectedTracker(){ @@ -617,6 +620,7 @@ void properties::lowerSelectedTracker(){
// Reload Trackers
loadTrackers();
trackersURLS->item(i+1)->setSelected(true);
emit trackersChanged(h.hash());
}
}

2
src/properties_imp.h

@ -42,6 +42,7 @@ class properties : public QDialog, private Ui::properties{ @@ -42,6 +42,7 @@ class properties : public QDialog, private Ui::properties{
QTorrentHandle h;
bittorrent *BTSession;
bool changedFilteredfiles;
bool changedTrackers;
QString hash;
PropListDelegate *PropDelegate;
QStandardItemModel *PropListModel;
@ -84,6 +85,7 @@ class properties : public QDialog, private Ui::properties{ @@ -84,6 +85,7 @@ class properties : public QDialog, private Ui::properties{
signals:
void filteredFilesChanged(QString hash);
void fileSizeChanged(QString hash);
void trackersChanged(QString hash);
public:
// Constructor

Loading…
Cancel
Save