本文整理汇总了C++中QTorrentHandle::is_paused方法的典型用法代码示例。如果您正苦于以下问题:C++ QTorrentHandle::is_paused方法的具体用法?C++ QTorrentHandle::is_paused怎么用?C++ QTorrentHandle::is_paused使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTorrentHandle
的用法示例。
在下文中一共展示了QTorrentHandle::is_paused方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: torrentDoubleClicked
void TransferListWidget::torrentDoubleClicked(const QModelIndex& index) {
const int row = mapToSource(index).row();
const QString hash = getHashFromRow(row);
QTorrentHandle h = BTSession->getTorrentHandle(hash);
if (!h.is_valid()) return;
int action;
if (h.is_seed()) {
action = Preferences().getActionOnDblClOnTorrentFn();
} else {
action = Preferences().getActionOnDblClOnTorrentDl();
}
switch(action) {
case TOGGLE_PAUSE:
if (h.is_paused()) {
h.resume();
} else {
h.pause();
}
break;
case OPEN_DEST:
const QString path = h.root_path();
openUrl(path);
}
}
示例2: getETA
qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const
{
QMutexLocker locker(&m_mutex);
QTorrentHandle h = m_session->getTorrentHandle(hash);
if (h.is_paused() || !m_samples.contains(hash)) return -1;
const qreal speed_average = m_samples.value(hash).average();
if (speed_average == 0) return -1;
return (h.total_wanted() - h.total_done()) / speed_average;
}
示例3: toMap
static QVariantMap toMap(const QTorrentHandle& h)
{
libtorrent::torrent_status status = h.status(torrent_handle::query_accurate_download_counters);
QVariantMap ret;
ret[KEY_TORRENT_HASH] = h.hash();
ret[KEY_TORRENT_NAME] = h.name();
ret[KEY_TORRENT_SIZE] = misc::friendlyUnit(status.total_wanted, false, true); // FIXME: Should pass as Number, not formatted String (for sorting).
ret[KEY_TORRENT_PROGRESS] = (double)h.progress(status);
ret[KEY_TORRENT_DLSPEED] = misc::friendlyUnit(status.download_payload_rate, true, true); // FIXME: Should be passed as a Number
ret[KEY_TORRENT_UPSPEED] = misc::friendlyUnit(status.upload_payload_rate, true, true); // FIXME: Should be passed as a Number
if (QBtSession::instance()->isQueueingEnabled() && h.queue_position(status) >= 0)
ret[KEY_TORRENT_PRIORITY] = QString::number(h.queue_position(status));
else
ret[KEY_TORRENT_PRIORITY] = "*";
QString seeds = QString::number(status.num_seeds);
if (status.num_complete > 0)
seeds += " ("+QString::number(status.num_complete)+")";
ret[KEY_TORRENT_SEEDS] = seeds;
QString leechs = QString::number(status.num_peers - status.num_seeds);
if (status.num_incomplete > 0)
leechs += " ("+QString::number(status.num_incomplete)+")";
ret[KEY_TORRENT_LEECHS] = leechs;
const qreal ratio = QBtSession::instance()->getRealRatio(status);
ret[KEY_TORRENT_RATIO] = (ratio > 100.) ? QString::fromUtf8("∞") : misc::accurateDoubleToString(ratio, 1, false);
QString eta;
QString state;
if (h.is_paused(status)) {
if (h.has_error(status))
state = "error";
else
state = h.is_seed(status) ? "pausedUP" : "pausedDL";
} else {
if (QBtSession::instance()->isQueueingEnabled() && h.is_queued(status))
state = h.is_seed(status) ? "queuedUP" : "queuedDL";
else {
switch (status.state) {
case torrent_status::finished:
case torrent_status::seeding:
state = status.upload_payload_rate > 0 ? "uploading" : "stalledUP";
break;
case torrent_status::allocating:
case torrent_status::checking_files:
case torrent_status::queued_for_checking:
case torrent_status::checking_resume_data:
state = h.is_seed(status) ? "checkingUP" : "checkingDL";
break;
case torrent_status::downloading:
case torrent_status::downloading_metadata:
state = status.download_payload_rate > 0 ? "downloading" : "stalledDL";
eta = misc::userFriendlyDuration(QBtSession::instance()->getETA(h.hash(), status));
break;
default:
qWarning("Unrecognized torrent status, should not happen!!! status was %d", h.state());
}
}
}
ret[KEY_TORRENT_ETA] = eta.isEmpty() ? QString::fromUtf8("∞") : eta;
ret[KEY_TORRENT_STATE] = state;
return ret;
}
示例4: toJson
static JsonDict toJson(const QTorrentHandle& h)
{
JsonDict ret;
ret.add(KEY_TORRENT_HASH, h.hash());
ret.add(KEY_TORRENT_NAME, h.name());
ret.add(KEY_TORRENT_SIZE, misc::friendlyUnit(h.actual_size())); // FIXME: Should pass as Number, not formatted String (for sorting).
ret.add(KEY_TORRENT_PROGRESS, (double)h.progress());
ret.add(KEY_TORRENT_DLSPEED, misc::friendlyUnit(h.download_payload_rate(), true)); // FIXME: Should be passed as a Number
ret.add(KEY_TORRENT_UPSPEED, misc::friendlyUnit(h.upload_payload_rate(), true)); // FIXME: Should be passed as a Number
if (QBtSession::instance()->isQueueingEnabled() && h.queue_position() >= 0)
ret.add(KEY_TORRENT_PRIORITY, QString::number(h.queue_position()));
else
ret.add(KEY_TORRENT_PRIORITY, "*");
QString seeds = QString::number(h.num_seeds());
if (h.num_complete() > 0)
seeds += " ("+QString::number(h.num_complete())+")";
ret.add(KEY_TORRENT_SEEDS, seeds);
QString leechs = QString::number(h.num_peers() - h.num_seeds());
if (h.num_incomplete() > 0)
leechs += " ("+QString::number(h.num_incomplete())+")";
ret.add(KEY_TORRENT_LEECHS, leechs);
const qreal ratio = QBtSession::instance()->getRealRatio(h.hash());
/* HACK because QString rounds up. Eg QString::number(0.999*100.0, 'f' ,1) == 99.9
** but QString::number(0.9999*100.0, 'f' ,1) == 100.0 */
ret.add(KEY_TORRENT_RATIO, (ratio > 100.) ? QString::fromUtf8("∞") : QString::number((int)(ratio*10)/10.0, 'f', 1));
QString eta;
QString state;
if (h.is_paused()) {
if (h.has_error())
state = "error";
else
state = h.is_seed() ? "pausedUP" : "pausedDL";
} else {
if (QBtSession::instance()->isQueueingEnabled() && h.is_queued())
state = h.is_seed() ? "queuedUP" : "queuedDL";
else {
switch (h.state()) {
case torrent_status::finished:
case torrent_status::seeding:
state = h.upload_payload_rate() > 0 ? "uploading" : "stalledUP";
break;
case torrent_status::allocating:
case torrent_status::checking_files:
case torrent_status::queued_for_checking:
case torrent_status::checking_resume_data:
state = h.is_seed() ? "checkingUP" : "checkingDL";
break;
case torrent_status::downloading:
case torrent_status::downloading_metadata:
state = h.download_payload_rate() > 0 ? "downloading" : "stalledDL";
eta = misc::userFriendlyDuration(QBtSession::instance()->getETA(h.hash()));
break;
default:
qWarning("Unrecognized torrent status, should not happen!!! status was %d", h.state());
}
}
}
ret.add(KEY_TORRENT_ETA, eta.isEmpty() ? QString::fromUtf8("∞") : eta);
ret.add(KEY_TORRENT_STATE, state);
return ret;
}