mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-24 10:16:00 +03:00
Clean up usage of static
keyword
They are either misused or redundant, so remove it.
This commit is contained in:
parent
c2c17fd053
commit
73faf67084
14 changed files with 106 additions and 138 deletions
|
@ -635,7 +635,7 @@ Path Session::downloadPath() const
|
||||||
|
|
||||||
bool Session::isValidCategoryName(const QString &name)
|
bool Session::isValidCategoryName(const QString &name)
|
||||||
{
|
{
|
||||||
static const QRegularExpression re(uR"(^([^\\\/]|[^\\\/]([^\\\/]|\/(?=[^\/]))*[^\\\/])$)"_qs);
|
const QRegularExpression re(uR"(^([^\\\/]|[^\\\/]([^\\\/]|\/(?=[^\/]))*[^\\\/])$)"_qs);
|
||||||
if (!name.isEmpty() && (name.indexOf(re) != 0))
|
if (!name.isEmpty() && (name.indexOf(re) != 0))
|
||||||
{
|
{
|
||||||
qDebug() << "Incorrect category name:" << name;
|
qDebug() << "Incorrect category name:" << name;
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include "base/bittorrent/sessionstatus.h"
|
#include "base/bittorrent/sessionstatus.h"
|
||||||
#include "base/profile.h"
|
#include "base/profile.h"
|
||||||
|
|
||||||
static const qint64 SAVE_INTERVAL = 15 * 60 * 1000;
|
const qint64 SAVE_INTERVAL = 15 * 60 * 1000;
|
||||||
|
|
||||||
using namespace BitTorrent;
|
using namespace BitTorrent;
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ QString Item::name() const
|
||||||
|
|
||||||
bool Item::isValidPath(const QString &path)
|
bool Item::isValidPath(const QString &path)
|
||||||
{
|
{
|
||||||
static const QRegularExpression re(
|
const QRegularExpression re(
|
||||||
uR"(\A[^\%1]+(\%1[^\%1]+)*\z)"_qs.arg(Item::PathSeparator)
|
uR"(\A[^\%1]+(\%1[^\%1]+)*\z)"_qs.arg(Item::PathSeparator)
|
||||||
, QRegularExpression::DontCaptureOption);
|
, QRegularExpression::DontCaptureOption);
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,14 @@
|
||||||
#include "settingvalue.h"
|
#include "settingvalue.h"
|
||||||
#include "utils/fs.h"
|
#include "utils/fs.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
SettingValue<TorrentFileGuard::AutoDeleteMode> autoDeleteModeSetting()
|
||||||
|
{
|
||||||
|
return SettingValue<TorrentFileGuard::AutoDeleteMode> {u"Core/AutoDeleteAddedTorrentFile"_qs};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FileGuard::FileGuard(const Path &path)
|
FileGuard::FileGuard(const Path &path)
|
||||||
: m_path {path}
|
: m_path {path}
|
||||||
, m_remove {true}
|
, m_remove {true}
|
||||||
|
@ -76,13 +84,7 @@ TorrentFileGuard::AutoDeleteMode TorrentFileGuard::autoDeleteMode()
|
||||||
return autoDeleteModeSetting().get(AutoDeleteMode::Never);
|
return autoDeleteModeSetting().get(AutoDeleteMode::Never);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentFileGuard::setAutoDeleteMode(TorrentFileGuard::AutoDeleteMode mode)
|
void TorrentFileGuard::setAutoDeleteMode(const TorrentFileGuard::AutoDeleteMode mode)
|
||||||
{
|
{
|
||||||
autoDeleteModeSetting() = mode;
|
autoDeleteModeSetting() = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingValue<TorrentFileGuard::AutoDeleteMode> &TorrentFileGuard::autoDeleteModeSetting()
|
|
||||||
{
|
|
||||||
static SettingValue<AutoDeleteMode> setting {u"Core/AutoDeleteAddedTorrentFile"_qs};
|
|
||||||
return setting;
|
|
||||||
}
|
|
||||||
|
|
|
@ -33,8 +33,6 @@
|
||||||
|
|
||||||
#include "base/path.h"
|
#include "base/path.h"
|
||||||
|
|
||||||
template <typename T> class SettingValue;
|
|
||||||
|
|
||||||
/// Utility class to defer file deletion
|
/// Utility class to defer file deletion
|
||||||
class FileGuard
|
class FileGuard
|
||||||
{
|
{
|
||||||
|
@ -47,7 +45,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Path m_path;
|
Path m_path;
|
||||||
bool m_remove;
|
bool m_remove = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Reads settings for .torrent files from preferences
|
/// Reads settings for .torrent files from preferences
|
||||||
|
@ -64,7 +62,7 @@ public:
|
||||||
void markAsAddedToSession();
|
void markAsAddedToSession();
|
||||||
using FileGuard::setAutoRemove;
|
using FileGuard::setAutoRemove;
|
||||||
|
|
||||||
enum AutoDeleteMode: int // do not change these names: they are stored in config file
|
enum AutoDeleteMode : int // do not change these names: they are stored in config file
|
||||||
{
|
{
|
||||||
Never,
|
Never,
|
||||||
IfAdded,
|
IfAdded,
|
||||||
|
@ -77,9 +75,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TorrentFileGuard(const Path &path, AutoDeleteMode mode);
|
TorrentFileGuard(const Path &path, AutoDeleteMode mode);
|
||||||
static SettingValue<AutoDeleteMode> &autoDeleteModeSetting();
|
|
||||||
|
|
||||||
Q_ENUM(AutoDeleteMode)
|
Q_ENUM(AutoDeleteMode)
|
||||||
AutoDeleteMode m_mode;
|
AutoDeleteMode m_mode;
|
||||||
bool m_wasAdded;
|
bool m_wasAdded = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -457,7 +457,7 @@ QString Utils::Misc::parseHtmlLinks(const QString &rawText)
|
||||||
result.replace(reURL, u"\\1<a href=\"\\2\">\\2</a>"_qs);
|
result.replace(reURL, u"\\1<a href=\"\\2\">\\2</a>"_qs);
|
||||||
|
|
||||||
// Capture links without scheme
|
// Capture links without scheme
|
||||||
static const QRegularExpression reNoScheme(u"<a\\s+href=\"(?!https?)([a-zA-Z0-9\\?%=&/_\\.-:#]+)\\s*\">"_qs);
|
const QRegularExpression reNoScheme(u"<a\\s+href=\"(?!https?)([a-zA-Z0-9\\?%=&/_\\.-:#]+)\\s*\">"_qs);
|
||||||
result.replace(reNoScheme, u"<a href=\"http://\\1\">"_qs);
|
result.replace(reNoScheme, u"<a href=\"http://\\1\">"_qs);
|
||||||
|
|
||||||
// to preserve plain text formatting
|
// to preserve plain text formatting
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
#include "base/search/searchdownloadhandler.h"
|
#include "base/search/searchdownloadhandler.h"
|
||||||
#include "base/search/searchhandler.h"
|
#include "base/search/searchhandler.h"
|
||||||
#include "base/search/searchpluginmanager.h"
|
#include "base/search/searchpluginmanager.h"
|
||||||
#include "base/settingvalue.h"
|
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "gui/addnewtorrentdialog.h"
|
#include "gui/addnewtorrentdialog.h"
|
||||||
#include "gui/lineedit.h"
|
#include "gui/lineedit.h"
|
||||||
|
@ -57,6 +56,7 @@ SearchJobWidget::SearchJobWidget(SearchHandler *searchHandler, QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_ui(new Ui::SearchJobWidget)
|
, m_ui(new Ui::SearchJobWidget)
|
||||||
, m_searchHandler(searchHandler)
|
, m_searchHandler(searchHandler)
|
||||||
|
, m_nameFilteringMode(u"Search/FilteringMode"_qs)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ void SearchJobWidget::updateFilter()
|
||||||
sizeInBytes(m_ui->minSize->value(), static_cast<SizeUnit>(m_ui->minSizeUnit->currentIndex())),
|
sizeInBytes(m_ui->minSize->value(), static_cast<SizeUnit>(m_ui->minSizeUnit->currentIndex())),
|
||||||
sizeInBytes(m_ui->maxSize->value(), static_cast<SizeUnit>(m_ui->maxSizeUnit->currentIndex())));
|
sizeInBytes(m_ui->maxSize->value(), static_cast<SizeUnit>(m_ui->maxSizeUnit->currentIndex())));
|
||||||
|
|
||||||
nameFilteringModeSetting() = filteringMode();
|
m_nameFilteringMode = filteringMode();
|
||||||
|
|
||||||
m_proxyModel->invalidate();
|
m_proxyModel->invalidate();
|
||||||
updateResultsCount();
|
updateResultsCount();
|
||||||
|
@ -355,8 +355,8 @@ void SearchJobWidget::fillFilterComboBoxes()
|
||||||
m_ui->filterMode->addItem(tr("Torrent names only"), static_cast<int>(NameFilteringMode::OnlyNames));
|
m_ui->filterMode->addItem(tr("Torrent names only"), static_cast<int>(NameFilteringMode::OnlyNames));
|
||||||
m_ui->filterMode->addItem(tr("Everywhere"), static_cast<int>(NameFilteringMode::Everywhere));
|
m_ui->filterMode->addItem(tr("Everywhere"), static_cast<int>(NameFilteringMode::Everywhere));
|
||||||
|
|
||||||
QVariant selectedMode = static_cast<int>(nameFilteringModeSetting().get(NameFilteringMode::OnlyNames));
|
const QVariant selectedMode = static_cast<int>(m_nameFilteringMode.get(NameFilteringMode::OnlyNames));
|
||||||
int index = m_ui->filterMode->findData(selectedMode);
|
const int index = m_ui->filterMode->findData(selectedMode);
|
||||||
m_ui->filterMode->setCurrentIndex((index == -1) ? 0 : index);
|
m_ui->filterMode->setCurrentIndex((index == -1) ? 0 : index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,12 +545,6 @@ void SearchJobWidget::appendSearchResults(const QVector<SearchResult> &results)
|
||||||
updateResultsCount();
|
updateResultsCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingValue<SearchJobWidget::NameFilteringMode> &SearchJobWidget::nameFilteringModeSetting()
|
|
||||||
{
|
|
||||||
static SettingValue<NameFilteringMode> setting {u"Search/FilteringMode"_qs};
|
|
||||||
return setting;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SearchJobWidget::keyPressEvent(QKeyEvent *event)
|
void SearchJobWidget::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
switch (event->key())
|
switch (event->key())
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "base/settingvalue.h"
|
||||||
|
|
||||||
#define ENGINE_URL_COLUMN 4
|
#define ENGINE_URL_COLUMN 4
|
||||||
#define URL_COLUMN 5
|
#define URL_COLUMN 5
|
||||||
|
|
||||||
|
@ -127,7 +129,6 @@ private:
|
||||||
void copyField(int column) const;
|
void copyField(int column) const;
|
||||||
|
|
||||||
static QString statusText(Status st);
|
static QString statusText(Status st);
|
||||||
static SettingValue<NameFilteringMode> &nameFilteringModeSetting();
|
|
||||||
|
|
||||||
Ui::SearchJobWidget *m_ui;
|
Ui::SearchJobWidget *m_ui;
|
||||||
SearchHandler *m_searchHandler;
|
SearchHandler *m_searchHandler;
|
||||||
|
@ -136,6 +137,8 @@ private:
|
||||||
LineEdit *m_lineEditSearchResultsFilter;
|
LineEdit *m_lineEditSearchResultsFilter;
|
||||||
Status m_status = Status::Ongoing;
|
Status m_status = Status::Ongoing;
|
||||||
bool m_noSearchResults = true;
|
bool m_noSearchResults = true;
|
||||||
|
|
||||||
|
SettingValue<NameFilteringMode> m_nameFilteringMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(SearchJobWidget::NameFilteringMode)
|
Q_DECLARE_METATYPE(SearchJobWidget::NameFilteringMode)
|
||||||
|
|
|
@ -69,14 +69,20 @@ namespace
|
||||||
class UnifiedFileIconProvider : public QFileIconProvider
|
class UnifiedFileIconProvider : public QFileIconProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
UnifiedFileIconProvider()
|
||||||
|
: m_textPlainIcon {UIThemeManager::instance()->getIcon(u"text-plain"_qs)}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
using QFileIconProvider::icon;
|
using QFileIconProvider::icon;
|
||||||
|
|
||||||
QIcon icon(const QFileInfo &info) const override
|
QIcon icon(const QFileInfo &) const override
|
||||||
{
|
{
|
||||||
Q_UNUSED(info);
|
return m_textPlainIcon;
|
||||||
static QIcon cached = UIThemeManager::instance()->getIcon(u"text-plain"_qs);
|
|
||||||
return cached;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QIcon m_textPlainIcon;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef QBT_PIXMAP_CACHE_FOR_FILE_ICONS
|
#ifdef QBT_PIXMAP_CACHE_FOR_FILE_ICONS
|
||||||
|
@ -185,15 +191,14 @@ namespace
|
||||||
TorrentContentModel::TorrentContentModel(QObject *parent)
|
TorrentContentModel::TorrentContentModel(QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
, m_rootItem(new TorrentContentModelFolder(QVector<QString>({ tr("Name"), tr("Total Size"), tr("Progress"), tr("Download Priority"), tr("Remaining"), tr("Availability") })))
|
, m_rootItem(new TorrentContentModelFolder(QVector<QString>({ tr("Name"), tr("Total Size"), tr("Progress"), tr("Download Priority"), tr("Remaining"), tr("Availability") })))
|
||||||
{
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
m_fileIconProvider = new WinShellFileIconProvider();
|
, m_fileIconProvider {new WinShellFileIconProvider}
|
||||||
#elif defined(Q_OS_MACOS)
|
#elif defined(Q_OS_MACOS)
|
||||||
m_fileIconProvider = new MacFileIconProvider();
|
, m_fileIconProvider {new MacFileIconProvider}
|
||||||
#else
|
#else
|
||||||
static bool doesBuiltInProviderWork = doesQFileIconProviderWork();
|
, m_fileIconProvider {doesQFileIconProviderWork() ? new QFileIconProvider : new MimeFileIconProvider}
|
||||||
m_fileIconProvider = doesBuiltInProviderWork ? new QFileIconProvider() : new MimeFileIconProvider();
|
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TorrentContentModel::~TorrentContentModel()
|
TorrentContentModel::~TorrentContentModel()
|
||||||
|
|
|
@ -84,7 +84,7 @@ public slots:
|
||||||
void selectNone();
|
void selectNone();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TorrentContentModelFolder *m_rootItem;
|
TorrentContentModelFolder *m_rootItem = nullptr;
|
||||||
QVector<TorrentContentModelFile *> m_filesIndex;
|
QVector<TorrentContentModelFile *> m_filesIndex;
|
||||||
QFileIconProvider *m_fileIconProvider;
|
QFileIconProvider *m_fileIconProvider = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,15 +50,14 @@ QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem &option, const Q
|
||||||
// the rows shrink if the text's height is smaller than the icon's height.
|
// the rows shrink if the text's height is smaller than the icon's height.
|
||||||
// This happens because icon from the 'name' column is no longer drawn.
|
// This happens because icon from the 'name' column is no longer drawn.
|
||||||
|
|
||||||
static int nameColHeight = -1;
|
if (m_nameColHeight == -1)
|
||||||
if (nameColHeight == -1)
|
|
||||||
{
|
{
|
||||||
const QModelIndex nameColumn = index.sibling(index.row(), TransferListModel::TR_NAME);
|
const QModelIndex nameColumn = index.sibling(index.row(), TransferListModel::TR_NAME);
|
||||||
nameColHeight = QStyledItemDelegate::sizeHint(option, nameColumn).height();
|
m_nameColHeight = QStyledItemDelegate::sizeHint(option, nameColumn).height();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize size = QStyledItemDelegate::sizeHint(option, index);
|
QSize size = QStyledItemDelegate::sizeHint(option, index);
|
||||||
size.setHeight(std::max(nameColHeight, size.height()));
|
size.setHeight(std::max(m_nameColHeight, size.height()));
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,4 +46,5 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProgressBarPainter m_progressBarPainter;
|
ProgressBarPainter m_progressBarPainter;
|
||||||
|
mutable int m_nameColHeight = -1;
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QIcon>
|
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
|
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
|
@ -47,60 +46,6 @@
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
QIcon getPausedIcon()
|
|
||||||
{
|
|
||||||
static QIcon cached = UIThemeManager::instance()->getIcon(u"paused"_qs);
|
|
||||||
return cached;
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon getQueuedIcon()
|
|
||||||
{
|
|
||||||
static QIcon cached = UIThemeManager::instance()->getIcon(u"queued"_qs);
|
|
||||||
return cached;
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon getDownloadingIcon()
|
|
||||||
{
|
|
||||||
static QIcon cached = UIThemeManager::instance()->getIcon(u"downloading"_qs);
|
|
||||||
return cached;
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon getStalledDownloadingIcon()
|
|
||||||
{
|
|
||||||
static QIcon cached = UIThemeManager::instance()->getIcon(u"stalledDL"_qs);
|
|
||||||
return cached;
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon getUploadingIcon()
|
|
||||||
{
|
|
||||||
static QIcon cached = UIThemeManager::instance()->getIcon(u"uploading"_qs);
|
|
||||||
return cached;
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon getStalledUploadingIcon()
|
|
||||||
{
|
|
||||||
static QIcon cached = UIThemeManager::instance()->getIcon(u"stalledUP"_qs);
|
|
||||||
return cached;
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon getCompletedIcon()
|
|
||||||
{
|
|
||||||
static QIcon cached = UIThemeManager::instance()->getIcon(u"completed"_qs);
|
|
||||||
return cached;
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon getCheckingIcon()
|
|
||||||
{
|
|
||||||
static QIcon cached = UIThemeManager::instance()->getIcon(u"checking"_qs);
|
|
||||||
return cached;
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon getErrorIcon()
|
|
||||||
{
|
|
||||||
static QIcon cached = UIThemeManager::instance()->getIcon(u"error"_qs);
|
|
||||||
return cached;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isDarkTheme()
|
bool isDarkTheme()
|
||||||
{
|
{
|
||||||
const QPalette pal = QApplication::palette();
|
const QPalette pal = QApplication::palette();
|
||||||
|
@ -109,48 +54,10 @@ namespace
|
||||||
return (color.lightness() < 127);
|
return (color.lightness() < 127);
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon getIconByState(const BitTorrent::TorrentState state)
|
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
case BitTorrent::TorrentState::Downloading:
|
|
||||||
case BitTorrent::TorrentState::ForcedDownloading:
|
|
||||||
case BitTorrent::TorrentState::DownloadingMetadata:
|
|
||||||
case BitTorrent::TorrentState::ForcedDownloadingMetadata:
|
|
||||||
return getDownloadingIcon();
|
|
||||||
case BitTorrent::TorrentState::StalledDownloading:
|
|
||||||
return getStalledDownloadingIcon();
|
|
||||||
case BitTorrent::TorrentState::StalledUploading:
|
|
||||||
return getStalledUploadingIcon();
|
|
||||||
case BitTorrent::TorrentState::Uploading:
|
|
||||||
case BitTorrent::TorrentState::ForcedUploading:
|
|
||||||
return getUploadingIcon();
|
|
||||||
case BitTorrent::TorrentState::PausedDownloading:
|
|
||||||
return getPausedIcon();
|
|
||||||
case BitTorrent::TorrentState::PausedUploading:
|
|
||||||
return getCompletedIcon();
|
|
||||||
case BitTorrent::TorrentState::QueuedDownloading:
|
|
||||||
case BitTorrent::TorrentState::QueuedUploading:
|
|
||||||
return getQueuedIcon();
|
|
||||||
case BitTorrent::TorrentState::CheckingDownloading:
|
|
||||||
case BitTorrent::TorrentState::CheckingUploading:
|
|
||||||
case BitTorrent::TorrentState::CheckingResumeData:
|
|
||||||
case BitTorrent::TorrentState::Moving:
|
|
||||||
return getCheckingIcon();
|
|
||||||
case BitTorrent::TorrentState::Unknown:
|
|
||||||
case BitTorrent::TorrentState::MissingFiles:
|
|
||||||
case BitTorrent::TorrentState::Error:
|
|
||||||
return getErrorIcon();
|
|
||||||
default:
|
|
||||||
Q_ASSERT(false);
|
|
||||||
return getErrorIcon();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor getDefaultColorByState(const BitTorrent::TorrentState state)
|
QColor getDefaultColorByState(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();
|
const bool dark = isDarkTheme();
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
|
@ -267,8 +174,17 @@ TransferListModel::TransferListModel(QObject *parent)
|
||||||
{BitTorrent::TorrentState::Moving, tr("Moving", "Torrent local data are being moved/relocated")},
|
{BitTorrent::TorrentState::Moving, tr("Moving", "Torrent local data are being moved/relocated")},
|
||||||
{BitTorrent::TorrentState::MissingFiles, tr("Missing Files")},
|
{BitTorrent::TorrentState::MissingFiles, tr("Missing Files")},
|
||||||
{BitTorrent::TorrentState::Error, tr("Errored", "Torrent status, the torrent has an error")}
|
{BitTorrent::TorrentState::Error, tr("Errored", "Torrent status, the torrent has an error")}
|
||||||
}
|
}
|
||||||
, m_stateThemeColors {torrentStateColorsFromUITheme()}
|
, m_stateThemeColors {torrentStateColorsFromUITheme()}
|
||||||
|
, m_checkingIcon {UIThemeManager::instance()->getIcon(u"checking"_qs)}
|
||||||
|
, m_completedIcon {UIThemeManager::instance()->getIcon(u"completed"_qs)}
|
||||||
|
, m_downloadingIcon {UIThemeManager::instance()->getIcon(u"downloading"_qs)}
|
||||||
|
, m_errorIcon {UIThemeManager::instance()->getIcon(u"error"_qs)}
|
||||||
|
, m_pausedIcon {UIThemeManager::instance()->getIcon(u"paused"_qs)}
|
||||||
|
, m_queuedIcon {UIThemeManager::instance()->getIcon(u"queued"_qs)}
|
||||||
|
, m_stalledDLIcon {UIThemeManager::instance()->getIcon(u"stalledDL"_qs)}
|
||||||
|
, m_stalledUPIcon {UIThemeManager::instance()->getIcon(u"stalledUP"_qs)}
|
||||||
|
, m_uploadingIcon {UIThemeManager::instance()->getIcon(u"uploading"_qs)}
|
||||||
{
|
{
|
||||||
configure();
|
configure();
|
||||||
connect(Preferences::instance(), &Preferences::changed, this, &TransferListModel::configure);
|
connect(Preferences::instance(), &Preferences::changed, this, &TransferListModel::configure);
|
||||||
|
@ -796,3 +712,41 @@ void TransferListModel::configure()
|
||||||
emit dataChanged(index(0, 0), index((rowCount() - 1), (columnCount() - 1)));
|
emit dataChanged(index(0, 0), index((rowCount() - 1), (columnCount() - 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon TransferListModel::getIconByState(const BitTorrent::TorrentState state) const
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case BitTorrent::TorrentState::Downloading:
|
||||||
|
case BitTorrent::TorrentState::ForcedDownloading:
|
||||||
|
case BitTorrent::TorrentState::DownloadingMetadata:
|
||||||
|
case BitTorrent::TorrentState::ForcedDownloadingMetadata:
|
||||||
|
return m_downloadingIcon;
|
||||||
|
case BitTorrent::TorrentState::StalledDownloading:
|
||||||
|
return m_stalledDLIcon;
|
||||||
|
case BitTorrent::TorrentState::StalledUploading:
|
||||||
|
return m_stalledUPIcon;
|
||||||
|
case BitTorrent::TorrentState::Uploading:
|
||||||
|
case BitTorrent::TorrentState::ForcedUploading:
|
||||||
|
return m_uploadingIcon;
|
||||||
|
case BitTorrent::TorrentState::PausedDownloading:
|
||||||
|
return m_pausedIcon;
|
||||||
|
case BitTorrent::TorrentState::PausedUploading:
|
||||||
|
return m_completedIcon;
|
||||||
|
case BitTorrent::TorrentState::QueuedDownloading:
|
||||||
|
case BitTorrent::TorrentState::QueuedUploading:
|
||||||
|
return m_queuedIcon;
|
||||||
|
case BitTorrent::TorrentState::CheckingDownloading:
|
||||||
|
case BitTorrent::TorrentState::CheckingUploading:
|
||||||
|
case BitTorrent::TorrentState::CheckingResumeData:
|
||||||
|
case BitTorrent::TorrentState::Moving:
|
||||||
|
return m_checkingIcon;
|
||||||
|
case BitTorrent::TorrentState::Unknown:
|
||||||
|
case BitTorrent::TorrentState::MissingFiles:
|
||||||
|
case BitTorrent::TorrentState::Error:
|
||||||
|
return m_errorIcon;
|
||||||
|
default:
|
||||||
|
Q_ASSERT(false);
|
||||||
|
return m_errorIcon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QIcon>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
#include "base/bittorrent/torrent.h"
|
#include "base/bittorrent/torrent.h"
|
||||||
|
@ -111,6 +112,7 @@ private:
|
||||||
void configure();
|
void configure();
|
||||||
QString displayValue(const BitTorrent::Torrent *torrent, int column) const;
|
QString displayValue(const BitTorrent::Torrent *torrent, int column) const;
|
||||||
QVariant internalValue(const BitTorrent::Torrent *torrent, int column, bool alt) const;
|
QVariant internalValue(const BitTorrent::Torrent *torrent, int column, bool alt) const;
|
||||||
|
QIcon getIconByState(const BitTorrent::TorrentState state) const;
|
||||||
|
|
||||||
QList<BitTorrent::Torrent *> m_torrentList; // maps row number to torrent handle
|
QList<BitTorrent::Torrent *> m_torrentList; // maps row number to torrent handle
|
||||||
QHash<BitTorrent::Torrent *, int> m_torrentMap; // maps torrent handle to row number
|
QHash<BitTorrent::Torrent *, int> m_torrentMap; // maps torrent handle to row number
|
||||||
|
@ -126,4 +128,15 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
HideZeroValuesMode m_hideZeroValuesMode = HideZeroValuesMode::Never;
|
HideZeroValuesMode m_hideZeroValuesMode = HideZeroValuesMode::Never;
|
||||||
|
|
||||||
|
// cached icons
|
||||||
|
QIcon m_checkingIcon;
|
||||||
|
QIcon m_completedIcon;
|
||||||
|
QIcon m_downloadingIcon;
|
||||||
|
QIcon m_errorIcon;
|
||||||
|
QIcon m_pausedIcon;
|
||||||
|
QIcon m_queuedIcon;
|
||||||
|
QIcon m_stalledDLIcon;
|
||||||
|
QIcon m_stalledUPIcon;
|
||||||
|
QIcon m_uploadingIcon;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue