00001 #include "taskdetailsshower.h" 00002 00003 #include <domain/taskmanagerdata.h> 00004 #include <tools/functions.h> 00005 #include <models/taskmodel.h> 00006 #include <models/userrequirementsmodel.h> 00007 #include <models/resourcerequirementsmodel.h> 00008 00009 using namespace control; 00010 00011 ControllerInterface::ActionType TaskDetailsShower::actionType() const 00012 { 00013 return ViewAction; 00014 } 00015 00016 ControllerInterface::DataType TaskDetailsShower::dataType() const 00017 { 00018 return TaskData; 00019 } 00020 00021 QString TaskDetailsShower::description() const 00022 { 00023 return "Show task details"; 00024 } 00025 00026 void TaskDetailsShower::execute() 00027 { 00028 QList<domain::Task*> allTasks = data->tasks(); 00029 00030 TaskModel tasks(data, tools::makeConstList(allTasks)); 00031 data::SelectionData selectedTasks = ui->getSelection("Select a task", &tasks); 00032 00033 if (!selectedTasks.processData) 00034 return; 00035 00036 if (selectedTasks.selection.isEmpty()) 00037 { 00038 ui->showWarning("No task selected."); 00039 return; 00040 } 00041 00042 Q_ASSERT(selectedTasks.selection.count() == 1); 00043 00044 const domain::Task* task = 00045 tasks.taskForIndex(selectedTasks.selection.first()); 00046 allTasks.removeAll(this->data->task(task)); 00047 TaskModel tasksWithoutThis(data, tools::makeConstList(allTasks)); 00048 data::TaskDetails currentDetails(task); 00049 00050 Q_FOREACH (const domain::Task* subTask, task->subTasks()) 00051 { 00052 currentDetails.selectedTasks.selection 00053 << tasksWithoutThis.indexForTask(this->data->task(subTask)); 00054 } 00055 00056 data::TaskRepresentation rep; 00057 rep.subTasks = &tasksWithoutThis; 00058 rep.type = data::TaskTypeDetails(task->taskType()); 00059 rep.details = currentDetails; 00060 UserRequirementsModel userReqs(this->data->task(task)); 00061 rep.userReqs = &userReqs; 00062 ResourceRequirementsModel resourceReqs(this->data->task(task)); 00063 rep.resourceReqs = &resourceReqs; 00064 ui->showTaskDetails(rep, QStringList() << "Ok"); 00065 } 00066 00067 QString TaskDetailsShower::name() const 00068 { 00069 return "TaskDetailsShower"; 00070 } 00071 00072 bool TaskDetailsShower::userIsValid() const 00073 { 00074 return true; 00075 } 00076 00077 Q_EXPORT_PLUGIN2(controller_taskdetailsshower, TaskDetailsShower) 00078