Diffstat (limited to 'libopie2/opiepim/core/opimoccurrence.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimoccurrence.h | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/libopie2/opiepim/core/opimoccurrence.h b/libopie2/opiepim/core/opimoccurrence.h new file mode 100644 index 0000000..902638b --- a/dev/null +++ b/libopie2/opiepim/core/opimoccurrence.h | |||
@@ -0,0 +1,142 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) 2003, 2004 Holger Freyther <zecke@handhelds.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | |||
30 | #ifndef OPIE_PIM_OCCURRENCE_H | ||
31 | #define OPIE_PIM_OCCURRENCE_H | ||
32 | |||
33 | #include <opie2/osharedpointer.h> | ||
34 | #include <opie2/opimrecord.h> | ||
35 | #include <opie2/opimevent.h> | ||
36 | #include <opie2/opimtodo.h> | ||
37 | #include <opie2/opimcontact.h> | ||
38 | |||
39 | #include <qdatetime.h> | ||
40 | #include <qstringlist.h> | ||
41 | |||
42 | namespace Opie { | ||
43 | |||
44 | template<class T> class OPimAccessTemplate; | ||
45 | /** | ||
46 | * \brief An OPimOccurrence represents a occurence for one day of a OPimRecord | ||
47 | * | ||
48 | * An OPimOccurrence represents the occurrence of one OPimRecord | ||
49 | * for a period of Time for one day. An occurrence can spawn | ||
50 | * more then one day and then is splitted into multiple OPimOccurrence. | ||
51 | * By attributes you can find if a OPimOccurrence is the beginning and | ||
52 | * end, begin, end or is midway of a multiday occurrence. | ||
53 | * | ||
54 | */ | ||
55 | class OPimOccurrence { | ||
56 | friend class OPimBase; | ||
57 | public: | ||
58 | typedef QValueList<OPimOccurrence> List; | ||
59 | /** | ||
60 | * The position of the OPimOccurrence in a possible | ||
61 | * MultiDay Occurrence. | ||
62 | */ | ||
63 | enum Position { | ||
64 | MidWay, /* This OPimOccurrence is somewhere in between Start and End */ | ||
65 | Start, /* This OPimOccurrence is the Start of a multi day Occurrence */ | ||
66 | End, /* This OPimOccurrence is the End of a multi day Occurrence */ | ||
67 | StartEnd /* This OPimOccurrence only spans one day */ | ||
68 | }; | ||
69 | |||
70 | //@{ | ||
71 | OPimOccurrence(); | ||
72 | OPimOccurrence( const OPimOccurrence& ); | ||
73 | ~OPimOccurrence(); | ||
74 | //@} | ||
75 | |||
76 | //@{ | ||
77 | void setPeriod( const QDate& from ); | ||
78 | void setPeriod( const QDateTime& from, const QDateTime& to ); | ||
79 | void setPeriod( const QDate& from, const QTime& start, const QTime& end ); | ||
80 | //@} | ||
81 | |||
82 | //@{ | ||
83 | bool isAllDay()const; | ||
84 | QDate date()const; | ||
85 | QTime startTime()const; | ||
86 | QTime endTime()const; | ||
87 | QDateTime startDateTime()const; | ||
88 | QDateTime endDateTime()const; | ||
89 | //@} | ||
90 | |||
91 | //@{ | ||
92 | QString summary()const; | ||
93 | QString location()const; | ||
94 | QString note()const; | ||
95 | //@} | ||
96 | |||
97 | //@{ | ||
98 | int length()const; | ||
99 | Position position()const; | ||
100 | void setPosition( enum Position& ); | ||
101 | //@} | ||
102 | |||
103 | //@{ | ||
104 | Opie::Core::OSharedPointer<OPimRecord> record()const; | ||
105 | OPimEvent toEvent()const; | ||
106 | OPimTodo toTodo()const; | ||
107 | OPimContact toContact()const; | ||
108 | //@} | ||
109 | |||
110 | |||
111 | //@{ | ||
112 | bool operator< ( const OPimOccurrence& )const; | ||
113 | bool operator<=( const OPimOccurrence& )const; | ||
114 | bool operator==( const OPimOccurrence& )const; | ||
115 | bool operator!=( const OPimOccurrence& )const; | ||
116 | bool operator> ( const OPimOccurrence& )const; | ||
117 | bool operator>=( const OPimOccurrence& )const; | ||
118 | OPimOccurrence &operator=( const OPimOccurrence& ); | ||
119 | //@} | ||
120 | |||
121 | private: | ||
122 | QDate m_occurrence; | ||
123 | QTime m_start, m_end; | ||
124 | bool m_isAllDay : 1; | ||
125 | enum Position m_pos; | ||
126 | |||
127 | void deref(); | ||
128 | inline void changeOrModify(); | ||
129 | |||
130 | struct Private; | ||
131 | struct Data; | ||
132 | |||
133 | Data *data; | ||
134 | Private *d; | ||
135 | |||
136 | private: // ctor | ||
137 | OPimOccurrence( OPimOccurrence::Data *, enum Position ); | ||
138 | template<class T> T internalToRecord()const; | ||
139 | }; | ||
140 | } | ||
141 | |||
142 | #endif | ||