Commit d9837b51 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

const'ify

parent 08aeb8c9
......@@ -94,7 +94,7 @@ void LogViewModel::startingMultipleInsertions()
if (hasLocked) {
logDebug() << "Starting multiple insertions...";
emit(processingMultipleInsertions(true));
Q_EMIT(processingMultipleInsertions(true));
mLogViewWidget->setUpdatesEnabled(false);
......@@ -123,7 +123,7 @@ void LogViewModel::endingMultipleInsertions(Analyzer::ReadingMode readingMode, i
logDebug() << "Enabling log view widget refresh...";
mLogViewWidget->setUpdatesEnabled(true);
emit(processingMultipleInsertions(false));
Q_EMIT(processingMultipleInsertions(false));
}
}
......
......@@ -30,7 +30,7 @@ void AuditAnalyzer::setLogFiles(const QList<LogFile> &logFiles)
// Remove previous files
deleteLogFiles();
foreach (const LogFile &logFile, logFiles) {
for (const LogFile &logFile : logFiles) {
LogFileReader *logFileReader = createLogFileReader(logFile);
mLogFileReaders.append(logFileReader);
......@@ -55,17 +55,17 @@ LogLine *AuditAnalyzer::parseMessage(const QString &logLine, const LogFile &orig
if (logLine.length() < 15)
return nullptr;
QRegularExpression re(QStringLiteral("^type=(.*)\\s.*msg=audit\\((\\d*\\.\\d*).*"));
static QRegularExpression re(QStringLiteral("^type=(.*)\\s.*msg=audit\\((\\d*\\.\\d*).*"));
QRegularExpressionMatch match = re.match(logLine);
if (!match.hasMatch())
return nullptr;
QString messageType = match.captured(1);
const QString messageType = match.captured(1);
qint64 msecs = qint64(match.captured(2).toDouble() * 1000.);
const qint64 msecs = qint64(match.captured(2).toDouble() * 1000.);
QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(msecs);
const QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(msecs);
QString message(logLine);
re.setPattern(QStringLiteral("^type=.*\\):\\s"));
......@@ -98,7 +98,7 @@ int AuditAnalyzer::insertLines(const QStringList &bufferedLines, const LogFile &
logDebug() << "Inserting lines...";
// If there is no line
if (bufferedLines.size() == 0) {
if (bufferedLines.isEmpty()) {
logWarning() << "File is empty : " << logFile.url().path();
}
......@@ -166,7 +166,7 @@ bool AuditAnalyzer::insertLine(const QStringList &event, const LogFile &original
LogLine *line = parseEvent(event, originalFile);
// Invalid log line
if (line == NULL) {
if (!line) {
return false;
}
......@@ -181,7 +181,7 @@ bool AuditAnalyzer::insertLine(const QStringList &event, const LogFile &original
void AuditAnalyzer::logFileChanged(LogFileReader *logFileReader, ReadingMode readingMode,
const QStringList &content)
{
QString filePath = logFileReader->logFile().url().path();
const QString filePath = logFileReader->logFile().url().path();
if (readingMode == Analyzer::FullRead)
logDebug() << "File " << filePath << " has been modified on full read.";
else
......@@ -208,28 +208,28 @@ void AuditAnalyzer::logFileChanged(LogFileReader *logFileReader, ReadingMode rea
} else {
logDebug() << "Reading file " << filePath;
emit statusBarChanged(i18n("Opening '%1'...", filePath));
Q_EMIT statusBarChanged(i18n("Opening '%1'...", filePath));
// Inform that we are now reading the "index" file
emit readFileStarted(*mLogMode, logFileReader->logFile(),
Q_EMIT readFileStarted(*mLogMode, logFileReader->logFile(),
mLogFileReaders.count() - mLogFileReaders.indexOf(logFileReader),
mLogFileReaders.count());
insertedLogLineCount = insertLines(content, logFileReader->logFile(), Analyzer::FullRead);
emit statusBarChanged(i18n("Log file '%1' loaded successfully.", filePath));
Q_EMIT statusBarChanged(i18n("Log file '%1' loaded successfully.", filePath));
}
mLogViewModel->endingMultipleInsertions(readingMode, insertedLogLineCount);
// Inform connected LoadingBar that the reading is now finished
emit readEnded();
Q_EMIT readEnded();
// Inform LogManager that new lines have been added
emit logUpdated(insertedLogLineCount);
Q_EMIT logUpdated(insertedLogLineCount);
// Inform MainWindow status bar
emit statusBarChanged(i18n("Log file '%1' has changed.", filePath));
Q_EMIT statusBarChanged(i18n("Log file '%1' has changed.", filePath));
logDebug() << "Updating log files in " << benchmark.elapsed() << " ms";
......@@ -238,8 +238,8 @@ void AuditAnalyzer::logFileChanged(LogFileReader *logFileReader, ReadingMode rea
QString AuditAnalyzer::getMsgField(const QString &logLine)
{
QRegularExpression re(QStringLiteral("^.*msg=audit\\((\\d*\\.\\d*:\\d*)\\)"));
QRegularExpressionMatch match = re.match(logLine);
static const QRegularExpression re(QStringLiteral("^.*msg=audit\\((\\d*\\.\\d*:\\d*)\\)"));
const QRegularExpressionMatch match = re.match(logLine);
if (!match.hasMatch()) {
return QString();
......@@ -259,8 +259,8 @@ LogLine *AuditAnalyzer::parseEvent(const QStringList &event, const LogFile &orig
if (!match.hasMatch())
return nullptr;
qint64 msecs = qint64(match.captured(1).toDouble() * 1000.);
QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(msecs);
const qint64 msecs = qint64(match.captured(1).toDouble() * 1000.);
const QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(msecs);
QStringList messages;
QString message;
......
......@@ -13,10 +13,9 @@
AuditConfigurationWidget::AuditConfigurationWidget()
: LogModeConfigurationWidget(i18n("Audit Log"), QStringLiteral(AUDIT_MODE_ICON), i18n("Audit Log"))
{
QVBoxLayout *layout = new QVBoxLayout();
this->setLayout(layout);
QVBoxLayout *layout = new QVBoxLayout(this);
QString description = i18n("<p>These files will be analyzed to show the <b>Audit logs</b>.</p>");
const QString description = i18n("<p>These files will be analyzed to show the <b>Audit logs</b>.</p>");
fileList = new LogLevelFileList(this, description);
......@@ -27,7 +26,7 @@ AuditConfigurationWidget::AuditConfigurationWidget()
bool AuditConfigurationWidget::isValid() const
{
if (fileList->isEmpty() == false) {
if (!fileList->isEmpty()) {
logDebug() << "Audit configuration valid";
return true;
}
......
......@@ -39,8 +39,8 @@ AuditConvertor::AuditConvertor()
QString AuditConvertor::getParam(const QString &message, const QString &name)
{
QRegularExpression re(QStringLiteral("\\s%1=([^\\s]*)").arg(name));
QRegularExpressionMatch match = re.match(message);
const QRegularExpression re(QStringLiteral("\\s%1=([^\\s]*)").arg(name));
const QRegularExpressionMatch match = re.match(message);
if (match.hasMatch()) {
return match.captured(1);
......@@ -51,7 +51,7 @@ QString AuditConvertor::getParam(const QString &message, const QString &name)
QString AuditConvertor::replaceParam(const QString &message, const QString &name, const QString &value)
{
QRegularExpression re(QStringLiteral("\\s%1=[^\\s]*").arg(name));
const QRegularExpression re(QStringLiteral("\\s%1=[^\\s]*").arg(name));
QString newMessage = message;
return newMessage.replace(re, QStringLiteral(" %1=%2").arg(name).arg(value));
......@@ -241,7 +241,7 @@ QString AuditConvertor::convertMode(const QString &mode, int base)
name = audit_ftype_to_name(ival & S_IFMT);
if (name != NULL) {
if (name) {
newMode = QString::fromLatin1(name);
} else {
unsigned first_ifmt_bit = S_IFMT & ~(S_IFMT - 1);
......
......@@ -12,8 +12,7 @@
QList<LogMode *> AuditLogModeFactory::createLogModes() const
{
QList<LogMode *> logModes;
logModes.append(new AuditLogMode());
const QList<LogMode *> logModes{new AuditLogMode()};
return logModes;
}
......
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