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 <kstatusbar.h>
56#include <kxmlguifactory.h>
58#include <kstandarddirs.h>
59#include <kdesktopfile.h>
61#include <tdefiledialog.h>
64#include "kptaccountsview.h"
65#include "kptfactory.h"
66#include "kptmilestoneprogressdialog.h"
69#include "kptproject.h"
70#include "kptmainprojectdialog.h"
71#include "kptprojectdialog.h"
73#include "kptsummarytaskdialog.h"
74#include "kpttaskdialog.h"
75#include "kpttaskprogressdialog.h"
76#include "kptganttview.h"
77#include "kptpertview.h"
79#include "kptdatetime.h"
80#include "kptcommand.h"
81#include "kptrelation.h"
82#include "kptrelationdialog.h"
83#include "kptresourceview.h"
84#include "kptresourcedialog.h"
85#include "kptresource.h"
86#include "kptresourcesdialog.h"
87#include "kptcalendarlistdialog.h"
88#include "kptstandardworktimedialog.h"
89#include "kptcanvasitem.h"
90#include "kptconfigdialog.h"
91#include "kptwbsdefinitiondialog.h"
92#include "kptaccountsdialog.h"
94#include "KDGanttView.h"
95#include "KDGanttViewTaskItem.h"
96#include "KPtViewIface.h"
101View::View(Part* part, TQWidget* parent,
const char* )
102 : KoView(part, parent,
"Main View"),
108 m_baselineMode(false),
109 m_currentEstimateType(
Effort::Use_Expected)
112 getProject().setCurrentSchedule(Schedule::Expected);
114 setInstance(Factory::global());
115 if ( !part->isReadWrite() )
116 setXMLFile(
"kplato_readonly.rc");
118 setXMLFile(
"kplato.rc");
123 m_tab =
new TQWidgetStack(
this);
124 TQVBoxLayout *layout =
new TQVBoxLayout(
this);
127 m_ganttview =
new GanttView(m_tab, part->isReadWrite());
128 m_tab->addWidget(m_ganttview);
129 m_updateGanttview =
false;
130 m_ganttview->draw(getPart()->getProject());
132 m_pertview =
new PertView(
this, m_tab, layout );
133 m_tab->addWidget(m_pertview);
135 m_resourceview =
new ResourceView(
this, m_tab );
136 m_updateResourceview =
true;
137 m_tab->addWidget(m_resourceview);
139 m_accountsview =
new AccountsView( getProject(),
this, m_tab );
140 m_updateAccountsview =
true;
141 m_tab->addWidget(m_accountsview);
146 connect(m_tab, TQ_SIGNAL(aboutToShow(TQWidget *)),
this, TQ_SLOT(slotAboutToShow(TQWidget *)));
148 connect(m_pertview, TQ_SIGNAL(addRelation(Node*, Node*)), TQ_SLOT(slotAddRelation(Node*, Node*)));
149 connect(m_pertview, TQ_SIGNAL(modifyRelation(Relation*)), TQ_SLOT(slotModifyRelation(Relation*)));
151 connect(m_ganttview, TQ_SIGNAL(enableActions(
bool)), TQ_SLOT(setTaskActionsEnabled(
bool)));
152 connect(m_ganttview, TQ_SIGNAL(addRelation(Node*, Node*,
int)), TQ_SLOT(slotAddRelation(Node*, Node*,
int)));
153 connect(m_ganttview, TQ_SIGNAL(modifyRelation(Relation*,
int)), TQ_SLOT(slotModifyRelation(Relation*,
int)));
154 connect(m_ganttview, TQ_SIGNAL(modifyRelation(Relation*)), TQ_SLOT(slotModifyRelation(Relation*)));
155 connect(m_ganttview, TQ_SIGNAL(itemDoubleClicked()), TQ_SLOT(slotOpenNode()));
156 connect(m_ganttview, TQ_SIGNAL(itemRenamed(Node*,
const TQString&)),
this, TQ_SLOT(slotRenameNode(Node*,
const TQString&)));
157 connect(m_ganttview, TQ_SIGNAL(requestPopupMenu(
const TQString&,
const TQPoint &)),
this, TQ_SLOT(slotPopupMenu(
const TQString&,
const TQPoint&)));
158 connect(m_resourceview, TQ_SIGNAL(itemDoubleClicked()), TQ_SLOT(slotEditResource()));
162 actionCut = KStdAction::cut(
this, TQ_SLOT( slotEditCut() ), actionCollection(),
"edit_cut" );
163 actionCopy = KStdAction::copy(
this, TQ_SLOT( slotEditCopy() ), actionCollection(),
"edit_copy" );
164 actionPaste = KStdAction::paste(
this, TQ_SLOT( slotEditPaste() ), actionCollection(),
"edit_paste" );
166 actionIndentTask =
new TDEAction(i18n(
"Indent Task"),
"indent_task", 0,
this,
167 TQ_SLOT(slotIndentTask()), actionCollection(),
"indent_task");
168 actionUnindentTask =
new TDEAction(i18n(
"Unindent Task"),
"unindent_task", 0,
this,
169 TQ_SLOT(slotUnindentTask()), actionCollection(),
"unindent_task");
170 actionMoveTaskUp =
new TDEAction(i18n(
"Move Up"),
"move_task_up", 0,
this,
171 TQ_SLOT(slotMoveTaskUp()), actionCollection(),
"move_task_up");
172 actionMoveTaskDown =
new TDEAction(i18n(
"Move Down"),
"move_task_down", 0,
this,
173 TQ_SLOT(slotMoveTaskDown()), actionCollection(),
"move_task_down");
176 actionViewGantt =
new TDEAction(i18n(
"Gantt"),
"gantt_chart", 0,
this, TQ_SLOT(slotViewGantt()), actionCollection(),
"view_gantt");
178 TQString group =
"EstimationType";
179 actionViewExpected =
new TDERadioAction(i18n(
"Expected"), 0, 0,
this, TQ_SLOT(slotViewExpected()), actionCollection(),
"view_expected");
180 actionViewExpected->setExclusiveGroup(group);
181 actionViewOptimistic =
new TDERadioAction(i18n(
"Optimistic"), 0, 0,
this, TQ_SLOT(slotViewOptimistic()), actionCollection(),
"view_optimistic");
182 actionViewOptimistic->setExclusiveGroup(group);
183 actionViewPessimistic =
new TDERadioAction(i18n(
"Pessimistic"), 0, 0,
this, TQ_SLOT(slotViewPessimistic()), actionCollection(),
"view_pessimistic");
184 actionViewPessimistic->setExclusiveGroup(group);
186 actionViewGanttResources =
new TDEToggleAction(i18n(
"Resources"), 0, 0,
this, TQ_SLOT(slotViewGanttResources()), actionCollection(),
"view_gantt_showResources");
187 actionViewGanttTaskName =
new TDEToggleAction(i18n(
"Task Name"), 0, 0,
this, TQ_SLOT(slotViewGanttTaskName()), actionCollection(),
"view_gantt_showTaskName");
188 actionViewGanttTaskLinks =
new TDEToggleAction(i18n(
"Task Links"), 0, 0,
this, TQ_SLOT(slotViewGanttTaskLinks()), actionCollection(),
"view_gantt_showTaskLinks");
189 actionViewGanttProgress =
new TDEToggleAction(i18n(
"Progress"), 0, 0,
this, TQ_SLOT(slotViewGanttProgress()), actionCollection(),
"view_gantt_showProgress");
190 actionViewGanttFloat =
new TDEToggleAction(i18n(
"Float"), 0, 0,
this, TQ_SLOT(slotViewGanttFloat()), actionCollection(),
"view_gantt_showFloat");
191 actionViewGanttCriticalTasks =
new TDEToggleAction(i18n(
"Critical Tasks"), 0, 0,
this, TQ_SLOT(slotViewGanttCriticalTasks()), actionCollection(),
"view_gantt_showCriticalTasks");
192 actionViewGanttCriticalPath =
new TDEToggleAction(i18n(
"Critical Path"), 0, 0,
this, TQ_SLOT(slotViewGanttCriticalPath()), actionCollection(),
"view_gantt_showCriticalPath");
196 actionViewTaskAppointments =
new TDEToggleAction(i18n(
"Show Allocations"), 0, 0,
this, TQ_SLOT(slotViewTaskAppointments()), actionCollection(),
"view_task_appointments");
198 actionViewPert =
new TDEAction(i18n(
"Network"),
"pert_chart", 0,
this, TQ_SLOT(slotViewPert()), actionCollection(),
"view_pert");
200 actionViewResources =
new TDEAction(i18n(
"Resources"),
"resources", 0,
this, TQ_SLOT(slotViewResources()), actionCollection(),
"view_resources");
202 actionViewResourceAppointments =
new TDEToggleAction(i18n(
"Show Allocations"), 0, 0,
this, TQ_SLOT(slotViewResourceAppointments()), actionCollection(),
"view_resource_appointments");
204 actionViewAccounts =
new TDEAction(i18n(
"Accounts"),
"accounts", 0,
this, TQ_SLOT(slotViewAccounts()), actionCollection(),
"view_accounts");
209 actionAddTask =
new TDEAction(i18n(
"Task..."),
"add_task", 0,
this,
210 TQ_SLOT(slotAddTask()), actionCollection(),
"add_task");
211 actionAddSubtask =
new TDEAction(i18n(
"Sub-Task..."),
"add_sub_task", 0,
this,
212 TQ_SLOT(slotAddSubTask()), actionCollection(),
"add_sub_task");
213 actionAddMilestone =
new TDEAction(i18n(
"Milestone..."),
"add_milestone", 0,
this,
214 TQ_SLOT(slotAddMilestone()), actionCollection(),
"add_milestone");
217 actionEditMainProject =
new TDEAction(i18n(
"Edit Main Project..."),
"edit", 0,
this, TQ_SLOT(slotProjectEdit()), actionCollection(),
"project_edit");
218 actionEditStandardWorktime =
new TDEAction(i18n(
"Edit Standard Worktime..."),
"edit", 0,
this, TQ_SLOT(slotProjectWorktime()), actionCollection(),
"project_worktime");
219 actionEditCalendar =
new TDEAction(i18n(
"Edit Calendar..."),
"edit", 0,
this, TQ_SLOT(slotProjectCalendar()), actionCollection(),
"project_calendar");
220 actionEditAccounts =
new TDEAction(i18n(
"Edit Accounts..."),
"edit", 0,
this, TQ_SLOT(slotProjectAccounts()), actionCollection(),
"project_accounts");
221 actionEditResources =
new TDEAction(i18n(
"Edit Resources..."),
"edit", 0,
this, TQ_SLOT(slotProjectResources()), actionCollection(),
"project_resources");
223 actionCalculate =
new TDEActionMenu(i18n(
"Calculate"),
"project_calculate", actionCollection(),
"project_calculate");
224 connect(actionCalculate, TQ_SIGNAL(activated()), TQ_SLOT(slotProjectCalculate()));
226 actionCalculateExpected =
new TDEAction(i18n(
"Expected"), 0, 0,
this, TQ_SLOT(slotProjectCalculateExpected()), actionCollection(),
"project_calculate_expected");
227 actionCalculate->insert(actionCalculateExpected);
229 actionCalculateOptimistic =
new TDEAction(i18n(
"Optimistic"), 0, 0,
this, TQ_SLOT(slotProjectCalculateOptimistic()), actionCollection(),
"project_calculate_optimistic");
230 actionCalculate->insert(actionCalculateOptimistic);
232 actionCalculatePessimistic =
new TDEAction(i18n(
"Pessimistic"), 0, 0,
this, TQ_SLOT(slotProjectCalculatePessimistic()), actionCollection(),
"project_calculate_pessimistic");
233 actionCalculate->insert(actionCalculatePessimistic);
245 mainWindow()->toolBar(
"report")->hide();
253 new TDEAction(i18n(
"Define WBS Pattern..."),
"tools_define_wbs", 0,
this,
254 TQ_SLOT(slotDefineWBS()), actionCollection(),
"tools_generate_wbs");
256 new TDEAction(i18n(
"Generate WBS Code"),
"tools_generate_wbs", 0,
this,
257 TQ_SLOT(slotGenerateWBS()), actionCollection(),
"tools_define_wbs");
264 actionConfigure =
new TDEAction(i18n(
"Configure KPlato..."),
"configure", 0,
this,
265 TQ_SLOT(slotConfigure()), actionCollection(),
"configure");
268 actionOpenNode =
new TDEAction(i18n(
"Edit..."),
"edit", 0,
this,
269 TQ_SLOT(slotOpenNode()), actionCollection(),
"node_properties");
270 actionTaskProgress =
new TDEAction(i18n(
"Progress..."),
"edit", 0,
this,
271 TQ_SLOT(slotTaskProgress()), actionCollection(),
"task_progress");
272 actionDeleteTask =
new TDEAction(i18n(
"Delete Task"),
"edit-delete", 0,
this,
273 TQ_SLOT(slotDeleteTask()), actionCollection(),
"delete_task");
275 actionEditResource =
new TDEAction(i18n(
"Edit Resource..."),
"edit", 0,
this,
276 TQ_SLOT(slotEditResource()), actionCollection(),
"edit_resource");
280 actNoInformation =
new TDEAction(
"Toggle no information", CTRL+SHIFT+Key_T,
this, TQ_SLOT(slotViewGanttNoInformation()), actionCollection(),
"show_noinformation");
284 new TDEAction(
"Print Debug", CTRL+SHIFT+Key_P,
this, TQ_SLOT(slotPrintSelectedDebug()), actionCollection(),
"print_debug");
285 new TDEAction(
"Print Calendar Debug", CTRL+SHIFT+Key_C,
this, TQ_SLOT(slotPrintCalendarDebug()), actionCollection(),
"print_calendar_debug");
288 TDEAction* actExportGantt =
new TDEAction( i18n(
"Export Gantt" ), CTRL+SHIFT+Key_G,
289 this, TQ_SLOT( slotExportGantt() ), actionCollection(),
"export_gantt" );
296 Q_UNUSED( actExportGantt );
299 m_estlabel =
new KStatusBarLabel(
"", 0);
300 addStatusBarItem(m_estlabel, 0,
true);
301 actionViewExpected->setChecked(
true);
302 setScheduleActionsEnabled();
305 setTaskActionsEnabled(
false);
311 removeStatusBarItem(m_estlabel);
315DCOPObject * View::dcopObject()
318 m_dcop =
new ViewIface(
this );
324Project& View::getProject()
const
326 return getPart()->getProject();
329void View::setZoom(
double zoom) {
330 m_ganttview->setZoom(zoom);
331 m_pertview->setZoom(zoom);
334void View::setupPrinter(KPrinter &) {
338void View::print(KPrinter &printer) {
340 if (printer.previewOnly()) {
342 if (!printer.setup()) {
346 if (m_tab->visibleWidget() == m_ganttview)
348 m_ganttview->print(printer);
350 else if (m_tab->visibleWidget() == m_pertview)
352 m_pertview->print(printer);
354 else if (m_tab->visibleWidget() == m_resourceview)
356 m_resourceview->print(printer);
358 else if (m_tab->visibleWidget() == m_accountsview)
360 m_accountsview->print(printer);
369void View::slotEditCut() {
373void View::slotEditCopy() {
377void View::slotEditPaste() {
381void View::slotViewExpected() {
383 m_currentEstimateType = Effort::Use_Expected;
384 getProject().setCurrentSchedulePtr(getProject().findSchedule(Schedule::Expected));
388void View::slotViewOptimistic() {
390 m_currentEstimateType = Effort::Use_Optimistic;
391 getProject().setCurrentSchedulePtr(getProject().findSchedule(Schedule::Optimistic));
395void View::slotViewPessimistic() {
397 m_currentEstimateType = Effort::Use_Pessimistic;
398 getProject().setCurrentSchedulePtr(getProject().findSchedule(Schedule::Pessimistic));
402void View::slotViewGanttResources() {
404 m_ganttview->setShowResources(actionViewGanttResources->isChecked());
405 if (m_tab->visibleWidget() == m_ganttview)
409void View::slotViewGanttTaskName() {
411 m_ganttview->setShowTaskName(actionViewGanttTaskName->isChecked());
412 if (m_tab->visibleWidget() == m_ganttview)
416void View::slotViewGanttTaskLinks() {
418 m_ganttview->setShowTaskLinks(actionViewGanttTaskLinks->isChecked());
419 if (m_tab->visibleWidget() == m_ganttview)
423void View::slotViewGanttProgress() {
425 m_ganttview->setShowProgress(actionViewGanttProgress->isChecked());
426 if (m_tab->visibleWidget() == m_ganttview)
430void View::slotViewGanttFloat() {
432 m_ganttview->setShowPositiveFloat(actionViewGanttFloat->isChecked());
433 if (m_tab->visibleWidget() == m_ganttview)
437void View::slotViewGanttCriticalTasks() {
439 m_ganttview->setShowCriticalTasks(actionViewGanttCriticalTasks->isChecked());
440 if (m_tab->visibleWidget() == m_ganttview)
444void View::slotViewGanttCriticalPath() {
446 m_ganttview->setShowCriticalPath(actionViewGanttCriticalPath->isChecked());
447 if (m_tab->visibleWidget() == m_ganttview)
451void View::slotViewGanttNoInformation() {
452 kdDebug()<<k_funcinfo<<m_ganttview->showNoInformation()<<endl;
453 m_ganttview->setShowNoInformation(!m_ganttview->showNoInformation());
454 if (m_tab->visibleWidget() == m_ganttview)
458void View::slotViewTaskAppointments() {
460 m_ganttview->setShowAppointments(actionViewTaskAppointments->isChecked());
461 m_updateGanttview =
true;
462 if (m_tab->visibleWidget() == m_ganttview)
466void View::slotViewGantt() {
468 m_tab->raiseWidget(m_ganttview);
471void View::slotViewPert() {
473 m_tab->raiseWidget(m_pertview);
476void View::slotViewResources() {
478 m_tab->raiseWidget(m_resourceview);
481void View::slotViewResourceAppointments() {
483 m_resourceview->setShowAppointments(actionViewResourceAppointments->isChecked());
484 m_updateResourceview =
true;
485 if (m_tab->visibleWidget() == m_resourceview)
489void View::slotViewAccounts() {
491 m_tab->raiseWidget(m_accountsview);
494void View::slotProjectEdit() {
495 MainProjectDialog *dia =
new MainProjectDialog(getProject());
497 KCommand *cmd = dia->buildCommand(getPart());
499 getPart()->addCommand(cmd);
505void View::slotProjectCalendar() {
506 CalendarListDialog *dia =
new CalendarListDialog(getProject());
508 KCommand *cmd = dia->buildCommand(getPart());
511 getPart()->addCommand(cmd);
517void View::slotProjectAccounts() {
518 AccountsDialog *dia =
new AccountsDialog(getProject().accounts());
520 KCommand *cmd = dia->buildCommand(getPart());
523 getPart()->addCommand(cmd);
529void View::slotProjectWorktime() {
530 StandardWorktimeDialog *dia =
new StandardWorktimeDialog(getProject());
532 KCommand *cmd = dia->buildCommand(getPart());
535 getPart()->addCommand(cmd);
541void View::slotProjectResources() {
542 ResourcesDialog *dia =
new ResourcesDialog(getProject());
544 KCommand *cmd = dia->buildCommand(getPart());
547 getPart()->addCommand(cmd);
553void View::slotProjectCalculate() {
558void View::slotProjectCalculateExpected() {
559 m_currentEstimateType = Effort::Use_Expected;
560 m_updateGanttview =
true;
561 m_updateResourceview =
true;
562 m_updateAccountsview =
true;
566void View::slotProjectCalculateOptimistic() {
567 m_currentEstimateType = Effort::Use_Optimistic;
568 m_updateGanttview =
true;
569 m_updateResourceview =
true;
570 m_updateAccountsview =
true;
574void View::slotProjectCalculatePessimistic() {
575 m_currentEstimateType = Effort::Use_Pessimistic;
576 m_updateGanttview =
true;
577 m_updateResourceview =
true;
578 m_updateAccountsview =
true;
582void View::projectCalculate() {
585 if (KMessageBox::warningContinueCancel(
this, i18n(
"Progress information will be deleted if the project is recalculated."), i18n(
"Calculate"), i18n(
"Calculate")) == KMessageBox::Cancel) {
589 TQApplication::setOverrideCursor(TQt::waitCursor);
590 Schedule *ns = getProject().findSchedule((Schedule::Type)m_currentEstimateType);
593 cmd =
new RecalculateProjectCmd(getPart(), getProject(), *ns, i18n(
"Calculate"));
595 cmd =
new CalculateProjectCmd(getPart(), getProject(), i18n(
"Standard"), (Effort::Use)m_currentEstimateType, i18n(
"Calculate"));
597 getPart()->addCommand(cmd);
598 TQApplication::restoreOverrideCursor();
601void View::slotViewReportDesign() {
605void View::slotViewReports() {
610void View::slotAddSubTask() {
614 Task* node = getProject().createTask(getPart()->config().taskDefaults(), currentTask());
615 TaskDialog *dia =
new TaskDialog(*node, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
617 Node *currNode = currentTask();
620 KCommand *m = dia->buildCommand(getPart());
623 SubtaskAddCmd *cmd =
new SubtaskAddCmd(getPart(), &(getProject()), node, currNode, i18n(
"Add Subtask"));
624 getPart()->addCommand(cmd);
628 kdDebug()<<k_funcinfo<<
"Cannot insert new project. Hmm, no current node!?"<<endl;
635void View::slotAddTask() {
636 Task* node = getProject().createTask(getPart()->config().taskDefaults(), currentTask());
637 TaskDialog *dia =
new TaskDialog(*node, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
639 Node* currNode = currentTask();
642 KCommand *m = dia->buildCommand(getPart());
645 TaskAddCmd *cmd =
new TaskAddCmd(getPart(), &(getProject()), node, currNode, i18n(
"Add Task"));
646 getPart()->addCommand(cmd);
650 kdDebug()<<k_funcinfo<<
"Cannot insert new task. Hmm, no current node!?"<<endl;
656void View::slotAddMilestone() {
657 Task* node = getProject().createTask(currentTask());
658 node->effort()->set(Duration::zeroDuration);
660 TaskDialog *dia =
new TaskDialog(*node, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
662 Node *currNode = currentTask();
665 KCommand *m = dia->buildCommand(getPart());
668 TaskAddCmd *cmd =
new TaskAddCmd(getPart(), &(getProject()), node, currNode, i18n(
"Add Milestone"));
669 getPart()->addCommand(cmd);
673 kdDebug()<<k_funcinfo<<
"Cannot insert new milestone. Hmm, no current node!?"<<endl;
679void View::slotDefineWBS() {
681 WBSDefinitionDialog *dia =
new WBSDefinitionDialog(getPart()->wbsDefinition());
687void View::slotGenerateWBS() {
689 getPart()->generateWBS();
693void View::slotConfigure() {
695 ConfigDialog *dia =
new ConfigDialog(getPart()->config(), getProject());
700Node *View::currentTask()
703 if (m_tab->visibleWidget() == m_ganttview) {
704 task = m_ganttview->currentNode();
706 else if (m_tab->visibleWidget() == m_pertview) {
707 task = m_pertview->currentNode();
709 else if (m_tab->visibleWidget() == m_resourceview) {
710 task = m_resourceview->currentNode();
715 return &(getProject());
718void View::slotOpenNode() {
720 Node *node = currentTask();
724 switch (node->type()) {
725 case Node::Type_Project: {
726 Project *project =
dynamic_cast<Project *
>(node);
727 MainProjectDialog *dia =
new MainProjectDialog(*project);
729 KCommand *m = dia->buildCommand(getPart());
731 getPart()->addCommand(m);
737 case Node::Type_Subproject:
740 case Node::Type_Task: {
741 Task *task =
dynamic_cast<Task *
>(node);
742 TaskDialog *dia =
new TaskDialog(*task, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
744 KCommand *m = dia->buildCommand(getPart());
746 getPart()->addCommand(m);
752 case Node::Type_Milestone: {
757 Task *task =
dynamic_cast<Task *
>(node);
758 TaskDialog *dia =
new TaskDialog(*task, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
760 KCommand *m = dia->buildCommand(getPart());
762 getPart()->addCommand(m);
768 case Node::Type_Summarytask: {
769 Task *task =
dynamic_cast<Task *
>(node);
770 SummaryTaskDialog *dia =
new SummaryTaskDialog(*task);
772 KCommand *m = dia->buildCommand(getPart());
774 getPart()->addCommand(m);
785void View::slotTaskProgress() {
787 Node *node = currentTask();
791 switch (node->type()) {
792 case Node::Type_Project: {
795 case Node::Type_Subproject:
798 case Node::Type_Task: {
799 Task *task =
dynamic_cast<Task *
>(node);
800 TaskProgressDialog *dia =
new TaskProgressDialog(*task, getProject().standardWorktime());
802 KCommand *m = dia->buildCommand(getPart());
804 getPart()->addCommand(m);
810 case Node::Type_Milestone: {
811 Task *task =
dynamic_cast<Task *
>(node);
812 MilestoneProgressDialog *dia =
new MilestoneProgressDialog(*task);
814 KCommand *m = dia->buildCommand(getPart());
816 getPart()->addCommand(m);
822 case Node::Type_Summarytask: {
831void View::slotDeleteTask()
834 Node *node = currentTask();
835 if (node == 0 || node->getParent() == 0) {
836 kdDebug()<<k_funcinfo<<(node ?
"Task is main project" :
"No current task")<<endl;
839 KMacroCommand *cmd =
new KMacroCommand(i18n(
"Delete Task"));
840 cmd->addCommand(
new NodeDeleteCmd(getPart(), node));
841 TQPtrListIterator<Relation> it = node->dependChildNodes();
842 for (; it.current(); ++it) {
843 cmd->addCommand(
new DeleteRelationCmd(getPart(), it.current()));
845 it = node->dependParentNodes();
846 for (; it.current(); ++it) {
847 cmd->addCommand(
new DeleteRelationCmd(getPart(),it.current()));
849 getPart()->addCommand(cmd);
852void View::slotIndentTask()
855 Node *node = currentTask();
856 if (node == 0 || node->getParent() == 0) {
857 kdDebug()<<k_funcinfo<<(node ?
"Task is main project" :
"No current task")<<endl;
860 if (getProject().canIndentTask(node)) {
861 NodeIndentCmd *cmd =
new NodeIndentCmd(getPart(), *node, i18n(
"Indent Task"));
862 getPart()->addCommand(cmd);
866void View::slotUnindentTask()
869 Node *node = currentTask();
870 if (node == 0 || node->getParent() == 0) {
871 kdDebug()<<k_funcinfo<<(node ?
"Task is main project" :
"No current task")<<endl;
874 if (getProject().canUnindentTask(node)) {
875 NodeUnindentCmd *cmd =
new NodeUnindentCmd(getPart(), *node, i18n(
"Unindent Task"));
876 getPart()->addCommand(cmd);
880void View::slotMoveTaskUp()
884 Node* task = currentTask();
888 kdError()<<k_funcinfo<<
"No current task"<<endl;
892 if ( Node::Type_Project == task->type() ) {
893 kdDebug()<<k_funcinfo<<
"The root node cannot be moved up"<<endl;
896 if (getProject().canMoveTaskUp(task)) {
897 NodeMoveUpCmd *cmd =
new NodeMoveUpCmd(getPart(), *task, i18n(
"Move Task Up"));
898 getPart()->addCommand(cmd);
902void View::slotMoveTaskDown()
906 Node* task = currentTask();
913 if ( Node::Type_Project == task->type() ) {
914 kdDebug()<<k_funcinfo<<
"The root node cannot be moved down"<<endl;
917 if (getProject().canMoveTaskDown(task)) {
918 NodeMoveDownCmd *cmd =
new NodeMoveDownCmd(getPart(), *task, i18n(
"Move Task Down"));
919 getPart()->addCommand(cmd);
923void View::slotAddRelation(Node *par, Node *child) {
925 Relation *rel =
new Relation(par, child);
926 AddRelationDialog *dia =
new AddRelationDialog(rel,
this);
928 KCommand *cmd = dia->buildCommand(getPart());
930 getPart()->addCommand(cmd);
937void View::slotAddRelation(Node *par, Node *child,
int linkType) {
939 if (linkType == Relation::FinishStart ||
940 linkType == Relation::StartStart ||
941 linkType == Relation::FinishFinish)
943 Relation *rel =
new Relation(par, child,
static_cast<Relation::Type
>(linkType));
944 getPart()->addCommand(
new AddRelationCmd(getPart(), rel, i18n(
"Add Relation")));
946 slotAddRelation(par, child);
950void View::slotModifyRelation(Relation *rel) {
952 ModifyRelationDialog *dia =
new ModifyRelationDialog(rel,
this);
954 if (dia->relationIsDeleted()) {
955 getPart()->addCommand(
new DeleteRelationCmd(getPart(), rel, i18n(
"Delete Relation")));
957 KCommand *cmd = dia->buildCommand(getPart());
959 getPart()->addCommand(cmd);
966void View::slotModifyRelation(Relation *rel,
int linkType) {
968 if (linkType == Relation::FinishStart ||
969 linkType == Relation::StartStart ||
970 linkType == Relation::FinishFinish)
972 getPart()->addCommand(
new ModifyRelationTypeCmd(getPart(), rel,
static_cast<Relation::Type
>(linkType)));
974 slotModifyRelation(rel);
979void View::slotExportGantt() {
984 TQString fn = KFileDialog::getSaveFileName( TQString(), TQString(),
this );
987 m_ganttview->exportGantt(&f);
991void View::slotEditResource() {
993 Resource *r = m_resourceview->currentResource();
996 ResourceDialog *dia =
new ResourceDialog(getProject(), r);
998 KCommand *cmd = dia->buildCommand(getPart());
1000 getPart()->addCommand(cmd);
1005void View::updateReadWrite(
bool ) {
1008Part *View::getPart()
const {
1009 return (Part *)koDocument();
1012void View::slotConnectNode() {
1020TQPopupMenu * View::popupMenu(
const TQString& name )
1023 Q_ASSERT(factory());
1025 return ((TQPopupMenu*)factory()->container( name,
this ));
1029void View::slotChanged(TQWidget *)
1035void View::slotChanged()
1041void View::slotUpdate(
bool calculate)
1047 m_updateGanttview =
true;
1048 m_updateResourceview =
true;
1049 m_updateAccountsview =
true;
1051 updateView(m_tab->visibleWidget());
1054void View::slotAboutToShow(TQWidget *widget) {
1058void View::updateView(TQWidget *widget)
1060 TQApplication::setOverrideCursor(TQt::waitCursor);
1061 setScheduleActionsEnabled();
1062 setTaskActionsEnabled(
false);
1063 mainWindow()->toolBar(
"report")->hide();
1064 if (widget == m_ganttview)
1067 m_ganttview->setShowExpected(actionViewExpected->isChecked());
1068 m_ganttview->setShowOptimistic(actionViewOptimistic->isChecked());
1069 m_ganttview->setShowPessimistic(actionViewPessimistic->isChecked());
1070 if (m_updateGanttview)
1071 m_ganttview->drawChanges(getProject());
1072 setTaskActionsEnabled(widget,
true);
1073 m_updateGanttview =
false;
1075 else if (widget == m_pertview)
1080 else if (widget == m_resourceview)
1083 if (m_updateResourceview)
1084 m_resourceview->draw(getPart()->getProject());
1085 m_updateResourceview =
false;
1087 else if (widget == m_accountsview)
1090 if (m_updateAccountsview)
1091 m_accountsview->draw();
1092 m_updateAccountsview =
false;
1099 TQApplication::restoreOverrideCursor();
1102void View::slotRenameNode(Node *node,
const TQString& name) {
1105 NodeModifyNameCmd *cmd =
new NodeModifyNameCmd(getPart(), *node, name, i18n(
"Modify Name"));
1106 getPart()->addCommand(cmd);
1110void View::slotPopupMenu(
const TQString& menuname,
const TQPoint & pos)
1112 TQPopupMenu* menu = this->popupMenu(menuname);
1117bool View::setContext(Context &context) {
1119 m_currentEstimateType = context.currentEstimateType;
1120 getProject().setCurrentSchedule(context.currentSchedule);
1121 actionViewExpected->setChecked(context.actionViewExpected);
1122 actionViewOptimistic->setChecked(context.actionViewOptimistic);
1123 actionViewPessimistic->setChecked(context.actionViewPessimistic);
1125 m_ganttview->setContext(context.ganttview, getProject());
1127 actionViewGanttResources->setChecked(context.ganttview.showResources);
1128 actionViewGanttTaskName->setChecked(context.ganttview.showTaskName);
1129 actionViewGanttTaskLinks->setChecked(context.ganttview.showTaskLinks);
1130 actionViewGanttProgress->setChecked(context.ganttview.showProgress);
1131 actionViewGanttFloat->setChecked(context.ganttview.showPositiveFloat);
1132 actionViewGanttCriticalTasks->setChecked(context.ganttview.showCriticalTasks);
1133 actionViewGanttCriticalPath->setChecked(context.ganttview.showCriticalPath);
1135 m_pertview->setContext(context.pertview);
1136 m_resourceview->setContext(context.resourceview);
1137 m_accountsview->setContext(context.accountsview);
1140 if (context.currentView ==
"ganttview") {
1141 m_ganttview->setShowExpected(actionViewExpected->isChecked());
1142 m_ganttview->setShowOptimistic(actionViewOptimistic->isChecked());
1143 m_ganttview->setShowPessimistic(actionViewPessimistic->isChecked());
1145 }
else if (context.currentView ==
"pertview") {
1147 }
else if (context.currentView ==
"resourceview") {
1148 slotViewResources();
1149 }
else if (context.currentView ==
"accountsview") {
1151 }
else if (context.currentView ==
"reportview") {
1160void View::getContext(Context &context)
const {
1162 context.currentEstimateType = m_currentEstimateType;
1163 if (getProject().currentSchedule())
1164 context.currentSchedule = getProject().currentSchedule()->id();
1165 context.actionViewExpected = actionViewExpected->isChecked();
1166 context.actionViewOptimistic = actionViewOptimistic->isChecked();
1167 context.actionViewPessimistic = actionViewPessimistic->isChecked();
1169 if (m_tab->visibleWidget() == m_ganttview) {
1170 context.currentView =
"ganttview";
1171 }
else if (m_tab->visibleWidget() == m_pertview) {
1172 context.currentView =
"pertview";
1173 }
else if (m_tab->visibleWidget() == m_resourceview) {
1174 context.currentView =
"resourceview";
1175 }
else if (m_tab->visibleWidget() == m_accountsview) {
1176 context.currentView =
"accountsview";
1180 m_ganttview->getContext(context.ganttview);
1181 m_pertview->getContext(context.pertview);
1182 m_resourceview->getContext(context.resourceview);
1183 m_accountsview->getContext(context.accountsview);
1187void View::setBaselineMode(
bool ) {
1216void View::setTaskActionsEnabled(TQWidget *w,
bool on) {
1218 if (w == m_ganttview) {
1219 n = m_ganttview->currentNode();
1222 actionAddTask->setEnabled(on);
1223 actionAddMilestone->setEnabled(on);
1226 actionAddSubtask->setEnabled(o);
1227 actionDeleteTask->setEnabled(o);
1228 actionMoveTaskUp->setEnabled(o && getProject().canMoveTaskUp(n));
1229 actionMoveTaskDown->setEnabled(o && getProject().canMoveTaskDown(n));
1230 actionIndentTask->setEnabled(o && getProject().canIndentTask(n));
1231 actionUnindentTask->setEnabled(o && getProject().canUnindentTask(n));
1234void View::setTaskActionsEnabled(
bool on) {
1235 setTaskActionsEnabled(m_ganttview, on);
1238void View::setScheduleActionsEnabled() {
1239 actionViewExpected->setEnabled(getProject().findSchedule(Schedule::Expected));
1240 actionViewOptimistic->setEnabled(getProject().findSchedule(Schedule::Optimistic));
1241 actionViewPessimistic->setEnabled(getProject().findSchedule(Schedule::Pessimistic));
1242 if (getProject().notScheduled()) {
1243 m_estlabel->setText(i18n(
"Not scheduled"));
1246 Schedule *ns = getProject().currentSchedule();
1247 if (ns->type() == Schedule::Expected) {
1248 actionViewExpected->setChecked(
true);
1249 m_estlabel->setText(i18n(
"Expected"));
1250 }
else if (ns->type() == Schedule::Optimistic) {
1251 actionViewOptimistic->setChecked(
true);
1252 m_estlabel->setText(i18n(
"Optimistic"));
1253 }
else if (ns->type() == Schedule::Pessimistic) {
1254 actionViewPessimistic->setChecked(
true);
1255 m_estlabel->setText(i18n(
"Pessimistic"));
1261void View::slotPrintDebug() {
1262 kdDebug()<<
"-------- Debug printout: Node list" <<endl;
1267 getPart()->getProject().printDebug(
true,
"");
1269void View::slotPrintSelectedDebug() {
1270 Node *curr = m_ganttview->currentNode();
1272 kdDebug()<<
"-------- Debug printout: Selected node" <<endl;
1273 curr->printDebug(
true,
"");
1277void View::slotPrintCalendarDebug() {
1278 kdDebug()<<
"-------- Debug printout: Node list" <<endl;
1283 getPart()->getProject().printCalendarDebug(
"");
1285void View::slotPrintTestDebug() {
1286 const TQStringList &lst = getPart()->xmlLoader().log();
1288 for ( TQStringList::ConstIterator it = lst.constBegin(); it != lst.constEnd(); ++it ) {
1289 kdDebug()<<*it<<endl;
1518#include "kptview.moc"
Any Node will store how much time it takes to complete the node (typically a Task) in the traditional...