File indexing completed on 2024-05-05 05:48:55

0001 /*
0002     SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "analyzer.h"
0008 
0009 #include "ksystemlogConfig.h"
0010 #include "ksystemlog_debug.h"
0011 
0012 #include "logViewModel.h"
0013 
0014 #include "logFileReader.h"
0015 #include "logMode.h"
0016 
0017 Analyzer::Analyzer(LogMode *mode)
0018     : QObject(nullptr)
0019     , mLogMode(mode)
0020     , mInsertionLocking()
0021 {
0022 }
0023 
0024 Analyzer::~Analyzer()
0025 {
0026     // logMode is managed by Globals
0027     // logViewModel is managed by LogViewWidget
0028 }
0029 
0030 bool Analyzer::isParsingPaused() const
0031 {
0032     return mParsingPaused;
0033 }
0034 
0035 void Analyzer::setParsingPaused(bool paused)
0036 {
0037     mParsingPaused = paused;
0038 
0039     bool watching;
0040     // If we resume the parsing, then parse files to know if new lines have been appended.
0041     if (mParsingPaused) {
0042         qCDebug(KSYSTEMLOG) << "Pausing reading";
0043         watching = false;
0044     } else {
0045         qCDebug(KSYSTEMLOG) << "Relaunch reading";
0046         watching = true;
0047     }
0048 
0049     watchLogFiles(watching);
0050 }
0051 
0052 void Analyzer::setLogViewModel(LogViewModel *logViewModel)
0053 {
0054     mLogViewModel = logViewModel;
0055 }
0056 
0057 void Analyzer::informOpeningProgress(int currentPosition, int total)
0058 {
0059     const int each = total / 100;
0060     if (each == 0) {
0061         return;
0062     }
0063 
0064     if (currentPosition % each == 0) {
0065         Q_EMIT openingProgressed();
0066     }
0067 }
0068 
0069 #include "moc_analyzer.cpp"