Fix coding style for various things

This commit is contained in:
thalieht
2018-11-06 17:49:17 +02:00
committed by sledgehammer999
parent c62127e9f1
commit 62e71a15a4
35 changed files with 120 additions and 121 deletions

View File

@@ -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)
}
#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()
, 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()
, 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()
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)
break;
}
}
#endif
#endif // LIBTORRENT_VERSION_NUM >= 10100
void Session::enableTracker(bool enable)
{
@@ -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)
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)
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)
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()
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()
#else
m_listenInterfaceChanged = true;
configureDeferred();
#endif
#endif // LIBTORRENT_VERSION_NUM < 10100
}
int Session::globalDownloadSpeedLimit() const
@@ -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)
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()
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)
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()
emit statsUpdated();
}
#endif
#endif // LIBTORRENT_VERSION_NUM >= 10100
void Session::handleStateUpdateAlert(libt::state_update_alert *p)
{
@@ -4590,7 +4590,7 @@ namespace
return true;
}
bool loadTorrentResumeData(const QByteArray &data, CreateTorrentParams &torrentParams, int &prio, MagnetUri &magnetUri)
bool loadTorrentResumeData(const QByteArray &data, CreateTorrentParams &torrentParams, int &prio, MagnetUri &magnetUri)
{
torrentParams = CreateTorrentParams();
torrentParams.restored = true;

View File

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

View File

@@ -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);
}
@@ -623,7 +623,7 @@ QString TorrentHandle::filePath(int index) const
QString TorrentHandle::fileName(int index) const
{
if (!hasMetadata()) return QString();
if (!hasMetadata()) return QString();
return Utils::Fs::fileName(filePath(index));
}
@@ -636,7 +636,7 @@ qlonglong TorrentHandle::fileSize(int index) const
// to all files in a torrent
QStringList TorrentHandle::absoluteFilePaths() const
{
if (!hasMetadata()) return QStringList();
if (!hasMetadata()) return QStringList();
QDir saveDir(savePath(true));
QStringList res;
@@ -647,7 +647,7 @@ QStringList TorrentHandle::absoluteFilePaths() const
QStringList TorrentHandle::absoluteFilePathsUnwanted() const
{
if (!hasMetadata()) return QStringList();
if (!hasMetadata()) return QStringList();
QDir saveDir(savePath(true));
QStringList res;
@@ -2063,7 +2063,7 @@ void TorrentHandle::prioritizeFiles(const QVector<int> &priorities)
if (created) {
// Hide the folder on Windows
qDebug() << "Hiding folder (Windows)";
std::wstring winPath = Utils::Fs::toNativePath(unwantedAbsPath).toStdWString();
std::wstring winPath = Utils::Fs::toNativePath(unwantedAbsPath).toStdWString();
DWORD dwAttrs = ::GetFileAttributesW(winPath.c_str());
bool ret = ::SetFileAttributesW(winPath.c_str(), dwAttrs | FILE_ATTRIBUTE_HIDDEN);
Q_ASSERT(ret != 0); Q_UNUSED(ret);

View File

@@ -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

View File

@@ -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
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) {}
};
}

View File

@@ -40,7 +40,7 @@ const QString KEY_PASSWORD = SETTINGS_KEY("Password");
namespace
{
inline SettingsStorage *settings() { return SettingsStorage::instance(); }
inline SettingsStorage *settings() { return SettingsStorage::instance(); }
inline bool isSameConfig(const Net::ProxyConfiguration &conf1, const Net::ProxyConfiguration &conf2)
{

View File

@@ -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();

View File

@@ -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)
settings.remove("qBittorrent");
}
}
#endif
#endif // Q_OS_WIN
// Downloads
QString Preferences::lastLocationPath() const
@@ -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()
CFStringRef myBundleId = CFBundleGetIdentifier(CFBundleGetMainBundle());
LSSetDefaultHandlerForURLScheme(magnetUrlScheme, myBundleId);
}
#endif
#endif // Q_OS_MAC
int Preferences::getTrackerPort() const
{

View File

@@ -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.

View File

@@ -435,13 +435,13 @@ namespace
if (leapSecond)
second = 59; // apparently a leap second - validate below, once time zone is known
int month = 0;
for ( ; (month < 12) && (parts[nmonth] != shortMonth[month]); ++month);
for ( ; (month < 12) && (parts[nmonth] != shortMonth[month]); ++month);
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
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
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
}
}
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())

View File

@@ -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;

View File

@@ -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
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
return false;
}
bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString& articleTitle) const
bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString &articleTitle) const
{
if (!useSmartFilter())
return true;

View File

@@ -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)
{
Q_ASSERT(m_items.contains(item));
for (auto article: copyAsConst(item->articles()))
for (auto article : copyAsConst(item->articles()))
emit articleAboutToBeRemoved(article);
item->disconnect(this);

View File

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

View File

@@ -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)
default:
return false;
}
#endif
#endif // Q_OS_WIN
}
#endif
#endif // Q_OS_HAIKU

View File

@@ -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"

View File

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