Browse Source

Add availability column to torrent properties window

adaptive-webui-19844
Eugene Shalygin 9 years ago
parent
commit
5c10a24923
  1. 1
      src/base/unicodestrings.h
  2. 1
      src/gui/addnewtorrentdialog.cpp
  3. 1
      src/gui/properties/propertieswidget.cpp
  4. 14
      src/gui/properties/proplistdelegate.cpp
  5. 4
      src/gui/properties/proplistdelegate.h
  6. 2
      src/gui/torrentcontentmodel.cpp

1
src/base/unicodestrings.h

@ -39,6 +39,7 @@ const char C_NON_BREAKING_SPACE[] = " "; @@ -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)";

1
src/gui/addnewtorrentdialog.cpp

@ -737,6 +737,7 @@ void AddNewTorrentDialog::setupTreeview() @@ -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);

1
src/gui/properties/propertieswidget.cpp

@ -493,6 +493,7 @@ void PropertiesWidget::loadDynamicData() @@ -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.

14
src/gui/properties/proplistdelegate.cpp

@ -42,6 +42,7 @@ @@ -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 @@ -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;

4
src/gui/properties/proplistdelegate.h

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

2
src/gui/torrentcontentmodel.cpp

@ -56,7 +56,7 @@ namespace @@ -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") })))
{
}

Loading…
Cancel
Save