22#include <tdemessagebox.h>
24#include <KoMainWindow.h>
26#include <tqapplication.h>
30#include <tqsplitter.h>
32#include <tqscrollview.h>
36#include <tqstringlist.h>
41#include <tqtabwidget.h>
42#include <tqwidgetstack.h>
44#include <tqpopupmenu.h>
47#include <kiconloader.h>
49#include <kstdaction.h>
52#include <tdelistview.h>
53#include <tdestdaccel.h>
54#include <tdeaccelgen.h>
55#include <tdeversion.h>
56#include <kstatusbar.h>
57#include <kxmlguifactory.h>
59#include <kstandarddirs.h>
60#include <kdesktopfile.h>
62#include <tdefiledialog.h>
65#include "kptaccountsview.h"
66#include "kptfactory.h"
67#include "kptmilestoneprogressdialog.h"
70#include "kptproject.h"
71#include "kptmainprojectdialog.h"
72#include "kptprojectdialog.h"
74#include "kptsummarytaskdialog.h"
75#include "kpttaskdialog.h"
76#include "kpttaskprogressdialog.h"
77#include "kptganttview.h"
78#include "kptpertview.h"
80#include "kptdatetime.h"
81#include "kptcommand.h"
82#include "kptrelation.h"
83#include "kptrelationdialog.h"
84#include "kptresourceview.h"
85#include "kptresourcedialog.h"
86#include "kptresource.h"
87#include "kptresourcesdialog.h"
88#include "kptcalendarlistdialog.h"
89#include "kptstandardworktimedialog.h"
90#include "kptcanvasitem.h"
91#include "kptconfigdialog.h"
92#include "kptwbsdefinitiondialog.h"
93#include "kptaccountsdialog.h"
95#include "KDGanttView.h"
96#include "KDGanttViewTaskItem.h"
97#include "KPtViewIface.h"
102View::View(Part* part, TQWidget* parent,
const char* )
103 : KoView(part, parent,
"Main View"),
109 m_baselineMode(false),
110 m_currentEstimateType(Effort::Use_Expected)
113 getProject().setCurrentSchedule(Schedule::Expected);
115 setInstance(Factory::global());
116 if ( !part->isReadWrite() )
117 setXMLFile(
"kplato_readonly.rc");
119 setXMLFile(
"kplato.rc");
124 m_tab =
new TQWidgetStack(
this);
125 TQVBoxLayout *layout =
new TQVBoxLayout(
this);
128 m_ganttview =
new GanttView(m_tab, part->isReadWrite());
129 m_tab->addWidget(m_ganttview);
130 m_updateGanttview =
false;
131 m_ganttview->draw(getPart()->getProject());
133 m_pertview =
new PertView(
this, m_tab, layout );
134 m_tab->addWidget(m_pertview);
136 m_resourceview =
new ResourceView(
this, m_tab );
137 m_updateResourceview =
true;
138 m_tab->addWidget(m_resourceview);
140 m_accountsview =
new AccountsView( getProject(),
this, m_tab );
141 m_updateAccountsview =
true;
142 m_tab->addWidget(m_accountsview);
147 connect(m_tab, TQ_SIGNAL(aboutToShow(TQWidget *)),
this, TQ_SLOT(slotAboutToShow(TQWidget *)));
149 connect(m_pertview, TQ_SIGNAL(addRelation(Node*, Node*)), TQ_SLOT(slotAddRelation(Node*, Node*)));
150 connect(m_pertview, TQ_SIGNAL(modifyRelation(Relation*)), TQ_SLOT(slotModifyRelation(Relation*)));
152 connect(m_ganttview, TQ_SIGNAL(enableActions(
bool)), TQ_SLOT(setTaskActionsEnabled(
bool)));
153 connect(m_ganttview, TQ_SIGNAL(addRelation(Node*, Node*,
int)), TQ_SLOT(slotAddRelation(Node*, Node*,
int)));
154 connect(m_ganttview, TQ_SIGNAL(modifyRelation(Relation*,
int)), TQ_SLOT(slotModifyRelation(Relation*,
int)));
155 connect(m_ganttview, TQ_SIGNAL(modifyRelation(Relation*)), TQ_SLOT(slotModifyRelation(Relation*)));
156 connect(m_ganttview, TQ_SIGNAL(itemDoubleClicked()), TQ_SLOT(slotOpenNode()));
157 connect(m_ganttview, TQ_SIGNAL(itemRenamed(Node*,
const TQString&)),
this, TQ_SLOT(slotRenameNode(Node*,
const TQString&)));
158 connect(m_ganttview, TQ_SIGNAL(requestPopupMenu(
const TQString&,
const TQPoint &)),
this, TQ_SLOT(slotPopupMenu(
const TQString&,
const TQPoint&)));
159 connect(m_resourceview, TQ_SIGNAL(itemDoubleClicked()), TQ_SLOT(slotEditResource()));
163 actionCut = KStdAction::cut(
this, TQ_SLOT( slotEditCut() ), actionCollection(),
"edit_cut" );
164 actionCopy = KStdAction::copy(
this, TQ_SLOT( slotEditCopy() ), actionCollection(),
"edit_copy" );
165 actionPaste = KStdAction::paste(
this, TQ_SLOT( slotEditPaste() ), actionCollection(),
"edit_paste" );
167 actionIndentTask =
new TDEAction(i18n(
"Indent Task"),
"indent_task", 0,
this,
168 TQ_SLOT(slotIndentTask()), actionCollection(),
"indent_task");
169 actionUnindentTask =
new TDEAction(i18n(
"Unindent Task"),
"unindent_task", 0,
this,
170 TQ_SLOT(slotUnindentTask()), actionCollection(),
"unindent_task");
171 actionMoveTaskUp =
new TDEAction(i18n(
"Move Up"),
"move_task_up", 0,
this,
172 TQ_SLOT(slotMoveTaskUp()), actionCollection(),
"move_task_up");
173 actionMoveTaskDown =
new TDEAction(i18n(
"Move Down"),
"move_task_down", 0,
this,
174 TQ_SLOT(slotMoveTaskDown()), actionCollection(),
"move_task_down");
177 actionViewGantt =
new TDEAction(i18n(
"Gantt"),
"gantt_chart", 0,
this, TQ_SLOT(slotViewGantt()), actionCollection(),
"view_gantt");
179 TQString group =
"EstimationType";
180 actionViewExpected =
new TDERadioAction(i18n(
"Expected"), 0, 0,
this, TQ_SLOT(slotViewExpected()), actionCollection(),
"view_expected");
181 actionViewExpected->setExclusiveGroup(group);
182 actionViewOptimistic =
new TDERadioAction(i18n(
"Optimistic"), 0, 0,
this, TQ_SLOT(slotViewOptimistic()), actionCollection(),
"view_optimistic");
183 actionViewOptimistic->setExclusiveGroup(group);
184 actionViewPessimistic =
new TDERadioAction(i18n(
"Pessimistic"), 0, 0,
this, TQ_SLOT(slotViewPessimistic()), actionCollection(),
"view_pessimistic");
185 actionViewPessimistic->setExclusiveGroup(group);
187 actionViewGanttResources =
new TDEToggleAction(i18n(
"Resources"), 0, 0,
this, TQ_SLOT(slotViewGanttResources()), actionCollection(),
"view_gantt_showResources");
188 actionViewGanttTaskName =
new TDEToggleAction(i18n(
"Task Name"), 0, 0,
this, TQ_SLOT(slotViewGanttTaskName()), actionCollection(),
"view_gantt_showTaskName");
189 actionViewGanttTaskLinks =
new TDEToggleAction(i18n(
"Task Links"), 0, 0,
this, TQ_SLOT(slotViewGanttTaskLinks()), actionCollection(),
"view_gantt_showTaskLinks");
190 actionViewGanttProgress =
new TDEToggleAction(i18n(
"Progress"), 0, 0,
this, TQ_SLOT(slotViewGanttProgress()), actionCollection(),
"view_gantt_showProgress");
191 actionViewGanttFloat =
new TDEToggleAction(i18n(
"Float"), 0, 0,
this, TQ_SLOT(slotViewGanttFloat()), actionCollection(),
"view_gantt_showFloat");
192 actionViewGanttCriticalTasks =
new TDEToggleAction(i18n(
"Critical Tasks"), 0, 0,
this, TQ_SLOT(slotViewGanttCriticalTasks()), actionCollection(),
"view_gantt_showCriticalTasks");
193 actionViewGanttCriticalPath =
new TDEToggleAction(i18n(
"Critical Path"), 0, 0,
this, TQ_SLOT(slotViewGanttCriticalPath()), actionCollection(),
"view_gantt_showCriticalPath");
197 actionViewTaskAppointments =
new TDEToggleAction(i18n(
"Show Allocations"), 0, 0,
this, TQ_SLOT(slotViewTaskAppointments()), actionCollection(),
"view_task_appointments");
199 actionViewPert =
new TDEAction(i18n(
"Network"),
"pert_chart", 0,
this, TQ_SLOT(slotViewPert()), actionCollection(),
"view_pert");
201 actionViewResources =
new TDEAction(i18n(
"Resources"),
"resources", 0,
this, TQ_SLOT(slotViewResources()), actionCollection(),
"view_resources");
203 actionViewResourceAppointments =
new TDEToggleAction(i18n(
"Show Allocations"), 0, 0,
this, TQ_SLOT(slotViewResourceAppointments()), actionCollection(),
"view_resource_appointments");
205 actionViewAccounts =
new TDEAction(i18n(
"Accounts"),
"accounts", 0,
this, TQ_SLOT(slotViewAccounts()), actionCollection(),
"view_accounts");
210 actionAddTask =
new TDEAction(i18n(
"Task..."),
"add_task", 0,
this,
211 TQ_SLOT(slotAddTask()), actionCollection(),
"add_task");
212 actionAddSubtask =
new TDEAction(i18n(
"Sub-Task..."),
"add_sub_task", 0,
this,
213 TQ_SLOT(slotAddSubTask()), actionCollection(),
"add_sub_task");
214 actionAddMilestone =
new TDEAction(i18n(
"Milestone..."),
"add_milestone", 0,
this,
215 TQ_SLOT(slotAddMilestone()), actionCollection(),
"add_milestone");
218 actionEditMainProject =
new TDEAction(i18n(
"Edit Main Project..."),
"edit", 0,
this, TQ_SLOT(slotProjectEdit()), actionCollection(),
"project_edit");
219 actionEditStandardWorktime =
new TDEAction(i18n(
"Edit Standard Worktime..."),
"edit", 0,
this, TQ_SLOT(slotProjectWorktime()), actionCollection(),
"project_worktime");
220 actionEditCalendar =
new TDEAction(i18n(
"Edit Calendar..."),
"edit", 0,
this, TQ_SLOT(slotProjectCalendar()), actionCollection(),
"project_calendar");
221 actionEditAccounts =
new TDEAction(i18n(
"Edit Accounts..."),
"edit", 0,
this, TQ_SLOT(slotProjectAccounts()), actionCollection(),
"project_accounts");
222 actionEditResources =
new TDEAction(i18n(
"Edit Resources..."),
"edit", 0,
this, TQ_SLOT(slotProjectResources()), actionCollection(),
"project_resources");
224 actionCalculate =
new TDEActionMenu(i18n(
"Calculate"),
"project_calculate", actionCollection(),
"project_calculate");
225 connect(actionCalculate, TQ_SIGNAL(activated()), TQ_SLOT(slotProjectCalculate()));
227 actionCalculateExpected =
new TDEAction(i18n(
"Expected"), 0, 0,
this, TQ_SLOT(slotProjectCalculateExpected()), actionCollection(),
"project_calculate_expected");
228 actionCalculate->insert(actionCalculateExpected);
230 actionCalculateOptimistic =
new TDEAction(i18n(
"Optimistic"), 0, 0,
this, TQ_SLOT(slotProjectCalculateOptimistic()), actionCollection(),
"project_calculate_optimistic");
231 actionCalculate->insert(actionCalculateOptimistic);
233 actionCalculatePessimistic =
new TDEAction(i18n(
"Pessimistic"), 0, 0,
this, TQ_SLOT(slotProjectCalculatePessimistic()), actionCollection(),
"project_calculate_pessimistic");
234 actionCalculate->insert(actionCalculatePessimistic);
246 mainWindow()->toolBar(
"report")->hide();
254 new TDEAction(i18n(
"Define WBS Pattern..."),
"tools_define_wbs", 0,
this,
255 TQ_SLOT(slotDefineWBS()), actionCollection(),
"tools_generate_wbs");
257 new TDEAction(i18n(
"Generate WBS Code"),
"tools_generate_wbs", 0,
this,
258 TQ_SLOT(slotGenerateWBS()), actionCollection(),
"tools_define_wbs");
265 actionConfigure =
new TDEAction(i18n(
"Configure KPlato..."),
"configure", 0,
this,
266 TQ_SLOT(slotConfigure()), actionCollection(),
"configure");
269 actionOpenNode =
new TDEAction(i18n(
"Edit..."),
"edit", 0,
this,
270 TQ_SLOT(slotOpenNode()), actionCollection(),
"node_properties");
271 actionTaskProgress =
new TDEAction(i18n(
"Progress..."),
"edit", 0,
this,
272 TQ_SLOT(slotTaskProgress()), actionCollection(),
"task_progress");
273 actionDeleteTask =
new TDEAction(i18n(
"Delete Task"),
"edit-delete", 0,
this,
274 TQ_SLOT(slotDeleteTask()), actionCollection(),
"delete_task");
276 actionEditResource =
new TDEAction(i18n(
"Edit Resource..."),
"edit", 0,
this,
277 TQ_SLOT(slotEditResource()), actionCollection(),
"edit_resource");
281 actNoInformation =
new TDEAction(
"Toggle no information", CTRL+SHIFT+Key_T,
this, TQ_SLOT(slotViewGanttNoInformation()), actionCollection(),
"show_noinformation");
285 new TDEAction(
"Print Debug", CTRL+SHIFT+Key_P,
this, TQ_SLOT(slotPrintSelectedDebug()), actionCollection(),
"print_debug");
286 new TDEAction(
"Print Calendar Debug", CTRL+SHIFT+Key_C,
this, TQ_SLOT(slotPrintCalendarDebug()), actionCollection(),
"print_calendar_debug");
289 TDEAction* actExportGantt =
new TDEAction( i18n(
"Export Gantt" ), CTRL+SHIFT+Key_G,
290 this, TQ_SLOT( slotExportGantt() ), actionCollection(),
"export_gantt" );
297 Q_UNUSED( actExportGantt );
300 m_estlabel =
new KStatusBarLabel(
"", 0);
301 addStatusBarItem(m_estlabel, 0,
true);
302 actionViewExpected->setChecked(
true);
303 setScheduleActionsEnabled();
306 setTaskActionsEnabled(
false);
312 removeStatusBarItem(m_estlabel);
316DCOPObject * View::dcopObject()
319 m_dcop =
new ViewIface(
this );
325Project& View::getProject()
const
327 return getPart()->getProject();
330void View::setZoom(
double zoom) {
331 m_ganttview->setZoom(zoom);
332 m_pertview->setZoom(zoom);
335void View::setupPrinter(KPrinter &) {
339void View::print(KPrinter &printer) {
341 if (printer.previewOnly()) {
343 if (!printer.setup()) {
347 if (m_tab->visibleWidget() == m_ganttview)
349 m_ganttview->print(printer);
351 else if (m_tab->visibleWidget() == m_pertview)
353 m_pertview->print(printer);
355 else if (m_tab->visibleWidget() == m_resourceview)
357 m_resourceview->print(printer);
359 else if (m_tab->visibleWidget() == m_accountsview)
361 m_accountsview->print(printer);
370void View::slotEditCut() {
374void View::slotEditCopy() {
378void View::slotEditPaste() {
382void View::slotViewExpected() {
384 m_currentEstimateType = Effort::Use_Expected;
385 getProject().setCurrentSchedulePtr(getProject().findSchedule(Schedule::Expected));
389void View::slotViewOptimistic() {
391 m_currentEstimateType = Effort::Use_Optimistic;
392 getProject().setCurrentSchedulePtr(getProject().findSchedule(Schedule::Optimistic));
396void View::slotViewPessimistic() {
398 m_currentEstimateType = Effort::Use_Pessimistic;
399 getProject().setCurrentSchedulePtr(getProject().findSchedule(Schedule::Pessimistic));
403void View::slotViewGanttResources() {
405 m_ganttview->setShowResources(actionViewGanttResources->isChecked());
406 if (m_tab->visibleWidget() == m_ganttview)
410void View::slotViewGanttTaskName() {
412 m_ganttview->setShowTaskName(actionViewGanttTaskName->isChecked());
413 if (m_tab->visibleWidget() == m_ganttview)
417void View::slotViewGanttTaskLinks() {
419 m_ganttview->setShowTaskLinks(actionViewGanttTaskLinks->isChecked());
420 if (m_tab->visibleWidget() == m_ganttview)
424void View::slotViewGanttProgress() {
426 m_ganttview->setShowProgress(actionViewGanttProgress->isChecked());
427 if (m_tab->visibleWidget() == m_ganttview)
431void View::slotViewGanttFloat() {
433 m_ganttview->setShowPositiveFloat(actionViewGanttFloat->isChecked());
434 if (m_tab->visibleWidget() == m_ganttview)
438void View::slotViewGanttCriticalTasks() {
440 m_ganttview->setShowCriticalTasks(actionViewGanttCriticalTasks->isChecked());
441 if (m_tab->visibleWidget() == m_ganttview)
445void View::slotViewGanttCriticalPath() {
447 m_ganttview->setShowCriticalPath(actionViewGanttCriticalPath->isChecked());
448 if (m_tab->visibleWidget() == m_ganttview)
452void View::slotViewGanttNoInformation() {
453 kdDebug()<<k_funcinfo<<m_ganttview->showNoInformation()<<endl;
454 m_ganttview->setShowNoInformation(!m_ganttview->showNoInformation());
455 if (m_tab->visibleWidget() == m_ganttview)
459void View::slotViewTaskAppointments() {
461 m_ganttview->setShowAppointments(actionViewTaskAppointments->isChecked());
462 m_updateGanttview =
true;
463 if (m_tab->visibleWidget() == m_ganttview)
467void View::slotViewGantt() {
469 m_tab->raiseWidget(m_ganttview);
472void View::slotViewPert() {
474 m_tab->raiseWidget(m_pertview);
477void View::slotViewResources() {
479 m_tab->raiseWidget(m_resourceview);
482void View::slotViewResourceAppointments() {
484 m_resourceview->setShowAppointments(actionViewResourceAppointments->isChecked());
485 m_updateResourceview =
true;
486 if (m_tab->visibleWidget() == m_resourceview)
490void View::slotViewAccounts() {
492 m_tab->raiseWidget(m_accountsview);
495void View::slotProjectEdit() {
496 MainProjectDialog *dia =
new MainProjectDialog(getProject());
498 KCommand *cmd = dia->buildCommand(getPart());
500 getPart()->addCommand(cmd);
506void View::slotProjectCalendar() {
507 CalendarListDialog *dia =
new CalendarListDialog(getProject());
509 KCommand *cmd = dia->buildCommand(getPart());
512 getPart()->addCommand(cmd);
518void View::slotProjectAccounts() {
519 AccountsDialog *dia =
new AccountsDialog(getProject().accounts());
521 KCommand *cmd = dia->buildCommand(getPart());
524 getPart()->addCommand(cmd);
530void View::slotProjectWorktime() {
531 StandardWorktimeDialog *dia =
new StandardWorktimeDialog(getProject());
533 KCommand *cmd = dia->buildCommand(getPart());
536 getPart()->addCommand(cmd);
542void View::slotProjectResources() {
543 ResourcesDialog *dia =
new ResourcesDialog(getProject());
545 KCommand *cmd = dia->buildCommand(getPart());
548 getPart()->addCommand(cmd);
554void View::slotProjectCalculate() {
559void View::slotProjectCalculateExpected() {
560 m_currentEstimateType = Effort::Use_Expected;
561 m_updateGanttview =
true;
562 m_updateResourceview =
true;
563 m_updateAccountsview =
true;
567void View::slotProjectCalculateOptimistic() {
568 m_currentEstimateType = Effort::Use_Optimistic;
569 m_updateGanttview =
true;
570 m_updateResourceview =
true;
571 m_updateAccountsview =
true;
575void View::slotProjectCalculatePessimistic() {
576 m_currentEstimateType = Effort::Use_Pessimistic;
577 m_updateGanttview =
true;
578 m_updateResourceview =
true;
579 m_updateAccountsview =
true;
583void View::projectCalculate() {
586 if (KMessageBox::warningContinueCancel(
this, i18n(
"Progress information will be deleted if the project is recalculated."), i18n(
"Calculate"), i18n(
"Calculate")) == KMessageBox::Cancel) {
590 TQApplication::setOverrideCursor(TQt::waitCursor);
591 Schedule *ns = getProject().findSchedule((Schedule::Type)m_currentEstimateType);
594 cmd =
new RecalculateProjectCmd(getPart(), getProject(), *ns, i18n(
"Calculate"));
596 cmd =
new CalculateProjectCmd(getPart(), getProject(), i18n(
"Standard"), (Effort::Use)m_currentEstimateType, i18n(
"Calculate"));
598 getPart()->addCommand(cmd);
599 TQApplication::restoreOverrideCursor();
602void View::slotViewReportDesign() {
606void View::slotViewReports() {
611void View::slotAddSubTask() {
615 Task* node = getProject().createTask(getPart()->config().taskDefaults(), currentTask());
616 TaskDialog *dia =
new TaskDialog(*node, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
618 Node *currNode = currentTask();
621 KCommand *m = dia->buildCommand(getPart());
624 SubtaskAddCmd *cmd =
new SubtaskAddCmd(getPart(), &(getProject()), node, currNode, i18n(
"Add Subtask"));
625 getPart()->addCommand(cmd);
629 kdDebug()<<k_funcinfo<<
"Cannot insert new project. Hmm, no current node!?"<<endl;
636void View::slotAddTask() {
637 Task* node = getProject().createTask(getPart()->config().taskDefaults(), currentTask());
638 TaskDialog *dia =
new TaskDialog(*node, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
640 Node* currNode = currentTask();
643 KCommand *m = dia->buildCommand(getPart());
646 TaskAddCmd *cmd =
new TaskAddCmd(getPart(), &(getProject()), node, currNode, i18n(
"Add Task"));
647 getPart()->addCommand(cmd);
651 kdDebug()<<k_funcinfo<<
"Cannot insert new task. Hmm, no current node!?"<<endl;
657void View::slotAddMilestone() {
658 Task* node = getProject().createTask(currentTask());
659 node->effort()->set(Duration::zeroDuration);
661 TaskDialog *dia =
new TaskDialog(*node, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
663 Node *currNode = currentTask();
666 KCommand *m = dia->buildCommand(getPart());
669 TaskAddCmd *cmd =
new TaskAddCmd(getPart(), &(getProject()), node, currNode, i18n(
"Add Milestone"));
670 getPart()->addCommand(cmd);
674 kdDebug()<<k_funcinfo<<
"Cannot insert new milestone. Hmm, no current node!?"<<endl;
680void View::slotDefineWBS() {
682 WBSDefinitionDialog *dia =
new WBSDefinitionDialog(getPart()->wbsDefinition());
688void View::slotGenerateWBS() {
690 getPart()->generateWBS();
694void View::slotConfigure() {
696 ConfigDialog *dia =
new ConfigDialog(getPart()->config(), getProject());
701Node *View::currentTask()
704 if (m_tab->visibleWidget() == m_ganttview) {
705 task = m_ganttview->currentNode();
707 else if (m_tab->visibleWidget() == m_pertview) {
708 task = m_pertview->currentNode();
710 else if (m_tab->visibleWidget() == m_resourceview) {
711 task = m_resourceview->currentNode();
716 return &(getProject());
719void View::slotOpenNode() {
721 Node *node = currentTask();
725 switch (node->type()) {
726 case Node::Type_Project: {
727 Project *project =
dynamic_cast<Project *
>(node);
728 MainProjectDialog *dia =
new MainProjectDialog(*project);
730 KCommand *m = dia->buildCommand(getPart());
732 getPart()->addCommand(m);
738 case Node::Type_Subproject:
741 case Node::Type_Task: {
742 Task *task =
dynamic_cast<Task *
>(node);
743 TaskDialog *dia =
new TaskDialog(*task, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
745 KCommand *m = dia->buildCommand(getPart());
747 getPart()->addCommand(m);
753 case Node::Type_Milestone: {
758 Task *task =
dynamic_cast<Task *
>(node);
759 TaskDialog *dia =
new TaskDialog(*task, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
761 KCommand *m = dia->buildCommand(getPart());
763 getPart()->addCommand(m);
769 case Node::Type_Summarytask: {
770 Task *task =
dynamic_cast<Task *
>(node);
771 SummaryTaskDialog *dia =
new SummaryTaskDialog(*task);
773 KCommand *m = dia->buildCommand(getPart());
775 getPart()->addCommand(m);
786void View::slotTaskProgress() {
788 Node *node = currentTask();
792 switch (node->type()) {
793 case Node::Type_Project: {
796 case Node::Type_Subproject:
799 case Node::Type_Task: {
800 Task *task =
dynamic_cast<Task *
>(node);
801 TaskProgressDialog *dia =
new TaskProgressDialog(*task, getProject().standardWorktime());
803 KCommand *m = dia->buildCommand(getPart());
805 getPart()->addCommand(m);
811 case Node::Type_Milestone: {
812 Task *task =
dynamic_cast<Task *
>(node);
813 MilestoneProgressDialog *dia =
new MilestoneProgressDialog(*task);
815 KCommand *m = dia->buildCommand(getPart());
817 getPart()->addCommand(m);
823 case Node::Type_Summarytask: {
832void View::slotDeleteTask()
835 Node *node = currentTask();
836 if (node == 0 || node->getParent() == 0) {
837 kdDebug()<<k_funcinfo<<(node ?
"Task is main project" :
"No current task")<<endl;
840 KMacroCommand *cmd =
new KMacroCommand(i18n(
"Delete Task"));
841 cmd->addCommand(
new NodeDeleteCmd(getPart(), node));
842 TQPtrListIterator<Relation> it = node->dependChildNodes();
843 for (; it.current(); ++it) {
844 cmd->addCommand(
new DeleteRelationCmd(getPart(), it.current()));
846 it = node->dependParentNodes();
847 for (; it.current(); ++it) {
848 cmd->addCommand(
new DeleteRelationCmd(getPart(),it.current()));
850 getPart()->addCommand(cmd);
853void View::slotIndentTask()
856 Node *node = currentTask();
857 if (node == 0 || node->getParent() == 0) {
858 kdDebug()<<k_funcinfo<<(node ?
"Task is main project" :
"No current task")<<endl;
861 if (getProject().canIndentTask(node)) {
862 NodeIndentCmd *cmd =
new NodeIndentCmd(getPart(), *node, i18n(
"Indent Task"));
863 getPart()->addCommand(cmd);
867void View::slotUnindentTask()
870 Node *node = currentTask();
871 if (node == 0 || node->getParent() == 0) {
872 kdDebug()<<k_funcinfo<<(node ?
"Task is main project" :
"No current task")<<endl;
875 if (getProject().canUnindentTask(node)) {
876 NodeUnindentCmd *cmd =
new NodeUnindentCmd(getPart(), *node, i18n(
"Unindent Task"));
877 getPart()->addCommand(cmd);
881void View::slotMoveTaskUp()
885 Node* task = currentTask();
889 kdError()<<k_funcinfo<<
"No current task"<<endl;
893 if ( Node::Type_Project == task->type() ) {
894 kdDebug()<<k_funcinfo<<
"The root node cannot be moved up"<<endl;
897 if (getProject().canMoveTaskUp(task)) {
898 NodeMoveUpCmd *cmd =
new NodeMoveUpCmd(getPart(), *task, i18n(
"Move Task Up"));
899 getPart()->addCommand(cmd);
903void View::slotMoveTaskDown()
907 Node* task = currentTask();
914 if ( Node::Type_Project == task->type() ) {
915 kdDebug()<<k_funcinfo<<
"The root node cannot be moved down"<<endl;
918 if (getProject().canMoveTaskDown(task)) {
919 NodeMoveDownCmd *cmd =
new NodeMoveDownCmd(getPart(), *task, i18n(
"Move Task Down"));
920 getPart()->addCommand(cmd);
924void View::slotAddRelation(Node *par, Node *child) {
926 Relation *rel =
new Relation(par, child);
927 AddRelationDialog *dia =
new AddRelationDialog(rel,
this);
929 KCommand *cmd = dia->buildCommand(getPart());
931 getPart()->addCommand(cmd);
938void View::slotAddRelation(Node *par, Node *child,
int linkType) {
940 if (linkType == Relation::FinishStart ||
941 linkType == Relation::StartStart ||
942 linkType == Relation::FinishFinish)
944 Relation *rel =
new Relation(par, child,
static_cast<Relation::Type
>(linkType));
945 getPart()->addCommand(
new AddRelationCmd(getPart(), rel, i18n(
"Add Relation")));
947 slotAddRelation(par, child);
951void View::slotModifyRelation(Relation *rel) {
953 ModifyRelationDialog *dia =
new ModifyRelationDialog(rel,
this);
955 if (dia->relationIsDeleted()) {
956 getPart()->addCommand(
new DeleteRelationCmd(getPart(), rel, i18n(
"Delete Relation")));
958 KCommand *cmd = dia->buildCommand(getPart());
960 getPart()->addCommand(cmd);
967void View::slotModifyRelation(Relation *rel,
int linkType) {
969 if (linkType == Relation::FinishStart ||
970 linkType == Relation::StartStart ||
971 linkType == Relation::FinishFinish)
973 getPart()->addCommand(
new ModifyRelationTypeCmd(getPart(), rel,
static_cast<Relation::Type
>(linkType)));
975 slotModifyRelation(rel);
980void View::slotExportGantt() {
985 TQString fn = KFileDialog::getSaveFileName( TQString(), TQString(),
this );
988 m_ganttview->exportGantt(&f);
992void View::slotEditResource() {
994 Resource *r = m_resourceview->currentResource();
997 ResourceDialog *dia =
new ResourceDialog(getProject(), r);
999 KCommand *cmd = dia->buildCommand(getPart());
1001 getPart()->addCommand(cmd);
1006void View::updateReadWrite(
bool ) {
1009Part *View::getPart()
const {
1010 return (Part *)koDocument();
1013void View::slotConnectNode() {
1021TQPopupMenu * View::popupMenu(
const TQString& name )
1024 Q_ASSERT(factory());
1026 return ((TQPopupMenu*)factory()->container( name,
this ));
1030void View::slotChanged(TQWidget *)
1036void View::slotChanged()
1042void View::slotUpdate(
bool calculate)
1048 m_updateGanttview =
true;
1049 m_updateResourceview =
true;
1050 m_updateAccountsview =
true;
1052 updateView(m_tab->visibleWidget());
1055void View::slotAboutToShow(TQWidget *widget) {
1059void View::updateView(TQWidget *widget)
1061 TQApplication::setOverrideCursor(TQt::waitCursor);
1062 setScheduleActionsEnabled();
1063 setTaskActionsEnabled(
false);
1064 mainWindow()->toolBar(
"report")->hide();
1065 if (widget == m_ganttview)
1068 m_ganttview->setShowExpected(actionViewExpected->isChecked());
1069 m_ganttview->setShowOptimistic(actionViewOptimistic->isChecked());
1070 m_ganttview->setShowPessimistic(actionViewPessimistic->isChecked());
1071 if (m_updateGanttview)
1072 m_ganttview->drawChanges(getProject());
1073 setTaskActionsEnabled(widget,
true);
1074 m_updateGanttview =
false;
1076 else if (widget == m_pertview)
1081 else if (widget == m_resourceview)
1084 if (m_updateResourceview)
1085 m_resourceview->draw(getPart()->getProject());
1086 m_updateResourceview =
false;
1088 else if (widget == m_accountsview)
1091 if (m_updateAccountsview)
1092 m_accountsview->draw();
1093 m_updateAccountsview =
false;
1100 TQApplication::restoreOverrideCursor();
1103void View::slotRenameNode(Node *node,
const TQString& name) {
1106 NodeModifyNameCmd *cmd =
new NodeModifyNameCmd(getPart(), *node, name, i18n(
"Modify Name"));
1107 getPart()->addCommand(cmd);
1111void View::slotPopupMenu(
const TQString& menuname,
const TQPoint & pos)
1113 TQPopupMenu* menu = this->popupMenu(menuname);
1118bool View::setContext(Context &context) {
1120 m_currentEstimateType = context.currentEstimateType;
1121 getProject().setCurrentSchedule(context.currentSchedule);
1122 actionViewExpected->setChecked(context.actionViewExpected);
1123 actionViewOptimistic->setChecked(context.actionViewOptimistic);
1124 actionViewPessimistic->setChecked(context.actionViewPessimistic);
1126 m_ganttview->setContext(context.ganttview, getProject());
1128 actionViewGanttResources->setChecked(context.ganttview.showResources);
1129 actionViewGanttTaskName->setChecked(context.ganttview.showTaskName);
1130 actionViewGanttTaskLinks->setChecked(context.ganttview.showTaskLinks);
1131 actionViewGanttProgress->setChecked(context.ganttview.showProgress);
1132 actionViewGanttFloat->setChecked(context.ganttview.showPositiveFloat);
1133 actionViewGanttCriticalTasks->setChecked(context.ganttview.showCriticalTasks);
1134 actionViewGanttCriticalPath->setChecked(context.ganttview.showCriticalPath);
1136 m_pertview->setContext(context.pertview);
1137 m_resourceview->setContext(context.resourceview);
1138 m_accountsview->setContext(context.accountsview);
1141 if (context.currentView ==
"ganttview") {
1142 m_ganttview->setShowExpected(actionViewExpected->isChecked());
1143 m_ganttview->setShowOptimistic(actionViewOptimistic->isChecked());
1144 m_ganttview->setShowPessimistic(actionViewPessimistic->isChecked());
1146 }
else if (context.currentView ==
"pertview") {
1148 }
else if (context.currentView ==
"resourceview") {
1149 slotViewResources();
1150 }
else if (context.currentView ==
"accountsview") {
1152 }
else if (context.currentView ==
"reportview") {
1161void View::getContext(Context &context)
const {
1163 context.currentEstimateType = m_currentEstimateType;
1164 if (getProject().currentSchedule())
1165 context.currentSchedule = getProject().currentSchedule()->id();
1166 context.actionViewExpected = actionViewExpected->isChecked();
1167 context.actionViewOptimistic = actionViewOptimistic->isChecked();
1168 context.actionViewPessimistic = actionViewPessimistic->isChecked();
1170 if (m_tab->visibleWidget() == m_ganttview) {
1171 context.currentView =
"ganttview";
1172 }
else if (m_tab->visibleWidget() == m_pertview) {
1173 context.currentView =
"pertview";
1174 }
else if (m_tab->visibleWidget() == m_resourceview) {
1175 context.currentView =
"resourceview";
1176 }
else if (m_tab->visibleWidget() == m_accountsview) {
1177 context.currentView =
"accountsview";
1181 m_ganttview->getContext(context.ganttview);
1182 m_pertview->getContext(context.pertview);
1183 m_resourceview->getContext(context.resourceview);
1184 m_accountsview->getContext(context.accountsview);
1188void View::setBaselineMode(
bool ) {
1217void View::setTaskActionsEnabled(TQWidget *w,
bool on) {
1219 if (w == m_ganttview) {
1220 n = m_ganttview->currentNode();
1223 actionAddTask->setEnabled(on);
1224 actionAddMilestone->setEnabled(on);
1227 actionAddSubtask->setEnabled(o);
1228 actionDeleteTask->setEnabled(o);
1229 actionMoveTaskUp->setEnabled(o && getProject().canMoveTaskUp(n));
1230 actionMoveTaskDown->setEnabled(o && getProject().canMoveTaskDown(n));
1231 actionIndentTask->setEnabled(o && getProject().canIndentTask(n));
1232 actionUnindentTask->setEnabled(o && getProject().canUnindentTask(n));
1235void View::setTaskActionsEnabled(
bool on) {
1236 setTaskActionsEnabled(m_ganttview, on);
1239void View::setScheduleActionsEnabled() {
1240 actionViewExpected->setEnabled(getProject().findSchedule(Schedule::Expected));
1241 actionViewOptimistic->setEnabled(getProject().findSchedule(Schedule::Optimistic));
1242 actionViewPessimistic->setEnabled(getProject().findSchedule(Schedule::Pessimistic));
1243 if (getProject().notScheduled()) {
1244 m_estlabel->setText(i18n(
"Not scheduled"));
1247 Schedule *ns = getProject().currentSchedule();
1248 if (ns->type() == Schedule::Expected) {
1249 actionViewExpected->setChecked(
true);
1250 m_estlabel->setText(i18n(
"Expected"));
1251 }
else if (ns->type() == Schedule::Optimistic) {
1252 actionViewOptimistic->setChecked(
true);
1253 m_estlabel->setText(i18n(
"Optimistic"));
1254 }
else if (ns->type() == Schedule::Pessimistic) {
1255 actionViewPessimistic->setChecked(
true);
1256 m_estlabel->setText(i18n(
"Pessimistic"));
1262void View::slotPrintDebug() {
1263 kdDebug()<<
"-------- Debug printout: Node list" <<endl;
1268 getPart()->getProject().printDebug(
true,
"");
1270void View::slotPrintSelectedDebug() {
1271 Node *curr = m_ganttview->currentNode();
1273 kdDebug()<<
"-------- Debug printout: Selected node" <<endl;
1274 curr->printDebug(
true,
"");
1278void View::slotPrintCalendarDebug() {
1279 kdDebug()<<
"-------- Debug printout: Node list" <<endl;
1284 getPart()->getProject().printCalendarDebug(
"");
1286void View::slotPrintTestDebug() {
1287 const TQStringList &lst = getPart()->xmlLoader().log();
1289 for ( TQStringList::ConstIterator it = lst.constBegin(); it != lst.constEnd(); ++it ) {
1290 kdDebug()<<*it<<endl;
1519#include "kptview.moc"