本文整理汇总了C++中QTorrentHandle::is_valid方法的典型用法代码示例。如果您正苦于以下问题:C++ QTorrentHandle::is_valid方法的具体用法?C++ QTorrentHandle::is_valid怎么用?C++ QTorrentHandle::is_valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTorrentHandle
的用法示例。
在下文中一共展示了QTorrentHandle::is_valid方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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());
}
示例3: onTimer
void HttpServer::onTimer() {
std::vector<torrent_handle> torrents = QBtSession::instance()->getTorrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
QTorrentHandle h = QTorrentHandle(*torrentIT);
if (h.is_valid())
m_eventManager->modifiedTorrent(h);
}
}
示例4: getTorrentsRatesLimits
QByteArray btjson::getTorrentsRatesLimits(QStringList &hashes, bool downloadLimits)
{
QVariantMap map;
foreach (const QString &hash, hashes) {
int limit = -1;
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
if (h.is_valid())
limit = downloadLimits ? h.download_limit() : h.upload_limit();
map[hash] = limit;
}
示例5: showPeerListMenu
void PeerListWidget::showPeerListMenu(const QPoint&)
{
QMenu menu;
bool empty_menu = true;
QTorrentHandle h = m_properties->getCurrentTorrent();
if (!h.is_valid()) return;
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
QStringList selectedPeerIPs;
foreach (const QModelIndex &index, selectedIndexes) {
int row = m_proxyModel->mapToSource(index).row();
QString myip = m_listModel->data(m_listModel->index(row, PeerListDelegate::IP_HIDDEN)).toString();
selectedPeerIPs << myip;
}
示例6: moveSelectionUp
void TrackerList::moveSelectionUp() {
QTorrentHandle h = properties->getCurrentTorrent();
if (!h.is_valid()) {
clear();
return;
}
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
if (selected_items.isEmpty()) return;
bool change = false;
foreach (QTreeWidgetItem *item, selected_items) {
int index = indexOfTopLevelItem(item);
if (index > NB_STICKY_ITEM) {
insertTopLevelItem(index-1, takeTopLevelItem(index));
change = true;
}
}
示例7: getWebSeedsForTorrent
/**
* Returns the web seeds for a torrent in JSON format.
*
* The return value is a JSON-formatted list of dictionaries.
* The dictionary keys are:
* - "url": Web seed URL
*/
QByteArray btjson::getWebSeedsForTorrent(const QString& hash)
{
CACHED_VARIABLE_FOR_HASH(QVariantList, webSeedList, CACHE_DURATION_MS, hash);
QTorrentHandle torrent = QBtSession::instance()->getTorrentHandle(hash);
if (!torrent.is_valid()) {
qWarning() << Q_FUNC_INFO << "Invalid torrent " << qPrintable(hash);
return QByteArray();
}
foreach (const QString &webseed, torrent.url_seeds()) {
QVariantMap webSeedDict;
webSeedDict[KEY_WEBSEED_URL] = webseed;
webSeedList.append(webSeedDict);
}
return json::toJson(webSeedList);
}
示例8: QTcpServer
HttpServer::HttpServer(int msec, QObject* parent) : QTcpServer(parent),
m_eventManager(new EventManager(this)) {
const Preferences pref;
m_username = pref.getWebUiUsername().toLocal8Bit();
m_passwordSha1 = pref.getWebUiPassword().toLocal8Bit();
m_localAuthEnabled = pref.isWebUiLocalAuthEnabled();
m_needsTranslation = !Preferences().getLocale().startsWith("en");
connect(m_eventManager, SIGNAL(localeChanged(QString)), SLOT(onLocaleChanged(QString)));
// HTTPS-related
#ifndef QT_NO_OPENSSL
m_https = pref.isWebUiHttpsEnabled();
if (m_https) {
m_certificate = QSslCertificate(pref.getWebUiHttpsCertificate());
m_key = QSslKey(pref.getWebUiHttpsKey(), QSsl::Rsa);
}
#endif
// Add torrents
std::vector<torrent_handle> torrents = QBtSession::instance()->getTorrents();
std::vector<torrent_handle>::iterator torrentIT;
for (torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
QTorrentHandle h = QTorrentHandle(*torrentIT);
if (h.is_valid())
m_eventManager->addedTorrent(h);
}
//connect QBtSession::instance() to manager
connect(QBtSession::instance(), SIGNAL(addedTorrent(QTorrentHandle)), m_eventManager, SLOT(addedTorrent(QTorrentHandle)));
connect(QBtSession::instance(), SIGNAL(deletedTorrent(QString)), m_eventManager, SLOT(deletedTorrent(QString)));
//set timer
connect(&m_timer, SIGNAL(timeout()), SLOT(onTimer()));
m_timer.start(msec);
// Additional translations for Web UI
QString a = tr("File");
a = tr("Edit");
a = tr("Help");
a = tr("Download Torrents from their URL or Magnet link");
a = tr("Only one link per line");
a = tr("Download local torrent");
a = tr("Torrent files were correctly added to download list.");
a = tr("Point to torrent file");
a = tr("Download");
a = tr("Are you sure you want to delete the selected torrents from the transfer list and hard disk?");
a = tr("Download rate limit must be greater than 0 or disabled.");
a = tr("Upload rate limit must be greater than 0 or disabled.");
a = tr("Maximum number of connections limit must be greater than 0 or disabled.");
a = tr("Maximum number of connections per torrent limit must be greater than 0 or disabled.");
a = tr("Maximum number of upload slots per torrent limit must be greater than 0 or disabled.");
a = tr("Unable to save program preferences, qBittorrent is probably unreachable.");
a = tr("Language");
a = tr("Downloaded", "Is the file downloaded or not?");
a = tr("The port used for incoming connections must be greater than 1024 and less than 65535.");
a = tr("The port used for the Web UI must be greater than 1024 and less than 65535.");
a = tr("The Web UI username must be at least 3 characters long.");
a = tr("The Web UI password must be at least 3 characters long.");
a = tr("Save");
a = tr("qBittorrent client is not reachable");
a = tr("HTTP Server");
a = tr("The following parameters are supported:");
a = tr("Torrent path");
a = tr("Torrent name");
}