Browse Source

Add infohash and download path columns

PR #17799.
adaptive-webui-19844
tristanleboss 2 years ago committed by GitHub
parent
commit
a71d7e6557
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/base/bittorrent/infohash.h
  2. 19
      src/gui/transferlistmodel.cpp
  3. 3
      src/gui/transferlistmodel.h
  4. 7
      src/gui/transferlistsortmodel.cpp
  5. 3
      src/gui/transferlistwidget.cpp

3
src/base/bittorrent/infohash.h

@ -40,6 +40,9 @@
using SHA1Hash = Digest32<160>; using SHA1Hash = Digest32<160>;
using SHA256Hash = Digest32<256>; using SHA256Hash = Digest32<256>;
Q_DECLARE_METATYPE(SHA1Hash)
Q_DECLARE_METATYPE(SHA256Hash)
namespace BitTorrent namespace BitTorrent
{ {
class InfoHash; class InfoHash;

19
src/gui/transferlistmodel.cpp

@ -34,6 +34,7 @@
#include <QDebug> #include <QDebug>
#include <QPalette> #include <QPalette>
#include "base/bittorrent/infohash.h"
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "base/bittorrent/torrent.h" #include "base/bittorrent/torrent.h"
#include "base/global.h" #include "base/global.h"
@ -224,12 +225,15 @@ QVariant TransferListModel::headerData(const int section, const Qt::Orientation
case TR_AMOUNT_LEFT: return tr("Remaining", "Amount of data left to download (e.g. in MB)"); case TR_AMOUNT_LEFT: return tr("Remaining", "Amount of data left to download (e.g. in MB)");
case TR_TIME_ELAPSED: return tr("Time Active", "Time (duration) the torrent is active (not paused)"); case TR_TIME_ELAPSED: return tr("Time Active", "Time (duration) the torrent is active (not paused)");
case TR_SAVE_PATH: return tr("Save path", "Torrent save path"); case TR_SAVE_PATH: return tr("Save path", "Torrent save path");
case TR_DOWNLOAD_PATH: return tr("Incomplete Save Path", "Torrent incomplete save path");
case TR_COMPLETED: return tr("Completed", "Amount of data completed (e.g. in MB)"); case TR_COMPLETED: return tr("Completed", "Amount of data completed (e.g. in MB)");
case TR_RATIO_LIMIT: return tr("Ratio Limit", "Upload share ratio limit"); case TR_RATIO_LIMIT: return tr("Ratio Limit", "Upload share ratio limit");
case TR_SEEN_COMPLETE_DATE: return tr("Last Seen Complete", "Indicates the time when the torrent was last seen complete/whole"); case TR_SEEN_COMPLETE_DATE: return tr("Last Seen Complete", "Indicates the time when the torrent was last seen complete/whole");
case TR_LAST_ACTIVITY: return tr("Last Activity", "Time passed since a chunk was downloaded/uploaded"); case TR_LAST_ACTIVITY: return tr("Last Activity", "Time passed since a chunk was downloaded/uploaded");
case TR_TOTAL_SIZE: return tr("Total Size", "i.e. Size including unwanted data"); case TR_TOTAL_SIZE: return tr("Total Size", "i.e. Size including unwanted data");
case TR_AVAILABILITY: return tr("Availability", "The number of distributed copies of the torrent"); case TR_AVAILABILITY: return tr("Availability", "The number of distributed copies of the torrent");
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");
default: return {}; default: return {};
} }
} }
@ -424,6 +428,8 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons
return timeElapsedString(torrent->activeTime(), torrent->finishedTime()); return timeElapsedString(torrent->activeTime(), torrent->finishedTime());
case TR_SAVE_PATH: case TR_SAVE_PATH:
return torrent->savePath().toString(); return torrent->savePath().toString();
case TR_DOWNLOAD_PATH:
return torrent->downloadPath().toString();
case TR_COMPLETED: case TR_COMPLETED:
return unitString(torrent->completedSize()); return unitString(torrent->completedSize());
case TR_SEEN_COMPLETE_DATE: case TR_SEEN_COMPLETE_DATE:
@ -434,6 +440,10 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons
return availabilityString(torrent->distributedCopies()); return availabilityString(torrent->distributedCopies());
case TR_TOTAL_SIZE: case TR_TOTAL_SIZE:
return unitString(torrent->totalSize()); return unitString(torrent->totalSize());
case TR_INFOHASH_V1:
return torrent->infoHash().v1().toString();
case TR_INFOHASH_V2:
return torrent->infoHash().v2().toString();
} }
return {}; return {};
@ -491,6 +501,8 @@ QVariant TransferListModel::internalValue(const BitTorrent::Torrent *torrent, co
return torrent->remainingSize(); return torrent->remainingSize();
case TR_TIME_ELAPSED: case TR_TIME_ELAPSED:
return !alt ? torrent->activeTime() : torrent->finishedTime(); return !alt ? torrent->activeTime() : torrent->finishedTime();
case TR_DOWNLOAD_PATH:
return torrent->downloadPath().data();
case TR_SAVE_PATH: case TR_SAVE_PATH:
return torrent->savePath().toString(); return torrent->savePath().toString();
case TR_COMPLETED: case TR_COMPLETED:
@ -505,6 +517,10 @@ QVariant TransferListModel::internalValue(const BitTorrent::Torrent *torrent, co
return torrent->distributedCopies(); return torrent->distributedCopies();
case TR_TOTAL_SIZE: case TR_TOTAL_SIZE:
return torrent->totalSize(); return torrent->totalSize();
case TR_INFOHASH_V1:
return QVariant::fromValue(torrent->infoHash().v1());
case TR_INFOHASH_V2:
return QVariant::fromValue(torrent->infoHash().v2());
} }
return {}; return {};
@ -540,6 +556,9 @@ QVariant TransferListModel::data(const QModelIndex &index, const int role) const
case TR_TAGS: case TR_TAGS:
case TR_TRACKER: case TR_TRACKER:
case TR_SAVE_PATH: case TR_SAVE_PATH:
case TR_DOWNLOAD_PATH:
case TR_INFOHASH_V1:
case TR_INFOHASH_V2:
return displayValue(torrent, index.column()); return displayValue(torrent, index.column());
} }
break; break;

