From cda9c34bb9dae1d8444f96c875d7a61daef46da2 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Fri, 7 Feb 2020 13:19:14 +0500 Subject: [PATCH] UI: SchedulePage: Open ZonesWindow on TaskZoneDownloader double click. --- src/ui/form/opt/pages/schedulepage.cpp | 8 ++++++++ src/ui/task/tasklistmodel.cpp | 14 +++++++------- src/ui/task/tasklistmodel.h | 6 +++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/ui/form/opt/pages/schedulepage.cpp b/src/ui/form/opt/pages/schedulepage.cpp index 15b9143e..973d421a 100644 --- a/src/ui/form/opt/pages/schedulepage.cpp +++ b/src/ui/form/opt/pages/schedulepage.cpp @@ -9,6 +9,7 @@ #include #include +#include "../../../fortmanager.h" #include "../../../task/taskinfo.h" #include "../../../task/tasklistmodel.h" #include "../../../task/taskmanager.h" @@ -115,6 +116,13 @@ void SchedulePage::setupTableTasks() m_tableTasks->setSelectionBehavior(QAbstractItemView::SelectItems); m_tableTasks->setModel(taskListModel()); + + connect(m_tableTasks, &TableView::doubleClicked, [&](const QModelIndex &index) { + const auto taskInfo = taskListModel()->taskInfoAt(index.row()); + if (taskInfo->type() == TaskInfo::ZoneDownloader) { + fortManager()->showZonesWindow(); + } + }); } void SchedulePage::setupTableTasksHeader() diff --git a/src/ui/task/tasklistmodel.cpp b/src/ui/task/tasklistmodel.cpp index af403888..aefe04d7 100644 --- a/src/ui/task/tasklistmodel.cpp +++ b/src/ui/task/tasklistmodel.cpp @@ -221,26 +221,26 @@ void TaskListModel::setTaskIntervalHours(const QModelIndex &index, int v) emit dataEdited(); } -TaskRow *TaskListModel::addTaskRow(int index) +TaskRow *TaskListModel::addTaskRow(int row) { auto taskRow = new TaskRow(); - m_taskRows.replace(index, taskRow); + m_taskRows.replace(row, taskRow); - auto taskInfo = taskInfoAt(index); + auto taskInfo = taskInfoAt(row); taskRow->enabled = taskInfo->enabled(); taskRow->intervalHours = taskInfo->intervalHours(); return taskRow; } -TaskInfo *TaskListModel::taskInfoAt(int index) const +TaskInfo *TaskListModel::taskInfoAt(int row) const { - return taskInfosList().at(index); + return taskInfosList().at(row); } -TaskRow *TaskListModel::taskRowAt(int index) const +TaskRow *TaskListModel::taskRowAt(int row) const { - return m_taskRows.at(index); + return m_taskRows.at(row); } QString TaskListModel::formatDateTime(const QDateTime &dateTime) diff --git a/src/ui/task/tasklistmodel.h b/src/ui/task/tasklistmodel.h index 90d3f062..6f9bfa2f 100644 --- a/src/ui/task/tasklistmodel.h +++ b/src/ui/task/tasklistmodel.h @@ -32,7 +32,7 @@ public: TaskManager *taskManager() const { return m_taskManager; } const QList &taskInfosList() const; - TaskInfo *taskInfoAt(int index) const; + TaskInfo *taskInfoAt(int row) const; int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; @@ -62,9 +62,9 @@ private: int taskIntervalHours(int index) const; void setTaskIntervalHours(const QModelIndex &index, int v); - TaskRow *addTaskRow(int index); + TaskRow *addTaskRow(int row); - TaskRow *taskRowAt(int index) const; + TaskRow *taskRowAt(int row) const; static QString formatDateTime(const QDateTime &dateTime);