mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Clean up TransferListModel class
This commit is contained in:
parent
dcf632b39c
commit
c61116882b
@ -160,11 +160,11 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation,
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant TransferListModel::data(const QModelIndex &index, int role) const
|
QVariant TransferListModel::data(const QModelIndex &index, const int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid()) return {};
|
if (!index.isValid()) return {};
|
||||||
|
|
||||||
BitTorrent::TorrentHandle *const torrent = m_torrents.value(index.row());
|
const BitTorrent::TorrentHandle *torrent = m_torrents.value(index.row());
|
||||||
if (!torrent) return {};
|
if (!torrent) return {};
|
||||||
|
|
||||||
if ((role == Qt::DecorationRole) && (index.column() == TR_NAME))
|
if ((role == Qt::DecorationRole) && (index.column() == TR_NAME))
|
||||||
@ -258,7 +258,7 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value,
|
|||||||
BitTorrent::TorrentHandle *const torrent = m_torrents.value(index.row());
|
BitTorrent::TorrentHandle *const torrent = m_torrents.value(index.row());
|
||||||
if (!torrent) return false;
|
if (!torrent) return false;
|
||||||
|
|
||||||
// Category, seed date and Name columns can be edited
|
// Category and Name columns can be edited
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case TR_NAME:
|
case TR_NAME:
|
||||||
torrent->setName(value.toString());
|
torrent->setName(value.toString());
|
||||||
@ -275,7 +275,7 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value,
|
|||||||
|
|
||||||
void TransferListModel::addTorrent(BitTorrent::TorrentHandle *const torrent)
|
void TransferListModel::addTorrent(BitTorrent::TorrentHandle *const torrent)
|
||||||
{
|
{
|
||||||
if (m_torrents.indexOf(torrent) == -1) {
|
if (!m_torrents.contains(torrent)) {
|
||||||
const int row = m_torrents.size();
|
const int row = m_torrents.size();
|
||||||
beginInsertRows(QModelIndex(), row, row);
|
beginInsertRows(QModelIndex(), row, row);
|
||||||
m_torrents << torrent;
|
m_torrents << torrent;
|
||||||
@ -322,7 +322,7 @@ void TransferListModel::handleTorrentsUpdated()
|
|||||||
|
|
||||||
// Static functions
|
// Static functions
|
||||||
|
|
||||||
QIcon getIconByState(BitTorrent::TorrentState state)
|
QIcon getIconByState(const BitTorrent::TorrentState state)
|
||||||
{
|
{
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case BitTorrent::TorrentState::Downloading:
|
case BitTorrent::TorrentState::Downloading:
|
||||||
@ -359,7 +359,7 @@ QIcon getIconByState(BitTorrent::TorrentState state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor getColorByState(BitTorrent::TorrentState state)
|
QColor getColorByState(const BitTorrent::TorrentState state)
|
||||||
{
|
{
|
||||||
// Color names taken from http://cloford.com/resources/colours/500col.htm
|
// Color names taken from http://cloford.com/resources/colours/500col.htm
|
||||||
bool dark = isDarkTheme();
|
bool dark = isDarkTheme();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user