qBittorrent
transferlistmodel.cpp File Reference
#include "transferlistmodel.h"
#include <QApplication>
#include <QDateTime>
#include <QDebug>
#include <QIcon>
#include <QPalette>
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrent.h"
#include "base/global.h"
#include "base/preferences.h"
#include "base/unicodestrings.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "base/utils/string.h"
#include "uithememanager.h"
Include dependency graph for transferlistmodel.cpp:

Go to the source code of this file.

Namespaces

 anonymous_namespace{transferlistmodel.cpp}
 

Functions

static QIcon getIconByState (BitTorrent::TorrentState state)
 
static QColor getDefaultColorByState (BitTorrent::TorrentState state)
 
static QIcon getPausedIcon ()
 
static QIcon getQueuedIcon ()
 
static QIcon getDownloadingIcon ()
 
static QIcon getStalledDownloadingIcon ()
 
static QIcon getUploadingIcon ()
 
static QIcon getStalledUploadingIcon ()
 
static QIcon getCompletedIcon ()
 
static QIcon getCheckingIcon ()
 
static QIcon getErrorIcon ()
 
static bool isDarkTheme ()
 
QHash< BitTorrent::TorrentState, QColor > anonymous_namespace{transferlistmodel.cpp}::torrentStateColorsFromUITheme ()
 

Function Documentation

◆ getCheckingIcon()

QIcon getCheckingIcon ( )
static

Definition at line 797 of file transferlistmodel.cpp.

798 {
799  static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("checking"));
800  return cached;
801 }
static UIThemeManager * instance()
QIcon getIcon(const QString &iconId, const QString &fallback={}) const

References UIThemeManager::getIcon(), and UIThemeManager::instance().

Referenced by getIconByState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCompletedIcon()

QIcon getCompletedIcon ( )
static

Definition at line 791 of file transferlistmodel.cpp.

792 {
793  static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("completed"));
794  return cached;
795 }

References UIThemeManager::getIcon(), and UIThemeManager::instance().

Referenced by getIconByState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDefaultColorByState()

QColor getDefaultColorByState ( BitTorrent::TorrentState  state)
static

Definition at line 700 of file transferlistmodel.cpp.

701 {
702  // Color names taken from http://cloford.com/resources/colours/500col.htm
703  bool dark = isDarkTheme();
704 
705  switch (state)
706  {
711  if (!dark)
712  return {34, 139, 34}; // Forest Green
713  else
714  return {50, 205, 50}; // Lime Green
717  if (!dark)
718  return {0, 0, 0}; // Black
719  else
720  return {204, 204, 204}; // Gray 80
723  if (!dark)
724  return {65, 105, 225}; // Royal Blue
725  else
726  return {99, 184, 255}; // Steel Blue 1
728  return {250, 128, 114}; // Salmon
730  if (!dark)
731  return {0, 0, 139}; // Dark Blue
732  else
733  return {79, 148, 205}; // Steel Blue 3
736  return {255, 0, 0}; // red
743  if (!dark)
744  return {0, 128, 128}; // Teal
745  else
746  return {0, 205, 205}; // Cyan 3
748  return {255, 0, 0}; // red
749  default:
750  Q_ASSERT(false);
751  return {255, 0, 0}; // red
752  }
753 }
static bool isDarkTheme()

References BitTorrent::CheckingDownloading, BitTorrent::CheckingResumeData, BitTorrent::CheckingUploading, BitTorrent::Downloading, BitTorrent::DownloadingMetadata, BitTorrent::Error, BitTorrent::ForcedDownloading, BitTorrent::ForcedDownloadingMetadata, BitTorrent::ForcedUploading, isDarkTheme(), BitTorrent::MissingFiles, BitTorrent::Moving, BitTorrent::PausedDownloading, BitTorrent::PausedUploading, BitTorrent::QueuedDownloading, BitTorrent::QueuedUploading, BitTorrent::StalledDownloading, BitTorrent::StalledUploading, BitTorrent::Unknown, and BitTorrent::Uploading.

Referenced by TransferListModel::data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDownloadingIcon()

QIcon getDownloadingIcon ( )
static

Definition at line 767 of file transferlistmodel.cpp.

768 {
769  static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("downloading"));
770  return cached;
771 }

