当前位置: 首页>>代码示例>>C++>>正文


C++ QTorrentHandle类代码示例

本文整理汇总了C++中QTorrentHandle的典型用法代码示例。如果您正苦于以下问题:C++ QTorrentHandle类的具体用法?C++ QTorrentHandle怎么用?C++ QTorrentHandle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QTorrentHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handleTorrentUpdate

void TorrentModel::handleTorrentUpdate(const QTorrentHandle &h)
{
    const int row = torrentRow(h.hash());
    if (row >= 0) {
        // This line changes the torrent name when magnet is retrieved.
        // When magnet link is added, "dn" parameter is used as name, but when metadata is retrieved
        // we change the name with the retrieved torrent name.
        m_torrents[row]->setData(TorrentModelItem::TR_NAME, h.name(), Qt::DisplayRole);

        m_torrents[row]->refreshStatus(h.status(torrent_handle::query_accurate_download_counters));
        notifyTorrentChanged(row);
    }
}
开发者ID:azuwis,项目名称:debian_qbittorrent,代码行数:13,代码来源:torrentmodel.cpp

示例2: CACHED_VARIABLE_FOR_HASH

/**
 * Returns the files in a torrent in JSON format.
 *
 * The return value is a JSON-formatted list of dictionaries.
 * The dictionary keys are:
 *   - "name": File name
 *   - "size": File size
 *   - "progress": File progress
 *   - "priority": File priority
 *   - "is_seed": Flag indicating if torrent is seeding/complete
 */
QByteArray btjson::getFilesForTorrent(const QString& hash)
{
    CACHED_VARIABLE_FOR_HASH(QVariantList, file_list, CACHE_DURATION_MS, hash);
    try {
        QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
        if (!h.has_metadata())
            return json::toJson(file_list);

        const std::vector<int> priorities = h.file_priorities();
        std::vector<size_type> fp;
        h.file_progress(fp);
        for (int i = 0; i < h.num_files(); ++i) {
            QVariantMap file_dict;
            QString fileName = h.filepath_at(i);
            if (fileName.endsWith(".!qB", Qt::CaseInsensitive))
                fileName.chop(4);
            file_dict[KEY_FILE_NAME] = fsutils::toNativePath(fileName);
            const size_type size = h.filesize_at(i);
            file_dict[KEY_FILE_SIZE] = static_cast<qlonglong>(size);
            file_dict[KEY_FILE_PROGRESS] = (size > 0) ? (fp[i] / (double) size) : 1.;
            file_dict[KEY_FILE_PRIORITY] = priorities[i];
            if (i == 0)
                file_dict[KEY_FILE_IS_SEED] = h.is_seed();

            file_list.append(file_dict);
        }
    }
    catch (const std::exception& e) {
        qWarning() << Q_FUNC_INFO << "Invalid torrent: " << misc::toQStringU(e.what());
        return QByteArray();
    }

    return json::toJson(file_list);
}
开发者ID:azuwis,项目名称:debian_qbittorrent,代码行数:45,代码来源:btjson.cpp

示例3: CACHED_VARIABLE_FOR_HASH

/**
 * Returns the files in a torrent in JSON format.
 *
 * The return value is a JSON-formatted list of dictionaries.
 * The dictionary keys are:
 *   - "name": File name
 *   - "size": File size
 *   - "progress": File progress
 *   - "priority": File priority
 *   - "is_seed": Flag indicating if torrent is seeding/complete
 */
QString btjson::getFilesForTorrent(const QString& hash)
{
  CACHED_VARIABLE_FOR_HASH(JsonList, file_list, CACHE_DURATION_MS, hash);
  try {
    QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
    if (!h.has_metadata())
      return QString();

    const std::vector<int> priorities = h.file_priorities();
    std::vector<size_type> fp;
    h.file_progress(fp);
    for (int i = 0; i < h.num_files(); ++i) {
      JsonDict file_dict;
      QString fileName = h.filename_at(i);
      if (fileName.endsWith(".!qB", Qt::CaseInsensitive))
        fileName.chop(4);
      file_dict.add(KEY_FILE_NAME, fileName);
      const size_type size = h.filesize_at(i);
      file_dict.add(KEY_FILE_SIZE, misc::friendlyUnit(size));
      file_dict.add(KEY_FILE_PROGRESS, (size > 0) ? (fp[i] / (double) size) : 1.);
      file_dict.add(KEY_FILE_PRIORITY, priorities[i]);
      if (i == 0)
        file_dict.add(KEY_FILE_IS_SEED, h.is_seed());

      file_list.append(file_dict);
    }
  } catch (const std::exception& e) {
    qWarning() << Q_FUNC_INFO << "Invalid torrent: " << e.what();
    return QString();
  }

  return file_list.toString();
}
开发者ID:Boris-de,项目名称:qBittorrent,代码行数:44,代码来源:btjson.cpp

