UI: ConfAppManager: Simplify addOrUpdateApp()

This commit is contained in:
Nodir Temirkhodjaev 2024-01-12 15:42:23 +03:00
parent c0099a68c8
commit c270a23a33
2 changed files with 19 additions and 12 deletions

View File

@ -188,6 +188,21 @@ void ConfAppManager::updateAppEndTimer()
}
}
void ConfAppManager::onAddOrUpdateApp(const App &app, bool onlyUpdate)
{
if (!app.endTime.isNull()) {
updateAppEndTimer();
}
if (onlyUpdate) {
emitAppUpdated();
} else {
emitAppsChanged();
}
updateDriverUpdateAppConf(app);
}
void ConfAppManager::emitAppAlerted()
{
m_appAlertedTimer.startTrigger();
@ -255,24 +270,14 @@ bool ConfAppManager::addOrUpdateApp(const App &app, bool onlyUpdate)
if (ok) {
// Alert
const char *alertSql = app.alerted && !onlyUpdate ? sqlInsertAppAlert : sqlDeleteAppAlert;
const char *alertSql = (app.alerted && !onlyUpdate) ? sqlInsertAppAlert : sqlDeleteAppAlert;
sqliteDb()->executeEx(alertSql, { appIdVar });
}
commitTransaction(ok);
if (ok) {
if (!app.endTime.isNull()) {
updateAppEndTimer();
}
if (onlyUpdate) {
emitAppUpdated();
} else {
emitAppsChanged();
}
updateDriverUpdateAppConf(app);
onAddOrUpdateApp(app, onlyUpdate);
}
return ok;

View File

@ -63,6 +63,8 @@ protected:
void updateAppEndTimer();
private:
void onAddOrUpdateApp(const App &app, bool onlyUpdate);
bool deleteApp(qint64 appId, bool &isWildcard);
bool updateAppBlocked(qint64 appId, bool blocked, bool killProcess, bool &isWildcard);