File: VacationList.cpp

package info (click to toggle)
taskjuggler 2.3.0-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 8,764 kB
  • ctags: 3,700
  • sloc: cpp: 36,852; sh: 12,761; xml: 5,541; perl: 5,207; makefile: 269; python: 258; lisp: 67
file content (63 lines) | stat: -rw-r--r-- 1,438 bytes parent folder | download
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
/*
 * VacationList.cpp - TaskJuggler
 *
 * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger <cs@kde.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * $Id: VacationList.cpp 1310 2006-07-20 14:24:09Z cs $
 */

#include "VacationList.h"
#include "VacationInterval.h"

void
VacationList::add(const QString& name, const Interval& i)
{
    inSort(new VacationInterval(name, i));
}

void
VacationList::add(VacationInterval* vi)
{
    inSort(vi);
}

int
VacationList::compareItems(QCollection::Item it1, QCollection::Item it2)
{
    Interval* i1 = static_cast<Interval*>(it1);
    Interval* i2 = static_cast<Interval*>(it2);

    if (i1->getStart() == i2->getStart())
    {
        if (i1->getEnd() == i2->getEnd())
            return 0;
        else
            return i2->getEnd() - i1->getEnd();
    }
    else
        return i2->getStart() - i1->getStart();
}

bool
VacationList::isVacation(time_t date) const
{
    for (VacationListIterator vli(*this); *vli != 0; ++vli)
        if ((*vli)->contains(date))
            return TRUE;

    return FALSE;
}

const QString&
VacationList::vacationName(time_t date) const
{
    for (VacationListIterator vli(*this); *vli != 0; ++vli)
        if ((*vli)->contains(date))
            return (*vli)->getName();

    return QString::null;
}