00001 #include "projectcreator.h" 00002 00003 #include <controldata.h> 00004 00005 #include <domain/taskmanagerdata.h> 00006 00007 #include <tools/functions.h> 00008 #include <tools/stringexception.h> 00009 00010 using namespace control; 00011 00012 ControllerInterface::ActionType ProjectCreator::actionType() const 00013 { 00014 return CreateAction; 00015 } 00016 00017 ControllerInterface::DataType ProjectCreator::dataType() const 00018 { 00019 return ProjectData; 00020 } 00021 00022 QString ProjectCreator::description() const 00023 { 00024 return "Create project"; 00025 } 00026 00027 bool ProjectCreator::userIsValid() const 00028 { 00029 return userHasLoggedIn() && !userIsAdmin(); 00030 } 00031 00032 void ProjectCreator::execute() 00033 { 00034 data::ProjectDetails details = ui->getProjectDetails(); 00035 00036 if (!details.processData) 00037 return; 00038 00039 try 00040 { 00041 data->createProject(details.description); 00042 } 00043 catch (tools::StringException e) 00044 { 00045 ui->showError(e.message()); 00046 } 00047 } 00048 00049 QString ProjectCreator::name() const 00050 { 00051 return "ProjectCreator"; 00052 } 00053 00054 Q_EXPORT_PLUGIN2(controller_projectcreator, ProjectCreator)