References UIThemeManager::getIcon(), and UIThemeManager::instance().

Referenced by getIconByState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getErrorIcon()

QIcon getErrorIcon ( )
static

Definition at line 803 of file transferlistmodel.cpp.

804 {
805  static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("error"));
806  return cached;
807 }

References UIThemeManager::getIcon(), and UIThemeManager::instance().

Referenced by getIconByState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getIconByState()

QIcon getIconByState ( BitTorrent::TorrentState  state)
static

Definition at line 662 of file transferlistmodel.cpp.

663 {
664  switch (state)
665  {
670  return getDownloadingIcon();
672  return getStalledDownloadingIcon();
674  return getStalledUploadingIcon();
677  return getUploadingIcon();
679  return getPausedIcon();
681  return getCompletedIcon();
684  return getQueuedIcon();
689  return getCheckingIcon();
693  return getErrorIcon();
694  default:
695  Q_ASSERT(false);
696  return getErrorIcon();
697  }
698 }
static QIcon getStalledDownloadingIcon()
static QIcon getCheckingIcon()
static QIcon getCompletedIcon()
static QIcon getDownloadingIcon()
static QIcon getStalledUploadingIcon()
static QIcon getPausedIcon()
static QIcon getErrorIcon()
static QIcon getUploadingIcon()
static QIcon getQueuedIcon()

References BitTorrent::CheckingDownloading, BitTorrent::CheckingResumeData, BitTorrent::CheckingUploading, BitTorrent::Downloading, BitTorrent::DownloadingMetadata, BitTorrent::Error, BitTorrent::ForcedDownloading, BitTorrent::ForcedDownloadingMetadata, BitTorrent::ForcedUploading, getCheckingIcon(), getCompletedIcon(), getDownloadingIcon(), getErrorIcon(), getPausedIcon(), getQueuedIcon(), getStalledDownloadingIcon(), getStalledUploadingIcon(), getUploadingIcon(), BitTorrent::MissingFiles, BitTorrent::Moving, BitTorrent::PausedDownloading, BitTorrent::PausedUploading, BitTorrent::QueuedDownloading, BitTorrent::QueuedUploading, BitTorrent::StalledDownloading, BitTorrent::StalledUploading, BitTorrent::Unknown, and BitTorrent::Uploading.

Referenced by TransferListModel::data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPausedIcon()

QIcon getPausedIcon ( )
static

Definition at line 755 of file transferlistmodel.cpp.

756 {
757  static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("paused"));
758  return cached;
759 }

References UIThemeManager::getIcon(), and UIThemeManager::instance().

Referenced by getIconByState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getQueuedIcon()

QIcon getQueuedIcon ( )
static

Definition at line 761 of file transferlistmodel.cpp.

762 {
763  static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("queued"));
764  return cached;
765 }

References UIThemeManager::getIcon(), and UIThemeManager::instance().

Referenced by getIconByState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStalledDownloadingIcon()

QIcon getStalledDownloadingIcon ( )
static

Definition at line 773 of file transferlistmodel.cpp.

774 {
775  static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("stalledDL"));
776  return cached;
777 }

References UIThemeManager::getIcon(), and UIThemeManager::instance().

Referenced by getIconByState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStalledUploadingIcon()

QIcon getStalledUploadingIcon ( )
static

Definition at line 785 of file transferlistmodel.cpp.

786 {
787  static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("stalledUP"));
788  return cached;
789 }

References UIThemeManager::getIcon(), and UIThemeManager::instance().

Referenced by getIconByState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getUploadingIcon()

QIcon getUploadingIcon ( )
static

Definition at line 779 of file transferlistmodel.cpp.

780 {
781  static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("uploading"));
782  return cached;
783 }

References UIThemeManager::getIcon(), and UIThemeManager::instance().

Referenced by getIconByState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isDarkTheme()

bool isDarkTheme ( )
static

Definition at line 809 of file transferlistmodel.cpp.

810 {
811  const QPalette pal = QApplication::palette();
812  // QPalette::Base is used for the background of the Treeview
813  const QColor &color = pal.color(QPalette::Active, QPalette::Base);
814  return (color.lightness() < 127);
815 }

Referenced by getDefaultColorByState().

Here is the caller graph for this function: