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

3
src/bittorrent.cpp

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

8
src/downloadingTorrents.cpp

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

4
src/properties_imp.cpp

@ -502,6 +502,7 @@ void properties::askForTracker(){
h.force_reannounce(); h.force_reannounce();
// Reload Trackers // Reload Trackers
loadTrackers(); loadTrackers();
emit trackersChanged(h.hash());
} }
void properties::deleteSelectedUrlSeeds(){ void properties::deleteSelectedUrlSeeds(){
@ -550,6 +551,7 @@ void properties::deleteSelectedTrackers(){
h.force_reannounce(); h.force_reannounce();
// Reload Trackers // Reload Trackers
loadTrackers(); loadTrackers();
emit trackersChanged(h.hash());
} }
void properties::riseSelectedTracker(){ void properties::riseSelectedTracker(){
@ -583,6 +585,7 @@ void properties::riseSelectedTracker(){
// Reload Trackers // Reload Trackers
loadTrackers(); loadTrackers();
trackersURLS->item(i-1)->setSelected(true); trackersURLS->item(i-1)->setSelected(true);
emit trackersChanged(h.hash());
} }
} }
@ -617,6 +620,7 @@ void properties::lowerSelectedTracker(){
// Reload Trackers // Reload Trackers
loadTrackers(); loadTrackers();
trackersURLS->item(i+1)->setSelected(true); 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{
QTorrentHandle h; QTorrentHandle h;
bittorrent *BTSession; bittorrent *BTSession;
bool changedFilteredfiles; bool changedFilteredfiles;
bool changedTrackers;
QString hash; QString hash;
PropListDelegate *PropDelegate; PropListDelegate *PropDelegate;
QStandardItemModel *PropListModel; QStandardItemModel *PropListModel;
@ -84,6 +85,7 @@ class properties : public QDialog, private Ui::properties{
signals: signals:
void filteredFilesChanged(QString hash); void filteredFilesChanged(QString hash);
void fileSizeChanged(QString hash); void fileSizeChanged(QString hash);
void trackersChanged(QString hash);
public: public:
// Constructor // Constructor

Loading…
Cancel
Save