00001 #include "statechangedata.h" 00002 #include <tools/invaliddataexception.h> 00003 00004 using namespace domain; 00005 00006 StateChangeData::StateChangeData(bool possible) : changePossible(possible) 00007 { 00008 } 00009 00010 bool StateChangeData::isChangePossible() const 00011 { 00012 return changePossible; 00013 } 00014 00015 bool domain::StateChangeData::areMoreChangesNeeded() const 00016 { 00017 return isChangePossible() && !badTasks.isEmpty(); 00018 } 00019 00020 const QString& domain::StateChangeData::message() const 00021 { 00022 return msg; 00023 } 00024 00025 QList<const domain::Task*> domain::StateChangeData::violatingTasks() const 00026 { 00027 return badTasks.keys(); 00028 } 00029 00030 TaskState::SettableState StateChangeData::suggestedState(const domain::Task* task) const 00031 { 00032 if (task == 0 || !isChangePossible() || !badTasks.contains(task)) 00033 throw tools::InvalidDataException("No suggested new state for the given task."); 00034 00035 return badTasks[task]; 00036 } 00037 00038 StateChangeData::operator bool() const 00039 { 00040 return isChangePossible(); 00041 } 00042 00043 void domain::StateChangeData::addViolatingTask(const domain::Task* task, 00044 TaskState::SettableState newState) 00045 { 00046 badTasks[task] = newState; 00047 } 00048 00049 void domain::StateChangeData::setMessage(const QString& message) 00050 { 00051 this->msg = message; 00052 }