summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/opimbackendoccurrence.cpp
blob: 8af930d227f96f93cccdddcdfb14c31333a7b026 (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
/*
                             This file is part of the Opie Project
                             Copyright (C) 2004 Holger Hans Peter Freyther <zecke@handhelds.org>
              =.             Copyright (C) The Opie Team <opie-devel@handhelds.org>
            .=l.
           .>+-=
 _;:,     .>    :=|.         This program is free software; you can
.> <`_,   >  .   <=          redistribute it and/or  modify it under
:`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
.="- .-=="i,     .._         License as published by the Free Software
 - .   .-<_>     .<>         Foundation; either version 2 of the License,
     ._= =}       :          or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s.       This program 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.
*/

#include "opimbackendoccurrence.h"

namespace Opie {

OPimBackendOccurrence::OPimBackendOccurrence() {}
/**
 * \brief The occurence is only on the specefic Day
 *
 * If an occurrence is only a day without any time associated
 * use this Constructor.
 * \sa timeAssociated() will return false.
 *
 * @param date The Date this Occurence takes place
 * @param  uid The \sa UID of the associated OPimRecord
 * @param  sum The optional summary
 *
 */
OPimBackendOccurrence::OPimBackendOccurrence( const QDate& date,
                                              const UID& uid,
                                              const QString& sum )
    : m_start( date ), m_end( date ), m_uid( uid ),
      m_haveTime(false ), m_summary( sum )
{}

/**
 * \brief An Occurrence with a start day and end day without time
 *
 * Overloaded Constructor. Use this if you've a start date and
 * end date but no time. If you need to overwrite the summary
 * use setSummary.
 * \sa timeAssociated() will return false.
 *
 * @param date The Start Date
 * @param  end Tne End Date
 * @param  uid The UID of the associated record
 *
 * @see setSummary
 */
OPimBackendOccurrence::OPimBackendOccurrence( const QDate& date,
                                              const QDate& end,
                                              const UID& uid)
    : m_start( date ), m_end( end ), m_uid( uid ), m_haveTime( false )
{}


/**
 * \brief Use Start and End Date with Time
 *
 * Overloaded Constructor to use Dates with Time time associated
 * to it. \sa timeAssociated() will return true.
 *
 * @param date The Start Date and Time of the occurrence
 * @param  end The End   Date and Time of the occurrence
 * @param  uid The UID of the \sa OPimRecord.
 */
OPimBackendOccurrence::OPimBackendOccurrence( const QDateTime& date,
                                              const QDateTime& end,
                                              const UID& uid )
    : m_start( date ), m_end( end ), m_uid( uid ), m_haveTime( true )
{}

/**
 * \brief Return the Start Date and Time
 *
 * @return This method will return the start
 *  Date and Time. Time is only valid if
 *  \sa timeAssociated() is true.
 *
 */
QDateTime OPimBackendOccurrence::startDateTime()const {
    return m_start;
}

/**
 * \brief Return the Start Date and Time
 *
 * @return This will return the end Date and Time. The
 * limitation for Time is the same as in startDateTime
 *
 * @see startDateTime()
 */
QDateTime OPimBackendOccurrence::endDateTime()const {
    return m_end;
}

/**
 * \brief Return the UID of the Associated OPimRecord
 *
 * @return the associated OPimRecord
 */
UID OPimBackendOccurrence::uid()const {
    return m_uid;
}

/**
 * \brief Return if there is a time associated or not
 *
 * If a time is present with start and end date this method
 * will return true. There is no direct way to manipulate
 * that attribute. But \sa setStartDate and \sa setStartDateTime
 * will change it.
 *
 * @return Return true if a time is available with the date
 *
 */
bool OPimBackendOccurrence::isAllDay()const {
    return m_haveTime;
}

/**
 * @return The special summary that will overwrite OPimRecord::summary
 */
QString OPimBackendOccurrence::summary()const {
    return m_summary;
}

QString OPimBackendOccurrence::location()const {
    return m_location;
}

QString OPimBackendOccurrence::note()const {
    return m_note;
}

/**
 * \brief Set the Start Date
 *
 * This method will set the start date and internally will mark
 * this occurrence to have no time associated to both start
 * and end date.
 * A call to timeAssociated will return false after using this
 * method.
 *
 * @param start The Start Date
 *
 */
void OPimBackendOccurrence::setStartDate( const QDate& start) {
    m_start = start;
    m_haveTime = false;
}

/**
 * \brief Set the Start Date and Time
 *
 * Set the Start Date and Time. After this call
 * \sa timeAssociated will return true.
 *
 * @param  dt The Start Date and Time to be set
 */
void OPimBackendOccurrence::setStartDateTime( const QDateTime& dt ) {
    m_start = dt;
    m_haveTime = true;
}

/**
 * \brief This will set the End Date.
 *
 * This method will set the End Date. The timeAssociated attribute
 * will not be changed.
 *
 * @param  end The End Date to be set
 */
void OPimBackendOccurrence::setEndDate( const QDate& end ) {
    m_end = end;
}

/**
 * \brief Set the End  Date and Time of the occurrence
 *
 * This will set the End Date and Time but will not change
 * the timeAssociated attribute.
 *
 * @param dt The End Date and Time to be set.
 */
void OPimBackendOccurrence::setEndDateTime( const QDateTime& dt ) {
    m_end = dt;
}

/**
 * \brief This method will set the UID of the Record
 *
 * Set the UID of the OPimRecord to be associated with
 * this OPimRecurrence.
 *
 * @param uid The UID of the associated OPimRecord to be set
 */
void OPimBackendOccurrence::setUid( const UID& uid ) {
    m_uid = uid;
}


/**
 * \brief Set a special summary instead of \sa OPimRecord::summary()
 *
 * If \sa OPimRecord::summary() doesn't describe the occurrence
 * reason you can set a custom summary for the Occurrence.
 *
 * @param str The to be set Summary
 */
void OPimBackendOccurrence::setSummary( const QString& str ) {
    m_summary = str;
}

void OPimBackendOccurrence::setLocation( const QString& str ) {
    m_location = str;
}

void OPimBackendOccurrence::setNote( const QString& str ) {
    m_note = str;
}

}