kplato

kpttaskappointmentsview.ui.h
1/****************************************************************************
2** ui.h extension file, included from the uic-generated form implementation.
3**
4** If you wish to add, delete or rename functions or slots use
5** TQt Designer which will update this file, preserving your code. Create an
6** init() function in place of a constructor, and a destroy() function in
7** place of a destructor.
8*****************************************************************************/
9
10/* This file is part of the KDE project
11 Copyright (C) 2004 - 2005 Dag Andersen <danders@get2net.dk>
12
13 This library is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Library General Public
15 License as published by the Free Software Foundation;
16 version 2 of the License.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Library General Public License for more details.
22
23 You should have received a copy of the GNU Library General Public License
24 along with this library; see the file COPYING.LIB. If not, write to
25 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 * Boston, MA 02110-1301, USA.
27*/
28
29
30#include <kdebug.h>
31
32namespace KPlato
33{
34
35void TaskAppointmentsView::clear()
36{
37 if (m_appList) m_appList->clear();
38 if (m_taskName) m_taskName->clear();
39 if (m_plannedCost) m_plannedCost->clear();
40 if (m_plannedCostTotal) m_plannedCostTotal->clear();
41 if (m_actualCost) m_actualCost->clear();
42 if (m_plannedEffort) m_plannedEffort->clear();
43 if (m_plannedEffortTotal) m_plannedEffortTotal->clear();
44 if (m_epi) m_epi->clear();
45 if (m_cpi) m_cpi->clear();
46}
47
48void TaskAppointmentsView::draw(Task *task)
49{
50 //kdDebug()<<k_funcinfo<<endl;
51 m_task = task;
52 clear();
53 if (!task)
54 return;
55 m_taskName->setText(task->name());
56
57 TQPtrListIterator<Appointment> it(task->appointments());
58 for (; it.current(); ++it) {
59 Resource *r = it.current()->resource();
60 TQListViewItem *item = new TQListViewItem(m_appList, r->name());
61 int i = 1;
62 item->setText(i++, r->typeToString());
63 item->setText(i++, it.current()->startTime().date().toString(ISODate));
64 item->setText(i++, it.current()->endTime().date().toString(ISODate));
65 item->setText(i++, it.current()->plannedEffort().toString(Duration::Format_HourFraction));
66 item->setText(i++, TDEGlobal::locale()->formatMoney(r->normalRate()));
67 item->setText(i++, TDEGlobal::locale()->formatMoney(r->overtimeRate()));
68 item->setText(i++, TDEGlobal::locale()->formatMoney(r->fixedCost()));
69 TQPtrListIterator<AppointmentInterval> ait = it.current()->intervals();
70 for (; ait.current(); ++ait) {
71 TQListViewItem *sub = new TQListViewItem(item, "");
72 i = 1;
73 sub->setText(i++, "");
74 sub->setText(i++, ait.current()->startTime().date().toString(ISODate));
75 sub->setText(i++, ait.current()->endTime().date().toString(ISODate));
76 sub->setText(i++, ait.current()->effort().toString(Duration::Format_HourFraction));
77 }
78
79 }
80 drawCostEffort();
81}
82
83
84void TaskAppointmentsView::init()
85{
86 m_appList->setColumnAlignment(1, AlignHCenter);
87 m_appList->setColumnAlignment(3, AlignRight);
88 m_appList->setColumnAlignment(4, AlignRight);
89 m_appList->setColumnAlignment(5, AlignRight);
90 m_appList->setColumnAlignment(6, AlignRight);
91
92 m_task = 0;
93 m_date->setDate(TQDate::currentDate());
94
95}
96
97void TaskAppointmentsView::drawCostEffort()
98{
99 if (m_task == 0)
100 return;
101 m_actualCost->setText(TDEGlobal::locale()->formatMoney(m_task->actualCostTo(m_date->date())));
102 m_plannedCost->setText(TDEGlobal::locale()->formatMoney(m_task->plannedCostTo(m_date->date())));
103 m_plannedCostTotal->setText(TDEGlobal::locale()->formatMoney(m_task->plannedCost()));
104
105 m_actualEffort->setText(m_task->actualEffortTo(m_date->date()).toString(Duration::Format_HourFraction));
106 m_plannedEffort->setText(m_task->plannedEffortTo(m_date->date()).toString(Duration::Format_HourFraction));
107 m_plannedEffortTotal->setText(m_task->plannedEffort().toString(Duration::Format_HourFraction));
108
109 m_epi->setText(TQString("%1").arg(m_task->effortPerformanceIndex(m_date->date()),3,'f',2));
110 m_cpi->setText(TQString("%1").arg(m_task->costPerformanceIndex(m_date->date()),3,'f',2));
111
112}
113
114} // KPlato namespace