mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-23 00:47:21 -06:00
Implement 'Force Start' feature. Closes #270.
This commit is contained in:
@@ -817,10 +817,10 @@ void QBtSession::pauseTorrent(const QString &hash) {
|
||||
}
|
||||
}
|
||||
|
||||
void QBtSession::resumeTorrent(const QString &hash) {
|
||||
void QBtSession::resumeTorrent(const QString &hash, const bool force) {
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
if (h.is_paused()) {
|
||||
h.resume();
|
||||
if (h.is_paused() || (h.is_forced() != force)) {
|
||||
h.resume(force);
|
||||
emit resumedTorrent(h);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public slots:
|
||||
/* Needed by Web UI */
|
||||
void pauseAllTorrents();
|
||||
void pauseTorrent(const QString &hash);
|
||||
void resumeTorrent(const QString &hash);
|
||||
void resumeTorrent(const QString &hash, const bool force = false);
|
||||
void resumeAllTorrents();
|
||||
/* End Web UI */
|
||||
void preAllocateAllFiles(bool b);
|
||||
|
||||
@@ -505,6 +505,11 @@ void QTorrentHandle::toggleFirstLastPiecePrio()
|
||||
prioritize_first_last_piece(!first_last_piece_first());
|
||||
}
|
||||
|
||||
bool QTorrentHandle::is_forced() const
|
||||
{
|
||||
return is_forced(status(0x0));
|
||||
}
|
||||
|
||||
//
|
||||
// Setters
|
||||
//
|
||||
@@ -517,10 +522,11 @@ void QTorrentHandle::pause() const
|
||||
torrent_handle::save_resume_data();
|
||||
}
|
||||
|
||||
void QTorrentHandle::resume() const
|
||||
void QTorrentHandle::resume(const bool force) const
|
||||
{
|
||||
if (has_error())
|
||||
torrent_handle::clear_error();
|
||||
torrent_handle::set_upload_mode(false);
|
||||
|
||||
const QString torrent_hash = hash();
|
||||
TorrentPersistentData* const TorPersistent = TorrentPersistentData::instance();
|
||||
@@ -535,7 +541,7 @@ void QTorrentHandle::resume() const
|
||||
if (!final_save_path.isEmpty())
|
||||
move_storage(final_save_path);
|
||||
}
|
||||
torrent_handle::auto_managed(true);
|
||||
torrent_handle::auto_managed(!force);
|
||||
torrent_handle::resume();
|
||||
if (has_persistant_error && temp_path_enabled)
|
||||
// Force recheck
|
||||
@@ -803,6 +809,11 @@ QString QTorrentHandle::filepath_at(const libtorrent::torrent_info &info, unsign
|
||||
|
||||
}
|
||||
|
||||
bool QTorrentHandle::is_forced(const libtorrent::torrent_status &status)
|
||||
{
|
||||
return !status.paused && !status.auto_managed;
|
||||
}
|
||||
|
||||
|
||||
QTorrentState::QTorrentState(int value)
|
||||
: m_value(value)
|
||||
|
||||
@@ -130,12 +130,13 @@ public:
|
||||
qulonglong eta() const;
|
||||
void toggleSequentialDownload();
|
||||
void toggleFirstLastPiecePrio();
|
||||
bool is_forced() const;
|
||||
|
||||
//
|
||||
// Setters
|
||||
//
|
||||
void pause() const;
|
||||
void resume() const;
|
||||
void resume(const bool force = false) const;
|
||||
void remove_url_seed(const QString& seed) const;
|
||||
void add_url_seed(const QString& seed) const;
|
||||
void set_tracker_login(const QString& username, const QString& password) const;
|
||||
@@ -159,6 +160,7 @@ public:
|
||||
static bool has_error(const libtorrent::torrent_status &status);
|
||||
static float progress(const libtorrent::torrent_status &status);
|
||||
static QString filepath_at(const libtorrent::torrent_info &info, unsigned int index);
|
||||
static bool is_forced(const libtorrent::torrent_status &status);
|
||||
|
||||
private:
|
||||
void prioritize_first_last_piece(int file_index, bool b) const;
|
||||
|
||||
@@ -148,10 +148,16 @@ TorrentModelItem::State TorrentModelItem::state() const {
|
||||
case torrent_status::downloading_metadata:
|
||||
return STATE_DOWNLOADING_META;
|
||||
case torrent_status::downloading:
|
||||
return m_lastStatus.download_payload_rate > 0 ? STATE_DOWNLOADING : STATE_STALLED_DL;
|
||||
if (!m_torrent.is_forced(m_lastStatus))
|
||||
return m_lastStatus.download_payload_rate > 0 ? STATE_DOWNLOADING : STATE_STALLED_DL;
|
||||
else
|
||||
return STATE_FORCED_DL;
|
||||
case torrent_status::finished:
|
||||
case torrent_status::seeding:
|
||||
return m_lastStatus.upload_payload_rate > 0 ? STATE_SEEDING : STATE_STALLED_UP;
|
||||
if (!m_torrent.is_forced(m_lastStatus))
|
||||
return m_lastStatus.upload_payload_rate > 0 ? STATE_SEEDING : STATE_STALLED_UP;
|
||||
else
|
||||
return STATE_FORCED_UP;
|
||||
case torrent_status::queued_for_checking:
|
||||
return STATE_QUEUED_CHECK;
|
||||
case torrent_status::checking_resume_data:
|
||||
@@ -170,6 +176,7 @@ QIcon TorrentModelItem::getIconByState(State state) {
|
||||
switch (state) {
|
||||
case STATE_DOWNLOADING:
|
||||
case STATE_DOWNLOADING_META:
|
||||
case STATE_FORCED_DL:
|
||||
return get_downloading_icon();
|
||||
case STATE_ALLOCATING:
|
||||
case STATE_STALLED_DL:
|
||||
@@ -177,6 +184,7 @@ QIcon TorrentModelItem::getIconByState(State state) {
|
||||
case STATE_STALLED_UP:
|
||||
return get_stalled_uploading_icon();
|
||||
case STATE_SEEDING:
|
||||
case STATE_FORCED_UP:
|
||||
return get_uploading_icon();
|
||||
case STATE_PAUSED_DL:
|
||||
return get_paused_icon();
|
||||
@@ -204,6 +212,7 @@ QColor TorrentModelItem::getColorByState(State state) {
|
||||
switch (state) {
|
||||
case STATE_DOWNLOADING:
|
||||
case STATE_DOWNLOADING_META:
|
||||
case STATE_FORCED_DL:
|
||||
return QColor(34, 139, 34); // Forest Green
|
||||
case STATE_ALLOCATING:
|
||||
case STATE_STALLED_DL:
|
||||
@@ -213,6 +222,7 @@ QColor TorrentModelItem::getColorByState(State state) {
|
||||
else
|
||||
return QColor(255, 255, 255); // White
|
||||
case STATE_SEEDING:
|
||||
case STATE_FORCED_UP:
|
||||
if (!dark)
|
||||
return QColor(65, 105, 225); // Royal Blue
|
||||
else
|
||||
@@ -596,6 +606,7 @@ TorrentStatusReport TorrentModel::getTorrentStatusReport() const
|
||||
for ( ; it != itend; ++it) {
|
||||
switch((*it)->state()) {
|
||||
case TorrentModelItem::STATE_DOWNLOADING:
|
||||
case TorrentModelItem::STATE_FORCED_DL:
|
||||
++report.nb_active;
|
||||
++report.nb_downloading;
|
||||
break;
|
||||
@@ -613,6 +624,7 @@ TorrentStatusReport TorrentModel::getTorrentStatusReport() const
|
||||
break;
|
||||
}
|
||||
case TorrentModelItem::STATE_SEEDING:
|
||||
case TorrentModelItem::STATE_FORCED_UP:
|
||||
++report.nb_active;
|
||||
++report.nb_seeding;
|
||||
++report.nb_completed;
|
||||
@@ -690,8 +702,10 @@ bool TorrentModel::inhibitSystem()
|
||||
switch((*it)->data(TorrentModelItem::TR_STATUS).toInt()) {
|
||||
case TorrentModelItem::STATE_DOWNLOADING:
|
||||
case TorrentModelItem::STATE_DOWNLOADING_META:
|
||||
case TorrentModelItem::STATE_FORCED_DL:
|
||||
case TorrentModelItem::STATE_STALLED_DL:
|
||||
case TorrentModelItem::STATE_SEEDING:
|
||||
case TorrentModelItem::STATE_FORCED_UP:
|
||||
case TorrentModelItem::STATE_STALLED_UP:
|
||||
return true;
|
||||
default:
|
||||
|
||||
@@ -53,7 +53,7 @@ class TorrentModelItem : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum State {STATE_DOWNLOADING, STATE_DOWNLOADING_META, STATE_ALLOCATING, STATE_STALLED_DL, STATE_SEEDING, STATE_STALLED_UP, STATE_QUEUED_DL, STATE_QUEUED_UP, STATE_CHECKING_UP, STATE_CHECKING_DL, STATE_QUEUED_CHECK, STATE_QUEUED_FASTCHECK, STATE_PAUSED_DL, STATE_PAUSED_UP, STATE_PAUSED_MISSING, STATE_INVALID};
|
||||
enum State {STATE_DOWNLOADING, STATE_DOWNLOADING_META, STATE_ALLOCATING, STATE_STALLED_DL, STATE_SEEDING, STATE_STALLED_UP, STATE_QUEUED_DL, STATE_QUEUED_UP, STATE_CHECKING_UP, STATE_CHECKING_DL, STATE_QUEUED_CHECK, STATE_QUEUED_FASTCHECK, STATE_PAUSED_DL, STATE_PAUSED_UP, STATE_PAUSED_MISSING, STATE_FORCED_DL, STATE_FORCED_UP, STATE_INVALID};
|
||||
enum Column {TR_NAME, TR_PRIORITY, TR_SIZE, TR_TOTAL_SIZE, TR_PROGRESS, TR_STATUS, TR_SEEDS, TR_PEERS, TR_DLSPEED, TR_UPSPEED, TR_ETA, TR_RATIO, TR_LABEL, TR_ADD_DATE, TR_SEED_DATE, TR_TRACKER, TR_DLLIMIT, TR_UPLIMIT, TR_AMOUNT_DOWNLOADED, TR_AMOUNT_UPLOADED, TR_AMOUNT_LEFT, TR_TIME_ELAPSED, TR_SAVE_PATH, TR_COMPLETED, TR_RATIO_LIMIT, TR_SEEN_COMPLETE_DATE, TR_LAST_ACTIVITY, TR_AMOUNT_DOWNLOADED_SESSION, TR_AMOUNT_UPLOADED_SESSION, NB_COLUMNS};
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user