3
src/gui/transferlistmodel.h

@ -81,6 +81,9 @@ public:
TR_SEEN_COMPLETE_DATE, TR_SEEN_COMPLETE_DATE,
TR_LAST_ACTIVITY, TR_LAST_ACTIVITY,
TR_AVAILABILITY, TR_AVAILABILITY,
TR_DOWNLOAD_PATH,
TR_INFOHASH_V1,
TR_INFOHASH_V2,
NB_COLUMNS NB_COLUMNS
}; };

7
src/gui/transferlistsortmodel.cpp

@ -163,11 +163,18 @@ int TransferListSortModel::compare(const QModelIndex &left, const QModelIndex &r
switch (compareColumn) switch (compareColumn)
{ {
case TransferListModel::TR_CATEGORY: case TransferListModel::TR_CATEGORY:
case TransferListModel::TR_DOWNLOAD_PATH:
case TransferListModel::TR_NAME: case TransferListModel::TR_NAME:
case TransferListModel::TR_SAVE_PATH: case TransferListModel::TR_SAVE_PATH:
case TransferListModel::TR_TRACKER: case TransferListModel::TR_TRACKER:
return m_naturalCompare(leftValue.toString(), rightValue.toString()); return m_naturalCompare(leftValue.toString(), rightValue.toString());
case TransferListModel::TR_INFOHASH_V1:
return threeWayCompare(leftValue.value<SHA1Hash>(), rightValue.value<SHA1Hash>());
case TransferListModel::TR_INFOHASH_V2:
return threeWayCompare(leftValue.value<SHA256Hash>(), rightValue.value<SHA256Hash>());
case TransferListModel::TR_TAGS: case TransferListModel::TR_TAGS:
return customCompare(leftValue.value<TagSet>(), rightValue.value<TagSet>(), m_naturalCompare); return customCompare(leftValue.value<TagSet>(), rightValue.value<TagSet>(), m_naturalCompare);

3
src/gui/transferlistwidget.cpp

@ -171,6 +171,9 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow)
setColumnHidden(TransferListModel::TR_AMOUNT_LEFT, true); setColumnHidden(TransferListModel::TR_AMOUNT_LEFT, true);
setColumnHidden(TransferListModel::TR_TIME_ELAPSED, true); setColumnHidden(TransferListModel::TR_TIME_ELAPSED, true);
setColumnHidden(TransferListModel::TR_SAVE_PATH, true); setColumnHidden(TransferListModel::TR_SAVE_PATH, true);
setColumnHidden(TransferListModel::TR_DOWNLOAD_PATH, true);
setColumnHidden(TransferListModel::TR_INFOHASH_V1, true);
setColumnHidden(TransferListModel::TR_INFOHASH_V2, true);
setColumnHidden(TransferListModel::TR_COMPLETED, true); setColumnHidden(TransferListModel::TR_COMPLETED, true);
setColumnHidden(TransferListModel::TR_RATIO_LIMIT, true); setColumnHidden(TransferListModel::TR_RATIO_LIMIT, true);
setColumnHidden(TransferListModel::TR_SEEN_COMPLETE_DATE, true); setColumnHidden(TransferListModel::TR_SEEN_COMPLETE_DATE, true);

Loading…
Cancel
Save