mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-03-10 12:21:12 +00:00
- Moved "download in sequential order" from Torrent properties to right click menu in transfer list (it makes more sense this way)
- Do not save sequential mode status to hard disk because libtorrent is already taking care of this
This commit is contained in:
parent
81412584e1
commit
e8fba3e630
@ -722,6 +722,18 @@ void TransferListWidget::toggleSelectedTorrentsSuperSeeding() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void TransferListWidget::toggleSelectedTorrentsSequentialDownload() {
|
||||||
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||||
|
foreach(const QModelIndex &index, selectedIndexes) {
|
||||||
|
// Get the file hash
|
||||||
|
QString hash = getHashFromRow(proxyModel->mapToSource(index).row());
|
||||||
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
|
if(h.is_valid()) {
|
||||||
|
h.set_sequential_download(!h.is_sequential_download());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TransferListWidget::displayListMenu(const QPoint&) {
|
void TransferListWidget::displayListMenu(const QPoint&) {
|
||||||
// Create actions
|
// Create actions
|
||||||
QAction actionStart(QIcon(QString::fromUtf8(":/Icons/skin/play.png")), tr("Start"), 0);
|
QAction actionStart(QIcon(QString::fromUtf8(":/Icons/skin/play.png")), tr("Start"), 0);
|
||||||
@ -750,13 +762,15 @@ void TransferListWidget::displayListMenu(const QPoint&) {
|
|||||||
connect(&actionCopy_magnet_link, SIGNAL(triggered()), this, SLOT(copySelectedMagnetURIs()));
|
connect(&actionCopy_magnet_link, SIGNAL(triggered()), this, SLOT(copySelectedMagnetURIs()));
|
||||||
QAction actionSuper_seeding_mode(tr("Super seeding mode"), 0);
|
QAction actionSuper_seeding_mode(tr("Super seeding mode"), 0);
|
||||||
connect(&actionSuper_seeding_mode, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSuperSeeding()));
|
connect(&actionSuper_seeding_mode, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSuperSeeding()));
|
||||||
|
QAction actionSequential_download(tr("Download in sequential order"), 0);
|
||||||
|
connect(&actionSequential_download, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSequentialDownload()));
|
||||||
// End of actions
|
// End of actions
|
||||||
QMenu listMenu(this);
|
QMenu listMenu(this);
|
||||||
// Enable/disable pause/start action given the DL state
|
// Enable/disable pause/start action given the DL state
|
||||||
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||||
bool has_pause = false, has_start = false, has_preview = false;
|
bool has_pause = false, has_start = false, has_preview = false;
|
||||||
bool all_same_super_seeding = true;
|
bool all_same_super_seeding = true, all_same_sequential_download_mode = true;
|
||||||
bool super_seeding_mode = false;
|
bool super_seeding_mode = false, sequential_download_mode = false;
|
||||||
bool one_has_metadata = false, one_not_seed = false;
|
bool one_has_metadata = false, one_not_seed = false;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
QTorrentHandle h;
|
QTorrentHandle h;
|
||||||
@ -771,6 +785,13 @@ void TransferListWidget::displayListMenu(const QPoint&) {
|
|||||||
one_has_metadata = true;
|
one_has_metadata = true;
|
||||||
if(!h.is_seed()) {
|
if(!h.is_seed()) {
|
||||||
one_not_seed = true;
|
one_not_seed = true;
|
||||||
|
if(first) {
|
||||||
|
sequential_download_mode = h.is_sequential_download();
|
||||||
|
} else {
|
||||||
|
if(sequential_download_mode != h.is_sequential_download()) {
|
||||||
|
all_same_sequential_download_mode = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!one_not_seed && all_same_super_seeding) {
|
if(!one_not_seed && all_same_super_seeding) {
|
||||||
if(first) {
|
if(first) {
|
||||||
@ -816,6 +837,16 @@ void TransferListWidget::displayListMenu(const QPoint&) {
|
|||||||
actionSuper_seeding_mode.setIcon(ico);
|
actionSuper_seeding_mode.setIcon(ico);
|
||||||
listMenu.addAction(&actionSuper_seeding_mode);
|
listMenu.addAction(&actionSuper_seeding_mode);
|
||||||
}
|
}
|
||||||
|
if(one_not_seed && all_same_sequential_download_mode) {
|
||||||
|
QIcon ico;
|
||||||
|
if(sequential_download_mode) {
|
||||||
|
ico = QIcon(":/Icons/oxygen/button_ok.png");
|
||||||
|
} else {
|
||||||
|
ico = QIcon(":/Icons/oxygen/button_cancel.png");
|
||||||
|
}
|
||||||
|
actionSequential_download.setIcon(ico);
|
||||||
|
listMenu.addAction(&actionSequential_download);
|
||||||
|
}
|
||||||
listMenu.addSeparator();
|
listMenu.addSeparator();
|
||||||
if(one_has_metadata) {
|
if(one_has_metadata) {
|
||||||
listMenu.addAction(&actionForce_recheck);
|
listMenu.addAction(&actionForce_recheck);
|
||||||
|
@ -80,6 +80,7 @@ protected slots:
|
|||||||
#ifdef LIBTORRENT_0_15
|
#ifdef LIBTORRENT_0_15
|
||||||
void toggleSelectedTorrentsSuperSeeding();
|
void toggleSelectedTorrentsSuperSeeding();
|
||||||
#endif
|
#endif
|
||||||
|
void toggleSelectedTorrentsSequentialDownload();
|
||||||
//void setRowColor(int row, QColor color);
|
//void setRowColor(int row, QColor color);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -53,9 +53,9 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>-85</y>
|
<y>-59</y>
|
||||||
<width>518</width>
|
<width>518</width>
|
||||||
<height>374</height>
|
<height>348</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||||
@ -530,13 +530,6 @@ p, li { white-space: pre-wrap; }
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="incrementalDownload">
|
|
||||||
<property name="text">
|
|
||||||
<string>Download in correct order (slower but good for previewing)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -93,7 +93,6 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transfer
|
|||||||
connect(addWS_button, SIGNAL(clicked()), this, SLOT(askWebSeed()));
|
connect(addWS_button, SIGNAL(clicked()), this, SLOT(askWebSeed()));
|
||||||
connect(deleteWS_button, SIGNAL(clicked()), this, SLOT(deleteSelectedUrlSeeds()));
|
connect(deleteWS_button, SIGNAL(clicked()), this, SLOT(deleteSelectedUrlSeeds()));
|
||||||
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &)));
|
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &)));
|
||||||
connect(incrementalDownload, SIGNAL(stateChanged(int)), this, SLOT(setIncrementalDownload(int)));
|
|
||||||
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
||||||
connect(stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData()));
|
connect(stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData()));
|
||||||
|
|
||||||
@ -165,7 +164,6 @@ void PropertiesWidget::clear() {
|
|||||||
lbl_creationDate->clear();
|
lbl_creationDate->clear();
|
||||||
hash_lbl->clear();
|
hash_lbl->clear();
|
||||||
comment_text->clear();
|
comment_text->clear();
|
||||||
incrementalDownload->setChecked(false);
|
|
||||||
trackerList->clear();
|
trackerList->clear();
|
||||||
progressBar->setProgress(QRealArray());
|
progressBar->setProgress(QRealArray());
|
||||||
wasted->clear();
|
wasted->clear();
|
||||||
@ -211,8 +209,6 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
|
|||||||
hash_lbl->setText(h.hash());
|
hash_lbl->setText(h.hash());
|
||||||
// Comment
|
// Comment
|
||||||
comment_text->setHtml(h.comment());
|
comment_text->setHtml(h.comment());
|
||||||
// Sequential download
|
|
||||||
incrementalDownload->setChecked(TorrentPersistentData::isSequentialDownload(h.hash()));
|
|
||||||
// URL seeds
|
// URL seeds
|
||||||
loadUrlSeeds();
|
loadUrlSeeds();
|
||||||
// downloaded pieces updater
|
// downloaded pieces updater
|
||||||
@ -344,12 +340,6 @@ void PropertiesWidget::loadDynamicData() {
|
|||||||
} catch(invalid_handle e) {}
|
} catch(invalid_handle e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::setIncrementalDownload(int checkboxState) {
|
|
||||||
if(!h.is_valid()) return;
|
|
||||||
h.set_sequential_download(checkboxState == Qt::Checked);
|
|
||||||
TorrentPersistentData::saveSequentialStatus(h);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertiesWidget::loadUrlSeeds(){
|
void PropertiesWidget::loadUrlSeeds(){
|
||||||
QStringList already_added;
|
QStringList already_added;
|
||||||
listWebSeeds->clear();
|
listWebSeeds->clear();
|
||||||
|
@ -80,7 +80,6 @@ protected:
|
|||||||
protected slots:
|
protected slots:
|
||||||
void loadTorrentInfos(QTorrentHandle &h);
|
void loadTorrentInfos(QTorrentHandle &h);
|
||||||
void loadDynamicData();
|
void loadDynamicData();
|
||||||
void setIncrementalDownload(int checkboxState);
|
|
||||||
void loadUrlSeeds();
|
void loadUrlSeeds();
|
||||||
void on_main_infos_button_clicked();
|
void on_main_infos_button_clicked();
|
||||||
void on_trackers_button_clicked();
|
void on_trackers_button_clicked();
|
||||||
|
@ -203,8 +203,6 @@ public:
|
|||||||
}
|
}
|
||||||
data["url_seeds"] = url_seeds;
|
data["url_seeds"] = url_seeds;
|
||||||
}
|
}
|
||||||
// Sequential download
|
|
||||||
data["sequential"] = h.is_sequential_download();
|
|
||||||
// Save data
|
// Save data
|
||||||
all_data[h.hash()] = data;
|
all_data[h.hash()] = data;
|
||||||
settings.setValue("torrents", all_data);
|
settings.setValue("torrents", all_data);
|
||||||
@ -288,15 +286,6 @@ public:
|
|||||||
settings.setValue("torrents", all_data);
|
settings.setValue("torrents", all_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void saveSequentialStatus(QTorrentHandle h) {
|
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
|
||||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
|
||||||
QHash<QString, QVariant> data = all_data[h.hash()].toHash();
|
|
||||||
data["sequential"] = h.is_sequential_download();
|
|
||||||
all_data[h.hash()] = data;
|
|
||||||
settings.setValue("torrents", all_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
static QHash<QString, QVariant> getTrackers(QString hash) {
|
static QHash<QString, QVariant> getTrackers(QString hash) {
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||||
@ -359,12 +348,5 @@ public:
|
|||||||
return data["magnet_uri"].toString();
|
return data["magnet_uri"].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isSequentialDownload(QString hash) {
|
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
|
||||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
|
||||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
|
||||||
return data["sequential"].toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // TORRENTPERSISTENTDATA_H
|
#endif // TORRENTPERSISTENTDATA_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user