mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 23:47:23 -06:00
Add ability to display torrent "privateness" in UI
PR #20951. --------- Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com> Co-authored-by: Vladimir Golovnev <glassez@yandex.ru> Co-authored-by: thalieht <thalieht@users.noreply.github.com>
This commit is contained in:
committed by
Vladimir Golovnev (Glassez)
parent
96607ce874
commit
4d490c84e7
@@ -210,6 +210,7 @@ void PropertiesWidget::clear()
|
||||
m_ui->labelSavePathVal->clear();
|
||||
m_ui->labelCreatedOnVal->clear();
|
||||
m_ui->labelTotalPiecesVal->clear();
|
||||
m_ui->labelPrivateVal->clear();
|
||||
m_ui->labelInfohash1Val->clear();
|
||||
m_ui->labelInfohash2Val->clear();
|
||||
m_ui->labelCommentVal->clear();
|
||||
@@ -335,7 +336,14 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::Torrent *const torrent)
|
||||
m_ui->labelCommentVal->setText(Utils::Misc::parseHtmlLinks(m_torrent->comment().toHtmlEscaped()));
|
||||
|
||||
m_ui->labelCreatedByVal->setText(m_torrent->creator());
|
||||
|
||||
m_ui->labelPrivateVal->setText(m_torrent->isPrivate() ? tr("Yes") : tr("No"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->labelPrivateVal->setText(tr("N/A"));
|
||||
}
|
||||
|
||||
// Load dynamic data
|
||||
loadDynamicData();
|
||||
}
|
||||
|
||||
@@ -823,6 +823,38 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelPrivate">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Private:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="5">
|
||||
<widget class="QLabel" name="labelPrivateVal">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelInfohash1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
@@ -838,71 +870,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelInfohash2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Info Hash v2:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="5">
|
||||
<widget class="QLabel" name="labelInfohash2Val">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelSavePath">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save Path:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="labelComment">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Comment:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="5">
|
||||
<widget class="QLabel" name="labelInfohash1Val">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
@@ -918,7 +886,55 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelInfohash2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Info Hash v2:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="5">
|
||||
<widget class="QLabel" name="labelInfohash2Val">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="labelSavePath">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save Path:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="5">
|
||||
<widget class="QLabel" name="labelSavePathVal">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
@@ -937,7 +953,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="5">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="labelComment">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Comment:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="5">
|
||||
<widget class="QLabel" name="labelCommentVal">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
|
||||
@@ -193,6 +193,7 @@ QVariant TransferListModel::headerData(const int section, const Qt::Orientation
|
||||
case TR_INFOHASH_V1: return tr("Info Hash v1", "i.e: torrent info hash v1");
|
||||
case TR_INFOHASH_V2: return tr("Info Hash v2", "i.e: torrent info hash v2");
|
||||
case TR_REANNOUNCE: return tr("Reannounce In", "Indicates the time until next trackers reannounce");
|
||||
case TR_PRIVATE: return tr("Private", "Flags private torrents");
|
||||
default: return {};
|
||||
}
|
||||
}
|
||||
@@ -357,6 +358,15 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons
|
||||
return Utils::Misc::userFriendlyDuration(time);
|
||||
};
|
||||
|
||||
const auto privateString = [hideValues](const bool isPrivate, const bool hasMetadata) -> QString
|
||||
{
|
||||
if (hideValues && !isPrivate)
|
||||
return {};
|
||||
if (hasMetadata)
|
||||
return isPrivate ? tr("Yes") : tr("No");
|
||||
return tr("N/A");
|
||||
};
|
||||
|
||||
switch (column)
|
||||
{
|
||||
case TR_NAME:
|
||||
@@ -431,6 +441,8 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons
|
||||
return hashString(torrent->infoHash().v2());
|
||||
case TR_REANNOUNCE:
|
||||
return reannounceString(torrent->nextAnnounce());
|
||||
case TR_PRIVATE:
|
||||
return privateString(torrent->isPrivate(), torrent->hasMetadata());
|
||||
}
|
||||
|
||||
return {};
|
||||
@@ -512,6 +524,8 @@ QVariant TransferListModel::internalValue(const BitTorrent::Torrent *torrent, co
|
||||
return QVariant::fromValue(torrent->infoHash().v2());
|
||||
case TR_REANNOUNCE:
|
||||
return torrent->nextAnnounce();
|
||||
case TR_PRIVATE:
|
||||
return (torrent->hasMetadata() ? torrent->isPrivate() : QVariant());
|
||||
}
|
||||
|
||||
return {};
|
||||
|
||||
@@ -86,6 +86,7 @@ public:
|
||||
TR_INFOHASH_V1,
|
||||
TR_INFOHASH_V2,
|
||||
TR_REANNOUNCE,
|
||||
TR_PRIVATE,
|
||||
|
||||
NB_COLUMNS
|
||||
};
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "transferlistsortmodel.h"
|
||||
|
||||
#include <concepts>
|
||||
#include <type_traits>
|
||||
|
||||
#include <QDateTime>
|
||||
@@ -46,16 +47,6 @@ namespace
|
||||
return (left < right) ? -1 : 1;
|
||||
}
|
||||
|
||||
int customCompare(const QDateTime &left, const QDateTime &right)
|
||||
{
|
||||
const bool isLeftValid = left.isValid();
|
||||
const bool isRightValid = right.isValid();
|
||||
|
||||
if (isLeftValid == isRightValid)
|
||||
return threeWayCompare(left, right);
|
||||
return isLeftValid ? -1 : 1;
|
||||
}
|
||||
|
||||
int customCompare(const TagSet &left, const TagSet &right, const Utils::Compare::NaturalCompare<Qt::CaseInsensitive> &compare)
|
||||
{
|
||||
for (auto leftIter = left.cbegin(), rightIter = right.cbegin();
|
||||
@@ -70,12 +61,27 @@ namespace
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int customCompare(const T left, const T right)
|
||||
{
|
||||
static_assert(std::is_arithmetic_v<T>);
|
||||
concept Validateable = requires (T t) { {t.isValid()} -> std::same_as<bool>; };
|
||||
|
||||
const bool isLeftValid = (left >= 0);
|
||||
const bool isRightValid = (right >= 0);
|
||||
template <Validateable T>
|
||||
bool isValid(const T &value)
|
||||
{
|
||||
return value.isValid();
|
||||
}
|
||||
|
||||
// consider negative values as invalid
|
||||
template <typename T>
|
||||
requires std::is_arithmetic_v<T>
|
||||
bool isValid(const T value)
|
||||
{
|
||||
return (value >= 0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int customCompare(const T &left, const T &right)
|
||||
{
|
||||
const bool isLeftValid = isValid(left);
|
||||
const bool isRightValid = isValid(right);
|
||||
|
||||
if (isLeftValid && isRightValid)
|
||||
return threeWayCompare(left, right);
|
||||
@@ -209,6 +215,7 @@ int TransferListSortModel::compare(const QModelIndex &left, const QModelIndex &r
|
||||
|
||||
case TransferListModel::TR_DLLIMIT:
|
||||
case TransferListModel::TR_DLSPEED:
|
||||
case TransferListModel::TR_PRIVATE:
|
||||
case TransferListModel::TR_QUEUE_POSITION:
|
||||
case TransferListModel::TR_UPLIMIT:
|
||||
case TransferListModel::TR_UPSPEED:
|
||||
|
||||
@@ -184,6 +184,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow)
|
||||
setColumnHidden(TransferListModel::TR_LAST_ACTIVITY, true);
|
||||
setColumnHidden(TransferListModel::TR_TOTAL_SIZE, true);
|
||||
setColumnHidden(TransferListModel::TR_REANNOUNCE, true);
|
||||
setColumnHidden(TransferListModel::TR_PRIVATE, true);
|
||||
}
|
||||
|
||||
//Ensure that at least one column is visible at all times
|
||||
|
||||
Reference in New Issue
Block a user