mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 08:16:16 -07:00
Add availability column to torrent properties window
This commit is contained in:
parent
bc18bf1ab4
commit
5c10a24923
6 changed files with 21 additions and 2 deletions
|
@ -39,6 +39,7 @@ const char C_NON_BREAKING_SPACE[] = " ";
|
||||||
const char C_UP[] = "▲";
|
const char C_UP[] = "▲";
|
||||||
const char C_DOWN[] = "▼";
|
const char C_DOWN[] = "▼";
|
||||||
const char C_COPYRIGHT[] = "©";
|
const char C_COPYRIGHT[] = "©";
|
||||||
|
const char C_THIN_SPACE[] = " ";
|
||||||
const char C_UTP[] = "μTP";
|
const char C_UTP[] = "μTP";
|
||||||
const char C_LOCALE_ENGLISH[] = "English";
|
const char C_LOCALE_ENGLISH[] = "English";
|
||||||
const char C_LOCALE_ENGLISH_AUSTRALIA[] = "English(Australia)";
|
const char C_LOCALE_ENGLISH_AUSTRALIA[] = "English(Australia)";
|
||||||
|
|
|
@ -737,6 +737,7 @@ void AddNewTorrentDialog::setupTreeview()
|
||||||
// Hide useless columns after loading the header state
|
// Hide useless columns after loading the header state
|
||||||
ui->contentTreeView->hideColumn(PROGRESS);
|
ui->contentTreeView->hideColumn(PROGRESS);
|
||||||
ui->contentTreeView->hideColumn(REMAINING);
|
ui->contentTreeView->hideColumn(REMAINING);
|
||||||
|
ui->contentTreeView->hideColumn(AVAILABILITY);
|
||||||
|
|
||||||
// Expand root folder
|
// Expand root folder
|
||||||
ui->contentTreeView->setExpanded(m_contentModel->index(0, 0), true);
|
ui->contentTreeView->setExpanded(m_contentModel->index(0, 0), true);
|
||||||
|
|
|
@ -493,6 +493,7 @@ void PropertiesWidget::loadDynamicData()
|
||||||
qDebug("Updating priorities in files tab");
|
qDebug("Updating priorities in files tab");
|
||||||
m_ui->filesList->setUpdatesEnabled(false);
|
m_ui->filesList->setUpdatesEnabled(false);
|
||||||
PropListModel->model()->updateFilesProgress(m_torrent->filesProgress());
|
PropListModel->model()->updateFilesProgress(m_torrent->filesProgress());
|
||||||
|
PropListModel->model()->updateFilesAvailability(m_torrent->availableFileFractions());
|
||||||
// XXX: We don't update file priorities regularly for performance
|
// XXX: We don't update file priorities regularly for performance
|
||||||
// reasons. This means that priorities will not be updated if
|
// reasons. This means that priorities will not be updated if
|
||||||
// set from the Web UI.
|
// set from the Web UI.
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <QProxyStyle>
|
#include <QProxyStyle>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "base/unicodestrings.h"
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "base/utils/string.h"
|
#include "base/utils/string.h"
|
||||||
#include "propertieswidget.h"
|
#include "propertieswidget.h"
|
||||||
|
@ -131,6 +132,19 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, text);
|
QItemDelegate::drawDisplay(painter, opt, option.rect, text);
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
QItemDelegate::paint(painter, option, index);
|
QItemDelegate::paint(painter, option, index);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -46,7 +46,8 @@ enum PropColumn
|
||||||
PCSIZE,
|
PCSIZE,
|
||||||
PROGRESS,
|
PROGRESS,
|
||||||
PRIORITY,
|
PRIORITY,
|
||||||
REMAINING
|
REMAINING,
|
||||||
|
AVAILABILITY
|
||||||
};
|
};
|
||||||
|
|
||||||
class PropListDelegate: public QItemDelegate
|
class PropListDelegate: public QItemDelegate
|
||||||
|
@ -72,3 +73,4 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace
|
||||||
|
|
||||||
TorrentContentModel::TorrentContentModel(QObject *parent)
|
TorrentContentModel::TorrentContentModel(QObject *parent)
|
||||||
: QAbstractItemModel(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") })))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue