Browse Source

Fix coding style for various things

adaptive-webui-19844
thalieht 6 years ago
parent
commit
d668a4fe6d
  1. 2
      src/app/cmdoptions.cpp
  2. 2
      src/app/main.cpp
  3. 2
      src/app/upgrade.h
  4. 42
      src/base/bittorrent/session.cpp
  5. 2
      src/base/bittorrent/session.h
  6. 4
      src/base/bittorrent/torrenthandle.cpp
  7. 2
      src/base/bittorrent/torrentinfo.cpp
  8. 4
      src/base/http/types.h
  9. 2
      src/base/net/smtp.cpp
  10. 8
      src/base/preferences.cpp
  11. 2
      src/base/preferences.h
  12. 18
      src/base/rss/private/rss_parser.cpp
  13. 2
      src/base/rss/rss_autodownloader.cpp
  14. 6
      src/base/rss/rss_autodownloadrule.cpp
  15. 4
      src/base/rss/rss_folder.cpp
  16. 2
      src/base/utils/foreignapps.cpp
  17. 6
      src/base/utils/fs.cpp
  18. 2
      src/base/utils/misc.cpp
  19. 2
      src/base/utils/misc.h
  20. 2
      src/gui/advancedsettings.cpp
  21. 2
      src/gui/fspathedit.cpp
  22. 8
      src/gui/mainwindow.cpp
  23. 36
      src/gui/optionsdialog.cpp
  24. 9
      src/gui/optionsdialog.h
  25. 2
      src/gui/programupdater.cpp
  26. 6
      src/gui/properties/peerlistwidget.cpp
  27. 2
      src/gui/properties/piecesbar.cpp
  28. 2
      src/gui/search/searchsortmodel.cpp
  29. 4
      src/gui/torrentcontentmodel.cpp
  30. 4
      src/gui/torrentcontentmodel.h
  31. 4
      src/gui/transferlistfilterswidget.cpp
  32. 2
      src/gui/transferlistmodel.h
  33. 26
      src/gui/transferlistwidget.cpp
  34. 2
      src/gui/transferlistwidget.h

2
src/app/cmdoptions.cpp

@ -486,7 +486,7 @@ CommandLineParameterError::CommandLineParameterError(const QString &messageForUs @@ -486,7 +486,7 @@ CommandLineParameterError::CommandLineParameterError(const QString &messageForUs
{
}
const QString& CommandLineParameterError::messageForUser() const
const QString &CommandLineParameterError::messageForUser() const
{
return m_messageForUser;
}

2
src/app/main.cpp

@ -202,7 +202,7 @@ int main(int argc, char *argv[]) @@ -202,7 +202,7 @@ int main(int argc, char *argv[])
// this is the default in Qt6
app->setAttribute(Qt::AA_DisableWindowContextHelpButton);
#endif
#endif
#endif // Q_OS_WIN
#if defined(Q_OS_MAC)
// Since Apple made difficult for users to set PATH, we set here for convenience.

2
src/app/upgrade.h

@ -83,7 +83,7 @@ bool userAcceptsUpgrade() @@ -83,7 +83,7 @@ bool userAcceptsUpgrade()
msgBox.move(Utils::Misc::screenCenter(&msgBox));
if (msgBox.exec() == QMessageBox::Ok)
return true;
#endif
#endif // DISABLE_GUI
return false;
}

42
src/base/bittorrent/session.cpp

@ -469,7 +469,7 @@ Session::Session(QObject *parent) @@ -469,7 +469,7 @@ Session::Session(QObject *parent)
});
configurePeerClasses();
#endif
#endif // LIBTORRENT_VERSION_NUM < 10100
// Enabling plugins
//m_nativeSession->add_extension(&libt::create_metadata_plugin);
@ -1253,7 +1253,7 @@ void Session::configure(libtorrent::settings_pack &settingsPack) @@ -1253,7 +1253,7 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
}
#else
settingsPack.set_str(libt::settings_pack::outgoing_interfaces, networkInterface().toStdString());
#endif
#endif // Q_OS_WIN
m_listenInterfaceChanged = false;
}
@ -1462,7 +1462,7 @@ void Session::configurePeerClasses() @@ -1462,7 +1462,7 @@ void Session::configurePeerClasses()
, 1 << libt::session::global_peer_class_id);
}
catch (std::exception &) {}
#endif
#endif // TORRENT_USE_IPV6
if (ignoreLimitsOnLAN()) {
// local networks
f.add_rule(libt::address_v4::from_string("10.0.0.0")
@ -1501,7 +1501,7 @@ void Session::configurePeerClasses() @@ -1501,7 +1501,7 @@ void Session::configurePeerClasses()
, 1 << libt::session::local_peer_class_id);
}
catch (std::exception &) {}
#endif
#endif // TORRENT_USE_IPV6
}
m_nativeSession->set_peer_class_filter(f);
@ -1518,7 +1518,7 @@ void Session::configurePeerClasses() @@ -1518,7 +1518,7 @@ void Session::configurePeerClasses()
m_nativeSession->set_peer_class_type_filter(peerClassTypeFilter);
}
#else
#else // LIBTORRENT_VERSION_NUM >= 10100
void Session::adjustLimits(libt::session_settings &sessionSettings)
{
@ -1735,7 +1735,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings) @@ -1735,7 +1735,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings)
break;
}
}
#endif
#endif // LIBTORRENT_VERSION_NUM >= 10100
void Session::enableTracker(bool enable)
{
@ -1983,8 +1983,8 @@ void Session::increaseTorrentsPriority(const QStringList &hashes) @@ -1983,8 +1983,8 @@ void Session::increaseTorrentsPriority(const QStringList &hashes)
std::greater<QPair<int, TorrentHandle *>>> torrentQueue;
// Sort torrents by priority
foreach (const InfoHash &hash, hashes) {
TorrentHandle *const torrent = m_torrents.value(hash);
foreach (const InfoHash &infoHash, hashes) {
TorrentHandle *const torrent = m_torrents.value(infoHash);
if (torrent && !torrent->isSeed())
torrentQueue.push(qMakePair(torrent->queuePosition(), torrent));
}
@ -2006,8 +2006,8 @@ void Session::decreaseTorrentsPriority(const QStringList &hashes) @@ -2006,8 +2006,8 @@ void Session::decreaseTorrentsPriority(const QStringList &hashes)
std::less<QPair<int, TorrentHandle *>>> torrentQueue;
// Sort torrents by priority
foreach (const InfoHash &hash, hashes) {
TorrentHandle *const torrent = m_torrents.value(hash);
foreach (const InfoHash &infoHash, hashes) {
TorrentHandle *const torrent = m_torrents.value(infoHash);
if (torrent && !torrent->isSeed())
torrentQueue.push(qMakePair(torrent->queuePosition(), torrent));
}
@ -2032,8 +2032,8 @@ void Session::topTorrentsPriority(const QStringList &hashes) @@ -2032,8 +2032,8 @@ void Session::topTorrentsPriority(const QStringList &hashes)
std::greater<QPair<int, TorrentHandle *>>> torrentQueue;
// Sort torrents by priority
foreach (const InfoHash &hash, hashes) {
TorrentHandle *const torrent = m_torrents.value(hash);
foreach (const InfoHash &infoHash, hashes) {
TorrentHandle *const torrent = m_torrents.value(infoHash);
if (torrent && !torrent->isSeed())
torrentQueue.push(qMakePair(torrent->queuePosition(), torrent));
}
@ -2055,8 +2055,8 @@ void Session::bottomTorrentsPriority(const QStringList &hashes) @@ -2055,8 +2055,8 @@ void Session::bottomTorrentsPriority(const QStringList &hashes)
std::less<QPair<int, TorrentHandle *>>> torrentQueue;
// Sort torrents by priority
foreach (const InfoHash &hash, hashes) {
TorrentHandle *const torrent = m_torrents.value(hash);
foreach (const InfoHash &infoHash, hashes) {
TorrentHandle *const torrent = m_torrents.value(infoHash);
if (torrent && !torrent->isSeed())
torrentQueue.push(qMakePair(torrent->queuePosition(), torrent));
}
@ -2397,7 +2397,7 @@ void Session::saveResumeData() @@ -2397,7 +2397,7 @@ void Session::saveResumeData()
break;
}
for (const auto a: alerts) {
for (const auto a : alerts) {
switch (a->type()) {
case libt::save_resume_data_failed_alert::alert_type:
case libt::save_resume_data_alert::alert_type:
@ -2598,7 +2598,7 @@ void Session::configureListeningInterface() @@ -2598,7 +2598,7 @@ void Session::configureListeningInterface()
#else
m_listenInterfaceChanged = true;
configureDeferred();
#endif
#endif // LIBTORRENT_VERSION_NUM < 10100
}
int Session::globalDownloadSpeedLimit() const
@ -3011,7 +3011,7 @@ void Session::setMaxConnectionsPerTorrent(int max) @@ -3011,7 +3011,7 @@ void Session::setMaxConnectionsPerTorrent(int max)
m_maxConnectionsPerTorrent = max;
// Apply this to all session torrents
for (const auto &handle: m_nativeSession->get_torrents()) {
for (const auto &handle : m_nativeSession->get_torrents()) {
if (!handle.is_valid()) continue;
try {
handle.set_max_connections(max);
@ -3033,7 +3033,7 @@ void Session::setMaxUploadsPerTorrent(int max) @@ -3033,7 +3033,7 @@ void Session::setMaxUploadsPerTorrent(int max)
m_maxUploadsPerTorrent = max;
// Apply this to all session torrents
for (const auto &handle: m_nativeSession->get_torrents()) {
for (const auto &handle : m_nativeSession->get_torrents()) {
if (!handle.is_valid()) continue;
try {
handle.set_max_uploads(max);
@ -4095,7 +4095,7 @@ void Session::readAlerts() @@ -4095,7 +4095,7 @@ void Session::readAlerts()
std::vector<libt::alert *> alerts;
getPendingAlerts(alerts);
for (const auto a: alerts) {
for (const auto a : alerts) {
handleAlert(a);
#if LIBTORRENT_VERSION_NUM < 10100
delete a;
@ -4502,7 +4502,7 @@ void Session::handleSessionStatsAlert(libt::session_stats_alert *p) @@ -4502,7 +4502,7 @@ void Session::handleSessionStatsAlert(libt::session_stats_alert *p)
emit statsUpdated();
}
#else
#else // LIBTORRENT_VERSION_NUM >= 10100
void Session::updateStats()
{
libt::session_status ss = m_nativeSession->status();
@ -4539,7 +4539,7 @@ void Session::updateStats() @@ -4539,7 +4539,7 @@ void Session::updateStats()
emit statsUpdated();
}
#endif
#endif // LIBTORRENT_VERSION_NUM >= 10100
void Session::handleStateUpdateAlert(libt::state_update_alert *p)
{

2
src/base/bittorrent/session.h

@ -237,7 +237,7 @@ namespace BitTorrent @@ -237,7 +237,7 @@ namespace BitTorrent
int diskJobTime = 0;
} disk;
};
#endif
#endif // LIBTORRENT_VERSION_NUM >= 10100
class Session : public QObject
{

4
src/base/bittorrent/torrenthandle.cpp

@ -158,14 +158,14 @@ namespace @@ -158,14 +158,14 @@ namespace
{
// new constructor is available
template<typename T, typename std::enable_if<std::is_constructible<T, libt::torrent_info, bool>::value, int>::type = 0>
T makeTorrentCreator(const libtorrent::torrent_info & ti)
T makeTorrentCreator(const libtorrent::torrent_info &ti)
{
return T(ti, true);
}
// new constructor isn't available
template<typename T, typename std::enable_if<!std::is_constructible<T, libt::torrent_info, bool>::value, int>::type = 0>
T makeTorrentCreator(const libtorrent::torrent_info & ti)
T makeTorrentCreator(const libtorrent::torrent_info &ti)
{
return T(ti);
}

2
src/base/bittorrent/torrentinfo.cpp

@ -350,7 +350,7 @@ void TorrentInfo::renameFile(const int index, const QString &newPath) @@ -350,7 +350,7 @@ void TorrentInfo::renameFile(const int index, const QString &newPath)
nativeInfo()->rename_file(index, Utils::Fs::toNativePath(newPath).toStdString());
}
int BitTorrent::TorrentInfo::fileIndex(const QString& fileName) const
int BitTorrent::TorrentInfo::fileIndex(const QString &fileName) const
{
// the check whether the object is valid is not needed here
// because if filesCount() returns -1 the loop exits immediately

4
src/base/http/types.h

@ -107,7 +107,7 @@ namespace Http @@ -107,7 +107,7 @@ namespace Http
uint code;
QString text;
ResponseStatus(uint code = 200, const QString& text = "OK"): code(code), text(text) {}
ResponseStatus(uint code = 200, const QString &text = "OK"): code(code), text(text) {}
};
struct Response
@ -116,7 +116,7 @@ namespace Http @@ -116,7 +116,7 @@ namespace Http
QStringMap headers;
QByteArray content;
Response(uint code = 200, const QString& text = "OK"): status(code, text) {}
Response(uint code = 200, const QString &text = "OK"): status(code, text) {}
};
}

2
src/base/net/smtp.cpp

@ -291,7 +291,7 @@ QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, QTex @@ -291,7 +291,7 @@ QByteArray Smtp::encodeMimeHeader(const QString &key, const QString &value, QTex
if (!prefix.isEmpty()) line += prefix;
if (!value.contains("=?") && latin1->canEncode(value)) {
bool firstWord = true;
foreach (const QByteArray& word, value.toLatin1().split(' ')) {
foreach (const QByteArray &word, value.toLatin1().split(' ')) {
if (line.size() > 78) {
rv = rv + line + "\r\n";
line.clear();

8
src/base/preferences.cpp

@ -212,7 +212,7 @@ void Preferences::setCloseToTrayNotified(bool b) @@ -212,7 +212,7 @@ void Preferences::setCloseToTrayNotified(bool b)
{
setValue("Preferences/General/CloseToTrayNotified", b);
}
#endif
#endif // Q_OS_MAC
bool Preferences::isToolbarDisplayed() const
{
@ -293,7 +293,7 @@ void Preferences::setWinStartup(bool b) @@ -293,7 +293,7 @@ void Preferences::setWinStartup(bool b)
settings.remove("qBittorrent");
}
}
#endif
#endif // Q_OS_WIN
// Downloads
QString Preferences::lastLocationPath() const
@ -967,7 +967,7 @@ void Preferences::setMagnetLinkAssoc(bool set) @@ -967,7 +967,7 @@ void Preferences::setMagnetLinkAssoc(bool set)
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
}
#endif
#endif // Q_OS_WIN
#ifdef Q_OS_MAC
namespace
@ -1023,7 +1023,7 @@ void Preferences::setMagnetLinkAssoc() @@ -1023,7 +1023,7 @@ void Preferences::setMagnetLinkAssoc()
CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId);
}
#endif
#endif // Q_OS_MAC
int Preferences::getTrackerPort() const
{

2
src/base/preferences.h

@ -299,7 +299,7 @@ public: @@ -299,7 +299,7 @@ public:
void setCloseToTrayNotified(bool b);
TrayIcon::Style trayIconStyle() const;
void setTrayIconStyle(TrayIcon::Style style);
#endif
#endif // Q_OS_MAC
// Stuff that don't appear in the Options GUI but are saved
// in the same file.

18
src/base/rss/private/rss_parser.cpp

@ -439,9 +439,9 @@ namespace @@ -439,9 +439,9 @@ namespace
int dayOfWeek = -1;
if (!parts[nwday].isEmpty()) {
// Look up the weekday name
while (++dayOfWeek < 7 && (shortDay[dayOfWeek] != parts[nwday]));
while ((++dayOfWeek < 7) && (shortDay[dayOfWeek] != parts[nwday]));
if (dayOfWeek >= 7)
for (dayOfWeek = 0; dayOfWeek < 7 && (longDay[dayOfWeek] != parts[nwday]); ++dayOfWeek);
for (dayOfWeek = 0; (dayOfWeek < 7) && (longDay[dayOfWeek] != parts[nwday]); ++dayOfWeek);
}
// if (month >= 12 || dayOfWeek >= 7
@ -450,7 +450,7 @@ namespace @@ -450,7 +450,7 @@ namespace
int i = parts[nyear].size();
if (i < 4) {
// It's an obsolete year specification with less than 4 digits
year += (i == 2 && year < 50) ? 2000 : 1900;
year += ((i == 2) && (year < 50)) ? 2000 : 1900;
}
// Parse the UTC offset part
@ -473,17 +473,17 @@ namespace @@ -473,17 +473,17 @@ namespace
else {
// Check for an obsolete time zone name
QByteArray zone = parts[10].toLatin1();
if (zone.length() == 1 && isalpha(zone[0]) && toupper(zone[0]) != 'J') {
if ((zone.length() == 1) && (isalpha(zone[0])) && (toupper(zone[0]) != 'J')) {
negOffset = true; // military zone: RFC 2822 treats as '-0000'
}
else if (zone != "UT" && zone != "GMT") { // treated as '+0000'
else if ((zone != "UT") && (zone != "GMT")) { // treated as '+0000'
offset = (zone == "EDT")
? -4 * 3600
: ((zone == "EST") || (zone == "CDT"))
? -5 * 3600
: ((zone == "CST") || (zone == "MDT"))
? -6 * 3600
: (zone == "MST" || zone == "PDT")
: ((zone == "MST") || (zone == "PDT"))
? -7 * 3600
: (zone == "PST")
? -8 * 3600
@ -502,12 +502,12 @@ namespace @@ -502,12 +502,12 @@ namespace
}
}
QDate qdate(year, month + 1, day); // convert date, and check for out-of-range
if (!qdate.isValid())
QDate qDate(year, month + 1, day); // convert date, and check for out-of-range
if (!qDate.isValid())
return QDateTime::currentDateTime();
QTime qTime(hour, minute, second);
QDateTime result(qdate, qTime, Qt::UTC);
QDateTime result(qDate, qTime, Qt::UTC);
if (offset)
result = result.addSecs(-offset);
if (!result.isValid())

2
src/base/rss/rss_autodownloader.cpp

@ -373,7 +373,7 @@ void AutoDownloader::addJobForArticle(Article *article) @@ -373,7 +373,7 @@ void AutoDownloader::addJobForArticle(Article *article)
void AutoDownloader::processJob(const QSharedPointer<ProcessingJob> &job)
{
for (AutoDownloadRule &rule: m_rules) {
for (AutoDownloadRule &rule : m_rules) {
if (!rule.isEnabled()) continue;
if (!rule.feedURLs().contains(job->feedURL)) continue;
if (!rule.accepts(job->articleData)) continue;

6
src/base/rss/rss_autodownloadrule.cpp

@ -246,7 +246,7 @@ bool AutoDownloadRule::matchesMustContainExpression(const QString &articleTitle) @@ -246,7 +246,7 @@ bool AutoDownloadRule::matchesMustContainExpression(const QString &articleTitle)
return false;
}
bool AutoDownloadRule::matchesMustNotContainExpression(const QString& articleTitle) const
bool AutoDownloadRule::matchesMustNotContainExpression(const QString &articleTitle) const
{
if (m_dataPtr->mustNotContain.empty())
return true;
@ -262,7 +262,7 @@ bool AutoDownloadRule::matchesMustNotContainExpression(const QString& articleTit @@ -262,7 +262,7 @@ bool AutoDownloadRule::matchesMustNotContainExpression(const QString& articleTit
return true;
}
bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString& articleTitle) const
bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString &articleTitle) const
{
// Reset the lastComputedEpisode, we don't want to leak it between matches
m_dataPtr->lastComputedEpisode.clear();
@ -332,7 +332,7 @@ bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString& articleTitl @@ -332,7 +332,7 @@ bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString& articleTitl
return false;
}
bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString& articleTitle) const
bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString &articleTitle) const
{
if (!useSmartFilter())
return true;

4
src/base/rss/rss_folder.cpp

@ -123,7 +123,7 @@ void Folder::addItem(Item *item) @@ -123,7 +123,7 @@ void Folder::addItem(Item *item)
connect(item, &Item::articleAboutToBeRemoved, this, &Item::articleAboutToBeRemoved);
connect(item, &Item::unreadCountChanged, this, &Folder::handleItemUnreadCountChanged);
for (auto article: copyAsConst(item->articles()))
for (auto article : copyAsConst(item->articles()))
emit newArticle(article);
if (item->unreadCount() > 0)
@ -134,7 +134,7 @@ void Folder::removeItem(Item *item) @@ -134,7 +134,7 @@ void Folder::removeItem(Item *item)
{
Q_ASSERT(m_items.contains(item));
for (auto article: copyAsConst(item->articles()))
for (auto article : copyAsConst(item->articles()))
emit articleAboutToBeRemoved(article);
item->disconnect(this);

2
src/base/utils/foreignapps.cpp

@ -229,7 +229,7 @@ namespace @@ -229,7 +229,7 @@ namespace
return QString();
}
#endif
#endif // Q_OS_WIN
}
bool Utils::ForeignApps::PythonInfo::isValid() const

6
src/base/utils/fs.cpp

@ -329,7 +329,7 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path) @@ -329,7 +329,7 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path)
return ((strncmp(buf.f_fstypename, "cifs", sizeof(buf.f_fstypename)) == 0)
|| (strncmp(buf.f_fstypename, "nfs", sizeof(buf.f_fstypename)) == 0)
|| (strncmp(buf.f_fstypename, "smbfs", sizeof(buf.f_fstypename)) == 0));
#else
#else // Q_OS_WIN
QString file = path;
if (!file.endsWith('/'))
file += '/';
@ -351,6 +351,6 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path) @@ -351,6 +351,6 @@ bool Utils::Fs::isNetworkFileSystem(const QString &path)
default:
return false;
}
#endif
#endif // Q_OS_WIN
}
#endif
#endif // Q_OS_HAIKU

2
src/base/utils/misc.cpp

@ -66,7 +66,7 @@ @@ -66,7 +66,7 @@
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
#include "base/utils/version.h"
#endif
#endif
#endif // DISABLE_GUI
#include "base/logger.h"
#include "base/unicodestrings.h"

2
src/base/utils/misc.h

@ -124,7 +124,7 @@ namespace Utils @@ -124,7 +124,7 @@ namespace Utils
return reinterpret_cast<T>(
::GetProcAddress(::LoadLibraryW(pathWchar.get()), funcName));
}
#endif
#endif // Q_OS_WIN
}
}

2
src/gui/advancedsettings.cpp

@ -425,7 +425,7 @@ void AdvancedSettings::loadAdvancedSettings() @@ -425,7 +425,7 @@ void AdvancedSettings::loadAdvancedSettings()
const QString currentInterface = session->networkInterface();
bool interfaceExists = currentInterface.isEmpty();
int i = 1;
foreach (const QNetworkInterface& iface, QNetworkInterface::allInterfaces()) {
foreach (const QNetworkInterface &iface, QNetworkInterface::allInterfaces()) {
// This line fixes a Qt bug => https://bugreports.qt.io/browse/QTBUG-52633
// Tested in Qt 5.6.0. For more info see:
// https://github.com/qbittorrent/qBittorrent/issues/5131

2
src/gui/fspathedit.cpp

@ -350,7 +350,7 @@ void FileSystemPathComboEdit::addItem(const QString &text) @@ -350,7 +350,7 @@ void FileSystemPathComboEdit::addItem(const QString &text)
editWidget<WidgetType>()->addItem(Utils::Fs::toNativePath(text));
}
void FileSystemPathComboEdit::insertItem(int index, const QString& text)
void FileSystemPathComboEdit::insertItem(int index, const QString &text)
{
editWidget<WidgetType>()->insertItem(index, Utils::Fs::toNativePath(text));
}

8
src/gui/mainwindow.cpp

@ -305,7 +305,7 @@ MainWindow::MainWindow(QWidget *parent) @@ -305,7 +305,7 @@ MainWindow::MainWindow(QWidget *parent)
spacer->setMinimumWidth(8);
m_ui->toolBar->addWidget(spacer);
}
#endif
#endif // Q_OS_MAC
// Transfer list slots
connect(m_ui->actionStart, &QAction::triggered, m_transferListWidget, &TransferListWidget::startSelectedTorrents);
@ -1110,7 +1110,7 @@ void MainWindow::toggleVisibility(const QSystemTrayIcon::ActivationReason reason @@ -1110,7 +1110,7 @@ void MainWindow::toggleVisibility(const QSystemTrayIcon::ActivationReason reason
break;
}
}
#endif
#endif // Q_OS_MAC
// Display About Dialog
void MainWindow::on_actionAbout_triggered()
@ -1272,7 +1272,7 @@ bool MainWindow::event(QEvent *e) @@ -1272,7 +1272,7 @@ bool MainWindow::event(QEvent *e)
default:
break;
}
#endif
#endif // Q_OS_MAC
return QMainWindow::event(e);
}
@ -1361,7 +1361,7 @@ void MainWindow::setupDockClickHandler() @@ -1361,7 +1361,7 @@ void MainWindow::setupDockClickHandler()
MacUtils::overrideDockClickHandler(dockClickHandler);
}
#endif
#endif // Q_OS_MAC
/*****************************************************
* *

36
src/gui/optionsdialog.cpp

@ -148,7 +148,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) @@ -148,7 +148,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
QList<QAbstractButton *> buttons = m_ui->buttonBox->buttons();
foreach (QAbstractButton *button, buttons) {
if (m_ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) {
applyButton = button;
m_applyButton = button;
break;
}
}
@ -410,13 +410,13 @@ OptionsDialog::OptionsDialog(QWidget *parent) @@ -410,13 +410,13 @@ OptionsDialog::OptionsDialog(QWidget *parent)
connect(m_ui->btnEditRules, &QPushButton::clicked, this, [this]() { AutomatedRssDownloader(this).exec(); });
// Disable apply Button
applyButton->setEnabled(false);
m_applyButton->setEnabled(false);
// Tab selection mechanism
connect(m_ui->tabSelection, &QListWidget::currentItemChanged, this, &ThisType::changePage);
// Load Advanced settings
advancedSettings = new AdvancedSettings(m_ui->tabAdvancedPage);
m_ui->advPageLayout->addWidget(advancedSettings);
connect(advancedSettings, &AdvancedSettings::settingsChanged, this, &ThisType::enableApplyButton);
m_advancedSettings = new AdvancedSettings(m_ui->tabAdvancedPage);
m_ui->advPageLayout->addWidget(m_advancedSettings);
connect(m_advancedSettings, &AdvancedSettings::settingsChanged, this, &ThisType::enableApplyButton);
m_ui->textFileLogPath->setDialogCaption(tr("Choose a save directory"));
m_ui->textFileLogPath->setMode(FileSystemPathEdit::Mode::DirectorySave);
@ -479,7 +479,7 @@ OptionsDialog::~OptionsDialog() @@ -479,7 +479,7 @@ OptionsDialog::~OptionsDialog()
saveWindowState();
foreach (const QString &path, addedScanDirs)
foreach (const QString &path, m_addedScanDirs)
ScanFoldersModel::instance()->removePath(path);
ScanFoldersModel::instance()->configure(); // reloads "removed" paths
delete m_ui;
@ -527,7 +527,7 @@ void OptionsDialog::saveWindowState() const @@ -527,7 +527,7 @@ void OptionsDialog::saveWindowState() const
void OptionsDialog::saveOptions()
{
applyButton->setEnabled(false);
m_applyButton->setEnabled(false);
Preferences *const pref = Preferences::instance();
// Load the translation
QString locale = getLocale();
@ -611,11 +611,11 @@ void OptionsDialog::saveOptions() @@ -611,11 +611,11 @@ void OptionsDialog::saveOptions()
AddNewTorrentDialog::setTopLevel(m_ui->checkAdditionDialogFront->isChecked());
session->setAddTorrentPaused(addTorrentsInPause());
session->setCreateTorrentSubfolder(m_ui->checkCreateSubfolder->isChecked());
ScanFoldersModel::instance()->removeFromFSWatcher(removedScanDirs);
ScanFoldersModel::instance()->addToFSWatcher(addedScanDirs);
ScanFoldersModel::instance()->removeFromFSWatcher(m_removedScanDirs);
ScanFoldersModel::instance()->addToFSWatcher(m_addedScanDirs);
ScanFoldersModel::instance()->makePersistent();
removedScanDirs.clear();
addedScanDirs.clear();
m_removedScanDirs.clear();
m_addedScanDirs.clear();
session->setTorrentExportDirectory(getTorrentExportDir());
session->setFinishedTorrentExportDirectory(getFinishedTorrentExportDir());
pref->setMailNotificationEnabled(m_ui->groupMailNotification->isChecked());
@ -734,7 +734,7 @@ void OptionsDialog::saveOptions() @@ -734,7 +734,7 @@ void OptionsDialog::saveOptions()
// End Web UI
// End preferences
// Save advanced settings
advancedSettings->saveAdvancedSettings();
m_advancedSettings->saveAdvancedSettings();
// Assume that user changed multiple settings
// so it's best to save immediately
pref->apply();
@ -1226,7 +1226,7 @@ int OptionsDialog::getMaxUploadsPerTorrent() const @@ -1226,7 +1226,7 @@ int OptionsDialog::getMaxUploadsPerTorrent() const
void OptionsDialog::on_buttonBox_accepted()
{
if (applyButton->isEnabled()) {
if (m_applyButton->isEnabled()) {
if (!schedTimesOk()) {
m_ui->tabSelection->setCurrentRow(TAB_SPEED);
return;
@ -1235,7 +1235,7 @@ void OptionsDialog::on_buttonBox_accepted() @@ -1235,7 +1235,7 @@ void OptionsDialog::on_buttonBox_accepted()
m_ui->tabSelection->setCurrentRow(TAB_WEBUI);
return;
}
applyButton->setEnabled(false);
m_applyButton->setEnabled(false);
this->hide();
saveOptions();
}
@ -1245,7 +1245,7 @@ void OptionsDialog::on_buttonBox_accepted() @@ -1245,7 +1245,7 @@ void OptionsDialog::on_buttonBox_accepted()
void OptionsDialog::applySettings(QAbstractButton *button)
{
if (button == applyButton) {
if (button == m_applyButton) {
if (!schedTimesOk()) {
m_ui->tabSelection->setCurrentRow(TAB_SPEED);
return;
@ -1277,7 +1277,7 @@ bool OptionsDialog::useAdditionDialog() const @@ -1277,7 +1277,7 @@ bool OptionsDialog::useAdditionDialog() const
void OptionsDialog::enableApplyButton()
{
applyButton->setEnabled(true);
m_applyButton->setEnabled(true);
}
void OptionsDialog::toggleComboRatioLimitAct()
@ -1472,7 +1472,7 @@ void OptionsDialog::on_addScanFolderButton_clicked() @@ -1472,7 +1472,7 @@ void OptionsDialog::on_addScanFolderButton_clicked()
break;
default:
pref->setScanDirsLastPath(dir);
addedScanDirs << dir;
m_addedScanDirs << dir;
for (int i = 0; i < ScanFoldersModel::instance()->columnCount(); ++i)
m_ui->scanFoldersView->resizeColumnToContents(i);
enableApplyButton();
@ -1492,7 +1492,7 @@ void OptionsDialog::on_removeScanFolderButton_clicked() @@ -1492,7 +1492,7 @@ void OptionsDialog::on_removeScanFolderButton_clicked()
Q_ASSERT(selected.count() == ScanFoldersModel::instance()->columnCount());
foreach (const QModelIndex &index, selected) {
if (index.column() == ScanFoldersModel::WATCH)
removedScanDirs << index.data().toString();
m_removedScanDirs << index.data().toString();
}
ScanFoldersModel::instance()->removePath(selected.first().row(), false);
}

9
src/gui/optionsdialog.h

@ -176,11 +176,10 @@ private: @@ -176,11 +176,10 @@ private:
QByteArray m_sslCert, m_sslKey;
Ui::OptionsDialog *m_ui;
QButtonGroup choiceLanguage;
QAbstractButton *applyButton;
AdvancedSettings *advancedSettings;
QList<QString> addedScanDirs;
QList<QString> removedScanDirs;
QAbstractButton *m_applyButton;
AdvancedSettings *m_advancedSettings;
QList<QString> m_addedScanDirs;
QList<QString> m_removedScanDirs;
};
#endif // OPTIONSDIALOG_H

2
src/gui/programupdater.cpp

@ -141,7 +141,7 @@ bool ProgramUpdater::isVersionMoreRecent(const QString &remoteVersion) const @@ -141,7 +141,7 @@ bool ProgramUpdater::isVersionMoreRecent(const QString &remoteVersion) const
qDebug() << Q_FUNC_INFO << "local version:" << localVersion << "/" << QBT_VERSION;
QStringList remoteParts = remoteVersion.split('.');
QStringList localParts = localVersion.split('.');
for (int i = 0; i<qMin(remoteParts.size(), localParts.size()); ++i) {
for (int i = 0; i < qMin(remoteParts.size(), localParts.size()); ++i) {
if (remoteParts[i].toInt() > localParts[i].toInt())
return true;
if (remoteParts[i].toInt() < localParts[i].toInt())

6
src/gui/properties/peerlistwidget.cpp

@ -103,7 +103,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent) @@ -103,7 +103,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
hideColumn(PeerListDelegate::COUNTRY);
// Ensure that at least one column is visible at all times
bool atLeastOne = false;
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
for (int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
if (!isColumnHidden(i)) {
atLeastOne = true;
break;
@ -114,7 +114,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent) @@ -114,7 +114,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
// To also mitigate the above issue, we have to resize each column when
// its size is 0, because explicitly 'showing' the column isn't enough
// in the above scenario.
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i)
for (int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i)
if ((columnWidth(i) <= 0) && !isColumnHidden(i))
resizeColumnToContents(i);
// Context menu
@ -169,7 +169,7 @@ void PeerListWidget::displayToggleColumnsMenu(const QPoint &) @@ -169,7 +169,7 @@ void PeerListWidget::displayToggleColumnsMenu(const QPoint &)
actions.append(myAct);
}
int visibleCols = 0;
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
for (int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
if (!isColumnHidden(i))
++visibleCols;

2
src/gui/properties/piecesbar.cpp

@ -275,7 +275,7 @@ void PiecesBar::showToolTip(const QHelpEvent *e) @@ -275,7 +275,7 @@ void PiecesBar::showToolTip(const QHelpEvent *e)
DetailedTooltipRenderer renderer(stream, tooltipTitle);
const bool isFileNameCorrectionNeeded = this->isFileNameCorrectionNeeded();
for (int f: files) {
for (int f : files) {
QString filePath {m_torrent->info().filePath(f)};
if (isFileNameCorrectionNeeded)
filePath.replace(QLatin1String("/.unwanted"), QString());

2
src/gui/search/searchsortmodel.cpp

@ -126,7 +126,7 @@ bool SearchSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP @@ -126,7 +126,7 @@ bool SearchSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP
const QAbstractItemModel *const sourceModel = this->sourceModel();
if (m_isNameFilterEnabled && !m_searchTerm.isEmpty()) {
QString name = sourceModel->data(sourceModel->index(sourceRow, NAME, sourceParent)).toString();
for (const QString &word: m_searchTermWords) {
for (const QString &word : m_searchTermWords) {
int i = name.indexOf(word, 0, Qt::CaseInsensitive);
if (i == -1) {
return false;

4
src/gui/torrentcontentmodel.cpp

@ -146,7 +146,7 @@ namespace @@ -146,7 +146,7 @@ namespace
#elif defined(Q_OS_MAC)
// There is a similar bug on macOS, to be reported to Qt
// https://github.com/qbittorrent/qBittorrent/pull/6156#issuecomment-316302615
class MacFileIconProvider final: public CachingFileIconProvider
class MacFileIconProvider final : public CachingFileIconProvider
{
QPixmap pixmapForExtension(const QString &ext) const override
{
@ -346,7 +346,7 @@ int TorrentContentModel::getFileIndex(const QModelIndex &index) @@ -346,7 +346,7 @@ int TorrentContentModel::getFileIndex(const QModelIndex &index)
return -1;
}
QVariant TorrentContentModel::data(const QModelIndex& index, int role) const
QVariant TorrentContentModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();

4
src/gui/torrentcontentmodel.h

@ -54,13 +54,13 @@ public: @@ -54,13 +54,13 @@ public:
QVector<int> getFilePriorities() const;
bool allFiltered() const;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
bool setData(const QModelIndex &index, const QVariant& value, int role = Qt::EditRole) override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
TorrentContentModelItem::ItemType itemType(const QModelIndex &index) const;
int getFileIndex(const QModelIndex &index);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
void clear();

4
src/gui/transferlistfilterswidget.cpp

@ -404,7 +404,7 @@ void TrackerFiltersList::trackerWarning(const QString &hash, const QString &trac @@ -404,7 +404,7 @@ void TrackerFiltersList::trackerWarning(const QString &hash, const QString &trac
applyFilter(3);
}
void TrackerFiltersList::downloadFavicon(const QString& url)
void TrackerFiltersList::downloadFavicon(const QString &url)
{
if (!m_downloadTrackerFavicon) return;
Net::DownloadHandler *h = Net::DownloadManager::instance()->download(
@ -416,7 +416,7 @@ void TrackerFiltersList::downloadFavicon(const QString& url) @@ -416,7 +416,7 @@ void TrackerFiltersList::downloadFavicon(const QString& url)
, &TrackerFiltersList::handleFavicoFailure);
}
void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString& filePath)
void TrackerFiltersList::handleFavicoDownload(const QString &url, const QString &filePath)
{
QString host = url.startsWith(GOOGLE_FAVICON_URL)
? url.mid(GOOGLE_FAVICON_URL.size())

2
src/gui/transferlistmodel.h

@ -83,7 +83,7 @@ public: @@ -83,7 +83,7 @@ public:
explicit TransferListModel(QObject *parent = nullptr);
int rowCount(const QModelIndex& index = QModelIndex()) const override;
int rowCount(const QModelIndex &index = QModelIndex()) const override;
int columnCount(const QModelIndex &parent=QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;

26
src/gui/transferlistwidget.cpp

@ -582,7 +582,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const @@ -582,7 +582,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const
}
pathsList.insert(path);
}
#endif
#endif // Q_OS_MAC
}
void TransferListWidget::previewSelectedTorrents()
@ -595,16 +595,16 @@ void TransferListWidget::previewSelectedTorrents() @@ -595,16 +595,16 @@ void TransferListWidget::previewSelectedTorrents()
void TransferListWidget::setDlLimitSelectedTorrents()
{
QList<BitTorrent::TorrentHandle *> TorrentsList;
QList<BitTorrent::TorrentHandle *> torrentsList;
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) {
if (torrent->isSeed())
continue;
TorrentsList += torrent;
torrentsList += torrent;
}
if (TorrentsList.empty()) return;
if (torrentsList.empty()) return;
int oldLimit = TorrentsList.first()->downloadLimit();
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
int oldLimit = torrentsList.first()->downloadLimit();
foreach (BitTorrent::TorrentHandle *const torrent, torrentsList) {
if (torrent->downloadLimit() != oldLimit) {
oldLimit = -1;
break;
@ -617,7 +617,7 @@ void TransferListWidget::setDlLimitSelectedTorrents() @@ -617,7 +617,7 @@ void TransferListWidget::setDlLimitSelectedTorrents()
, BitTorrent::Session::instance()->globalDownloadSpeedLimit());
if (!ok) return;
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
foreach (BitTorrent::TorrentHandle *const torrent, torrentsList) {
qDebug("Applying download speed limit of %ld Kb/s to torrent %s", (newLimit / 1024l), qUtf8Printable(torrent->hash()));
torrent->setDownloadLimit(newLimit);
}
@ -625,11 +625,11 @@ void TransferListWidget::setDlLimitSelectedTorrents() @@ -625,11 +625,11 @@ void TransferListWidget::setDlLimitSelectedTorrents()
void TransferListWidget::setUpLimitSelectedTorrents()
{
QList<BitTorrent::TorrentHandle *> TorrentsList = getSelectedTorrents();
if (TorrentsList.empty()) return;
QList<BitTorrent::TorrentHandle *> torrentsList = getSelectedTorrents();
if (torrentsList.empty()) return;
int oldLimit = TorrentsList.first()->uploadLimit();
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
int oldLimit = torrentsList.first()->uploadLimit();
foreach (BitTorrent::TorrentHandle *const torrent, torrentsList) {
if (torrent->uploadLimit() != oldLimit) {
oldLimit = -1;
break;
@ -642,7 +642,7 @@ void TransferListWidget::setUpLimitSelectedTorrents() @@ -642,7 +642,7 @@ void TransferListWidget::setUpLimitSelectedTorrents()
, BitTorrent::Session::instance()->globalUploadSpeedLimit());
if (!ok) return;
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
foreach (BitTorrent::TorrentHandle *const torrent, torrentsList) {
qDebug("Applying upload speed limit of %ld Kb/s to torrent %s", (newLimit / 1024l), qUtf8Printable(torrent->hash()));
torrent->setUploadLimit(newLimit);
}
@ -1144,7 +1144,7 @@ void TransferListWidget::displayListMenu(const QPoint&) @@ -1144,7 +1144,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
}
}
void TransferListWidget::currentChanged(const QModelIndex& current, const QModelIndex&)
void TransferListWidget::currentChanged(const QModelIndex &current, const QModelIndex&)
{
qDebug("CURRENT CHANGED");
BitTorrent::TorrentHandle *torrent = nullptr;

2
src/gui/transferlistwidget.h

@ -106,7 +106,7 @@ protected: @@ -106,7 +106,7 @@ protected:
protected slots:
void torrentDoubleClicked();
void displayListMenu(const QPoint&);
void currentChanged(const QModelIndex& current, const QModelIndex&) override;
void currentChanged(const QModelIndex &current, const QModelIndex&) override;
void toggleSelectedTorrentsSuperSeeding() const;
void toggleSelectedTorrentsSequentialDownload() const;
void toggleSelectedFirstLastPiecePrio() const;

Loading…
Cancel
Save