KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kptview.cc 56KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519
  1. /* This file is part of the KDE project
  2. Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org>
  3. Copyright (C) 2002 - 2005 Dag Andersen <danders@get2net.dk>
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. * Boston, MA 02110-1301, USA.
  16. */
  17. #include <kprinter.h>
  18. #include <kmessagebox.h>
  19. #include <KoMainWindow.h>
  20. #include <tqapplication.h>
  21. #include <tqpainter.h>
  22. #include <tqiconset.h>
  23. #include <tqlayout.h>
  24. #include <tqsplitter.h>
  25. #include <tqcanvas.h>
  26. #include <tqscrollview.h>
  27. #include <tqcolor.h>
  28. #include <tqlabel.h>
  29. #include <tqstring.h>
  30. #include <tqstringlist.h>
  31. #include <tqvbox.h>
  32. #include <tqgrid.h>
  33. #include <tqsize.h>
  34. #include <tqheader.h>
  35. #include <tqtabwidget.h>
  36. #include <tqwidgetstack.h>
  37. #include <tqtimer.h>
  38. #include <tqpopupmenu.h>
  39. #include <tqpair.h>
  40. #include <kiconloader.h>
  41. #include <kaction.h>
  42. #include <kstdaction.h>
  43. #include <klocale.h>
  44. #include <kdebug.h>
  45. #include <klistview.h>
  46. #include <kstdaccel.h>
  47. #include <kaccelgen.h>
  48. #include <tdeversion.h>
  49. #include <kstatusbar.h>
  50. #include <kxmlguifactory.h>
  51. #include <kstandarddirs.h>
  52. #include <kdesktopfile.h>
  53. #include <kcommand.h>
  54. #include <tdefiledialog.h>
  55. #include "kptview.h"
  56. #include "kptaccountsview.h"
  57. #include "kptfactory.h"
  58. #include "kptmilestoneprogressdialog.h"
  59. #include "kptnode.h"
  60. #include "kptpart.h"
  61. #include "kptproject.h"
  62. #include "kptmainprojectdialog.h"
  63. #include "kptprojectdialog.h"
  64. #include "kpttask.h"
  65. #include "kptsummarytaskdialog.h"
  66. #include "kpttaskdialog.h"
  67. #include "kpttaskprogressdialog.h"
  68. #include "kptganttview.h"
  69. #include "kptpertview.h"
  70. //#include "kptreportview.h"
  71. #include "kptdatetime.h"
  72. #include "kptcommand.h"
  73. #include "kptrelation.h"
  74. #include "kptrelationdialog.h"
  75. #include "kptresourceview.h"
  76. #include "kptresourcedialog.h"
  77. #include "kptresource.h"
  78. #include "kptresourcesdialog.h"
  79. #include "kptcalendarlistdialog.h"
  80. #include "kptstandardworktimedialog.h"
  81. #include "kptcanvasitem.h"
  82. #include "kptconfigdialog.h"
  83. #include "kptwbsdefinitiondialog.h"
  84. #include "kptaccountsdialog.h"
  85. #include "KDGanttView.h"
  86. #include "KDGanttViewTaskItem.h"
  87. #include "KPtViewIface.h"
  88. namespace KPlato
  89. {
  90. View::View(Part* part, TQWidget* parent, const char* /*name*/)
  91. : KoView(part, parent, "Main View"),
  92. m_ganttview(0),
  93. m_ganttlayout(0),
  94. m_pertview(0),
  95. m_pertlayout(0),
  96. // m_reportview(0),
  97. m_baselineMode(false),
  98. m_currentEstimateType(Effort::Use_Expected)
  99. {
  100. //kdDebug()<<k_funcinfo<<endl;
  101. getProject().setCurrentSchedule(Schedule::Expected);
  102. setInstance(Factory::global());
  103. if ( !part->isReadWrite() )
  104. setXMLFile("kplato_readonly.rc");
  105. else
  106. setXMLFile("kplato.rc");
  107. m_dcop = 0L;
  108. // build the DCOP object
  109. dcopObject();
  110. m_tab = new TQWidgetStack(this);
  111. TQVBoxLayout *layout = new TQVBoxLayout(this);
  112. layout->add(m_tab);
  113. m_ganttview = new GanttView(m_tab, part->isReadWrite());
  114. m_tab->addWidget(m_ganttview);
  115. m_updateGanttview = false;
  116. m_ganttview->draw(getPart()->getProject());
  117. m_pertview = new PertView( this, m_tab, layout );
  118. m_tab->addWidget(m_pertview);
  119. m_resourceview = new ResourceView( this, m_tab );
  120. m_updateResourceview = true;
  121. m_tab->addWidget(m_resourceview);
  122. m_accountsview = new AccountsView( getProject(), this, m_tab );
  123. m_updateAccountsview = true;
  124. m_tab->addWidget(m_accountsview);
  125. //m_reportview = new ReportView(this, m_tab);
  126. //m_tab->addWidget(m_reportview);
  127. connect(m_tab, TQT_SIGNAL(aboutToShow(TQWidget *)), TQT_TQOBJECT(this), TQT_SLOT(slotAboutToShow(TQWidget *)));
  128. connect(m_pertview, TQT_SIGNAL(addRelation(Node*, Node*)), TQT_SLOT(slotAddRelation(Node*, Node*)));
  129. connect(m_pertview, TQT_SIGNAL(modifyRelation(Relation*)), TQT_SLOT(slotModifyRelation(Relation*)));
  130. connect(m_ganttview, TQT_SIGNAL(enableActions(bool)), TQT_SLOT(setTaskActionsEnabled(bool)));
  131. connect(m_ganttview, TQT_SIGNAL(addRelation(Node*, Node*, int)), TQT_SLOT(slotAddRelation(Node*, Node*, int)));
  132. connect(m_ganttview, TQT_SIGNAL(modifyRelation(Relation*, int)), TQT_SLOT(slotModifyRelation(Relation*, int)));
  133. connect(m_ganttview, TQT_SIGNAL(modifyRelation(Relation*)), TQT_SLOT(slotModifyRelation(Relation*)));
  134. connect(m_ganttview, TQT_SIGNAL(itemDoubleClicked()), TQT_SLOT(slotOpenNode()));
  135. connect(m_ganttview, TQT_SIGNAL(itemRenamed(Node*, const TQString&)),TQT_TQOBJECT(this), TQT_SLOT(slotRenameNode(Node*, const TQString&)));
  136. connect(m_ganttview, TQT_SIGNAL(requestPopupMenu(const TQString&, const TQPoint &)),TQT_TQOBJECT(this), TQT_SLOT(slotPopupMenu(const TQString&, const TQPoint&)));
  137. connect(m_resourceview, TQT_SIGNAL(itemDoubleClicked()), TQT_SLOT(slotEditResource()));
  138. // The menu items
  139. // ------ Edit
  140. actionCut = KStdAction::cut( TQT_TQOBJECT(this), TQT_SLOT( slotEditCut() ), actionCollection(), "edit_cut" );
  141. actionCopy = KStdAction::copy( TQT_TQOBJECT(this), TQT_SLOT( slotEditCopy() ), actionCollection(), "edit_copy" );
  142. actionPaste = KStdAction::paste( TQT_TQOBJECT(this), TQT_SLOT( slotEditPaste() ), actionCollection(), "edit_paste" );
  143. actionIndentTask = new KAction(i18n("Indent Task"), "indent_task", 0, TQT_TQOBJECT(this),
  144. TQT_SLOT(slotIndentTask()), actionCollection(), "indent_task");
  145. actionUnindentTask = new KAction(i18n("Unindent Task"), "unindent_task", 0, TQT_TQOBJECT(this),
  146. TQT_SLOT(slotUnindentTask()), actionCollection(), "unindent_task");
  147. actionMoveTaskUp = new KAction(i18n("Move Up"), "move_task_up", 0, TQT_TQOBJECT(this),
  148. TQT_SLOT(slotMoveTaskUp()), actionCollection(), "move_task_up");
  149. actionMoveTaskDown = new KAction(i18n("Move Down"), "move_task_down", 0, TQT_TQOBJECT(this),
  150. TQT_SLOT(slotMoveTaskDown()), actionCollection(), "move_task_down");
  151. // ------ View
  152. actionViewGantt = new KAction(i18n("Gantt"), "gantt_chart", 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGantt()), actionCollection(), "view_gantt");
  153. TQString group = "EstimationType";
  154. actionViewExpected = new KRadioAction(i18n("Expected"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewExpected()), actionCollection(), "view_expected");
  155. actionViewExpected->setExclusiveGroup(group);
  156. actionViewOptimistic = new KRadioAction(i18n("Optimistic"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewOptimistic()), actionCollection(), "view_optimistic");
  157. actionViewOptimistic->setExclusiveGroup(group);
  158. actionViewPessimistic = new KRadioAction(i18n("Pessimistic"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewPessimistic()), actionCollection(), "view_pessimistic");
  159. actionViewPessimistic->setExclusiveGroup(group);
  160. actionViewGanttResources = new KToggleAction(i18n("Resources"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttResources()), actionCollection(), "view_gantt_showResources");
  161. actionViewGanttTaskName = new KToggleAction(i18n("Task Name"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttTaskName()), actionCollection(), "view_gantt_showTaskName");
  162. actionViewGanttTaskLinks = new KToggleAction(i18n("Task Links"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttTaskLinks()), actionCollection(), "view_gantt_showTaskLinks");
  163. actionViewGanttProgress = new KToggleAction(i18n("Progress"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttProgress()), actionCollection(), "view_gantt_showProgress");
  164. actionViewGanttFloat = new KToggleAction(i18n("Float"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttFloat()), actionCollection(), "view_gantt_showFloat");
  165. actionViewGanttCriticalTasks = new KToggleAction(i18n("Critical Tasks"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttCriticalTasks()), actionCollection(), "view_gantt_showCriticalTasks");
  166. actionViewGanttCriticalPath = new KToggleAction(i18n("Critical Path"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttCriticalPath()), actionCollection(), "view_gantt_showCriticalPath");
  167. // actionViewGanttNotScheduled = new KToggleAction(i18n("Not Scheduled"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttNotScheduled()), actionCollection(), "view_gantt_showNotScheduled");
  168. actionViewTaskAppointments = new KToggleAction(i18n("Show Allocations"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewTaskAppointments()), actionCollection(), "view_task_appointments");
  169. actionViewPert = new KAction(i18n("Network"), "pert_chart", 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewPert()), actionCollection(), "view_pert");
  170. actionViewResources = new KAction(i18n("Resources"), "resources", 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewResources()), actionCollection(), "view_resources");
  171. actionViewResourceAppointments = new KToggleAction(i18n("Show Allocations"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewResourceAppointments()), actionCollection(), "view_resource_appointments");
  172. actionViewAccounts = new KAction(i18n("Accounts"), "accounts", 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewAccounts()), actionCollection(), "view_accounts");
  173. //actionViewReports = new KAction(i18n("Reports"), "reports", 0, TQT_TQOBJECT(this), TQT_SLOT(slotViewReports()), actionCollection(), "view_reports");
  174. // ------ Insert
  175. actionAddTask = new KAction(i18n("Task..."), "add_task", 0, TQT_TQOBJECT(this),
  176. TQT_SLOT(slotAddTask()), actionCollection(), "add_task");
  177. actionAddSubtask = new KAction(i18n("Sub-Task..."), "add_sub_task", 0, TQT_TQOBJECT(this),
  178. TQT_SLOT(slotAddSubTask()), actionCollection(), "add_sub_task");
  179. actionAddMilestone = new KAction(i18n("Milestone..."), "add_milestone", 0, TQT_TQOBJECT(this),
  180. TQT_SLOT(slotAddMilestone()), actionCollection(), "add_milestone");
  181. // ------ Project
  182. actionEditMainProject = new KAction(i18n("Edit Main Project..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectEdit()), actionCollection(), "project_edit");
  183. actionEditStandardWorktime = new KAction(i18n("Edit Standard Worktime..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectWorktime()), actionCollection(), "project_worktime");
  184. actionEditCalendar = new KAction(i18n("Edit Calendar..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectCalendar()), actionCollection(), "project_calendar");
  185. actionEditAccounts = new KAction(i18n("Edit Accounts..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectAccounts()), actionCollection(), "project_accounts");
  186. actionEditResources = new KAction(i18n("Edit Resources..."), "edit", 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectResources()), actionCollection(), "project_resources");
  187. actionCalculate = new KActionMenu(i18n("Calculate"), "project_calculate", actionCollection(), "project_calculate");
  188. connect(actionCalculate, TQT_SIGNAL(activated()), TQT_SLOT(slotProjectCalculate()));
  189. actionCalculateExpected = new KAction(i18n("Expected"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectCalculateExpected()), actionCollection(), "project_calculate_expected");
  190. actionCalculate->insert(actionCalculateExpected);
  191. actionCalculateOptimistic = new KAction(i18n("Optimistic"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectCalculateOptimistic()), actionCollection(), "project_calculate_optimistic");
  192. actionCalculate->insert(actionCalculateOptimistic);
  193. actionCalculatePessimistic = new KAction(i18n("Pessimistic"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotProjectCalculatePessimistic()), actionCollection(), "project_calculate_pessimistic");
  194. actionCalculate->insert(actionCalculatePessimistic);
  195. /* // ------ Reports
  196. actionFirstpage = KStdAction::firstPage(m_reportview,TQT_SLOT(slotPrevPage()),actionCollection(),"go_firstpage");
  197. connect(m_reportview, TQT_SIGNAL(setFirstPageActionEnabled(bool)), actionFirstpage, TQT_SLOT(setEnabled(bool)));
  198. actionPriorpage = KStdAction::prior(m_reportview,TQT_SLOT(slotPrevPage()),actionCollection(),"go_prevpage");
  199. connect(m_reportview, TQT_SIGNAL(setPriorPageActionEnabled(bool)), actionPriorpage, TQT_SLOT(setEnabled(bool)));
  200. actionNextpage = KStdAction::next(m_reportview,TQT_SLOT(slotNextPage()),actionCollection(), "go_nextpage");
  201. connect(m_reportview, TQT_SIGNAL(setNextPageActionEnabled(bool)), actionNextpage, TQT_SLOT(setEnabled(bool)));
  202. actionLastpage = KStdAction::lastPage(m_reportview,TQT_SLOT(slotLastPage()),actionCollection(), "go_lastpage");
  203. connect(m_reportview, TQT_SIGNAL(setLastPageActionEnabled(bool)), actionLastpage, TQT_SLOT(setEnabled(bool)));
  204. m_reportview->enableNavigationBtn();*/
  205. mainWindow()->toolBar("report")->hide();
  206. // new KAction(i18n("Design..."), "report_design", 0, TQT_TQOBJECT(this),
  207. // TQT_SLOT(slotReportDesign()), actionCollection(), "report_design");
  208. // ------ Tools
  209. actionDefineWBS =
  210. new KAction(i18n("Define WBS Pattern..."), "tools_define_wbs", 0, TQT_TQOBJECT(this),
  211. TQT_SLOT(slotDefineWBS()), actionCollection(), "tools_generate_wbs");
  212. actionGenerateWBS =
  213. new KAction(i18n("Generate WBS Code"), "tools_generate_wbs", 0, TQT_TQOBJECT(this),
  214. TQT_SLOT(slotGenerateWBS()), actionCollection(), "tools_define_wbs");
  215. // ------ Export (testing)
  216. //actionExportGantt = new KAction(i18n("Export Ganttview"), "export_gantt", 0, TQT_TQOBJECT(this),
  217. // TQT_SLOT(slotExportGantt()), actionCollection(), "export_gantt");
  218. // ------ Settings
  219. actionConfigure = new KAction(i18n("Configure KPlato..."), "configure", 0, TQT_TQOBJECT(this),
  220. TQT_SLOT(slotConfigure()), actionCollection(), "configure");
  221. // ------ Popup
  222. actionOpenNode = new KAction(i18n("Edit..."), "edit", 0, TQT_TQOBJECT(this),
  223. TQT_SLOT(slotOpenNode()), actionCollection(), "node_properties");
  224. actionTaskProgress = new KAction(i18n("Progress..."), "edit", 0, TQT_TQOBJECT(this),
  225. TQT_SLOT(slotTaskProgress()), actionCollection(), "task_progress");
  226. actionDeleteTask = new KAction(i18n("Delete Task"), "editdelete", 0, TQT_TQOBJECT(this),
  227. TQT_SLOT(slotDeleteTask()), actionCollection(), "delete_task");
  228. actionEditResource = new KAction(i18n("Edit Resource..."), "edit", 0, TQT_TQOBJECT(this),
  229. TQT_SLOT(slotEditResource()), actionCollection(), "edit_resource");
  230. // ------------------- Actions with a key binding and no GUI item
  231. // Temporary, till we get a menu entry
  232. actNoInformation = new KAction("Toggle no information", CTRL+SHIFT+Key_T, TQT_TQOBJECT(this), TQT_SLOT(slotViewGanttNoInformation()), actionCollection(), "show_noinformation");
  233. #ifndef NDEBUG
  234. //new KAction("Print Debug", CTRL+SHIFT+Key_P, TQT_TQOBJECT(this), TQT_SLOT( slotPrintDebug()), actionCollection(), "print_debug");
  235. new KAction("Print Debug", CTRL+SHIFT+Key_P, TQT_TQOBJECT(this), TQT_SLOT(slotPrintSelectedDebug()), actionCollection(), "print_debug");
  236. new KAction("Print Calendar Debug", CTRL+SHIFT+Key_C, TQT_TQOBJECT(this), TQT_SLOT(slotPrintCalendarDebug()), actionCollection(), "print_calendar_debug");
  237. // new KAction("Print Test Debug", CTRL+SHIFT+Key_T, TQT_TQOBJECT(this), TQT_SLOT(slotPrintTestDebug()), actionCollection(), "print_test_debug");
  238. KAction* actExportGantt = new KAction( i18n( "Export Gantt" ), CTRL+SHIFT+Key_G,
  239. TQT_TQOBJECT(this), TQT_SLOT( slotExportGantt() ), actionCollection(), "export_gantt" );
  240. #endif
  241. // Stupid compilers ;)
  242. #ifndef NDEBUG
  243. /* Q_UNUSED( actPrintSelectedDebug );
  244. Q_UNUSED( actPrintCalendarDebug );*/
  245. Q_UNUSED( actExportGantt );
  246. #endif
  247. m_estlabel = new KStatusBarLabel("", 0);
  248. addStatusBarItem(m_estlabel, 0, true);
  249. actionViewExpected->setChecked(true); //TODO: context
  250. setScheduleActionsEnabled();
  251. slotViewExpected();
  252. setTaskActionsEnabled(false);
  253. }
  254. View::~View()
  255. {
  256. delete m_dcop;
  257. removeStatusBarItem(m_estlabel);
  258. delete m_estlabel;
  259. }
  260. DCOPObject * View::dcopObject()
  261. {
  262. if ( !m_dcop )
  263. m_dcop = new ViewIface( this );
  264. return m_dcop;
  265. }
  266. Project& View::getProject() const
  267. {
  268. return getPart()->getProject();
  269. }
  270. void View::setZoom(double zoom) {
  271. m_ganttview->setZoom(zoom);
  272. m_pertview->setZoom(zoom);
  273. }
  274. void View::setupPrinter(KPrinter &/*printer*/) {
  275. //kdDebug()<<k_funcinfo<<endl;
  276. }
  277. void View::print(KPrinter &printer) {
  278. //kdDebug()<<k_funcinfo<<endl;
  279. if (printer.previewOnly()) {
  280. //HACK: KoMainWindow shows setup on print, but not on print preview!
  281. if (!printer.setup()) {
  282. return;
  283. }
  284. }
  285. if (m_tab->visibleWidget() == m_ganttview)
  286. {
  287. m_ganttview->print(printer);
  288. }
  289. else if (m_tab->visibleWidget() == m_pertview)
  290. {
  291. m_pertview->print(printer);
  292. }
  293. else if (m_tab->visibleWidget() == m_resourceview)
  294. {
  295. m_resourceview->print(printer);
  296. }
  297. else if (m_tab->visibleWidget() == m_accountsview)
  298. {
  299. m_accountsview->print(printer);
  300. }
  301. // else if (m_tab->visibleWidget() == m_reportview)
  302. // {
  303. // m_reportview->print(printer);
  304. // }
  305. }
  306. void View::slotEditCut() {
  307. //kdDebug()<<k_funcinfo<<endl;
  308. }
  309. void View::slotEditCopy() {
  310. //kdDebug()<<k_funcinfo<<endl;
  311. }
  312. void View::slotEditPaste() {
  313. //kdDebug()<<k_funcinfo<<endl;
  314. }
  315. void View::slotViewExpected() {
  316. //kdDebug()<<k_funcinfo<<endl;
  317. m_currentEstimateType = Effort::Use_Expected;
  318. getProject().setCurrentSchedulePtr(getProject().findSchedule(Schedule::Expected));
  319. slotUpdate(false);
  320. }
  321. void View::slotViewOptimistic() {
  322. //kdDebug()<<k_funcinfo<<endl;
  323. m_currentEstimateType = Effort::Use_Optimistic;
  324. getProject().setCurrentSchedulePtr(getProject().findSchedule(Schedule::Optimistic));
  325. slotUpdate(false);
  326. }
  327. void View::slotViewPessimistic() {
  328. //kdDebug()<<k_funcinfo<<endl;
  329. m_currentEstimateType = Effort::Use_Pessimistic;
  330. getProject().setCurrentSchedulePtr(getProject().findSchedule(Schedule::Pessimistic));
  331. slotUpdate(false);
  332. }
  333. void View::slotViewGanttResources() {
  334. //kdDebug()<<k_funcinfo<<endl;
  335. m_ganttview->setShowResources(actionViewGanttResources->isChecked());
  336. if (m_tab->visibleWidget() == m_ganttview)
  337. slotUpdate(false);
  338. }
  339. void View::slotViewGanttTaskName() {
  340. //kdDebug()<<k_funcinfo<<endl;
  341. m_ganttview->setShowTaskName(actionViewGanttTaskName->isChecked());
  342. if (m_tab->visibleWidget() == m_ganttview)
  343. slotUpdate(false);
  344. }
  345. void View::slotViewGanttTaskLinks() {
  346. //kdDebug()<<k_funcinfo<<endl;
  347. m_ganttview->setShowTaskLinks(actionViewGanttTaskLinks->isChecked());
  348. if (m_tab->visibleWidget() == m_ganttview)
  349. slotUpdate(false);
  350. }
  351. void View::slotViewGanttProgress() {
  352. //kdDebug()<<k_funcinfo<<endl;
  353. m_ganttview->setShowProgress(actionViewGanttProgress->isChecked());
  354. if (m_tab->visibleWidget() == m_ganttview)
  355. slotUpdate(false);
  356. }
  357. void View::slotViewGanttFloat() {
  358. //kdDebug()<<k_funcinfo<<endl;
  359. m_ganttview->setShowPositiveFloat(actionViewGanttFloat->isChecked());
  360. if (m_tab->visibleWidget() == m_ganttview)
  361. slotUpdate(false);
  362. }
  363. void View::slotViewGanttCriticalTasks() {
  364. //kdDebug()<<k_funcinfo<<endl;
  365. m_ganttview->setShowCriticalTasks(actionViewGanttCriticalTasks->isChecked());
  366. if (m_tab->visibleWidget() == m_ganttview)
  367. slotUpdate(false);
  368. }
  369. void View::slotViewGanttCriticalPath() {
  370. //kdDebug()<<k_funcinfo<<endl;
  371. m_ganttview->setShowCriticalPath(actionViewGanttCriticalPath->isChecked());
  372. if (m_tab->visibleWidget() == m_ganttview)
  373. slotUpdate(false);
  374. }
  375. void View::slotViewGanttNoInformation() {
  376. kdDebug()<<k_funcinfo<<m_ganttview->showNoInformation()<<endl;
  377. m_ganttview->setShowNoInformation(!m_ganttview->showNoInformation()); //Toggle
  378. if (m_tab->visibleWidget() == m_ganttview)
  379. slotUpdate(false);
  380. }
  381. void View::slotViewTaskAppointments() {
  382. //kdDebug()<<k_funcinfo<<endl;
  383. m_ganttview->setShowAppointments(actionViewTaskAppointments->isChecked());
  384. m_updateGanttview = true;
  385. if (m_tab->visibleWidget() == m_ganttview)
  386. slotUpdate(false);
  387. }
  388. void View::slotViewGantt() {
  389. //kdDebug()<<k_funcinfo<<endl;
  390. m_tab->raiseWidget(m_ganttview);
  391. }
  392. void View::slotViewPert() {
  393. //kdDebug()<<k_funcinfo<<endl;
  394. m_tab->raiseWidget(m_pertview);
  395. }
  396. void View::slotViewResources() {
  397. //kdDebug()<<k_funcinfo<<endl;
  398. m_tab->raiseWidget(m_resourceview);
  399. }
  400. void View::slotViewResourceAppointments() {
  401. //kdDebug()<<k_funcinfo<<endl;
  402. m_resourceview->setShowAppointments(actionViewResourceAppointments->isChecked());
  403. m_updateResourceview = true;
  404. if (m_tab->visibleWidget() == m_resourceview)
  405. slotUpdate(false);
  406. }
  407. void View::slotViewAccounts() {
  408. //kdDebug()<<k_funcinfo<<endl;
  409. m_tab->raiseWidget(m_accountsview);
  410. }
  411. void View::slotProjectEdit() {
  412. MainProjectDialog *dia = new MainProjectDialog(getProject());
  413. if (dia->exec()) {
  414. KCommand *cmd = dia->buildCommand(getPart());
  415. if (cmd) {
  416. getPart()->addCommand(cmd);
  417. }
  418. }
  419. delete dia;
  420. }
  421. void View::slotProjectCalendar() {
  422. CalendarListDialog *dia = new CalendarListDialog(getProject());
  423. if (dia->exec()) {
  424. KCommand *cmd = dia->buildCommand(getPart());
  425. if (cmd) {
  426. //kdDebug()<<k_funcinfo<<"Modifying calendar(s)"<<endl;
  427. getPart()->addCommand(cmd); //also executes
  428. }
  429. }
  430. delete dia;
  431. }
  432. void View::slotProjectAccounts() {
  433. AccountsDialog *dia = new AccountsDialog(getProject().accounts());
  434. if (dia->exec()) {
  435. KCommand *cmd = dia->buildCommand(getPart());
  436. if (cmd) {
  437. //kdDebug()<<k_funcinfo<<"Modifying account(s)"<<endl;
  438. getPart()->addCommand(cmd); //also executes
  439. }
  440. }
  441. delete dia;
  442. }
  443. void View::slotProjectWorktime() {
  444. StandardWorktimeDialog *dia = new StandardWorktimeDialog(getProject());
  445. if (dia->exec()) {
  446. KCommand *cmd = dia->buildCommand(getPart());
  447. if (cmd) {
  448. //kdDebug()<<k_funcinfo<<"Modifying calendar(s)"<<endl;
  449. getPart()->addCommand(cmd); //also executes
  450. }
  451. }
  452. delete dia;
  453. }
  454. void View::slotProjectResources() {
  455. ResourcesDialog *dia = new ResourcesDialog(getProject());
  456. if (dia->exec()) {
  457. KCommand *cmd = dia->buildCommand(getPart());
  458. if (cmd) {
  459. //kdDebug()<<k_funcinfo<<"Modifying resources"<<endl;
  460. getPart()->addCommand(cmd); //also executes
  461. }
  462. }
  463. delete dia;
  464. }
  465. void View::slotProjectCalculate() {
  466. //kdDebug()<<k_funcinfo<<endl;
  467. slotUpdate(true);
  468. }
  469. void View::slotProjectCalculateExpected() {
  470. m_currentEstimateType = Effort::Use_Expected;
  471. m_updateGanttview = true;
  472. m_updateResourceview = true;
  473. m_updateAccountsview = true;
  474. slotUpdate(true);
  475. }
  476. void View::slotProjectCalculateOptimistic() {
  477. m_currentEstimateType = Effort::Use_Optimistic;
  478. m_updateGanttview = true;
  479. m_updateResourceview = true;
  480. m_updateAccountsview = true;
  481. slotUpdate(true);
  482. }
  483. void View::slotProjectCalculatePessimistic() {
  484. m_currentEstimateType = Effort::Use_Pessimistic;
  485. m_updateGanttview = true;
  486. m_updateResourceview = true;
  487. m_updateAccountsview = true;
  488. slotUpdate(true);
  489. }
  490. void View::projectCalculate() {
  491. if (false /*getProject().actualEffort() > 0*/) {
  492. // NOTE: This can be removed when proper baselining etc is implemented
  493. if (KMessageBox::warningContinueCancel(this, i18n("Progress information will be deleted if the project is recalculated."), i18n("Calculate"), i18n("Calculate")) == KMessageBox::Cancel) {
  494. return;
  495. }
  496. }
  497. TQApplication::setOverrideCursor(TQt::waitCursor);
  498. Schedule *ns = getProject().findSchedule((Schedule::Type)m_currentEstimateType);
  499. KCommand *cmd;
  500. if (ns) {
  501. cmd = new RecalculateProjectCmd(getPart(), getProject(), *ns, i18n("Calculate"));
  502. } else {
  503. cmd = new CalculateProjectCmd(getPart(), getProject(), i18n("Standard"), (Effort::Use)m_currentEstimateType, i18n("Calculate"));
  504. }
  505. getPart()->addCommand(cmd);
  506. TQApplication::restoreOverrideCursor();
  507. }
  508. void View::slotViewReportDesign() {
  509. //kdDebug()<<k_funcinfo<<endl;
  510. }
  511. void View::slotViewReports() {
  512. //kdDebug()<<k_funcinfo<<endl;
  513. //m_tab->raiseWidget(m_reportview);
  514. }
  515. void View::slotAddSubTask() {
  516. // If we are positionend on the root project, then what we really want to
  517. // do is to add a first project. We will silently accept the challenge
  518. // and will not complain.
  519. Task* node = getProject().createTask(getPart()->config().taskDefaults(), currentTask());
  520. TaskDialog *dia = new TaskDialog(*node, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
  521. if (dia->exec()) {
  522. Node *currNode = currentTask();
  523. if (currNode)
  524. {
  525. KCommand *m = dia->buildCommand(getPart());
  526. m->execute(); // do changes to task
  527. delete m;
  528. SubtaskAddCmd *cmd = new SubtaskAddCmd(getPart(), &(getProject()), node, currNode, i18n("Add Subtask"));
  529. getPart()->addCommand(cmd); // add task to project
  530. return;
  531. }
  532. else
  533. kdDebug()<<k_funcinfo<<"Cannot insert new project. Hmm, no current node!?"<<endl;
  534. }
  535. delete node;
  536. delete dia;
  537. }
  538. void View::slotAddTask() {
  539. Task* node = getProject().createTask(getPart()->config().taskDefaults(), currentTask());
  540. TaskDialog *dia = new TaskDialog(*node, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
  541. if (dia->exec()) {
  542. Node* currNode = currentTask();
  543. if (currNode)
  544. {
  545. KCommand *m = dia->buildCommand(getPart());
  546. m->execute(); // do changes to task
  547. delete m;
  548. TaskAddCmd *cmd = new TaskAddCmd(getPart(), &(getProject()), node, currNode, i18n("Add Task"));
  549. getPart()->addCommand(cmd); // add task to project
  550. return;
  551. }
  552. else
  553. kdDebug()<<k_funcinfo<<"Cannot insert new task. Hmm, no current node!?"<<endl;
  554. }
  555. delete node;
  556. delete dia;
  557. }
  558. void View::slotAddMilestone() {
  559. Task* node = getProject().createTask(currentTask());
  560. node->effort()->set(Duration::zeroDuration);
  561. TaskDialog *dia = new TaskDialog(*node, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
  562. if (dia->exec()) {
  563. Node *currNode = currentTask();
  564. if (currNode)
  565. {
  566. KCommand *m = dia->buildCommand(getPart());
  567. m->execute(); // do changes to task
  568. delete m;
  569. TaskAddCmd *cmd = new TaskAddCmd(getPart(), &(getProject()), node, currNode, i18n("Add Milestone"));
  570. getPart()->addCommand(cmd); // add task to project
  571. return;
  572. }
  573. else
  574. kdDebug()<<k_funcinfo<<"Cannot insert new milestone. Hmm, no current node!?"<<endl;
  575. }
  576. delete node;
  577. delete dia;
  578. }
  579. void View::slotDefineWBS() {
  580. //kdDebug()<<k_funcinfo<<endl;
  581. WBSDefinitionDialog *dia = new WBSDefinitionDialog(getPart()->wbsDefinition());
  582. dia->exec();
  583. delete dia;
  584. }
  585. void View::slotGenerateWBS() {
  586. //kdDebug()<<k_funcinfo<<endl;
  587. getPart()->generateWBS();
  588. slotUpdate(false);
  589. }
  590. void View::slotConfigure() {
  591. //kdDebug()<<k_funcinfo<<endl;
  592. ConfigDialog *dia = new ConfigDialog(getPart()->config(), getProject());
  593. dia->exec();
  594. delete dia;
  595. }
  596. Node *View::currentTask()
  597. {
  598. Node* task = 0;
  599. if (m_tab->visibleWidget() == m_ganttview) {
  600. task = m_ganttview->currentNode();
  601. }
  602. else if (m_tab->visibleWidget() == m_pertview) {
  603. task = m_pertview->currentNode();
  604. }
  605. else if (m_tab->visibleWidget() == m_resourceview) {
  606. task = m_resourceview->currentNode();
  607. }
  608. if ( 0 != task ) {
  609. return task;
  610. }
  611. return &(getProject());
  612. }
  613. void View::slotOpenNode() {
  614. //kdDebug()<<k_funcinfo<<endl;
  615. Node *node = currentTask();
  616. if (!node)
  617. return;
  618. switch (node->type()) {
  619. case Node::Type_Project: {
  620. Project *project = dynamic_cast<Project *>(node);
  621. MainProjectDialog *dia = new MainProjectDialog(*project);
  622. if (dia->exec()){
  623. KCommand *m = dia->buildCommand(getPart());
  624. if (m) {
  625. getPart()->addCommand(m);
  626. }
  627. }
  628. delete dia;
  629. break;
  630. }
  631. case Node::Type_Subproject:
  632. //TODO
  633. break;
  634. case Node::Type_Task: {
  635. Task *task = dynamic_cast<Task *>(node);
  636. TaskDialog *dia = new TaskDialog(*task, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
  637. if (dia->exec()) {
  638. KCommand *m = dia->buildCommand(getPart());
  639. if (m) {
  640. getPart()->addCommand(m);
  641. }
  642. }
  643. delete dia;
  644. break;
  645. }
  646. case Node::Type_Milestone: {
  647. // Use the normal task dialog for now.
  648. // Maybe milestone should have it's own dialog, but we need to be able to
  649. // enter a duration in case we accidentally set a tasks duration to zero
  650. // and hence, create a milestone
  651. Task *task = dynamic_cast<Task *>(node);
  652. TaskDialog *dia = new TaskDialog(*task, getProject().accounts(), getProject().standardWorktime(), getProject().isBaselined());
  653. if (dia->exec()) {
  654. KCommand *m = dia->buildCommand(getPart());
  655. if (m) {
  656. getPart()->addCommand(m);
  657. }
  658. }
  659. delete dia;
  660. break;
  661. }
  662. case Node::Type_Summarytask: {
  663. Task *task = dynamic_cast<Task *>(node);
  664. SummaryTaskDialog *dia = new SummaryTaskDialog(*task);
  665. if (dia->exec()) {
  666. KCommand *m = dia->buildCommand(getPart());
  667. if (m) {
  668. getPart()->addCommand(m);
  669. }
  670. }
  671. delete dia;
  672. break;
  673. }
  674. default:
  675. break; // avoid warnings
  676. }
  677. }
  678. void View::slotTaskProgress() {
  679. //kdDebug()<<k_funcinfo<<endl;
  680. Node *node = currentTask();
  681. if (!node)
  682. return;
  683. switch (node->type()) {
  684. case Node::Type_Project: {
  685. break;
  686. }
  687. case Node::Type_Subproject:
  688. //TODO
  689. break;
  690. case Node::Type_Task: {
  691. Task *task = dynamic_cast<Task *>(node);
  692. TaskProgressDialog *dia = new TaskProgressDialog(*task, getProject().standardWorktime());
  693. if (dia->exec()) {
  694. KCommand *m = dia->buildCommand(getPart());
  695. if (m) {
  696. getPart()->addCommand(m);
  697. }
  698. }
  699. delete dia;
  700. break;
  701. }
  702. case Node::Type_Milestone: {
  703. Task *task = dynamic_cast<Task *>(node);
  704. MilestoneProgressDialog *dia = new MilestoneProgressDialog(*task);
  705. if (dia->exec()) {
  706. KCommand *m = dia->buildCommand(getPart());
  707. if (m) {
  708. getPart()->addCommand(m);
  709. }
  710. }
  711. delete dia;
  712. break;
  713. }
  714. case Node::Type_Summarytask: {
  715. // TODO
  716. break;
  717. }
  718. default:
  719. break; // avoid warnings
  720. }
  721. }
  722. void View::slotDeleteTask()
  723. {
  724. //kdDebug()<<k_funcinfo<<endl;
  725. Node *node = currentTask();
  726. if (node == 0 || node->getParent() == 0) {
  727. kdDebug()<<k_funcinfo<<(node ? "Task is main project" : "No current task")<<endl;
  728. return;
  729. }
  730. KMacroCommand *cmd = new KMacroCommand(i18n("Delete Task"));
  731. cmd->addCommand(new NodeDeleteCmd(getPart(), node));
  732. TQPtrListIterator<Relation> it = node->dependChildNodes();
  733. for (; it.current(); ++it) {
  734. cmd->addCommand(new DeleteRelationCmd(getPart(), it.current()));
  735. }
  736. it = node->dependParentNodes();
  737. for (; it.current(); ++it) {
  738. cmd->addCommand(new DeleteRelationCmd(getPart(),it.current()));
  739. }
  740. getPart()->addCommand(cmd);
  741. }
  742. void View::slotIndentTask()
  743. {
  744. //kdDebug()<<k_funcinfo<<endl;
  745. Node *node = currentTask();
  746. if (node == 0 || node->getParent() == 0) {
  747. kdDebug()<<k_funcinfo<<(node ? "Task is main project" : "No current task")<<endl;
  748. return;
  749. }
  750. if (getProject().canIndentTask(node)) {
  751. NodeIndentCmd *cmd = new NodeIndentCmd(getPart(), *node, i18n("Indent Task"));
  752. getPart()->addCommand(cmd);
  753. }
  754. }
  755. void View::slotUnindentTask()
  756. {
  757. //kdDebug()<<k_funcinfo<<endl;
  758. Node *node = currentTask();
  759. if (node == 0 || node->getParent() == 0) {
  760. kdDebug()<<k_funcinfo<<(node ? "Task is main project" : "No current task")<<endl;
  761. return;
  762. }
  763. if (getProject().canUnindentTask(node)) {
  764. NodeUnindentCmd *cmd = new NodeUnindentCmd(getPart(), *node, i18n("Unindent Task"));
  765. getPart()->addCommand(cmd);
  766. }
  767. }
  768. void View::slotMoveTaskUp()
  769. {
  770. //kdDebug()<<k_funcinfo<<endl;
  771. Node* task = currentTask();
  772. if ( 0 == task ) {
  773. // is always != 0. At least we would get the Project, but you never know who might change that
  774. // so better be careful
  775. kdError()<<k_funcinfo<<"No current task"<<endl;
  776. return;
  777. }
  778. if ( Node::Type_Project == task->type() ) {
  779. kdDebug()<<k_funcinfo<<"The root node cannot be moved up"<<endl;
  780. return;
  781. }
  782. if (getProject().canMoveTaskUp(task)) {
  783. NodeMoveUpCmd *cmd = new NodeMoveUpCmd(getPart(), *task, i18n("Move Task Up"));
  784. getPart()->addCommand(cmd);
  785. }
  786. }
  787. void View::slotMoveTaskDown()
  788. {
  789. //kdDebug()<<k_funcinfo<<endl;
  790. Node* task = currentTask();
  791. if ( 0 == task ) {
  792. // is always != 0. At least we would get the Project, but you never know who might change that
  793. // so better be careful
  794. return;
  795. }
  796. if ( Node::Type_Project == task->type() ) {
  797. kdDebug()<<k_funcinfo<<"The root node cannot be moved down"<<endl;
  798. return;
  799. }
  800. if (getProject().canMoveTaskDown(task)) {
  801. NodeMoveDownCmd *cmd = new NodeMoveDownCmd(getPart(), *task, i18n("Move Task Down"));
  802. getPart()->addCommand(cmd);
  803. }
  804. }
  805. void View::slotAddRelation(Node *par, Node *child) {
  806. //kdDebug()<<k_funcinfo<<endl;
  807. Relation *rel = new Relation(par, child);
  808. AddRelationDialog *dia = new AddRelationDialog(rel, this);
  809. if (dia->exec()) {
  810. KCommand *cmd = dia->buildCommand(getPart());
  811. if (cmd)
  812. getPart()->addCommand(cmd);
  813. } else {
  814. delete rel;
  815. }
  816. delete dia;
  817. }
  818. void View::slotAddRelation(Node *par, Node *child, int linkType) {
  819. //kdDebug()<<k_funcinfo<<endl;
  820. if (linkType == Relation::FinishStart ||
  821. linkType == Relation::StartStart ||
  822. linkType == Relation::FinishFinish)
  823. {
  824. Relation *rel = new Relation(par, child, static_cast<Relation::Type>(linkType));
  825. getPart()->addCommand(new AddRelationCmd(getPart(), rel, i18n("Add Relation")));
  826. } else {
  827. slotAddRelation(par, child);
  828. }
  829. }
  830. void View::slotModifyRelation(Relation *rel) {
  831. //kdDebug()<<k_funcinfo<<endl;
  832. ModifyRelationDialog *dia = new ModifyRelationDialog(rel, this);
  833. if (dia->exec()) {
  834. if (dia->relationIsDeleted()) {
  835. getPart()->addCommand(new DeleteRelationCmd(getPart(), rel, i18n("Delete Relation")));
  836. } else {
  837. KCommand *cmd = dia->buildCommand(getPart());
  838. if (cmd) {
  839. getPart()->addCommand(cmd);
  840. }
  841. }
  842. }
  843. delete dia;
  844. }
  845. void View::slotModifyRelation(Relation *rel, int linkType) {
  846. //kdDebug()<<k_funcinfo<<endl;
  847. if (linkType == Relation::FinishStart ||
  848. linkType == Relation::StartStart ||
  849. linkType == Relation::FinishFinish)
  850. {
  851. getPart()->addCommand(new ModifyRelationTypeCmd(getPart(), rel, static_cast<Relation::Type>(linkType)));
  852. } else {
  853. slotModifyRelation(rel);
  854. }
  855. }
  856. // testing
  857. void View::slotExportGantt() {
  858. //kdDebug()<<k_funcinfo<<endl;
  859. if (!m_ganttview) {
  860. return;
  861. }
  862. TQString fn = KFileDialog::getSaveFileName( TQString(), TQString(), this );
  863. if (!fn.isEmpty()) {
  864. TQFile f(fn);
  865. m_ganttview->exportGantt(TQT_TQIODEVICE(&f));
  866. }
  867. }
  868. void View::slotEditResource() {
  869. //kdDebug()<<k_funcinfo<<endl;
  870. Resource *r = m_resourceview->currentResource();
  871. if (!r)
  872. return;
  873. ResourceDialog *dia = new ResourceDialog(getProject(), r);
  874. if (dia->exec()) {
  875. KCommand *cmd = dia->buildCommand(getPart());
  876. if (cmd)
  877. getPart()->addCommand(cmd);
  878. }
  879. delete dia;
  880. }
  881. void View::updateReadWrite(bool /*readwrite*/) {
  882. }
  883. Part *View::getPart()const {
  884. return (Part *)koDocument();
  885. }
  886. void View::slotConnectNode() {
  887. //kdDebug()<<k_funcinfo<<endl;
  888. /* NodeItem *curr = m_ganttview->currentItem();
  889. if (curr) {
  890. kdDebug()<<k_funcinfo<<"node="<<curr->getNode().name()<<endl;
  891. }*/
  892. }
  893. TQPopupMenu * View::popupMenu( const TQString& name )
  894. {
  895. //kdDebug()<<k_funcinfo<<endl;
  896. Q_ASSERT(factory());
  897. if ( factory() )
  898. return ((TQPopupMenu*)factory()->container( name, this ));
  899. return 0L;
  900. }
  901. void View::slotChanged(TQWidget *)
  902. {
  903. //kdDebug()<<k_funcinfo<<endl;
  904. slotUpdate(false);
  905. }
  906. void View::slotChanged()
  907. {
  908. //kdDebug()<<k_funcinfo<<endl;
  909. slotUpdate(false);
  910. }
  911. void View::slotUpdate(bool calculate)
  912. {
  913. //kdDebug()<<k_funcinfo<<"calculate="<<calculate<<endl;
  914. if (calculate)
  915. projectCalculate();
  916. m_updateGanttview = true;
  917. m_updateResourceview = true;
  918. m_updateAccountsview = true;
  919. updateView(m_tab->visibleWidget());
  920. }
  921. void View::slotAboutToShow(TQWidget *widget) {
  922. updateView(widget);
  923. }
  924. void View::updateView(TQWidget *widget)
  925. {
  926. TQApplication::setOverrideCursor(TQt::waitCursor);
  927. setScheduleActionsEnabled();
  928. setTaskActionsEnabled(false);
  929. mainWindow()->toolBar("report")->hide();
  930. if (widget == m_ganttview)
  931. {
  932. //kdDebug()<<k_funcinfo<<"draw gantt"<<endl;
  933. m_ganttview->setShowExpected(actionViewExpected->isChecked());
  934. m_ganttview->setShowOptimistic(actionViewOptimistic->isChecked());
  935. m_ganttview->setShowPessimistic(actionViewPessimistic->isChecked());
  936. if (m_updateGanttview)
  937. m_ganttview->drawChanges(getProject());
  938. setTaskActionsEnabled(widget, true);
  939. m_updateGanttview = false;
  940. }
  941. else if (widget == m_pertview)
  942. {
  943. //kdDebug()<<k_funcinfo<<"draw pertview"<<endl;
  944. m_pertview->draw();
  945. }
  946. else if (widget == m_resourceview)
  947. {
  948. //kdDebug()<<k_funcinfo<<"draw resourceview"<<endl;
  949. if (m_updateResourceview)
  950. m_resourceview->draw(getPart()->getProject());
  951. m_updateResourceview = false;
  952. }
  953. else if (widget == m_accountsview)
  954. {
  955. //kdDebug()<<k_funcinfo<<"draw accountsview"<<endl;
  956. if (m_updateAccountsview)
  957. m_accountsview->draw();
  958. m_updateAccountsview = false;
  959. }
  960. /* else if (widget == m_reportview)
  961. {
  962. mainWindow()->toolBar("report")->show();
  963. m_reportview->enableNavigationBtn();
  964. }*/
  965. TQApplication::restoreOverrideCursor();
  966. }
  967. void View::slotRenameNode(Node *node, const TQString& name) {
  968. //kdDebug()<<k_funcinfo<<name<<endl;
  969. if (node) {
  970. NodeModifyNameCmd *cmd = new NodeModifyNameCmd(getPart(), *node, name, i18n("Modify Name"));
  971. getPart()->addCommand(cmd);
  972. }
  973. }
  974. void View::slotPopupMenu(const TQString& menuname, const TQPoint & pos)
  975. {
  976. TQPopupMenu* menu = this->popupMenu(menuname);
  977. if (menu)
  978. menu->exec(pos);
  979. }
  980. bool View::setContext(Context &context) {
  981. //kdDebug()<<k_funcinfo<<endl;
  982. m_currentEstimateType = context.currentEstimateType;
  983. getProject().setCurrentSchedule(context.currentSchedule);
  984. actionViewExpected->setChecked(context.actionViewExpected);
  985. actionViewOptimistic->setChecked(context.actionViewOptimistic);
  986. actionViewPessimistic->setChecked(context.actionViewPessimistic);
  987. m_ganttview->setContext(context.ganttview, getProject());
  988. // hmmm, can't decide if these should be here or actions moved to ganttview
  989. actionViewGanttResources->setChecked(context.ganttview.showResources);
  990. actionViewGanttTaskName->setChecked(context.ganttview.showTaskName);
  991. actionViewGanttTaskLinks->setChecked(context.ganttview.showTaskLinks);
  992. actionViewGanttProgress->setChecked(context.ganttview.showProgress);
  993. actionViewGanttFloat->setChecked(context.ganttview.showPositiveFloat);
  994. actionViewGanttCriticalTasks->setChecked(context.ganttview.showCriticalTasks);
  995. actionViewGanttCriticalPath->setChecked(context.ganttview.showCriticalPath);
  996. m_pertview->setContext(context.pertview);
  997. m_resourceview->setContext(context.resourceview);
  998. m_accountsview->setContext(context.accountsview);
  999. // m_reportview->setContext(context.reportview);
  1000. if (context.currentView == "ganttview") {
  1001. m_ganttview->setShowExpected(actionViewExpected->isChecked());
  1002. m_ganttview->setShowOptimistic(actionViewOptimistic->isChecked());
  1003. m_ganttview->setShowPessimistic(actionViewPessimistic->isChecked());
  1004. slotViewGantt();
  1005. } else if (context.currentView == "pertview") {
  1006. slotViewPert();
  1007. } else if (context.currentView == "resourceview") {
  1008. slotViewResources();
  1009. } else if (context.currentView == "accountsview") {
  1010. slotViewAccounts();
  1011. } else if (context.currentView == "reportview") {
  1012. //slotViewReport();
  1013. } else {
  1014. slotViewGantt();
  1015. }
  1016. slotUpdate(false);
  1017. return true;
  1018. }
  1019. void View::getContext(Context &context) const {
  1020. //kdDebug()<<k_funcinfo<<endl;
  1021. context.currentEstimateType = m_currentEstimateType;
  1022. if (getProject().currentSchedule())
  1023. context.currentSchedule = getProject().currentSchedule()->id();
  1024. context.actionViewExpected = actionViewExpected->isChecked();
  1025. context.actionViewOptimistic = actionViewOptimistic->isChecked();
  1026. context.actionViewPessimistic = actionViewPessimistic->isChecked();
  1027. if (m_tab->visibleWidget() == m_ganttview) {
  1028. context.currentView = "ganttview";
  1029. } else if (m_tab->visibleWidget() == m_pertview) {
  1030. context.currentView = "pertview";
  1031. } else if (m_tab->visibleWidget() == m_resourceview) {
  1032. context.currentView = "resourceview";
  1033. } else if (m_tab->visibleWidget() == m_accountsview) {
  1034. context.currentView = "accountsview";
  1035. /* } else if (m_tab->visibleWidget() == m_reportview) {
  1036. context.currentView = "reportview";*/
  1037. }
  1038. m_ganttview->getContext(context.ganttview);
  1039. m_pertview->getContext(context.pertview);
  1040. m_resourceview->getContext(context.resourceview);
  1041. m_accountsview->getContext(context.accountsview);
  1042. // m_reportview->getContext(context.reportview);
  1043. }
  1044. void View::setBaselineMode(bool /*on*/) {
  1045. //kdDebug()<<k_funcinfo<<endl;
  1046. /* m_baselineMode = on;
  1047. m_ganttview->setReadWriteMode(!on);
  1048. actionCut->setEnabled(!on);
  1049. actionCopy->setEnabled(!on);
  1050. actionPaste->setEnabled(!on);
  1051. actionDeleteTask->setEnabled(!on);
  1052. actionIndentTask->setEnabled(!on);
  1053. actionUnindentTask->setEnabled(!on);
  1054. actionMoveTaskUp->setEnabled(!on);
  1055. actionMoveTaskDown->setEnabled(!on);
  1056. actionAddTask->setEnabled(!on);
  1057. actionAddSubtask->setEnabled(!on);
  1058. actionAddMilestone->setEnabled(!on);
  1059. actionEditStandardWorktime->setEnabled(!on);
  1060. actionEditCalendar->setEnabled(!on);
  1061. actionEditResources->setEnabled(!on);
  1062. actionCalculate->setEnabled(!on);
  1063. actionEditResource->setEnabled(!on);*/
  1064. }
  1065. // called when widget w is about to be shown
  1066. void View::setTaskActionsEnabled(TQWidget *w, bool on) {
  1067. Node *n = 0;
  1068. if (w == m_ganttview) {
  1069. n = m_ganttview->currentNode();
  1070. }// else pert, etc when implemented
  1071. actionAddTask->setEnabled(on);
  1072. actionAddMilestone->setEnabled(on);
  1073. // only enabled when we have a task selected
  1074. bool o = (on && n);
  1075. actionAddSubtask->setEnabled(o);
  1076. actionDeleteTask->setEnabled(o);
  1077. actionMoveTaskUp->setEnabled(o && getProject().canMoveTaskUp(n));
  1078. actionMoveTaskDown->setEnabled(o && getProject().canMoveTaskDown(n));
  1079. actionIndentTask->setEnabled(o && getProject().canIndentTask(n));
  1080. actionUnindentTask->setEnabled(o && getProject().canUnindentTask(n));
  1081. }
  1082. void View::setTaskActionsEnabled(bool on) {
  1083. setTaskActionsEnabled(m_ganttview, on); //FIXME if more than ganttview can do this
  1084. }
  1085. void View::setScheduleActionsEnabled() {
  1086. actionViewExpected->setEnabled(getProject().findSchedule(Schedule::Expected));
  1087. actionViewOptimistic->setEnabled(getProject().findSchedule(Schedule::Optimistic));
  1088. actionViewPessimistic->setEnabled(getProject().findSchedule(Schedule::Pessimistic));
  1089. if (getProject().notScheduled()) {
  1090. m_estlabel->setText(i18n("Not scheduled"));
  1091. return;
  1092. }
  1093. Schedule *ns = getProject().currentSchedule();
  1094. if (ns->type() == Schedule::Expected) {
  1095. actionViewExpected->setChecked(true);
  1096. m_estlabel->setText(i18n("Expected"));
  1097. } else if (ns->type() == Schedule::Optimistic) {
  1098. actionViewOptimistic->setChecked(true);
  1099. m_estlabel->setText(i18n("Optimistic"));
  1100. } else if (ns->type() == Schedule::Pessimistic) {
  1101. actionViewPessimistic->setChecked(true);
  1102. m_estlabel->setText(i18n("Pessimistic"));
  1103. }
  1104. }
  1105. #ifndef NDEBUG
  1106. void View::slotPrintDebug() {
  1107. kdDebug()<<"-------- Debug printout: Node list" <<endl;
  1108. /* Node *curr = m_ganttview->currentNode();
  1109. if (curr) {
  1110. curr->printDebug(true,"");
  1111. } else*/
  1112. getPart()->getProject().printDebug(true, "");
  1113. }
  1114. void View::slotPrintSelectedDebug() {
  1115. Node *curr = m_ganttview->currentNode();
  1116. if (curr) {
  1117. kdDebug()<<"-------- Debug printout: Selected node" <<endl;
  1118. curr->printDebug(true,"");
  1119. } else
  1120. slotPrintDebug();
  1121. }
  1122. void View::slotPrintCalendarDebug() {
  1123. kdDebug()<<"-------- Debug printout: Node list" <<endl;
  1124. /* Node *curr = m_ganttview->currentNode();
  1125. if (curr) {
  1126. curr->printDebug(true,"");
  1127. } else*/
  1128. getPart()->getProject().printCalendarDebug("");
  1129. }
  1130. void View::slotPrintTestDebug() {
  1131. const TQStringList &lst = getPart()->xmlLoader().log();
  1132. for ( TQStringList::ConstIterator it = lst.constBegin(); it != lst.constEnd(); ++it ) {
  1133. kdDebug()<<*it<<endl;
  1134. }
  1135. // kdDebug()<<"------------Test 1---------------------"<<endl;
  1136. // {
  1137. // DateTime d1(TQDate(2006,1,2), TQTime(8,0,0));
  1138. // DateTime d2 = d1.addSecs(3600);
  1139. // Duration d = d2 - d1;
  1140. // bool b = d==Duration(0,0,0,3600);
  1141. // kdDebug()<<"1: Success="<<b<<" "<<d2.toString()<<"-"<<d1.toString()<<"="<<d.toString()<<endl;
  1142. // d = d1 - d2;
  1143. // b = d==Duration(0,0,0,3600);
  1144. // kdDebug()<<"2: Success="<<b<<" "<<d1.toString()<<"-"<<d2.toString()<<"="<<d.toString()<<endl;
  1145. // d2 = d2.addDays(-2);
  1146. // d = d1 - d2;
  1147. // b = d==Duration(2,0,0)-Duration(0,0,0,3600);
  1148. // kdDebug()<<"3: Success="<<b<<" "<<d1.toString()<<"-"<<d2.toString()<<"="<<d.toString()<<endl;
  1149. // d = d2 - d1;
  1150. // b = d==Duration(2,0,0)-Duration(0,0,0,3600);
  1151. // kdDebug()<<"4: Success="<<b<<" "<<d2.toString()<<"-"<<d1.toString()<<"="<<d.toString()<<endl;
  1152. // kdDebug()<<endl;
  1153. // b = (d2 + d)==d1;
  1154. // kdDebug()<<"5: Success="<<b<<" "<<d2<<"+"<<d.toString()<<"="<<d1<<endl;
  1155. // b = (d1 - d)==d2;
  1156. // kdDebug()<<"6: Success="<<b<<" "<<d1<<"-"<<d.toString()<<"="<<d2<<endl;
  1157. // } // end test 1
  1158. // kdDebug()<<endl;
  1159. // kdDebug()<<"------------Test 2 Single calendar-----------------"<<endl;
  1160. // {
  1161. // Calendar *t = new Calendar("Test 2");
  1162. // TQDate wdate(2006,1,2);
  1163. // DateTime before = DateTime(wdate.addDays(-1));
  1164. // DateTime after = DateTime(wdate.addDays(1));
  1165. // TQTime t1(8,0,0);
  1166. // TQTime t2(10,0,0);
  1167. // DateTime wdt1(wdate, t1);
  1168. // DateTime wdt2(wdate, t2);
  1169. // CalendarDay *day = new CalendarDay(TQDate(2006,1,2), Map::Working);
  1170. // day->addInterval(TQPair<TQTime, TQTime>(t1, t2));
  1171. // if (!t->addDay(day)) {
  1172. // kdDebug()<<"Failed to add day"<<endl;
  1173. // delete day;
  1174. // delete t;
  1175. // return;
  1176. // }
  1177. // kdDebug()<<"Added date="<<day->date().toString()<<" "<<day->startOfDay().toString()<<" - "<<day->endOfDay()<<endl;
  1178. // kdDebug()<<"Found date="<<day->date().toString()<<" "<<day->startOfDay().toString()<<" - "<<day->endOfDay()<<endl;
  1179. //
  1180. // CalendarDay *d = t->findDay(wdate);
  1181. // bool b = (day == d);
  1182. // kdDebug()<<"1: Success="<<b<<" Find same day"<<endl;
  1183. //
  1184. // DateTime dt = t->firstAvailableAfter(after, after.addDays(10));
  1185. // b = !dt.isValid();
  1186. // kdDebug()<<"2: Success="<<b<<" firstAvailableAfter("<<after<<"): ="<<dt<<endl;
  1187. //
  1188. // dt = t->firstAvailableBefore(before, before.addDays(-10));
  1189. // b = !dt.isValid();
  1190. // kdDebug()<<"3: Success="<<b<<" firstAvailableBefore("<<before.toString()<<"): ="<<dt<<endl;
  1191. //
  1192. // dt = t->firstAvailableAfter(before, after);
  1193. // b = dt == wdt1;
  1194. // kdDebug()<<"4: Success="<<b<<" firstAvailableAfter("<<before<<"): ="<<dt<<endl;
  1195. //
  1196. // dt = t->firstAvailableBefore(after, before);
  1197. // b = dt == wdt2;
  1198. // kdDebug()<<"5: Success="<<b<<" firstAvailableBefore("<<after<<"): ="<<dt<<endl;
  1199. //
  1200. // b = t->hasInterval(before, after);
  1201. // kdDebug()<<"6: Success="<<b<<" hasInterval("<<before<<", "<<after<<")"<<endl;
  1202. //
  1203. // b = !t->hasInterval(after, after.addDays(1));
  1204. // kdDebug()<<"7: Success="<<b<<" !hasInterval("<<after<<", "<<after.addDays(1)<<")"<<endl;
  1205. //
  1206. // b = !t->hasInterval(before, before.addDays(-1));
  1207. // kdDebug()<<"8: Success="<<b<<" !hasInterval("<<before<<", "<<before.addDays(-1)<<")"<<endl;
  1208. //
  1209. // Duration e1(0, 2, 0); // 2 hours
  1210. // Duration e2 = t->effort(before, after);
  1211. // b = e1==e2;
  1212. // kdDebug()<<"9: Success="<<b<<" effort"<<e1.toString()<<" = "<<e2.toString()<<endl;
  1213. //
  1214. // delete t;
  1215. // }// end test 2
  1216. //
  1217. // kdDebug()<<endl;
  1218. // kdDebug()<<"------------Test 3 Parent calendar-----------------"<<endl;
  1219. // {
  1220. // Calendar *t = new Calendar("Test 3");
  1221. // Calendar *p = new Calendar("Test 3 parent");
  1222. // t->setParent(p);
  1223. // TQDate wdate(2006,1,2);
  1224. // DateTime before = DateTime(wdate.addDays(-1));
  1225. // DateTime after = DateTime(wdate.addDays(1));
  1226. // TQTime t1(8,0,0);
  1227. // TQTime t2(10,0,0);
  1228. // DateTime wdt1(wdate, t1);
  1229. // DateTime wdt2(wdate, t2);
  1230. // CalendarDay *day = new CalendarDay(TQDate(2006,1,2), Map::Working);
  1231. // day->addInterval(TQPair<TQTime, TQTime>(t1, t2));
  1232. // if (!p->addDay(day)) {
  1233. // kdDebug()<<"Failed to add day"<<endl;
  1234. // delete day;
  1235. // delete t;
  1236. // return;
  1237. // }
  1238. // kdDebug()<<"Added date="<<day->date().toString()<<" "<<day->startOfDay().toString()<<" - "<<day->endOfDay().toString()<<endl;
  1239. // kdDebug()<<"Found date="<<day->date().toString()<<" "<<day->startOfDay().toString()<<" - "<<day->endOfDay().toString()<<endl;
  1240. //
  1241. // CalendarDay *d = p->findDay(wdate);
  1242. // bool b = (day == d);
  1243. // kdDebug()<<"1: Success="<<b<<" Find same day"<<endl;
  1244. //
  1245. // DateTime dt = t->firstAvailableAfter(after, after.addDays(10));
  1246. // b = !dt.isValid();
  1247. // kdDebug()<<"2: Success="<<b<<" firstAvailableAfter("<<after.toString()<<"): ="<<!b<<endl;
  1248. //
  1249. // dt = t->firstAvailableBefore(before, before.addDays(-10));
  1250. // b = !dt.isValid();
  1251. // kdDebug()<<"3: Success="<<b<<" firstAvailableBefore("<<before.toString()<<"): ="<<!b<<endl;
  1252. //
  1253. // dt = t->firstAvailableAfter(before, after);
  1254. // b = dt == wdt1;
  1255. // kdDebug()<<"4: Success="<<b<<" firstAvailableAfter("<<before.toString()<<"): ="<<dt.toString()<<endl;
  1256. //
  1257. // dt = t->firstAvailableBefore(after, before);
  1258. // b = dt == wdt2;
  1259. // kdDebug()<<"5: Success="<<b<<" firstAvailableBefore("<<after.toString()<<"): ="<<dt.toString()<<endl;
  1260. //
  1261. // b = t->hasInterval(before, after);
  1262. // kdDebug()<<"6: Success="<<b<<" hasInterval("<<before.toString()<<", "<<after<<")"<<endl;
  1263. //
  1264. // b = !t->hasInterval(after, after.addDays(1));
  1265. // kdDebug()<<"7: Success="<<b<<" !hasInterval("<<after.toString()<<", "<<after.addDays(1)<<")"<<endl;
  1266. //
  1267. // b = !t->hasInterval(before, before.addDays(-1));
  1268. // kdDebug()<<"8: Success="<<b<<" !hasInterval("<<before.toString()<<", "<<before.addDays(-1)<<")"<<endl;
  1269. // Duration e1(0, 2, 0); // 2 hours
  1270. // Duration e2 = t->effort(before, after);
  1271. // b = e1==e2;
  1272. // kdDebug()<<"9: Success="<<b<<" effort "<<e1.toString()<<"=="<<e2.toString()<<endl;
  1273. //
  1274. // delete t;
  1275. // delete p;
  1276. // }// end test 3
  1277. // kdDebug()<<endl;
  1278. // kdDebug()<<"------------Test 4 Parent calendar/weekdays-------------"<<endl;
  1279. // {
  1280. // TQTime t1(8,0,0);
  1281. // TQTime t2(10,0,0);
  1282. // Calendar *p = new Calendar("Test 4 parent");
  1283. // CalendarDay *wd1 = p->weekday(0); // monday
  1284. // if (wd1 == 0) {
  1285. // kdDebug()<<"Failed to get weekday"<<endl;
  1286. // }
  1287. // wd1->setState(Map::NonWorking);
  1288. //
  1289. // CalendarDay *wd2 = p->weekday(2); // wednesday
  1290. // if (wd2 == 0) {
  1291. // kdDebug()<<"Failed to get weekday"<<endl;
  1292. // }
  1293. // wd2->addInterval(TQPair<TQTime, TQTime>(t1, t2));
  1294. // wd2->setState(Map::Working);
  1295. //
  1296. // Calendar *t = new Calendar("Test 4");
  1297. // t->setParent(p);
  1298. // TQDate wdate(2006,1,2); // monday jan 2
  1299. // DateTime before = DateTime(wdate.addDays(-4)); //Thursday dec 29
  1300. // DateTime after = DateTime(wdate.addDays(4)); // Friday jan 6
  1301. // DateTime wdt1(wdate, t1);
  1302. // DateTime wdt2(TQDate(2006, 1, 4), t2); // Wednesday
  1303. // CalendarDay *day = new CalendarDay(TQDate(2006,1,2), Map::Working);
  1304. // day->addInterval(TQPair<TQTime, TQTime>(t1, t2));
  1305. // if (!p->addDay(day)) {
  1306. // kdDebug()<<"Failed to add day"<<endl;
  1307. // delete day;
  1308. // delete t;
  1309. // return;
  1310. // }
  1311. // kdDebug()<<"Added date="<<day->date().toString()<<" "<<day->startOfDay().toString()<<" - "<<day->endOfDay().toString()<<endl;
  1312. // kdDebug()<<"Found date="<<day->date().toString()<<" "<<day->startOfDay().toString()<<" - "<<day->endOfDay().toString()<<endl;
  1313. //
  1314. // CalendarDay *d = p->findDay(wdate);
  1315. // bool b = (day == d);
  1316. // kdDebug()<<"1: Success="<<b<<" Find same day"<<endl;
  1317. //
  1318. // DateTime dt = t->firstAvailableAfter(after, after.addDays(10));
  1319. // b = (dt.isValid() && dt == DateTime(TQDate(2006,1,11), t1));
  1320. // kdDebug()<<"2: Success="<<b<<" firstAvailableAfter("<<after<<"): ="<<dt<<endl;
  1321. //
  1322. // dt = t->firstAvailableBefore(before, before.addDays(-10));
  1323. // b = (dt.isValid() && dt == DateTime(TQDate(2005, 12, 28), t2));
  1324. // kdDebug()<<"3: Success="<<b<<" firstAvailableBefore("<<before.toString()<<"): ="<<dt<<endl;
  1325. //
  1326. // dt = t->firstAvailableAfter(before, after);
  1327. // b = dt == wdt1; // We find the day jan 2
  1328. // kdDebug()<<"4: Success="<<b<<" firstAvailableAfter("<<before.toString()<<"): ="<<dt.toString()<<endl;
  1329. //
  1330. // dt = t->firstAvailableBefore(after, before);
  1331. // b = dt == wdt2; // We find the weekday (wednesday)
  1332. // kdDebug()<<"5: Success="<<b<<" firstAvailableBefore("<<after.toString()<<"): ="<<dt.toString()<<endl;
  1333. //
  1334. // b = t->hasInterval(before, after);
  1335. // kdDebug()<<"6: Success="<<b<<" hasInterval("<<before.toString()<<", "<<after<<")"<<endl;
  1336. //
  1337. // b = !t->hasInterval(after, after.addDays(1));
  1338. // kdDebug()<<"7: Success="<<b<<" !hasInterval("<<after.toString()<<", "<<after.addDays(1)<<")"<<endl;
  1339. //
  1340. // b = !t->hasInterval(before, before.addDays(-1));
  1341. // kdDebug()<<"8: Success="<<b<<" !hasInterval("<<before.toString()<<", "<<before.addDays(-1)<<")"<<endl;
  1342. // Duration e1(0, 4, 0); // 2 hours
  1343. // Duration e2 = t->effort(before, after);
  1344. // b = e1==e2;
  1345. // kdDebug()<<"9: Success="<<b<<" effort "<<e1.toString()<<"="<<e2.toString()<<endl;
  1346. //
  1347. // TQPair<DateTime, DateTime> r = t->firstInterval(before, after);
  1348. // b = r.first == wdt1; // We find the monday jan 2
  1349. // kdDebug()<<"10: Success="<<b<<" firstInterval("<<before<<"): ="<<r.first<<", "<<r.second<<endl;
  1350. // r = t->firstInterval(r.second, after);
  1351. // b = r.first == DateTime(TQDate(2006, 1, 4),t1); // We find the wednesday jan 4
  1352. // kdDebug()<<"11: Success="<<b<<" firstInterval("<<r.second<<"): ="<<r.first<<", "<<r.second<<endl;
  1353. //
  1354. // delete t;
  1355. // delete p;
  1356. // }// end test 4
  1357. }
  1358. #endif
  1359. } //KPlato namespace
  1360. #include "kptview.moc"