mirror of
https://github.com/tnodir/fort
synced 2024-11-15 03:15:46 +00:00
UI: Options: Schedule: Fix tasks saving
This commit is contained in:
parent
fa2240b387
commit
0121104977
@ -96,21 +96,21 @@ const char *const sqlUpdateAppResetGroup = "UPDATE app"
|
|||||||
|
|
||||||
const char *const sqlSelectTaskByName = "SELECT task_id, enabled,"
|
const char *const sqlSelectTaskByName = "SELECT task_id, enabled,"
|
||||||
" run_on_startup, delay_startup,"
|
" run_on_startup, delay_startup,"
|
||||||
" interval_hours, max_retries, interval_hours,"
|
" max_retries, retry_seconds, interval_hours,"
|
||||||
" last_run, last_success, data"
|
" last_run, last_success, data"
|
||||||
" FROM task"
|
" FROM task"
|
||||||
" WHERE name = ?1;";
|
" WHERE name = ?1;";
|
||||||
|
|
||||||
const char *const sqlInsertTask = "INSERT INTO task(task_id, name, enabled,"
|
const char *const sqlInsertTask = "INSERT INTO task(task_id, name, enabled,"
|
||||||
" run_on_startup, delay_startup,"
|
" run_on_startup, delay_startup,"
|
||||||
" max_retries, retry_minutes, interval_hours,"
|
" max_retries, retry_seconds, interval_hours,"
|
||||||
" last_run, last_success, data)"
|
" last_run, last_success, data)"
|
||||||
" VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11);";
|
" VALUES(?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11);";
|
||||||
|
|
||||||
const char *const sqlUpdateTask = "UPDATE task"
|
const char *const sqlUpdateTask = "UPDATE task"
|
||||||
" SET name = ?2, enabled = ?3,"
|
" SET name = ?2, enabled = ?3,"
|
||||||
" run_on_startup = ?4, delay_startup = ?5,"
|
" 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,"
|
" last_run = ?9, last_success = ?10,"
|
||||||
" data = ?11"
|
" data = ?11"
|
||||||
" WHERE task_id = ?1;";
|
" WHERE task_id = ?1;";
|
||||||
|
@ -185,6 +185,8 @@ void SchedulePage::setupTaskInterval()
|
|||||||
|
|
||||||
connect(m_cscTaskInterval->checkBox(), &QCheckBox::toggled, this, [&](bool checked) {
|
connect(m_cscTaskInterval->checkBox(), &QCheckBox::toggled, this, [&](bool checked) {
|
||||||
auto &task = currentTaskRow();
|
auto &task = currentTaskRow();
|
||||||
|
if (task.enabled() == checked)
|
||||||
|
return;
|
||||||
|
|
||||||
task.setEnabled(checked);
|
task.setEnabled(checked);
|
||||||
setCurrentTaskRowEdited(Qt::CheckStateRole);
|
setCurrentTaskRowEdited(Qt::CheckStateRole);
|
||||||
@ -193,6 +195,8 @@ void SchedulePage::setupTaskInterval()
|
|||||||
connect(m_cscTaskInterval->spinBox(), QOverload<int>::of(&QSpinBox::valueChanged), this,
|
connect(m_cscTaskInterval->spinBox(), QOverload<int>::of(&QSpinBox::valueChanged), this,
|
||||||
[&](int value) {
|
[&](int value) {
|
||||||
auto &task = currentTaskRow();
|
auto &task = currentTaskRow();
|
||||||
|
if (task.intervalHours() == value)
|
||||||
|
return;
|
||||||
|
|
||||||
task.setIntervalHours(value);
|
task.setIntervalHours(value);
|
||||||
setCurrentTaskRowEdited();
|
setCurrentTaskRowEdited();
|
||||||
@ -219,6 +223,8 @@ void SchedulePage::setupTaskStartup()
|
|||||||
{
|
{
|
||||||
m_cbTaskRunOnStartup = ControlUtil::createCheckBox(false, [&](bool checked) {
|
m_cbTaskRunOnStartup = ControlUtil::createCheckBox(false, [&](bool checked) {
|
||||||
auto &task = currentTaskRow();
|
auto &task = currentTaskRow();
|
||||||
|
if (task.runOnStartup() == checked)
|
||||||
|
return;
|
||||||
|
|
||||||
task.setRunOnStartup(checked);
|
task.setRunOnStartup(checked);
|
||||||
setCurrentTaskRowEdited();
|
setCurrentTaskRowEdited();
|
||||||
@ -226,6 +232,8 @@ void SchedulePage::setupTaskStartup()
|
|||||||
|
|
||||||
m_cbTaskDelayStartup = ControlUtil::createCheckBox(false, [&](bool checked) {
|
m_cbTaskDelayStartup = ControlUtil::createCheckBox(false, [&](bool checked) {
|
||||||
auto &task = currentTaskRow();
|
auto &task = currentTaskRow();
|
||||||
|
if (task.delayStartup() == checked)
|
||||||
|
return;
|
||||||
|
|
||||||
task.setDelayStartup(checked);
|
task.setDelayStartup(checked);
|
||||||
setCurrentTaskRowEdited();
|
setCurrentTaskRowEdited();
|
||||||
@ -240,6 +248,8 @@ void SchedulePage::setupTaskMaxRetries()
|
|||||||
connect(m_lsTaskMaxRetries->spinBox(), QOverload<int>::of(&QSpinBox::valueChanged), this,
|
connect(m_lsTaskMaxRetries->spinBox(), QOverload<int>::of(&QSpinBox::valueChanged), this,
|
||||||
[&](int value) {
|
[&](int value) {
|
||||||
auto &task = currentTaskRow();
|
auto &task = currentTaskRow();
|
||||||
|
if (task.maxRetries() == value)
|
||||||
|
return;
|
||||||
|
|
||||||
task.setMaxRetries(value);
|
task.setMaxRetries(value);
|
||||||
setCurrentTaskRowEdited();
|
setCurrentTaskRowEdited();
|
||||||
@ -255,6 +265,8 @@ void SchedulePage::setupTaskRetrySeconds()
|
|||||||
connect(m_lscTaskRetrySeconds->spinBox(), QOverload<int>::of(&QSpinBox::valueChanged), this,
|
connect(m_lscTaskRetrySeconds->spinBox(), QOverload<int>::of(&QSpinBox::valueChanged), this,
|
||||||
[&](int value) {
|
[&](int value) {
|
||||||
auto &task = currentTaskRow();
|
auto &task = currentTaskRow();
|
||||||
|
if (task.retrySeconds() == value)
|
||||||
|
return;
|
||||||
|
|
||||||
task.setRetrySeconds(value);
|
task.setRetrySeconds(value);
|
||||||
setCurrentTaskRowEdited();
|
setCurrentTaskRowEdited();
|
||||||
@ -282,6 +294,9 @@ void SchedulePage::setupTableTasksChanged()
|
|||||||
m_cbTaskRunOnStartup->setChecked(task.runOnStartup());
|
m_cbTaskRunOnStartup->setChecked(task.runOnStartup());
|
||||||
m_cbTaskDelayStartup->setChecked(task.delayStartup());
|
m_cbTaskDelayStartup->setChecked(task.delayStartup());
|
||||||
|
|
||||||
|
m_lsTaskMaxRetries->spinBox()->setValue(task.maxRetries());
|
||||||
|
m_lscTaskRetrySeconds->spinBox()->setValue(task.retrySeconds());
|
||||||
|
|
||||||
const bool running = taskInfo->running();
|
const bool running = taskInfo->running();
|
||||||
m_btTaskRun->setEnabled(!running);
|
m_btTaskRun->setEnabled(!running);
|
||||||
m_btTaskAbort->setEnabled(running);
|
m_btTaskAbort->setEnabled(running);
|
||||||
|
@ -2,12 +2,9 @@
|
|||||||
|
|
||||||
#include "taskinfo.h"
|
#include "taskinfo.h"
|
||||||
|
|
||||||
TaskEditInfo::TaskEditInfo(bool enabled, bool runOnStartup, quint16 intervalHours) :
|
static_assert(sizeof(TaskEditInfo) == sizeof(quint64), "TaskEditInfo size mismatch");
|
||||||
m_enabled(enabled), m_runOnStartup(runOnStartup), m_intervalHours(intervalHours)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
TaskEditInfo::TaskEditInfo(quint32 v) : m_value(v) { }
|
TaskEditInfo::TaskEditInfo(quint64 v) : m_value(v) { }
|
||||||
|
|
||||||
void TaskEditInfo::resetToDefault()
|
void TaskEditInfo::resetToDefault()
|
||||||
{
|
{
|
||||||
|
@ -6,9 +6,7 @@
|
|||||||
class TaskEditInfo
|
class TaskEditInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit TaskEditInfo(
|
explicit TaskEditInfo(quint64 v = 0);
|
||||||
bool enabled = false, bool runOnStartup = false, quint16 intervalHours = 0);
|
|
||||||
explicit TaskEditInfo(quint32 v);
|
|
||||||
|
|
||||||
bool enabled() const { return m_enabled; }
|
bool enabled() const { return m_enabled; }
|
||||||
void setEnabled(bool v) { m_enabled = v; }
|
void setEnabled(bool v) { m_enabled = v; }
|
||||||
@ -28,7 +26,7 @@ public:
|
|||||||
int intervalHours() const { return m_intervalHours; }
|
int intervalHours() const { return m_intervalHours; }
|
||||||
void setIntervalHours(int v) { m_intervalHours = quint16(v); }
|
void setIntervalHours(int v) { m_intervalHours = quint16(v); }
|
||||||
|
|
||||||
quint32 value() const { return m_value; }
|
quint64 value() const { return m_value; }
|
||||||
|
|
||||||
void resetToDefault();
|
void resetToDefault();
|
||||||
|
|
||||||
@ -42,9 +40,10 @@ private:
|
|||||||
quint8 m_maxRetries;
|
quint8 m_maxRetries;
|
||||||
quint16 m_retrySeconds;
|
quint16 m_retrySeconds;
|
||||||
quint16 m_intervalHours;
|
quint16 m_intervalHours;
|
||||||
|
quint16 m_reserved; // not used
|
||||||
};
|
};
|
||||||
|
|
||||||
quint32 m_value = 0;
|
quint64 m_value = 0;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,14 +49,14 @@ QDateTime TaskInfo::plannedRun() const
|
|||||||
|
|
||||||
void TaskInfo::editFromVariant(const QVariant &v)
|
void TaskInfo::editFromVariant(const QVariant &v)
|
||||||
{
|
{
|
||||||
const TaskEditInfo info(v.toUInt());
|
const TaskEditInfo task(v.toULongLong());
|
||||||
|
|
||||||
setEnabled(info.enabled());
|
setEnabled(task.enabled());
|
||||||
setRunOnStartup(info.runOnStartup());
|
setRunOnStartup(task.runOnStartup());
|
||||||
setDelayStartup(info.delayStartup());
|
setDelayStartup(task.delayStartup());
|
||||||
setMaxRetries(info.maxRetries());
|
setMaxRetries(task.maxRetries());
|
||||||
setRetrySeconds(info.retrySeconds());
|
setRetrySeconds(task.retrySeconds());
|
||||||
setIntervalHours(info.intervalHours());
|
setIntervalHours(task.intervalHours());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TaskInfo::typeToString(TaskInfo::TaskType type)
|
QString TaskInfo::typeToString(TaskInfo::TaskType type)
|
||||||
|
@ -158,8 +158,8 @@ void TaskListModel::setupTaskRows()
|
|||||||
QVariant TaskListModel::toVariant() const
|
QVariant TaskListModel::toVariant() const
|
||||||
{
|
{
|
||||||
QVariantList list;
|
QVariantList list;
|
||||||
for (const TaskEditInfo &info : std::as_const(m_taskRows)) {
|
for (const TaskEditInfo &task : std::as_const(m_taskRows)) {
|
||||||
list.append(info.value());
|
list.append(task.value());
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user