Commit 15a16a42 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

More const'ify

parent 9d6892ea
......@@ -519,7 +519,8 @@ void MainWindow::showSearchBar()
LogManager *activeLogManager = mTabs->activeLogManager();
foreach (LogManager *manager, mTabs->logManagers()) {
const auto logManagers = mTabs->logManagers();
for (LogManager *manager : logManagers) {
if (manager != activeLogManager) {
manager->usedView()->toggleLogViewSearch(true);
}
......
......@@ -91,7 +91,7 @@ void JournaldConfigurationWidget::readConfig()
remoteJournalsListWidget->removeRow(0);
}
QList<JournalAddress> remoteJournals = configuration->remoteJournals();
const QList<JournalAddress> remoteJournals = configuration->remoteJournals();
for (const JournalAddress &addressInfo : remoteJournals) {
if (haveJournalAddress(addressInfo.address, QString::number(addressInfo.port), addressInfo.https)) {
continue;
......
......@@ -49,14 +49,14 @@ void KernelAnalyzer::startupTime()
file.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream in(&file);
QString line = in.readLine();
const QString line = in.readLine();
// Format : 1618.72 1382.98 (uptime / something)
QStringList times = line.split(QLatin1Char(' '));
const QStringList times = line.split(QLatin1Char(' '));
QString secondsString = times.at(0);
QString pureSecondsString = secondsString.left(secondsString.indexOf(QLatin1Char('.')));
long updateSeconds = pureSecondsString.toLong();
const QString secondsString = times.at(0);
const QString pureSecondsString = secondsString.left(secondsString.indexOf(QLatin1Char('.')));
const long updateSeconds = pureSecondsString.toLong();
mStartupDateTime = QDateTime::currentDateTime().addSecs(-updateSeconds);
logDebug() << "Startup time : " << mStartupDateTime;
......
......@@ -29,8 +29,7 @@
QList<LogMode *> KernelLogModeFactory::createLogModes() const
{
QList<LogMode *> logModes;
logModes.append(new KernelLogMode());
const QList<LogMode *> logModes{new KernelLogMode()};
return logModes;
}
......
......@@ -41,8 +41,7 @@ OpenLogModeFactory::~OpenLogModeFactory()
QList<LogMode *> OpenLogModeFactory::createLogModes() const
{
QList<LogMode *> logModes;
logModes.append(new OpenLogMode(mParent));
const QList<LogMode *> logModes{new OpenLogMode(mParent)};
return logModes;
}
......
......@@ -66,8 +66,7 @@ QList<LogFile> OpenLogMode::createLogFiles()
if (openingFileName.isValid()) {
const LogFile logFile(openingFileName, Globals::instance().informationLogLevel());
QList<LogFile> logFiles;
logFiles.append(logFile);
const QList<LogFile> logFiles{logFile};
return logFiles;
}
......
......@@ -27,7 +27,7 @@ PostfixConfigurationWidget::PostfixConfigurationWidget()
{
QVBoxLayout *layout = new QVBoxLayout(this);
QString description = i18n("<p>These files will be analyzed to show the <b>Postfix Logs</b>.</p>");
const QString description = i18n("<p>These files will be analyzed to show the <b>Postfix Logs</b>.</p>");
mLileList = new LogLevelFileList(this, description);
......@@ -38,7 +38,7 @@ PostfixConfigurationWidget::PostfixConfigurationWidget()
bool PostfixConfigurationWidget::isValid() const
{
if (mLileList->isEmpty() == false) {
if (!mLileList->isEmpty()) {
logDebug() << "Postfix configuration valid";
return true;
}
......
......@@ -55,22 +55,22 @@ LogLine *SambaAnalyzer::parseMessage(const QString &logLine, const LogFile &orig
QString line(logLine);
// The Date
int dateBegin = line.indexOf(QLatin1String("["));
int dateEnd = line.indexOf(QLatin1String("]"));
const int dateBegin = line.indexOf(QLatin1String("["));
const int dateEnd = line.indexOf(QLatin1String("]"));
if (dateBegin != -1) {
QString strDate = line.mid(dateBegin + 1, dateEnd - dateBegin - 1);
const QString strDate = line.mid(dateBegin + 1, dateEnd - dateBegin - 1);
QString year = strDate.mid(0, 4);
QString month = strDate.mid(5, 2);
QString day = strDate.mid(8, 2);
const QString year = strDate.mid(0, 4);
const QString month = strDate.mid(5, 2);
const QString day = strDate.mid(8, 2);
QString hour = strDate.mid(11, 2);
QString min = strDate.mid(14, 2);
QString sec = strDate.mid(17, 2);
const QString hour = strDate.mid(11, 2);
const QString min = strDate.mid(14, 2);
const QString sec = strDate.mid(17, 2);
QDate date = QDate(year.toInt(), month.toInt(), day.toInt());
QTime time = QTime(hour.toInt(), min.toInt(), sec.toInt());
const QDate date = QDate(year.toInt(), month.toInt(), day.toInt());
const QTime time = QTime(hour.toInt(), min.toInt(), sec.toInt());
line.remove(0, dateEnd + 2);
......@@ -114,7 +114,7 @@ LogLine *SambaAnalyzer::parseMessage(const QString &logLine, const LogFile &orig
// A line has already been added
if (list.count() == 4) {
QString currentMessage = list.takeLast();
const QString currentMessage = list.takeLast();
list.append(currentMessage + QLatin1String("\n") + line.simplified());
}
// First time we add a line for the current Log line
......
......@@ -25,8 +25,7 @@ SambaConfiguration::SambaConfiguration()
{
mConfiguration->setCurrentGroup(QStringLiteral("SambaLogMode"));
QStringList defaultSambaPaths;
defaultSambaPaths << QStringLiteral("/var/log/samba/log.smbd");
const QStringList defaultSambaPaths{QStringLiteral("/var/log/samba/log.smbd")};
mConfiguration->addItemStringList(QStringLiteral("SambaLogFilesPaths"), mSambaPaths,
defaultSambaPaths, QStringLiteral("SambaLogFilesPaths"));
......@@ -36,8 +35,7 @@ SambaConfiguration::SambaConfiguration()
mConfiguration->addItemStringList(QStringLiteral("SambaAccessLogFilesPaths"), mSambaAccessPaths,
defaultSambaAccessPaths, QStringLiteral("SambaAccessLogFilesPaths"));
QStringList defaultNetbiosPaths;
defaultNetbiosPaths << QStringLiteral("/var/log/samba/log.nmbd");
const QStringList defaultNetbiosPaths{QStringLiteral("/var/log/samba/log.nmbd")};
mConfiguration->addItemStringList(QStringLiteral("NetbiosLogFilesPaths"), mNetbiosPaths,
defaultNetbiosPaths, QStringLiteral("NetbiosLogFilesPaths"));
}
......
......@@ -74,7 +74,7 @@ void SambaConfigurationWidget::readConfig()
bool SambaConfigurationWidget::isValid() const
{
if (mSambaFileList->isOneOfCategoryEmpty() == true) {
if (mSambaFileList->isOneOfCategoryEmpty()) {
logDebug() << "Samba configuration not valid";
return false;
}
......
......@@ -25,8 +25,7 @@ XorgConfiguration::XorgConfiguration()
{
mConfiguration->setCurrentGroup(QStringLiteral("XorgLogMode"));
QStringList defaultXorgPaths;
defaultXorgPaths << QStringLiteral("/var/log/Xorg.0.log");
const QStringList defaultXorgPaths{QStringLiteral("/var/log/Xorg.0.log")};
mConfiguration->addItemStringList(QStringLiteral("LogFilesPaths"), mXorgPaths, defaultXorgPaths,
QStringLiteral("LogFilesPaths"));
}
......
......@@ -28,7 +28,8 @@ void XorgItemBuilder::prepareItem(LogViewWidgetItem *item) const
item->setText(0, QLatin1String(""));
int i = 1;
foreach (const QString &label, line->logItems()) {
const auto logItems = line->logItems();
for (const QString &label : logItems) {
item->setText(i, label);
i++;
}
......
......@@ -53,7 +53,7 @@ Analyzer::LogFileSortMode XSessionAnalyzer::logFileSortMode()
LogLine *XSessionAnalyzer::parseMessage(const QString &logLine, const LogFile &originalFile)
{
int classPrototypePosition = logLine.indexOf(QLatin1String("::"));
const int classPrototypePosition = logLine.indexOf(QLatin1String("::"));
int programPos = logLine.indexOf(QLatin1Char(':'));
// If the first found : is the begin of a :: (example: QFile::at:) then we move to the next :
......
......@@ -69,8 +69,8 @@ void XSessionConfigurationWidget::readConfig()
.findLogMode(QStringLiteral(X_SESSION_LOG_MODE_ID))
->logModeConfiguration<XSessionConfiguration *>();
QString path = configuration->xsessionPath();
QFileInfo fileInfo(path);
const QString path = configuration->xsessionPath();
const QFileInfo fileInfo(path);
mWarningBox->setVisible(!fileInfo.exists());
xsessionUrlRequester->setUrl(QUrl::fromLocalFile(path));
......
......@@ -28,7 +28,8 @@ void XSessionItemBuilder::prepareItem(LogViewWidgetItem *item) const
item->setText(0, QLatin1String(""));
int i = 1;
foreach (const QString &label, line->logItems()) {
const auto logItems = line->logItems();
for (const QString &label : logItems) {
item->setText(i, label);
i++;
}
......
......@@ -32,8 +32,8 @@
#include "logManager.h"
TabLogManager::TabLogManager(LogManager *logManager)
: mLogManager(logManager)
{
mLogManager = logManager;
}
TabLogManager::~TabLogManager()
......
......@@ -49,7 +49,7 @@ public:
private:
QString logModeName() const;
LogManager *mLogManager = nullptr;
LogManager *const mLogManager;
int mNewLinesCount = 0;
};
......
......@@ -75,6 +75,7 @@ TabLogViewsWidget::TabLogViewsWidget(QWidget *parent)
TabLogViewsWidget::~TabLogViewsWidget()
{
qDebug() << " TabLogViewsWidget::~TabLogViewsWidget()" << this;
const QList<TabLogManager *> copy = mTabLogManagers;
for (TabLogManager *tabLogManager : copy) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment