mirror of
https://github.com/tnodir/fort
synced 2024-11-15 13:26:48 +00:00
UI: LogManager: Refactor models.
This commit is contained in:
parent
3f08da55f7
commit
054c378584
@ -15,6 +15,8 @@
|
|||||||
#include "driver/drivermanager.h"
|
#include "driver/drivermanager.h"
|
||||||
#include "fortsettings.h"
|
#include "fortsettings.h"
|
||||||
#include "log/logmanager.h"
|
#include "log/logmanager.h"
|
||||||
|
#include "log/model/appblockedmodel.h"
|
||||||
|
#include "log/model/iplistmodel.h"
|
||||||
#include "task/taskinfo.h"
|
#include "task/taskinfo.h"
|
||||||
#include "task/taskmanager.h"
|
#include "task/taskmanager.h"
|
||||||
#include "translationmanager.h"
|
#include "translationmanager.h"
|
||||||
@ -62,8 +64,14 @@ void FortManager::registerQmlTypes()
|
|||||||
"Singleton");
|
"Singleton");
|
||||||
qmlRegisterUncreatableType<FortSettings>("com.fortfirewall", 1, 0, "FortSettings",
|
qmlRegisterUncreatableType<FortSettings>("com.fortfirewall", 1, 0, "FortSettings",
|
||||||
"Singleton");
|
"Singleton");
|
||||||
|
|
||||||
qmlRegisterUncreatableType<LogManager>("com.fortfirewall", 1, 0, "LogManager",
|
qmlRegisterUncreatableType<LogManager>("com.fortfirewall", 1, 0, "LogManager",
|
||||||
"Singleton");
|
"Singleton");
|
||||||
|
qmlRegisterUncreatableType<AppBlockedModel>("com.fortfirewall", 1, 0, "AppBlockedModel",
|
||||||
|
"Singleton");
|
||||||
|
qmlRegisterUncreatableType<IpListModel>("com.fortfirewall", 1, 0, "IpListModel",
|
||||||
|
"Singleton");
|
||||||
|
|
||||||
qmlRegisterUncreatableType<TranslationManager>("com.fortfirewall", 1, 0, "TranslationManager",
|
qmlRegisterUncreatableType<TranslationManager>("com.fortfirewall", 1, 0, "TranslationManager",
|
||||||
"Singleton");
|
"Singleton");
|
||||||
qmlRegisterUncreatableType<TaskManager>("com.fortfirewall", 1, 0, "TaskManager",
|
qmlRegisterUncreatableType<TaskManager>("com.fortfirewall", 1, 0, "TaskManager",
|
||||||
|
@ -16,16 +16,6 @@ LogManager::LogManager(DriverWorker *driverWorker,
|
|||||||
setupDriverWorker();
|
setupDriverWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
QAbstractItemModel *LogManager::appBlockedModel() const
|
|
||||||
{
|
|
||||||
return m_appBlockedModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
QAbstractItemModel *LogManager::ipListModel(const QString &appPath) const
|
|
||||||
{
|
|
||||||
return m_appBlockedModel->ipListModel(appPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LogManager::clearModels() const
|
void LogManager::clearModels() const
|
||||||
{
|
{
|
||||||
m_appBlockedModel->clear();
|
m_appBlockedModel->clear();
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef LOGMANAGER_H
|
#ifndef LOGMANAGER_H
|
||||||
#define LOGMANAGER_H
|
#define LOGMANAGER_H
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class AppBlockedModel;
|
class AppBlockedModel;
|
||||||
@ -12,20 +11,21 @@ class LogEntry;
|
|||||||
class LogManager : public QObject
|
class LogManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(AppBlockedModel *appBlockedModel READ appBlockedModel CONSTANT)
|
||||||
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
|
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit LogManager(DriverWorker *driverWorker,
|
explicit LogManager(DriverWorker *driverWorker,
|
||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
|
AppBlockedModel *appBlockedModel() const { return m_appBlockedModel; }
|
||||||
|
|
||||||
QString errorMessage() const { return m_errorMessage; }
|
QString errorMessage() const { return m_errorMessage; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void errorMessageChanged();
|
void errorMessageChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QAbstractItemModel *appBlockedModel() const;
|
|
||||||
QAbstractItemModel *ipListModel(const QString &appPath) const;
|
|
||||||
|
|
||||||
void clearModels() const;
|
void clearModels() const;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ AppBlockedModel::AppBlockedModel(QObject *parent) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QAbstractItemModel *AppBlockedModel::ipListModel(const QString &appPath) const
|
IpListModel *AppBlockedModel::ipListModel(const QString &appPath) const
|
||||||
{
|
{
|
||||||
if (appPath != m_ipListModel->appPath()) {
|
if (appPath != m_ipListModel->appPath()) {
|
||||||
m_ipListModel->setAppPath(appPath);
|
m_ipListModel->setAppPath(appPath);
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QAbstractItemModel *ipListModel(const QString &appPath) const;
|
IpListModel *ipListModel(const QString &appPath) const;
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import com.fortfirewall 1.0
|
|||||||
BasePage {
|
BasePage {
|
||||||
|
|
||||||
readonly property LogManager logManager: fortManager.logManager
|
readonly property LogManager logManager: fortManager.logManager
|
||||||
|
readonly property AppBlockedModel appBlockedModel: logManager.appBlockedModel
|
||||||
|
|
||||||
property bool logReadingEnabled: false
|
property bool logReadingEnabled: false
|
||||||
property bool addressResolvingEnabled: false
|
property bool addressResolvingEnabled: false
|
||||||
@ -93,7 +94,7 @@ BasePage {
|
|||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
model: logManager.appBlockedModel()
|
model: appBlockedModel
|
||||||
|
|
||||||
highlightRangeMode: ListView.ApplyRange
|
highlightRangeMode: ListView.ApplyRange
|
||||||
highlightResizeDuration: 0
|
highlightResizeDuration: 0
|
||||||
@ -147,7 +148,7 @@ BasePage {
|
|||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
spacing: 4
|
spacing: 4
|
||||||
|
|
||||||
model: logManager.ipListModel(currentAppPath)
|
model: appBlockedModel.ipListModel(currentAppPath)
|
||||||
|
|
||||||
delegate: Label {
|
delegate: Label {
|
||||||
width: ipListView.width
|
width: ipListView.width
|
||||||
|
Loading…
Reference in New Issue
Block a user