UI: SchedulePage: Open ZonesWindow on TaskZoneDownloader double click.

This commit is contained in:
Nodir Temirkhodjaev 2020-02-07 13:19:14 +05:00
parent a261ade018
commit cda9c34bb9
3 changed files with 18 additions and 10 deletions

View File

@ -9,6 +9,7 @@
#include <QTableView>
#include <QVBoxLayout>
#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()

View File

@ -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)

View File

@ -32,7 +32,7 @@ public:
TaskManager *taskManager() const { return m_taskManager; }
const QList<TaskInfo *> &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);