00001 #include "clockadjuster.h"
00002
00003 #include <controldata.h>
00004
00005 #include <domain/clock.h>
00006 #include <domain/taskmanagerdata.h>
00007
00008 using namespace control;
00009
00010 ControllerInterface::ActionType ClockAdjuster::actionType() const
00011 {
00012 return ModifyAction;
00013 }
00014
00015 ControllerInterface::DataType ClockAdjuster::dataType() const
00016 {
00017 return NoData;
00018 }
00019
00020 QString ClockAdjuster::description() const
00021 {
00022 return "Adjust clock";
00023 }
00024
00025 QString ClockAdjuster::name() const
00026 {
00027 return "ClockAdjuster";
00028 }
00029
00030 bool ClockAdjuster::userIsValid() const
00031 {
00032 return userIsAdmin();
00033 }
00034
00035 void ClockAdjuster::execute()
00036 {
00037 domain::Clock* clock = data->clock();
00038 QDateTime oldTime = clock->time();
00039 data::DateTimeInputData input = ui->getDateTime("Enter new clock time");
00040
00041 if (!input.processData)
00042 return;
00043
00044 if (oldTime > input)
00045 {
00046 ui->showError("You cannot go back in time :-)");
00047 return;
00048 }
00049
00050 clock->setTime(input);
00051 clock->setTicking(true);
00052 }
00053
00054 Q_EXPORT_PLUGIN2(controller_clockadjuster, ClockAdjuster)