mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-06 05:01:25 -07:00
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:
parent
7982f66fa6
commit
0a7acbadf0
3 changed files with 13 additions and 3 deletions
|
@ -166,7 +166,7 @@ namespace
|
||||||
|
|
||||||
TorrentContentModel::TorrentContentModel(QObject *parent)
|
TorrentContentModel::TorrentContentModel(QObject *parent)
|
||||||
: QAbstractItemModel(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)
|
#if defined(Q_OS_WIN)
|
||||||
, m_fileIconProvider {new QFileIconProvider}
|
, m_fileIconProvider {new QFileIconProvider}
|
||||||
#elif defined(Q_OS_MACOS)
|
#elif defined(Q_OS_MACOS)
|
||||||
|
@ -409,7 +409,8 @@ QVariant TorrentContentModel::data(const QModelIndex &index, const int role) con
|
||||||
|
|
||||||
case Qt::TextAlignmentRole:
|
case Qt::TextAlignmentRole:
|
||||||
if ((index.column() == TorrentContentModelItem::COL_SIZE)
|
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};
|
return QVariant {Qt::AlignRight | Qt::AlignVCenter};
|
||||||
}
|
}
|
||||||
|
@ -456,6 +457,7 @@ QVariant TorrentContentModel::headerData(int section, Qt::Orientation orientatio
|
||||||
|
|
||||||
case Qt::TextAlignmentRole:
|
case Qt::TextAlignmentRole:
|
||||||
if ((section == TorrentContentModelItem::COL_SIZE)
|
if ((section == TorrentContentModelItem::COL_SIZE)
|
||||||
|
|| (section == TorrentContentModelItem::COL_SIZE_BYTES)
|
||||||
|| (section == TorrentContentModelItem::COL_REMAINING))
|
|| (section == TorrentContentModelItem::COL_REMAINING))
|
||||||
{
|
{
|
||||||
return QVariant {Qt::AlignRight | Qt::AlignVCenter};
|
return QVariant {Qt::AlignRight | Qt::AlignVCenter};
|
||||||
|
@ -649,7 +651,8 @@ void TorrentContentModel::refresh()
|
||||||
{TorrentContentModelItem::COL_NAME, TorrentContentModelItem::COL_NAME},
|
{TorrentContentModelItem::COL_NAME, TorrentContentModelItem::COL_NAME},
|
||||||
{TorrentContentModelItem::COL_PROGRESS, TorrentContentModelItem::COL_PROGRESS},
|
{TorrentContentModelItem::COL_PROGRESS, TorrentContentModelItem::COL_PROGRESS},
|
||||||
{TorrentContentModelItem::COL_PRIO, TorrentContentModelItem::COL_PRIO},
|
{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);
|
notifySubtreeUpdated(index(0, 0), columns);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "torrentcontentmodelitem.h"
|
#include "torrentcontentmodelitem.h"
|
||||||
|
|
||||||
|
#include <QLocale>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include "base/unicodestrings.h"
|
#include "base/unicodestrings.h"
|
||||||
|
@ -139,6 +140,8 @@ QString TorrentContentModelItem::displayData(const int column) const
|
||||||
: Utils::String::fromDouble((avail * 100), 1);
|
: Utils::String::fromDouble((avail * 100), 1);
|
||||||
return (value + u'%');
|
return (value + u'%');
|
||||||
}
|
}
|
||||||
|
case COL_SIZE_BYTES:
|
||||||
|
return QLocale().toString(m_size);
|
||||||
default:
|
default:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
|
@ -166,6 +169,9 @@ QVariant TorrentContentModelItem::underlyingData(const int column) const
|
||||||
return remaining();
|
return remaining();
|
||||||
case COL_AVAILABILITY:
|
case COL_AVAILABILITY:
|
||||||
return availability();
|
return availability();
|
||||||
|
case COL_SIZE_BYTES:
|
||||||
|
return m_size;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
{
|
{
|
||||||
COL_NAME,
|
COL_NAME,
|
||||||
COL_SIZE,
|
COL_SIZE,
|
||||||
|
COL_SIZE_BYTES,
|
||||||
COL_PROGRESS,
|
COL_PROGRESS,
|
||||||
COL_PRIO,
|
COL_PRIO,
|
||||||
COL_REMAINING,
|
COL_REMAINING,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue