Merge pull request #17259 from Chocobo1/cleanup

Make use of chrono literals from std library
This commit is contained in:
Chocobo1 2022-06-25 13:23:27 +08:00 committed by GitHub
commit 41a38428fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
93 changed files with 241 additions and 237 deletions

View file

@ -51,6 +51,6 @@ signals:
void messageReceived(const QString &message); void messageReceived(const QString &message);
private: private:
QtLocalPeer *m_peer; QtLocalPeer *m_peer = nullptr;
const bool m_isFirstInstance; const bool m_isFirstInstance;
}; };

View file

@ -97,7 +97,7 @@ namespace
} }
private: private:
const char *m_name; const char *m_name = nullptr;
const char m_shortcut; const char m_shortcut;
}; };

View file

@ -29,6 +29,7 @@
#include <QtGlobal> #include <QtGlobal>
#include <chrono>
#include <cstdlib> #include <cstdlib>
#include <memory> #include <memory>
@ -79,6 +80,8 @@ Q_IMPORT_PLUGIN(QICOPlugin)
#include "gui/utils.h" #include "gui/utils.h"
#endif #endif
using namespace std::chrono_literals;
void displayVersion(); void displayVersion();
bool userAgreesWithLegalNotice(); bool userAgreesWithLegalNotice();
void displayBadArgMessage(const QString &message); void displayBadArgMessage(const QString &message);
@ -284,7 +287,7 @@ void showSplashScreen()
painter.drawText(224 - painter.fontMetrics().horizontalAdvance(version), 270, version); painter.drawText(224 - painter.fontMetrics().horizontalAdvance(version), 270, version);
QSplashScreen *splash = new QSplashScreen(splashImg); QSplashScreen *splash = new QSplashScreen(splashImg);
splash->show(); splash->show();
QTimer::singleShot(1500, splash, &QObject::deleteLater); QTimer::singleShot(1500ms, splash, &QObject::deleteLater);
qApp->processEvents(); qApp->processEvents();
} }
#endif // DISABLE_GUI #endif // DISABLE_GUI

View file

@ -29,14 +29,16 @@
#include "bandwidthscheduler.h" #include "bandwidthscheduler.h"
#include <chrono>
#include <utility> #include <utility>
#include <QDate> #include <QDate>
#include <QTime> #include <QTime>
#include <QTimer>
#include "base/preferences.h" #include "base/preferences.h"
using namespace std::chrono_literals;
BandwidthScheduler::BandwidthScheduler(QObject *parent) BandwidthScheduler::BandwidthScheduler(QObject *parent)
: QObject(parent) : QObject(parent)
, m_lastAlternative(false) , m_lastAlternative(false)
@ -51,7 +53,7 @@ void BandwidthScheduler::start()
// Timeout regularly to accommodate for external system clock changes // Timeout regularly to accommodate for external system clock changes
// eg from the user or from a timesync utility // eg from the user or from a timesync utility
m_timer.start(30000); m_timer.start(30s);
} }
bool BandwidthScheduler::isTimeForAlternative() const bool BandwidthScheduler::isTimeForAlternative() const

View file

@ -48,7 +48,7 @@ namespace
unsigned char octetIndex = 0; unsigned char octetIndex = 0;
const char *octetStart = str; const char *octetStart = str;
char *endptr; char *endptr = nullptr;
for (; *str; ++str) for (; *str; ++str)
{ {
if (*str == '.') if (*str == '.')

View file

@ -58,6 +58,6 @@ private:
void stop(); void stop();
CachedSettingValue<bool> m_storeActive; CachedSettingValue<bool> m_storeActive;
lt::session *m_provider; lt::session *m_provider = nullptr;
QHash<quint16, std::vector<lt::port_mapping_t>> m_mappedPorts; QHash<quint16, std::vector<lt::port_mapping_t>> m_mappedPorts;
}; };

View file

@ -30,6 +30,7 @@
#include "session.h" #include "session.h"
#include <algorithm> #include <algorithm>
#include <chrono>
#include <cstdint> #include <cstdint>
#include <ctime> #include <ctime>
#include <queue> #include <queue>
@ -107,6 +108,7 @@
#include "torrentimpl.h" #include "torrentimpl.h"
#include "tracker.h" #include "tracker.h"
using namespace std::chrono_literals;
using namespace BitTorrent; using namespace BitTorrent;
const Path CATEGORIES_FILE_NAME {u"categories.json"_qs}; const Path CATEGORIES_FILE_NAME {u"categories.json"_qs};
@ -442,11 +444,11 @@ Session::Session(QObject *parent)
m_port = Utils::Random::rand(1024, 65535); m_port = Utils::Random::rand(1024, 65535);
m_recentErroredTorrentsTimer->setSingleShot(true); m_recentErroredTorrentsTimer->setSingleShot(true);
m_recentErroredTorrentsTimer->setInterval(1000); m_recentErroredTorrentsTimer->setInterval(1s);
connect(m_recentErroredTorrentsTimer, &QTimer::timeout connect(m_recentErroredTorrentsTimer, &QTimer::timeout
, this, [this]() { m_recentErroredTorrents.clear(); }); , this, [this]() { m_recentErroredTorrents.clear(); });
m_seedingLimitTimer->setInterval(10000); m_seedingLimitTimer->setInterval(10s);
connect(m_seedingLimitTimer, &QTimer::timeout, this, &Session::processShareLimits); connect(m_seedingLimitTimer, &QTimer::timeout, this, &Session::processShareLimits);
initializeNativeSession(); initializeNativeSession();
@ -497,7 +499,7 @@ Session::Session(QObject *parent)
const int saveInterval = saveResumeDataInterval(); const int saveInterval = saveResumeDataInterval();
if (saveInterval > 0) if (saveInterval > 0)
{ {
m_resumeDataTimer->setInterval(saveInterval * 60 * 1000); m_resumeDataTimer->setInterval(std::chrono::minutes(saveInterval));
m_resumeDataTimer->start(); m_resumeDataTimer->start();
} }
@ -2907,7 +2909,7 @@ void Session::setSaveResumeDataInterval(const int value)
if (value > 0) if (value > 0)
{ {
m_resumeDataTimer->setInterval(value * 60 * 1000); m_resumeDataTimer->setInterval(std::chrono::minutes(value));
m_resumeDataTimer->start(); m_resumeDataTimer->start();
} }
else else
@ -5243,7 +5245,6 @@ void Session::handleSessionStatsAlert(const lt::session_stats_alert *p)
{ {
Q_ASSERT(current >= previous); Q_ASSERT(current >= previous);
Q_ASSERT(interval >= 0); Q_ASSERT(interval >= 0);
using namespace std::chrono_literals;
return (((current - previous) * lt::microseconds(1s).count()) / interval); return (((current - previous) * lt::microseconds(1s).count()) / interval);
}; };

View file

@ -40,7 +40,7 @@
using namespace std::chrono_literals; using namespace std::chrono_literals;
using namespace BitTorrent; using namespace BitTorrent;
const qint64 SAVE_INTERVAL = std::chrono::milliseconds(15min).count(); const int SAVE_INTERVAL = std::chrono::milliseconds(15min).count();
Statistics::Statistics(Session *session) Statistics::Statistics(Session *session)
: QObject(session) : QObject(session)

View file

@ -288,8 +288,8 @@ namespace BitTorrent
nonstd::expected<lt::entry, QString> exportTorrent() const; nonstd::expected<lt::entry, QString> exportTorrent() const;
Session *const m_session; Session *const m_session = nullptr;
lt::session *m_nativeSession; lt::session *m_nativeSession = nullptr;
lt::torrent_handle m_nativeHandle; lt::torrent_handle m_nativeHandle;
mutable lt::torrent_status m_nativeStatus; mutable lt::torrent_status m_nativeStatus;
TorrentState m_state = TorrentState::Unknown; TorrentState m_state = TorrentState::Unknown;

View file

@ -103,7 +103,7 @@ namespace BitTorrent
void unregisterPeer(const TrackerAnnounceRequest &announceReq); void unregisterPeer(const TrackerAnnounceRequest &announceReq);
void prepareAnnounceResponse(const TrackerAnnounceRequest &announceReq); void prepareAnnounceResponse(const TrackerAnnounceRequest &announceReq);
Http::Server *m_server; Http::Server *m_server = nullptr;
Http::Request m_request; Http::Request m_request;
Http::Environment m_env; Http::Environment m_env;

View file

@ -57,8 +57,8 @@ namespace Http
void read(); void read();
void sendResponse(const Response &response) const; void sendResponse(const Response &response) const;
QTcpSocket *m_socket; QTcpSocket *m_socket = nullptr;
IRequestHandler *m_requestHandler; IRequestHandler *m_requestHandler = nullptr;
QByteArray m_receivedData; QByteArray m_receivedData;
QElapsedTimer m_idleTimer; QElapsedTimer m_idleTimer;
}; };

View file

@ -31,6 +31,7 @@
#include "server.h" #include "server.h"
#include <algorithm> #include <algorithm>
#include <chrono>
#include <QNetworkProxy> #include <QNetworkProxy>
#include <QSslCipher> #include <QSslCipher>
@ -44,11 +45,13 @@
#include "base/utils/net.h" #include "base/utils/net.h"
#include "connection.h" #include "connection.h"
using namespace std::chrono_literals;
namespace namespace
{ {
const int KEEP_ALIVE_DURATION = 7 * 1000; // milliseconds const int KEEP_ALIVE_DURATION = std::chrono::milliseconds(7s).count();
const int CONNECTIONS_LIMIT = 500; const int CONNECTIONS_LIMIT = 500;
const int CONNECTIONS_SCAN_INTERVAL = 2; // seconds const std::chrono::seconds CONNECTIONS_SCAN_INTERVAL {2};
QList<QSslCipher> safeCipherList() QList<QSslCipher> safeCipherList()
{ {
@ -71,7 +74,6 @@ using namespace Http;
Server::Server(IRequestHandler *requestHandler, QObject *parent) Server::Server(IRequestHandler *requestHandler, QObject *parent)
: QTcpServer(parent) : QTcpServer(parent)
, m_requestHandler(requestHandler) , m_requestHandler(requestHandler)
, m_https(false)
{ {
setProxy(QNetworkProxy::NoProxy); setProxy(QNetworkProxy::NoProxy);
@ -81,14 +83,14 @@ Server::Server(IRequestHandler *requestHandler, QObject *parent)
auto *dropConnectionTimer = new QTimer(this); auto *dropConnectionTimer = new QTimer(this);
connect(dropConnectionTimer, &QTimer::timeout, this, &Server::dropTimedOutConnection); connect(dropConnectionTimer, &QTimer::timeout, this, &Server::dropTimedOutConnection);
dropConnectionTimer->start(CONNECTIONS_SCAN_INTERVAL * 1000); dropConnectionTimer->start(CONNECTIONS_SCAN_INTERVAL);
} }
void Server::incomingConnection(const qintptr socketDescriptor) void Server::incomingConnection(const qintptr socketDescriptor)
{ {
if (m_connections.size() >= CONNECTIONS_LIMIT) return; if (m_connections.size() >= CONNECTIONS_LIMIT) return;
QTcpSocket *serverSocket; QTcpSocket *serverSocket = nullptr;
if (m_https) if (m_https)
serverSocket = new QSslSocket(this); serverSocket = new QSslSocket(this);
else else

View file

@ -58,10 +58,10 @@ namespace Http
void incomingConnection(qintptr socketDescriptor) override; void incomingConnection(qintptr socketDescriptor) override;
void removeConnection(Connection *connection); void removeConnection(Connection *connection);
IRequestHandler *m_requestHandler; IRequestHandler *m_requestHandler = nullptr;
QSet<Connection *> m_connections; // for tracking persistent connections QSet<Connection *> m_connections; // for tracking persistent connections
bool m_https; bool m_https = false;
QList<QSslCertificate> m_certificates; QList<QSslCertificate> m_certificates;
QSslKey m_key; QSslKey m_key;
}; };

View file

@ -37,8 +37,11 @@
#include "base/net/downloadmanager.h" #include "base/net/downloadmanager.h"
#include "base/version.h" #include "base/version.h"
using namespace std::chrono_literals;
using namespace Net; using namespace Net;
const std::chrono::seconds IP_CHECK_INTERVAL = 30min;
DNSUpdater::DNSUpdater(QObject *parent) DNSUpdater::DNSUpdater(QObject *parent)
: QObject(parent) : QObject(parent)
, m_state(OK) , m_state(OK)
@ -52,14 +55,14 @@ DNSUpdater::DNSUpdater(QObject *parent)
m_lastIP = QHostAddress(pref->getDNSLastIP()); m_lastIP = QHostAddress(pref->getDNSLastIP());
// Start IP checking timer // Start IP checking timer
m_ipCheckTimer.setInterval(IP_CHECK_INTERVAL_MS); m_ipCheckTimer.setInterval(IP_CHECK_INTERVAL);
connect(&m_ipCheckTimer, &QTimer::timeout, this, &DNSUpdater::checkPublicIP); connect(&m_ipCheckTimer, &QTimer::timeout, this, &DNSUpdater::checkPublicIP);
m_ipCheckTimer.start(); m_ipCheckTimer.start();
// Check lastUpdate to avoid flooding // Check lastUpdate to avoid flooding
if (!m_lastIPCheckTime.isValid() if (!m_lastIPCheckTime.isValid()
|| (m_lastIPCheckTime.secsTo(QDateTime::currentDateTime()) * 1000 > IP_CHECK_INTERVAL_MS)) || (m_lastIPCheckTime.secsTo(QDateTime::currentDateTime()) > IP_CHECK_INTERVAL.count()))
{ {
checkPublicIP(); checkPublicIP();
} }
} }

View file

@ -68,8 +68,6 @@ namespace Net
FATAL FATAL
}; };
static const int IP_CHECK_INTERVAL_MS = 1800000; // 30 min
QString getUpdateUrl() const; QString getUpdateUrl() const;
void processIPUpdateReply(const QString &reply); void processIPUpdateReply(const QString &reply);

View file

@ -76,13 +76,7 @@ struct DataFieldDescriptor
}; };
GeoIPDatabase::GeoIPDatabase(const quint32 size) GeoIPDatabase::GeoIPDatabase(const quint32 size)
: m_ipVersion(0) : m_size(size)
, m_recordSize(0)
, m_nodeCount(0)
, m_nodeSize(0)
, m_indexSize(0)
, m_recordBytes(0)
, m_size(size)
, m_data(new uchar[size]) , m_data(new uchar[size])
{ {
} }

View file

@ -73,16 +73,16 @@ private:
template <typename T> QVariant readPlainValue(quint32 &offset, quint8 len) const; template <typename T> QVariant readPlainValue(quint32 &offset, quint8 len) const;
// Metadata // Metadata
quint16 m_ipVersion; quint16 m_ipVersion = 0;
quint16 m_recordSize; quint16 m_recordSize = 0;
quint32 m_nodeCount; quint32 m_nodeCount = 0;
int m_nodeSize; int m_nodeSize = 0;
int m_indexSize; int m_indexSize = 0;
int m_recordBytes; int m_recordBytes = 0;
QDateTime m_buildEpoch; QDateTime m_buildEpoch;
QString m_dbType; QString m_dbType;
// Search data // Search data
mutable QHash<quint32, QString> m_countries; mutable QHash<quint32, QString> m_countries;
quint32 m_size; quint32 m_size = 0;
uchar *m_data; uchar *m_data = nullptr;
}; };

View file

@ -54,8 +54,6 @@ using namespace Net;
GeoIPManager *GeoIPManager::m_instance = nullptr; GeoIPManager *GeoIPManager::m_instance = nullptr;
GeoIPManager::GeoIPManager() GeoIPManager::GeoIPManager()
: m_enabled(false)
, m_geoIPDatabase(nullptr)
{ {
configure(); configure();
connect(Preferences::instance(), &Preferences::changed, this, &GeoIPManager::configure); connect(Preferences::instance(), &Preferences::changed, this, &GeoIPManager::configure);

View file

@ -66,8 +66,8 @@ namespace Net
void manageDatabaseUpdate(); void manageDatabaseUpdate();
void downloadDatabaseFile(); void downloadDatabaseFile();
bool m_enabled; bool m_enabled = false;
GeoIPDatabase *m_geoIPDatabase; GeoIPDatabase *m_geoIPDatabase = nullptr;
static GeoIPManager *m_instance; static GeoIPManager *m_instance;
}; };

View file

@ -103,9 +103,6 @@ using namespace Net;
Smtp::Smtp(QObject *parent) Smtp::Smtp(QObject *parent)
: QObject(parent) : QObject(parent)
, m_state(Init)
, m_useSsl(false)
, m_authType(AuthPlain)
{ {
static bool needToRegisterMetaType = true; static bool needToRegisterMetaType = true;

View file

@ -103,18 +103,18 @@ namespace Net
QByteArray m_message; QByteArray m_message;
#ifndef QT_NO_OPENSSL #ifndef QT_NO_OPENSSL
QSslSocket *m_socket; QSslSocket *m_socket = nullptr;
#else #else
QTcpSocket *m_socket; QTcpSocket *m_socket = nullptr;
#endif #endif
QString m_from; QString m_from;
QString m_rcpt; QString m_rcpt;
QString m_response; QString m_response;
int m_state; int m_state = Init;
QHash<QString, QString> m_extensions; QHash<QString, QString> m_extensions;
QByteArray m_buffer; QByteArray m_buffer;
bool m_useSsl; bool m_useSsl = false;
AuthType m_authType; AuthType m_authType = AuthPlain;
QString m_username; QString m_username;
QString m_password; QString m_password;
}; };

View file

@ -136,9 +136,9 @@ namespace RSS
SettingValue<QVariant> m_storeSmartEpisodeFilter; SettingValue<QVariant> m_storeSmartEpisodeFilter;
SettingValue<bool> m_storeDownloadRepacks; SettingValue<bool> m_storeDownloadRepacks;
QTimer *m_processingTimer; QTimer *m_processingTimer = nullptr;
QThread *m_ioThread; QThread *m_ioThread = nullptr;
AsyncFileStorage *m_fileStorage; AsyncFileStorage *m_fileStorage = nullptr;
QHash<QString, AutoDownloadRule> m_rules; QHash<QString, AutoDownloadRule> m_rules;
QList<QSharedPointer<ProcessingJob>> m_processingQueue; QList<QSharedPointer<ProcessingJob>> m_processingQueue;
QHash<QString, QSharedPointer<ProcessingJob>> m_waitingJobs; QHash<QString, QSharedPointer<ProcessingJob>> m_waitingJobs;

View file

@ -30,6 +30,8 @@
#include "rss_session.h" #include "rss_session.h"
#include <chrono>
#include <QDebug> #include <QDebug>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
@ -48,7 +50,6 @@
#include "rss_folder.h" #include "rss_folder.h"
#include "rss_item.h" #include "rss_item.h"
const int MsecsPerMin = 60000;
const QString CONF_FOLDER_NAME = u"rss"_qs; const QString CONF_FOLDER_NAME = u"rss"_qs;
const QString DATA_FOLDER_NAME = u"rss/articles"_qs; const QString DATA_FOLDER_NAME = u"rss/articles"_qs;
const QString FEEDS_FILE_NAME = u"feeds.json"_qs; const QString FEEDS_FILE_NAME = u"feeds.json"_qs;
@ -92,7 +93,7 @@ Session::Session()
connect(&m_refreshTimer, &QTimer::timeout, this, &Session::refresh); connect(&m_refreshTimer, &QTimer::timeout, this, &Session::refresh);
if (isProcessingEnabled()) if (isProcessingEnabled())
{ {
m_refreshTimer.start(refreshInterval() * MsecsPerMin); m_refreshTimer.start(std::chrono::minutes(refreshInterval()));
refresh(); refresh();
} }
@ -433,7 +434,7 @@ void Session::setProcessingEnabled(const bool enabled)
m_storeProcessingEnabled = enabled; m_storeProcessingEnabled = enabled;
if (enabled) if (enabled)
{ {
m_refreshTimer.start(refreshInterval() * MsecsPerMin); m_refreshTimer.start(std::chrono::minutes(refreshInterval()));
refresh(); refresh();
} }
else else
@ -480,7 +481,7 @@ void Session::setRefreshInterval(const int refreshInterval)
if (m_storeRefreshInterval != refreshInterval) if (m_storeRefreshInterval != refreshInterval)
{ {
m_storeRefreshInterval = refreshInterval; m_storeRefreshInterval = refreshInterval;
m_refreshTimer.start(m_storeRefreshInterval * MsecsPerMin); m_refreshTimer.start(std::chrono::minutes(m_storeRefreshInterval));
} }
} }

View file

@ -158,9 +158,9 @@ namespace RSS
CachedSettingValue<bool> m_storeProcessingEnabled; CachedSettingValue<bool> m_storeProcessingEnabled;
CachedSettingValue<int> m_storeRefreshInterval; CachedSettingValue<int> m_storeRefreshInterval;
CachedSettingValue<int> m_storeMaxArticlesPerFeed; CachedSettingValue<int> m_storeMaxArticlesPerFeed;
QThread *m_workingThread; QThread *m_workingThread = nullptr;
AsyncFileStorage *m_confFileStorage; AsyncFileStorage *m_confFileStorage = nullptr;
AsyncFileStorage *m_dataFileStorage; AsyncFileStorage *m_dataFileStorage = nullptr;
QTimer m_refreshTimer; QTimer m_refreshTimer;
QHash<QString, Item *> m_itemsByPath; QHash<QString, Item *> m_itemsByPath;
QHash<QUuid, Feed *> m_feedsByUID; QHash<QUuid, Feed *> m_feedsByUID;

View file

@ -49,6 +49,6 @@ signals:
private: private:
void downloadProcessFinished(int exitcode); void downloadProcessFinished(int exitcode);
SearchPluginManager *m_manager; SearchPluginManager *m_manager = nullptr;
QProcess *m_downloadProcess; QProcess *m_downloadProcess = nullptr;
}; };

View file

@ -29,6 +29,8 @@
#include "searchhandler.h" #include "searchhandler.h"
#include <chrono>
#include <QMetaObject> #include <QMetaObject>
#include <QProcess> #include <QProcess>
#include <QTimer> #include <QTimer>
@ -40,6 +42,8 @@
#include "base/utils/fs.h" #include "base/utils/fs.h"
#include "searchpluginmanager.h" #include "searchpluginmanager.h"
using namespace std::chrono_literals;
namespace namespace
{ {
enum SearchResultColumn enum SearchResultColumn
@ -85,7 +89,7 @@ SearchHandler::SearchHandler(const QString &pattern, const QString &category, co
m_searchTimeout->setSingleShot(true); m_searchTimeout->setSingleShot(true);
connect(m_searchTimeout, &QTimer::timeout, this, &SearchHandler::cancelSearch); connect(m_searchTimeout, &QTimer::timeout, this, &SearchHandler::cancelSearch);
m_searchTimeout->start(180000); // 3 min m_searchTimeout->start(3min);
// deferred start allows clients to handle starting-related signals // deferred start allows clients to handle starting-related signals
QMetaObject::invokeMethod(this, [this]() { m_searchProcess->start(QIODevice::ReadOnly); } QMetaObject::invokeMethod(this, [this]() { m_searchProcess->start(QIODevice::ReadOnly); }

View file

@ -83,9 +83,9 @@ private:
const QString m_pattern; const QString m_pattern;
const QString m_category; const QString m_category;
const QStringList m_usedPlugins; const QStringList m_usedPlugins;
SearchPluginManager *m_manager; SearchPluginManager *m_manager = nullptr;
QProcess *m_searchProcess; QProcess *m_searchProcess = nullptr;
QTimer *m_searchTimeout; QTimer *m_searchTimeout = nullptr;
QByteArray m_searchResultLineTruncated; QByteArray m_searchResultLineTruncated;
bool m_searchCancelled = false; bool m_searchCancelled = false;
QList<SearchResult> m_results; QList<SearchResult> m_results;

View file

@ -29,7 +29,9 @@
#include "settingsstorage.h" #include "settingsstorage.h"
#include <chrono>
#include <memory> #include <memory>
#include <QFile> #include <QFile>
#include <QHash> #include <QHash>
@ -39,6 +41,8 @@
#include "profile.h" #include "profile.h"
#include "utils/fs.h" #include "utils/fs.h"
using namespace std::chrono_literals;
namespace namespace
{ {
// Encapsulates serialization of settings in "atomic" way. // Encapsulates serialization of settings in "atomic" way.
@ -73,7 +77,7 @@ SettingsStorage::SettingsStorage()
: m_data {TransactionalSettings(u"qBittorrent"_qs).read()} : m_data {TransactionalSettings(u"qBittorrent"_qs).read()}
{ {
m_timer.setSingleShot(true); m_timer.setSingleShot(true);
m_timer.setInterval(5 * 1000); m_timer.setInterval(5s);
connect(&m_timer, &QTimer::timeout, this, &SettingsStorage::save); connect(&m_timer, &QTimer::timeout, this, &SettingsStorage::save);
} }

View file

@ -63,7 +63,7 @@
using namespace std::chrono_literals; using namespace std::chrono_literals;
const std::chrono::duration WATCH_INTERVAL = 10s; const std::chrono::seconds WATCH_INTERVAL {10};
const int MAX_FAILED_RETRIES = 5; const int MAX_FAILED_RETRIES = 5;
const QString CONF_FILE_NAME = u"watched_folders.json"_qs; const QString CONF_FILE_NAME = u"watched_folders.json"_qs;
@ -478,7 +478,7 @@ void TorrentFilesWatcher::Worker::removeWatchedFolder(const Path &path)
void TorrentFilesWatcher::Worker::scheduleWatchedFolderProcessing(const Path &path) void TorrentFilesWatcher::Worker::scheduleWatchedFolderProcessing(const Path &path)
{ {
QTimer::singleShot(2000, this, [this, path]() QTimer::singleShot(2s, this, [this, path]()
{ {
processWatchedFolder(path); processWatchedFolder(path);
}); });

View file

@ -76,9 +76,9 @@ namespace Utils::IO
} }
private: private:
QFileDevice *m_device; QFileDevice *m_device = nullptr;
std::shared_ptr<QByteArray> m_buffer; std::shared_ptr<QByteArray> m_buffer;
int m_bufferSize; int m_bufferSize = 0;
}; };
nonstd::expected<void, QString> saveToFile(const Path &path, const QByteArray &data); nonstd::expected<void, QString> saveToFile(const Path &path, const QByteArray &data);

View file

@ -125,7 +125,7 @@ namespace
} }
private: private:
FILE *m_randDev; FILE *m_randDev = nullptr;
}; };
#endif #endif
} }

View file

@ -47,6 +47,6 @@ public:
~AboutDialog() override; ~AboutDialog() override;
private: private:
Ui::AboutDialog *m_ui; Ui::AboutDialog *m_ui = nullptr;
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;
}; };

View file

@ -115,7 +115,7 @@ private:
void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
Ui::AddNewTorrentDialog *m_ui; Ui::AddNewTorrentDialog *m_ui = nullptr;
TorrentContentFilterModel *m_contentModel = nullptr; TorrentContentFilterModel *m_contentModel = nullptr;
PropListDelegate *m_contentDelegate = nullptr; PropListDelegate *m_contentDelegate = nullptr;
BitTorrent::MagnetUri m_magnetURI; BitTorrent::MagnetUri m_magnetURI;

View file

@ -55,5 +55,5 @@ protected:
void showEvent(QShowEvent *e) override; void showEvent(QShowEvent *e) override;
private: private:
Ui::AutoExpandableDialog *m_ui; Ui::AutoExpandableDialog *m_ui = nullptr;
}; };

View file

@ -56,9 +56,9 @@ private slots:
void on_txtIP_textChanged(const QString &ip); void on_txtIP_textChanged(const QString &ip);
private: private:
Ui::BanListOptionsDialog *m_ui; Ui::BanListOptionsDialog *m_ui = nullptr;
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;
QStringListModel *m_model; QStringListModel *m_model = nullptr;
QSortFilterProxyModel *m_sortFilter; QSortFilterProxyModel *m_sortFilter = nullptr;
bool m_modified = false; bool m_modified = false;
}; };

View file

@ -40,8 +40,6 @@ class CategoryModelItem
{ {
public: public:
CategoryModelItem() CategoryModelItem()
: m_parent(nullptr)
, m_torrentsCount(0)
{ {
} }
@ -154,9 +152,9 @@ public:
} }
private: private:
CategoryModelItem *m_parent; CategoryModelItem *m_parent = nullptr;
QString m_name; QString m_name;
int m_torrentsCount; int m_torrentsCount = 0;
QHash<QString, CategoryModelItem *> m_children; QHash<QString, CategoryModelItem *> m_children;
QStringList m_childUids; QStringList m_childUids;
}; };

View file

@ -75,5 +75,5 @@ private:
CategoryModelItem *findItem(const QString &fullName) const; CategoryModelItem *findItem(const QString &fullName) const;
bool m_isSubcategoriesEnabled; bool m_isSubcategoriesEnabled;
CategoryModelItem *m_rootItem; CategoryModelItem *m_rootItem = nullptr;
}; };

View file

@ -56,8 +56,8 @@ private slots:
void onButtonDeleteClicked(); void onButtonDeleteClicked();
private: private:
Ui::CookiesDialog *m_ui; Ui::CookiesDialog *m_ui = nullptr;
CookiesModel *m_cookiesModel; CookiesModel *m_cookiesModel = nullptr;
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;
SettingValue<QByteArray> m_storeViewState; SettingValue<QByteArray> m_storeViewState;

View file

@ -53,5 +53,5 @@ private slots:
void on_rememberBtn_clicked(); void on_rememberBtn_clicked();
private: private:
Ui::DeletionConfirmationDialog *m_ui; Ui::DeletionConfirmationDialog *m_ui = nullptr;
}; };

View file

@ -53,6 +53,6 @@ private slots:
void downloadButtonClicked(); void downloadButtonClicked();
private: private:
Ui::DownloadFromURLDialog *m_ui; Ui::DownloadFromURLDialog *m_ui = nullptr;
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;
}; };

View file

@ -55,6 +55,6 @@ public:
private: private:
void displayContextMenu(const LogListView *view, const BaseLogModel *model) const; void displayContextMenu(const LogListView *view, const BaseLogModel *model) const;
Ui::ExecutionLogWidget *m_ui; Ui::ExecutionLogWidget *m_ui = nullptr;
LogFilterModel *m_messageFilterModel; LogFilterModel *m_messageFilterModel = nullptr;
}; };

View file

@ -46,8 +46,8 @@ namespace
{ {
struct TrStringWithComment struct TrStringWithComment
{ {
const char *source; const char *source = nullptr;
const char *comment; const char *comment = nullptr;
QString tr() const QString tr() const
{ {
@ -76,15 +76,15 @@ class FileSystemPathEdit::FileSystemPathEditPrivate
void browseActionTriggered(); void browseActionTriggered();
QString dialogCaptionOrDefault() const; QString dialogCaptionOrDefault() const;
FileSystemPathEdit *q_ptr; FileSystemPathEdit *q_ptr = nullptr;
std::unique_ptr<Private::FileEditorWithCompletion> m_editor; std::unique_ptr<Private::FileEditorWithCompletion> m_editor;
QAction *m_browseAction; QAction *m_browseAction = nullptr;
QToolButton *m_browseBtn; QToolButton *m_browseBtn = nullptr;
QString m_fileNameFilter; QString m_fileNameFilter;
Mode m_mode; Mode m_mode;
Path m_lastSignaledPath; Path m_lastSignaledPath;
QString m_dialogCaption; QString m_dialogCaption;
Private::FileSystemPathValidator *m_validator; Private::FileSystemPathValidator *m_validator = nullptr;
}; };
FileSystemPathEdit::FileSystemPathEditPrivate::FileSystemPathEditPrivate( FileSystemPathEdit::FileSystemPathEditPrivate::FileSystemPathEditPrivate(

View file

@ -111,7 +111,7 @@ private:
QWidget *editWidgetImpl() const; QWidget *editWidgetImpl() const;
FileSystemPathEditPrivate *d_ptr; FileSystemPathEditPrivate *d_ptr = nullptr;
}; };
/// Widget which uses QLineEdit for path editing /// Widget which uses QLineEdit for path editing

View file

@ -138,11 +138,11 @@ namespace Private
static QString warningText(FileSystemPathValidator::TestResult r); static QString warningText(FileSystemPathValidator::TestResult r);
void showCompletionPopup(); void showCompletionPopup();
QFileSystemModel *m_completerModel; QFileSystemModel *m_completerModel = nullptr;
QCompleter *m_completer; QCompleter *m_completer = nullptr;
QAction *m_browseAction; QAction *m_browseAction = nullptr;
QAction *m_warningAction = nullptr;
QFileIconProvider m_iconProvider; QFileIconProvider m_iconProvider;
QAction *m_warningAction;
}; };
class FileComboEdit final : public QComboBox, public FileEditorWithCompletion class FileComboEdit final : public QComboBox, public FileEditorWithCompletion

View file

@ -56,10 +56,10 @@ private slots:
void on_txtIPSubnet_textChanged(const QString &subnetStr); void on_txtIPSubnet_textChanged(const QString &subnetStr);
private: private:
Ui::IPSubnetWhitelistOptionsDialog *m_ui; Ui::IPSubnetWhitelistOptionsDialog *m_ui = nullptr;
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;
QStringListModel *m_model; QStringListModel *m_model = nullptr;
QSortFilterProxyModel *m_sortFilter; QSortFilterProxyModel *m_sortFilter = nullptr;
bool m_modified = false; bool m_modified = false;
}; };

View file

@ -26,5 +26,5 @@ protected:
void keyPressEvent(QKeyEvent *event) override; void keyPressEvent(QKeyEvent *event) override;
private: private:
QToolButton *m_searchButton; QToolButton *m_searchButton = nullptr;
}; };

View file

@ -1762,7 +1762,7 @@ void MainWindow::createTrayIcon(const int retries)
if (retries > 0) if (retries > 0)
{ {
LogMsg(tr("System tray icon is not available, retrying..."), Log::WARNING); LogMsg(tr("System tray icon is not available, retrying..."), Log::WARNING);
QTimer::singleShot(std::chrono::seconds(2), this, [this, retries]() QTimer::singleShot(2s, this, [this, retries]()
{ {
if (Preferences::instance()->systemTrayEnabled()) if (Preferences::instance()->systemTrayEnabled())
createTrayIcon(retries - 1); createTrayIcon(retries - 1);

View file

@ -219,9 +219,9 @@ private:
void showStatusBar(bool show); void showStatusBar(bool show);
void showFiltersSidebar(bool show); void showFiltersSidebar(bool show);
Ui::MainWindow *m_ui; Ui::MainWindow *m_ui = nullptr;
QFileSystemWatcher *m_executableWatcher; QFileSystemWatcher *m_executableWatcher = nullptr;
// GUI related // GUI related
bool m_posInitialized = false; bool m_posInitialized = false;
QPointer<QTabWidget> m_tabs; QPointer<QTabWidget> m_tabs;
@ -237,27 +237,27 @@ private:
#endif #endif
QPointer<QMenu> m_trayIconMenu; QPointer<QMenu> m_trayIconMenu;
TransferListWidget *m_transferListWidget; TransferListWidget *m_transferListWidget = nullptr;
TransferListFiltersWidget *m_transferListFiltersWidget = nullptr; TransferListFiltersWidget *m_transferListFiltersWidget = nullptr;
PropertiesWidget *m_propertiesWidget; PropertiesWidget *m_propertiesWidget = nullptr;
bool m_displaySpeedInTitle; bool m_displaySpeedInTitle = false;
bool m_forceExit = false; bool m_forceExit = false;
bool m_uiLocked; bool m_uiLocked = false;
bool m_unlockDlgShowing = false; bool m_unlockDlgShowing = false;
LineEdit *m_searchFilter; LineEdit *m_searchFilter = nullptr;
QAction *m_searchFilterAction; QAction *m_searchFilterAction = nullptr;
// Widgets // Widgets
QAction *m_queueSeparator; QAction *m_queueSeparator = nullptr;
QAction *m_queueSeparatorMenu; QAction *m_queueSeparatorMenu = nullptr;
QSplitter *m_splitter; QSplitter *m_splitter = nullptr;
QPointer<SearchWidget> m_searchWidget; QPointer<SearchWidget> m_searchWidget;
QPointer<RSSWidget> m_rssWidget; QPointer<RSSWidget> m_rssWidget;
QPointer<ExecutionLogWidget> m_executionLog; QPointer<ExecutionLogWidget> m_executionLog;
// Power Management // Power Management
PowerManagement *m_pwr; PowerManagement *m_pwr = nullptr;
QTimer *m_preventTimer; QTimer *m_preventTimer = nullptr;
bool m_hasPython = false; bool m_hasPython = false;
QMenu *m_toolbarMenu; QMenu *m_toolbarMenu = nullptr;
SettingValue<bool> m_storeExecutionLogEnabled; SettingValue<bool> m_storeExecutionLogEnabled;
SettingValue<bool> m_storeDownloadTrackerFavicon; SettingValue<bool> m_storeDownloadTrackerFavicon;

View file

@ -177,14 +177,14 @@ private:
bool schedTimesOk(); bool schedTimesOk();
Ui::OptionsDialog *m_ui; Ui::OptionsDialog *m_ui = nullptr;
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;
SettingValue<QStringList> m_storeHSplitterSize; SettingValue<QStringList> m_storeHSplitterSize;
SettingValue<int> m_storeLastViewedPage; SettingValue<int> m_storeLastViewedPage;
QPushButton *m_applyButton; QPushButton *m_applyButton = nullptr;
AdvancedSettings *m_advancedSettings; AdvancedSettings *m_advancedSettings = nullptr;
bool m_refreshingIpFilter = false; bool m_refreshingIpFilter = false;
}; };

View file

@ -58,7 +58,7 @@ private:
bool m_busy = false; bool m_busy = false;
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB) #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
PowerManagementInhibitor *m_inhibitor; PowerManagementInhibitor *m_inhibitor = nullptr;
#endif #endif
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
IOPMAssertionID m_assertionID; IOPMAssertionID m_assertionID;

View file

@ -78,10 +78,10 @@ private:
void loadWindowState(); void loadWindowState();
void saveWindowState(); void saveWindowState();
Ui::PreviewSelectDialog *m_ui; Ui::PreviewSelectDialog *m_ui = nullptr;
QStandardItemModel *m_previewListModel; QStandardItemModel *m_previewListModel = nullptr;
PreviewListDelegate *m_listDelegate; PreviewListDelegate *m_listDelegate = nullptr;
const BitTorrent::Torrent *m_torrent; const BitTorrent::Torrent *m_torrent = nullptr;
bool m_headerStateInitialized = false; bool m_headerStateInitialized = false;
// Settings // Settings

View file

@ -53,6 +53,6 @@ protected slots:
void validateInput(); void validateInput();
private: private:
Ui::PeersAdditionDialog *m_ui; Ui::PeersAdditionDialog *m_ui = nullptr;
QVector<BitTorrent::PeerAddress> m_peersList; QVector<BitTorrent::PeerAddress> m_peersList;
}; };

View file

@ -73,8 +73,6 @@
PropertiesWidget::PropertiesWidget(QWidget *parent) PropertiesWidget::PropertiesWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, m_ui(new Ui::PropertiesWidget()) , m_ui(new Ui::PropertiesWidget())
, m_torrent(nullptr)
, m_handleWidth(-1)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
setAutoFillBackground(true); setAutoFillBackground(true);

View file

@ -112,18 +112,18 @@ private:
void openParentFolder(const QModelIndex &index) const; void openParentFolder(const QModelIndex &index) const;
Path getFullPath(const QModelIndex &index) const; Path getFullPath(const QModelIndex &index) const;
Ui::PropertiesWidget *m_ui; Ui::PropertiesWidget *m_ui = nullptr;
BitTorrent::Torrent *m_torrent; BitTorrent::Torrent *m_torrent = nullptr;
SlideState m_state; SlideState m_state;
TorrentContentFilterModel *m_propListModel; TorrentContentFilterModel *m_propListModel = nullptr;
PropListDelegate *m_propListDelegate; PropListDelegate *m_propListDelegate = nullptr;
PeerListWidget *m_peerList; PeerListWidget *m_peerList = nullptr;
TrackerListWidget *m_trackerList; TrackerListWidget *m_trackerList = nullptr;
QWidget *m_speedWidget = nullptr; QWidget *m_speedWidget = nullptr;
QList<int> m_slideSizes; QList<int> m_slideSizes;
DownloadedPiecesBar *m_downloadedPieces; DownloadedPiecesBar *m_downloadedPieces = nullptr;
PieceAvailabilityBar *m_piecesAvailability; PieceAvailabilityBar *m_piecesAvailability = nullptr;
PropTabBar *m_tabBar; PropTabBar *m_tabBar = nullptr;
LineEdit *m_contentFilterLine; LineEdit *m_contentFilterLine = nullptr;
int m_handleWidth; int m_handleWidth = -1;
}; };

View file

@ -69,6 +69,6 @@ signals:
void filteredFilesChanged() const; void filteredFilesChanged() const;
private: private:
PropertiesWidget *m_properties; PropertiesWidget *m_properties = nullptr;
ProgressBarPainter m_progressBarPainter; ProgressBarPainter m_progressBarPainter;
}; };

View file

@ -38,7 +38,6 @@
PropTabBar::PropTabBar(QWidget *parent) PropTabBar::PropTabBar(QWidget *parent)
: QHBoxLayout(parent) : QHBoxLayout(parent)
, m_currentIndex(-1)
{ {
setAlignment(Qt::AlignLeft | Qt::AlignCenter); setAlignment(Qt::AlignLeft | Qt::AlignCenter);
setSpacing(3); setSpacing(3);

View file

@ -60,6 +60,6 @@ public slots:
void setCurrentIndex(int index); void setCurrentIndex(int index);
private: private:
QButtonGroup *m_btnGroup; QButtonGroup *m_btnGroup = nullptr;
int m_currentIndex; int m_currentIndex = -1;
}; };

View file

@ -267,7 +267,7 @@ quint64 SpeedPlotView::maxYValue() const
if (!m_properties[static_cast<GraphID>(id)].enable) if (!m_properties[static_cast<GraphID>(id)].enable)
continue; continue;
milliseconds duration {0ms}; milliseconds duration {0};
for (int i = static_cast<int>(queue.size()) - 1; i >= 0; --i) for (int i = static_cast<int>(queue.size()) - 1; i >= 0; --i)
{ {
maxYValue = std::max(maxYValue, queue[i].data[id]); maxYValue = std::max(maxYValue, queue[i].data[id]);
@ -360,7 +360,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
continue; continue;
QVector<QPoint> points; QVector<QPoint> points;
milliseconds duration {0ms}; milliseconds duration {0};
for (int i = static_cast<int>(queue.size()) - 1; i >= 0; --i) for (int i = static_cast<int>(queue.size()) - 1; i >= 0; --i)
{ {

View file

@ -111,7 +111,7 @@ private:
private: private:
const milliseconds m_resolution; const milliseconds m_resolution;
const milliseconds m_maxDuration; const milliseconds m_maxDuration;
milliseconds m_currentDuration {0ms}; milliseconds m_currentDuration {0};
int m_counter = 0; int m_counter = 0;
SampleData m_accumulator {}; SampleData m_accumulator {};
DataCircularBuffer m_sink {}; DataCircularBuffer m_sink {};

View file

@ -32,7 +32,6 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLabel> #include <QLabel>
#include <QMenu> #include <QMenu>
#include <QTimer>
#include <QVBoxLayout> #include <QVBoxLayout>
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"

View file

@ -49,7 +49,7 @@ public:
void showPopup() override; void showPopup() override;
private: private:
QMenu *m_menu; QMenu *m_menu = nullptr;
}; };
@ -71,13 +71,13 @@ private:
void loadSettings(); void loadSettings();
void saveSettings() const; void saveSettings() const;
QVBoxLayout *m_layout; QVBoxLayout *m_layout = nullptr;
QHBoxLayout *m_hlayout; QHBoxLayout *m_hlayout = nullptr;
QLabel *m_periodLabel; QLabel *m_periodLabel = nullptr;
QComboBox *m_periodCombobox; QComboBox *m_periodCombobox = nullptr;
SpeedPlotView *m_plot; SpeedPlotView *m_plot = nullptr;
ComboBoxMenuButton *m_graphsButton; ComboBoxMenuButton *m_graphsButton = nullptr;
QMenu *m_graphsMenu; QMenu *m_graphsMenu = nullptr;
QList<QAction *> m_graphsMenuActions; QList<QAction *> m_graphsMenuActions;
}; };

View file

@ -91,9 +91,9 @@ private:
static QStringList headerLabels(); static QStringList headerLabels();
PropertiesWidget *m_properties; PropertiesWidget *m_properties = nullptr;
QHash<QString, QTreeWidgetItem *> m_trackerItems; QHash<QString, QTreeWidgetItem *> m_trackerItems;
QTreeWidgetItem *m_DHTItem; QTreeWidgetItem *m_DHTItem = nullptr;
QTreeWidgetItem *m_PEXItem; QTreeWidgetItem *m_PEXItem = nullptr;
QTreeWidgetItem *m_LSDItem; QTreeWidgetItem *m_LSDItem = nullptr;
}; };

View file

@ -65,6 +65,6 @@ public slots:
void torrentListDownloadFinished(const Net::DownloadResult &result); void torrentListDownloadFinished(const Net::DownloadResult &result);
private: private:
Ui::TrackersAdditionDialog *m_ui; Ui::TrackersAdditionDialog *m_ui = nullptr;
BitTorrent::Torrent *const m_torrent; BitTorrent::Torrent *const m_torrent = nullptr;
}; };

View file

@ -101,12 +101,12 @@ private:
const QString m_formatFilterJSON; const QString m_formatFilterJSON;
const QString m_formatFilterLegacy; const QString m_formatFilterLegacy;
Ui::AutomatedRssDownloader *m_ui; Ui::AutomatedRssDownloader *m_ui = nullptr;
QListWidgetItem *m_currentRuleItem; QListWidgetItem *m_currentRuleItem = nullptr;
QSet<std::pair<QString, QString>> m_treeListEntries; QSet<std::pair<QString, QString>> m_treeListEntries;
RSS::AutoDownloadRule m_currentRule; RSS::AutoDownloadRule m_currentRule;
QHash<QString, QListWidgetItem *> m_itemsByRuleName; QHash<QString, QListWidgetItem *> m_itemsByRuleName;
QRegularExpression *m_episodeRegex; QRegularExpression *m_episodeRegex = nullptr;
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;
SettingValue<QByteArray> m_storeHSplitterSize; SettingValue<QByteArray> m_storeHSplitterSize;

View file

@ -71,5 +71,5 @@ private:
void fill(QTreeWidgetItem *parent, RSS::Folder *rssParent); void fill(QTreeWidgetItem *parent, RSS::Folder *rssParent);
QHash<RSS::Item *, QTreeWidgetItem *> m_rssToTreeItemMapping; QHash<RSS::Item *, QTreeWidgetItem *> m_rssToTreeItemMapping;
QTreeWidgetItem *m_unreadStickyItem; QTreeWidgetItem *m_unreadStickyItem = nullptr;
}; };

View file

@ -47,8 +47,8 @@ public:
QVariant loadResource(int type, const QUrl &name) override; QVariant loadResource(int type, const QUrl &name) override;
protected: protected:
QNetworkAccessManager *m_netManager; QNetworkAccessManager *m_netManager = nullptr;
QNetworkDiskCache *m_diskCache; QNetworkDiskCache *m_diskCache = nullptr;
QHash<QUrl, bool> m_activeRequests; QHash<QUrl, bool> m_activeRequests;
protected slots: protected slots:

View file

@ -82,7 +82,7 @@ private slots:
void handleUnreadCountChanged(); void handleUnreadCountChanged();
private: private:
Ui::RSSWidget *m_ui; Ui::RSSWidget *m_ui = nullptr;
ArticleListWidget *m_articleListWidget; ArticleListWidget *m_articleListWidget = nullptr;
FeedListWidget *m_feedListWidget; FeedListWidget *m_feedListWidget = nullptr;
}; };

View file

@ -91,9 +91,9 @@ private:
void finishAsyncOp(); void finishAsyncOp();
void finishPluginUpdate(); void finishPluginUpdate();
Ui::PluginSelectDialog *m_ui; Ui::PluginSelectDialog *m_ui = nullptr;
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;
SearchPluginManager *m_pluginManager; SearchPluginManager *m_pluginManager = nullptr;
QStringList m_updatedPlugins; QStringList m_updatedPlugins;
int m_asyncOps = 0; int m_asyncOps = 0;
int m_pendingUpdates = 0; int m_pendingUpdates = 0;

View file

@ -55,6 +55,6 @@ private slots:
void on_urlButton_clicked(); void on_urlButton_clicked();
private: private:
Ui::PluginSourceDialog *m_ui; Ui::PluginSourceDialog *m_ui = nullptr;
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;
}; };

View file

@ -130,11 +130,11 @@ private:
static QString statusText(Status st); static QString statusText(Status st);
Ui::SearchJobWidget *m_ui; Ui::SearchJobWidget *m_ui = nullptr;
SearchHandler *m_searchHandler; SearchHandler *m_searchHandler = nullptr;
QStandardItemModel *m_searchListModel; QStandardItemModel *m_searchListModel = nullptr;
SearchSortModel *m_proxyModel; SearchSortModel *m_proxyModel = nullptr;
LineEdit *m_lineEditSearchResultsFilter; LineEdit *m_lineEditSearchResultsFilter = nullptr;
Status m_status = Status::Ongoing; Status m_status = Status::Ongoing;
bool m_noSearchResults = true; bool m_noSearchResults = true;

View file

@ -87,7 +87,6 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
: QWidget(mainWindow) : QWidget(mainWindow)
, m_ui(new Ui::SearchWidget()) , m_ui(new Ui::SearchWidget())
, m_mainWindow(mainWindow) , m_mainWindow(mainWindow)
, m_isNewQueryString(false)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->tabWidget->tabBar()->installEventFilter(this); m_ui->tabWidget->tabBar()->installEventFilter(this);

View file

@ -78,10 +78,10 @@ private:
QString selectedCategory() const; QString selectedCategory() const;
QString selectedPlugin() const; QString selectedPlugin() const;
Ui::SearchWidget *m_ui; Ui::SearchWidget *m_ui = nullptr;
QPointer<SearchJobWidget> m_currentSearchTab; // Selected tab QPointer<SearchJobWidget> m_currentSearchTab; // Selected tab
QPointer<SearchJobWidget> m_activeSearchTab; // Tab with running search QPointer<SearchJobWidget> m_activeSearchTab; // Tab with running search
QList<SearchJobWidget *> m_allTabs; // To store all tabs QList<SearchJobWidget *> m_allTabs; // To store all tabs
MainWindow *m_mainWindow; MainWindow *m_mainWindow = nullptr;
bool m_isNewQueryString; bool m_isNewQueryString = false;
}; };

View file

@ -29,6 +29,8 @@
#include "shutdownconfirmdialog.h" #include "shutdownconfirmdialog.h"
#include <chrono>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QIcon> #include <QIcon>
#include <QPushButton> #include <QPushButton>
@ -38,10 +40,11 @@
#include "ui_shutdownconfirmdialog.h" #include "ui_shutdownconfirmdialog.h"
#include "utils.h" #include "utils.h"
using namespace std::chrono_literals;
ShutdownConfirmDialog::ShutdownConfirmDialog(QWidget *parent, const ShutdownDialogAction &action) ShutdownConfirmDialog::ShutdownConfirmDialog(QWidget *parent, const ShutdownDialogAction &action)
: QDialog(parent) : QDialog(parent)
, m_ui(new Ui::ShutdownConfirmDialog) , m_ui(new Ui::ShutdownConfirmDialog)
, m_timeout(15)
, m_action(action) , m_action(action)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
@ -64,7 +67,7 @@ ShutdownConfirmDialog::ShutdownConfirmDialog(QWidget *parent, const ShutdownDial
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
move(Utils::Gui::screenCenter(this)); move(Utils::Gui::screenCenter(this));
m_timer.setInterval(1000); // 1sec m_timer.setInterval(1s);
connect(&m_timer, &QTimer::timeout, this, &ShutdownConfirmDialog::updateSeconds); connect(&m_timer, &QTimer::timeout, this, &ShutdownConfirmDialog::updateSeconds);
} }

View file

@ -62,9 +62,9 @@ private:
void updateText(); void updateText();
// Vars // Vars
Ui::ShutdownConfirmDialog *m_ui; Ui::ShutdownConfirmDialog *m_ui = nullptr;
QTimer m_timer; QTimer m_timer;
int m_timeout; int m_timeout = 15;
ShutdownDialogAction m_action; ShutdownDialogAction m_action;
QString m_msg; QString m_msg;
}; };

View file

@ -50,7 +50,7 @@ public slots:
void accept() override; void accept() override;
private: private:
Ui::SpeedLimitDialog *m_ui; Ui::SpeedLimitDialog *m_ui = nullptr;
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;
struct struct
{ {

View file

@ -48,5 +48,5 @@ public:
void setText(const QString &signalName, const QString &stacktrace); void setText(const QString &signalName, const QString &stacktrace);
private: private:
Ui::StacktraceDialog *m_ui; Ui::StacktraceDialog *m_ui = nullptr;
}; };

View file

@ -50,6 +50,6 @@ private slots:
void update(); void update();
private: private:
Ui::StatsDialog *m_ui; Ui::StatsDialog *m_ui = nullptr;
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;
}; };

View file

@ -64,9 +64,9 @@ private:
void updateDHTNodesNumber(); void updateDHTNodesNumber();
void updateSpeedLabels(); void updateSpeedLabels();
QPushButton *m_dlSpeedLbl; QPushButton *m_dlSpeedLbl = nullptr;
QPushButton *m_upSpeedLbl; QPushButton *m_upSpeedLbl = nullptr;
QLabel *m_DHTLbl; QLabel *m_DHTLbl = nullptr;
QPushButton *m_connecStatusLblIcon; QPushButton *m_connecStatusLblIcon = nullptr;
QPushButton *m_altSpeedsBtn; QPushButton *m_altSpeedsBtn = nullptr;
}; };

View file

@ -65,6 +65,6 @@ private slots:
void useDownloadPathChanged(int index); void useDownloadPathChanged(int index);
private: private:
Ui::TorrentCategoryDialog *m_ui; Ui::TorrentCategoryDialog *m_ui = nullptr;
Path m_lastEnteredDownloadPath; Path m_lastEnteredDownloadPath;
}; };

View file

@ -62,6 +62,6 @@ protected:
private: private:
bool hasFiltered(const QModelIndex &folder) const; bool hasFiltered(const QModelIndex &folder) const;
TorrentContentModel *m_model; TorrentContentModel *m_model = nullptr;
Utils::Compare::NaturalLessThan<Qt::CaseInsensitive> m_naturalLessThan; Utils::Compare::NaturalLessThan<Qt::CaseInsensitive> m_naturalLessThan;
}; };

View file

