/* This file is part of the KDE project Copyright (C) 2004, 2005 Dag Andersen This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; version 2 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kptcommand.h" #include "kptaccount.h" #include "kptappointment.h" #include "kptpart.h" #include "kptproject.h" #include "kpttask.h" #include "kptcalendar.h" #include "kptrelation.h" #include "kptresource.h" #include #include #include #include namespace KPlato { void NamedCommand::setCommandType(int type) { if (m_part) m_part->setCommandType(type); } void NamedCommand::setSchDeleted() { TQMap::Iterator it; for (it = m_schedules.begin(); it != m_schedules.end(); ++it) { kdDebug()<id()<<": "<setDeleted(it.data()); } } void NamedCommand::setSchDeleted(bool state) { TQMap::Iterator it; for (it = m_schedules.begin(); it != m_schedules.end(); ++it) { kdDebug()<id()<<": "<setDeleted(state); } } void NamedCommand::setSchScheduled() { TQMap::Iterator it; for (it = m_schedules.begin(); it != m_schedules.end(); ++it) { kdDebug()<id()<<": "<setScheduled(it.data()); } } void NamedCommand::setSchScheduled(bool state) { TQMap::Iterator it; for (it = m_schedules.begin(); it != m_schedules.end(); ++it) { kdDebug()<id()<<": "<setScheduled(state); } } void NamedCommand::addSchScheduled(Schedule *sch) { kdDebug()<id()<<": "<isScheduled()<isScheduled()); TQPtrListIterator it = sch->appointments(); for (; it.current(); ++it) { if (it.current()->node() == sch) { m_schedules.insert(it.current()->resource(), it.current()->resource()->isScheduled()); } else if (it.current()->resource() == sch) { m_schedules.insert(it.current()->node(), it.current()->node()->isScheduled()); } } } void NamedCommand::addSchDeleted(Schedule *sch) { kdDebug()<id()<<": "<isDeleted()<isDeleted()); TQPtrListIterator it = sch->appointments(); for (; it.current(); ++it) { if (it.current()->node() == sch) { m_schedules.insert(it.current()->resource(), it.current()->resource()->isDeleted()); } else if (it.current()->resource() == sch) { m_schedules.insert(it.current()->node(), it.current()->node()->isDeleted()); } } } //------------------------------------------------- CalendarAddCmd::CalendarAddCmd(Part *part, Project *project,Calendar *cal, TQString name) : NamedCommand(part, name), m_project(project), m_cal(cal), m_added(false) { cal->setDeleted(true); //kdDebug()<name()<addCalendar(m_cal); m_added = true; } m_cal->setDeleted(false); setCommandType(0); //kdDebug()<name()<<" added to: "<name()<setDeleted(true); setCommandType(0); //kdDebug()<name()< it = part->getProject().schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } } void CalendarDeleteCmd::execute() { m_cal->setDeleted(true); setSchScheduled(false); setCommandType(1); } void CalendarDeleteCmd::unexecute() { m_cal->setDeleted(false); setSchScheduled(); setCommandType(0); } CalendarModifyNameCmd::CalendarModifyNameCmd(Part *part, Calendar *cal, TQString newvalue, TQString name) : NamedCommand(part, name), m_cal(cal) { m_oldvalue = cal->name(); m_newvalue = newvalue; //kdDebug()<name()<setName(m_newvalue); setCommandType(0); //kdDebug()<name()<setName(m_oldvalue); setCommandType(0); //kdDebug()<name()<tqparent(); m_newvalue = newvalue; //kdDebug()<name()< it = part->getProject().schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } } void CalendarModifyParentCmd::execute() { m_cal->setParent(m_newvalue); setSchScheduled(false); setCommandType(1); } void CalendarModifyParentCmd::unexecute() { m_cal->setParent(m_oldvalue); setSchScheduled(); setCommandType(1); } CalendarAddDayCmd::CalendarAddDayCmd(Part *part, Calendar *cal, CalendarDay *newvalue, TQString name) : NamedCommand(part, name), m_cal(cal), m_mine(true) { m_newvalue = newvalue; //kdDebug()<name()< it = part->getProject().schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } } CalendarAddDayCmd::~CalendarAddDayCmd() { //kdDebug()<name()<addDay(m_newvalue); m_mine = false; setSchScheduled(false); setCommandType(1); } void CalendarAddDayCmd::unexecute() { //kdDebug()<name()<takeDay(m_newvalue); m_mine = true; setSchScheduled(); setCommandType(1); } CalendarRemoveDayCmd::CalendarRemoveDayCmd(Part *part, Calendar *cal, const TQDate &day, TQString name) : NamedCommand(part, name), m_cal(cal), m_mine(false) { m_value = cal->findDay(day); //kdDebug()<name()< it = part->getProject().schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } } void CalendarRemoveDayCmd::execute() { //kdDebug()<name()<takeDay(m_value); m_mine = true; setSchScheduled(false); setCommandType(1); } void CalendarRemoveDayCmd::unexecute() { //kdDebug()<name()<addDay(m_value); m_mine = false; setSchScheduled(); setCommandType(1); } CalendarModifyDayCmd::CalendarModifyDayCmd(Part *part, Calendar *cal, CalendarDay *value, TQString name) : NamedCommand(part, name), m_cal(cal), m_mine(true) { m_newvalue = value; m_oldvalue = cal->findDay(value->date()); //kdDebug()<name()<<" old:("< it = part->getProject().schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } } CalendarModifyDayCmd::~CalendarModifyDayCmd() { //kdDebug()<takeDay(m_oldvalue); m_cal->addDay(m_newvalue); m_mine = false; setSchScheduled(false); setCommandType(1); } void CalendarModifyDayCmd::unexecute() { //kdDebug()<takeDay(m_newvalue); m_cal->addDay(m_oldvalue); m_mine = true; setSchScheduled(); setCommandType(1); } CalendarModifyWeekdayCmd::CalendarModifyWeekdayCmd(Part *part, Calendar *cal, int weekday, CalendarDay *value, TQString name) : NamedCommand(part, name), m_weekday(weekday), m_cal(cal), m_mine(true) { m_value = value; kdDebug()<name()<<" ("< it = part->getProject().schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } } CalendarModifyWeekdayCmd::~CalendarModifyWeekdayCmd() { kdDebug()<weekdays()->replace(m_weekday, m_value); setSchScheduled(false); setCommandType(1); } void CalendarModifyWeekdayCmd::unexecute() { m_value = m_cal->weekdays()->replace(m_weekday, m_value); setSchScheduled(); setCommandType(1); } NodeDeleteCmd::NodeDeleteCmd(Part *part, Node *node, TQString name) : NamedCommand(part, name), m_node(node), m_index(-1) { m_parent = node->getParent(); if (m_parent) m_index = m_parent->findChildNode(node); m_mine = false; m_appointments.setAutoDelete(true); m_project = static_cast(node->projectNode()); if (m_project) { TQIntDictIterator it = m_project->schedules(); for (; it.current(); ++it) { Schedule *s = node->findSchedule(it.current()->id()); if (s && s->isScheduled()) { // Only tqinvalidate schedules this node is part of addSchScheduled(it.current()); } } } } NodeDeleteCmd::~NodeDeleteCmd() { if (m_mine) delete m_node; } void NodeDeleteCmd::execute() { if (m_parent && m_project) { //kdDebug()<name()<<" "< it = m_node->appointments(); for (; it.current(); ++it) { it.current()->detach(); m_appointments.append(it.current()); } m_project->delTask(m_node); m_mine = true; setSchScheduled(false); setCommandType(1); } } void NodeDeleteCmd::unexecute() { if (m_parent && m_project) { //kdDebug()<name()<<" "<addSubTask(m_node, m_index, m_parent); Appointment *a; for (a = m_appointments.first(); a != 0; m_appointments.take()) { a->attach(); } m_mine = false; setSchScheduled(); setCommandType(1); } } TaskAddCmd::TaskAddCmd(Part *part, Project *project, Node *node, Node *after, TQString name) : NamedCommand(part, name), m_project(project), m_node(node), m_after(after), m_added(false) { // set some reasonable defaults for normally calculated values if (after && after->getParent() && after->getParent() != project) { node->setStartTime(after->getParent()->startTime()); node->setEndTime(node->startTime() + node->duration()); } else { if (project->constraint() == Node::MustFinishOn) { node->setEndTime(project->endTime()); node->setStartTime(node->endTime() - node->duration()); } else { node->setStartTime(project->startTime()); node->setEndTime(node->startTime() + node->duration()); } } node->setEarliestStart(node->startTime()); node->setLatestFinish(node->endTime()); node->setWorkStartTime(node->startTime()); node->setWorkEndTime(node->endTime()); } TaskAddCmd::~TaskAddCmd() { if (!m_added) delete m_node; } void TaskAddCmd::execute() { //kdDebug()<name()<addTask(m_node, m_after); m_added = true; setCommandType(1); } void TaskAddCmd::unexecute() { m_project->delTask(m_node); m_added = false; setCommandType(1); } SubtaskAddCmd::SubtaskAddCmd(Part *part, Project *project, Node *node, Node *tqparent, TQString name) : NamedCommand(part, name), m_project(project), m_node(node), m_parent(tqparent), m_added(false) { // set some reasonable defaults for normally calculated values node->setStartTime(tqparent->startTime()); node->setEndTime(node->startTime() + node->duration()); node->setEarliestStart(node->startTime()); node->setLatestFinish(node->endTime()); node->setWorkStartTime(node->startTime()); node->setWorkEndTime(node->endTime()); } SubtaskAddCmd::~SubtaskAddCmd() { if (!m_added) delete m_node; } void SubtaskAddCmd::execute() { m_project->addSubTask(m_node, m_parent); m_added = true; setCommandType(1); } void SubtaskAddCmd::unexecute() { m_project->delTask(m_node); m_added = false; setCommandType(1); } NodeModifyNameCmd::NodeModifyNameCmd(Part *part, Node &node, TQString nodename, TQString name) : NamedCommand(part, name), m_node(node), newName(nodename), oldName(node.name()) { } void NodeModifyNameCmd::execute() { m_node.setName(newName); setCommandType(0); } void NodeModifyNameCmd::unexecute() { m_node.setName(oldName); setCommandType(0); } NodeModifyLeaderCmd::NodeModifyLeaderCmd(Part *part, Node &node, TQString leader, TQString name) : NamedCommand(part, name), m_node(node), newLeader(leader), oldLeader(node.leader()) { } void NodeModifyLeaderCmd::execute() { m_node.setLeader(newLeader); setCommandType(0); } void NodeModifyLeaderCmd::unexecute() { m_node.setLeader(oldLeader); setCommandType(0); } NodeModifyDescriptionCmd::NodeModifyDescriptionCmd(Part *part, Node &node, TQString description, TQString name) : NamedCommand(part, name), m_node(node), newDescription(description), oldDescription(node.description()) { } void NodeModifyDescriptionCmd::execute() { m_node.setDescription(newDescription); setCommandType(0); } void NodeModifyDescriptionCmd::unexecute() { m_node.setDescription(oldDescription); setCommandType(0); } NodeModifyConstraintCmd::NodeModifyConstraintCmd(Part *part, Node &node, Node::ConstraintType c, TQString name) : NamedCommand(part, name), m_node(node), newConstraint(c), oldConstraint(static_cast(node.constraint())) { TQIntDictIterator it = node.schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } void NodeModifyConstraintCmd::execute() { m_node.setConstraint(newConstraint); setSchScheduled(false); setCommandType(1); } void NodeModifyConstraintCmd::unexecute() { m_node.setConstraint(oldConstraint); setSchScheduled(); setCommandType(1); } NodeModifyConstraintStartTimeCmd::NodeModifyConstraintStartTimeCmd(Part *part, Node &node, TQDateTime dt, TQString name) : NamedCommand(part, name), m_node(node), newTime(dt), oldTime(node.constraintStartTime()) { TQIntDictIterator it = node.schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } void NodeModifyConstraintStartTimeCmd::execute() { m_node.setConstraintStartTime(newTime); setSchScheduled(false); setCommandType(1); } void NodeModifyConstraintStartTimeCmd::unexecute() { m_node.setConstraintStartTime(oldTime); setSchScheduled(); setCommandType(1); } NodeModifyConstraintEndTimeCmd::NodeModifyConstraintEndTimeCmd(Part *part, Node &node, TQDateTime dt, TQString name) : NamedCommand(part, name), m_node(node), newTime(dt), oldTime(node.constraintEndTime()) { TQIntDictIterator it = node.schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } void NodeModifyConstraintEndTimeCmd::execute() { m_node.setConstraintEndTime(newTime); setSchScheduled(false); setCommandType(1); } void NodeModifyConstraintEndTimeCmd::unexecute() { m_node.setConstraintEndTime(oldTime); setSchScheduled(); setCommandType(1); } NodeModifyStartTimeCmd::NodeModifyStartTimeCmd(Part *part, Node &node, TQDateTime dt, TQString name) : NamedCommand(part, name), m_node(node), newTime(dt), oldTime(node.startTime()) { } void NodeModifyStartTimeCmd::execute() { m_node.setStartTime(newTime); setCommandType(1); } void NodeModifyStartTimeCmd::unexecute() { m_node.setStartTime(oldTime); setCommandType(1); } NodeModifyEndTimeCmd::NodeModifyEndTimeCmd(Part *part, Node &node, TQDateTime dt, TQString name) : NamedCommand(part, name), m_node(node), newTime(dt), oldTime(node.endTime()) { } void NodeModifyEndTimeCmd::execute() { m_node.setEndTime(newTime); setCommandType(1); } void NodeModifyEndTimeCmd::unexecute() { m_node.setEndTime(oldTime); setCommandType(1); } NodeModifyIdCmd::NodeModifyIdCmd(Part *part, Node &node, TQString id, TQString name) : NamedCommand(part, name), m_node(node), newId(id), oldId(node.id()) { } void NodeModifyIdCmd::execute() { m_node.setId(newId); setCommandType(0); } void NodeModifyIdCmd::unexecute() { m_node.setId(oldId); setCommandType(0); } NodeIndentCmd::NodeIndentCmd(Part *part, Node &node, TQString name) : NamedCommand(part, name), m_node(node), m_newtqparent(0), m_newindex(-1) { } void NodeIndentCmd::execute() { m_oldtqparent = m_node.getParent(); m_oldindex = m_oldtqparent->findChildNode(&m_node); Project *p = dynamic_cast(m_node.projectNode()); if (p && p->indentTask(&m_node)) { m_newtqparent = m_node.getParent(); m_newindex = m_newtqparent->findChildNode(&m_node); m_node.setParent(m_newtqparent); } setCommandType(1); } void NodeIndentCmd::unexecute() { if (m_newindex != -1) { m_newtqparent->delChildNode(m_newindex, false); m_oldtqparent->insertChildNode(m_oldindex, &m_node); m_node.setParent(m_oldtqparent); m_newindex = -1; } setCommandType(1); } NodeUnindentCmd::NodeUnindentCmd(Part *part, Node &node, TQString name) : NamedCommand(part, name), m_node(node), m_newtqparent(0), m_newindex(-1) { } void NodeUnindentCmd::execute() { m_oldtqparent = m_node.getParent(); m_oldindex = m_oldtqparent->findChildNode(&m_node); Project *p = dynamic_cast(m_node.projectNode()); if (p && p->unindentTask(&m_node)) { m_newtqparent = m_node.getParent(); m_newindex = m_newtqparent->findChildNode(&m_node); m_node.setParent(m_newtqparent); } setCommandType(1); } void NodeUnindentCmd::unexecute() { if (m_newindex != -1) { m_newtqparent->delChildNode(m_newindex, false); m_oldtqparent->insertChildNode(m_oldindex, &m_node); m_node.setParent(m_oldtqparent); m_newindex = -1; } setCommandType(1); } NodeMoveUpCmd::NodeMoveUpCmd(Part *part, Node &node, TQString name) : NamedCommand(part, name), m_node(node), m_moved(false) { m_project = static_cast(m_node.projectNode()); } void NodeMoveUpCmd::execute() { if (m_project) { m_moved = m_project->moveTaskUp(&m_node); } setCommandType(0); } void NodeMoveUpCmd::unexecute() { if (m_project && m_moved) { m_project->moveTaskDown(&m_node); } m_moved = false; setCommandType(0); } NodeMoveDownCmd::NodeMoveDownCmd(Part *part, Node &node, TQString name) : NamedCommand(part, name), m_node(node), m_moved(false) { m_project = static_cast(m_node.projectNode()); } void NodeMoveDownCmd::execute() { if (m_project) { m_moved = m_project->moveTaskDown(&m_node); } setCommandType(0); } void NodeMoveDownCmd::unexecute() { if (m_project && m_moved) { m_project->moveTaskUp(&m_node); } m_moved = false; setCommandType(0); } AddRelationCmd::AddRelationCmd(Part *part, Relation *rel, TQString name) : NamedCommand(part, name), m_rel(rel) { m_taken = true; Node *p = rel->tqparent()->projectNode(); if (p) { TQIntDictIterator it = p->schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } } AddRelationCmd::~AddRelationCmd() { if (m_taken) delete m_rel; } void AddRelationCmd::execute() { //kdDebug()<tqparent()<<" to "<child()<tqparent()->addDependChildNode(m_rel); m_rel->child()->addDependParentNode(m_rel); setSchScheduled(false); setCommandType(1); } void AddRelationCmd::unexecute() { m_taken = true; m_rel->tqparent()->takeDependChildNode(m_rel); m_rel->child()->takeDependParentNode(m_rel); setSchScheduled(); setCommandType(1); } DeleteRelationCmd::DeleteRelationCmd(Part *part, Relation *rel, TQString name) : NamedCommand(part, name), m_rel(rel) { m_taken = false; Node *p = rel->tqparent()->projectNode(); if (p) { TQIntDictIterator it = p->schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } } DeleteRelationCmd::~DeleteRelationCmd() { if (m_taken) delete m_rel; } void DeleteRelationCmd::execute() { //kdDebug()<tqparent()<<" to "<child()<tqparent()->takeDependChildNode(m_rel); m_rel->child()->takeDependParentNode(m_rel); setSchScheduled(false); setCommandType(1); } void DeleteRelationCmd::unexecute() { m_taken = false; m_rel->tqparent()->addDependChildNode(m_rel); m_rel->child()->addDependParentNode(m_rel); setSchScheduled(); setCommandType(1); } ModifyRelationTypeCmd::ModifyRelationTypeCmd(Part *part, Relation *rel, Relation::Type type, TQString name) : NamedCommand(part, name), m_rel(rel), m_newtype(type) { m_oldtype = rel->type(); Node *p = rel->tqparent()->projectNode(); if (p) { TQIntDictIterator it = p->schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } } void ModifyRelationTypeCmd::execute() { m_rel->setType(m_newtype); setSchScheduled(false); setCommandType(1); } void ModifyRelationTypeCmd::unexecute() { m_rel->setType(m_oldtype); setSchScheduled(); setCommandType(1); } ModifyRelationLagCmd::ModifyRelationLagCmd(Part *part, Relation *rel, Duration lag, TQString name) : NamedCommand(part, name), m_rel(rel), m_newlag(lag) { m_oldlag = rel->lag(); Node *p = rel->tqparent()->projectNode(); if (p) { TQIntDictIterator it = p->schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } } void ModifyRelationLagCmd::execute() { m_rel->setLag(m_newlag); setSchScheduled(false); setCommandType(1); } void ModifyRelationLagCmd::unexecute() { m_rel->setLag(m_oldlag); setSchScheduled(); setCommandType(1); } AddResourceRequestCmd::AddResourceRequestCmd(Part *part, ResourceGroupRequest *group, ResourceRequest *request, TQString name) : NamedCommand(part, name), m_group(group), m_request(request) { m_mine = true; } AddResourceRequestCmd::~AddResourceRequestCmd() { if (m_mine) delete m_request; } void AddResourceRequestCmd::execute() { //kdDebug()<addResource(m_resource, 0/*risk*/); m_mine = false; //kdDebug()<takeResource(m_resource); //kdDebug()<requests(); TQIntDictIterator it = resource->schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } RemoveResourceCmd::~RemoveResourceCmd() { m_appointments.setAutoDelete(true); } void RemoveResourceCmd::execute() { TQPtrListIterator it = m_requests; for (; it.current(); ++it) { it.current()->tqparent()->takeResourceRequest(it.current()); //kdDebug()<<"Remove request for"<resource()->name()< ait = m_resource->appointments(); for (; ait.current(); ++ait) { m_appointments.append(ait.current()); } TQPtrListIterator mit = m_appointments; for (; mit.current(); ++mit) { mit.current()->detach(); //NOTE: removes from m_resource->appointments() //kdDebug()<attach(); } TQPtrListIterator it = m_requests; for (; it.current(); ++it) { it.current()->tqparent()->addResourceRequest(it.current()); //kdDebug()<<"Add request for "<resource()->name()<name(); } void ModifyResourceNameCmd::execute() { m_resource->setName(m_newvalue); setCommandType(0); } void ModifyResourceNameCmd::unexecute() { m_resource->setName(m_oldvalue); setCommandType(0); } ModifyResourceInitialsCmd::ModifyResourceInitialsCmd(Part *part, Resource *resource, TQString value, TQString name) : NamedCommand(part, name), m_resource(resource), m_newvalue(value) { m_oldvalue = resource->initials(); } void ModifyResourceInitialsCmd::execute() { m_resource->setInitials(m_newvalue); setCommandType(0); } void ModifyResourceInitialsCmd::unexecute() { m_resource->setInitials(m_oldvalue); setCommandType(0); } ModifyResourceEmailCmd::ModifyResourceEmailCmd(Part *part, Resource *resource, TQString value, TQString name) : NamedCommand(part, name), m_resource(resource), m_newvalue(value) { m_oldvalue = resource->email(); } void ModifyResourceEmailCmd::execute() { m_resource->setEmail(m_newvalue); setCommandType(0); } void ModifyResourceEmailCmd::unexecute() { m_resource->setEmail(m_oldvalue); setCommandType(0); } ModifyResourceTypeCmd::ModifyResourceTypeCmd(Part *part, Resource *resource, int value, TQString name) : NamedCommand(part, name), m_resource(resource), m_newvalue(value) { m_oldvalue = resource->type(); TQIntDictIterator it = resource->schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } void ModifyResourceTypeCmd::execute() { m_resource->setType((Resource::Type)m_newvalue); setSchScheduled(false); setCommandType(1); } void ModifyResourceTypeCmd::unexecute() { m_resource->setType((Resource::Type)m_oldvalue); setSchScheduled(); setCommandType(1); } ModifyResourceUnitsCmd::ModifyResourceUnitsCmd(Part *part, Resource *resource, int value, TQString name) : NamedCommand(part, name), m_resource(resource), m_newvalue(value) { m_oldvalue = resource->units(); TQIntDictIterator it = resource->schedules(); for (; it.current(); ++it) { addSchScheduled(it.current()); } } void ModifyResourceUnitsCmd::execute() { m_resource->setUnits(m_newvalue); setSchScheduled(false); setCommandType(1); } void ModifyResourceUnitsCmd::unexecute() { m_resource->setUnits(m_oldvalue); setSchScheduled(); setCommandType(1); } ModifyResourceAvailableFromCmd::ModifyResourceAvailableFromCmd(Part *part, Resource *resource, DateTime value, TQString name) : NamedCommand(part, name), m_resource(resource), m_newvalue(value) { m_oldvalue = resource->availableFrom(); TQIntDictIterator it = resource->schedules(); if (!it.isEmpty() && resource->project()) { TQDateTime s; TQDateTime e; for (; it.current(); ++it) { Schedule *sch = resource->project()->findSchedule(it.current()->id()); if (sch) { s = sch->start(); e = sch->end(); kdDebug()<setDeleted(false); m_node.setCurrentSchedulePtr(newSchedule); } setCommandType(0); } void CalculateProjectCmd::unexecute() { //kdDebug()<setDeleted(true); m_node.setCurrentSchedulePtr(oldCurrent); setCommandType(0); } RecalculateProjectCmd::RecalculateProjectCmd(Part *part, Project &node, Schedule &sch, TQString name) : NamedCommand(part, name), m_node(node), oldSchedule(sch), newSchedule(0), oldDeleted(sch.isDeleted()) { oldCurrent = node.currentSchedule(); //kdDebug()<typeToString()<<(oldCurrent ? oldCurrent->id() : -1)<setDeleted(true); oldSchedule.setDeleted(oldDeleted); m_node.setCurrentSchedulePtr(oldCurrent); setCommandType(0); } ModifyStandardWorktimeYearCmd::ModifyStandardWorktimeYearCmd(Part *part, StandardWorktime *wt, double oldvalue, double newvalue, TQString name) : NamedCommand(part, name), swt(wt), m_oldvalue(oldvalue), m_newvalue(newvalue) { } void ModifyStandardWorktimeYearCmd::execute() { swt->setYear(m_newvalue); setCommandType(0); } void ModifyStandardWorktimeYearCmd::unexecute() { swt->setYear(m_oldvalue); setCommandType(0); } ModifyStandardWorktimeMonthCmd::ModifyStandardWorktimeMonthCmd(Part *part, StandardWorktime *wt, double oldvalue, double newvalue, TQString name) : NamedCommand(part, name), swt(wt), m_oldvalue(oldvalue), m_newvalue(newvalue) { } void ModifyStandardWorktimeMonthCmd::execute() { swt->setMonth(m_newvalue); setCommandType(0); } void ModifyStandardWorktimeMonthCmd::unexecute() { swt->setMonth(m_oldvalue); setCommandType(0); } ModifyStandardWorktimeWeekCmd::ModifyStandardWorktimeWeekCmd(Part *part, StandardWorktime *wt, double oldvalue, double newvalue, TQString name) : NamedCommand(part, name), swt(wt), m_oldvalue(oldvalue), m_newvalue(newvalue) { } void ModifyStandardWorktimeWeekCmd::execute() { swt->setWeek(m_newvalue); setCommandType(0); } void ModifyStandardWorktimeWeekCmd::unexecute() { swt->setWeek(m_oldvalue); setCommandType(0); } ModifyStandardWorktimeDayCmd::ModifyStandardWorktimeDayCmd(Part *part, StandardWorktime *wt, double oldvalue, double newvalue, TQString name) : NamedCommand(part, name), swt(wt), m_oldvalue(oldvalue), m_newvalue(newvalue) { } void ModifyStandardWorktimeDayCmd::execute() { swt->setDay(m_newvalue); setCommandType(0); } void ModifyStandardWorktimeDayCmd::unexecute() { swt->setDay(m_oldvalue); setCommandType(0); } } //KPlato namespace