diff --git a/src/ui/conf/confmanager.cpp b/src/ui/conf/confmanager.cpp index 82a35094..b64fbd58 100644 --- a/src/ui/conf/confmanager.cpp +++ b/src/ui/conf/confmanager.cpp @@ -96,21 +96,21 @@ const char *const sqlUpdateAppResetGroup = "UPDATE app" const char *const sqlSelectTaskByName = "SELECT task_id, enabled," " run_on_startup, delay_startup," - " interval_hours, max_retries, interval_hours," + " max_retries, retry_seconds, interval_hours," " last_run, last_success, data" " FROM task" " WHERE name = ?1;"; const char *const sqlInsertTask = "INSERT INTO task(task_id, name, enabled," " run_on_startup, delay_startup," - " max_retries, retry_minutes, interval_hours," + " max_retries, retry_seconds, interval_hours," " last_run, last_success, data)" " VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11);"; const char *const sqlUpdateTask = "UPDATE task" " SET name = ?2, enabled = ?3," " run_on_startup = ?4, delay_startup = ?5," - " max_retries = ?6, retry_minutes = ?7, interval_hours = ?8," + " max_retries = ?6, retry_seconds = ?7, interval_hours = ?8," " last_run = ?9, last_success = ?10," " data = ?11" " WHERE task_id = ?1;"; diff --git a/src/ui/form/opt/pages/schedulepage.cpp b/src/ui/form/opt/pages/schedulepage.cpp index 814ef3bd..5f7b6d79 100644 --- a/src/ui/form/opt/pages/schedulepage.cpp +++ b/src/ui/form/opt/pages/schedulepage.cpp @@ -185,6 +185,8 @@ void SchedulePage::setupTaskInterval() connect(m_cscTaskInterval->checkBox(), &QCheckBox::toggled, this, [&](bool checked) { auto &task = currentTaskRow(); + if (task.enabled() == checked) + return; task.setEnabled(checked); setCurrentTaskRowEdited(Qt::CheckStateRole); @@ -193,6 +195,8 @@ void SchedulePage::setupTaskInterval() connect(m_cscTaskInterval->spinBox(), QOverload::of(&QSpinBox::valueChanged), this, [&](int value) { auto &task = currentTaskRow(); + if (task.intervalHours() == value) + return; task.setIntervalHours(value); setCurrentTaskRowEdited(); @@ -219,6 +223,8 @@ void SchedulePage::setupTaskStartup() { m_cbTaskRunOnStartup = ControlUtil::createCheckBox(false, [&](bool checked) { auto &task = currentTaskRow(); + if (task.runOnStartup() == checked) + return; task.setRunOnStartup(checked); setCurrentTaskRowEdited(); @@ -226,6 +232,8 @@ void SchedulePage::setupTaskStartup() m_cbTaskDelayStartup = ControlUtil::createCheckBox(false, [&](bool checked) { auto &task = currentTaskRow(); + if (task.delayStartup() == checked) + return; task.setDelayStartup(checked); setCurrentTaskRowEdited(); @@ -240,6 +248,8 @@ void SchedulePage::setupTaskMaxRetries() connect(m_lsTaskMaxRetries->spinBox(), QOverload::of(&QSpinBox::valueChanged), this, [&](int value) { auto &task = currentTaskRow(); + if (task.maxRetries() == value) + return; task.setMaxRetries(value); setCurrentTaskRowEdited(); @@ -255,6 +265,8 @@ void SchedulePage::setupTaskRetrySeconds() connect(m_lscTaskRetrySeconds->spinBox(), QOverload::of(&QSpinBox::valueChanged), this, [&](int value) { auto &task = currentTaskRow(); + if (task.retrySeconds() == value) + return; task.setRetrySeconds(value); setCurrentTaskRowEdited(); @@ -282,6 +294,9 @@ void SchedulePage::setupTableTasksChanged() m_cbTaskRunOnStartup->setChecked(task.runOnStartup()); m_cbTaskDelayStartup->setChecked(task.delayStartup()); + m_lsTaskMaxRetries->spinBox()->setValue(task.maxRetries()); + m_lscTaskRetrySeconds->spinBox()->setValue(task.retrySeconds()); + const bool running = taskInfo->running(); m_btTaskRun->setEnabled(!running); m_btTaskAbort->setEnabled(running); diff --git a/src/ui/task/taskeditinfo.cpp b/src/ui/task/taskeditinfo.cpp index 1bcc9eec..5a953d26 100644 --- a/src/ui/task/taskeditinfo.cpp +++ b/src/ui/task/taskeditinfo.cpp @@ -2,12 +2,9 @@ #include "taskinfo.h" -TaskEditInfo::TaskEditInfo(bool enabled, bool runOnStartup, quint16 intervalHours) : - m_enabled(enabled), m_runOnStartup(runOnStartup), m_intervalHours(intervalHours) -{ -} +static_assert(sizeof(TaskEditInfo) == sizeof(quint64), "TaskEditInfo size mismatch"); -TaskEditInfo::TaskEditInfo(quint32 v) : m_value(v) { } +TaskEditInfo::TaskEditInfo(quint64 v) : m_value(v) { } void TaskEditInfo::resetToDefault() { diff --git a/src/ui/task/taskeditinfo.h b/src/ui/task/taskeditinfo.h index d43085ca..ccaf9db1 100644 --- a/src/ui/task/taskeditinfo.h +++ b/src/ui/task/taskeditinfo.h @@ -6,9 +6,7 @@ class TaskEditInfo { public: - explicit TaskEditInfo( - bool enabled = false, bool runOnStartup = false, quint16 intervalHours = 0); - explicit TaskEditInfo(quint32 v); + explicit TaskEditInfo(quint64 v = 0); bool enabled() const { return m_enabled; } void setEnabled(bool v) { m_enabled = v; } @@ -28,7 +26,7 @@ public: int intervalHours() const { return m_intervalHours; } void setIntervalHours(int v) { m_intervalHours = quint16(v); } - quint32 value() const { return m_value; } + quint64 value() const { return m_value; } void resetToDefault(); @@ -42,9 +40,10 @@ private: quint8 m_maxRetries; quint16 m_retrySeconds; quint16 m_intervalHours; + quint16 m_reserved; // not used }; - quint32 m_value = 0; + quint64 m_value = 0; }; }; diff --git a/src/ui/task/taskinfo.cpp b/src/ui/task/taskinfo.cpp index ec2dd985..a249ec6b 100644 --- a/src/ui/task/taskinfo.cpp +++ b/src/ui/task/taskinfo.cpp @@ -49,14 +49,14 @@ QDateTime TaskInfo::plannedRun() const void TaskInfo::editFromVariant(const QVariant &v) { - const TaskEditInfo info(v.toUInt()); + const TaskEditInfo task(v.toULongLong()); - setEnabled(info.enabled()); - setRunOnStartup(info.runOnStartup()); - setDelayStartup(info.delayStartup()); - setMaxRetries(info.maxRetries()); - setRetrySeconds(info.retrySeconds()); - setIntervalHours(info.intervalHours()); + setEnabled(task.enabled()); + setRunOnStartup(task.runOnStartup()); + setDelayStartup(task.delayStartup()); + setMaxRetries(task.maxRetries()); + setRetrySeconds(task.retrySeconds()); + setIntervalHours(task.intervalHours()); } QString TaskInfo::typeToString(TaskInfo::TaskType type) diff --git a/src/ui/task/tasklistmodel.cpp b/src/ui/task/tasklistmodel.cpp index e56e89c0..7860e2a7 100644 --- a/src/ui/task/tasklistmodel.cpp +++ b/src/ui/task/tasklistmodel.cpp @@ -158,8 +158,8 @@ void TaskListModel::setupTaskRows() QVariant TaskListModel::toVariant() const { QVariantList list; - for (const TaskEditInfo &info : std::as_const(m_taskRows)) { - list.append(info.value()); + for (const TaskEditInfo &task : std::as_const(m_taskRows)) { + list.append(task.value()); } return list; }