@ -438,7 +438,7 @@ QModelIndex TorrentContentModel::index(int row, int column, const QModelIndex &p
if (column >= TorrentContentModelItem::NB_COL) if (column >= TorrentContentModelItem::NB_COL)
return {}; return {};
TorrentContentModelFolder *parentItem; TorrentContentModelFolder *parentItem = nullptr;
if (!parent.isValid()) if (!parent.isValid())
parentItem = m_rootItem; parentItem = m_rootItem;
else else
@ -475,7 +475,7 @@ int TorrentContentModel::rowCount(const QModelIndex &parent) const
if (parent.column() > 0) if (parent.column() > 0)
return 0; return 0;
TorrentContentModelFolder *parentItem; TorrentContentModelFolder *parentItem = nullptr;
if (!parent.isValid()) if (!parent.isValid())
parentItem = m_rootItem; parentItem = m_rootItem;
else else

View file

@ -37,11 +37,6 @@
TorrentContentModelItem::TorrentContentModelItem(TorrentContentModelFolder *parent) TorrentContentModelItem::TorrentContentModelItem(TorrentContentModelFolder *parent)
: m_parentItem(parent) : m_parentItem(parent)
, m_size(0)
, m_remaining(0)
, m_priority(BitTorrent::DownloadPriority::Normal)
, m_progress(0)
, m_availability(-1.)
{ {
} }

View file

@ -84,14 +84,14 @@ public:
int row() const; int row() const;
protected: protected:
TorrentContentModelFolder *m_parentItem; TorrentContentModelFolder *m_parentItem = nullptr;
// Root item members // Root item members
QVector<QString> m_itemData; QVector<QString> m_itemData;
// Non-root item members // Non-root item members
QString m_name; QString m_name;
qulonglong m_size; qulonglong m_size = 0;
qulonglong m_remaining; qulonglong m_remaining = 0;
BitTorrent::DownloadPriority m_priority; BitTorrent::DownloadPriority m_priority = BitTorrent::DownloadPriority::Normal;
qreal m_progress; qreal m_progress = 0;
qreal m_availability; qreal m_availability = -1;
}; };

View file

@ -74,8 +74,8 @@ private:
int getPaddedFileSizeLimit() const; int getPaddedFileSizeLimit() const;
#endif #endif
Ui::TorrentCreatorDialog *m_ui; Ui::TorrentCreatorDialog *m_ui = nullptr;
BitTorrent::TorrentCreatorThread *m_creatorThread; BitTorrent::TorrentCreatorThread *m_creatorThread = nullptr;
// settings // settings
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;

View file

@ -75,7 +75,7 @@ private:
int getSeedingTime() const; int getSeedingTime() const;
QVector<BitTorrent::TorrentID> m_torrentIDs; QVector<BitTorrent::TorrentID> m_torrentIDs;
Ui::TorrentOptionsDialog *m_ui; Ui::TorrentOptionsDialog *m_ui = nullptr;
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;
QStringList m_categories; QStringList m_categories;
QString m_currentCategoriesString; QString m_currentCategoriesString;

View file

@ -59,6 +59,6 @@ private:
void saveSettings(); void saveSettings();
void loadSettings(); void loadSettings();
Ui::TrackerEntriesDialog *m_ui; Ui::TrackerEntriesDialog *m_ui = nullptr;
SettingValue<QSize> m_storeDialogSize; SettingValue<QSize> m_storeDialogSize;
}; };

View file

@ -66,7 +66,7 @@ public slots:
void toggleFilter(bool checked); void toggleFilter(bool checked);
protected: protected:
TransferListWidget *transferList; TransferListWidget *transferList = nullptr;
private slots: private slots:
virtual void showMenu() = 0; virtual void showMenu() = 0;
@ -190,8 +190,8 @@ private:
void toggleCategoryFilter(bool enabled); void toggleCategoryFilter(bool enabled);
void toggleTagFilter(bool enabled); void toggleTagFilter(bool enabled);
TransferListWidget *m_transferList; TransferListWidget *m_transferList = nullptr;
TrackerFiltersList *m_trackerFilters; TrackerFiltersList *m_trackerFilters = nullptr;
CategoryFilterWidget *m_categoryFilterWidget; CategoryFilterWidget *m_categoryFilterWidget = nullptr;
TagFilterWidget *m_tagFilterWidget; TagFilterWidget *m_tagFilterWidget = nullptr;
}; };

View file

@ -216,7 +216,7 @@ int TransferListModel::columnCount(const QModelIndex &) const
return NB_COLUMNS; return NB_COLUMNS;
} }
QVariant TransferListModel::headerData(int section, Qt::Orientation orientation, int role) const QVariant TransferListModel::headerData(const int section, const Qt::Orientation orientation, const int role) const
{ {
if (orientation == Qt::Horizontal) if (orientation == Qt::Horizontal)
{ {
@ -289,7 +289,7 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation,
} }
} }
return {}; return QAbstractListModel::headerData(section, orientation, role);
} }
QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, const int column) const QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, const int column) const
@ -591,8 +591,11 @@ QVariant TransferListModel::data(const QModelIndex &index, const int role) const
case TR_QUEUE_POSITION: case TR_QUEUE_POSITION:
case TR_LAST_ACTIVITY: case TR_LAST_ACTIVITY:
case TR_AVAILABILITY: case TR_AVAILABILITY:
return QVariant {Qt::AlignRight | Qt::AlignVCenter}; return QVariant(Qt::AlignRight | Qt::AlignVCenter);
} }
break;
default:
break;
} }
return {}; return {};

View file

@ -131,7 +131,7 @@ private:
QVector<BitTorrent::Torrent *> getVisibleTorrents() const; QVector<BitTorrent::Torrent *> getVisibleTorrents() const;
int visibleColumnsCount() const; int visibleColumnsCount() const;
TransferListModel *m_listModel; TransferListModel *m_listModel = nullptr;
TransferListSortModel *m_sortFilterModel; TransferListSortModel *m_sortFilterModel = nullptr;
MainWindow *m_mainWindow; MainWindow *m_mainWindow = nullptr;
}; };

View file

@ -54,5 +54,5 @@ public:
void setCloseOnInteraction(bool enabled); void setCloseOnInteraction(bool enabled);
private: private:
TriStateWidget *m_triStateWidget; TriStateWidget *m_triStateWidget = nullptr;
}; };

View file

@ -57,7 +57,7 @@ private:
void onTMMChanged(int index); void onTMMChanged(int index);
void onCategoryChanged(int index); void onCategoryChanged(int index);
Ui::WatchedFolderOptionsDialog *m_ui; Ui::WatchedFolderOptionsDialog *m_ui = nullptr;
Path m_savePath; Path m_savePath;
Path m_downloadPath; Path m_downloadPath;
bool m_useDownloadPath = false; bool m_useDownloadPath = false;

View file

@ -62,7 +62,7 @@ private:
void onFolderSet(const Path &path, const TorrentFilesWatcher::WatchedFolderOptions &options); void onFolderSet(const Path &path, const TorrentFilesWatcher::WatchedFolderOptions &options);
void onFolderRemoved(const Path &path); void onFolderRemoved(const Path &path);
TorrentFilesWatcher *m_fsWatcher; TorrentFilesWatcher *m_fsWatcher = nullptr;
PathList m_watchedFolders; PathList m_watchedFolders;
QHash<Path, TorrentFilesWatcher::WatchedFolderOptions> m_watchedFoldersOptions; QHash<Path, TorrentFilesWatcher::WatchedFolderOptions> m_watchedFoldersOptions;
QSet<Path> m_deletedFolders; QSet<Path> m_deletedFolders;

View file

@ -31,6 +31,7 @@
#include "appcontroller.h" #include "appcontroller.h"
#include <algorithm> #include <algorithm>
#include <chrono>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDebug> #include <QDebug>
@ -62,6 +63,8 @@
#include "base/version.h" #include "base/version.h"
#include "../webapplication.h" #include "../webapplication.h"
using namespace std::chrono_literals;
void AppController::webapiVersionAction() void AppController::webapiVersionAction()
{ {
setResult(API_VERSION.toString()); setResult(API_VERSION.toString());
@ -93,7 +96,7 @@ void AppController::shutdownAction()
// Special case handling for shutdown, we // Special case handling for shutdown, we
// need to reply to the Web UI before // need to reply to the Web UI before
// actually shutting down. // actually shutting down.
QTimer::singleShot(100, qApp, &QCoreApplication::quit); QTimer::singleShot(100ms, qApp, &QCoreApplication::quit);
} }
void AppController::preferencesAction() void AppController::preferencesAction()