float TorrentContentModelItem::progress() const { Q_ASSERT(!isRootItem()); if (m_priority == prio::IGNORED) return 0; if (m_size > 0) return m_totalDone / (double) m_size; return 1; }
QVariant TorrentContentModelItem::data(int column) const { if (isRootItem()) return m_itemData.value(column); switch(column) { case COL_NAME: return m_name; case COL_PRIO: return m_priority; case COL_PROGRESS: return progress(); case COL_SIZE: return m_size; default: Q_ASSERT(false); return QVariant(); } }
QVariant TorrentContentModelItem::data(int column) const { if (isRootItem()) return m_itemData.value(column); switch (column) { case COL_NAME: return m_name; case COL_PRIO: return static_cast<int>(m_priority); case COL_PROGRESS: return progress(); case COL_SIZE: return m_size; case COL_REMAINING: return remaining(); case COL_AVAILABILITY: return availability(); default: Q_ASSERT(false); return {}; } }
BitTorrent::FilePriority TorrentContentModelItem::priority() const { Q_ASSERT(!isRootItem()); return m_priority; }
qreal TorrentContentModelItem::availability() const { Q_ASSERT(!isRootItem()); return (m_size > 0) ? m_availability : 0; }
qulonglong TorrentContentModelItem::remaining() const { Q_ASSERT(!isRootItem()); return m_remaining; }
qreal TorrentContentModelItem::progress() const { Q_ASSERT(!isRootItem()); return (m_size > 0) ? m_progress : 1; }
qulonglong TorrentContentModelItem::size() const { Q_ASSERT(!isRootItem()); return m_size; }
void TorrentContentModelItem::setName(const QString &name) { Q_ASSERT(!isRootItem()); m_name = name; }
QString TorrentContentModelItem::name() const { Q_ASSERT(!isRootItem()); return m_name; }
void TorrentContentModelFolder::deleteAllChildren() { Q_ASSERT(isRootItem()); qDeleteAll(m_childItems); m_childItems.clear(); }
qulonglong TorrentContentModelItem::totalDone() const { Q_ASSERT(!isRootItem()); return m_totalDone; }