1 /*
2     SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QList>
10 #include <QMutex>
11 #include <QString>
12 
13 #include "globals.h"
14 
15 #include "logLine.h"
16 
17 #include "logFile.h"
18 #include "logViewColumn.h"
19 #include "logViewColumns.h"
20 
21 class LogViewModel;
22 class LogMode;
23 
24 class Analyzer : public QObject
25 {
26     Q_OBJECT
27 
28 public:
29     enum ReadingMode { UpdatingRead, FullRead };
30     Q_DECLARE_FLAGS(ReadingModes, ReadingMode)
31 
32     enum LogFileSortMode { AscendingSortedLogFile, FilteredLogFile, UnsortedLogFile };
33     Q_DECLARE_FLAGS(LogFileSortModes, LogFileSortMode)
34 
35     explicit Analyzer(LogMode *mode);
36 
37     ~Analyzer() override;
38 
39     virtual void watchLogFiles(bool enabled) = 0;
40 
41     virtual void setLogFiles(const QVector<LogFile> &logFiles) = 0;
42 
43     virtual LogViewColumns initColumns() = 0;
44 
45     void setLogViewModel(LogViewModel *logViewModel);
46 
47     bool isParsingPaused() const;
48 
49 public Q_SLOTS:
50     void setParsingPaused(bool paused);
51 
52 Q_SIGNALS:
53     void statusBarChanged(const QString &message);
54     void errorOccured(const QString &title, const QString &message);
55     void statusChanged(const QString &status);
56 
57     void openingProgressed();
58 
59     void logUpdated(int lineTotal);
60 
61     void readFileStarted(const LogMode &logMode, const LogFile &logFile, int fileIndex, int fileCount);
62     void readEnded();
63 
64 protected:
65     void informOpeningProgress(int currentPosition, int total);
66 
67     bool mParsingPaused = false;
68     LogViewModel *mLogViewModel = nullptr;
69     LogMode *const mLogMode;
70     QRecursiveMutex mInsertionLocking;
71     long mLogLineInternalIdGenerator = 0;
72 };
73 
74