Add const to many vars and arguments

Also remove const in declarations' arguments that are passed by value
This commit is contained in:
thalieht 2019-02-09 17:40:14 +02:00
parent fc534e88a3
commit ca3ce87e06
21 changed files with 217 additions and 219 deletions

View file

@ -127,7 +127,7 @@ Application::Application(const QString &id, int &argc, char **argv)
setApplicationName("qBittorrent");
validateCommandLineParameters();
QString profileDir = m_commandLineArgs.portableMode
const QString profileDir = m_commandLineArgs.portableMode
? QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(DEFAULT_PORTABLE_MODE_PROFILE_DIR)
: m_commandLineArgs.profileDir;
@ -185,7 +185,7 @@ bool Application::isFileLoggerEnabled() const
return settings()->loadValue(KEY_FILELOGGER_ENABLED, true).toBool();
}
void Application::setFileLoggerEnabled(bool value)
void Application::setFileLoggerEnabled(const bool value)
{
if (value && !m_fileLogger)
m_fileLogger = new FileLogger(fileLoggerPath(), isFileLoggerBackup(), fileLoggerMaxSize(), isFileLoggerDeleteOld(), fileLoggerAge(), static_cast<FileLogger::FileLogAgeType>(fileLoggerAgeType()));
@ -212,7 +212,7 @@ bool Application::isFileLoggerBackup() const
return settings()->loadValue(KEY_FILELOGGER_BACKUP, true).toBool();
}
void Application::setFileLoggerBackup(bool value)
void Application::setFileLoggerBackup(const bool value)
{
if (m_fileLogger)
m_fileLogger->setBackup(value);
@ -224,7 +224,7 @@ bool Application::isFileLoggerDeleteOld() const
return settings()->loadValue(KEY_FILELOGGER_DELETEOLD, true).toBool();
}
void Application::setFileLoggerDeleteOld(bool value)
void Application::setFileLoggerDeleteOld(const bool value)
{
if (value && m_fileLogger)
m_fileLogger->deleteOld(fileLoggerAge(), static_cast<FileLogger::FileLogAgeType>(fileLoggerAgeType()));
@ -233,13 +233,13 @@ void Application::setFileLoggerDeleteOld(bool value)
int Application::fileLoggerMaxSize() const
{
int val = settings()->loadValue(KEY_FILELOGGER_MAXSIZEBYTES, DEFAULT_FILELOG_SIZE).toInt();
const int val = settings()->loadValue(KEY_FILELOGGER_MAXSIZEBYTES, DEFAULT_FILELOG_SIZE).toInt();
return std::min(std::max(val, MIN_FILELOG_SIZE), MAX_FILELOG_SIZE);
}
void Application::setFileLoggerMaxSize(const int bytes)
{
int clampedValue = std::min(std::max(bytes, MIN_FILELOG_SIZE), MAX_FILELOG_SIZE);
const int clampedValue = std::min(std::max(bytes, MIN_FILELOG_SIZE), MAX_FILELOG_SIZE);
if (m_fileLogger)
m_fileLogger->setMaxSize(clampedValue);
settings()->storeValue(KEY_FILELOGGER_MAXSIZEBYTES, clampedValue);
@ -247,7 +247,7 @@ void Application::setFileLoggerMaxSize(const int bytes)
int Application::fileLoggerAge() const
{
int val = settings()->loadValue(KEY_FILELOGGER_AGE, 1).toInt();
const int val = settings()->loadValue(KEY_FILELOGGER_AGE, 1).toInt();
return std::min(std::max(val, 1), 365);
}
@ -258,7 +258,7 @@ void Application::setFileLoggerAge(const int value)
int Application::fileLoggerAgeType() const
{
int val = settings()->loadValue(KEY_FILELOGGER_AGETYPE, 1).toInt();
const int val = settings()->loadValue(KEY_FILELOGGER_AGETYPE, 1).toInt();
return ((val < 0) || (val > 2)) ? 1 : val;
}
@ -269,7 +269,7 @@ void Application::setFileLoggerAgeType(const int value)
void Application::processMessage(const QString &message)
{
QStringList params = message.split(PARAMS_SEPARATOR, QString::SkipEmptyParts);
const QStringList params = message.split(PARAMS_SEPARATOR, QString::SkipEmptyParts);
// If Application is not running (i.e., other
// components are not ready) store params
if (m_running)
@ -572,7 +572,7 @@ int Application::exec(const QStringList &params)
#ifdef Q_OS_WIN
bool Application::isRunning()
{
bool running = BaseApplication::isRunning();
const bool running = BaseApplication::isRunning();
QSharedMemory *sharedMem = new QSharedMemory(id() + QLatin1String("-shared-memory-key"), this);
if (!running) {
// First instance creates shared memory and store PID
@ -622,7 +622,7 @@ void Application::initializeTranslation()
{
Preferences *const pref = Preferences::instance();
// Load translation
QString localeStr = pref->getLocale();
const QString localeStr = pref->getLocale();
if (m_qtTranslator.load(QLatin1String("qtbase_") + localeStr, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) ||
m_qtTranslator.load(QLatin1String("qt_") + localeStr, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))