/* This file is part of the KDE project Copyright (C) 1998, 1999, 2000 Torben Weis Copyright (C) 2002 - 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; either version 2 of the License, or (at your option) any later version. 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kptview.h" #include "kptaccountsview.h" #include "kptfactory.h" #include "kptmilestoneprogressdialog.h" #include "kptnode.h" #include "kptpart.h" #include "kptproject.h" #include "kptmainprojectdialog.h" #include "kptprojectdialog.h" #include "kpttask.h" #include "kptsummarytaskdialog.h" #include "kpttaskdialog.h" #include "kpttaskprogressdialog.h" #include "kptganttview.h" #include "kptpertview.h" //#include "kptreportview.h" #include "kptdatetime.h" #include "kptcommand.h" #include "kptrelation.h" #include "kptrelationdialog.h" #include "kptresourceview.h" #include "kptresourcedialog.h" #include "kptresource.h" #include "kptresourcesdialog.h" #include "kptcalendarlistdialog.h" #include "kptstandardworktimedialog.h" #include "kptcanvasitem.h" #include "kptconfigdialog.h" #include "kptwbsdefinitiondialog.h" #include "kptaccountsdialog.h" #include "KDGanttView.h" #include "KDGanttViewTaskItem.h" #include "KPtViewIface.h" namespace KPlato { View::View(Part* part, TQWidget* parent, const char* /*name*/) : KoView(part, parent, "Main View"), m_ganttview(0), m_ganttlayout(0), m_pertview(0), m_pertlayout(0), // m_reportview(0), m_baselineMode(false), m_currentEstimateType(Effort::Use_Expected) { //kdDebug()<isReadWrite() ) setXMLFile("kplato_readonly.rc"); else setXMLFile("kplato.rc"); m_dcop = 0L; // build the DCOP object dcopObject(); m_tab = new TQWidgetStack(this); TQVBoxLayout *layout = new TQVBoxLayout(this); layout->add(m_tab); m_ganttview = new GanttView(m_tab, part->isReadWrite()); m_tab->addWidget(m_ganttview); m_updateGanttview = false; m_ganttview->draw(getPart()->getProject()); m_pertview = new PertView( this, m_tab, layout ); m_tab->addWidget(m_pertview); m_resourceview = new ResourceView( this, m_tab ); m_updateResourceview = true; m_tab->addWidget(m_resourceview); m_accountsview = new AccountsView( getProject(), this, m_tab ); m_updateAccountsview = true; m_tab->addWidget(m_accountsview); //m_reportview = new ReportView(this, m_tab); //m_tab->addWidget(m_reportview); connect(m_tab, TQT_SIGNAL(aboutToShow(TQWidget *)), TQT_TQOBJECT(this), TQT_SLOT(slotAboutToShow(TQWidget *))); connect(m_pertview, TQT_SIGNAL(addRelation(Node*, Node*)), TQT_SLOT(slotAddRelation(Node*, Node*))); connect(m_pertview, TQT_SIGNAL(modifyRelation(Relation*)), TQT_SLOT(slotModifyRelation(Relation*))); connect(m_ganttview, TQT_SIGNAL(enableActions(bool)), TQT_SLOT(setTaskActionsEnabled(bool))); connect(m_ganttview, TQT_SIGNAL(addRelation(Node*, Node*, int)), TQT_SLOT(slotAddRelation(Node*, Node*, int))); connect(m_ganttview, TQT_SIGNAL(modifyRelation(Relation*, int)), TQT_SLOT(slotModifyRelation(Relation*, int))); connect(m_ganttview, TQT_SIGNAL(modifyRelation(Relation*)), TQT_SLOT(slotModifyRelation(Relation*))); connect(m_ganttview, TQT_SIGNAL(itemDoubleClicked()), TQT_SLOT(slotOpenNode())); connect(m_ganttview, TQT_SIGNAL(itemRenamed(Node*, const TQString&)),TQT_TQOBJECT(this), TQT_SLOT(slotRenameNode(Node*, const TQString&))); connect(m_ganttview, TQT_SIGNAL(requestPopupMenu(const TQString&, const TQPoint &)),TQT_TQOBJECT(this), TQT_SLOT(slotPopupMenu(const TQString&, const TQPoint&))); connect(m_resourceview, TQT_SIGNAL(itemDoubleClicked()), TQT_SLOT(slotEditResource())); // The menu items // ------ Edit actionCut = KStdAction::cut( TQT_TQOBJECT(this), TQT_SLOT( slotEditCut() ), actionCollection(), "edit_cut" ); actionCopy = KStdAction::copy( TQT_TQOBJECT(this), TQT_SLOT( slotEditCopy() ), actionCollection(), "edit_copy" ); actionPaste = KStdAction::paste( TQT_TQOBJECT(this), TQT_SLOT( slotEditPaste() ), actionCollection(), "edit_paste" ); actionIndentTask = new KAction(i18n("Indent Task"), "indent_task", 0, TQT_TQOBJECT(this), TQT_SLOT(slotIndentTask()), actionCollection(), "indent_task"); actionUnindentTask = new KAction(i18n("Unindent Task"), "unindent_task", 0, TQT_TQOBJECT(this), TQT_SLOT(slotUnindentTask()), actionCollection(), "unindent_task"); actionMoveTaskUp = new KAction(i18n("Move Up"), "move_task_up", 0, TQT_TQOBJECT(this), TQT_SLOT(slotMoveTaskUp()), actionCollection(), "move_task_up"); actionMoveTaskDown = new KAction(i18n("Move Down"), "move_task_down", 0, TQT_TQOBJECT(this), TQT_SLOT(slotMoveTaskDown()), actionCollection(), "move_task_down"); // ------ View actionViewGantt = new KAction(i18n("Gantt"), "gantt_chart", 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGantt()), actionCollection(), "view_gantt"); TQString group = "EstimationType"; actionViewExpected = new KRadioAction(i18n("Expected"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewExpected()), actionCollection(), "view_expected"); actionViewExpected->setExclusiveGroup(group); actionViewOptimistic = new KRadioAction(i18n("Optimistic"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewOptimistic()), actionCollection(), "view_optimistic"); actionViewOptimistic->setExclusiveGroup(group); actionViewPessimistic = new KRadioAction(i18n("Pessimistic"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewPessimistic()), actionCollection(), "view_pessimistic"); actionViewPessimistic->setExclusiveGroup(group); actionViewGanttResources = new KToggleAction(i18n("Resources"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttResources()), actionCollection(), "view_gantt_showResources"); actionViewGanttTaskName = new KToggleAction(i18n("Task Name"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttTaskName()), actionCollection(), "view_gantt_showTaskName"); actionViewGanttTaskLinks = new KToggleAction(i18n("Task Links"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttTaskLinks()), actionCollection(), "view_gantt_showTaskLinks"); actionViewGanttProgress = new KToggleAction(i18n("Progress"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttProgress()), actionCollection(), "view_gantt_showProgress"); actionViewGanttFloat = new KToggleAction(i18n("Float"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttFloat()), actionCollection(), "view_gantt_showFloat"); actionViewGanttCriticalTasks = new KToggleAction(i18n("Critical Tasks"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttCriticalTasks()), actionCollection(), "view_gantt_showCriticalTasks"); actionViewGanttCriticalPath = new KToggleAction(i18n("Critical Path"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttCriticalPath()), actionCollection(), "view_gantt_showCriticalPath"); // actionViewGanttNotScheduled = new KToggleAction(i18n("Not Scheduled"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttNotScheduled()), actionCollection(), "view_gantt_showNotScheduled"); actionViewTaskAppointments = new KToggleAction(i18n("Show Allocations"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewTaskAppointments()), actionCollection(), "view_task_appointments"); actionViewPert = new KAction(i18n("Network"), "pert_chart", 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewPert()), actionCollection(), "view_pert"); actionViewResources = new KAction(i18n("Resources"), "resources", 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewResources()), actionCollection(), "view_resources"); actionViewResourceAppointments = new KToggleAction(i18n("Show Allocations"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewResourceAppointments()), actionCollection(), "view_resource_appointments"); actionViewAccounts = new KAction(i18n("Accounts"), "accounts", 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewAccounts()), actionCollection(), "view_accounts"); //actionViewReports = new KAction(i18n("Reports"), "reports", 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewReports()), actionCollection(), "view_reports"); // ------ Insert actionAddTask = new KAction(i18n("Task..."), "add_task", 0, TQT_TQOBJECT(this), TQT_SLOT(slotAddTask()), actionCollection(), "add_task"); actionAddSubtask = new KAction(i18n("Sub-Task..."), "add_sub_task", 0, TQT_TQOBJECT(this), TQT_SLOT(slotAddSubTask()), actionCollection(), "add_sub_task"); actionAddMilestone = new KAction(i18n("Milestone..."), "add_milestone", 0, TQT_TQOBJECT(this), TQT_SLOT(slotAddMilestone()), actionCollection(), "add_milestone"); // ------ Project actionEditMainProject = new KAction(i18n("Edit Main Project..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectEdit()), actionCollection(), "project_edit"); actionEditStandardWorktime = new KAction(i18n("Edit Standard Worktime..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectWorktime()), actionCollection(), "project_worktime"); actionEditCalendar = new KAction(i18n("Edit Calendar..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectCalendar()), actionCollection(), "project_calendar"); actionEditAccounts = new KAction(i18n("Edit Accounts..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectAccounts()), actionCollection(), "project_accounts"); actionEditResources = new KAction(i18n("Edit Resources..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectResources()), actionCollection(), "project_resources"); actionCalculate = new KActionMenu(i18n("Calculate"), "project_calculate", actionCollection(), "project_calculate"); connect(actionCalculate, TQT_SIGNAL(activated()), TQT_SLOT(slotProjectCalculate())); actionCalculateExpected = new KAction(i18n("Expected"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectCalculateExpected()), actionCollection(), "project_calculate_expected"); actionCalculate->insert(actionCalculateExpected); actionCalculateOptimistic = new KAction(i18n("Optimistic"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectCalculateOptimistic()), actionCollection(), "project_calculate_optimistic"); actionCalculate->insert(actionCalculateOptimistic); actionCalculatePessimistic = new KAction(i18n("Pessimistic"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectCalculatePessimistic()), actionCollection(), "project_calculate_pessimistic"); actionCalculate->insert(actionCalculatePessimistic); /* // ------ Reports actionFirstpage = KStdAction::firstPage(m_reportview,TQT_SLOT(slotPrevPage()),actionCollection(),"go_firstpage"); connect(m_reportview, TQT_SIGNAL(setFirstPageActionEnabled(bool)), actionFirstpage, TQT_SLOT(setEnabled(bool))); actionPriorpage = KStdAction::prior(m_reportview,TQT_SLOT(slotPrevPage()),actionCollection(),"go_prevpage"); connect(m_reportview, TQT_SIGNAL(setPriorPageActionEnabled(bool)), actionPriorpage, TQT_SLOT(setEnabled(bool))); actionNextpage = KStdAction::next(m_reportview,TQT_SLOT(slotNextPage()),actionCollection(), "go_nextpage"); connect(m_reportview, TQT_SIGNAL(setNextPageActionEnabled(bool)), actionNextpage, TQT_SLOT(setEnabled(bool))); actionLastpage = KStdAction::lastPage(m_reportview,TQT_SLOT(slotLastPage()),actionCollection(), "go_lastpage"); connect(m_reportview, TQT_SIGNAL(setLastPageActionEnabled(bool)), actionLastpage, TQT_SLOT(setEnabled(bool))); m_reportview->enableNavigationBtn();*/ mainWindow()->toolBar("report")->hide(); // new KAction(i18n("Design..."), "report_design", 0, TQT_TQOBJECT(this), // TQT_SLOT(slotReportDesign()), actionCollection(), "report_design"); // ------ Tools actionDefineWBS = new KAction(i18n("Define WBS Pattern..."), "tools_define_wbs", 0, TQT_TQOBJECT(this), TQT_SLOT(slotDefineWBS()), actionCollection(), "tools_generate_wbs"); actionGenerateWBS = new KAction(i18n("Generate WBS Code"), "tools_generate_wbs", 0, TQT_TQOBJECT(this), TQT_SLOT(slotGenerateWBS()), actionCollection(), "tools_define_wbs"); // ------ Export (testing) //actionExportGantt = new KAction(i18n("Export Ganttview"), "export_gantt", 0, TQT_TQOBJECT(this), // TQT_SLOT(slotExportGantt()), actionCollection(), "export_gantt"); // ------ Settings actionConfigure = new KAction(i18n("Configure KPlato..."), "configure", 0, TQT_TQOBJECT(this), TQT_SLOT(slotConfigure()), actionCollection(), "configure"); // ------ Popup actionOpenNode = new KAction(i18n("Edit..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotOpenNode()), actionCollection(), "node_properties"); actionTaskProgress = new KAction(i18n("Progress..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotTaskProgress()), actionCollection(), "task_progress"); actionDeleteTask = new KAction(i18n("Delete Task"), "editdelete", 0, TQT_TQOBJECT(this), TQT_SLOT(slotDeleteTask()), actionCollection(), "delete_task"); actionEditResource = new KAction(i18n("Edit Resource..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotEditResource()), actionCollection(), "edit_resource"); // ------------------- Actions with a key binding and no GUI item // Temporary, till we get a menu entry actNoInformation = new KAction("Toggle no information", CTRL+SHIFT+Key_T, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttNoInformation()), actionCollection(), "show_noinformation"); #ifndef NDEBUG //new KAction("Print Debug", CTRL+SHIFT+Key_P, TQT_TQOBJECT(this), TQT_SLOT( slotPrintDebug()), actionCollection(), "print_debug"); new KAction("Print Debug", CTRL+SHIFT+Key_P, TQT_TQOBJECT(this), TQT_SLOT(slotPrintSelectedDebug()), actionCollection(), "print_debug"); new KAction("Print Calendar Debug", CTRL+SHIFT+Key_C, TQT_TQOBJECT(this), TQT_SLOT(slotPrintCalendarDebug()), actionCollection(), "print_calendar_debug"); // new KAction("Print Test Debug", CTRL+SHIFT+Key_T, TQT_TQOBJECT(this), TQT_SLOT(slotPrintTestDebug()), actionCollection(), "print_test_debug"); KAction* actExportGantt = new KAction( i18n( "Export Gantt" ), CTRL+SHIFT+Key_G, TQT_TQOBJECT(this), TQT_SLOT( slotExportGantt() ), actionCollection(), "export_gantt" ); #endif // Stupid compilers ;) #ifndef NDEBUG /* Q_UNUSED( actPrintSelectedDebug ); Q_UNUSED( actPrintCalendarDebug );*/ Q_UNUSED( actExportGantt ); #endif m_estlabel = new KStatusBarLabel("", 0); addStatusBarItem(m_estlabel, 0, true); actionViewExpected->setChecked(true); //TODO: context setScheduleActionsEnabled(); slotViewExpected(); setTaskActionsEnabled(false); } View::~View() { delete m_dcop; removeStatusBarItem(m_estlabel); delete m_estlabel; } DCOPObject * View::dcopObject() { if ( !m_dcop ) m_dcop = new ViewIface( this ); return m_dcop; } Project& View::getProject() const { return getPart()->getProject(); } void View::setZoom(double zoom) { m_ganttview->setZoom(zoom); m_pertview->setZoom(zoom); } void View::setupPrinter(KPrinter &/*printer*/) { //kdDebug()<visibleWidget() == m_ganttview) { m_ganttview->print(printer); } else if (m_tab->visibleWidget() == m_pertview) { m_pertview->print(printer); } else if (m_tab->visibleWidget() == m_resourceview) { m_resourceview->print(printer); } else if (m_tab->visibleWidget() == m_accountsview) { m_accountsview->print(printer); } // else if (m_tab->visibleWidget() == m_reportview) // { // m_reportview->print(printer); // } } void View::slotEditCut() { //kdDebug()<setShowResources(actionViewGanttResources->isChecked()); if (m_tab->visibleWidget() == m_ganttview) slotUpdate(false); } void View::slotViewGanttTaskName() { //kdDebug()<setShowTaskName(actionViewGanttTaskName->isChecked()); if (m_tab->visibleWidget() == m_ganttview) slotUpdate(false); } void View::slotViewGanttTaskLinks() { //kdDebug()<setShowTaskLinks(actionViewGanttTaskLinks->isChecked()); if (m_tab->visibleWidget() == m_ganttview) slotUpdate(false); } void View::slotViewGanttProgress() { //kdDebug()<setShowProgress(actionViewGanttProgress->isChecked()); if (m_tab->visibleWidget() == m_ganttview) slotUpdate(false); } void View::slotViewGanttFloat() { //kdDebug()<setShowPositiveFloat(actionViewGanttFloat->isChecked()); if (m_tab->visibleWidget() == m_ganttview) slotUpdate(false); } void View::slotViewGanttCriticalTasks() { //kdDebug()<setShowCriticalTasks(actionViewGanttCriticalTasks->isChecked()); if (m_tab->visibleWidget() == m_ganttview) slotUpdate(false); } void View::slotViewGanttCriticalPath() { //kdDebug()<setShowCriticalPath(actionViewGanttCriticalPath->isChecked()); if (m_tab->visibleWidget() == m_ganttview) slotUpdate(false); } void View::slotViewGanttNoInformation() { kdDebug()<showNoInformation()<setShowNoInformation(!m_ganttview->showNoInformation()); //Toggle if (m_tab->visibleWidget() == m_ganttview) slotUpdate(false); } void View::slotViewTaskAppointments() { //kdDebug()<setShowAppointments(actionViewTaskAppointments->isChecked()); m_updateGanttview = true; if (m_tab->visibleWidget() == m_ganttview) slotUpdate(false); } void View::slotViewGantt() { //kdDebug()<raiseWidget(m_ganttview); } void View::slotViewPert() { //kdDebug()<raiseWidget(m_pertview); } void View::slotViewResources() { //kdDebug()<raiseWidget(m_resourceview); } void View::slotViewResourceAppointments() { //kdDebug()<setShowAppointments(actionViewResourceAppointments->isChecked()); m_updateResourceview = true; if (m_tab->visibleWidget() == m_resourceview) slotUpdate(false); } void View::slotViewAccounts() { //kdDebug()<raiseWidget(m_accountsview); } void View::slotProjectEdit() { MainProjectDialog *dia = new MainProjectDialog(getProject()); if (dia->exec()) { KCommand *cmd = dia->buildCommand(getPart()); if (cmd) { getPart()->addCommand(cmd); } } delete dia; } void View::slotProjectCalendar() { CalendarListDialog *dia = new CalendarListDialog(getProject()); if (dia->exec()) { KCommand *cmd = dia->buildCommand(getPart()); if (cmd) { //kdDebug()<addCommand(cmd); //also executes } } delete dia; } void View::slotProjectAccounts() { AccountsDialog *dia = new AccountsDialog(getProject().accounts()); if (dia->exec()) { KCommand *cmd = dia->buildCommand(getPart()); if (cmd) { //kdDebug()<addCommand(cmd); //also executes } } delete dia; } void View::slotProjectWorktime() { StandardWorktimeDialog *dia = new StandardWorktimeDialog(getProject()); if (dia->exec()) { KCommand *cmd = dia->buildCommand(getPart()); if (cmd) { //kdDebug()<addCommand(cmd); //also executes } } delete dia; } void View::slotProjectResources() { ResourcesDialog *dia = new ResourcesDialog(getProject()); if (dia->exec()) { KCommand *cmd = dia->buildCommand(getPart()); if (cmd) { //kdDebug()<addCommand(cmd); //also executes } } delete dia; } void View::slotProjectCalculate() { //kdDebug()< 0*/) { // NOTE: This can be removed when proper baselining etc is implemented if (KMessageBox::warningContinueCancel(this, i18n("Progress information will be deleted if the project is recalculated."), i18n("Calculate"), i18n("Calculate")) == KMessageBox::Cancel) { return; } } TQApplication::setOverrideCursor(TQt::waitCursor); Schedule *ns = getProject().findSchedule((Schedule::Type)m_currentEstimateType); KCommand *cmd; if (ns) { cmd = new RecalculateProjectCmd(getPart(), getProject(), *ns, i18n("Calculate")); } else { cmd = new CalculateProjectCmd(getPart(), getProject(), i18n("Standard"), (Effort::Use)m_currentEstimateType, i18n("Calculate")); } getPart()->addCommand(cmd); TQApplication::restoreOverrideCursor(); } void View::slotViewReportDesign() { //kdDebug()<raiseWidget(m_reportview); } void View::slotAddSubTask() { // If we are positionend on the root project, then what we really want to // do is to add a first project. We will silently accept the challenge // and will not complain. Task* node = getProject().createTask(getPart()->config().taskDefaults(), currentTask()); TaskDialog *dia = new TaskDialog(*node, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined()); if (dia->exec()) { Node *currNode = currentTask(); if (currNode) { KCommand *m = dia->buildCommand(getPart()); m->execute(); // do changes to task delete m; SubtaskAddCmd *cmd = new SubtaskAddCmd(getPart(), &(getProject()), node, currNode, i18n("Add Subtask")); getPart()->addCommand(cmd); // add task to project return; } else kdDebug()<config().taskDefaults(), currentTask()); TaskDialog *dia = new TaskDialog(*node, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined()); if (dia->exec()) { Node* currNode = currentTask(); if (currNode) { KCommand *m = dia->buildCommand(getPart()); m->execute(); // do changes to task delete m; TaskAddCmd *cmd = new TaskAddCmd(getPart(), &(getProject()), node, currNode, i18n("Add Task")); getPart()->addCommand(cmd); // add task to project return; } else kdDebug()<effort()->set(Duration::zeroDuration); TaskDialog *dia = new TaskDialog(*node, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined()); if (dia->exec()) { Node *currNode = currentTask(); if (currNode) { KCommand *m = dia->buildCommand(getPart()); m->execute(); // do changes to task delete m; TaskAddCmd *cmd = new TaskAddCmd(getPart(), &(getProject()), node, currNode, i18n("Add Milestone")); getPart()->addCommand(cmd); // add task to project return; } else kdDebug()<wbsDefinition()); dia->exec(); delete dia; } void View::slotGenerateWBS() { //kdDebug()<generateWBS(); slotUpdate(false); } void View::slotConfigure() { //kdDebug()<config(), getProject()); dia->exec(); delete dia; } Node *View::currentTask() { Node* task = 0; if (m_tab->visibleWidget() == m_ganttview) { task = m_ganttview->currentNode(); } else if (m_tab->visibleWidget() == m_pertview) { task = m_pertview->currentNode(); } else if (m_tab->visibleWidget() == m_resourceview) { task = m_resourceview->currentNode(); } if ( 0 != task ) { return task; } return &(getProject()); } void View::slotOpenNode() { //kdDebug()<type()) { case Node::Type_Project: { Project *project = dynamic_cast(node); MainProjectDialog *dia = new MainProjectDialog(*project); if (dia->exec()){ KCommand *m = dia->buildCommand(getPart()); if (m) { getPart()->addCommand(m); } } delete dia; break; } case Node::Type_Subproject: //TODO break; case Node::Type_Task: { Task *task = dynamic_cast(node); TaskDialog *dia = new TaskDialog(*task, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined()); if (dia->exec()) { KCommand *m = dia->buildCommand(getPart()); if (m) { getPart()->addCommand(m); } } delete dia; break; } case Node::Type_Milestone: { // Use the normal task dialog for now. // Maybe milestone should have it's own dialog, but we need to be able to // enter a duration in case we accidentally set a tasks duration to zero // and hence, create a milestone Task *task = dynamic_cast(node); TaskDialog *dia = new TaskDialog(*task, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined()); if (dia->exec()) { KCommand *m = dia->buildCommand(getPart()); if (m) { getPart()->addCommand(m); } } delete dia; break; } case Node::Type_Summarytask: { Task *task = dynamic_cast(node); SummaryTaskDialog *dia = new SummaryTaskDialog(*task); if (dia->exec()) { KCommand *m = dia->buildCommand(getPart()); if (m) { getPart()->addCommand(m); } } delete dia; break; } default: break; // avoid warnings } } void View::slotTaskProgress() { //kdDebug()<type()) { case Node::Type_Project: { break; } case Node::Type_Subproject: //TODO break; case Node::Type_Task: { Task *task = dynamic_cast(node); TaskProgressDialog *dia = new TaskProgressDialog(*task, getProject().standardWorktime()); if (dia->exec()) { KCommand *m = dia->buildCommand(getPart()); if (m) { getPart()->addCommand(m); } } delete dia; break; } case Node::Type_Milestone: { Task *task = dynamic_cast(node); MilestoneProgressDialog *dia = new MilestoneProgressDialog(*task); if (dia->exec()) { KCommand *m = dia->buildCommand(getPart()); if (m) { getPart()->addCommand(m); } } delete dia; break; } case Node::Type_Summarytask: { // TODO break; } default: break; // avoid warnings } } void View::slotDeleteTask() { //kdDebug()<getParent() == 0) { kdDebug()<addCommand(new NodeDeleteCmd(getPart(), node)); TQPtrListIterator it = node->dependChildNodes(); for (; it.current(); ++it) { cmd->addCommand(new DeleteRelationCmd(getPart(), it.current())); } it = node->dependParentNodes(); for (; it.current(); ++it) { cmd->addCommand(new DeleteRelationCmd(getPart(),it.current())); } getPart()->addCommand(cmd); } void View::slotIndentTask() { //kdDebug()<getParent() == 0) { kdDebug()<addCommand(cmd); } } void View::slotUnindentTask() { //kdDebug()<getParent() == 0) { kdDebug()<addCommand(cmd); } } void View::slotMoveTaskUp() { //kdDebug()<type() ) { kdDebug()<addCommand(cmd); } } void View::slotMoveTaskDown() { //kdDebug()<type() ) { kdDebug()<addCommand(cmd); } } void View::slotAddRelation(Node *par, Node *child) { //kdDebug()<exec()) { KCommand *cmd = dia->buildCommand(getPart()); if (cmd) getPart()->addCommand(cmd); } else { delete rel; } delete dia; } void View::slotAddRelation(Node *par, Node *child, int linkType) { //kdDebug()<(linkType)); getPart()->addCommand(new AddRelationCmd(getPart(), rel, i18n("Add Relation"))); } else { slotAddRelation(par, child); } } void View::slotModifyRelation(Relation *rel) { //kdDebug()<exec()) { if (dia->relationIsDeleted()) { getPart()->addCommand(new DeleteRelationCmd(getPart(), rel, i18n("Delete Relation"))); } else { KCommand *cmd = dia->buildCommand(getPart()); if (cmd) { getPart()->addCommand(cmd); } } } delete dia; } void View::slotModifyRelation(Relation *rel, int linkType) { //kdDebug()<addCommand(new ModifyRelationTypeCmd(getPart(), rel, static_cast(linkType))); } else { slotModifyRelation(rel); } } // testing void View::slotExportGantt() { //kdDebug()<exportGantt(TQT_TQIODEVICE(&f)); } } void View::slotEditResource() { //kdDebug()<currentResource(); if (!r) return; ResourceDialog *dia = new ResourceDialog(getProject(), r); if (dia->exec()) { KCommand *cmd = dia->buildCommand(getPart()); if (cmd) getPart()->addCommand(cmd); } delete dia; } void View::updateReadWrite(bool /*readwrite*/) { } Part *View::getPart()const { return (Part *)koDocument(); } void View::slotConnectNode() { //kdDebug()<currentItem(); if (curr) { kdDebug()<getNode().name()<container( name, this )); return 0L; } void View::slotChanged(TQWidget *) { //kdDebug()<hide(); if (widget == m_ganttview) { //kdDebug()<setShowExpected(actionViewExpected->isChecked()); m_ganttview->setShowOptimistic(actionViewOptimistic->isChecked()); m_ganttview->setShowPessimistic(actionViewPessimistic->isChecked()); if (m_updateGanttview) m_ganttview->drawChanges(getProject()); setTaskActionsEnabled(widget, true); m_updateGanttview = false; } else if (widget == m_pertview) { //kdDebug()<draw(); } else if (widget == m_resourceview) { //kdDebug()<draw(getPart()->getProject()); m_updateResourceview = false; } else if (widget == m_accountsview) { //kdDebug()<draw(); m_updateAccountsview = false; } /* else if (widget == m_reportview) { mainWindow()->toolBar("report")->show(); m_reportview->enableNavigationBtn(); }*/ TQApplication::restoreOverrideCursor(); } void View::slotRenameNode(Node *node, const TQString& name) { //kdDebug()<addCommand(cmd); } } void View::slotPopupMenu(const TQString& menuname, const TQPoint & pos) { TQPopupMenu* menu = this->popupMenu(menuname); if (menu) menu->exec(pos); } bool View::setContext(Context &context) { //kdDebug()<setChecked(context.actionViewExpected); actionViewOptimistic->setChecked(context.actionViewOptimistic); actionViewPessimistic->setChecked(context.actionViewPessimistic); m_ganttview->setContext(context.ganttview, getProject()); // hmmm, can't decide if these should be here or actions moved to ganttview actionViewGanttResources->setChecked(context.ganttview.showResources); actionViewGanttTaskName->setChecked(context.ganttview.showTaskName); actionViewGanttTaskLinks->setChecked(context.ganttview.showTaskLinks); actionViewGanttProgress->setChecked(context.ganttview.showProgress); actionViewGanttFloat->setChecked(context.ganttview.showPositiveFloat); actionViewGanttCriticalTasks->setChecked(context.ganttview.showCriticalTasks); actionViewGanttCriticalPath->setChecked(context.ganttview.showCriticalPath); m_pertview->setContext(context.pertview); m_resourceview->setContext(context.resourceview); m_accountsview->setContext(context.accountsview); // m_reportview->setContext(context.reportview); if (context.currentView == "ganttview") { m_ganttview->setShowExpected(actionViewExpected->isChecked()); m_ganttview->setShowOptimistic(actionViewOptimistic->isChecked()); m_ganttview->setShowPessimistic(actionViewPessimistic->isChecked()); slotViewGantt(); } else if (context.currentView == "pertview") { slotViewPert(); } else if (context.currentView == "resourceview") { slotViewResources(); } else if (context.currentView == "accountsview") { slotViewAccounts(); } else if (context.currentView == "reportview") { //slotViewReport(); } else { slotViewGantt(); } slotUpdate(false); return true; } void View::getContext(Context &context) const { //kdDebug()<id(); context.actionViewExpected = actionViewExpected->isChecked(); context.actionViewOptimistic = actionViewOptimistic->isChecked(); context.actionViewPessimistic = actionViewPessimistic->isChecked(); if (m_tab->visibleWidget() == m_ganttview) { context.currentView = "ganttview"; } else if (m_tab->visibleWidget() == m_pertview) { context.currentView = "pertview"; } else if (m_tab->visibleWidget() == m_resourceview) { context.currentView = "resourceview"; } else if (m_tab->visibleWidget() == m_accountsview) { context.currentView = "accountsview"; /* } else if (m_tab->visibleWidget() == m_reportview) { context.currentView = "reportview";*/ } m_ganttview->getContext(context.ganttview); m_pertview->getContext(context.pertview); m_resourceview->getContext(context.resourceview); m_accountsview->getContext(context.accountsview); // m_reportview->getContext(context.reportview); } void View::setBaselineMode(bool /*on*/) { //kdDebug()<setReadWriteMode(!on); actionCut->setEnabled(!on); actionCopy->setEnabled(!on); actionPaste->setEnabled(!on); actionDeleteTask->setEnabled(!on); actionIndentTask->setEnabled(!on); actionUnindentTask->setEnabled(!on); actionMoveTaskUp->setEnabled(!on); actionMoveTaskDown->setEnabled(!on); actionAddTask->setEnabled(!on); actionAddSubtask->setEnabled(!on); actionAddMilestone->setEnabled(!on); actionEditStandardWorktime->setEnabled(!on); actionEditCalendar->setEnabled(!on); actionEditResources->setEnabled(!on); actionCalculate->setEnabled(!on); actionEditResource->setEnabled(!on);*/ } // called when widget w is about to be shown void View::setTaskActionsEnabled(TQWidget *w, bool on) { Node *n = 0; if (w == m_ganttview) { n = m_ganttview->currentNode(); }// else pert, etc when implemented actionAddTask->setEnabled(on); actionAddMilestone->setEnabled(on); // only enabled when we have a task selected bool o = (on && n); actionAddSubtask->setEnabled(o); actionDeleteTask->setEnabled(o); actionMoveTaskUp->setEnabled(o && getProject().canMoveTaskUp(n)); actionMoveTaskDown->setEnabled(o && getProject().canMoveTaskDown(n)); actionIndentTask->setEnabled(o && getProject().canIndentTask(n)); actionUnindentTask->setEnabled(o && getProject().canUnindentTask(n)); } void View::setTaskActionsEnabled(bool on) { setTaskActionsEnabled(m_ganttview, on); //FIXME if more than ganttview can do this } void View::setScheduleActionsEnabled() { actionViewExpected->setEnabled(getProject().findSchedule(Schedule::Expected)); actionViewOptimistic->setEnabled(getProject().findSchedule(Schedule::Optimistic)); actionViewPessimistic->setEnabled(getProject().findSchedule(Schedule::Pessimistic)); if (getProject().notScheduled()) { m_estlabel->setText(i18n("Not scheduled")); return; } Schedule *ns = getProject().currentSchedule(); if (ns->type() == Schedule::Expected) { actionViewExpected->setChecked(true); m_estlabel->setText(i18n("Expected")); } else if (ns->type() == Schedule::Optimistic) { actionViewOptimistic->setChecked(true); m_estlabel->setText(i18n("Optimistic")); } else if (ns->type() == Schedule::Pessimistic) { actionViewPessimistic->setChecked(true); m_estlabel->setText(i18n("Pessimistic")); } } #ifndef NDEBUG void View::slotPrintDebug() { kdDebug()<<"-------- Debug printout: Node list" <currentNode(); if (curr) { curr->printDebug(true,""); } else*/ getPart()->getProject().printDebug(true, ""); } void View::slotPrintSelectedDebug() { Node *curr = m_ganttview->currentNode(); if (curr) { kdDebug()<<"-------- Debug printout: Selected node" <printDebug(true,""); } else slotPrintDebug(); } void View::slotPrintCalendarDebug() { kdDebug()<<"-------- Debug printout: Node list" <currentNode(); if (curr) { curr->printDebug(true,""); } else*/ getPart()->getProject().printCalendarDebug(""); } void View::slotPrintTestDebug() { const TQStringList &lst = getPart()->xmlLoader().log(); for ( TQStringList::ConstIterator it = lst.constBegin(); it != lst.constEnd(); ++it ) { kdDebug()<<*it<addInterval(TQPair(t1, t2)); // if (!t->addDay(day)) { // kdDebug()<<"Failed to add day"<startOfDay().toString()<<" - "<endOfDay()<startOfDay().toString()<<" - "<endOfDay()<findDay(wdate); // bool b = (day == d); // kdDebug()<<"1: Success="<firstAvailableAfter(after, after.addDays(10)); // b = !dt.isValid(); // kdDebug()<<"2: Success="<hasInterval(after, after.addDays(1)); // kdDebug()<<"7: Success="<hasInterval(before, before.addDays(-1)); // kdDebug()<<"8: Success="<effort(before, after); // b = e1==e2; // kdDebug()<<"9: Success="<setParent(p); // TQDate wdate(2006,1,2); // DateTime before = DateTime(wdate.addDays(-1)); // DateTime after = DateTime(wdate.addDays(1)); // TQTime t1(8,0,0); // TQTime t2(10,0,0); // DateTime wdt1(wdate, t1); // DateTime wdt2(wdate, t2); // CalendarDay *day = new CalendarDay(TQDate(2006,1,2), Map::Working); // day->addInterval(TQPair(t1, t2)); // if (!p->addDay(day)) { // kdDebug()<<"Failed to add day"<startOfDay().toString()<<" - "<endOfDay().toString()<startOfDay().toString()<<" - "<endOfDay().toString()<findDay(wdate); // bool b = (day == d); // kdDebug()<<"1: Success="<firstAvailableAfter(after, after.addDays(10)); // b = !dt.isValid(); // kdDebug()<<"2: Success="<hasInterval(after, after.addDays(1)); // kdDebug()<<"7: Success="<hasInterval(before, before.addDays(-1)); // kdDebug()<<"8: Success="<effort(before, after); // b = e1==e2; // kdDebug()<<"9: Success="<weekday(0); // monday // if (wd1 == 0) { // kdDebug()<<"Failed to get weekday"<setState(Map::NonWorking); // // CalendarDay *wd2 = p->weekday(2); // wednesday // if (wd2 == 0) { // kdDebug()<<"Failed to get weekday"<addInterval(TQPair(t1, t2)); // wd2->setState(Map::Working); // // Calendar *t = new Calendar("Test 4"); // t->setParent(p); // TQDate wdate(2006,1,2); // monday jan 2 // DateTime before = DateTime(wdate.addDays(-4)); //Thursday dec 29 // DateTime after = DateTime(wdate.addDays(4)); // Friday jan 6 // DateTime wdt1(wdate, t1); // DateTime wdt2(TQDate(2006, 1, 4), t2); // Wednesday // CalendarDay *day = new CalendarDay(TQDate(2006,1,2), Map::Working); // day->addInterval(TQPair(t1, t2)); // if (!p->addDay(day)) { // kdDebug()<<"Failed to add day"<startOfDay().toString()<<" - "<endOfDay().toString()<startOfDay().toString()<<" - "<endOfDay().toString()<findDay(wdate); // bool b = (day == d); // kdDebug()<<"1: Success="<firstAvailableAfter(after, after.addDays(10)); // b = (dt.isValid() && dt == DateTime(TQDate(2006,1,11), t1)); // kdDebug()<<"2: Success="<hasInterval(after, after.addDays(1)); // kdDebug()<<"7: Success="<hasInterval(before, before.addDays(-1)); // kdDebug()<<"8: Success="<effort(before, after); // b = e1==e2; // kdDebug()<<"9: Success="<firstInterval(r.second, after); // b = r.first == DateTime(TQDate(2006, 1, 4),t1); // We find the wednesday jan 4 // kdDebug()<<"11: Success="<