1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-03-13 05:41:17 +00:00

Add availability column to torrent properties window

This commit is contained in:
Eugene Shalygin 2016-03-22 19:41:43 +01:00
parent bc18bf1ab4
commit 5c10a24923
6 changed files with 21 additions and 2 deletions

View File

@ -39,6 +39,7 @@ const char C_NON_BREAKING_SPACE[] = " ";
const char C_UP[] = "";
const char C_DOWN[] = "";
const char C_COPYRIGHT[] = "©";
const char C_THIN_SPACE[] = "";
const char C_UTP[] = "μTP";
const char C_LOCALE_ENGLISH[] = "English";
const char C_LOCALE_ENGLISH_AUSTRALIA[] = "English(Australia)";

View File

@ -737,6 +737,7 @@ void AddNewTorrentDialog::setupTreeview()
// Hide useless columns after loading the header state
ui->contentTreeView->hideColumn(PROGRESS);
ui->contentTreeView->hideColumn(REMAINING);
ui->contentTreeView->hideColumn(AVAILABILITY);
// Expand root folder
ui->contentTreeView->setExpanded(m_contentModel->index(0, 0), true);

View File

@ -493,6 +493,7 @@ void PropertiesWidget::loadDynamicData()
qDebug("Updating priorities in files tab");
m_ui->filesList->setUpdatesEnabled(false);
PropListModel->model()->updateFilesProgress(m_torrent->filesProgress());
PropListModel->model()->updateFilesAvailability(m_torrent->availableFileFractions());
// XXX: We don't update file priorities regularly for performance
// reasons. This means that priorities will not be updated if
// set from the Web UI.

View File

@ -42,6 +42,7 @@
#include <QProxyStyle>
#endif
#include "base/unicodestrings.h"
#include "base/utils/misc.h"
#include "base/utils/string.h"
#include "propertieswidget.h"
@ -131,6 +132,19 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
QItemDelegate::drawDisplay(painter, opt, option.rect, text);
}
break;
case AVAILABILITY: {
const qreal availability = index.data().toDouble();
if (availability < 0) {
QItemDelegate::drawDisplay(painter, opt, option.rect, tr("N/A"));
}
else {
const QString value = (availability >= 1.0)
? QLatin1String("100")
: Utils::String::fromDouble(availability * 100., 1);
QItemDelegate::drawDisplay(painter, opt, option.rect, value + C_THIN_SPACE + QLatin1Char('%'));
}
}
break;
default:
QItemDelegate::paint(painter, option, index);
break;

View File

@ -46,7 +46,8 @@ enum PropColumn
PCSIZE,
PROGRESS,
PRIORITY,
REMAINING
REMAINING,
AVAILABILITY
};
class PropListDelegate: public QItemDelegate
@ -72,3 +73,4 @@ private:
};
#endif

View File

@ -56,7 +56,7 @@ namespace
TorrentContentModel::TorrentContentModel(QObject *parent)
: QAbstractItemModel(parent)
, m_rootItem(new TorrentContentModelFolder(QList<QVariant>({ tr("Name"), tr("Size"), tr("Progress"), tr("Download Priority"), tr("Remaining") })))
, m_rootItem(new TorrentContentModelFolder(QList<QVariant>({ tr("Name"), tr("Size"), tr("Progress"), tr("Download Priority"), tr("Remaining"), tr("Availability") })))
{
}