mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-24 02:06:07 +03:00
- Saving trackers file only when necessary
- Avoid code duplication for showProperties()
This commit is contained in:
parent
f3f3f2822b
commit
c8b944508b
5 changed files with 11 additions and 14 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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(){
|
|||
h.force_reannounce();
|
||||
// Reload Trackers
|
||||
loadTrackers();
|
||||
emit trackersChanged(h.hash());
|
||||
}
|
||||
|
||||
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(){
|
|||
// Reload Trackers
|
||||
loadTrackers();
|
||||
trackersURLS->item(i+1)->setSelected(true);
|
||||
emit trackersChanged(h.hash());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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{
|
|||
signals:
|
||||
void filteredFilesChanged(QString hash);
|
||||
void fileSizeChanged(QString hash);
|
||||
void trackersChanged(QString hash);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
|
|
Loading…
Reference in a new issue