From 5abc3981bb440018afba1e4db03a1e0f0d93a24a Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Mon, 29 Jan 2024 19:48:17 +0300 Subject: [PATCH] UI: ProgramEditDialog: Simplify fillApp() --- src/ui/form/prog/programeditdialog.cpp | 34 ++++++++++++++++---------- src/ui/form/prog/programeditdialog.h | 2 ++ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/ui/form/prog/programeditdialog.cpp b/src/ui/form/prog/programeditdialog.cpp index f09ea0df..d44abc9e 100644 --- a/src/ui/form/prog/programeditdialog.cpp +++ b/src/ui/form/prog/programeditdialog.cpp @@ -642,21 +642,29 @@ void ProgramEditDialog::fillApp(App &app) const app.acceptZones = m_btZones->zones(); app.rejectZones = m_btZones->uncheckedZones(); - // App Path - { - const QString appPath = m_editPath->text(); - app.appOriginPath = isWildcard() ? m_editWildcard->toPlainText() : appPath; - app.appPath = FileUtil::normalizePath(appPath); - } + fillAppPath(app); + fillAppEndTime(app); +} - if (!app.blocked) { - if (m_cscBlockAppIn->checkBox()->isChecked()) { - const int minutes = m_cscBlockAppIn->spinBox()->value(); +void ProgramEditDialog::fillAppPath(App &app) const +{ + const QString appPath = m_editPath->text(); - app.endTime = QDateTime::currentDateTime().addSecs(minutes * 60); - } else if (m_cbBlockAppAt->isChecked()) { - app.endTime = m_dteBlockAppAt->dateTime(); - } + app.appOriginPath = isWildcard() ? m_editWildcard->toPlainText() : appPath; + app.appPath = FileUtil::normalizePath(appPath); +} + +void ProgramEditDialog::fillAppEndTime(App &app) const +{ + if (app.blocked) + return; + + if (m_cscBlockAppIn->checkBox()->isChecked()) { + const int minutes = m_cscBlockAppIn->spinBox()->value(); + + app.endTime = QDateTime::currentDateTime().addSecs(minutes * 60); + } else if (m_cbBlockAppAt->isChecked()) { + app.endTime = m_dteBlockAppAt->dateTime(); } } diff --git a/src/ui/form/prog/programeditdialog.h b/src/ui/form/prog/programeditdialog.h index 5a32ec02..8f55108c 100644 --- a/src/ui/form/prog/programeditdialog.h +++ b/src/ui/form/prog/programeditdialog.h @@ -73,6 +73,8 @@ private: bool validateFields() const; void fillApp(App &app) const; + void fillAppPath(App &app) const; + void fillAppEndTime(App &app) const; bool isWildcard() const;