本文整理汇总了C++中QTorrentHandle::hash方法的典型用法代码示例。如果您正苦于以下问题:C++ QTorrentHandle::hash方法的具体用法?C++ QTorrentHandle::hash怎么用?C++ QTorrentHandle::hash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTorrentHandle
的用法示例。
在下文中一共展示了QTorrentHandle::hash方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveSeedStatus
void TorrentPersistentData::saveSeedStatus(const QTorrentHandle &h) {
QHash<QString, QVariant> data = all_data[h.hash()].toHash();
bool was_seed = data.value("seed", false).toBool();
if (was_seed != h.is_seed()) {
data["seed"] = !was_seed;
all_data[h.hash()] = data;
markDirty();
}
}
示例2:
TorrentModelItem::TorrentModelItem(const QTorrentHandle &h)
: m_torrent(h)
, m_addedTime(TorrentPersistentData::getAddedDate(h.hash()))
, m_seedTime(TorrentPersistentData::getSeedDate(h.hash()))
, m_label(TorrentPersistentData::getLabel(h.hash()))
, m_name(TorrentPersistentData::getName(h.hash()))
, m_hash(h.hash())
{
if (m_name.isEmpty())
m_name = h.name();
}
示例3:
TorrentModelItem::TorrentModelItem(const QTorrentHandle &h)
: m_torrent(h)
, m_lastStatus(h.status(torrent_handle::query_accurate_download_counters))
, m_addedTime(TorrentPersistentData::getAddedDate(h.hash()))
, m_label(TorrentPersistentData::getLabel(h.hash()))
, m_name(TorrentPersistentData::getName(h.hash()))
, m_hash(h.hash())
{
if (m_name.isEmpty())
m_name = h.name();
}
示例4:
TorrentModelItem::TorrentModelItem(const QTorrentHandle &h)
: m_torrent(h)
, m_lastStatus(h.status(torrent_handle::query_accurate_download_counters))
, m_addedTime(TorrentPersistentData::instance()->getAddedDate(h.hash()))
, m_label(TorrentPersistentData::instance()->getLabel(h.hash()))
, m_name(TorrentPersistentData::instance()->getName(h.hash()))
, m_hash(h.hash())
{
if (m_name.isEmpty())
m_name = h.name();
// If name is empty show the hash. This happens when magnet isn't retrieved.
if (m_name.isEmpty())
m_name = h.hash();
}
示例5: handleTorrentUpdate
void TorrentModel::handleTorrentUpdate(const QTorrentHandle &h)
{
const int row = torrentRow(h.hash());
if (row >= 0) {
notifyTorrentChanged(row);
}
}
示例6: handleTorrentAboutToBeRemoved
void TorrentModel::handleTorrentAboutToBeRemoved(const QTorrentHandle &h)
{
const int row = torrentRow(h.hash());
if (row >= 0) {
emit torrentAboutToBeRemoved(m_torrents.at(row));
}
}
示例7: torrentHasLabel
bool QTorrentFilter::torrentHasLabel(const QTorrentHandle &h) const
{
if (label_.isNull())
return true;
else
return TorrentPersistentData::instance()->getLabel(h.hash()) == label_;
}
示例8: populate
void TorrentModel::populate() {
// Load the torrents
std::vector<torrent_handle> torrents = QBtSession::instance()->getSession()->get_torrents();
std::vector<torrent_handle>::const_iterator it = torrents.begin();
std::vector<torrent_handle>::const_iterator itend = torrents.end();
for ( ; it != itend; ++it) {
const QTorrentHandle h(*it);
if (HiddenData::hasData(h.hash()))
continue;
addTorrent(h);
}
// Refresh timer
connect(&m_refreshTimer, SIGNAL(timeout()), SLOT(forceModelRefresh()));
m_refreshTimer.start(m_refreshInterval);
// Listen for torrent changes
connect(QBtSession::instance(), SIGNAL(addedTorrent(QTorrentHandle)), SLOT(addTorrent(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(torrentAboutToBeRemoved(QTorrentHandle)), SLOT(handleTorrentAboutToBeRemoved(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(deletedTorrent(QString)), SLOT(removeTorrent(QString)));
connect(QBtSession::instance(), SIGNAL(finishedTorrent(QTorrentHandle)), SLOT(handleFinishedTorrent(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(metadataReceived(QTorrentHandle)), SLOT(handleTorrentUpdate(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(resumedTorrent(QTorrentHandle)), SLOT(handleTorrentUpdate(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(pausedTorrent(QTorrentHandle)), SLOT(handleTorrentUpdate(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(torrentFinishedChecking(QTorrentHandle)), SLOT(handleTorrentUpdate(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(stateUpdate(std::vector<libtorrent::torrent_status>)), SLOT(stateUpdated(std::vector<libtorrent::torrent_status>)));
}
示例9: getSyncMainData
/**
* The function returns the changed data from the server to synchronize with the web client.
* Return value is map in JSON format.
* Map contain the key:
* - "Rid": ID response
* Map can contain the keys:
* - "full_update": full data update flag
* - "torrents": dictionary contains information about torrents.
* - "torrents_removed": a list of hashes of removed torrents
* - "labels": list of labels
* - "labels_removed": list of removed labels
* - "server_state": map contains information about the state of the server
* The keys of the 'torrents' dictionary are hashes of torrents.
* Each value of the 'torrents' dictionary contains map. The map can contain following keys:
* - "name": Torrent name
* - "size": Torrent size
* - "progress: Torrent progress
* - "dlspeed": Torrent download speed
* - "upspeed": Torrent upload speed
* - "priority": Torrent priority (-1 if queuing is disabled)
* - "num_seeds": Torrent seeds connected to
* - "num_complete": Torrent seeds in the swarm
* - "num_leechs": Torrent leechers connected to
* - "num_incomplete": Torrent leechers in the swarm
* - "ratio": Torrent share ratio
* - "eta": Torrent ETA
* - "state": Torrent state
* - "seq_dl": Torrent sequential download state
* - "f_l_piece_prio": Torrent first last piece priority state
* Server state map may contain the following keys:
* - "connection_status": conection status
* - "dht_nodes": DHT nodes count
* - "dl_info_data": bytes downloaded
* - "dl_info_speed": download speed
* - "dl_rate_limit: downlaod rate limit
* - "up_info_data: bytes uploaded
* - "up_info_speed: upload speed
* - "up_rate_limit: upload speed limit
* - "queueing": priority system usage flag
* - "refresh_interval": torrents table refresh interval
*/
QByteArray btjson::getSyncMainData(int acceptedResponseId, QVariantMap &lastData, QVariantMap &lastAcceptedData)
{
QVariantMap data;
QVariantHash torrents;
std::vector<torrent_handle> torrentsList = QBtSession::instance()->getTorrents();
std::vector<torrent_handle>::const_iterator it = torrentsList.begin();
std::vector<torrent_handle>::const_iterator end = torrentsList.end();
for (; it != end; ++it) {
QTorrentHandle torrent = QTorrentHandle(*it);
QVariantMap map = toMap(torrent);
map.remove(KEY_TORRENT_HASH);
torrents[torrent.hash()] = map;
}
data["torrents"] = torrents;
QVariantList labels;
foreach (QString s, Preferences::instance()->getTorrentLabels())
labels << s;
data["labels"] = labels;
QVariantMap serverState = getTranserInfoMap();
serverState[KEY_SYNC_MAINDATA_QUEUEING] = QBtSession::instance()->isQueueingEnabled();
serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = Preferences::instance()->isAltBandwidthEnabled();
serverState[KEY_SYNC_MAINDATA_REFRESH_INTERVAL] = Preferences::instance()->getRefreshInterval();
data["server_state"] = serverState;
return json::toJson(generateSyncData(acceptedResponseId, data, lastAcceptedData, lastData));
}
示例10: handleTorrentUpdate
void TorrentModel::handleTorrentUpdate(const QTorrentHandle &h)
{
const int row = torrentRow(h.hash());
if (row >= 0) {
m_torrents[row]->refreshStatus(h.status(torrent_handle::query_accurate_download_counters));
notifyTorrentChanged(row);
}
}
示例11: handleFinishedTorrent
void TorrentModel::handleFinishedTorrent(const QTorrentHandle& h)
{
const int row = torrentRow(h.hash());
if (row < 0)
return;
// Update completion date
m_torrents[row]->refreshStatus(h.status(torrent_handle::query_accurate_download_counters));
notifyTorrentChanged(row);
}
示例12: handleFinishedTorrent
void TorrentModel::handleFinishedTorrent(const QTorrentHandle& h)
{
const int row = torrentRow(h.hash());
if (row < 0)
return;
// Update completion date
m_torrents[row]->setData(TorrentModelItem::TR_SEED_DATE, QDateTime::currentDateTime(), Qt::DisplayRole);
notifyTorrentChanged(row);
}
示例13: handleFinishedTorrent
void TorrentModel::handleFinishedTorrent(const QTorrentHandle& h)
{
const int row = torrentRow(h.hash());
if (row < 0)
return;
// Update completion date
m_torrents[row]->setData(TorrentModelItem::TR_SEED_DATE, QDateTime::currentDateTime(), Qt::DisplayRole);
m_torrents[row]->refreshStatus(h.status(torrent_handle::query_accurate_download_counters));
notifyTorrentChanged(row);
}
示例14: addTorrent
void TorrentModel::addTorrent(const QTorrentHandle &h)
{
if (torrentRow(h.hash()) < 0) {
beginInsertTorrent(m_torrents.size());
TorrentModelItem *item = new TorrentModelItem(h);
connect(item, SIGNAL(labelChanged(QString,QString)), SLOT(handleTorrentLabelChange(QString,QString)));
m_torrents << item;
emit torrentAdded(item);
endInsertTorrent();
}
}
示例15: saveTorrentPersistentData
void TorrentPersistentData::saveTorrentPersistentData(const QTorrentHandle &h, const QString &save_path, const bool is_magnet) {
Q_ASSERT(h.is_valid());
qDebug("Saving persistent data for %s", qPrintable(h.hash()));
// Save persistent data
QHash<QString, QVariant> data = all_data.value(h.hash()).toHash();
data["is_magnet"] = is_magnet;
if (is_magnet) {
data["magnet_uri"] = misc::toQString(make_magnet_uri(h));
}
data["seed"] = h.is_seed();
data["priority"] = h.queue_position();
if (save_path.isEmpty()) {
qDebug("TorrentPersistantData: save path is %s", qPrintable(h.save_path()));
data["save_path"] = h.save_path();
} else {
qDebug("TorrentPersistantData: overriding save path is %s", qPrintable(save_path));
data["save_path"] = save_path; // Override torrent save path (e.g. because it is a temp dir)
}
// Label
data["label"] = TorrentTempData::getLabel(h.hash());
// Save data
all_data[h.hash()] = data;
markDirty();
qDebug("TorrentPersistentData: Saving save_path %s, hash: %s", qPrintable(h.save_path()), qPrintable(h.hash()));
// Set Added date
setAddedDate(h.hash(), QDateTime::currentDateTime());
// Finally, remove temp data
TorrentTempData::deleteTempData(h.hash());
}