summaryrefslogtreecommitdiffstats
path: root/kplato/kptschedule.cc
blob: 7581312e0c1549f00f411280d77578c4578b08e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
/* This file is part of the KDE project
   Copyright (C) 2005 Dag Andersen <danders@get2net.dk>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation;
   version 2 of the License.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#include "kptschedule.h"

#include "kptappointment.h"
#include "kptdatetime.h"
#include "kptduration.h"
#include "kptnode.h"

#include <tqdom.h>
#include <tqstring.h>
#include <tqstringlist.h>

#include <tdelocale.h>
#include <kdebug.h>

namespace KPlato
{

Schedule::Schedule()
    : m_type(Expected),
      m_id(0),
      m_deleted(false),
      m_parent(0) {
}

Schedule::Schedule(Schedule *parent)
    : m_type(Expected),
      m_id(0),
      m_deleted(false),
      m_appointments(),
      m_parent(parent) {

    if (parent) {
        m_name = parent->name();
        m_type = parent->type();
        m_id = parent->id();
    }
    m_appointments.setAutoDelete(true);
    //kdDebug()<<k_funcinfo<<"("<<this<<") Name: '"<<name<<"' Type="<<type<<" id="<<id<<endl;
}

Schedule::Schedule(TQString name, Type type, long id)
    : m_name(name),
      m_type(type),
      m_id(id),
      m_deleted(false),
      m_appointments(),
      m_parent(0) {

    //kdDebug()<<k_funcinfo<<"("<<this<<") Name: '"<<name<<"' Type="<<type<<" id="<<id<<endl;
    m_appointments.setAutoDelete(true);
}

Schedule::~Schedule() {
}

void Schedule::setParent(Schedule *parent) {
    m_parent = parent;
}

void Schedule::setDeleted(bool on) {
    //kdDebug()<<k_funcinfo<<"deleted="<<on<<endl;
    m_deleted = on;
}

bool Schedule::isDeleted() const {
    return m_parent == 0 ? m_deleted : m_parent->isDeleted();
}

void Schedule::setType(const TQString type) {
    m_type = Expected;
    if (type == "Expected")
        m_type = Expected;
    else if (type == "Optimistic")
        m_type = Optimistic;
    else if (type == "Pessimistic")
        m_type = Pessimistic;
}

TQString Schedule::typeToString(bool translate) const {
    if (translate) {
        if (m_type == Expected)
            return i18n("Expected");
        if (m_type == Optimistic)
            return i18n("Optimistic");
        if (m_type == Pessimistic)
            return i18n("Pessimistic");
        return i18n("Expected");
    } else {
        if (m_type == Expected)
            return "Expected";
        if (m_type == Optimistic)
            return "Optimistic";
        if (m_type == Pessimistic)
            return "Pessimistic";
        return "Expected";
    }
}

void Schedule::initiateCalculation() {
    resourceError = false;
    resourceOverbooked = false;
    schedulingError = false;
    inCriticalPath = false;
    workStartTime = DateTime();
    workEndTime = DateTime();
}

void Schedule::calcResourceOverbooked() {
    resourceOverbooked = false;
    TQPtrListIterator<Appointment> it = m_appointments;
    for (; it.current(); ++it) {
        if (it.current()->resource()->isOverbooked(startTime, endTime)) {
            resourceOverbooked = true;
            break;
        }
    }
}

TQStringList Schedule::overbookedResources() const {
    TQStringList rl;
    TQPtrListIterator<Appointment> it = m_appointments;
    for (; it.current(); ++it) {
        if (it.current()->resource()->isOverbooked(it.current()->startTime(), it.current()->endTime())) {
            rl += it.current()->resource()->resource()->name();
        }
    }
    return rl;
}

bool Schedule::loadXML(const TQDomElement &sch) {
    m_name = sch.attribute("name");
    setType(sch.attribute("type"));
    m_id = sch.attribute("id").toLong();
    return true;
}

void Schedule::saveXML(TQDomElement &element) const {
    TQDomElement sch = element.ownerDocument().createElement("schedule");
    element.appendChild(sch);
    saveCommonXML(sch);
}

void Schedule::saveCommonXML(TQDomElement &element) const {
    //kdDebug()<<k_funcinfo<<m_name<<" save schedule"<<endl;
    element.setAttribute("name", m_name);
    element.setAttribute("type", typeToString());
    element.setAttribute("id", m_id);
}

void Schedule::saveAppointments(TQDomElement &element) const {
    //kdDebug()<<k_funcinfo<<endl;
    TQPtrListIterator<Appointment> it = m_appointments;
    for (; it.current(); ++it) {
        it.current()->saveXML(element);
    }
}

bool Schedule::add(Appointment *appointment) {
    if (m_appointments.findRef(appointment) != -1) {
        kdError()<<k_funcinfo<<"Appointment allready exists"<<endl;
        return false;
    }
    m_appointments.append(appointment);
    //if (resource()) kdDebug()<<k_funcinfo<<"For resource '"<<resource()->name()<<"'"<<endl;
    //if (node()) kdDebug()<<k_funcinfo<<"For node '"<<node()->name()<<"'"<<endl;
    return true;
}

void Schedule::removeAppointment(Appointment *appointment) {
    takeAppointment(appointment);
    delete appointment;
}

void Schedule::takeAppointment(Appointment *appointment) {
    int i = m_appointments.findRef(appointment);
    if (i != -1) {
        m_appointments.take(i);
        //kdDebug()<<k_funcinfo<<"Taken: "<<appointment<<endl;
        if (appointment->node())
            appointment->node()->takeAppointment(appointment);
    } else {
        //kdDebug()<<k_funcinfo<<"Couldn't find appointment: "<<appointment<<endl;
    }
}

Appointment *Schedule::findAppointment(Schedule *resource, Schedule *node) {
    TQPtrListIterator<Appointment> it = m_appointments;
    for (; it.current(); ++it) {
        if (it.current()->node() == node && it.current()->resource() == resource)
            return it.current();
    }
    return 0;
}

EffortCostMap Schedule::plannedEffortCostPrDay(const TQDate &start, const TQDate &end) const {
    //kdDebug()<<k_funcinfo<<m_name<<endl;
    EffortCostMap ec;
    TQPtrListIterator<Appointment> it(m_appointments);
    for (; it.current(); ++it) {
        //kdDebug()<<k_funcinfo<<m_name<<endl;
        ec += it.current()->plannedPrDay(start, end);
    }
    return ec;
}

Duration Schedule::plannedEffort() const {
   //kdDebug()<<k_funcinfo<<endl;
    Duration eff;
    TQPtrListIterator<Appointment> it(m_appointments);
    for (; it.current(); ++it) {
        eff += it.current()->plannedEffort();
    }
    return eff;
}

Duration Schedule::plannedEffort(const TQDate &date) const {
   //kdDebug()<<k_funcinfo<<endl;
    Duration eff;
    TQPtrListIterator<Appointment> it(m_appointments);
    for (; it.current(); ++it) {
        eff += it.current()->plannedEffort(date);
    }
    return eff;
}

Duration Schedule::plannedEffortTo(const TQDate &date) const {
    //kdDebug()<<k_funcinfo<<endl;
    Duration eff;
    TQPtrListIterator<Appointment> it(m_appointments);
    for (; it.current(); ++it) {
        eff += it.current()->plannedEffortTo(date);
    }
    return eff;
}

Duration Schedule::actualEffort() const {
    //kdDebug()<<k_funcinfo<<endl;
    Duration eff;
    TQPtrListIterator<Appointment> it(m_appointments);
    for (; it.current(); ++it) {
        eff += it.current()->actualEffort();
    }
    return eff;
}

Duration Schedule::actualEffort(const TQDate &date) const {
    //kdDebug()<<k_funcinfo<<endl;
    Duration eff;
    TQPtrListIterator<Appointment> it(m_appointments);
    for (; it.current(); ++it) {
        eff += it.current()->actualEffort(date);
    }
    return eff;
}

Duration Schedule::actualEffortTo(const TQDate &date) const {
    //kdDebug()<<k_funcinfo<<endl;
    Duration eff;
    TQPtrListIterator<Appointment> it(m_appointments);
    for (; it.current(); ++it) {
        eff += it.current()->actualEffortTo(date);
    }
    return eff;
}

double Schedule::plannedCost() const {
    //kdDebug()<<k_funcinfo<<endl;
    double c = 0;
    TQPtrListIterator<Appointment> it(m_appointments);
    for (; it.current(); ++it) {
        c += it.current()->plannedCost();
    }
    return c;
}

double Schedule::plannedCost(const TQDate &date) const {
    //kdDebug()<<k_funcinfo<<endl;
    double c = 0;
    TQPtrListIterator<Appointment> it(m_appointments);
    for (; it.current(); ++it) {
        c += it.current()->plannedCost(date);
    }
    return c;
}

double Schedule::plannedCostTo(const TQDate &date) const {
    //kdDebug()<<k_funcinfo<<endl;
    double c = 0;
    TQPtrListIterator<Appointment> it(m_appointments);
    for (; it.current(); ++it) {
        c += it.current()->plannedCostTo(date);
    }
    return c;
}

double Schedule::actualCost() const {
    //kdDebug()<<k_funcinfo<<endl;
    double c = 0;
    TQPtrListIterator<Appointment> it(m_appointments);
    for (; it.current(); ++it) {
        c += it.current()->actualCost();
    }
    return c;
}

double Schedule::actualCost(const TQDate &date) const {
    //kdDebug()<<k_funcinfo<<endl;
    double c = 0;
    TQPtrListIterator<Appointment> it(m_appointments);
    for (; it.current(); ++it) {
        c += it.current()->actualCost(date);
    }
    return c;
}

double Schedule::actualCostTo(const TQDate &date) const {
    //kdDebug()<<k_funcinfo<<endl;
    double c = 0;
    TQPtrListIterator<Appointment> it(m_appointments);
    for (; it.current(); ++it) {
        c += it.current()->actualCostTo(date);
    }
    return c;
}

//-------------------------------------------------
NodeSchedule::NodeSchedule()
    : Schedule(),
      m_node(0) {
    //kdDebug()<<k_funcinfo<<"("<<this<<")"<<endl;
    init();
}

NodeSchedule::NodeSchedule(Node *node, TQString name, Schedule::Type type, long id)
    : Schedule(name, type, id),
      m_node(node) {
    //kdDebug()<<k_funcinfo<<"node name: "<<node->name()<<endl;
    init();
}

NodeSchedule::NodeSchedule(Schedule *parent, Node *node)
    : Schedule(parent),
      m_node(node) {
    
    //kdDebug()<<k_funcinfo<<"node name: "<<node->name()<<endl;
    init();
}

NodeSchedule::~NodeSchedule() {
    //kdDebug()<<k_funcinfo<<"("<<this<<")"<<endl;
}

void NodeSchedule::init() {
    resourceError = false;
    resourceOverbooked = false;
    resourceNotAvailable = false;
    schedulingError = false;
    notScheduled = true;
    inCriticalPath = false;
}

void NodeSchedule::setDeleted(bool on) {
    //kdDebug()<<k_funcinfo<<"deleted="<<on<<endl;
    m_deleted = on;
    // set deleted also for possible resource schedules
    TQPtrListIterator<Appointment> it = m_appointments;
    for (; it.current(); ++it) {
        if (it.current()->resource()) {
            it.current()->resource()->setDeleted(on);
        }
    }
}

bool NodeSchedule::loadXML(const TQDomElement &sch) {
    //kdDebug()<<k_funcinfo<<endl;
    TQString s;
    Schedule::loadXML(sch);
    s = sch.attribute("earlieststart");
    if (s != "")
        earliestStart = DateTime::fromString(s);
    s = sch.attribute("latestfinish");
    if (s != "")
        latestFinish = DateTime::fromString(s);
    s = sch.attribute("start");
    if (s != "")
        startTime = DateTime::fromString(s);
    s = sch.attribute("end");
    if (s != "")
        endTime = DateTime::fromString(s);
    s = sch.attribute("start-work");
    if (s != "")
        workStartTime = DateTime::fromString(s);
    s = sch.attribute("end-work");
    if (s != "")
        workEndTime = DateTime::fromString(s);
    duration = Duration::fromString(sch.attribute("duration"));
    
    inCriticalPath = sch.attribute("in-critical-path", "0").toInt();
    resourceError = sch.attribute("resource-error", "0").toInt();
    resourceOverbooked = sch.attribute("resource-overbooked", "0").toInt();
    resourceNotAvailable = sch.attribute("resource-not-available", "0").toInt();
    schedulingError = sch.attribute("scheduling-conflict", "0").toInt();
    notScheduled = sch.attribute("not-scheduled", "1").toInt();

    return true;
}

void NodeSchedule::saveXML(TQDomElement &element) const {
    //kdDebug()<<k_funcinfo<<endl;
    TQDomElement sch = element.ownerDocument().createElement("schedule");
    element.appendChild(sch);
    saveCommonXML(sch);
    
    if (earliestStart.isValid())
        sch.setAttribute("earlieststart",earliestStart.toString(Qt::ISODate));
    if (latestFinish.isValid())
        sch.setAttribute("latestfinish",latestFinish.toString(Qt::ISODate));
    if (startTime.isValid())
        sch.setAttribute("start",startTime.toString(Qt::ISODate));
    if (endTime.isValid())
        sch.setAttribute("end",endTime.toString(Qt::ISODate));
    if (workStartTime.isValid())
        sch.setAttribute("start-work", workStartTime.toString(Qt::ISODate));
    if (workEndTime.isValid())
        sch.setAttribute("end-work", workEndTime.toString(Qt::ISODate));
    
    sch.setAttribute("duration",duration.toString());

    sch.setAttribute("in-critical-path",inCriticalPath);
    sch.setAttribute("resource-error",resourceError);
    sch.setAttribute("resource-overbooked",resourceOverbooked);
    sch.setAttribute("resource-not-available",resourceNotAvailable);
    sch.setAttribute("scheduling-conflict",schedulingError);
    sch.setAttribute("not-scheduled",notScheduled);
}

void NodeSchedule::addAppointment(Schedule *resource, DateTime &start, DateTime &end, double load) {
    //kdDebug()<<k_funcinfo<<endl;
    Appointment *a = findAppointment(resource, this);
    if (a != 0) {
        //kdDebug()<<k_funcinfo<<"Add interval"<<endl;
        a->addInterval(start, end, load);
        return;
    }
    a = new Appointment(resource, this, start, end, load);
    if (!add(a)) {
        delete a;
    }
    if (!resource->add(a)) {
        delete a;
    }
}

//-----------------------------------------------
ResourceSchedule::ResourceSchedule()
    : Schedule(),
      m_resource(0) {
    //kdDebug()<<k_funcinfo<<"("<<this<<")"<<endl;
}

ResourceSchedule::ResourceSchedule(Resource *resource, TQString name, Schedule::Type type, long id)
    : Schedule(name, type, id),
      m_resource(resource),
      m_parent(0) {
    //kdDebug()<<k_funcinfo<<"resource: "<<resource->name()<<endl;
}

ResourceSchedule::ResourceSchedule(Schedule *parent, Resource *resource)
    : Schedule(parent),
      m_resource(resource),
      m_parent(parent) {
    //kdDebug()<<k_funcinfo<<"resource: "<<resource->name()<<endl;
}

ResourceSchedule::~ResourceSchedule() {
    //kdDebug()<<k_funcinfo<<"("<<this<<")"<<endl;
}

void ResourceSchedule::addAppointment(Schedule *node, DateTime &start, DateTime &end, double load) {
    //kdDebug()<<k_funcinfo<<endl;
    Appointment *a = findAppointment(this, node);
    if (a != 0) {
        //kdDebug()<<k_funcinfo<<"Add interval"<<endl;
        a->addInterval(start, end, load);
        return;
    }
    a = new Appointment(this, node, start, end, load);
    if (!add(a)) {
        delete a;
    }
    if (!node->add(a)) {
        delete a;
    }
}

bool ResourceSchedule::isOverbooked() const {
    return false;
}

bool ResourceSchedule::isOverbooked(const DateTime &start, const DateTime &end) const {
    if (m_resource == 0)
        return false;
    //kdDebug()<<k_funcinfo<<start.toString()<<" - "<<end.toString()<<endl;
    Appointment a = appointmentIntervals();
    TQPtrListIterator<AppointmentInterval> it = a.intervals();
    for (; it.current(); ++it) {
        if ((!end.isValid() || it.current()->startTime() < end) && 
            (!start.isValid() || it.current()->endTime() > start)) 
        {
            if (it.current()->load() > m_resource->units()) {
                //kdDebug()<<k_funcinfo<<m_name<<" overbooked"<<endl;
                return true;
            }
        }
        if (it.current()->startTime() >= end)
            break;
    }
    //kdDebug()<<k_funcinfo<<m_name<<" not overbooked"<<endl;
    return false; 
}

Appointment ResourceSchedule::appointmentIntervals() const {
    Appointment a;
    TQPtrListIterator<Appointment> it = m_appointments;
    for (; it.current(); ++it) {
        a += *(it.current());
    }
    return a;
}

double ResourceSchedule::normalRatePrHour() const {
    return m_resource ? m_resource->normalRate() : 0.0;
}

//--------------------------------------
MainSchedule::MainSchedule()
    : NodeSchedule() {
    //kdDebug()<<k_funcinfo<<"("<<this<<")"<<endl;
    init();
}

MainSchedule::MainSchedule(Node *node, TQString name, Schedule::Type type, long id)
    : NodeSchedule(node, name, type, id) {
    //kdDebug()<<k_funcinfo<<"node name: "<<node->name()<<endl;
    init();
}

MainSchedule::~MainSchedule() {
    //kdDebug()<<k_funcinfo<<"("<<this<<")"<<endl;
}

bool MainSchedule::loadXML(const TQDomElement &sch, Project &project) {
    kdDebug()<<k_funcinfo<<endl;
    TQString s;
    Schedule::loadXML(sch);
    
    s = sch.attribute("start");
    if (s != "")
        startTime = DateTime::fromString(s);
    s = sch.attribute("end");
    if (s != "")
        endTime = DateTime::fromString(s);
    
    TQDomNodeList al = sch.childNodes();
    kdDebug()<<k_funcinfo<<"No of appointments: "<<al.count()<<endl;
    for (unsigned int i=0; i<al.count(); ++i) {
        if (al.item(i).isElement()) {
            TQDomElement app = al.item(i).toElement();
            if (app.tagName() == "appointment") {
                // Load the appointments. 
                // Resources and tasks must allready loaded
                Appointment *child = new Appointment();
                if (!child->loadXML(app, project, *this)) {
                    // TODO: Complain about this
                    kdError()<<k_funcinfo<<"Failed to load appointment"<<endl;
                    delete child;
                }
            }
        }
    }
    return true;
}

void MainSchedule::saveXML(TQDomElement &element) const {
    saveCommonXML(element);
    
    element.setAttribute("start",startTime.toString(Qt::ISODate));
    element.setAttribute("end",endTime.toString(Qt::ISODate));
}

#ifndef NDEBUG
void Schedule::printDebug(TQString indent) {
    kdDebug()<<indent<<"Schedule["<<m_id<<"] '"<<m_name<<"' type: "<<typeToString()<<" ("<<m_type<<")"<<(isDeleted()?"   Deleted":"")<<endl;
}
void NodeSchedule::printDebug(TQString indent) {
    Schedule::printDebug(indent);
    indent += "!  ";
    if (m_parent == 0)
        kdDebug()<<indent<<"No parent schedule!"<<endl;
    if (!notScheduled) {
        if (node()) kdDebug()<<indent<<"Node: "<<node()->name()<<endl;
        else kdDebug()<<indent<<"No parent node!"<<endl;
    }
    kdDebug()<<indent<<"Not scheduled="<<notScheduled<<endl;
    kdDebug()<<indent<<"Start time: "<<startTime.toString()<<endl;
    kdDebug()<<indent<<"End time: " <<endTime.toString()<<endl;
    kdDebug()<<indent<<"Duration: "<<duration.seconds()<<TQCString(" secs")<<" ("<<duration.toString()<<")"<<endl;
    kdDebug()<<indent<<"Earliest start: "<<earliestStart.toString()<<endl;
    kdDebug()<<indent<<"Latest finish: " <<latestFinish.toString()<<endl;

    kdDebug()<<indent<<"resourceError="<<resourceError<<endl;
    kdDebug()<<indent<<"schedulingError="<<schedulingError<<endl;
    kdDebug()<<indent<<"resourceNotAvailable="<<resourceNotAvailable<<endl;
    kdDebug()<<indent<<"Resource overbooked="<<resourceOverbooked<<endl;
    kdDebug()<<indent<<"  "<<overbookedResources()<<endl;

    kdDebug()<<indent<<"inCriticalPath="<<inCriticalPath<<endl;
    kdDebug()<<indent<<endl;
    kdDebug()<<indent<<"workStartTime="<<workStartTime.toString()<<endl;
    kdDebug()<<indent<<"workEndTime="<<workEndTime.toString()<<endl;
    kdDebug()<<indent<<endl;
    kdDebug()<<indent<<"Appointments: "<<m_appointments.count()<<endl;
    TQPtrListIterator<Appointment> it = m_appointments;
    for (; it.current(); ++it) {
        it.current()->printDebug(indent + "  ");
    }
}
void ResourceSchedule::printDebug(TQString indent) {
    Schedule::printDebug(indent);
    indent += "!  ";
    if (m_parent == 0)
        kdDebug()<<indent<<"No parent schedule!"<<endl;
    if (resource()) kdDebug()<<indent<<"Resource: "<<resource()->name()<<endl;
    else kdDebug()<<indent<<"No parent resource!"<<endl;
    kdDebug()<<indent<<endl;
    kdDebug()<<indent<<"Appointments: "<<m_appointments.count()<<endl;
}

void MainSchedule::printDebug(TQString indent) {
    Schedule::printDebug(indent);
    indent += "!  ";
    if (node()) kdDebug()<<indent<<"Node: "<<node()->name()<<endl;
    else kdDebug()<<indent<<"No parent node!"<<endl;
    
    kdDebug()<<indent<<"Not scheduled="<<notScheduled<<endl;
    kdDebug()<<indent<<"Start time: "<<startTime.toString()<<endl;
    kdDebug()<<indent<<"End time: " <<endTime.toString()<<endl;
    kdDebug()<<indent<<"Duration: "<<duration.seconds()<<TQCString(" secs")<<" ("<<duration.toString()<<")"<<endl;
    kdDebug()<<indent<<"Earliest start: "<<earliestStart.toString()<<endl;
    kdDebug()<<indent<<"Latest finish: " <<latestFinish.toString()<<endl;

    kdDebug()<<indent<<endl;
    kdDebug()<<indent<<"Appointments: "<<m_appointments.count()<<endl;
    TQPtrListIterator<Appointment> it = m_appointments;
    for (; it.current(); ++it) {
        it.current()->printDebug(indent + "  ");
    }
}
#endif

} //namespace KPlato