mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:35:08 +00:00
UI: ConfManager: Add app/zone edited signals.
This commit is contained in:
parent
12150dc54f
commit
f66aeee889
@ -372,21 +372,6 @@ void ConfManager::showErrorMessage(const QString &errorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
bool ConfManager::checkResult(bool ok, bool commit)
|
||||
{
|
||||
const auto errorMessage = ok ? QString() : sqliteDb()->errorMessage();
|
||||
|
||||
if (commit) {
|
||||
sqliteDb()->endTransaction(ok);
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
showErrorMessage(errorMessage);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool ConfManager::initialize()
|
||||
{
|
||||
if (!sqliteDb()->open()) {
|
||||
@ -603,8 +588,11 @@ qint64 ConfManager::appIdByPath(const QString &appPath)
|
||||
}
|
||||
|
||||
bool ConfManager::addApp(const QString &appPath, const QString &appName, const QDateTime &endTime,
|
||||
qint64 groupId, bool useGroupPerm, bool blocked, bool alerted)
|
||||
qint64 groupId, int groupIndex, bool useGroupPerm, bool blocked, bool alerted)
|
||||
{
|
||||
if (!updateDriverUpdateApp(appPath, groupIndex, useGroupPerm, blocked))
|
||||
return false;
|
||||
|
||||
bool ok = false;
|
||||
|
||||
sqliteDb()->beginTransaction();
|
||||
@ -628,16 +616,17 @@ bool ConfManager::addApp(const QString &appPath, const QString &appName, const Q
|
||||
m_appEndTimer.start();
|
||||
}
|
||||
|
||||
if (alerted) {
|
||||
emit alertedAppAdded();
|
||||
}
|
||||
emit appAdded(alerted);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool ConfManager::deleteApp(qint64 appId)
|
||||
bool ConfManager::deleteApp(qint64 appId, const QString &appPath)
|
||||
{
|
||||
if (!updateDriverDeleteApp(appPath))
|
||||
return false;
|
||||
|
||||
bool ok = false;
|
||||
|
||||
sqliteDb()->beginTransaction();
|
||||
@ -649,12 +638,21 @@ bool ConfManager::deleteApp(qint64 appId)
|
||||
sqliteDb()->executeEx(sqlDeleteAppAlert, vars, 0, &ok);
|
||||
}
|
||||
|
||||
return checkResult(ok, true);
|
||||
checkResult(ok, true);
|
||||
|
||||
if (ok) {
|
||||
emit appRemoved();
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool ConfManager::updateApp(qint64 appId, const QString &appName, const QDateTime &endTime,
|
||||
qint64 groupId, bool useGroupPerm, bool blocked)
|
||||
bool ConfManager::updateApp(qint64 appId, const QString &appPath, const QString &appName,
|
||||
const QDateTime &endTime, qint64 groupId, int groupIndex, bool useGroupPerm, bool blocked)
|
||||
{
|
||||
if (!updateDriverUpdateApp(appPath, groupIndex, useGroupPerm, blocked))
|
||||
return false;
|
||||
|
||||
bool ok = false;
|
||||
|
||||
sqliteDb()->beginTransaction();
|
||||
@ -669,8 +667,12 @@ bool ConfManager::updateApp(qint64 appId, const QString &appName, const QDateTim
|
||||
|
||||
checkResult(ok, true);
|
||||
|
||||
if (ok && !endTime.isNull()) {
|
||||
m_appEndTimer.start();
|
||||
if (ok) {
|
||||
if (!endTime.isNull()) {
|
||||
m_appEndTimer.start();
|
||||
}
|
||||
|
||||
emit appUpdated();
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -684,7 +686,13 @@ bool ConfManager::updateAppName(qint64 appId, const QString &appName)
|
||||
|
||||
sqliteDb()->executeEx(sqlUpdateAppName, vars, 0, &ok);
|
||||
|
||||
return checkResult(ok);
|
||||
checkResult(ok);
|
||||
|
||||
if (ok) {
|
||||
emit appUpdated();
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool ConfManager::walkApps(const std::function<walkAppsCallback> &func)
|
||||
@ -730,8 +738,8 @@ void ConfManager::updateAppEndTimes()
|
||||
const QString appName = stmt.columnText(4);
|
||||
const bool useGroupPerm = stmt.columnBool(5);
|
||||
|
||||
if (updateDriverUpdateApp(appPath, groupIndex, useGroupPerm, true)
|
||||
&& updateApp(appId, appName, QDateTime(), groupId, useGroupPerm, true)) {
|
||||
if (updateApp(appId, appPath, appName, QDateTime(), groupId, groupIndex, useGroupPerm,
|
||||
true)) {
|
||||
isAppEndTimesUpdated = true;
|
||||
}
|
||||
}
|
||||
@ -762,7 +770,13 @@ bool ConfManager::addZone(const QString &zoneName, const QString &sourceCode, co
|
||||
|
||||
sqliteDb()->executeEx(sqlInsertZone, vars, 0, &ok);
|
||||
|
||||
return checkResult(ok);
|
||||
checkResult(ok);
|
||||
|
||||
if (ok) {
|
||||
emit zoneAdded();
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
int ConfManager::getFreeZoneId()
|
||||
@ -796,12 +810,21 @@ bool ConfManager::deleteZone(int zoneId)
|
||||
sqliteDb()->executeEx(sqlDeleteAddressGroupZone, { qint64(zoneUnMask) }, 0, &ok);
|
||||
}
|
||||
|
||||
return checkResult(ok, true);
|
||||
checkResult(ok, true);
|
||||
|
||||
if (ok) {
|
||||
emit zoneRemoved(zoneId);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool ConfManager::updateZone(int zoneId, const QString &zoneName, const QString &sourceCode,
|
||||
const QString &url, const QString &formData, bool enabled, bool customUrl)
|
||||
{
|
||||
if (!updateDriverZoneFlag(zoneId, enabled))
|
||||
return false;
|
||||
|
||||
bool ok = false;
|
||||
|
||||
const auto vars = QVariantList()
|
||||
@ -809,7 +832,13 @@ bool ConfManager::updateZone(int zoneId, const QString &zoneName, const QString
|
||||
|
||||
sqliteDb()->executeEx(sqlUpdateZone, vars, 0, &ok);
|
||||
|
||||
return checkResult(ok);
|
||||
checkResult(ok);
|
||||
|
||||
if (ok) {
|
||||
emit zoneUpdated();
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool ConfManager::updateZoneName(int zoneId, const QString &zoneName)
|
||||
@ -820,18 +849,33 @@ bool ConfManager::updateZoneName(int zoneId, const QString &zoneName)
|
||||
|
||||
sqliteDb()->executeEx(sqlUpdateZoneName, vars, 0, &ok);
|
||||
|
||||
return checkResult(ok);
|
||||
checkResult(ok);
|
||||
|
||||
if (ok) {
|
||||
emit zoneUpdated();
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool ConfManager::updateZoneEnabled(int zoneId, bool enabled)
|
||||
{
|
||||
if (!updateDriverZoneFlag(zoneId, enabled))
|
||||
return false;
|
||||
|
||||
bool ok = false;
|
||||
|
||||
const auto vars = QVariantList() << zoneId << enabled;
|
||||
|
||||
sqliteDb()->executeEx(sqlUpdateZoneEnabled, vars, 0, &ok);
|
||||
|
||||
return checkResult(ok);
|
||||
checkResult(ok);
|
||||
|
||||
if (ok) {
|
||||
emit zoneUpdated();
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool ConfManager::updateZoneResult(int zoneId, const QString &textChecksum,
|
||||
@ -845,7 +889,13 @@ bool ConfManager::updateZoneResult(int zoneId, const QString &textChecksum,
|
||||
|
||||
sqliteDb()->executeEx(sqlUpdateZoneResult, vars, 0, &ok);
|
||||
|
||||
return checkResult(ok);
|
||||
checkResult(ok);
|
||||
|
||||
if (ok) {
|
||||
emit zoneUpdated();
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool ConfManager::validateDriver()
|
||||
@ -865,7 +915,6 @@ bool ConfManager::updateDriverConf(bool onlyFlags)
|
||||
|
||||
const int confSize = onlyFlags ? confUtil.writeFlags(*conf(), buf)
|
||||
: confUtil.write(*conf(), this, *envManager(), buf);
|
||||
|
||||
if (confSize == 0) {
|
||||
showErrorMessage(confUtil.errorMessage());
|
||||
return false;
|
||||
@ -1085,3 +1134,18 @@ bool ConfManager::saveTask(TaskInfo *taskInfo)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConfManager::checkResult(bool ok, bool commit)
|
||||
{
|
||||
const auto errorMessage = ok ? QString() : sqliteDb()->errorMessage();
|
||||
|
||||
if (commit) {
|
||||
sqliteDb()->endTransaction(ok);
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
showErrorMessage(errorMessage);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
@ -61,10 +61,11 @@ public:
|
||||
|
||||
qint64 appIdByPath(const QString &appPath);
|
||||
bool addApp(const QString &appPath, const QString &appName, const QDateTime &endTime,
|
||||
qint64 groupId, bool useGroupPerm, bool blocked, bool alerted = false);
|
||||
bool deleteApp(qint64 appId);
|
||||
bool updateApp(qint64 appId, const QString &appName, const QDateTime &endTime, qint64 groupId,
|
||||
bool useGroupPerm, bool blocked);
|
||||
qint64 groupId, int groupIndex, bool useGroupPerm, bool blocked, bool alerted = false);
|
||||
bool deleteApp(qint64 appId, const QString &appPath);
|
||||
bool updateApp(qint64 appId, const QString &appPath, const QString &appName,
|
||||
const QDateTime &endTime, qint64 groupId, int groupIndex, bool useGroupPerm,
|
||||
bool blocked);
|
||||
bool updateAppName(qint64 appId, const QString &appName);
|
||||
|
||||
bool walkApps(const std::function<walkAppsCallback> &func) override;
|
||||
@ -85,18 +86,21 @@ public:
|
||||
const QDateTime &sourceModTime, const QDateTime &lastRun, const QDateTime &lastSuccess);
|
||||
|
||||
bool validateDriver();
|
||||
bool updateDriverConf(bool onlyFlags = false);
|
||||
bool updateDriverDeleteApp(const QString &appPath);
|
||||
bool updateDriverUpdateApp(const QString &appPath, int groupIndex, bool useGroupPerm,
|
||||
bool blocked, bool remove = false);
|
||||
virtual bool updateDriverConf(bool onlyFlags = false);
|
||||
void updateDriverZones(quint32 zonesMask, quint32 enabledMask, quint32 dataSize,
|
||||
const QList<QByteArray> &zonesData);
|
||||
bool updateDriverZoneFlag(int zoneId, bool enabled);
|
||||
|
||||
signals:
|
||||
void confChanged(bool onlyFlags);
|
||||
|
||||
void appEndTimesUpdated();
|
||||
void alertedAppAdded();
|
||||
void appAdded(bool alerted);
|
||||
void appRemoved();
|
||||
void appUpdated();
|
||||
|
||||
void zoneAdded();
|
||||
void zoneRemoved(int zoneId);
|
||||
void zoneUpdated();
|
||||
|
||||
protected:
|
||||
virtual void setupAppEndTimer();
|
||||
@ -109,10 +113,13 @@ protected:
|
||||
void saveClientExtFlags(const IniOptions &ini);
|
||||
|
||||
private:
|
||||
bool checkResult(bool ok, bool commit = false);
|
||||
|
||||
void setupDefault(FirewallConf &conf) const;
|
||||
|
||||
bool updateDriverDeleteApp(const QString &appPath);
|
||||
bool updateDriverUpdateApp(const QString &appPath, int groupIndex, bool useGroupPerm,
|
||||
bool blocked, bool remove = false);
|
||||
bool updateDriverZoneFlag(int zoneId, bool enabled);
|
||||
|
||||
bool loadFromDb(FirewallConf &conf, bool &isNew);
|
||||
bool saveToDb(const FirewallConf &conf);
|
||||
|
||||
@ -126,6 +133,8 @@ private:
|
||||
bool loadTask(TaskInfo *taskInfo);
|
||||
bool saveTask(TaskInfo *taskInfo);
|
||||
|
||||
bool checkResult(bool ok, bool commit = false);
|
||||
|
||||
private:
|
||||
FortManager *m_fortManager = nullptr;
|
||||
SqliteDb *m_sqliteDb = nullptr;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "../../../conf/addressgroup.h"
|
||||
#include "../../../conf/confmanager.h"
|
||||
#include "../../../conf/firewallconf.h"
|
||||
#include "../../../driver/drivercommon.h"
|
||||
#include "../../../fortmanager.h"
|
||||
@ -344,7 +345,7 @@ void AddressesPage::setupZones()
|
||||
m_excludeAddresses->btSelectZones()->setMenu(m_menuZones);
|
||||
updateZonesMenuEnabled();
|
||||
|
||||
connect(zoneListModel(), &ZoneListModel::zoneRemoved, this, [&](int zoneId) {
|
||||
connect(confManager(), &ConfManager::zoneRemoved, this, [&](int zoneId) {
|
||||
for (auto addrGroup : addressGroups()) {
|
||||
addrGroup->removeIncludeZone(zoneId);
|
||||
addrGroup->removeExcludeZone(zoneId);
|
||||
|
@ -22,6 +22,11 @@ FortSettings *BasePage::settings() const
|
||||
return ctrl()->settings();
|
||||
}
|
||||
|
||||
ConfManager *BasePage::confManager() const
|
||||
{
|
||||
return ctrl()->confManager();
|
||||
}
|
||||
|
||||
FirewallConf *BasePage::conf() const
|
||||
{
|
||||
return ctrl()->conf();
|
||||
|
@ -14,6 +14,7 @@ QT_FORWARD_DECLARE_CLASS(QMenu)
|
||||
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
||||
QT_FORWARD_DECLARE_CLASS(QTabBar)
|
||||
|
||||
class ConfManager;
|
||||
class DriverManager;
|
||||
class FirewallConf;
|
||||
class FortManager;
|
||||
@ -35,6 +36,7 @@ protected:
|
||||
OptionsController *ctrl() const { return m_ctrl; }
|
||||
FortManager *fortManager() const;
|
||||
FortSettings *settings() const;
|
||||
ConfManager *confManager() const;
|
||||
FirewallConf *conf() const;
|
||||
IniOptions *ini() const;
|
||||
DriverManager *driverManager() const;
|
||||
|
@ -450,7 +450,7 @@ bool ZonesWindow::saveZoneEditForm()
|
||||
}
|
||||
|
||||
return zoneListModel()->updateZone(
|
||||
zoneRow.zoneId, zoneName, sourceCode, url, formData, enabled, customUrl, zoneEdited);
|
||||
zoneRow.zoneId, zoneName, sourceCode, url, formData, enabled, customUrl);
|
||||
}
|
||||
|
||||
void ZonesWindow::updateZone(int row, bool enabled)
|
||||
|
@ -358,8 +358,11 @@ void FortManager::setupTrayIcon()
|
||||
connect(m_trayIcon, &QSystemTrayIcon::messageClicked, this, &FortManager::onTrayMessageClicked);
|
||||
|
||||
connect(confManager(), &ConfManager::confChanged, m_trayIcon, &TrayIcon::updateTrayMenu);
|
||||
connect(confManager(), &ConfManager::alertedAppAdded, m_trayIcon,
|
||||
[&] { m_trayIcon->updateTrayIcon(true); });
|
||||
connect(confManager(), &ConfManager::appAdded, m_trayIcon, [&](bool alerted) {
|
||||
if (alerted) {
|
||||
m_trayIcon->updateTrayIcon(true);
|
||||
}
|
||||
});
|
||||
|
||||
connect(qApp, &QCoreApplication::aboutToQuit, this, &FortManager::closeUi);
|
||||
}
|
||||
|
@ -58,6 +58,8 @@ void AppListModel::initialize()
|
||||
refresh();
|
||||
});
|
||||
connect(confManager(), &ConfManager::appEndTimesUpdated, this, &AppListModel::refresh);
|
||||
connect(confManager(), &ConfManager::appAdded, this, &TableSqlModel::reset);
|
||||
connect(confManager(), &ConfManager::appUpdated, this, &TableSqlModel::refresh);
|
||||
}
|
||||
|
||||
void AppListModel::handleLogBlocked(const LogEntryBlocked &logEntry)
|
||||
@ -70,10 +72,7 @@ void AppListModel::handleLogBlocked(const LogEntryBlocked &logEntry)
|
||||
const auto groupId = appGroupAt(0)->id();
|
||||
const auto appName = appInfoCache()->appName(appPath);
|
||||
|
||||
if (confManager()->addApp(
|
||||
appPath, appName, QDateTime(), groupId, false, logEntry.blocked(), true)) {
|
||||
reset();
|
||||
}
|
||||
confManager()->addApp(appPath, appName, QDateTime(), groupId, false, logEntry.blocked(), true);
|
||||
}
|
||||
|
||||
int AppListModel::columnCount(const QModelIndex &parent) const
|
||||
@ -316,53 +315,31 @@ AppRow AppListModel::appRowByPath(const QString &appPath) const
|
||||
bool AppListModel::addApp(const QString &appPath, const QString &appName, const QDateTime &endTime,
|
||||
int groupIndex, bool useGroupPerm, bool blocked)
|
||||
{
|
||||
if (!confManager()->updateDriverUpdateApp(appPath, groupIndex, useGroupPerm, blocked))
|
||||
return false;
|
||||
|
||||
const auto groupId = appGroupAt(groupIndex)->id();
|
||||
|
||||
if (confManager()->addApp(appPath, appName, endTime, groupId, useGroupPerm, blocked)) {
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return confManager()->addApp(
|
||||
appPath, appName, endTime, groupId, groupIndex, useGroupPerm, blocked);
|
||||
}
|
||||
|
||||
bool AppListModel::updateApp(qint64 appId, const QString &appPath, const QString &appName,
|
||||
const QDateTime &endTime, int groupIndex, bool useGroupPerm, bool blocked)
|
||||
{
|
||||
if (!confManager()->updateDriverUpdateApp(appPath, groupIndex, useGroupPerm, blocked))
|
||||
return false;
|
||||
|
||||
const auto groupId = appGroupAt(groupIndex)->id();
|
||||
|
||||
if (confManager()->updateApp(appId, appName, endTime, groupId, useGroupPerm, blocked)) {
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return confManager()->updateApp(
|
||||
appId, appPath, appName, endTime, groupId, groupIndex, useGroupPerm, blocked);
|
||||
}
|
||||
|
||||
bool AppListModel::updateAppName(qint64 appId, const QString &appName)
|
||||
{
|
||||
if (confManager()->updateAppName(appId, appName)) {
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return confManager()->updateAppName(appId, appName);
|
||||
}
|
||||
|
||||
void AppListModel::deleteApp(qint64 appId, const QString &appPath, int row)
|
||||
{
|
||||
if (!confManager()->updateDriverDeleteApp(appPath))
|
||||
return;
|
||||
|
||||
beginRemoveRows(QModelIndex(), row, row);
|
||||
|
||||
if (confManager()->deleteApp(appId)) {
|
||||
if (confManager()->deleteApp(appId, appPath)) {
|
||||
invalidateRowCache();
|
||||
removeRow(row);
|
||||
}
|
||||
|
@ -25,8 +25,11 @@ SqliteDb *ZoneListModel::sqliteDb() const
|
||||
|
||||
void ZoneListModel::initialize()
|
||||
{
|
||||
initZoneTypes();
|
||||
initZoneSources();
|
||||
setupZoneTypes();
|
||||
setupZoneSources();
|
||||
|
||||
connect(confManager(), &ConfManager::zoneAdded, this, &TableSqlModel::reset);
|
||||
connect(confManager(), &ConfManager::zoneUpdated, this, &TableSqlModel::refresh);
|
||||
}
|
||||
|
||||
int ZoneListModel::columnCount(const QModelIndex &parent) const
|
||||
@ -140,64 +143,32 @@ const ZoneRow &ZoneListModel::zoneRowAt(int row) const
|
||||
bool ZoneListModel::addZone(const QString &zoneName, const QString &sourceCode, const QString &url,
|
||||
const QString &formData, bool enabled, bool customUrl, int &zoneId)
|
||||
{
|
||||
if (confManager()->addZone(zoneName, sourceCode, url, formData, enabled, customUrl, zoneId)) {
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return confManager()->addZone(zoneName, sourceCode, url, formData, enabled, customUrl, zoneId);
|
||||
}
|
||||
|
||||
bool ZoneListModel::updateZone(int zoneId, const QString &zoneName, const QString &sourceCode,
|
||||
const QString &url, const QString &formData, bool enabled, bool customUrl,
|
||||
bool updateDriver)
|
||||
const QString &url, const QString &formData, bool enabled, bool customUrl)
|
||||
{
|
||||
if (updateDriver && !confManager()->updateDriverZoneFlag(zoneId, enabled))
|
||||
return false;
|
||||
|
||||
if (confManager()->updateZone(
|
||||
zoneId, zoneName, sourceCode, url, formData, enabled, customUrl)) {
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return confManager()->updateZone(
|
||||
zoneId, zoneName, sourceCode, url, formData, enabled, customUrl);
|
||||
}
|
||||
|
||||
bool ZoneListModel::updateZoneName(int zoneId, const QString &zoneName)
|
||||
{
|
||||
if (confManager()->updateZoneName(zoneId, zoneName)) {
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return confManager()->updateZoneName(zoneId, zoneName);
|
||||
}
|
||||
|
||||
bool ZoneListModel::updateZoneEnabled(int zoneId, bool enabled)
|
||||
{
|
||||
if (!confManager()->updateDriverZoneFlag(zoneId, enabled))
|
||||
return false;
|
||||
|
||||
if (confManager()->updateZoneEnabled(zoneId, enabled)) {
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return confManager()->updateZoneEnabled(zoneId, enabled);
|
||||
}
|
||||
|
||||
bool ZoneListModel::updateZoneResult(int zoneId, const QString &textChecksum,
|
||||
const QString &binChecksum, const QDateTime &sourceModTime, const QDateTime &lastRun,
|
||||
const QDateTime &lastSuccess)
|
||||
{
|
||||
if (confManager()->updateZoneResult(
|
||||
zoneId, textChecksum, binChecksum, sourceModTime, lastRun, lastSuccess)) {
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return confManager()->updateZoneResult(
|
||||
zoneId, textChecksum, binChecksum, sourceModTime, lastRun, lastSuccess);
|
||||
}
|
||||
|
||||
void ZoneListModel::deleteZone(int zoneId, int row)
|
||||
@ -205,7 +176,6 @@ void ZoneListModel::deleteZone(int zoneId, int row)
|
||||
beginRemoveRows(QModelIndex(), row, row);
|
||||
|
||||
if (confManager()->deleteZone(zoneId)) {
|
||||
emit zoneRemoved(zoneId);
|
||||
invalidateRowCache();
|
||||
removeRow(row);
|
||||
}
|
||||
@ -275,7 +245,7 @@ QString ZoneListModel::sqlBase() const
|
||||
" FROM zone";
|
||||
}
|
||||
|
||||
void ZoneListModel::initZoneTypes()
|
||||
void ZoneListModel::setupZoneTypes()
|
||||
{
|
||||
const auto data = FileUtil::readFileData(":/zone/types.json");
|
||||
if (data.isEmpty())
|
||||
@ -297,7 +267,7 @@ void ZoneListModel::initZoneTypes()
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneListModel::initZoneSources()
|
||||
void ZoneListModel::setupZoneSources()
|
||||
{
|
||||
const auto data = FileUtil::readFileData(":/zone/sources.json");
|
||||
if (data.isEmpty())
|
||||
|
@ -56,8 +56,7 @@ public:
|
||||
bool addZone(const QString &zoneName, const QString &sourceCode, const QString &url,
|
||||
const QString &formData, bool enabled, bool customUrl, int &zoneId);
|
||||
bool updateZone(int zoneId, const QString &zoneName, const QString &sourceCode,
|
||||
const QString &url, const QString &formData, bool enabled, bool customUrl,
|
||||
bool updateDriver = true);
|
||||
const QString &url, const QString &formData, bool enabled, bool customUrl);
|
||||
bool updateZoneName(int zoneId, const QString &zoneName);
|
||||
bool updateZoneEnabled(int zoneId, bool enabled);
|
||||
bool updateZoneResult(int zoneId, const QString &textChecksum, const QString &binChecksum,
|
||||
@ -71,9 +70,6 @@ public:
|
||||
QVariant zoneSourceByCode(const QString &sourceCode) const;
|
||||
const QVariantList &zoneSources() const { return m_zoneSources; }
|
||||
|
||||
signals:
|
||||
void zoneRemoved(int zoneId);
|
||||
|
||||
protected:
|
||||
bool updateTableRow(int row) const override;
|
||||
TableRow &tableRow() const override { return m_zoneRow; }
|
||||
@ -84,9 +80,9 @@ private:
|
||||
QVariant dataDisplay(const QModelIndex &index) const;
|
||||
QVariant dataCheckState(const QModelIndex &index) const;
|
||||
|
||||
void initZoneTypes();
|
||||
void initZoneSources();
|
||||
void initZoneSourceNames();
|
||||
void setupZoneTypes();
|
||||
void setupZoneSources();
|
||||
void setupZoneSourceNames();
|
||||
|
||||
private:
|
||||
ConfManager *m_confManager = nullptr;
|
||||
|
@ -15,6 +15,8 @@ public:
|
||||
|
||||
RpcManager *rpcManager() const;
|
||||
|
||||
bool updateDriverConf(bool /*onlyFlags*/ = false) override { return false; }
|
||||
|
||||
void onConfChanged(const QVariant &confVar);
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user