QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCLoggingCategoryManager.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QObject>
4#include <QtCore/QReadWriteLock>
5#include <QtCore/QSet>
6#include <QtCore/QSortFilterProxyModel>
7#include <QtCore/QString>
8#include <QtCore/QStringList>
9#include <QtQmlIntegration/QtQmlIntegration>
10
11class QJSEngine;
12class QQmlEngine;
15
16class QGCLoggingCategoryManager : public QObject
17{
18 Q_OBJECT
19 QML_ELEMENT
20 QML_SINGLETON
21 Q_MOC_INCLUDE("LoggingCategoryModel.h")
22 Q_PROPERTY(LoggingCategoryTreeModel* treeModel READ treeCategoryModel CONSTANT)
23 Q_PROPERTY(LoggingCategoryFlatModel* flatModel READ flatCategoryModel CONSTANT)
24 Q_PROPERTY(QSortFilterProxyModel* filteredFlatModel READ filteredFlatModel CONSTANT)
25 Q_PROPERTY(QStringList enabledCategories READ enabledCategories NOTIFY enabledCategoriesChanged)
26
27public:
29 static void init();
30 static QGCLoggingCategoryManager* create(QQmlEngine* qmlEngine, QJSEngine* jsEngine);
31
32 void registerCategory(const QString& category);
33
35
37
38 QSortFilterProxyModel* filteredFlatModel() { return &_filteredFlatModel; }
39
40 Q_INVOKABLE void setFilterText(const QString& text);
41
42 Q_INVOKABLE bool isCategoryEnabled(const QString& fullCategoryName) const;
43 Q_INVOKABLE void setCategoryEnabled(const QString& fullCategoryName, bool enable);
44 void installFilter(const QString& commandLineLoggingOptions = QString());
45 Q_INVOKABLE void disableAllCategories();
46 QStringList enabledCategories() const;
47
48signals:
50
51private:
53 bool _isCategoryEnabled(const QString& fullCategoryName) const;
54 void _refreshItemStates();
55 static void _categoryFilter(QLoggingCategory* category);
56
57 LoggingCategoryTreeModel* _treeModel = nullptr;
58 LoggingCategoryFlatModel* _flatModel = nullptr;
59 QSortFilterProxyModel _filteredFlatModel;
60
61 mutable QReadWriteLock _filterLock;
62 QSet<QString> _enabledCategories;
63 QSet<QString> _commandLineCategories;
64 bool _commandLineFullLogging = false;
65
66 static QLoggingCategory::CategoryFilter s_previousFilter;
67 static constexpr const char* kFilterRulesSettingsGroup = "LoggingFilters";
68};
void registerCategory(const QString &category)
Q_INVOKABLE void setFilterText(const QString &text)
static QGCLoggingCategoryManager * create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
Q_INVOKABLE void setCategoryEnabled(const QString &fullCategoryName, bool enable)
Q_INVOKABLE bool isCategoryEnabled(const QString &fullCategoryName) const
static QGCLoggingCategoryManager * instance()
void installFilter(const QString &commandLineLoggingOptions=QString())
LoggingCategoryTreeModel * treeCategoryModel()
QSortFilterProxyModel * filteredFlatModel()
LoggingCategoryFlatModel * flatCategoryModel()