summaryrefslogtreecommitdiffabout
path: root/libkcal/todo.h
blob: a22d4b7d9b21127c1b0fe4484bb27759cdd25364 (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
/*
    This file is part of libkcal.
    Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>

    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; either
    version 2 of the License, or (at your option) any later version.

    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., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
#ifndef TODO_H
#define TODO_H
//
// Todo component, representing a VTODO object
//

#include "incidence.h"

namespace KCal {

/**
  This class provides a Todo in the sense of RFC2445.
*/
class Todo : public Incidence
{
  public:
    Todo();
    Todo(const Todo &);
    ~Todo();
    typedef ListBase<Todo> List;
    QCString type() const { return "Todo"; }

    /** Return an exact copy of this todo. */
    Incidence *clone();
    QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const;

    /** for setting the todo's due date/time with a QDateTime. */
    void setDtDue(const QDateTime &dtDue);
    /** returns an event's Due date/time as a QDateTime. */
    QDateTime dtDue() const;
    /** returns an event's due time as a string formatted according to the
     users locale settings */
    QString dtDueTimeStr() const;
    /** returns an event's due date as a string formatted according to the
     users locale settings */
    QString dtDueDateStr(bool shortfmt=true) const;
    /** returns an event's due date and time as a string formatted according
     to the users locale settings */
    QString dtDueStr(bool shortfmt=true) const;

    /** returns TRUE or FALSE depending on whether the todo has a due date */
    bool hasDueDate() const;
    /** sets the event's hasDueDate value. */
    void setHasDueDate(bool f);

    /*
      Looks for a subtodo (including itself ) which is not complete and is
      - overdue, or
      - due today.
      It returns 0 for nothing found,
      1 for found a todo which is due today and no overdue found
      2 for found a overdue todo
    */
    int hasDueSubTodo( bool checkSubtodos = true );
    /* same as above, but a specific date can be specified*/
    int hasDueSubTodoForDate( const  QDate & date, bool checkSubtodos );

 
    /** sets the event's status to the string specified.  The string
     * must be a recognized value for the status field, i.e. a string
     * equivalent of the possible status enumerations previously described. */
//    void setStatus(const QString &statStr);
    /** sets the event's status to the value specified.  See the enumeration
     * above for possible values. */
//    void setStatus(int);
    /** return the event's status. */
//    int status() const;
    /** return the event's status in string format. */
//    QString statusStr() const;

    /** return, if this todo is completed */
    bool isCompleted() const;
    /** set completed state of this todo */
    void setCompleted(bool);
    
    /**
      Return how many percent of the task are completed. Returns a value
      between 0 and 100.
    */
    int percentComplete() const;
    /**
      Set how many percent of the task are completed. Valid values are in the
      range from 0 to 100.
    */
    void setPercentComplete(int);

    /** return date and time when todo was completed */
    QDateTime completed() const;
    QString completedStr(bool shortF = true) const;
    /** set date and time of completion */
    void setCompleted(const QDateTime &completed);

    /** Return true, if todo has a date associated with completion */
    bool hasCompletedDate() const;
    bool contains ( Todo*);
    void checkSetCompletedFalse();
    bool setRecurDates();
    
  private:
    bool accept(Visitor &v) { return v.visit(this); }

    QDateTime mDtDue;                     // due date of todo

    bool mHasDueDate;                    // if todo has associated due date

//    int  mStatus;                         // confirmed/delegated/tentative/etc

    QDateTime mCompleted;
    bool mHasCompletedDate;

    int mPercentComplete;
};

    bool operator==( const Todo&, const Todo& );
}

#endif