Add Size (Bytes) column to Content tab^Add a new column showing exact file sizes in bytes with locale-^appropriate formatting to help users identify files modified by^external tools and prevent cross-seeding issues.^Closes #22690.

This commit is contained in:
Seclusion-5150 2025-06-04 15:21:36 -04:00
parent 7982f66fa6
commit 0a7acbadf0
3 changed files with 13 additions and 3 deletions

View file

@ -166,7 +166,7 @@ namespace
TorrentContentModel::TorrentContentModel(QObject *parent)
: QAbstractItemModel(parent)
, m_rootItem(new TorrentContentModelFolder(QList<QString>({ tr("Name"), tr("Total Size"), tr("Progress"), tr("Download Priority"), tr("Remaining"), tr("Availability") })))
, m_rootItem(new TorrentContentModelFolder(QList<QString>({ tr("Name"), tr("Total Size"), tr("Size (Bytes)"), tr("Progress"), tr("Download Priority"), tr("Remaining"), tr("Availability") })))
#if defined(Q_OS_WIN)
, m_fileIconProvider {new QFileIconProvider}
#elif defined(Q_OS_MACOS)
@ -409,7 +409,8 @@ QVariant TorrentContentModel::data(const QModelIndex &index, const int role) con
case Qt::TextAlignmentRole:
if ((index.column() == TorrentContentModelItem::COL_SIZE)
|| (index.column() == TorrentContentModelItem::COL_REMAINING))
|| (index.column() == TorrentContentModelItem::COL_SIZE_BYTES)
|| (index.column() == TorrentContentModelItem::COL_REMAINING))
{
return QVariant {Qt::AlignRight | Qt::AlignVCenter};
}
@ -456,6 +457,7 @@ QVariant TorrentContentModel::headerData(int section, Qt::Orientation orientatio
case Qt::TextAlignmentRole:
if ((section == TorrentContentModelItem::COL_SIZE)
|| (section == TorrentContentModelItem::COL_SIZE_BYTES)
|| (section == TorrentContentModelItem::COL_REMAINING))
{
return QVariant {Qt::AlignRight | Qt::AlignVCenter};
@ -649,7 +651,8 @@ void TorrentContentModel::refresh()
{TorrentContentModelItem::COL_NAME, TorrentContentModelItem::COL_NAME},
{TorrentContentModelItem::COL_PROGRESS, TorrentContentModelItem::COL_PROGRESS},
{TorrentContentModelItem::COL_PRIO, TorrentContentModelItem::COL_PRIO},
{TorrentContentModelItem::COL_AVAILABILITY, TorrentContentModelItem::COL_AVAILABILITY}
{TorrentContentModelItem::COL_AVAILABILITY, TorrentContentModelItem::COL_AVAILABILITY},
{TorrentContentModelItem::COL_SIZE_BYTES , TorrentContentModelItem::COL_SIZE_BYTES}
};
notifySubtreeUpdated(index(0, 0), columns);
}

View file

@ -28,6 +28,7 @@
#include "torrentcontentmodelitem.h"
#include <QLocale>
#include <QVariant>
#include "base/unicodestrings.h"
@ -139,6 +140,8 @@ QString TorrentContentModelItem::displayData(const int column) const
: Utils::String::fromDouble((avail * 100), 1);
return (value + u'%');
}
case COL_SIZE_BYTES:
return QLocale().toString(m_size);
default:
Q_UNREACHABLE();
break;
@ -166,6 +169,9 @@ QVariant TorrentContentModelItem::underlyingData(const int column) const
return remaining();
case COL_AVAILABILITY:
return availability();
case COL_SIZE_BYTES:
return m_size;
default:
Q_UNREACHABLE();
break;

View file

@ -46,6 +46,7 @@ public:
{
COL_NAME,
COL_SIZE,
COL_SIZE_BYTES,
COL_PROGRESS,
COL_PRIO,
COL_REMAINING,