UI: LogManager: Refactor models.

This commit is contained in:
Nodir Temirkhodjaev 2017-11-17 16:44:33 +05:00
parent 3f08da55f7
commit 054c378584
6 changed files with 16 additions and 17 deletions

View File

@ -15,6 +15,8 @@
#include "driver/drivermanager.h"
#include "fortsettings.h"
#include "log/logmanager.h"
#include "log/model/appblockedmodel.h"
#include "log/model/iplistmodel.h"
#include "task/taskinfo.h"
#include "task/taskmanager.h"
#include "translationmanager.h"
@ -62,8 +64,14 @@ void FortManager::registerQmlTypes()
"Singleton");
qmlRegisterUncreatableType<FortSettings>("com.fortfirewall", 1, 0, "FortSettings",
"Singleton");
qmlRegisterUncreatableType<LogManager>("com.fortfirewall", 1, 0, "LogManager",
"Singleton");
qmlRegisterUncreatableType<AppBlockedModel>("com.fortfirewall", 1, 0, "AppBlockedModel",
"Singleton");
qmlRegisterUncreatableType<IpListModel>("com.fortfirewall", 1, 0, "IpListModel",
"Singleton");
qmlRegisterUncreatableType<TranslationManager>("com.fortfirewall", 1, 0, "TranslationManager",
"Singleton");
qmlRegisterUncreatableType<TaskManager>("com.fortfirewall", 1, 0, "TaskManager",

View File

@ -16,16 +16,6 @@ LogManager::LogManager(DriverWorker *driverWorker,
setupDriverWorker();
}
QAbstractItemModel *LogManager::appBlockedModel() const
{
return m_appBlockedModel;
}
QAbstractItemModel *LogManager::ipListModel(const QString &appPath) const
{
return m_appBlockedModel->ipListModel(appPath);
}
void LogManager::clearModels() const
{
m_appBlockedModel->clear();

View File

@ -1,7 +1,6 @@
#ifndef LOGMANAGER_H
#define LOGMANAGER_H
#include <QAbstractItemModel>
#include <QObject>
class AppBlockedModel;
@ -12,20 +11,21 @@ class LogEntry;
class LogManager : public QObject
{
Q_OBJECT
Q_PROPERTY(AppBlockedModel *appBlockedModel READ appBlockedModel CONSTANT)
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
public:
explicit LogManager(DriverWorker *driverWorker,
QObject *parent = nullptr);
AppBlockedModel *appBlockedModel() const { return m_appBlockedModel; }
QString errorMessage() const { return m_errorMessage; }
signals:
void errorMessageChanged();
public slots:
QAbstractItemModel *appBlockedModel() const;
QAbstractItemModel *ipListModel(const QString &appPath) const;
void clearModels() const;

View File

@ -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()) {
m_ipListModel->setAppPath(appPath);

View File

@ -21,7 +21,7 @@ public:
signals:
public slots:
QAbstractItemModel *ipListModel(const QString &appPath) const;
IpListModel *ipListModel(const QString &appPath) const;
void clear();

View File

@ -7,6 +7,7 @@ import com.fortfirewall 1.0
BasePage {
readonly property LogManager logManager: fortManager.logManager
readonly property AppBlockedModel appBlockedModel: logManager.appBlockedModel
property bool logReadingEnabled: false
property bool addressResolvingEnabled: false
@ -93,7 +94,7 @@ BasePage {
Layout.fillHeight: true
spacing: 10
model: logManager.appBlockedModel()
model: appBlockedModel
highlightRangeMode: ListView.ApplyRange
highlightResizeDuration: 0
@ -147,7 +148,7 @@ BasePage {
Layout.fillHeight: true
spacing: 4
model: logManager.ipListModel(currentAppPath)
model: appBlockedModel.ipListModel(currentAppPath)
delegate: Label {
width: ipListView.width