00001 #include "tasktypefocus.h" 00002 #include <domain/taskmanagerdata.h> 00003 00004 using namespace control; 00005 00006 QString TaskTypeFocus::description() const 00007 { 00008 return "Task-type focus"; 00009 } 00010 00011 bool TaskTypeFocus::applyFocus(QList<domain::Task*>* tasks) 00012 { 00013 QList<domain::TaskType*> types = data->taskTypes(); 00014 QMap<QString, domain::TaskType*> typeMap; 00015 00016 Q_FOREACH (domain::TaskType* type, types) 00017 typeMap[type->name()] = type; 00018 00019 data::StringInputData choice = ui->getChoice(typeMap.keys(), 00020 "Choose a task type"); 00021 00022 if (!choice.processData) 00023 return false; 00024 00025 domain::TaskType* type = typeMap[choice]; 00026 00027 Q_FOREACH (domain::Task* task, *tasks) 00028 { 00029 if (task->taskType() != type) 00030 tasks->removeAll(task); 00031 } 00032 00033 return true; 00034 } 00035 00036 Q_EXPORT_PLUGIN2(focus_tasktype, TaskTypeFocus)