示例4: isTorrentResumed

bool QTorrentFilter::isTorrentResumed(const QTorrentHandle &h) const
{
    const QTorrentState state = h.torrentState();

    return state != QTorrentState::PausedUploading
            && state != QTorrentState::PausedDownloading;
}
开发者ID:AdunanzA,项目名称:Tsunami-Old,代码行数:7,代码来源:qtorrentfilter.cpp

示例5: 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;
    }
  }
开发者ID:FZLifer,项目名称:qBittorrent,代码行数:16,代码来源:trackerlist.cpp

示例6: handleTorrentAboutToBeRemoved

void TorrentModel::handleTorrentAboutToBeRemoved(const QTorrentHandle &h)
{
  const int row = torrentRow(h.hash());
  if (row >= 0) {
    emit torrentAboutToBeRemoved(m_torrents.at(row));
  }
}
开发者ID:jadacez,项目名称:qBittorrent,代码行数:7,代码来源:torrentmodel.cpp

示例7: torrentHasLabel

bool QTorrentFilter::torrentHasLabel(const QTorrentHandle &h) const
{
    if (label_.isNull())
        return true;
    else
        return TorrentPersistentData::instance()->getLabel(h.hash()) == label_;
}
开发者ID:AdunanzA,项目名称:Tsunami-Old,代码行数:7,代码来源:qtorrentfilter.cpp

示例8: isTorrentActive

bool QTorrentFilter::isTorrentActive(const QTorrentHandle &h) const
{
    const QTorrentState state = h.torrentState();

    return state == QTorrentState::Downloading
            || state == QTorrentState::Uploading;
}
开发者ID:AdunanzA,项目名称:Tsunami-Old,代码行数:7,代码来源:qtorrentfilter.cpp

示例9: handleTorrentUpdate

void TorrentModel::handleTorrentUpdate(const QTorrentHandle &h)
{
  const int row = torrentRow(h.hash());
  if (row >= 0) {
    notifyTorrentChanged(row);
  }
}
开发者ID:Bigcheese,项目名称:qBittorrent,代码行数:7,代码来源:torrentmodel.cpp

示例10: isTorrentPaused

bool QTorrentFilter::isTorrentPaused(const QTorrentHandle &h) const
{
    const QTorrentState state = h.torrentState();

    return state == QTorrentState::PausedUploading
            || state == QTorrentState::Error;
}
开发者ID:AdunanzA,项目名称:Tsunami-Old,代码行数:7,代码来源:qtorrentfilter.cpp

示例11: mapToSource

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);
  }
}
开发者ID:Fisiu,项目名称:qBittorrent,代码行数:25,代码来源:transferlistwidget.cpp

示例12: isTorrentSeeding

bool QTorrentFilter::isTorrentSeeding(const QTorrentHandle &h) const
{
    const QTorrentState state = h.torrentState();

    return state == QTorrentState::Uploading
            || state == QTorrentState::StalledUploading
            || state == QTorrentState::CheckingUploading
            || state == QTorrentState::QueuedUploading;
}
开发者ID:AdunanzA,项目名称:Tsunami-Old,代码行数:9,代码来源:qtorrentfilter.cpp

示例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);
  notifyTorrentChanged(row);
}
开发者ID:Bigcheese,项目名称:qBittorrent,代码行数:10,代码来源:torrentmodel.cpp

示例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();
  }
}
开发者ID:jadacez,项目名称:qBittorrent,代码行数:11,代码来源:torrentmodel.cpp

示例15: isTorrentDownloading

bool QTorrentFilter::isTorrentDownloading(const QTorrentHandle &h) const
{
    const QTorrentState state = h.torrentState();

    return state == QTorrentState::Downloading
            || state == QTorrentState::StalledDownloading
            || state == QTorrentState::CheckingDownloading
            || state == QTorrentState::PausedDownloading
            || state == QTorrentState::QueuedDownloading
            || state == QTorrentState::Error;
}
开发者ID:AdunanzA,项目名称:Tsunami-Old,代码行数:11,代码来源:qtorrentfilter.cpp


注:本文中的QTorrentHandle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。