mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-21 16:55:46 +03:00
parent
5dd41f506e
commit
c080fc3aa0
1 changed files with 16 additions and 5 deletions
|
@ -48,6 +48,11 @@
|
||||||
|
|
||||||
#define SETTINGS_KEY(name) u"PreviewSelectDialog/" name
|
#define SETTINGS_KEY(name) u"PreviewSelectDialog/" name
|
||||||
|
|
||||||
|
enum Roles
|
||||||
|
{
|
||||||
|
SortRole = Qt::UserRole
|
||||||
|
};
|
||||||
|
|
||||||
PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torrent *torrent)
|
PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torrent *torrent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, m_ui {new Ui::PreviewSelectDialog}
|
, m_ui {new Ui::PreviewSelectDialog}
|
||||||
|
@ -75,7 +80,6 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torr
|
||||||
m_ui->previewList->setAlternatingRowColors(pref->useAlternatingRowColors());
|
m_ui->previewList->setAlternatingRowColors(pref->useAlternatingRowColors());
|
||||||
m_ui->previewList->setUniformRowHeights(true);
|
m_ui->previewList->setUniformRowHeights(true);
|
||||||
m_ui->previewList->setModel(previewListModel);
|
m_ui->previewList->setModel(previewListModel);
|
||||||
m_ui->previewList->hideColumn(FILE_INDEX);
|
|
||||||
|
|
||||||
auto *listDelegate = new PreviewListDelegate(this);
|
auto *listDelegate = new PreviewListDelegate(this);
|
||||||
m_ui->previewList->setItemDelegate(listDelegate);
|
m_ui->previewList->setItemDelegate(listDelegate);
|
||||||
|
@ -89,13 +93,19 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torr
|
||||||
{
|
{
|
||||||
int row = previewListModel->rowCount();
|
int row = previewListModel->rowCount();
|
||||||
previewListModel->insertRow(row);
|
previewListModel->insertRow(row);
|
||||||
previewListModel->setData(previewListModel->index(row, NAME), filePath.filename());
|
previewListModel->setData(previewListModel->index(row, NAME), filePath.filename(), Qt::DisplayRole);
|
||||||
previewListModel->setData(previewListModel->index(row, SIZE), Utils::Misc::friendlyUnit(torrent->fileSize(i)));
|
previewListModel->setData(previewListModel->index(row, NAME), filePath.filename(), SortRole);
|
||||||
previewListModel->setData(previewListModel->index(row, PROGRESS), fp[i]);
|
// Sorting file size by bytes, while displaying by human readable format
|
||||||
previewListModel->setData(previewListModel->index(row, FILE_INDEX), i);
|
previewListModel->setData(previewListModel->index(row, SIZE), Utils::Misc::friendlyUnit(torrent->fileSize(i)), Qt::DisplayRole);
|
||||||
|
previewListModel->setData(previewListModel->index(row, SIZE), torrent->fileSize(i), SortRole);
|
||||||
|
previewListModel->setData(previewListModel->index(row, PROGRESS), fp[i], Qt::DisplayRole);
|
||||||
|
previewListModel->setData(previewListModel->index(row, PROGRESS), fp[i], SortRole);
|
||||||
|
previewListModel->setData(previewListModel->index(row, FILE_INDEX), i, Qt::DisplayRole);
|
||||||
|
previewListModel->setData(previewListModel->index(row, FILE_INDEX), i, SortRole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
previewListModel->setSortRole(SortRole);
|
||||||
previewListModel->sort(NAME);
|
previewListModel->sort(NAME);
|
||||||
m_ui->previewList->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
m_ui->previewList->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
m_ui->previewList->header()->setFirstSectionMovable(true);
|
m_ui->previewList->header()->setFirstSectionMovable(true);
|
||||||
|
@ -106,6 +116,7 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torr
|
||||||
|
|
||||||
// Restore dialog state
|
// Restore dialog state
|
||||||
loadWindowState();
|
loadWindowState();
|
||||||
|
m_ui->previewList->hideColumn(FILE_INDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
PreviewSelectDialog::~PreviewSelectDialog()
|
PreviewSelectDialog::~PreviewSelectDialog()
|
||||||
|
|
Loading…
Reference in a new issue