Browse Source

Clean up TransferListModel class

adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
c61116882b
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 12
      src/gui/transferlistmodel.cpp

12
src/gui/transferlistmodel.cpp

@ -160,11 +160,11 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation, @@ -160,11 +160,11 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation,
return {};
}
QVariant TransferListModel::data(const QModelIndex &index, int role) const
QVariant TransferListModel::data(const QModelIndex &index, const int role) const
{
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 ((role == Qt::DecorationRole) && (index.column() == TR_NAME))
@ -258,7 +258,7 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value, @@ -258,7 +258,7 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value,
BitTorrent::TorrentHandle *const torrent = m_torrents.value(index.row());
if (!torrent) return false;
// Category, seed date and Name columns can be edited
// Category and Name columns can be edited
switch (index.column()) {
case TR_NAME:
torrent->setName(value.toString());
@ -275,7 +275,7 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value, @@ -275,7 +275,7 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value,
void TransferListModel::addTorrent(BitTorrent::TorrentHandle *const torrent)
{
if (m_torrents.indexOf(torrent) == -1) {
if (!m_torrents.contains(torrent)) {
const int row = m_torrents.size();
beginInsertRows(QModelIndex(), row, row);
m_torrents << torrent;
@ -322,7 +322,7 @@ void TransferListModel::handleTorrentsUpdated() @@ -322,7 +322,7 @@ void TransferListModel::handleTorrentsUpdated()
// Static functions
QIcon getIconByState(BitTorrent::TorrentState state)
QIcon getIconByState(const BitTorrent::TorrentState state)
{
switch (state) {
case BitTorrent::TorrentState::Downloading:
@ -359,7 +359,7 @@ QIcon getIconByState(BitTorrent::TorrentState state) @@ -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
bool dark = isDarkTheme();

Loading…
Cancel
Save