author | zautrix <zautrix> | 2004-07-10 17:03:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-10 17:03:16 (UTC) |
commit | cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef (patch) (unidiff) | |
tree | 963322cd4c539c084feb43dfde5eabe52ae4385f | |
parent | 8cc6d456812b5a9a386e81c9e46baccd56029537 (diff) | |
download | kdepimpi-cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef.zip kdepimpi-cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef.tar.gz kdepimpi-cf2f3f98a4811668f9e9d0d5f44ea5b51d268cef.tar.bz2 |
Fixed some problems with the recurrence
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 125 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.h | 9 | ||||
-rw-r--r-- | libkcal/icalformatimpl.cpp | 20 | ||||
-rw-r--r-- | libkcal/recurrence.cpp | 17 | ||||
-rw-r--r-- | libkcal/recurrence.h | 6 |
5 files changed, 110 insertions, 67 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index 98356fe..ffc0fac 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -115,449 +115,448 @@ RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) : | |||
115 | 115 | ||
116 | QHBox *dayBox = new QHBox( this ); | 116 | QHBox *dayBox = new QHBox( this ); |
117 | topLayout->addWidget( dayBox, 1, AlignVCenter ); | 117 | topLayout->addWidget( dayBox, 1, AlignVCenter ); |
118 | // TODO: Respect start of week setting | 118 | // TODO: Respect start of week setting |
119 | for ( int i = 0; i < 7; ++i ) { | 119 | for ( int i = 0; i < 7; ++i ) { |
120 | QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true ); | 120 | QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true ); |
121 | if ( KOPrefs::instance()->mCompactDialogs ) { | 121 | if ( KOPrefs::instance()->mCompactDialogs ) { |
122 | weekDayName = weekDayName.left( 1 ); | 122 | weekDayName = weekDayName.left( 1 ); |
123 | } | 123 | } |
124 | mDayBoxes[ i ] = new QCheckBox( weekDayName, dayBox ); | 124 | mDayBoxes[ i ] = new QCheckBox( weekDayName, dayBox ); |
125 | } | 125 | } |
126 | 126 | ||
127 | topLayout->addStretch( 1 ); | 127 | topLayout->addStretch( 1 ); |
128 | } | 128 | } |
129 | 129 | ||
130 | void RecurWeekly::setDays( const QBitArray &days ) | 130 | void RecurWeekly::setDays( const QBitArray &days ) |
131 | { | 131 | { |
132 | for ( int i = 0; i < 7; ++i ) { | 132 | for ( int i = 0; i < 7; ++i ) { |
133 | mDayBoxes[ i ]->setChecked( days.testBit( i ) ); | 133 | mDayBoxes[ i ]->setChecked( days.testBit( i ) ); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | QBitArray RecurWeekly::days() | 137 | QBitArray RecurWeekly::days() |
138 | { | 138 | { |
139 | QBitArray days( 7 ); | 139 | QBitArray days( 7 ); |
140 | 140 | ||
141 | for ( int i = 0; i < 7; ++i ) { | 141 | for ( int i = 0; i < 7; ++i ) { |
142 | days.setBit( i, mDayBoxes[ i ]->isChecked() ); | 142 | days.setBit( i, mDayBoxes[ i ]->isChecked() ); |
143 | } | 143 | } |
144 | 144 | ||
145 | return days; | 145 | return days; |
146 | } | 146 | } |
147 | 147 | ||
148 | /////////////////////////// RecurMonthly /////////////////////////////// | 148 | /////////////////////////// RecurMonthly /////////////////////////////// |
149 | 149 | ||
150 | RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) : | 150 | RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) : |
151 | RecurBase( parent, name ) | 151 | RecurBase( parent, name ) |
152 | { | 152 | { |
153 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 153 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
154 | topLayout->setSpacing( KDialog::spacingHint() ); | 154 | topLayout->setSpacing( KDialog::spacingHint() ); |
155 | 155 | ||
156 | 156 | ||
157 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); | 157 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); |
158 | 158 | ||
159 | QLabel *preLabel = new QLabel( i18n("every"), this ); | 159 | QLabel *preLabel = new QLabel( i18n("every"), this ); |
160 | freqLayout->addWidget( preLabel ); | 160 | freqLayout->addWidget( preLabel ); |
161 | 161 | ||
162 | freqLayout->addWidget( frequencyEdit() ); | 162 | freqLayout->addWidget( frequencyEdit() ); |
163 | 163 | ||
164 | QLabel *postLabel = new QLabel( i18n("month(s)"), this ); | 164 | QLabel *postLabel = new QLabel( i18n("month(s)"), this ); |
165 | freqLayout->addWidget( postLabel ); | 165 | freqLayout->addWidget( postLabel ); |
166 | 166 | ||
167 | 167 | ||
168 | QButtonGroup *buttonGroup = new QButtonGroup( this ); | 168 | QButtonGroup *buttonGroup = new QButtonGroup( this ); |
169 | buttonGroup->setFrameStyle( QFrame::NoFrame ); | 169 | buttonGroup->setFrameStyle( QFrame::NoFrame ); |
170 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); | 170 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); |
171 | 171 | ||
172 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); | 172 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); |
173 | buttonLayout->setSpacing( KDialog::spacingHint() ); | 173 | buttonLayout->setSpacing( KDialog::spacingHint() ); |
174 | 174 | ||
175 | 175 | ||
176 | QString recurOnText; | 176 | QString recurOnText; |
177 | if ( !KOPrefs::instance()->mCompactDialogs ) { | 177 | if ( !KOPrefs::instance()->mCompactDialogs ) { |
178 | recurOnText = i18n("Recur on the"); | 178 | recurOnText = i18n("Recur on the"); |
179 | } | 179 | } |
180 | 180 | ||
181 | mByDayRadio = new QRadioButton( recurOnText, buttonGroup ); | 181 | mByDayRadio = new QRadioButton( recurOnText, buttonGroup ); |
182 | buttonLayout->addWidget( mByDayRadio, 0, 0 ); | 182 | buttonLayout->addWidget( mByDayRadio, 0, 0 ); |
183 | 183 | ||
184 | mByDayCombo = new QComboBox( buttonGroup ); | 184 | mByDayCombo = new QComboBox( buttonGroup ); |
185 | mByDayCombo->setSizeLimit( 7 ); | 185 | mByDayCombo->setSizeLimit( 7 ); |
186 | mByDayCombo->insertItem( i18n("1st") ); | 186 | mByDayCombo->insertItem( i18n("1st") ); |
187 | mByDayCombo->insertItem( i18n("2nd") ); | 187 | mByDayCombo->insertItem( i18n("2nd") ); |
188 | mByDayCombo->insertItem( i18n("3rd") ); | 188 | mByDayCombo->insertItem( i18n("3rd") ); |
189 | mByDayCombo->insertItem( i18n("4th") ); | 189 | mByDayCombo->insertItem( i18n("4th") ); |
190 | mByDayCombo->insertItem( i18n("5th") ); | 190 | mByDayCombo->insertItem( i18n("5th") ); |
191 | mByDayCombo->insertItem( i18n("6th") ); | 191 | mByDayCombo->insertItem( i18n("6th") ); |
192 | mByDayCombo->insertItem( i18n("7th") ); | 192 | mByDayCombo->insertItem( i18n("7th") ); |
193 | mByDayCombo->insertItem( i18n("8th") ); | 193 | mByDayCombo->insertItem( i18n("8th") ); |
194 | mByDayCombo->insertItem( i18n("9th") ); | 194 | mByDayCombo->insertItem( i18n("9th") ); |
195 | mByDayCombo->insertItem( i18n("10th") ); | 195 | mByDayCombo->insertItem( i18n("10th") ); |
196 | mByDayCombo->insertItem( i18n("11th") ); | 196 | mByDayCombo->insertItem( i18n("11th") ); |
197 | mByDayCombo->insertItem( i18n("12th") ); | 197 | mByDayCombo->insertItem( i18n("12th") ); |
198 | mByDayCombo->insertItem( i18n("13th") ); | 198 | mByDayCombo->insertItem( i18n("13th") ); |
199 | mByDayCombo->insertItem( i18n("14th") ); | 199 | mByDayCombo->insertItem( i18n("14th") ); |
200 | mByDayCombo->insertItem( i18n("15th") ); | 200 | mByDayCombo->insertItem( i18n("15th") ); |
201 | mByDayCombo->insertItem( i18n("16th") ); | 201 | mByDayCombo->insertItem( i18n("16th") ); |
202 | mByDayCombo->insertItem( i18n("17th") ); | 202 | mByDayCombo->insertItem( i18n("17th") ); |
203 | mByDayCombo->insertItem( i18n("18th") ); | 203 | mByDayCombo->insertItem( i18n("18th") ); |
204 | mByDayCombo->insertItem( i18n("19th") ); | 204 | mByDayCombo->insertItem( i18n("19th") ); |
205 | mByDayCombo->insertItem( i18n("20th") ); | 205 | mByDayCombo->insertItem( i18n("20th") ); |
206 | mByDayCombo->insertItem( i18n("21st") ); | 206 | mByDayCombo->insertItem( i18n("21st") ); |
207 | mByDayCombo->insertItem( i18n("22nd") ); | 207 | mByDayCombo->insertItem( i18n("22nd") ); |
208 | mByDayCombo->insertItem( i18n("23rd") ); | 208 | mByDayCombo->insertItem( i18n("23rd") ); |
209 | mByDayCombo->insertItem( i18n("24th") ); | 209 | mByDayCombo->insertItem( i18n("24th") ); |
210 | mByDayCombo->insertItem( i18n("25th") ); | 210 | mByDayCombo->insertItem( i18n("25th") ); |
211 | mByDayCombo->insertItem( i18n("26th") ); | 211 | mByDayCombo->insertItem( i18n("26th") ); |
212 | mByDayCombo->insertItem( i18n("27th") ); | 212 | mByDayCombo->insertItem( i18n("27th") ); |
213 | mByDayCombo->insertItem( i18n("28th") ); | 213 | mByDayCombo->insertItem( i18n("28th") ); |
214 | mByDayCombo->insertItem( i18n("29th") ); | 214 | mByDayCombo->insertItem( i18n("29th") ); |
215 | mByDayCombo->insertItem( i18n("30th") ); | 215 | mByDayCombo->insertItem( i18n("30th") ); |
216 | mByDayCombo->insertItem( i18n("31st") ); | 216 | mByDayCombo->insertItem( i18n("31st") ); |
217 | buttonLayout->addWidget( mByDayCombo, 0, 1 ); | 217 | buttonLayout->addWidget( mByDayCombo, 0, 1 ); |
218 | 218 | ||
219 | QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup ); | 219 | QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup ); |
220 | buttonLayout->addWidget( byDayLabel, 0, 2 ); | 220 | buttonLayout->addWidget( byDayLabel, 0, 2 ); |
221 | 221 | ||
222 | 222 | ||
223 | mByPosRadio = new QRadioButton( recurOnText, buttonGroup); | 223 | mByPosRadio = new QRadioButton( recurOnText, buttonGroup); |
224 | buttonLayout->addWidget( mByPosRadio, 1, 0 ); | 224 | buttonLayout->addWidget( mByPosRadio, 1, 0 ); |
225 | 225 | ||
226 | mByPosCountCombo = new QComboBox( buttonGroup ); | 226 | mByPosCountCombo = new QComboBox( buttonGroup ); |
227 | mByPosCountCombo->insertItem( i18n("1st") ); | 227 | mByPosCountCombo->insertItem( i18n("1st") ); |
228 | mByPosCountCombo->insertItem( i18n("2nd") ); | 228 | mByPosCountCombo->insertItem( i18n("2nd") ); |
229 | mByPosCountCombo->insertItem( i18n("3rd") ); | 229 | mByPosCountCombo->insertItem( i18n("3rd") ); |
230 | mByPosCountCombo->insertItem( i18n("4th") ); | 230 | mByPosCountCombo->insertItem( i18n("4th") ); |
231 | mByPosCountCombo->insertItem( i18n("5th") ); | 231 | mByPosCountCombo->insertItem( i18n("5th") ); |
232 | buttonLayout->addWidget( mByPosCountCombo, 1, 1 ); | 232 | buttonLayout->addWidget( mByPosCountCombo, 1, 1 ); |
233 | 233 | ||
234 | mByPosWeekdayCombo = new QComboBox( buttonGroup ); | 234 | mByPosWeekdayCombo = new QComboBox( buttonGroup ); |
235 | mByPosWeekdayCombo->insertItem( i18n("Monday") ); | 235 | mByPosWeekdayCombo->insertItem( i18n("Monday") ); |
236 | mByPosWeekdayCombo->insertItem( i18n("Tuesday") ); | 236 | mByPosWeekdayCombo->insertItem( i18n("Tuesday") ); |
237 | mByPosWeekdayCombo->insertItem( i18n("Wednesday") ); | 237 | mByPosWeekdayCombo->insertItem( i18n("Wednesday") ); |
238 | mByPosWeekdayCombo->insertItem( i18n("Thursday") ); | 238 | mByPosWeekdayCombo->insertItem( i18n("Thursday") ); |
239 | mByPosWeekdayCombo->insertItem( i18n("Friday") ); | 239 | mByPosWeekdayCombo->insertItem( i18n("Friday") ); |
240 | mByPosWeekdayCombo->insertItem( i18n("Saturday") ); | 240 | mByPosWeekdayCombo->insertItem( i18n("Saturday") ); |
241 | mByPosWeekdayCombo->insertItem( i18n("Sunday") ); | 241 | mByPosWeekdayCombo->insertItem( i18n("Sunday") ); |
242 | buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 ); | 242 | buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 ); |
243 | } | 243 | } |
244 | 244 | ||
245 | void RecurMonthly::setByDay( int day ) | 245 | void RecurMonthly::setByDay( int day ) |
246 | { | 246 | { |
247 | mByDayRadio->setChecked( true ); | 247 | mByDayRadio->setChecked( true ); |
248 | mByDayCombo->setCurrentItem( day ); | 248 | mByDayCombo->setCurrentItem( day ); |
249 | } | 249 | } |
250 | 250 | ||
251 | void RecurMonthly::setByPos( int count, int weekday ) | 251 | void RecurMonthly::setByPos( int count, int weekday ) |
252 | { | 252 | { |
253 | mByPosRadio->setChecked( true ); | 253 | mByPosRadio->setChecked( true ); |
254 | mByPosCountCombo->setCurrentItem( count ); | 254 | mByPosCountCombo->setCurrentItem( count ); |
255 | mByPosWeekdayCombo->setCurrentItem( weekday ); | 255 | mByPosWeekdayCombo->setCurrentItem( weekday ); |
256 | } | 256 | } |
257 | 257 | ||
258 | bool RecurMonthly::byDay() | 258 | bool RecurMonthly::byDay() |
259 | { | 259 | { |
260 | return mByDayRadio->isChecked(); | 260 | return mByDayRadio->isChecked(); |
261 | } | 261 | } |
262 | 262 | ||
263 | bool RecurMonthly::byPos() | 263 | bool RecurMonthly::byPos() |
264 | { | 264 | { |
265 | return mByPosRadio->isChecked(); | 265 | return mByPosRadio->isChecked(); |
266 | } | 266 | } |
267 | 267 | ||
268 | int RecurMonthly::day() | 268 | int RecurMonthly::day() |
269 | { | 269 | { |
270 | return mByDayCombo->currentItem() + 1; | 270 | return mByDayCombo->currentItem() + 1; |
271 | } | 271 | } |
272 | 272 | ||
273 | int RecurMonthly::count() | 273 | int RecurMonthly::count() |
274 | { | 274 | { |
275 | return mByPosCountCombo->currentItem() + 1; | 275 | return mByPosCountCombo->currentItem() + 1; |
276 | } | 276 | } |
277 | 277 | ||
278 | int RecurMonthly::weekday() | 278 | int RecurMonthly::weekday() |
279 | { | 279 | { |
280 | return mByPosWeekdayCombo->currentItem(); | 280 | return mByPosWeekdayCombo->currentItem(); |
281 | } | 281 | } |
282 | 282 | ||
283 | /////////////////////////// RecurYearly /////////////////////////////// | 283 | /////////////////////////// RecurYearly /////////////////////////////// |
284 | 284 | ||
285 | RecurYearly::RecurYearly( QWidget *parent, const char *name ) : | 285 | RecurYearly::RecurYearly( QWidget *parent, const char *name ) : |
286 | RecurBase( parent, name ) | 286 | RecurBase( parent, name ) |
287 | { | 287 | { |
288 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 288 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
289 | topLayout->setSpacing( KDialog::spacingHint() ); | 289 | topLayout->setSpacing( KDialog::spacingHint() ); |
290 | 290 | ||
291 | 291 | ||
292 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); | 292 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); |
293 | 293 | ||
294 | QLabel *preLabel = new QLabel( i18n("every"), this ); | 294 | QLabel *preLabel = new QLabel( i18n("every"), this ); |
295 | freqLayout->addWidget( preLabel ); | 295 | freqLayout->addWidget( preLabel ); |
296 | 296 | ||
297 | freqLayout->addWidget( frequencyEdit() ); | 297 | freqLayout->addWidget( frequencyEdit() ); |
298 | 298 | ||
299 | QLabel *postLabel = new QLabel( i18n("year(s)"), this ); | 299 | QLabel *postLabel = new QLabel( i18n("year(s)"), this ); |
300 | freqLayout->addWidget( postLabel ); | 300 | freqLayout->addWidget( postLabel ); |
301 | 301 | ||
302 | 302 | ||
303 | QButtonGroup *buttonGroup = new QButtonGroup( this ); | 303 | QButtonGroup *buttonGroup = new QButtonGroup( this ); |
304 | buttonGroup->setFrameStyle( QFrame::NoFrame ); | 304 | buttonGroup->setFrameStyle( QFrame::NoFrame ); |
305 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); | 305 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); |
306 | 306 | ||
307 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); | 307 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 ); |
308 | |||
309 | QString recurInMonthText; | ||
310 | if ( !KOPrefs::instance()->mCompactDialogs ) { | ||
311 | recurInMonthText = i18n("Recur in the month of"); | ||
312 | } | ||
313 | |||
314 | mByMonthRadio = new QRadioButton( recurInMonthText, buttonGroup); | ||
315 | buttonLayout->addWidget( mByMonthRadio, 0, 0 ); | ||
316 | 308 | ||
309 | mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup); | ||
310 | buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight); | ||
311 | mByDayLabel = new QLabel( i18n(" 1 of "), buttonGroup ); | ||
312 | |||
313 | buttonLayout->addWidget( mByDayLabel, 0, 1 ); | ||
317 | mByMonthCombo = new QComboBox( buttonGroup ); | 314 | mByMonthCombo = new QComboBox( buttonGroup ); |
318 | mByMonthCombo->insertItem( i18n("January") ); | 315 | mByMonthCombo->insertItem( i18n("January") ); |
319 | mByMonthCombo->insertItem( i18n("February") ); | 316 | mByMonthCombo->insertItem( i18n("February") ); |
320 | mByMonthCombo->insertItem( i18n("March") ); | 317 | mByMonthCombo->insertItem( i18n("March") ); |
321 | mByMonthCombo->insertItem( i18n("April") ); | 318 | mByMonthCombo->insertItem( i18n("April") ); |
322 | mByMonthCombo->insertItem( i18n("May") ); | 319 | mByMonthCombo->insertItem( i18n("May") ); |
323 | mByMonthCombo->insertItem( i18n("June") ); | 320 | mByMonthCombo->insertItem( i18n("June") ); |
324 | mByMonthCombo->insertItem( i18n("July") ); | 321 | mByMonthCombo->insertItem( i18n("July") ); |
325 | mByMonthCombo->insertItem( i18n("August") ); | 322 | mByMonthCombo->insertItem( i18n("August") ); |
326 | mByMonthCombo->insertItem( i18n("September") ); | 323 | mByMonthCombo->insertItem( i18n("September") ); |
327 | mByMonthCombo->insertItem( i18n("October") ); | 324 | mByMonthCombo->insertItem( i18n("October") ); |
328 | mByMonthCombo->insertItem( i18n("November") ); | 325 | mByMonthCombo->insertItem( i18n("November") ); |
329 | mByMonthCombo->insertItem( i18n("December") ); | 326 | mByMonthCombo->insertItem( i18n("December") ); |
330 | buttonLayout->addWidget( mByMonthCombo, 0, 1 ); | 327 | buttonLayout->addWidget( mByMonthCombo, 0, 2,Qt::AlignLeft ); |
331 | 328 | if ( QApplication::desktop()->width() <= 640 ) { | |
332 | mByMonthCombo->setSizeLimit( 6 ); | 329 | mByMonthCombo->setSizeLimit( 6 ); |
333 | 330 | } | |
334 | buttonLayout->setRowStretch( 1, 1 ); | 331 | |
335 | 332 | mByDayRadio = new QRadioButton( i18n("On day "), buttonGroup); | |
336 | QString recurOnDayText; | 333 | buttonLayout->addWidget( mByDayRadio, 1, 0 , Qt::AlignRight); |
337 | if ( KOPrefs::instance()->mCompactDialogs ) { | 334 | mDayOfLabel = new QLabel( i18n("1 of the year"), buttonGroup ); |
338 | recurOnDayText = i18n("This day"); | 335 | buttonLayout->addMultiCellWidget( mDayOfLabel, 1, 1, 1,3 ); |
339 | } else { | 336 | |
340 | recurOnDayText = i18n("Recur on this day"); | ||
341 | } | ||
342 | |||
343 | mByDayRadio = new QRadioButton( recurOnDayText, buttonGroup); | ||
344 | buttonLayout->addMultiCellWidget( mByDayRadio, 2, 2, 0, 1 ); | ||
345 | } | 337 | } |
346 | 338 | ||
347 | void RecurYearly::setByDay() | 339 | void RecurYearly::setByDay( int doy ) |
348 | { | 340 | { |
349 | mByDayRadio->setChecked( true ); | 341 | mByDayRadio->setChecked( true ); |
342 | mDayOfLabel->setText(i18n("%1 of the year").arg( doy ) ); | ||
350 | } | 343 | } |
351 | 344 | ||
352 | void RecurYearly::setByMonth( int month ) | 345 | void RecurYearly::setByMonth( int month, int day ) |
353 | { | 346 | { |
354 | mByMonthRadio->setChecked( true ); | 347 | mByMonthRadio->setChecked( true ); |
355 | mByMonthCombo->setCurrentItem( month - 1 ); | 348 | mByMonthCombo->setCurrentItem( month - 1 ); |
349 | mByDayLabel->setText(i18n("%1 of ").arg( day ) ); | ||
350 | mDay = day; | ||
356 | } | 351 | } |
357 | 352 | ||
358 | bool RecurYearly::byMonth() | 353 | bool RecurYearly::byMonth() |
359 | { | 354 | { |
360 | return mByMonthRadio->isChecked(); | 355 | return mByMonthRadio->isChecked(); |
361 | } | 356 | } |
362 | 357 | ||
363 | bool RecurYearly::byDay() | 358 | bool RecurYearly::byDay() |
364 | { | 359 | { |
365 | return mByDayRadio->isChecked(); | 360 | return mByDayRadio->isChecked(); |
366 | } | 361 | } |
367 | 362 | ||
368 | int RecurYearly::month() | 363 | int RecurYearly::month() |
369 | { | 364 | { |
370 | return mByMonthCombo->currentItem() + 1; | 365 | return mByMonthCombo->currentItem() + 1; |
371 | } | 366 | } |
367 | int RecurYearly::day() | ||
368 | { | ||
369 | return mDay;//mByDayCombo->currentItem() + 1; | ||
370 | } | ||
372 | 371 | ||
373 | //////////////////////////// ExceptionsWidget ////////////////////////// | 372 | //////////////////////////// ExceptionsWidget ////////////////////////// |
374 | 373 | ||
375 | ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : | 374 | ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : |
376 | QWidget( parent, name ) | 375 | QWidget( parent, name ) |
377 | { | 376 | { |
378 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 377 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
379 | 378 | ||
380 | QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"), | 379 | QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"), |
381 | this ); | 380 | this ); |
382 | topLayout->addWidget( groupBox ); | 381 | topLayout->addWidget( groupBox ); |
383 | 382 | ||
384 | QWidget *box = new QWidget( groupBox ); | 383 | QWidget *box = new QWidget( groupBox ); |
385 | 384 | ||
386 | QGridLayout *boxLayout = new QGridLayout( box ); | 385 | QGridLayout *boxLayout = new QGridLayout( box ); |
387 | 386 | ||
388 | mExceptionDateEdit = new KDateEdit( box ); | 387 | mExceptionDateEdit = new KDateEdit( box ); |
389 | boxLayout->addWidget( mExceptionDateEdit, 0, 0 ); | 388 | boxLayout->addWidget( mExceptionDateEdit, 0, 0 ); |
390 | 389 | ||
391 | QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box ); | 390 | QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box ); |
392 | boxLayout->addWidget( addExceptionButton, 1, 0 ); | 391 | boxLayout->addWidget( addExceptionButton, 1, 0 ); |
393 | QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box ); | 392 | QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box ); |
394 | boxLayout->addWidget( changeExceptionButton, 2, 0 ); | 393 | boxLayout->addWidget( changeExceptionButton, 2, 0 ); |
395 | QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box ); | 394 | QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box ); |
396 | boxLayout->addWidget( deleteExceptionButton, 3, 0 ); | 395 | boxLayout->addWidget( deleteExceptionButton, 3, 0 ); |
397 | 396 | ||
398 | mExceptionList = new QListBox( box ); | 397 | mExceptionList = new QListBox( box ); |
399 | boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 ); | 398 | boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 ); |
400 | 399 | ||
401 | boxLayout->setRowStretch( 4, 1 ); | 400 | boxLayout->setRowStretch( 4, 1 ); |
402 | boxLayout->setColStretch( 1, 3 ); | 401 | boxLayout->setColStretch( 1, 3 ); |
403 | 402 | ||
404 | connect( addExceptionButton, SIGNAL( clicked() ), | 403 | connect( addExceptionButton, SIGNAL( clicked() ), |
405 | SLOT( addException() ) ); | 404 | SLOT( addException() ) ); |
406 | connect( changeExceptionButton, SIGNAL( clicked() ), | 405 | connect( changeExceptionButton, SIGNAL( clicked() ), |
407 | SLOT( changeException() ) ); | 406 | SLOT( changeException() ) ); |
408 | connect( deleteExceptionButton, SIGNAL( clicked() ), | 407 | connect( deleteExceptionButton, SIGNAL( clicked() ), |
409 | SLOT( deleteException() ) ); | 408 | SLOT( deleteException() ) ); |
410 | if ( QApplication::desktop()->width() < 480 ) { | 409 | if ( QApplication::desktop()->width() < 480 ) { |
411 | setMinimumWidth( 220 ); | 410 | setMinimumWidth( 220 ); |
412 | } else { | 411 | } else { |
413 | setMinimumWidth( 440 ); | 412 | setMinimumWidth( 440 ); |
414 | mExceptionDateEdit->setMinimumWidth( 200 ); | 413 | mExceptionDateEdit->setMinimumWidth( 200 ); |
415 | } | 414 | } |
416 | } | 415 | } |
417 | 416 | ||
418 | void ExceptionsWidget::setDefaults( const QDateTime &from ) | 417 | void ExceptionsWidget::setDefaults( const QDateTime &from ) |
419 | { | 418 | { |
420 | mExceptionDateEdit->setDate( from.date() ); | 419 | mExceptionDateEdit->setDate( from.date() ); |
421 | } | 420 | } |
422 | 421 | ||
423 | void ExceptionsWidget::addException() | 422 | void ExceptionsWidget::addException() |
424 | { | 423 | { |
425 | QDate date = mExceptionDateEdit->date(); | 424 | QDate date = mExceptionDateEdit->date(); |
426 | QString dateStr = KGlobal::locale()->formatDate( date ); | 425 | QString dateStr = KGlobal::locale()->formatDate( date ); |
427 | if( !mExceptionList->findItem( dateStr ) ) { | 426 | if( !mExceptionList->findItem( dateStr ) ) { |
428 | mExceptionDates.append( date ); | 427 | mExceptionDates.append( date ); |
429 | mExceptionList->insertItem( dateStr ); | 428 | mExceptionList->insertItem( dateStr ); |
430 | } | 429 | } |
431 | } | 430 | } |
432 | 431 | ||
433 | void ExceptionsWidget::changeException() | 432 | void ExceptionsWidget::changeException() |
434 | { | 433 | { |
435 | int pos = mExceptionList->currentItem(); | 434 | int pos = mExceptionList->currentItem(); |
436 | if ( pos < 0 ) return; | 435 | if ( pos < 0 ) return; |
437 | 436 | ||
438 | QDate date = mExceptionDateEdit->date(); | 437 | QDate date = mExceptionDateEdit->date(); |
439 | mExceptionDates[ pos ] = date; | 438 | mExceptionDates[ pos ] = date; |
440 | mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos ); | 439 | mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos ); |
441 | } | 440 | } |
442 | 441 | ||
443 | void ExceptionsWidget::deleteException() | 442 | void ExceptionsWidget::deleteException() |
444 | { | 443 | { |
445 | int pos = mExceptionList->currentItem(); | 444 | int pos = mExceptionList->currentItem(); |
446 | if ( pos < 0 ) return; | 445 | if ( pos < 0 ) return; |
447 | 446 | ||
448 | mExceptionDates.remove( mExceptionDates.at( pos ) ); | 447 | mExceptionDates.remove( mExceptionDates.at( pos ) ); |
449 | mExceptionList->removeItem( pos ); | 448 | mExceptionList->removeItem( pos ); |
450 | } | 449 | } |
451 | 450 | ||
452 | void ExceptionsWidget::setDates( const DateList &dates ) | 451 | void ExceptionsWidget::setDates( const DateList &dates ) |
453 | { | 452 | { |
454 | mExceptionList->clear(); | 453 | mExceptionList->clear(); |
455 | mExceptionDates.clear(); | 454 | mExceptionDates.clear(); |
456 | DateList::ConstIterator dit; | 455 | DateList::ConstIterator dit; |
457 | for ( dit = dates.begin(); dit != dates.end(); ++dit ) { | 456 | for ( dit = dates.begin(); dit != dates.end(); ++dit ) { |
458 | mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) ); | 457 | mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) ); |
459 | mExceptionDates.append( *dit ); | 458 | mExceptionDates.append( *dit ); |
460 | } | 459 | } |
461 | } | 460 | } |
462 | 461 | ||
463 | DateList ExceptionsWidget::dates() | 462 | DateList ExceptionsWidget::dates() |
464 | { | 463 | { |
465 | return mExceptionDates; | 464 | return mExceptionDates; |
466 | } | 465 | } |
467 | 466 | ||
468 | ///////////////////////// ExceptionsDialog /////////////////////////// | 467 | ///////////////////////// ExceptionsDialog /////////////////////////// |
469 | 468 | ||
470 | ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : | 469 | ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : |
471 | KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel ) | 470 | KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel ) |
472 | { | 471 | { |
473 | mExceptions = new ExceptionsWidget( this ); | 472 | mExceptions = new ExceptionsWidget( this ); |
474 | setMainWidget( mExceptions ); | 473 | setMainWidget( mExceptions ); |
475 | resize(220,10); | 474 | resize(220,10); |
476 | } | 475 | } |
477 | 476 | ||
478 | void ExceptionsDialog::setDefaults( const QDateTime &from ) | 477 | void ExceptionsDialog::setDefaults( const QDateTime &from ) |
479 | { | 478 | { |
480 | mExceptions->setDefaults( from ); | 479 | mExceptions->setDefaults( from ); |
481 | } | 480 | } |
482 | 481 | ||
483 | void ExceptionsDialog::setDates( const DateList &dates ) | 482 | void ExceptionsDialog::setDates( const DateList &dates ) |
484 | { | 483 | { |
485 | mExceptions->setDates( dates ); | 484 | mExceptions->setDates( dates ); |
486 | } | 485 | } |
487 | 486 | ||
488 | DateList ExceptionsDialog::dates() | 487 | DateList ExceptionsDialog::dates() |
489 | { | 488 | { |
490 | return mExceptions->dates(); | 489 | return mExceptions->dates(); |
491 | } | 490 | } |
492 | 491 | ||
493 | ///////////////////////// RecurrenceRangeWidget /////////////////////////// | 492 | ///////////////////////// RecurrenceRangeWidget /////////////////////////// |
494 | 493 | ||
495 | RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, | 494 | RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, |
496 | const char *name ) | 495 | const char *name ) |
497 | : QWidget( parent, name ) | 496 | : QWidget( parent, name ) |
498 | { | 497 | { |
499 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 498 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
500 | 499 | ||
501 | mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"), | 500 | mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"), |
502 | this ); | 501 | this ); |
503 | topLayout->addWidget( mRangeGroupBox ); | 502 | topLayout->addWidget( mRangeGroupBox ); |
504 | 503 | ||
505 | QWidget *rangeBox = new QWidget( mRangeGroupBox ); | 504 | QWidget *rangeBox = new QWidget( mRangeGroupBox ); |
506 | QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox ); | 505 | QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox ); |
507 | rangeLayout->setSpacing( KDialog::spacingHint() ); | 506 | rangeLayout->setSpacing( KDialog::spacingHint() ); |
508 | 507 | ||
509 | mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); | 508 | mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); |
510 | rangeLayout->addWidget( mStartDateLabel ); | 509 | rangeLayout->addWidget( mStartDateLabel ); |
511 | 510 | ||
512 | QButtonGroup *rangeButtonGroup = new QButtonGroup; | 511 | QButtonGroup *rangeButtonGroup = new QButtonGroup; |
513 | 512 | ||
514 | mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); | 513 | mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); |
515 | rangeButtonGroup->insert( mNoEndDateButton ); | 514 | rangeButtonGroup->insert( mNoEndDateButton ); |
516 | rangeLayout->addWidget( mNoEndDateButton ); | 515 | rangeLayout->addWidget( mNoEndDateButton ); |
517 | 516 | ||
518 | QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); | 517 | QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); |
519 | durationLayout->setSpacing( KDialog::spacingHint() ); | 518 | durationLayout->setSpacing( KDialog::spacingHint() ); |
520 | 519 | ||
521 | mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); | 520 | mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); |
522 | rangeButtonGroup->insert( mEndDurationButton ); | 521 | rangeButtonGroup->insert( mEndDurationButton ); |
523 | durationLayout->addWidget( mEndDurationButton ); | 522 | durationLayout->addWidget( mEndDurationButton ); |
524 | 523 | ||
525 | mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); | 524 | mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); |
526 | durationLayout->addWidget( mEndDurationEdit ); | 525 | durationLayout->addWidget( mEndDurationEdit ); |
527 | 526 | ||
528 | QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); | 527 | QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); |
529 | durationLayout ->addWidget( endDurationLabel ); | 528 | durationLayout ->addWidget( endDurationLabel ); |
530 | 529 | ||
531 | QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); | 530 | QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); |
532 | endDateLayout->setSpacing( KDialog::spacingHint() ); | 531 | endDateLayout->setSpacing( KDialog::spacingHint() ); |
533 | 532 | ||
534 | mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); | 533 | mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); |
535 | rangeButtonGroup->insert( mEndDateButton ); | 534 | rangeButtonGroup->insert( mEndDateButton ); |
536 | endDateLayout->addWidget( mEndDateButton ); | 535 | endDateLayout->addWidget( mEndDateButton ); |
537 | 536 | ||
538 | mEndDateEdit = new KDateEdit( rangeBox ); | 537 | mEndDateEdit = new KDateEdit( rangeBox ); |
539 | endDateLayout->addWidget( mEndDateEdit ); | 538 | endDateLayout->addWidget( mEndDateEdit ); |
540 | 539 | ||
541 | endDateLayout->addStretch( 1 ); | 540 | endDateLayout->addStretch( 1 ); |
542 | 541 | ||
543 | connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), | 542 | connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), |
544 | SLOT( showCurrentRange() ) ); | 543 | SLOT( showCurrentRange() ) ); |
545 | connect( mEndDurationButton, SIGNAL( toggled( bool ) ), | 544 | connect( mEndDurationButton, SIGNAL( toggled( bool ) ), |
546 | SLOT( showCurrentRange() ) ); | 545 | SLOT( showCurrentRange() ) ); |
547 | connect( mEndDateButton, SIGNAL( toggled( bool ) ), | 546 | connect( mEndDateButton, SIGNAL( toggled( bool ) ), |
548 | SLOT( showCurrentRange() ) ); | 547 | SLOT( showCurrentRange() ) ); |
549 | } | 548 | } |
550 | 549 | ||
551 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) | 550 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) |
552 | { | 551 | { |
553 | mNoEndDateButton->setChecked( true ); | 552 | mNoEndDateButton->setChecked( true ); |
554 | 553 | ||
555 | setDateTimes( from ); | 554 | setDateTimes( from ); |
556 | mEndDateEdit->setDate( from.date() ); | 555 | mEndDateEdit->setDate( from.date() ); |
557 | } | 556 | } |
558 | 557 | ||
559 | void RecurrenceRangeWidget::setDuration( int duration ) | 558 | void RecurrenceRangeWidget::setDuration( int duration ) |
560 | { | 559 | { |
561 | if ( duration == -1 ) { | 560 | if ( duration == -1 ) { |
562 | mNoEndDateButton->setChecked( true ); | 561 | mNoEndDateButton->setChecked( true ); |
563 | } else if ( duration == 0 ) { | 562 | } else if ( duration == 0 ) { |
@@ -655,462 +654,486 @@ RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : | |||
655 | 654 | ||
656 | if ( KOPrefs::instance()->mCompactDialogs ) { | 655 | if ( KOPrefs::instance()->mCompactDialogs ) { |
657 | mTypeCombo = new QComboBox( this ); | 656 | mTypeCombo = new QComboBox( this ); |
658 | mTypeCombo->insertItem( i18n("Daily") ); | 657 | mTypeCombo->insertItem( i18n("Daily") ); |
659 | mTypeCombo->insertItem( i18n("Weekly") ); | 658 | mTypeCombo->insertItem( i18n("Weekly") ); |
660 | mTypeCombo->insertItem( i18n("Monthly") ); | 659 | mTypeCombo->insertItem( i18n("Monthly") ); |
661 | mTypeCombo->insertItem( i18n("Yearly") ); | 660 | mTypeCombo->insertItem( i18n("Yearly") ); |
662 | 661 | ||
663 | topLayout->addWidget( mTypeCombo ); | 662 | topLayout->addWidget( mTypeCombo ); |
664 | 663 | ||
665 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); | 664 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); |
666 | } else { | 665 | } else { |
667 | mTypeCombo = 0; | 666 | mTypeCombo = 0; |
668 | 667 | ||
669 | QButtonGroup *ruleButtonGroup = new QButtonGroup( 1, Horizontal, this ); | 668 | QButtonGroup *ruleButtonGroup = new QButtonGroup( 1, Horizontal, this ); |
670 | ruleButtonGroup->setFrameStyle( QFrame::NoFrame ); | 669 | ruleButtonGroup->setFrameStyle( QFrame::NoFrame ); |
671 | topLayout->addWidget( ruleButtonGroup ); | 670 | topLayout->addWidget( ruleButtonGroup ); |
672 | 671 | ||
673 | mDailyButton = new QRadioButton( i18n("Daily"), ruleButtonGroup ); | 672 | mDailyButton = new QRadioButton( i18n("Daily"), ruleButtonGroup ); |
674 | mWeeklyButton = new QRadioButton( i18n("Weekly"), ruleButtonGroup ); | 673 | mWeeklyButton = new QRadioButton( i18n("Weekly"), ruleButtonGroup ); |
675 | mMonthlyButton = new QRadioButton( i18n("Monthly"), ruleButtonGroup ); | 674 | mMonthlyButton = new QRadioButton( i18n("Monthly"), ruleButtonGroup ); |
676 | mYearlyButton = new QRadioButton( i18n("Yearly"), ruleButtonGroup ); | 675 | mYearlyButton = new QRadioButton( i18n("Yearly"), ruleButtonGroup ); |
677 | 676 | ||
678 | connect( mDailyButton, SIGNAL( toggled( bool ) ), | 677 | connect( mDailyButton, SIGNAL( toggled( bool ) ), |
679 | SLOT( emitChoice() ) ); | 678 | SLOT( emitChoice() ) ); |
680 | connect( mWeeklyButton, SIGNAL( toggled( bool ) ), | 679 | connect( mWeeklyButton, SIGNAL( toggled( bool ) ), |
681 | SLOT( emitChoice() ) ); | 680 | SLOT( emitChoice() ) ); |
682 | connect( mMonthlyButton, SIGNAL( toggled( bool ) ), | 681 | connect( mMonthlyButton, SIGNAL( toggled( bool ) ), |
683 | SLOT( emitChoice() ) ); | 682 | SLOT( emitChoice() ) ); |
684 | connect( mYearlyButton, SIGNAL( toggled( bool ) ), | 683 | connect( mYearlyButton, SIGNAL( toggled( bool ) ), |
685 | SLOT( emitChoice() ) ); | 684 | SLOT( emitChoice() ) ); |
686 | } | 685 | } |
687 | } | 686 | } |
688 | 687 | ||
689 | int RecurrenceChooser::type() | 688 | int RecurrenceChooser::type() |
690 | { | 689 | { |
691 | if ( mTypeCombo ) { | 690 | if ( mTypeCombo ) { |
692 | return mTypeCombo->currentItem(); | 691 | return mTypeCombo->currentItem(); |
693 | } else { | 692 | } else { |
694 | if ( mDailyButton->isChecked() ) return Daily; | 693 | if ( mDailyButton->isChecked() ) return Daily; |
695 | else if ( mWeeklyButton->isChecked() ) return Weekly; | 694 | else if ( mWeeklyButton->isChecked() ) return Weekly; |
696 | else if ( mMonthlyButton->isChecked() ) return Monthly; | 695 | else if ( mMonthlyButton->isChecked() ) return Monthly; |
697 | else return Yearly; | 696 | else return Yearly; |
698 | } | 697 | } |
699 | } | 698 | } |
700 | 699 | ||
701 | void RecurrenceChooser::setType( int type ) | 700 | void RecurrenceChooser::setType( int type ) |
702 | { | 701 | { |
703 | if ( mTypeCombo ) { | 702 | if ( mTypeCombo ) { |
704 | mTypeCombo->setCurrentItem( type ); | 703 | mTypeCombo->setCurrentItem( type ); |
705 | } else { | 704 | } else { |
706 | switch ( type ) { | 705 | switch ( type ) { |
707 | case Daily: | 706 | case Daily: |
708 | mDailyButton->setChecked( true ); | 707 | mDailyButton->setChecked( true ); |
709 | break; | 708 | break; |
710 | case Weekly: | 709 | case Weekly: |
711 | mWeeklyButton->setChecked( true ); | 710 | mWeeklyButton->setChecked( true ); |
712 | break; | 711 | break; |
713 | case Monthly: | 712 | case Monthly: |
714 | mMonthlyButton->setChecked( true ); | 713 | mMonthlyButton->setChecked( true ); |
715 | break; | 714 | break; |
716 | case Yearly: | 715 | case Yearly: |
717 | default: | 716 | default: |
718 | mYearlyButton->setChecked( true ); | 717 | mYearlyButton->setChecked( true ); |
719 | break; | 718 | break; |
720 | } | 719 | } |
721 | } | 720 | } |
722 | } | 721 | } |
723 | 722 | ||
724 | void RecurrenceChooser::emitChoice() | 723 | void RecurrenceChooser::emitChoice() |
725 | { | 724 | { |
726 | emit chosen ( type() ); | 725 | emit chosen ( type() ); |
727 | } | 726 | } |
728 | 727 | ||
729 | /////////////////////////////// Main Widget ///////////////////////////// | 728 | /////////////////////////////// Main Widget ///////////////////////////// |
730 | 729 | ||
731 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : | 730 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : |
732 | QWidget( parent, name ) | 731 | QWidget( parent, name ) |
733 | { | 732 | { |
734 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); | 733 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); |
735 | topLayout->setSpacing( KDialog::spacingHint() ); | 734 | topLayout->setSpacing( KDialog::spacingHint() ); |
736 | 735 | ||
737 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); | 736 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); |
738 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), | 737 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), |
739 | SLOT( setEnabled( bool ) ) ); | 738 | SLOT( setEnabled( bool ) ) ); |
740 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); | 739 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); |
741 | 740 | ||
742 | 741 | ||
743 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Appointment Time "), | 742 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Appointment Time "), |
744 | this ); | 743 | this ); |
745 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); | 744 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); |
746 | 745 | ||
747 | if ( KOPrefs::instance()->mCompactDialogs ) { | 746 | if ( KOPrefs::instance()->mCompactDialogs ) { |
748 | mTimeGroupBox->hide(); | 747 | mTimeGroupBox->hide(); |
749 | } | 748 | } |
750 | 749 | ||
751 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); | 750 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); |
752 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); | 751 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); |
753 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); | 752 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); |
754 | 753 | ||
755 | mDateTimeLabel = new QLabel( mTimeGroupBox ); | 754 | mDateTimeLabel = new QLabel( mTimeGroupBox ); |
756 | // mDateTimeLabel = new QLabel( timeFrame ); | 755 | // mDateTimeLabel = new QLabel( timeFrame ); |
757 | // layoutTimeFrame->addWidget( mDateTimeLabel ); | 756 | // layoutTimeFrame->addWidget( mDateTimeLabel ); |
758 | 757 | ||
759 | Qt::Orientation orientation; | 758 | Qt::Orientation orientation; |
760 | if ( KOPrefs::instance()->mCompactDialogs ) orientation = Horizontal; | 759 | if ( KOPrefs::instance()->mCompactDialogs ) orientation = Horizontal; |
761 | else orientation = Vertical; | 760 | else orientation = Vertical; |
762 | 761 | ||
763 | mRuleBox = new QGroupBox( 1, orientation, i18n("Recurrence Rule"), this ); | 762 | mRuleBox = new QGroupBox( 1, orientation, i18n("Recurrence Rule"), this ); |
764 | if ( KOPrefs::instance()->mCompactDialogs ) { | 763 | if ( KOPrefs::instance()->mCompactDialogs ) { |
765 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); | 764 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); |
766 | } else { | 765 | } else { |
767 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); | 766 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); |
768 | } | 767 | } |
769 | 768 | ||
770 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); | 769 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); |
771 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), | 770 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), |
772 | SLOT( showCurrentRule( int ) ) ); | 771 | SLOT( showCurrentRule( int ) ) ); |
773 | 772 | ||
774 | if ( !KOPrefs::instance()->mCompactDialogs ) { | 773 | if ( !KOPrefs::instance()->mCompactDialogs ) { |
775 | QFrame *ruleSepFrame = new QFrame( mRuleBox ); | 774 | QFrame *ruleSepFrame = new QFrame( mRuleBox ); |
776 | ruleSepFrame->setFrameStyle( QFrame::VLine | QFrame::Sunken ); | 775 | ruleSepFrame->setFrameStyle( QFrame::VLine | QFrame::Sunken ); |
777 | } | 776 | } |
778 | 777 | ||
779 | mRuleStack = new QWidgetStack( mRuleBox ); | 778 | mRuleStack = new QWidgetStack( mRuleBox ); |
780 | 779 | ||
781 | mDaily = new RecurDaily( mRuleStack ); | 780 | mDaily = new RecurDaily( mRuleStack ); |
782 | mRuleStack->addWidget( mDaily, 0 ); | 781 | mRuleStack->addWidget( mDaily, 0 ); |
783 | 782 | ||
784 | mWeekly = new RecurWeekly( mRuleStack ); | 783 | mWeekly = new RecurWeekly( mRuleStack ); |
785 | mRuleStack->addWidget( mWeekly, 0 ); | 784 | mRuleStack->addWidget( mWeekly, 0 ); |
786 | 785 | ||
787 | mMonthly = new RecurMonthly( mRuleStack ); | 786 | mMonthly = new RecurMonthly( mRuleStack ); |
788 | mRuleStack->addWidget( mMonthly, 0 ); | 787 | mRuleStack->addWidget( mMonthly, 0 ); |
789 | 788 | ||
790 | mYearly = new RecurYearly( mRuleStack ); | 789 | mYearly = new RecurYearly( mRuleStack ); |
791 | mRuleStack->addWidget( mYearly, 0 ); | 790 | mRuleStack->addWidget( mYearly, 0 ); |
792 | 791 | ||
793 | showCurrentRule( mRecurrenceChooser->type() ); | 792 | showCurrentRule( mRecurrenceChooser->type() ); |
794 | 793 | ||
795 | if ( KOPrefs::instance()->mCompactDialogs ) { | 794 | if ( KOPrefs::instance()->mCompactDialogs ) { |
796 | mRecurrenceRangeWidget = 0; | 795 | mRecurrenceRangeWidget = 0; |
797 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); | 796 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); |
798 | mRecurrenceRange = mRecurrenceRangeDialog; | 797 | mRecurrenceRange = mRecurrenceRangeDialog; |
799 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), | 798 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), |
800 | this ); | 799 | this ); |
801 | 800 | ||
802 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), | 801 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), |
803 | SLOT( showRecurrenceRangeDialog() ) ); | 802 | SLOT( showRecurrenceRangeDialog() ) ); |
804 | 803 | ||
805 | mExceptionsWidget = 0; | 804 | mExceptionsWidget = 0; |
806 | mExceptionsDialog = new ExceptionsDialog( this ); | 805 | mExceptionsDialog = new ExceptionsDialog( this ); |
807 | mExceptions = mExceptionsDialog; | 806 | mExceptions = mExceptionsDialog; |
808 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); | 807 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); |
809 | if ( QApplication::desktop()->width() < 320 ) { | 808 | if ( QApplication::desktop()->width() < 320 ) { |
810 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); | 809 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); |
811 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); | 810 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); |
812 | } else { | 811 | } else { |
813 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); | 812 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); |
814 | topLayout->addWidget( mExceptionsButton, 3, 1 ); | 813 | topLayout->addWidget( mExceptionsButton, 3, 1 ); |
815 | } | 814 | } |
816 | connect( mExceptionsButton, SIGNAL( clicked() ), | 815 | connect( mExceptionsButton, SIGNAL( clicked() ), |
817 | SLOT( showExceptionsDialog() ) ); | 816 | SLOT( showExceptionsDialog() ) ); |
818 | 817 | ||
819 | } else { | 818 | } else { |
820 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); | 819 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); |
821 | mRecurrenceRangeDialog = 0; | 820 | mRecurrenceRangeDialog = 0; |
822 | mRecurrenceRange = mRecurrenceRangeWidget; | 821 | mRecurrenceRange = mRecurrenceRangeWidget; |
823 | mRecurrenceRangeButton = 0; | 822 | mRecurrenceRangeButton = 0; |
824 | topLayout->addWidget( mRecurrenceRangeWidget, 3, 0 ); | 823 | topLayout->addWidget( mRecurrenceRangeWidget, 3, 0 ); |
825 | 824 | ||
826 | mExceptionsWidget = new ExceptionsWidget( this ); | 825 | mExceptionsWidget = new ExceptionsWidget( this ); |
827 | mExceptionsDialog = 0; | 826 | mExceptionsDialog = 0; |
828 | mExceptions = mExceptionsWidget; | 827 | mExceptions = mExceptionsWidget; |
829 | mExceptionsButton = 0; | 828 | mExceptionsButton = 0; |
830 | topLayout->addWidget( mExceptionsWidget, 3, 1 ); | 829 | topLayout->addWidget( mExceptionsWidget, 3, 1 ); |
831 | } | 830 | } |
832 | } | 831 | } |
833 | 832 | ||
834 | KOEditorRecurrence::~KOEditorRecurrence() | 833 | KOEditorRecurrence::~KOEditorRecurrence() |
835 | { | 834 | { |
836 | } | 835 | } |
837 | 836 | ||
838 | void KOEditorRecurrence::setEnabled( bool enabled ) | 837 | void KOEditorRecurrence::setEnabled( bool enabled ) |
839 | { | 838 | { |
840 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; | 839 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; |
841 | 840 | ||
842 | mTimeGroupBox->setEnabled( enabled ); | 841 | mTimeGroupBox->setEnabled( enabled ); |
843 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); | 842 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); |
844 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); | 843 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); |
845 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); | 844 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); |
846 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); | 845 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); |
846 | mRuleBox->setEnabled( enabled ); | ||
847 | } | 847 | } |
848 | 848 | ||
849 | void KOEditorRecurrence::showCurrentRule( int current ) | 849 | void KOEditorRecurrence::showCurrentRule( int current ) |
850 | { | 850 | { |
851 | switch ( current ) { | 851 | switch ( current ) { |
852 | case Daily: | 852 | case Daily: |
853 | mRuleStack->raiseWidget( mDaily ); | 853 | mRuleStack->raiseWidget( mDaily ); |
854 | break; | 854 | break; |
855 | case Weekly: | 855 | case Weekly: |
856 | mRuleStack->raiseWidget( mWeekly ); | 856 | mRuleStack->raiseWidget( mWeekly ); |
857 | break; | 857 | break; |
858 | case Monthly: | 858 | case Monthly: |
859 | mRuleStack->raiseWidget( mMonthly ); | 859 | mRuleStack->raiseWidget( mMonthly ); |
860 | break; | 860 | break; |
861 | default: | 861 | default: |
862 | case Yearly: | 862 | case Yearly: |
863 | mRuleStack->raiseWidget( mYearly ); | 863 | mRuleStack->raiseWidget( mYearly ); |
864 | break; | 864 | break; |
865 | } | 865 | } |
866 | } | 866 | } |
867 | 867 | ||
868 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) | 868 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) |
869 | { | 869 | { |
870 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; | 870 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; |
871 | 871 | ||
872 | mRecurrenceRange->setDateTimes( start, end ); | 872 | mRecurrenceRange->setDateTimes( start, end ); |
873 | mExceptions->setDefaults( end ); | 873 | mExceptions->setDefaults( end ); |
874 | 874 | ||
875 | } | 875 | } |
876 | 876 | ||
877 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) | 877 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) |
878 | { | 878 | { |
879 | 879 | ||
880 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); | 880 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); |
881 | setDateTimes( from, to ); | 881 | setDateTimes( from, to ); |
882 | 882 | ||
883 | bool enabled = false; | 883 | bool enabled = false; |
884 | mEnabledCheck->setChecked( enabled ); | 884 | mEnabledCheck->setChecked( enabled ); |
885 | setEnabled( enabled ); | 885 | setEnabled( enabled ); |
886 | 886 | ||
887 | mExceptions->setDefaults( to ); | 887 | mExceptions->setDefaults( to ); |
888 | mRecurrenceRange->setDefaults( to ); | 888 | mRecurrenceRange->setDefaults( to ); |
889 | 889 | ||
890 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); | 890 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); |
891 | showCurrentRule( mRecurrenceChooser->type() ); | 891 | showCurrentRule( mRecurrenceChooser->type() ); |
892 | 892 | ||
893 | mDaily->setFrequency( 1 ); | 893 | mDaily->setFrequency( 1 ); |
894 | 894 | ||
895 | mWeekly->setFrequency( 1 ); | 895 | mWeekly->setFrequency( 1 ); |
896 | QBitArray days( 7 ); | 896 | QBitArray days( 7 ); |
897 | days.fill( 0 ); | 897 | days.fill( 0 ); |
898 | days.setBit( from.date().dayOfWeek()- 1); | ||
898 | mWeekly->setDays( days ); | 899 | mWeekly->setDays( days ); |
899 | |||
900 | mMonthly->setFrequency( 1 ); | 900 | mMonthly->setFrequency( 1 ); |
901 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | ||
901 | mMonthly->setByDay( from.date().day()-1 ); | 902 | mMonthly->setByDay( from.date().day()-1 ); |
902 | |||
903 | mYearly->setFrequency( 1 ); | 903 | mYearly->setFrequency( 1 ); |
904 | mYearly->setByDay(); | 904 | mYearly->setByDay( from.date().dayOfYear() ); |
905 | mYearly->setByMonth( from.date().month(), from.date().day() ); | ||
905 | } | 906 | } |
906 | 907 | ||
907 | void KOEditorRecurrence::readEvent(Event *event) | 908 | void KOEditorRecurrence::readEvent(Event *event) |
908 | { | 909 | { |
910 | setDefaults( event->dtStart(), event->dtEnd(), true ); | ||
909 | QBitArray rDays( 7 ); | 911 | QBitArray rDays( 7 ); |
910 | QPtrList<Recurrence::rMonthPos> rmp; | 912 | QPtrList<Recurrence::rMonthPos> rmp; |
911 | QPtrList<int> rmd; | 913 | QPtrList<int> rmd; |
912 | int day = 0; | 914 | int day = 0; |
913 | int count = 0; | 915 | int count = 0; |
914 | int month = 0; | 916 | int month = 0; |
915 | setDateTimes( event->dtStart(), event->dtEnd() ); | 917 | setDateTimes( event->dtStart(), event->dtEnd() ); |
916 | 918 | ||
917 | Recurrence *r = event->recurrence(); | 919 | Recurrence *r = event->recurrence(); |
918 | int f = r->frequency(); | 920 | int f = r->frequency(); |
919 | 921 | ||
920 | int recurs = r->doesRecur(); | 922 | int recurs = r->doesRecur(); |
921 | 923 | ||
922 | mEnabledCheck->setChecked( recurs ); | 924 | mEnabledCheck->setChecked( recurs ); |
923 | setEnabled( recurs ); | 925 | setEnabled( recurs ); |
924 | 926 | ||
925 | int recurrenceType = RecurrenceChooser::Weekly; | 927 | int recurrenceType = RecurrenceChooser::Weekly; |
926 | 928 | ||
927 | switch ( recurs ) { | 929 | switch ( recurs ) { |
928 | case Recurrence::rNone: | 930 | case Recurrence::rNone: |
929 | setDefaults( event->dtStart(), event->dtEnd(), true ); | 931 | setDefaults( event->dtStart(), event->dtEnd(), true ); |
930 | break; | 932 | break; |
931 | case Recurrence::rDaily: | 933 | case Recurrence::rDaily: |
932 | recurrenceType = RecurrenceChooser::Daily; | 934 | recurrenceType = RecurrenceChooser::Daily; |
933 | mDaily->setFrequency( f ); | 935 | mDaily->setFrequency( f ); |
934 | break; | 936 | break; |
935 | case Recurrence::rWeekly: | 937 | case Recurrence::rWeekly: |
936 | recurrenceType = RecurrenceChooser::Weekly; | 938 | recurrenceType = RecurrenceChooser::Weekly; |
937 | mWeekly->setFrequency( f ); | 939 | mWeekly->setFrequency( f ); |
938 | mWeekly->setDays( r->days() ); | 940 | mWeekly->setDays( r->days() ); |
939 | break; | 941 | break; |
940 | case Recurrence::rMonthlyPos: | 942 | case Recurrence::rMonthlyPos: |
941 | // we only handle one possibility in the list right now, | 943 | // we only handle one possibility in the list right now, |
942 | // so I have hardcoded calls with first(). If we make the GUI | 944 | // so I have hardcoded calls with first(). If we make the GUI |
943 | // more extended, this can be changed. | 945 | // more extended, this can be changed. |
944 | recurrenceType = RecurrenceChooser::Monthly; | 946 | recurrenceType = RecurrenceChooser::Monthly; |
945 | 947 | ||
946 | rmp = r->monthPositions(); | 948 | rmp = r->monthPositions(); |
947 | if ( rmp.first()->negative ) | 949 | if ( rmp.first()->negative ) |
948 | count = 5 - rmp.first()->rPos - 1; | 950 | count = 5 - rmp.first()->rPos - 1; |
949 | else | 951 | else |
950 | count = rmp.first()->rPos - 1; | 952 | count = rmp.first()->rPos - 1; |
951 | day = 0; | 953 | day = 0; |
952 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; | 954 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; |
953 | mMonthly->setByPos( count, day ); | 955 | mMonthly->setByPos( count, day ); |
954 | 956 | ||
955 | mMonthly->setFrequency( f ); | 957 | mMonthly->setFrequency( f ); |
956 | 958 | ||
957 | break; | 959 | break; |
958 | case Recurrence::rMonthlyDay: | 960 | case Recurrence::rMonthlyDay: |
959 | recurrenceType = RecurrenceChooser::Monthly; | 961 | recurrenceType = RecurrenceChooser::Monthly; |
960 | 962 | ||
961 | rmd = r->monthDays(); | 963 | rmd = r->monthDays(); |
962 | day = *rmd.first() - 1; | 964 | day = *rmd.first() - 1; |
963 | mMonthly->setByDay( day ); | 965 | mMonthly->setByDay( day ); |
964 | 966 | ||
965 | mMonthly->setFrequency( f ); | 967 | mMonthly->setFrequency( f ); |
966 | 968 | ||
967 | break; | 969 | break; |
968 | case Recurrence::rYearlyMonth: | 970 | case Recurrence::rYearlyMonth: |
969 | case Recurrence::rYearlyDay: | 971 | { |
970 | recurrenceType = RecurrenceChooser::Yearly; | 972 | recurrenceType = RecurrenceChooser::Yearly; |
971 | 973 | qDebug("Recurrence::rYearlyMonth: "); | |
972 | rmd = r->yearNums(); | 974 | day = event->dtStart().date().day(); |
973 | month = *rmd.first(); | 975 | rmd = r->yearNums(); |
974 | if ( month == event->dtStart().date().month() ) { | 976 | if ( rmd.count() > 0 ) |
975 | mYearly->setByDay(); | 977 | month = *rmd.first(); |
976 | } else { | 978 | else |
977 | mYearly->setByMonth( month ); | 979 | month = event->dtStart().date().month() ; |
978 | } | 980 | mYearly->setByMonth( month, day ); |
981 | #if 0 | ||
982 | qDebug("2day = %d ",day ); | ||
983 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); | ||
984 | int month; | ||
985 | if ( !monthlist.isEmpty() ) { | ||
986 | month = monthlist.first()->rPos ; | ||
987 | } else { | ||
988 | month = event->dtStart().date().month() ; | ||
989 | } | ||
990 | mYearly->setByMonth( day, month ); | ||
991 | #endif | ||
992 | mYearly->setFrequency( f ); | ||
993 | } | ||
979 | 994 | ||
980 | mYearly->setFrequency( f ); | ||
981 | break; | 995 | break; |
996 | case Recurrence::rYearlyDay: | ||
997 | qDebug("Recurrence::rYearlyDay: "); | ||
998 | recurrenceType = RecurrenceChooser::Yearly; | ||
999 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); | ||
1000 | mYearly->setFrequency( f ); | ||
1001 | break; | ||
982 | default: | 1002 | default: |
983 | setDefaults( event->dtStart(), event->dtEnd(), true ); | 1003 | setDefaults( event->dtStart(), event->dtEnd(), true ); |
984 | break; | 1004 | break; |
985 | } | 1005 | } |
986 | 1006 | ||
987 | mRecurrenceChooser->setType( recurrenceType ); | 1007 | mRecurrenceChooser->setType( recurrenceType ); |
988 | showCurrentRule( recurrenceType ); | 1008 | showCurrentRule( recurrenceType ); |
989 | 1009 | ||
990 | mRecurrenceRange->setDateTimes( event->dtStart() ); | 1010 | mRecurrenceRange->setDateTimes( event->dtStart() ); |
991 | 1011 | ||
992 | if ( r->doesRecur() ) { | 1012 | if ( r->doesRecur() ) { |
993 | mRecurrenceRange->setDuration( r->duration() ); | 1013 | mRecurrenceRange->setDuration( r->duration() ); |
994 | if ( r->duration() == 0 ) | 1014 | if ( r->duration() == 0 ) |
995 | { | 1015 | { |
996 | if ( r->endDate() < event->dtStart().date() ) | 1016 | if ( r->endDate() < event->dtStart().date() ) |
997 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 1017 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
998 | else | 1018 | else |
999 | mRecurrenceRange->setEndDate( r->endDate() ); | 1019 | mRecurrenceRange->setEndDate( r->endDate() ); |
1000 | } else | 1020 | } else |
1001 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 1021 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
1002 | } | 1022 | } |
1003 | 1023 | ||
1004 | mExceptions->setDates( event->exDates() ); | 1024 | mExceptions->setDates( event->exDates() ); |
1005 | } | 1025 | } |
1006 | 1026 | ||
1007 | void KOEditorRecurrence::writeEvent( Event *event ) | 1027 | void KOEditorRecurrence::writeEvent( Event *event ) |
1008 | { | 1028 | { |
1009 | Recurrence *r = event->recurrence(); | 1029 | Recurrence *r = event->recurrence(); |
1010 | 1030 | ||
1011 | // clear out any old settings; | 1031 | // clear out any old settings; |
1012 | r->unsetRecurs(); | 1032 | r->unsetRecurs(); |
1013 | 1033 | ||
1014 | if ( mEnabledCheck->isChecked() ) { | 1034 | if ( mEnabledCheck->isChecked() ) { |
1015 | int duration = mRecurrenceRange->duration(); | 1035 | int duration = mRecurrenceRange->duration(); |
1016 | QDate endDate; | 1036 | QDate endDate; |
1017 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); | 1037 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); |
1018 | 1038 | ||
1019 | int recurrenceType = mRecurrenceChooser->type(); | 1039 | int recurrenceType = mRecurrenceChooser->type(); |
1020 | 1040 | ||
1021 | if ( recurrenceType == RecurrenceChooser::Daily ) { | 1041 | if ( recurrenceType == RecurrenceChooser::Daily ) { |
1022 | int freq = mDaily->frequency(); | 1042 | int freq = mDaily->frequency(); |
1023 | if ( duration != 0 ) r->setDaily( freq, duration ); | 1043 | if ( duration != 0 ) r->setDaily( freq, duration ); |
1024 | else r->setDaily( freq, endDate ); | 1044 | else r->setDaily( freq, endDate ); |
1025 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { | 1045 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { |
1026 | int freq = mWeekly->frequency(); | 1046 | int freq = mWeekly->frequency(); |
1027 | QBitArray days = mWeekly->days(); | 1047 | QBitArray days = mWeekly->days(); |
1028 | int j; | 1048 | int j; |
1029 | bool found = false; | 1049 | bool found = false; |
1030 | for (j = 0; j < 7 ; ++j ) { | 1050 | for (j = 0; j < 7 ; ++j ) { |
1031 | found |=days.at(j); | 1051 | found |=days.at(j); |
1032 | } | 1052 | } |
1033 | if ( !found ) { | 1053 | if ( !found ) { |
1034 | days.setBit( event->dtStart().date().dayOfWeek()-1); | 1054 | days.setBit( event->dtStart().date().dayOfWeek()-1); |
1035 | qDebug("bit set %d "); | 1055 | qDebug("bit set %d "); |
1036 | } | 1056 | } |
1037 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); | 1057 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); |
1038 | else r->setWeekly( freq, days, endDate ); | 1058 | else r->setWeekly( freq, days, endDate ); |
1039 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { | 1059 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { |
1040 | int freq = mMonthly->frequency(); | 1060 | int freq = mMonthly->frequency(); |
1041 | if ( mMonthly->byPos() ) { | 1061 | if ( mMonthly->byPos() ) { |
1042 | int pos = mMonthly->count(); | 1062 | int pos = mMonthly->count(); |
1043 | 1063 | ||
1044 | QBitArray days( 7 ); | 1064 | QBitArray days( 7 ); |
1045 | days.fill( false ); | 1065 | days.fill( false ); |
1046 | 1066 | ||
1047 | days.setBit( mMonthly->weekday() ); | 1067 | days.setBit( mMonthly->weekday() ); |
1048 | if ( duration != 0 ) | 1068 | if ( duration != 0 ) |
1049 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); | 1069 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); |
1050 | else | 1070 | else |
1051 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 1071 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
1052 | r->addMonthlyPos( pos, days ); | 1072 | r->addMonthlyPos( pos, days ); |
1053 | } else { | 1073 | } else { |
1054 | // it's by day | 1074 | // it's by day |
1055 | int day = mMonthly->day(); | 1075 | int day = mMonthly->day(); |
1056 | 1076 | ||
1057 | if ( duration != 0 ) { | 1077 | if ( duration != 0 ) { |
1058 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); | 1078 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); |
1059 | } else { | 1079 | } else { |
1060 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 1080 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
1061 | } | 1081 | } |
1062 | r->addMonthlyDay( day ); | 1082 | r->addMonthlyDay( day ); |
1063 | } | 1083 | } |
1064 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { | 1084 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { |
1085 | qDebug("RecurrenceChooser::Yearly "); | ||
1065 | int freq = mYearly->frequency(); | 1086 | int freq = mYearly->frequency(); |
1066 | 1087 | if ( mYearly->byDay() ) { | |
1067 | int month; | 1088 | if ( duration != 0 ) { |
1068 | if ( mYearly->byMonth() ) { | 1089 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); |
1069 | month = mYearly->month(); | 1090 | } else { |
1070 | } else { | 1091 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); |
1071 | month = event->dtStart().date().month(); | 1092 | } |
1072 | } | 1093 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); |
1073 | if ( duration != 0 ) { | ||
1074 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | ||
1075 | } else { | 1094 | } else { |
1076 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 1095 | if ( duration != 0 ) { |
1096 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | ||
1097 | } else { | ||
1098 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | ||
1099 | } | ||
1100 | r->addYearlyNum( mYearly->month() ); | ||
1077 | } | 1101 | } |
1078 | 1102 | ||
1079 | r->addYearlyNum( month ); | ||
1080 | } | 1103 | } |
1081 | 1104 | ||
1082 | event->setExDates( mExceptions->dates() ); | 1105 | event->setExDates( mExceptions->dates() ); |
1083 | } | 1106 | } |
1084 | } | 1107 | } |
1085 | 1108 | ||
1086 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) | 1109 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) |
1087 | { | 1110 | { |
1088 | mDateTimeLabel->setText( str ); | 1111 | mDateTimeLabel->setText( str ); |
1089 | } | 1112 | } |
1090 | 1113 | ||
1091 | bool KOEditorRecurrence::validateInput() | 1114 | bool KOEditorRecurrence::validateInput() |
1092 | { | 1115 | { |
1093 | // Check input here | 1116 | // Check input here |
1094 | 1117 | ||
1095 | return true; | 1118 | return true; |
1096 | } | 1119 | } |
1097 | 1120 | ||
1098 | void KOEditorRecurrence::showExceptionsDialog() | 1121 | void KOEditorRecurrence::showExceptionsDialog() |
1099 | { | 1122 | { |
1100 | DateList dates = mExceptions->dates(); | 1123 | DateList dates = mExceptions->dates(); |
1101 | int result = mExceptionsDialog->exec(); | 1124 | int result = mExceptionsDialog->exec(); |
1102 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); | 1125 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); |
1103 | } | 1126 | } |
1104 | 1127 | ||
1105 | void KOEditorRecurrence::showRecurrenceRangeDialog() | 1128 | void KOEditorRecurrence::showRecurrenceRangeDialog() |
1106 | { | 1129 | { |
1107 | int duration = mRecurrenceRange->duration(); | 1130 | int duration = mRecurrenceRange->duration(); |
1108 | QDate endDate = mRecurrenceRange->endDate(); | 1131 | QDate endDate = mRecurrenceRange->endDate(); |
1109 | 1132 | ||
1110 | int result = mRecurrenceRangeDialog->exec(); | 1133 | int result = mRecurrenceRangeDialog->exec(); |
1111 | if ( result == QDialog::Rejected ) { | 1134 | if ( result == QDialog::Rejected ) { |
1112 | mRecurrenceRange->setDuration( duration ); | 1135 | mRecurrenceRange->setDuration( duration ); |
1113 | mRecurrenceRange->setEndDate( endDate ); | 1136 | mRecurrenceRange->setEndDate( endDate ); |
1114 | } | 1137 | } |
1115 | 1138 | ||
1116 | } | 1139 | } |
diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h index 4f0f0b2..2b59085 100644 --- a/korganizer/koeditorrecurrence.h +++ b/korganizer/koeditorrecurrence.h | |||
@@ -1,315 +1,318 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KOEDITORRECURRENCE_H | 23 | #ifndef _KOEDITORRECURRENCE_H |
24 | #define _KOEDITORRECURRENCE_H | 24 | #define _KOEDITORRECURRENCE_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qgroupbox.h> | 30 | #include <qgroupbox.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qmultilineedit.h> | 33 | #include <qmultilineedit.h> |
34 | #include <qlistview.h> | 34 | #include <qlistview.h> |
35 | #include <qradiobutton.h> | 35 | #include <qradiobutton.h> |
36 | 36 | ||
37 | #include <kdialogbase.h> | 37 | #include <kdialogbase.h> |
38 | 38 | ||
39 | #include <libkcal/event.h> | 39 | #include <libkcal/event.h> |
40 | 40 | ||
41 | #include "ktimeedit.h" | 41 | #include "ktimeedit.h" |
42 | 42 | ||
43 | class QWidgetStack; | 43 | class QWidgetStack; |
44 | class QSpinBox; | 44 | class QSpinBox; |
45 | 45 | ||
46 | class KDateEdit; | 46 | class KDateEdit; |
47 | 47 | ||
48 | using namespace KCal; | 48 | using namespace KCal; |
49 | 49 | ||
50 | class RecurBase : public QWidget | 50 | class RecurBase : public QWidget |
51 | { | 51 | { |
52 | public: | 52 | public: |
53 | RecurBase( QWidget *parent = 0, const char *name = 0 ); | 53 | RecurBase( QWidget *parent = 0, const char *name = 0 ); |
54 | 54 | ||
55 | void setFrequency( int ); | 55 | void setFrequency( int ); |
56 | int frequency(); | 56 | int frequency(); |
57 | 57 | ||
58 | QWidget *frequencyEdit(); | 58 | QWidget *frequencyEdit(); |
59 | 59 | ||
60 | private: | 60 | private: |
61 | QSpinBox *mFrequencyEdit; | 61 | QSpinBox *mFrequencyEdit; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | class RecurDaily : public RecurBase | 64 | class RecurDaily : public RecurBase |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | RecurDaily( QWidget *parent = 0, const char *name = 0 ); | 67 | RecurDaily( QWidget *parent = 0, const char *name = 0 ); |
68 | }; | 68 | }; |
69 | 69 | ||
70 | class RecurWeekly : public RecurBase | 70 | class RecurWeekly : public RecurBase |
71 | { | 71 | { |
72 | public: | 72 | public: |
73 | RecurWeekly( QWidget *parent = 0, const char *name = 0 ); | 73 | RecurWeekly( QWidget *parent = 0, const char *name = 0 ); |
74 | 74 | ||
75 | void setDays( const QBitArray & ); | 75 | void setDays( const QBitArray & ); |
76 | QBitArray days(); | 76 | QBitArray days(); |
77 | 77 | ||
78 | private: | 78 | private: |
79 | QCheckBox *mDayBoxes[7]; | 79 | QCheckBox *mDayBoxes[7]; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | class RecurMonthly : public RecurBase | 82 | class RecurMonthly : public RecurBase |
83 | { | 83 | { |
84 | public: | 84 | public: |
85 | RecurMonthly( QWidget *parent = 0, const char *name = 0 ); | 85 | RecurMonthly( QWidget *parent = 0, const char *name = 0 ); |
86 | 86 | ||
87 | void setByDay( int day ); | 87 | void setByDay( int day ); |
88 | void setByPos( int count, int weekday ); | 88 | void setByPos( int count, int weekday ); |
89 | 89 | ||
90 | bool byDay(); | 90 | bool byDay(); |
91 | bool byPos(); | 91 | bool byPos(); |
92 | 92 | ||
93 | int day(); | 93 | int day(); |
94 | 94 | ||
95 | int count(); | 95 | int count(); |
96 | int weekday(); | 96 | int weekday(); |
97 | 97 | ||
98 | private: | 98 | private: |
99 | QRadioButton *mByDayRadio; | 99 | QRadioButton *mByDayRadio; |
100 | QComboBox *mByDayCombo; | 100 | QComboBox *mByDayCombo; |
101 | 101 | ||
102 | QRadioButton *mByPosRadio; | 102 | QRadioButton *mByPosRadio; |
103 | QComboBox *mByPosCountCombo; | 103 | QComboBox *mByPosCountCombo; |
104 | QComboBox *mByPosWeekdayCombo; | 104 | QComboBox *mByPosWeekdayCombo; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | class RecurYearly : public RecurBase | 107 | class RecurYearly : public RecurBase |
108 | { | 108 | { |
109 | public: | 109 | public: |
110 | RecurYearly( QWidget *parent = 0, const char *name = 0 ); | 110 | RecurYearly( QWidget *parent = 0, const char *name = 0 ); |
111 | 111 | ||
112 | void setByDay(); | 112 | void setByDay( int doy ); |
113 | void setByMonth( int month ); | 113 | void setByMonth( int month, int day ); |
114 | 114 | ||
115 | bool byMonth(); | 115 | bool byMonth(); |
116 | bool byDay(); | 116 | bool byDay(); |
117 | 117 | ||
118 | int month(); | 118 | int month(); |
119 | int day(); | ||
119 | 120 | ||
120 | private: | 121 | private: |
122 | int mDay; | ||
121 | QRadioButton *mByMonthRadio; | 123 | QRadioButton *mByMonthRadio; |
122 | QComboBox *mByMonthCombo; | 124 | QComboBox *mByMonthCombo; |
123 | 125 | QLabel* mByDayLabel; | |
126 | QLabel* mDayOfLabel; | ||
124 | QRadioButton *mByDayRadio; | 127 | QRadioButton *mByDayRadio; |
125 | }; | 128 | }; |
126 | 129 | ||
127 | class RecurrenceChooser : public QWidget | 130 | class RecurrenceChooser : public QWidget |
128 | { | 131 | { |
129 | Q_OBJECT | 132 | Q_OBJECT |
130 | public: | 133 | public: |
131 | RecurrenceChooser( QWidget *parent = 0, const char *name = 0 ); | 134 | RecurrenceChooser( QWidget *parent = 0, const char *name = 0 ); |
132 | 135 | ||
133 | enum { Daily, Weekly, Monthly, Yearly }; | 136 | enum { Daily, Weekly, Monthly, Yearly }; |
134 | 137 | ||
135 | void setType( int ); | 138 | void setType( int ); |
136 | int type(); | 139 | int type(); |
137 | 140 | ||
138 | signals: | 141 | signals: |
139 | void chosen( int ); | 142 | void chosen( int ); |
140 | 143 | ||
141 | protected slots: | 144 | protected slots: |
142 | void emitChoice(); | 145 | void emitChoice(); |
143 | 146 | ||
144 | private: | 147 | private: |
145 | QComboBox *mTypeCombo; | 148 | QComboBox *mTypeCombo; |
146 | 149 | ||
147 | QRadioButton *mDailyButton; | 150 | QRadioButton *mDailyButton; |
148 | QRadioButton *mWeeklyButton; | 151 | QRadioButton *mWeeklyButton; |
149 | QRadioButton *mMonthlyButton; | 152 | QRadioButton *mMonthlyButton; |
150 | QRadioButton *mYearlyButton; | 153 | QRadioButton *mYearlyButton; |
151 | }; | 154 | }; |
152 | 155 | ||
153 | class ExceptionsBase | 156 | class ExceptionsBase |
154 | { | 157 | { |
155 | public: | 158 | public: |
156 | virtual void setDefaults( const QDateTime &from ) = 0; | 159 | virtual void setDefaults( const QDateTime &from ) = 0; |
157 | virtual void setDates( const DateList & ) = 0; | 160 | virtual void setDates( const DateList & ) = 0; |
158 | virtual DateList dates() = 0; | 161 | virtual DateList dates() = 0; |
159 | }; | 162 | }; |
160 | 163 | ||
161 | class ExceptionsWidget : public QWidget, public ExceptionsBase | 164 | class ExceptionsWidget : public QWidget, public ExceptionsBase |
162 | { | 165 | { |
163 | Q_OBJECT | 166 | Q_OBJECT |
164 | public: | 167 | public: |
165 | ExceptionsWidget( QWidget *parent = 0, const char *name = 0 ); | 168 | ExceptionsWidget( QWidget *parent = 0, const char *name = 0 ); |
166 | 169 | ||
167 | void setDefaults( const QDateTime &from ); | 170 | void setDefaults( const QDateTime &from ); |
168 | 171 | ||
169 | void setDates( const DateList & ); | 172 | void setDates( const DateList & ); |
170 | DateList dates(); | 173 | DateList dates(); |
171 | 174 | ||
172 | protected slots: | 175 | protected slots: |
173 | void addException(); | 176 | void addException(); |
174 | void changeException(); | 177 | void changeException(); |
175 | void deleteException(); | 178 | void deleteException(); |
176 | 179 | ||
177 | private: | 180 | private: |
178 | KDateEdit *mExceptionDateEdit; | 181 | KDateEdit *mExceptionDateEdit; |
179 | QListBox *mExceptionList; | 182 | QListBox *mExceptionList; |
180 | DateList mExceptionDates; | 183 | DateList mExceptionDates; |
181 | }; | 184 | }; |
182 | 185 | ||
183 | class ExceptionsDialog : public KDialogBase, public ExceptionsBase | 186 | class ExceptionsDialog : public KDialogBase, public ExceptionsBase |
184 | { | 187 | { |
185 | public: | 188 | public: |
186 | ExceptionsDialog( QWidget *parent, const char *name = 0 ); | 189 | ExceptionsDialog( QWidget *parent, const char *name = 0 ); |
187 | 190 | ||
188 | void setDefaults( const QDateTime &from ); | 191 | void setDefaults( const QDateTime &from ); |
189 | 192 | ||
190 | void setDates( const DateList & ); | 193 | void setDates( const DateList & ); |
191 | DateList dates(); | 194 | DateList dates(); |
192 | 195 | ||
193 | private: | 196 | private: |
194 | ExceptionsWidget *mExceptions; | 197 | ExceptionsWidget *mExceptions; |
195 | }; | 198 | }; |
196 | 199 | ||
197 | class RecurrenceRangeBase | 200 | class RecurrenceRangeBase |
198 | { | 201 | { |
199 | public: | 202 | public: |
200 | virtual void setDefaults( const QDateTime &from ) = 0; | 203 | virtual void setDefaults( const QDateTime &from ) = 0; |
201 | 204 | ||
202 | virtual void setDuration( int ) = 0; | 205 | virtual void setDuration( int ) = 0; |
203 | virtual int duration() = 0; | 206 | virtual int duration() = 0; |
204 | 207 | ||
205 | virtual void setEndDate( const QDate & ) = 0; | 208 | virtual void setEndDate( const QDate & ) = 0; |
206 | virtual QDate endDate() = 0; | 209 | virtual QDate endDate() = 0; |
207 | 210 | ||
208 | virtual void setDateTimes( const QDateTime &start, | 211 | virtual void setDateTimes( const QDateTime &start, |
209 | const QDateTime &end = QDateTime() ) = 0; | 212 | const QDateTime &end = QDateTime() ) = 0; |
210 | }; | 213 | }; |
211 | 214 | ||
212 | class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase | 215 | class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase |
213 | { | 216 | { |
214 | Q_OBJECT | 217 | Q_OBJECT |
215 | public: | 218 | public: |
216 | RecurrenceRangeWidget( QWidget *parent = 0, const char *name = 0 ); | 219 | RecurrenceRangeWidget( QWidget *parent = 0, const char *name = 0 ); |
217 | 220 | ||
218 | void setDefaults( const QDateTime &from ); | 221 | void setDefaults( const QDateTime &from ); |
219 | 222 | ||
220 | void setDuration( int ); | 223 | void setDuration( int ); |
221 | int duration(); | 224 | int duration(); |
222 | 225 | ||
223 | void setEndDate( const QDate & ); | 226 | void setEndDate( const QDate & ); |
224 | QDate endDate(); | 227 | QDate endDate(); |
225 | 228 | ||
226 | void setDateTimes( const QDateTime &start, | 229 | void setDateTimes( const QDateTime &start, |
227 | const QDateTime &end = QDateTime() ); | 230 | const QDateTime &end = QDateTime() ); |
228 | 231 | ||
229 | protected slots: | 232 | protected slots: |
230 | void showCurrentRange(); | 233 | void showCurrentRange(); |
231 | 234 | ||
232 | private: | 235 | private: |
233 | QGroupBox *mRangeGroupBox; | 236 | QGroupBox *mRangeGroupBox; |
234 | QLabel *mStartDateLabel; | 237 | QLabel *mStartDateLabel; |
235 | QRadioButton *mNoEndDateButton; | 238 | QRadioButton *mNoEndDateButton; |
236 | QRadioButton *mEndDurationButton; | 239 | QRadioButton *mEndDurationButton; |
237 | QSpinBox *mEndDurationEdit; | 240 | QSpinBox *mEndDurationEdit; |
238 | QRadioButton *mEndDateButton; | 241 | QRadioButton *mEndDateButton; |
239 | KDateEdit *mEndDateEdit; | 242 | KDateEdit *mEndDateEdit; |
240 | }; | 243 | }; |
241 | 244 | ||
242 | class RecurrenceRangeDialog : public KDialogBase, public RecurrenceRangeBase | 245 | class RecurrenceRangeDialog : public KDialogBase, public RecurrenceRangeBase |
243 | { | 246 | { |
244 | public: | 247 | public: |
245 | RecurrenceRangeDialog( QWidget *parent = 0, const char *name = 0 ); | 248 | RecurrenceRangeDialog( QWidget *parent = 0, const char *name = 0 ); |
246 | 249 | ||
247 | void setDefaults( const QDateTime &from ); | 250 | void setDefaults( const QDateTime &from ); |
248 | 251 | ||
249 | void setDuration( int ); | 252 | void setDuration( int ); |
250 | int duration(); | 253 | int duration(); |
251 | 254 | ||
252 | void setEndDate( const QDate & ); | 255 | void setEndDate( const QDate & ); |
253 | QDate endDate(); | 256 | QDate endDate(); |
254 | 257 | ||
255 | void setDateTimes( const QDateTime &start, | 258 | void setDateTimes( const QDateTime &start, |
256 | const QDateTime &end = QDateTime() ); | 259 | const QDateTime &end = QDateTime() ); |
257 | 260 | ||
258 | private: | 261 | private: |
259 | RecurrenceRangeWidget *mRecurrenceRangeWidget; | 262 | RecurrenceRangeWidget *mRecurrenceRangeWidget; |
260 | }; | 263 | }; |
261 | 264 | ||
262 | class KOEditorRecurrence : public QWidget | 265 | class KOEditorRecurrence : public QWidget |
263 | { | 266 | { |
264 | Q_OBJECT | 267 | Q_OBJECT |
265 | public: | 268 | public: |
266 | KOEditorRecurrence ( QWidget *parent = 0, const char *name = 0 ); | 269 | KOEditorRecurrence ( QWidget *parent = 0, const char *name = 0 ); |
267 | virtual ~KOEditorRecurrence(); | 270 | virtual ~KOEditorRecurrence(); |
268 | 271 | ||
269 | enum { Daily, Weekly, Monthly, Yearly }; | 272 | enum { Daily, Weekly, Monthly, Yearly }; |
270 | 273 | ||
271 | /** Set widgets to default values */ | 274 | /** Set widgets to default values */ |
272 | void setDefaults( QDateTime from, QDateTime to, bool allday ); | 275 | void setDefaults( QDateTime from, QDateTime to, bool allday ); |
273 | /** Read event object and setup widgets accordingly */ | 276 | /** Read event object and setup widgets accordingly */ |
274 | void readEvent( Event * ); | 277 | void readEvent( Event * ); |
275 | /** Write event settings to event object */ | 278 | /** Write event settings to event object */ |
276 | void writeEvent( Event * ); | 279 | void writeEvent( Event * ); |
277 | 280 | ||
278 | /** Check if the input is valid. */ | 281 | /** Check if the input is valid. */ |
279 | bool validateInput(); | 282 | bool validateInput(); |
280 | 283 | ||
281 | public slots: | 284 | public slots: |
282 | void setEnabled( bool ); | 285 | void setEnabled( bool ); |
283 | void setDateTimes( QDateTime start, QDateTime end ); | 286 | void setDateTimes( QDateTime start, QDateTime end ); |
284 | void setDateTimeStr( const QString & ); | 287 | void setDateTimeStr( const QString & ); |
285 | 288 | ||
286 | signals: | 289 | signals: |
287 | void dateTimesChanged( QDateTime start, QDateTime end ); | 290 | void dateTimesChanged( QDateTime start, QDateTime end ); |
288 | 291 | ||
289 | protected slots: | 292 | protected slots: |
290 | void showCurrentRule( int ); | 293 | void showCurrentRule( int ); |
291 | void showExceptionsDialog(); | 294 | void showExceptionsDialog(); |
292 | void showRecurrenceRangeDialog(); | 295 | void showRecurrenceRangeDialog(); |
293 | 296 | ||
294 | private: | 297 | private: |
295 | QCheckBox *mEnabledCheck; | 298 | QCheckBox *mEnabledCheck; |
296 | 299 | ||
297 | QGroupBox *mTimeGroupBox; | 300 | QGroupBox *mTimeGroupBox; |
298 | QLabel *mDateTimeLabel; | 301 | QLabel *mDateTimeLabel; |
299 | 302 | ||
300 | QGroupBox *mRuleBox; | 303 | QGroupBox *mRuleBox; |
301 | QWidgetStack *mRuleStack; | 304 | QWidgetStack *mRuleStack; |
302 | RecurrenceChooser *mRecurrenceChooser; | 305 | RecurrenceChooser *mRecurrenceChooser; |
303 | 306 | ||
304 | RecurDaily *mDaily; | 307 | RecurDaily *mDaily; |
305 | RecurWeekly *mWeekly; | 308 | RecurWeekly *mWeekly; |
306 | RecurMonthly *mMonthly; | 309 | RecurMonthly *mMonthly; |
307 | RecurYearly *mYearly; | 310 | RecurYearly *mYearly; |
308 | 311 | ||
309 | RecurrenceRangeBase *mRecurrenceRange; | 312 | RecurrenceRangeBase *mRecurrenceRange; |
310 | RecurrenceRangeWidget *mRecurrenceRangeWidget; | 313 | RecurrenceRangeWidget *mRecurrenceRangeWidget; |
311 | RecurrenceRangeDialog *mRecurrenceRangeDialog; | 314 | RecurrenceRangeDialog *mRecurrenceRangeDialog; |
312 | QPushButton *mRecurrenceRangeButton; | 315 | QPushButton *mRecurrenceRangeButton; |
313 | 316 | ||
314 | ExceptionsBase *mExceptions; | 317 | ExceptionsBase *mExceptions; |
315 | ExceptionsDialog *mExceptionsDialog; | 318 | ExceptionsDialog *mExceptionsDialog; |
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index 32a1337..964ffe3 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp | |||
@@ -1203,553 +1203,557 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) | |||
1203 | } | 1203 | } |
1204 | break; | 1204 | break; |
1205 | case ICAL_STATUS_PROPERTY: // summary | 1205 | case ICAL_STATUS_PROPERTY: // summary |
1206 | { | 1206 | { |
1207 | if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) ) | 1207 | if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) ) |
1208 | incidence->setCancelled( true ); | 1208 | incidence->setCancelled( true ); |
1209 | } | 1209 | } |
1210 | break; | 1210 | break; |
1211 | 1211 | ||
1212 | case ICAL_LOCATION_PROPERTY: // location | 1212 | case ICAL_LOCATION_PROPERTY: // location |
1213 | text = icalproperty_get_location(p); | 1213 | text = icalproperty_get_location(p); |
1214 | incidence->setLocation(QString::fromUtf8(text)); | 1214 | incidence->setLocation(QString::fromUtf8(text)); |
1215 | break; | 1215 | break; |
1216 | 1216 | ||
1217 | #if 0 | 1217 | #if 0 |
1218 | // status | 1218 | // status |
1219 | if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) { | 1219 | if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) { |
1220 | incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo))); | 1220 | incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo))); |
1221 | deleteStr(s); | 1221 | deleteStr(s); |
1222 | } | 1222 | } |
1223 | else | 1223 | else |
1224 | incidence->setStatus("NEEDS ACTION"); | 1224 | incidence->setStatus("NEEDS ACTION"); |
1225 | #endif | 1225 | #endif |
1226 | 1226 | ||
1227 | case ICAL_PRIORITY_PROPERTY: // priority | 1227 | case ICAL_PRIORITY_PROPERTY: // priority |
1228 | intvalue = icalproperty_get_priority(p); | 1228 | intvalue = icalproperty_get_priority(p); |
1229 | incidence->setPriority(intvalue); | 1229 | incidence->setPriority(intvalue); |
1230 | break; | 1230 | break; |
1231 | 1231 | ||
1232 | case ICAL_CATEGORIES_PROPERTY: // categories | 1232 | case ICAL_CATEGORIES_PROPERTY: // categories |
1233 | text = icalproperty_get_categories(p); | 1233 | text = icalproperty_get_categories(p); |
1234 | categories.append(QString::fromUtf8(text)); | 1234 | categories.append(QString::fromUtf8(text)); |
1235 | break; | 1235 | break; |
1236 | //******************************************* | 1236 | //******************************************* |
1237 | case ICAL_RRULE_PROPERTY: | 1237 | case ICAL_RRULE_PROPERTY: |
1238 | // we do need (maybe )start datetime of incidence for recurrence | 1238 | // we do need (maybe )start datetime of incidence for recurrence |
1239 | // such that we can read recurrence only after we read incidence completely | 1239 | // such that we can read recurrence only after we read incidence completely |
1240 | readrec = true; | 1240 | readrec = true; |
1241 | rectype = icalproperty_get_rrule(p); | 1241 | rectype = icalproperty_get_rrule(p); |
1242 | break; | 1242 | break; |
1243 | 1243 | ||
1244 | case ICAL_EXDATE_PROPERTY: | 1244 | case ICAL_EXDATE_PROPERTY: |
1245 | icaltime = icalproperty_get_exdate(p); | 1245 | icaltime = icalproperty_get_exdate(p); |
1246 | incidence->addExDate(readICalDate(icaltime)); | 1246 | incidence->addExDate(readICalDate(icaltime)); |
1247 | break; | 1247 | break; |
1248 | 1248 | ||
1249 | case ICAL_CLASS_PROPERTY: { | 1249 | case ICAL_CLASS_PROPERTY: { |
1250 | int inttext = icalproperty_get_class(p); | 1250 | int inttext = icalproperty_get_class(p); |
1251 | if (inttext == ICAL_CLASS_PUBLIC ) { | 1251 | if (inttext == ICAL_CLASS_PUBLIC ) { |
1252 | incidence->setSecrecy(Incidence::SecrecyPublic); | 1252 | incidence->setSecrecy(Incidence::SecrecyPublic); |
1253 | } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { | 1253 | } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { |
1254 | incidence->setSecrecy(Incidence::SecrecyConfidential); | 1254 | incidence->setSecrecy(Incidence::SecrecyConfidential); |
1255 | } else { | 1255 | } else { |
1256 | incidence->setSecrecy(Incidence::SecrecyPrivate); | 1256 | incidence->setSecrecy(Incidence::SecrecyPrivate); |
1257 | } | 1257 | } |
1258 | } | 1258 | } |
1259 | break; | 1259 | break; |
1260 | 1260 | ||
1261 | case ICAL_ATTACH_PROPERTY: // attachments | 1261 | case ICAL_ATTACH_PROPERTY: // attachments |
1262 | incidence->addAttachment(readAttachment(p)); | 1262 | incidence->addAttachment(readAttachment(p)); |
1263 | break; | 1263 | break; |
1264 | 1264 | ||
1265 | default: | 1265 | default: |
1266 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind | 1266 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind |
1267 | // << endl; | 1267 | // << endl; |
1268 | break; | 1268 | break; |
1269 | } | 1269 | } |
1270 | 1270 | ||
1271 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); | 1271 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); |
1272 | } | 1272 | } |
1273 | if ( readrec ) { | 1273 | if ( readrec ) { |
1274 | readRecurrenceRule(rectype,incidence); | 1274 | readRecurrenceRule(rectype,incidence); |
1275 | } | 1275 | } |
1276 | // kpilot stuff | 1276 | // kpilot stuff |
1277 | // TODO: move this application-specific code to kpilot | 1277 | // TODO: move this application-specific code to kpilot |
1278 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); | 1278 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); |
1279 | if (!kp.isNull()) { | 1279 | if (!kp.isNull()) { |
1280 | incidence->setPilotId(kp.toInt()); | 1280 | incidence->setPilotId(kp.toInt()); |
1281 | } | 1281 | } |
1282 | kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); | 1282 | kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); |
1283 | if (!kp.isNull()) { | 1283 | if (!kp.isNull()) { |
1284 | incidence->setSyncStatus(kp.toInt()); | 1284 | incidence->setSyncStatus(kp.toInt()); |
1285 | } | 1285 | } |
1286 | kp = incidence->nonKDECustomProperty("X-ZAURUSID"); | 1286 | kp = incidence->nonKDECustomProperty("X-ZAURUSID"); |
1287 | if (!kp.isNull()) { | 1287 | if (!kp.isNull()) { |
1288 | incidence->setZaurusId(kp.toInt()); | 1288 | incidence->setZaurusId(kp.toInt()); |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | kp = incidence->nonKDECustomProperty("X-ZAURUSUID"); | 1291 | kp = incidence->nonKDECustomProperty("X-ZAURUSUID"); |
1292 | if (!kp.isNull()) { | 1292 | if (!kp.isNull()) { |
1293 | incidence->setZaurusUid(kp.toInt()); | 1293 | incidence->setZaurusUid(kp.toInt()); |
1294 | } | 1294 | } |
1295 | 1295 | ||
1296 | kp = incidence->nonKDECustomProperty("X-ZAURUSSTAT"); | 1296 | kp = incidence->nonKDECustomProperty("X-ZAURUSSTAT"); |
1297 | if (!kp.isNull()) { | 1297 | if (!kp.isNull()) { |
1298 | incidence->setZaurusStat(kp.toInt()); | 1298 | incidence->setZaurusStat(kp.toInt()); |
1299 | } | 1299 | } |
1300 | 1300 | ||
1301 | // Cancel backwards compatibility mode for subsequent changes by the application | 1301 | // Cancel backwards compatibility mode for subsequent changes by the application |
1302 | incidence->recurrence()->setCompatVersion(); | 1302 | incidence->recurrence()->setCompatVersion(); |
1303 | 1303 | ||
1304 | // add categories | 1304 | // add categories |
1305 | incidence->setCategories(categories); | 1305 | incidence->setCategories(categories); |
1306 | 1306 | ||
1307 | // iterate through all alarms | 1307 | // iterate through all alarms |
1308 | for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); | 1308 | for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); |
1309 | alarm; | 1309 | alarm; |
1310 | alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { | 1310 | alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { |
1311 | readAlarm(alarm,incidence); | 1311 | readAlarm(alarm,incidence); |
1312 | } | 1312 | } |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) | 1315 | void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) |
1316 | { | 1316 | { |
1317 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); | 1317 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); |
1318 | 1318 | ||
1319 | while (p) { | 1319 | while (p) { |
1320 | icalproperty_kind kind = icalproperty_isa(p); | 1320 | icalproperty_kind kind = icalproperty_isa(p); |
1321 | switch (kind) { | 1321 | switch (kind) { |
1322 | 1322 | ||
1323 | case ICAL_UID_PROPERTY: // unique id | 1323 | case ICAL_UID_PROPERTY: // unique id |
1324 | incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); | 1324 | incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); |
1325 | break; | 1325 | break; |
1326 | 1326 | ||
1327 | case ICAL_ORGANIZER_PROPERTY: // organizer | 1327 | case ICAL_ORGANIZER_PROPERTY: // organizer |
1328 | incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); | 1328 | incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); |
1329 | break; | 1329 | break; |
1330 | 1330 | ||
1331 | case ICAL_ATTENDEE_PROPERTY: // attendee | 1331 | case ICAL_ATTENDEE_PROPERTY: // attendee |
1332 | incidenceBase->addAttendee(readAttendee(p)); | 1332 | incidenceBase->addAttendee(readAttendee(p)); |
1333 | break; | 1333 | break; |
1334 | 1334 | ||
1335 | default: | 1335 | default: |
1336 | break; | 1336 | break; |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); | 1339 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); |
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | // custom properties | 1342 | // custom properties |
1343 | readCustomProperties(parent, incidenceBase); | 1343 | readCustomProperties(parent, incidenceBase); |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) | 1346 | void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) |
1347 | { | 1347 | { |
1348 | QMap<QCString, QString> customProperties; | 1348 | QMap<QCString, QString> customProperties; |
1349 | 1349 | ||
1350 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); | 1350 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); |
1351 | 1351 | ||
1352 | while (p) { | 1352 | while (p) { |
1353 | QString value = QString::fromUtf8(icalproperty_get_x(p)); | 1353 | QString value = QString::fromUtf8(icalproperty_get_x(p)); |
1354 | customProperties[icalproperty_get_x_name(p)] = value; | 1354 | customProperties[icalproperty_get_x_name(p)] = value; |
1355 | //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); | 1355 | //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); |
1356 | 1356 | ||
1357 | p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); | 1357 | p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); |
1358 | } | 1358 | } |
1359 | 1359 | ||
1360 | properties->setCustomProperties(customProperties); | 1360 | properties->setCustomProperties(customProperties); |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) | 1363 | void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) |
1364 | { | 1364 | { |
1365 | // kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; | 1365 | // kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; |
1366 | 1366 | ||
1367 | Recurrence *recur = incidence->recurrence(); | 1367 | Recurrence *recur = incidence->recurrence(); |
1368 | recur->setCompatVersion(mCalendarVersion); | 1368 | recur->setCompatVersion(mCalendarVersion); |
1369 | recur->unsetRecurs(); | 1369 | recur->unsetRecurs(); |
1370 | 1370 | ||
1371 | struct icalrecurrencetype r = rrule; | 1371 | struct icalrecurrencetype r = rrule; |
1372 | 1372 | ||
1373 | dumpIcalRecurrence(r); | 1373 | dumpIcalRecurrence(r); |
1374 | readRecurrence( r, recur, incidence); | 1374 | readRecurrence( r, recur, incidence); |
1375 | } | 1375 | } |
1376 | 1376 | ||
1377 | void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) | 1377 | void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) |
1378 | { | 1378 | { |
1379 | int wkst; | 1379 | int wkst; |
1380 | int index = 0; | 1380 | int index = 0; |
1381 | short day = 0; | 1381 | short day = 0; |
1382 | QBitArray qba(7); | 1382 | QBitArray qba(7); |
1383 | int frequ = r.freq; | 1383 | int frequ = r.freq; |
1384 | int interv = r.interval; | 1384 | int interv = r.interval; |
1385 | // preprocessing for odd recurrence definitions | 1385 | // preprocessing for odd recurrence definitions |
1386 | 1386 | ||
1387 | if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { | 1387 | if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { |
1388 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1388 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1389 | interv = 12; | 1389 | interv = 12; |
1390 | } | 1390 | } |
1391 | } | 1391 | } |
1392 | if ( r.freq == ICAL_YEARLY_RECURRENCE ) { | 1392 | if ( r.freq == ICAL_YEARLY_RECURRENCE ) { |
1393 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { | 1393 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { |
1394 | frequ = ICAL_MONTHLY_RECURRENCE; | 1394 | frequ = ICAL_MONTHLY_RECURRENCE; |
1395 | interv = 12; | 1395 | interv = 12* r.interval; |
1396 | } | 1396 | } |
1397 | } | 1397 | } |
1398 | 1398 | ||
1399 | switch (frequ) { | 1399 | switch (frequ) { |
1400 | case ICAL_MINUTELY_RECURRENCE: | 1400 | case ICAL_MINUTELY_RECURRENCE: |
1401 | if (!icaltime_is_null_time(r.until)) { | 1401 | if (!icaltime_is_null_time(r.until)) { |
1402 | recur->setMinutely(interv,readICalDateTime(r.until)); | 1402 | recur->setMinutely(interv,readICalDateTime(r.until)); |
1403 | } else { | 1403 | } else { |
1404 | if (r.count == 0) | 1404 | if (r.count == 0) |
1405 | recur->setMinutely(interv,-1); | 1405 | recur->setMinutely(interv,-1); |
1406 | else | 1406 | else |
1407 | recur->setMinutely(interv,r.count); | 1407 | recur->setMinutely(interv,r.count); |
1408 | } | 1408 | } |
1409 | break; | 1409 | break; |
1410 | case ICAL_HOURLY_RECURRENCE: | 1410 | case ICAL_HOURLY_RECURRENCE: |
1411 | if (!icaltime_is_null_time(r.until)) { | 1411 | if (!icaltime_is_null_time(r.until)) { |
1412 | recur->setHourly(interv,readICalDateTime(r.until)); | 1412 | recur->setHourly(interv,readICalDateTime(r.until)); |
1413 | } else { | 1413 | } else { |
1414 | if (r.count == 0) | 1414 | if (r.count == 0) |
1415 | recur->setHourly(interv,-1); | 1415 | recur->setHourly(interv,-1); |
1416 | else | 1416 | else |
1417 | recur->setHourly(interv,r.count); | 1417 | recur->setHourly(interv,r.count); |
1418 | } | 1418 | } |
1419 | break; | 1419 | break; |
1420 | case ICAL_DAILY_RECURRENCE: | 1420 | case ICAL_DAILY_RECURRENCE: |
1421 | if (!icaltime_is_null_time(r.until)) { | 1421 | if (!icaltime_is_null_time(r.until)) { |
1422 | recur->setDaily(interv,readICalDate(r.until)); | 1422 | recur->setDaily(interv,readICalDate(r.until)); |
1423 | } else { | 1423 | } else { |
1424 | if (r.count == 0) | 1424 | if (r.count == 0) |
1425 | recur->setDaily(interv,-1); | 1425 | recur->setDaily(interv,-1); |
1426 | else | 1426 | else |
1427 | recur->setDaily(interv,r.count); | 1427 | recur->setDaily(interv,r.count); |
1428 | } | 1428 | } |
1429 | break; | 1429 | break; |
1430 | case ICAL_WEEKLY_RECURRENCE: | 1430 | case ICAL_WEEKLY_RECURRENCE: |
1431 | // kdDebug(5800) << "WEEKLY_RECURRENCE" << endl; | 1431 | // kdDebug(5800) << "WEEKLY_RECURRENCE" << endl; |
1432 | wkst = (r.week_start + 5)%7 + 1; | 1432 | wkst = (r.week_start + 5)%7 + 1; |
1433 | if (!icaltime_is_null_time(r.until)) { | 1433 | if (!icaltime_is_null_time(r.until)) { |
1434 | recur->setWeekly(interv,qba,readICalDate(r.until),wkst); | 1434 | recur->setWeekly(interv,qba,readICalDate(r.until),wkst); |
1435 | } else { | 1435 | } else { |
1436 | if (r.count == 0) | 1436 | if (r.count == 0) |
1437 | recur->setWeekly(interv,qba,-1,wkst); | 1437 | recur->setWeekly(interv,qba,-1,wkst); |
1438 | else | 1438 | else |
1439 | recur->setWeekly(interv,qba,r.count,wkst); | 1439 | recur->setWeekly(interv,qba,r.count,wkst); |
1440 | } | 1440 | } |
1441 | if ( r.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) { | 1441 | if ( r.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) { |
1442 | int wday = incidence->dtStart().date().dayOfWeek ()-1; | 1442 | int wday = incidence->dtStart().date().dayOfWeek ()-1; |
1443 | //qDebug("weekly error found "); | 1443 | //qDebug("weekly error found "); |
1444 | qba.setBit(wday); | 1444 | qba.setBit(wday); |
1445 | } else { | 1445 | } else { |
1446 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1446 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1447 | // kdDebug(5800) << " " << day << endl; | 1447 | // kdDebug(5800) << " " << day << endl; |
1448 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1448 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1449 | } | 1449 | } |
1450 | } | 1450 | } |
1451 | break; | 1451 | break; |
1452 | case ICAL_MONTHLY_RECURRENCE: | 1452 | case ICAL_MONTHLY_RECURRENCE: |
1453 | 1453 | ||
1454 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1454 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1455 | if (!icaltime_is_null_time(r.until)) { | 1455 | if (!icaltime_is_null_time(r.until)) { |
1456 | recur->setMonthly(Recurrence::rMonthlyPos,interv, | 1456 | recur->setMonthly(Recurrence::rMonthlyPos,interv, |
1457 | readICalDate(r.until)); | 1457 | readICalDate(r.until)); |
1458 | } else { | 1458 | } else { |
1459 | if (r.count == 0) | 1459 | if (r.count == 0) |
1460 | recur->setMonthly(Recurrence::rMonthlyPos,interv,-1); | 1460 | recur->setMonthly(Recurrence::rMonthlyPos,interv,-1); |
1461 | else | 1461 | else |
1462 | recur->setMonthly(Recurrence::rMonthlyPos,interv,r.count); | 1462 | recur->setMonthly(Recurrence::rMonthlyPos,interv,r.count); |
1463 | } | 1463 | } |
1464 | bool useSetPos = false; | 1464 | bool useSetPos = false; |
1465 | short pos = 0; | 1465 | short pos = 0; |
1466 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1466 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1467 | // kdDebug(5800) << "----a " << index << ": " << day << endl; | 1467 | // kdDebug(5800) << "----a " << index << ": " << day << endl; |
1468 | pos = icalrecurrencetype_day_position(day); | 1468 | pos = icalrecurrencetype_day_position(day); |
1469 | if (pos) { | 1469 | if (pos) { |
1470 | day = icalrecurrencetype_day_day_of_week(day); | 1470 | day = icalrecurrencetype_day_day_of_week(day); |
1471 | QBitArray ba(7); // don't wipe qba | 1471 | QBitArray ba(7); // don't wipe qba |
1472 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1472 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1473 | recur->addMonthlyPos(pos,ba); | 1473 | recur->addMonthlyPos(pos,ba); |
1474 | } else { | 1474 | } else { |
1475 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1475 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1476 | useSetPos = true; | 1476 | useSetPos = true; |
1477 | } | 1477 | } |
1478 | } | 1478 | } |
1479 | if (useSetPos) { | 1479 | if (useSetPos) { |
1480 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1480 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1481 | recur->addMonthlyPos(r.by_set_pos[0],qba); | 1481 | recur->addMonthlyPos(r.by_set_pos[0],qba); |
1482 | } | 1482 | } |
1483 | } | 1483 | } |
1484 | } else if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1484 | } else if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1485 | if (!icaltime_is_null_time(r.until)) { | 1485 | if (!icaltime_is_null_time(r.until)) { |
1486 | recur->setMonthly(Recurrence::rMonthlyDay,interv, | 1486 | recur->setMonthly(Recurrence::rMonthlyDay,interv, |
1487 | readICalDate(r.until)); | 1487 | readICalDate(r.until)); |
1488 | } else { | 1488 | } else { |
1489 | if (r.count == 0) | 1489 | if (r.count == 0) |
1490 | recur->setMonthly(Recurrence::rMonthlyDay,interv,-1); | 1490 | recur->setMonthly(Recurrence::rMonthlyDay,interv,-1); |
1491 | else | 1491 | else |
1492 | recur->setMonthly(Recurrence::rMonthlyDay,interv,r.count); | 1492 | recur->setMonthly(Recurrence::rMonthlyDay,interv,r.count); |
1493 | } | 1493 | } |
1494 | while((day = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1494 | while((day = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1495 | // kdDebug(5800) << "----b " << day << endl; | 1495 | // kdDebug(5800) << "----b " << day << endl; |
1496 | recur->addMonthlyDay(day); | 1496 | recur->addMonthlyDay(day); |
1497 | } | 1497 | } |
1498 | } | 1498 | } |
1499 | break; | 1499 | break; |
1500 | case ICAL_YEARLY_RECURRENCE: | 1500 | case ICAL_YEARLY_RECURRENCE: |
1501 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1501 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1502 | qDebug(" YEARLY DAY OF YEAR"); | ||
1502 | if (!icaltime_is_null_time(r.until)) { | 1503 | if (!icaltime_is_null_time(r.until)) { |
1503 | recur->setYearly(Recurrence::rYearlyDay,interv, | 1504 | recur->setYearly(Recurrence::rYearlyDay,interv, |
1504 | readICalDate(r.until)); | 1505 | readICalDate(r.until)); |
1505 | } else { | 1506 | } else { |
1506 | if (r.count == 0) | 1507 | if (r.count == 0) |
1507 | recur->setYearly(Recurrence::rYearlyDay,interv,-1); | 1508 | recur->setYearly(Recurrence::rYearlyDay,interv,-1); |
1508 | else | 1509 | else |
1509 | recur->setYearly(Recurrence::rYearlyDay,interv,r.count); | 1510 | recur->setYearly(Recurrence::rYearlyDay,interv,r.count); |
1510 | } | 1511 | } |
1511 | while((day = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1512 | while((day = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1512 | recur->addYearlyNum(day); | 1513 | recur->addYearlyNum(day); |
1513 | } | 1514 | } |
1514 | } else if ( true /*r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX*/) { | 1515 | } else if ( true /*r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX*/) { |
1515 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1516 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1517 | qDebug("YEARLY POS NOT SUPPORTED BY GUI"); | ||
1516 | if (!icaltime_is_null_time(r.until)) { | 1518 | if (!icaltime_is_null_time(r.until)) { |
1517 | recur->setYearly(Recurrence::rYearlyPos,interv, | 1519 | recur->setYearly(Recurrence::rYearlyPos,interv, |
1518 | readICalDate(r.until)); | 1520 | readICalDate(r.until)); |
1519 | } else { | 1521 | } else { |
1520 | if (r.count == 0) | 1522 | if (r.count == 0) |
1521 | recur->setYearly(Recurrence::rYearlyPos,interv,-1); | 1523 | recur->setYearly(Recurrence::rYearlyPos,interv,-1); |
1522 | else | 1524 | else |
1523 | recur->setYearly(Recurrence::rYearlyPos,interv,r.count); | 1525 | recur->setYearly(Recurrence::rYearlyPos,interv,r.count); |
1524 | } | 1526 | } |
1525 | bool useSetPos = false; | 1527 | bool useSetPos = false; |
1526 | short pos = 0; | 1528 | short pos = 0; |
1527 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1529 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1528 | // kdDebug(5800) << "----a " << index << ": " << day << endl; | 1530 | // kdDebug(5800) << "----a " << index << ": " << day << endl; |
1529 | pos = icalrecurrencetype_day_position(day); | 1531 | pos = icalrecurrencetype_day_position(day); |
1530 | if (pos) { | 1532 | if (pos) { |
1531 | day = icalrecurrencetype_day_day_of_week(day); | 1533 | day = icalrecurrencetype_day_day_of_week(day); |
1532 | QBitArray ba(7); // don't wipe qba | 1534 | QBitArray ba(7); // don't wipe qba |
1533 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1535 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1534 | recur->addYearlyMonthPos(pos,ba); | 1536 | recur->addYearlyMonthPos(pos,ba); |
1535 | } else { | 1537 | } else { |
1536 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1538 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1537 | useSetPos = true; | 1539 | useSetPos = true; |
1538 | } | 1540 | } |
1539 | } | 1541 | } |
1540 | if (useSetPos) { | 1542 | if (useSetPos) { |
1541 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1543 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1542 | recur->addYearlyMonthPos(r.by_set_pos[0],qba); | 1544 | recur->addYearlyMonthPos(r.by_set_pos[0],qba); |
1543 | } | 1545 | } |
1544 | } | 1546 | } |
1545 | } else { | 1547 | } else { |
1548 | qDebug("YEARLY MONTH "); | ||
1546 | if (!icaltime_is_null_time(r.until)) { | 1549 | if (!icaltime_is_null_time(r.until)) { |
1547 | recur->setYearly(Recurrence::rYearlyMonth,interv, | 1550 | recur->setYearly(Recurrence::rYearlyMonth,interv, |
1548 | readICalDate(r.until)); | 1551 | readICalDate(r.until)); |
1549 | } else { | 1552 | } else { |
1550 | if (r.count == 0) | 1553 | if (r.count == 0) |
1551 | recur->setYearly(Recurrence::rYearlyMonth,interv,-1); | 1554 | recur->setYearly(Recurrence::rYearlyMonth,interv,-1); |
1552 | else | 1555 | else |
1553 | recur->setYearly(Recurrence::rYearlyMonth,interv,r.count); | 1556 | recur->setYearly(Recurrence::rYearlyMonth,interv,r.count); |
1554 | } | 1557 | } |
1555 | } | 1558 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) { |
1556 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) { | 1559 | index = 0; |
1557 | index = 0; | 1560 | while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1558 | while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1561 | recur->addYearlyNum(day); |
1559 | recur->addYearlyNum(day); | 1562 | } |
1563 | } else { | ||
1564 | recur->addYearlyNum(incidence->dtStart().date().month()); | ||
1560 | } | 1565 | } |
1561 | } else { | ||
1562 | recur->addYearlyNum(incidence->dtStart().date().month()); | ||
1563 | } | 1566 | } |
1567 | |||
1564 | } | 1568 | } |
1565 | break; | 1569 | break; |
1566 | default: | 1570 | default: |
1567 | ; | 1571 | ; |
1568 | break; | 1572 | break; |
1569 | } | 1573 | } |
1570 | } | 1574 | } |
1571 | 1575 | ||
1572 | void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) | 1576 | void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) |
1573 | { | 1577 | { |
1574 | //kdDebug(5800) << "Read alarm for " << incidence->summary() << endl; | 1578 | //kdDebug(5800) << "Read alarm for " << incidence->summary() << endl; |
1575 | 1579 | ||
1576 | Alarm* ialarm = incidence->newAlarm(); | 1580 | Alarm* ialarm = incidence->newAlarm(); |
1577 | ialarm->setRepeatCount(0); | 1581 | ialarm->setRepeatCount(0); |
1578 | ialarm->setEnabled(true); | 1582 | ialarm->setEnabled(true); |
1579 | 1583 | ||
1580 | // Determine the alarm's action type | 1584 | // Determine the alarm's action type |
1581 | icalproperty *p = icalcomponent_get_first_property(alarm,ICAL_ACTION_PROPERTY); | 1585 | icalproperty *p = icalcomponent_get_first_property(alarm,ICAL_ACTION_PROPERTY); |
1582 | if ( !p ) { | 1586 | if ( !p ) { |
1583 | return; | 1587 | return; |
1584 | } | 1588 | } |
1585 | 1589 | ||
1586 | icalproperty_action action = icalproperty_get_action(p); | 1590 | icalproperty_action action = icalproperty_get_action(p); |
1587 | Alarm::Type type = Alarm::Display; | 1591 | Alarm::Type type = Alarm::Display; |
1588 | switch ( action ) { | 1592 | switch ( action ) { |
1589 | case ICAL_ACTION_DISPLAY: type = Alarm::Display; break; | 1593 | case ICAL_ACTION_DISPLAY: type = Alarm::Display; break; |
1590 | case ICAL_ACTION_AUDIO: type = Alarm::Audio; break; | 1594 | case ICAL_ACTION_AUDIO: type = Alarm::Audio; break; |
1591 | case ICAL_ACTION_PROCEDURE: type = Alarm::Procedure; break; | 1595 | case ICAL_ACTION_PROCEDURE: type = Alarm::Procedure; break; |
1592 | case ICAL_ACTION_EMAIL: type = Alarm::Email; break; | 1596 | case ICAL_ACTION_EMAIL: type = Alarm::Email; break; |
1593 | default: | 1597 | default: |
1594 | ; | 1598 | ; |
1595 | return; | 1599 | return; |
1596 | } | 1600 | } |
1597 | ialarm->setType(type); | 1601 | ialarm->setType(type); |
1598 | 1602 | ||
1599 | p = icalcomponent_get_first_property(alarm,ICAL_ANY_PROPERTY); | 1603 | p = icalcomponent_get_first_property(alarm,ICAL_ANY_PROPERTY); |
1600 | while (p) { | 1604 | while (p) { |
1601 | icalproperty_kind kind = icalproperty_isa(p); | 1605 | icalproperty_kind kind = icalproperty_isa(p); |
1602 | 1606 | ||
1603 | switch (kind) { | 1607 | switch (kind) { |
1604 | case ICAL_TRIGGER_PROPERTY: { | 1608 | case ICAL_TRIGGER_PROPERTY: { |
1605 | icaltriggertype trigger = icalproperty_get_trigger(p); | 1609 | icaltriggertype trigger = icalproperty_get_trigger(p); |
1606 | if (icaltime_is_null_time(trigger.time)) { | 1610 | if (icaltime_is_null_time(trigger.time)) { |
1607 | if (icaldurationtype_is_null_duration(trigger.duration)) { | 1611 | if (icaldurationtype_is_null_duration(trigger.duration)) { |
1608 | kdDebug(5800) << "ICalFormatImpl::readAlarm(): Trigger has no time and no duration." << endl; | 1612 | kdDebug(5800) << "ICalFormatImpl::readAlarm(): Trigger has no time and no duration." << endl; |
1609 | } else { | 1613 | } else { |
1610 | Duration duration = icaldurationtype_as_int( trigger.duration ); | 1614 | Duration duration = icaldurationtype_as_int( trigger.duration ); |
1611 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_RELATED_PARAMETER); | 1615 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_RELATED_PARAMETER); |
1612 | if (param && icalparameter_get_related(param) == ICAL_RELATED_END) | 1616 | if (param && icalparameter_get_related(param) == ICAL_RELATED_END) |
1613 | ialarm->setEndOffset(duration); | 1617 | ialarm->setEndOffset(duration); |
1614 | else | 1618 | else |
1615 | ialarm->setStartOffset(duration); | 1619 | ialarm->setStartOffset(duration); |
1616 | } | 1620 | } |
1617 | } else { | 1621 | } else { |
1618 | ialarm->setTime(readICalDateTime(trigger.time)); | 1622 | ialarm->setTime(readICalDateTime(trigger.time)); |
1619 | } | 1623 | } |
1620 | break; | 1624 | break; |
1621 | } | 1625 | } |
1622 | case ICAL_DURATION_PROPERTY: { | 1626 | case ICAL_DURATION_PROPERTY: { |
1623 | icaldurationtype duration = icalproperty_get_duration(p); | 1627 | icaldurationtype duration = icalproperty_get_duration(p); |
1624 | ialarm->setSnoozeTime(icaldurationtype_as_int(duration)/60); | 1628 | ialarm->setSnoozeTime(icaldurationtype_as_int(duration)/60); |
1625 | break; | 1629 | break; |
1626 | } | 1630 | } |
1627 | case ICAL_REPEAT_PROPERTY: | 1631 | case ICAL_REPEAT_PROPERTY: |
1628 | ialarm->setRepeatCount(icalproperty_get_repeat(p)); | 1632 | ialarm->setRepeatCount(icalproperty_get_repeat(p)); |
1629 | break; | 1633 | break; |
1630 | 1634 | ||
1631 | // Only in DISPLAY and EMAIL and PROCEDURE alarms | 1635 | // Only in DISPLAY and EMAIL and PROCEDURE alarms |
1632 | case ICAL_DESCRIPTION_PROPERTY: { | 1636 | case ICAL_DESCRIPTION_PROPERTY: { |
1633 | QString description = QString::fromUtf8(icalproperty_get_description(p)); | 1637 | QString description = QString::fromUtf8(icalproperty_get_description(p)); |
1634 | switch ( action ) { | 1638 | switch ( action ) { |
1635 | case ICAL_ACTION_DISPLAY: | 1639 | case ICAL_ACTION_DISPLAY: |
1636 | ialarm->setText( description ); | 1640 | ialarm->setText( description ); |
1637 | break; | 1641 | break; |
1638 | case ICAL_ACTION_PROCEDURE: | 1642 | case ICAL_ACTION_PROCEDURE: |
1639 | ialarm->setProgramArguments( description ); | 1643 | ialarm->setProgramArguments( description ); |
1640 | break; | 1644 | break; |
1641 | case ICAL_ACTION_EMAIL: | 1645 | case ICAL_ACTION_EMAIL: |
1642 | ialarm->setMailText( description ); | 1646 | ialarm->setMailText( description ); |
1643 | break; | 1647 | break; |
1644 | default: | 1648 | default: |
1645 | break; | 1649 | break; |
1646 | } | 1650 | } |
1647 | break; | 1651 | break; |
1648 | } | 1652 | } |
1649 | // Only in EMAIL alarm | 1653 | // Only in EMAIL alarm |
1650 | case ICAL_SUMMARY_PROPERTY: | 1654 | case ICAL_SUMMARY_PROPERTY: |
1651 | ialarm->setMailSubject(QString::fromUtf8(icalproperty_get_summary(p))); | 1655 | ialarm->setMailSubject(QString::fromUtf8(icalproperty_get_summary(p))); |
1652 | break; | 1656 | break; |
1653 | 1657 | ||
1654 | // Only in EMAIL alarm | 1658 | // Only in EMAIL alarm |
1655 | case ICAL_ATTENDEE_PROPERTY: { | 1659 | case ICAL_ATTENDEE_PROPERTY: { |
1656 | QString email = QString::fromUtf8(icalproperty_get_attendee(p)); | 1660 | QString email = QString::fromUtf8(icalproperty_get_attendee(p)); |
1657 | QString name; | 1661 | QString name; |
1658 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_CN_PARAMETER); | 1662 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_CN_PARAMETER); |
1659 | if (param) { | 1663 | if (param) { |
1660 | name = QString::fromUtf8(icalparameter_get_cn(param)); | 1664 | name = QString::fromUtf8(icalparameter_get_cn(param)); |
1661 | } | 1665 | } |
1662 | ialarm->addMailAddress(Person(name, email)); | 1666 | ialarm->addMailAddress(Person(name, email)); |
1663 | break; | 1667 | break; |
1664 | } | 1668 | } |
1665 | // Only in AUDIO and EMAIL and PROCEDURE alarms | 1669 | // Only in AUDIO and EMAIL and PROCEDURE alarms |
1666 | case ICAL_ATTACH_PROPERTY: { | 1670 | case ICAL_ATTACH_PROPERTY: { |
1667 | icalattach *attach = icalproperty_get_attach(p); | 1671 | icalattach *attach = icalproperty_get_attach(p); |
1668 | QString url = QFile::decodeName(icalattach_get_url(attach)); | 1672 | QString url = QFile::decodeName(icalattach_get_url(attach)); |
1669 | switch ( action ) { | 1673 | switch ( action ) { |
1670 | case ICAL_ACTION_AUDIO: | 1674 | case ICAL_ACTION_AUDIO: |
1671 | ialarm->setAudioFile( url ); | 1675 | ialarm->setAudioFile( url ); |
1672 | break; | 1676 | break; |
1673 | case ICAL_ACTION_PROCEDURE: | 1677 | case ICAL_ACTION_PROCEDURE: |
1674 | ialarm->setProgramFile( url ); | 1678 | ialarm->setProgramFile( url ); |
1675 | break; | 1679 | break; |
1676 | case ICAL_ACTION_EMAIL: | 1680 | case ICAL_ACTION_EMAIL: |
1677 | ialarm->addMailAttachment( url ); | 1681 | ialarm->addMailAttachment( url ); |
1678 | break; | 1682 | break; |
1679 | default: | 1683 | default: |
1680 | break; | 1684 | break; |
1681 | } | 1685 | } |
1682 | break; | 1686 | break; |
1683 | } | 1687 | } |
1684 | default: | 1688 | default: |
1685 | break; | 1689 | break; |
1686 | } | 1690 | } |
1687 | 1691 | ||
1688 | p = icalcomponent_get_next_property(alarm,ICAL_ANY_PROPERTY); | 1692 | p = icalcomponent_get_next_property(alarm,ICAL_ANY_PROPERTY); |
1689 | } | 1693 | } |
1690 | 1694 | ||
1691 | // custom properties | 1695 | // custom properties |
1692 | readCustomProperties(alarm, ialarm); | 1696 | readCustomProperties(alarm, ialarm); |
1693 | 1697 | ||
1694 | // TODO: check for consistency of alarm properties | 1698 | // TODO: check for consistency of alarm properties |
1695 | } | 1699 | } |
1696 | 1700 | ||
1697 | icaltimetype ICalFormatImpl::writeICalDate(const QDate &date) | 1701 | icaltimetype ICalFormatImpl::writeICalDate(const QDate &date) |
1698 | { | 1702 | { |
1699 | icaltimetype t; | 1703 | icaltimetype t; |
1700 | 1704 | ||
1701 | t.year = date.year(); | 1705 | t.year = date.year(); |
1702 | t.month = date.month(); | 1706 | t.month = date.month(); |
1703 | t.day = date.day(); | 1707 | t.day = date.day(); |
1704 | 1708 | ||
1705 | t.hour = 0; | 1709 | t.hour = 0; |
1706 | t.minute = 0; | 1710 | t.minute = 0; |
1707 | t.second = 0; | 1711 | t.second = 0; |
1708 | 1712 | ||
1709 | t.is_date = 1; | 1713 | t.is_date = 1; |
1710 | 1714 | ||
1711 | t.is_utc = 0; | 1715 | t.is_utc = 0; |
1712 | 1716 | ||
1713 | t.zone = 0; | 1717 | t.zone = 0; |
1714 | 1718 | ||
1715 | return t; | 1719 | return t; |
1716 | } | 1720 | } |
1717 | 1721 | ||
1718 | icaltimetype ICalFormatImpl::writeICalDateTime(const QDateTime &dt ) | 1722 | icaltimetype ICalFormatImpl::writeICalDateTime(const QDateTime &dt ) |
1719 | { | 1723 | { |
1720 | icaltimetype t; | 1724 | icaltimetype t; |
1721 | t.is_date = 0; | 1725 | t.is_date = 0; |
1722 | t.zone = 0; | 1726 | t.zone = 0; |
1723 | QDateTime datetime; | 1727 | QDateTime datetime; |
1724 | if ( mParent->utc() ) { | 1728 | if ( mParent->utc() ) { |
1725 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 1729 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
1726 | datetime = dt.addSecs ( -offset*60); | 1730 | datetime = dt.addSecs ( -offset*60); |
1727 | t.is_utc = 1; | 1731 | t.is_utc = 1; |
1728 | } | 1732 | } |
1729 | else { | 1733 | else { |
1730 | datetime = dt; | 1734 | datetime = dt; |
1731 | t.is_utc = 0; | 1735 | t.is_utc = 0; |
1732 | 1736 | ||
1733 | } | 1737 | } |
1734 | t.year = datetime.date().year(); | 1738 | t.year = datetime.date().year(); |
1735 | t.month = datetime.date().month(); | 1739 | t.month = datetime.date().month(); |
1736 | t.day = datetime.date().day(); | 1740 | t.day = datetime.date().day(); |
1737 | 1741 | ||
1738 | t.hour = datetime.time().hour(); | 1742 | t.hour = datetime.time().hour(); |
1739 | t.minute = datetime.time().minute(); | 1743 | t.minute = datetime.time().minute(); |
1740 | t.second = datetime.time().second(); | 1744 | t.second = datetime.time().second(); |
1741 | 1745 | ||
1742 | //qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); | 1746 | //qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); |
1743 | 1747 | ||
1744 | // if ( mParent->utc() ) { | 1748 | // if ( mParent->utc() ) { |
1745 | // datetime = KGlobal::locale()->localTime( dt ); | 1749 | // datetime = KGlobal::locale()->localTime( dt ); |
1746 | // qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); | 1750 | // qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); |
1747 | // if (mParent->timeZoneId().isEmpty()) | 1751 | // if (mParent->timeZoneId().isEmpty()) |
1748 | // t = icaltime_as_utc(t, 0); | 1752 | // t = icaltime_as_utc(t, 0); |
1749 | // else | 1753 | // else |
1750 | // t = icaltime_as_utc(t,mParent->timeZoneId().local8Bit()); | 1754 | // t = icaltime_as_utc(t,mParent->timeZoneId().local8Bit()); |
1751 | // } | 1755 | // } |
1752 | 1756 | ||
1753 | return t; | 1757 | return t; |
1754 | } | 1758 | } |
1755 | 1759 | ||
diff --git a/libkcal/recurrence.cpp b/libkcal/recurrence.cpp index 5fc5d1f..dd74e10 100644 --- a/libkcal/recurrence.cpp +++ b/libkcal/recurrence.cpp | |||
@@ -465,456 +465,469 @@ QString Recurrence::endDateStr(bool shortfmt) const | |||
465 | 465 | ||
466 | const QBitArray &Recurrence::days() const | 466 | const QBitArray &Recurrence::days() const |
467 | { | 467 | { |
468 | return rDays; | 468 | return rDays; |
469 | } | 469 | } |
470 | 470 | ||
471 | const QPtrList<Recurrence::rMonthPos> &Recurrence::monthPositions() const | 471 | const QPtrList<Recurrence::rMonthPos> &Recurrence::monthPositions() const |
472 | { | 472 | { |
473 | return rMonthPositions; | 473 | return rMonthPositions; |
474 | } | 474 | } |
475 | 475 | ||
476 | const QPtrList<Recurrence::rMonthPos> &Recurrence::yearMonthPositions() const | 476 | const QPtrList<Recurrence::rMonthPos> &Recurrence::yearMonthPositions() const |
477 | { | 477 | { |
478 | return rMonthPositions; | 478 | return rMonthPositions; |
479 | } | 479 | } |
480 | 480 | ||
481 | const QPtrList<int> &Recurrence::monthDays() const | 481 | const QPtrList<int> &Recurrence::monthDays() const |
482 | { | 482 | { |
483 | return rMonthDays; | 483 | return rMonthDays; |
484 | } | 484 | } |
485 | 485 | ||
486 | void Recurrence::setMinutely(int _rFreq, int _rDuration) | 486 | void Recurrence::setMinutely(int _rFreq, int _rDuration) |
487 | { | 487 | { |
488 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) | 488 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) |
489 | return; | 489 | return; |
490 | setDailySub(rMinutely, _rFreq, _rDuration); | 490 | setDailySub(rMinutely, _rFreq, _rDuration); |
491 | } | 491 | } |
492 | 492 | ||
493 | void Recurrence::setMinutely(int _rFreq, const QDateTime &_rEndDateTime) | 493 | void Recurrence::setMinutely(int _rFreq, const QDateTime &_rEndDateTime) |
494 | { | 494 | { |
495 | if (mRecurReadOnly) return; | 495 | if (mRecurReadOnly) return; |
496 | rEndDateTime = _rEndDateTime; | 496 | rEndDateTime = _rEndDateTime; |
497 | setDailySub(rMinutely, _rFreq, 0); | 497 | setDailySub(rMinutely, _rFreq, 0); |
498 | } | 498 | } |
499 | 499 | ||
500 | void Recurrence::setHourly(int _rFreq, int _rDuration) | 500 | void Recurrence::setHourly(int _rFreq, int _rDuration) |
501 | { | 501 | { |
502 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) | 502 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) |
503 | return; | 503 | return; |
504 | setDailySub(rHourly, _rFreq, _rDuration); | 504 | setDailySub(rHourly, _rFreq, _rDuration); |
505 | } | 505 | } |
506 | 506 | ||
507 | void Recurrence::setHourly(int _rFreq, const QDateTime &_rEndDateTime) | 507 | void Recurrence::setHourly(int _rFreq, const QDateTime &_rEndDateTime) |
508 | { | 508 | { |
509 | if (mRecurReadOnly) return; | 509 | if (mRecurReadOnly) return; |
510 | rEndDateTime = _rEndDateTime; | 510 | rEndDateTime = _rEndDateTime; |
511 | setDailySub(rHourly, _rFreq, 0); | 511 | setDailySub(rHourly, _rFreq, 0); |
512 | } | 512 | } |
513 | 513 | ||
514 | void Recurrence::setDaily(int _rFreq, int _rDuration) | 514 | void Recurrence::setDaily(int _rFreq, int _rDuration) |
515 | { | 515 | { |
516 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) | 516 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) |
517 | return; | 517 | return; |
518 | setDailySub(rDaily, _rFreq, _rDuration); | 518 | setDailySub(rDaily, _rFreq, _rDuration); |
519 | } | 519 | } |
520 | 520 | ||
521 | void Recurrence::setDaily(int _rFreq, const QDate &_rEndDate) | 521 | void Recurrence::setDaily(int _rFreq, const QDate &_rEndDate) |
522 | { | 522 | { |
523 | if (mRecurReadOnly) return; | 523 | if (mRecurReadOnly) return; |
524 | rEndDateTime.setDate(_rEndDate); | 524 | rEndDateTime.setDate(_rEndDate); |
525 | rEndDateTime.setTime(mRecurStart.time()); | 525 | rEndDateTime.setTime(mRecurStart.time()); |
526 | setDailySub(rDaily, _rFreq, 0); | 526 | setDailySub(rDaily, _rFreq, 0); |
527 | } | 527 | } |
528 | 528 | ||
529 | void Recurrence::setWeekly(int _rFreq, const QBitArray &_rDays, | 529 | void Recurrence::setWeekly(int _rFreq, const QBitArray &_rDays, |
530 | int _rDuration, int _rWeekStart) | 530 | int _rDuration, int _rWeekStart) |
531 | { | 531 | { |
532 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) | 532 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) |
533 | return; | 533 | return; |
534 | recurs = rWeekly; | 534 | recurs = rWeekly; |
535 | 535 | ||
536 | rFreq = _rFreq; | 536 | rFreq = _rFreq; |
537 | rDays = _rDays; | 537 | rDays = _rDays; |
538 | rWeekStart = _rWeekStart; | 538 | rWeekStart = _rWeekStart; |
539 | rDuration = _rDuration; | 539 | rDuration = _rDuration; |
540 | if (mCompatVersion < 310 && _rDuration > 0) { | 540 | if (mCompatVersion < 310 && _rDuration > 0) { |
541 | // Backwards compatibility for KDE < 3.1. | 541 | // Backwards compatibility for KDE < 3.1. |
542 | // rDuration was set to the number of time periods to recur, | 542 | // rDuration was set to the number of time periods to recur, |
543 | // with week start always on a Monday. | 543 | // with week start always on a Monday. |
544 | // Convert this to the number of occurrences. | 544 | // Convert this to the number of occurrences. |
545 | mCompatDuration = _rDuration; | 545 | mCompatDuration = _rDuration; |
546 | int weeks = ((mCompatDuration-1+mRecurExDatesCount)*7) + (7 - mRecurStart.date().dayOfWeek()); | 546 | int weeks = ((mCompatDuration-1+mRecurExDatesCount)*7) + (7 - mRecurStart.date().dayOfWeek()); |
547 | QDate end(mRecurStart.date().addDays(weeks * rFreq)); | 547 | QDate end(mRecurStart.date().addDays(weeks * rFreq)); |
548 | rDuration = INT_MAX; // ensure that weeklyCalc() does its job correctly | 548 | rDuration = INT_MAX; // ensure that weeklyCalc() does its job correctly |
549 | rDuration = weeklyCalc(COUNT_TO_DATE, end); | 549 | rDuration = weeklyCalc(COUNT_TO_DATE, end); |
550 | } else { | 550 | } else { |
551 | mCompatDuration = 0; | 551 | mCompatDuration = 0; |
552 | } | 552 | } |
553 | rMonthPositions.clear(); | 553 | rMonthPositions.clear(); |
554 | rMonthDays.clear(); | 554 | rMonthDays.clear(); |
555 | if (mParent) mParent->updated(); | 555 | if (mParent) mParent->updated(); |
556 | } | 556 | } |
557 | 557 | ||
558 | void Recurrence::setWeekly(int _rFreq, const QBitArray &_rDays, | 558 | void Recurrence::setWeekly(int _rFreq, const QBitArray &_rDays, |
559 | const QDate &_rEndDate, int _rWeekStart) | 559 | const QDate &_rEndDate, int _rWeekStart) |
560 | { | 560 | { |
561 | if (mRecurReadOnly) return; | 561 | if (mRecurReadOnly) return; |
562 | recurs = rWeekly; | 562 | recurs = rWeekly; |
563 | 563 | ||
564 | rFreq = _rFreq; | 564 | rFreq = _rFreq; |
565 | rDays = _rDays; | 565 | rDays = _rDays; |
566 | rWeekStart = _rWeekStart; | 566 | rWeekStart = _rWeekStart; |
567 | rEndDateTime.setDate(_rEndDate); | 567 | rEndDateTime.setDate(_rEndDate); |
568 | rEndDateTime.setTime(mRecurStart.time()); | 568 | rEndDateTime.setTime(mRecurStart.time()); |
569 | rDuration = 0; // set to 0 because there is an end date | 569 | rDuration = 0; // set to 0 because there is an end date |
570 | mCompatDuration = 0; | 570 | mCompatDuration = 0; |
571 | rMonthPositions.clear(); | 571 | rMonthPositions.clear(); |
572 | rMonthDays.clear(); | 572 | rMonthDays.clear(); |
573 | rYearNums.clear(); | 573 | rYearNums.clear(); |
574 | if (mParent) mParent->updated(); | 574 | if (mParent) mParent->updated(); |
575 | } | 575 | } |
576 | 576 | ||
577 | void Recurrence::setMonthly(short type, int _rFreq, int _rDuration) | 577 | void Recurrence::setMonthly(short type, int _rFreq, int _rDuration) |
578 | { | 578 | { |
579 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) | 579 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) |
580 | return; | 580 | return; |
581 | recurs = type; | 581 | recurs = type; |
582 | 582 | ||
583 | rFreq = _rFreq; | 583 | rFreq = _rFreq; |
584 | rDuration = _rDuration; | 584 | rDuration = _rDuration; |
585 | if (mCompatVersion < 310) | 585 | if (mCompatVersion < 310) |
586 | mCompatDuration = (_rDuration > 0) ? _rDuration : 0; | 586 | mCompatDuration = (_rDuration > 0) ? _rDuration : 0; |
587 | rYearNums.clear(); | 587 | rYearNums.clear(); |
588 | if (mParent) mParent->updated(); | 588 | if (mParent) mParent->updated(); |
589 | } | 589 | } |
590 | 590 | ||
591 | void Recurrence::setMonthly(short type, int _rFreq, | 591 | void Recurrence::setMonthly(short type, int _rFreq, |
592 | const QDate &_rEndDate) | 592 | const QDate &_rEndDate) |
593 | { | 593 | { |
594 | if (mRecurReadOnly) return; | 594 | if (mRecurReadOnly) return; |
595 | recurs = type; | 595 | recurs = type; |
596 | 596 | ||
597 | rFreq = _rFreq; | 597 | rFreq = _rFreq; |
598 | rEndDateTime.setDate(_rEndDate); | 598 | rEndDateTime.setDate(_rEndDate); |
599 | rEndDateTime.setTime(mRecurStart.time()); | 599 | rEndDateTime.setTime(mRecurStart.time()); |
600 | rDuration = 0; // set to 0 because there is an end date | 600 | rDuration = 0; // set to 0 because there is an end date |
601 | mCompatDuration = 0; | 601 | mCompatDuration = 0; |
602 | rYearNums.clear(); | 602 | rYearNums.clear(); |
603 | if (mParent) mParent->updated(); | 603 | if (mParent) mParent->updated(); |
604 | } | 604 | } |
605 | 605 | ||
606 | void Recurrence::addMonthlyPos(short _rPos, const QBitArray &_rDays) | 606 | void Recurrence::addMonthlyPos(short _rPos, const QBitArray &_rDays) |
607 | { | 607 | { |
608 | if (recurs == rMonthlyPos) | 608 | if (recurs == rMonthlyPos) |
609 | addMonthlyPos_(_rPos, _rDays); | 609 | addMonthlyPos_(_rPos, _rDays); |
610 | } | 610 | } |
611 | 611 | ||
612 | void Recurrence::addMonthlyPos_(short _rPos, const QBitArray &_rDays) | 612 | void Recurrence::addMonthlyPos_(short _rPos, const QBitArray &_rDays) |
613 | { | 613 | { |
614 | if (mRecurReadOnly | 614 | if (mRecurReadOnly |
615 | || _rPos == 0 || _rPos > 5 || _rPos < -5) // invalid week number | 615 | || _rPos == 0 || _rPos > 5 || _rPos < -5) // invalid week number |
616 | return; | 616 | return; |
617 | 617 | ||
618 | for (rMonthPos* it = rMonthPositions.first(); it; it = rMonthPositions.next()) { | 618 | for (rMonthPos* it = rMonthPositions.first(); it; it = rMonthPositions.next()) { |
619 | int itPos = it->negative ? -it->rPos : it->rPos; | 619 | int itPos = it->negative ? -it->rPos : it->rPos; |
620 | if (_rPos == itPos) { | 620 | if (_rPos == itPos) { |
621 | // This week is already in the list. | 621 | // This week is already in the list. |
622 | // Combine the specified days with those in the list. | 622 | // Combine the specified days with those in the list. |
623 | it->rDays |= _rDays; | 623 | it->rDays |= _rDays; |
624 | if (mParent) mParent->updated(); | 624 | if (mParent) mParent->updated(); |
625 | return; | 625 | return; |
626 | } | 626 | } |
627 | } | 627 | } |
628 | // Add the new position to the list | 628 | // Add the new position to the list |
629 | rMonthPos *tmpPos = new rMonthPos; | 629 | rMonthPos *tmpPos = new rMonthPos; |
630 | if (_rPos > 0) { | 630 | if (_rPos > 0) { |
631 | tmpPos->rPos = _rPos; | 631 | tmpPos->rPos = _rPos; |
632 | tmpPos->negative = false; | 632 | tmpPos->negative = false; |
633 | } else { | 633 | } else { |
634 | tmpPos->rPos = -_rPos; // take abs() | 634 | tmpPos->rPos = -_rPos; // take abs() |
635 | tmpPos->negative = true; | 635 | tmpPos->negative = true; |
636 | } | 636 | } |
637 | tmpPos->rDays = _rDays; | 637 | tmpPos->rDays = _rDays; |
638 | tmpPos->rDays.detach(); | 638 | tmpPos->rDays.detach(); |
639 | rMonthPositions.append(tmpPos); | 639 | rMonthPositions.append(tmpPos); |
640 | 640 | ||
641 | if (mCompatVersion < 310 && mCompatDuration > 0) { | 641 | if (mCompatVersion < 310 && mCompatDuration > 0) { |
642 | // Backwards compatibility for KDE < 3.1. | 642 | // Backwards compatibility for KDE < 3.1. |
643 | // rDuration was set to the number of time periods to recur. | 643 | // rDuration was set to the number of time periods to recur. |
644 | // Convert this to the number of occurrences. | 644 | // Convert this to the number of occurrences. |
645 | int monthsAhead = (mCompatDuration-1+mRecurExDatesCount) * rFreq; | 645 | int monthsAhead = (mCompatDuration-1+mRecurExDatesCount) * rFreq; |
646 | int month = mRecurStart.date().month() - 1 + monthsAhead; | 646 | int month = mRecurStart.date().month() - 1 + monthsAhead; |
647 | QDate end(mRecurStart.date().year() + month/12, month%12 + 1, 31); | 647 | QDate end(mRecurStart.date().year() + month/12, month%12 + 1, 31); |
648 | rDuration = INT_MAX; // ensure that recurCalc() does its job correctly | 648 | rDuration = INT_MAX; // ensure that recurCalc() does its job correctly |
649 | rDuration = recurCalc(COUNT_TO_DATE, end); | 649 | rDuration = recurCalc(COUNT_TO_DATE, end); |
650 | } | 650 | } |
651 | 651 | ||
652 | if (mParent) mParent->updated(); | 652 | if (mParent) mParent->updated(); |
653 | } | 653 | } |
654 | 654 | ||
655 | void Recurrence::addMonthlyDay(short _rDay) | 655 | void Recurrence::addMonthlyDay(short _rDay) |
656 | { | 656 | { |
657 | if (mRecurReadOnly || recurs != rMonthlyDay | 657 | if (mRecurReadOnly || (recurs != rMonthlyDay && recurs != rYearlyMonth) |
658 | || _rDay == 0 || _rDay > 31 || _rDay < -31) // invalid day number | 658 | || _rDay == 0 || _rDay > 31 || _rDay < -31) // invalid day number |
659 | return; | 659 | return; |
660 | for (int* it = rMonthDays.first(); it; it = rMonthDays.next()) { | 660 | for (int* it = rMonthDays.first(); it; it = rMonthDays.next()) { |
661 | if (_rDay == *it) | 661 | if (_rDay == *it) |
662 | return; // this day is already in the list - avoid duplication | 662 | return; // this day is already in the list - avoid duplication |
663 | } | 663 | } |
664 | int *tmpDay = new int; | 664 | int *tmpDay = new int; |
665 | *tmpDay = _rDay; | 665 | *tmpDay = _rDay; |
666 | rMonthDays.append(tmpDay); | 666 | rMonthDays.append(tmpDay); |
667 | 667 | ||
668 | if (mCompatVersion < 310 && mCompatDuration > 0) { | 668 | if (mCompatVersion < 310 && mCompatDuration > 0) { |
669 | // Backwards compatibility for KDE < 3.1. | 669 | // Backwards compatibility for KDE < 3.1. |
670 | // rDuration was set to the number of time periods to recur. | 670 | // rDuration was set to the number of time periods to recur. |
671 | // Convert this to the number of occurrences. | 671 | // Convert this to the number of occurrences. |
672 | int monthsAhead = (mCompatDuration-1+mRecurExDatesCount) * rFreq; | 672 | int monthsAhead = (mCompatDuration-1+mRecurExDatesCount) * rFreq; |
673 | int month = mRecurStart.date().month() - 1 + monthsAhead; | 673 | int month = mRecurStart.date().month() - 1 + monthsAhead; |
674 | QDate end(mRecurStart.date().year() + month/12, month%12 + 1, 31); | 674 | QDate end(mRecurStart.date().year() + month/12, month%12 + 1, 31); |
675 | rDuration = INT_MAX; // ensure that recurCalc() does its job correctly | 675 | rDuration = INT_MAX; // ensure that recurCalc() does its job correctly |
676 | rDuration = recurCalc(COUNT_TO_DATE, end); | 676 | rDuration = recurCalc(COUNT_TO_DATE, end); |
677 | } | 677 | } |
678 | 678 | ||
679 | if (mParent) mParent->updated(); | 679 | if (mParent) mParent->updated(); |
680 | } | 680 | } |
681 | 681 | ||
682 | void Recurrence::setYearly(int type, int _rFreq, int _rDuration) | 682 | void Recurrence::setYearly(int type, int _rFreq, int _rDuration) |
683 | { | 683 | { |
684 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) | 684 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) |
685 | return; | 685 | return; |
686 | if (mCompatVersion < 310) | 686 | if (mCompatVersion < 310) |
687 | mCompatDuration = (_rDuration > 0) ? _rDuration : 0; | 687 | mCompatDuration = (_rDuration > 0) ? _rDuration : 0; |
688 | setYearly_(type, mFeb29YearlyDefaultType, _rFreq, _rDuration); | 688 | setYearly_(type, mFeb29YearlyDefaultType, _rFreq, _rDuration); |
689 | } | 689 | } |
690 | 690 | ||
691 | void Recurrence::setYearly(int type, int _rFreq, const QDate &_rEndDate) | 691 | void Recurrence::setYearly(int type, int _rFreq, const QDate &_rEndDate) |
692 | { | 692 | { |
693 | if (mRecurReadOnly) return; | 693 | if (mRecurReadOnly) return; |
694 | rEndDateTime.setDate(_rEndDate); | 694 | rEndDateTime.setDate(_rEndDate); |
695 | rEndDateTime.setTime(mRecurStart.time()); | 695 | rEndDateTime.setTime(mRecurStart.time()); |
696 | mCompatDuration = 0; | 696 | mCompatDuration = 0; |
697 | setYearly_(type, mFeb29YearlyDefaultType, _rFreq, 0); | 697 | setYearly_(type, mFeb29YearlyDefaultType, _rFreq, 0); |
698 | } | 698 | } |
699 | 699 | ||
700 | void Recurrence::setYearlyByDate(Feb29Type type, int _rFreq, int _rDuration) | 700 | void Recurrence::setYearlyByDate(Feb29Type type, int _rFreq, int _rDuration) |
701 | { | 701 | { |
702 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) | 702 | if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) |
703 | return; | 703 | return; |
704 | if (mCompatVersion < 310) | 704 | if (mCompatVersion < 310) |
705 | mCompatDuration = (_rDuration > 0) ? _rDuration : 0; | 705 | mCompatDuration = (_rDuration > 0) ? _rDuration : 0; |
706 | setYearly_(rYearlyMonth, type, _rFreq, _rDuration); | 706 | setYearly_(rYearlyMonth, type, _rFreq, _rDuration); |
707 | } | 707 | } |
708 | 708 | ||
709 | void Recurrence::setYearlyByDate(Feb29Type type, int _rFreq, const QDate &_rEndDate) | 709 | void Recurrence::setYearlyByDate(Feb29Type type, int _rFreq, const QDate &_rEndDate) |
710 | { | 710 | { |
711 | if (mRecurReadOnly) return; | 711 | if (mRecurReadOnly) return; |
712 | rEndDateTime.setDate(_rEndDate); | 712 | rEndDateTime.setDate(_rEndDate); |
713 | rEndDateTime.setTime(mRecurStart.time()); | 713 | rEndDateTime.setTime(mRecurStart.time()); |
714 | mCompatDuration = 0; | 714 | mCompatDuration = 0; |
715 | setYearly_(rYearlyMonth, type, _rFreq, 0); | 715 | setYearly_(rYearlyMonth, type, _rFreq, 0); |
716 | } | 716 | } |
717 | 717 | ||
718 | void Recurrence::addYearlyMonthPos(short _rPos, const QBitArray &_rDays) | 718 | void Recurrence::addYearlyMonthPos(short _rPos, const QBitArray &_rDays) |
719 | { | 719 | { |
720 | if (recurs == rYearlyPos) | 720 | if (recurs == rYearlyPos) |
721 | addMonthlyPos_(_rPos, _rDays); | 721 | addMonthlyPos_(_rPos, _rDays); |
722 | } | 722 | } |
723 | 723 | ||
724 | const QPtrList<int> &Recurrence::yearNums() const | 724 | const QPtrList<int> &Recurrence::yearNums() const |
725 | { | 725 | { |
726 | return rYearNums; | 726 | return rYearNums; |
727 | } | 727 | } |
728 | 728 | void Recurrence::addYearlyMonth(short _rPos ) | |
729 | { | ||
730 | if (mRecurReadOnly || recurs != rYearlyMonth) // invalid day/month number | ||
731 | return; | ||
732 | rMonthPos *tmpPos = new rMonthPos; | ||
733 | if ( _rPos > 0) { | ||
734 | tmpPos->rPos = _rPos; | ||
735 | tmpPos->negative = false; | ||
736 | } else { | ||
737 | tmpPos->rPos = -_rPos; // take abs() | ||
738 | tmpPos->negative = true; | ||
739 | } | ||
740 | rMonthPositions.append(tmpPos); | ||
741 | } | ||
729 | void Recurrence::addYearlyNum(short _rNum) | 742 | void Recurrence::addYearlyNum(short _rNum) |
730 | { | 743 | { |
731 | if (mRecurReadOnly | 744 | if (mRecurReadOnly |
732 | || (recurs != rYearlyMonth && recurs != rYearlyDay && recurs != rYearlyPos) | 745 | || (recurs != rYearlyMonth && recurs != rYearlyDay && recurs != rYearlyPos) |
733 | || _rNum <= 0) // invalid day/month number | 746 | || _rNum <= 0) // invalid day/month number |
734 | return; | 747 | return; |
735 | 748 | ||
736 | if (mCompatVersion < 310 && mCompatRecurs == rYearlyDay) { | 749 | if (mCompatVersion < 310 && mCompatRecurs == rYearlyDay) { |
737 | // Backwards compatibility for KDE < 3.1. | 750 | // Backwards compatibility for KDE < 3.1. |
738 | // Dates were stored as day numbers, with a fiddle to take account of leap years. | 751 | // Dates were stored as day numbers, with a fiddle to take account of leap years. |
739 | // Convert the day number to a month. | 752 | // Convert the day number to a month. |
740 | if (_rNum <= 0 || _rNum > 366 || (_rNum == 366 && mRecurStart.date().daysInYear() < 366)) | 753 | if (_rNum <= 0 || _rNum > 366 || (_rNum == 366 && mRecurStart.date().daysInYear() < 366)) |
741 | return; // invalid day number | 754 | return; // invalid day number |
742 | _rNum = QDate(mRecurStart.date().year(), 1, 1).addDays(_rNum - 1).month(); | 755 | _rNum = QDate(mRecurStart.date().year(), 1, 1).addDays(_rNum - 1).month(); |
743 | } else | 756 | } else |
744 | if ((recurs == rYearlyMonth || recurs == rYearlyPos) && _rNum > 12 | 757 | if ((recurs == rYearlyMonth || recurs == rYearlyPos) && _rNum > 12 |
745 | || recurs == rYearlyDay && _rNum > 366) | 758 | || recurs == rYearlyDay && _rNum > 366) |
746 | return; // invalid day number | 759 | return; // invalid day number |
747 | 760 | ||
748 | uint i = 0; | 761 | uint i = 0; |
749 | for (int* it = rYearNums.first(); it && _rNum >= *it; it = rYearNums.next()) { | 762 | for (int* it = rYearNums.first(); it && _rNum >= *it; it = rYearNums.next()) { |
750 | if (_rNum == *it) | 763 | if (_rNum == *it) |
751 | return; // this day/month is already in the list - avoid duplication | 764 | return; // this day/month is already in the list - avoid duplication |
752 | ++i; | 765 | ++i; |
753 | } | 766 | } |
754 | 767 | ||
755 | int *tmpNum = new int; | 768 | int *tmpNum = new int; |
756 | *tmpNum = _rNum; | 769 | *tmpNum = _rNum; |
757 | rYearNums.insert(i, tmpNum); // insert the day/month in a sorted position | 770 | rYearNums.insert(i, tmpNum); // insert the day/month in a sorted position |
758 | 771 | ||
759 | if (mCompatVersion < 310 && mCompatDuration > 0) { | 772 | if (mCompatVersion < 310 && mCompatDuration > 0) { |
760 | // Backwards compatibility for KDE < 3.1. | 773 | // Backwards compatibility for KDE < 3.1. |
761 | // rDuration was set to the number of time periods to recur. | 774 | // rDuration was set to the number of time periods to recur. |
762 | // Convert this to the number of occurrences. | 775 | // Convert this to the number of occurrences. |
763 | QDate end(mRecurStart.date().year() + (mCompatDuration-1+mRecurExDatesCount)*rFreq, 12, 31); | 776 | QDate end(mRecurStart.date().year() + (mCompatDuration-1+mRecurExDatesCount)*rFreq, 12, 31); |
764 | rDuration = INT_MAX; // ensure that recurCalc() does its job correctly | 777 | rDuration = INT_MAX; // ensure that recurCalc() does its job correctly |
765 | rDuration = recurCalc(COUNT_TO_DATE, end); | 778 | rDuration = recurCalc(COUNT_TO_DATE, end); |
766 | } | 779 | } |
767 | 780 | ||
768 | if (mParent) mParent->updated(); | 781 | if (mParent) mParent->updated(); |
769 | } | 782 | } |
770 | 783 | ||
771 | 784 | ||
772 | QDateTime Recurrence::getNextDateTime(const QDateTime &preDateTime, bool *last) const | 785 | QDateTime Recurrence::getNextDateTime(const QDateTime &preDateTime, bool *last) const |
773 | { | 786 | { |
774 | if (last) | 787 | if (last) |
775 | *last = false; | 788 | *last = false; |
776 | int freq; | 789 | int freq; |
777 | switch (recurs) | 790 | switch (recurs) |
778 | { | 791 | { |
779 | case rMinutely: | 792 | case rMinutely: |
780 | freq = rFreq * 60; | 793 | freq = rFreq * 60; |
781 | break; | 794 | break; |
782 | case rHourly: | 795 | case rHourly: |
783 | freq = rFreq * 3600; | 796 | freq = rFreq * 3600; |
784 | break; | 797 | break; |
785 | case rDaily: | 798 | case rDaily: |
786 | case rWeekly: | 799 | case rWeekly: |
787 | case rMonthlyPos: | 800 | case rMonthlyPos: |
788 | case rMonthlyDay: | 801 | case rMonthlyDay: |
789 | case rYearlyMonth: | 802 | case rYearlyMonth: |
790 | case rYearlyDay: | 803 | case rYearlyDay: |
791 | case rYearlyPos: { | 804 | case rYearlyPos: { |
792 | QDate preDate = preDateTime.date(); | 805 | QDate preDate = preDateTime.date(); |
793 | if (!mFloats && mRecurStart.time() > preDateTime.time()) | 806 | if (!mFloats && mRecurStart.time() > preDateTime.time()) |
794 | preDate = preDate.addDays(-1); | 807 | preDate = preDate.addDays(-1); |
795 | return QDateTime(getNextDateNoTime(preDate, last), mRecurStart.time()); | 808 | return QDateTime(getNextDateNoTime(preDate, last), mRecurStart.time()); |
796 | } | 809 | } |
797 | default: | 810 | default: |
798 | return QDateTime(); | 811 | return QDateTime(); |
799 | } | 812 | } |
800 | 813 | ||
801 | // It's a sub-daily recurrence | 814 | // It's a sub-daily recurrence |
802 | if (preDateTime < mRecurStart) | 815 | if (preDateTime < mRecurStart) |
803 | return mRecurStart; | 816 | return mRecurStart; |
804 | int count = mRecurStart.secsTo(preDateTime) / freq + 2; | 817 | int count = mRecurStart.secsTo(preDateTime) / freq + 2; |
805 | if (rDuration > 0) { | 818 | if (rDuration > 0) { |
806 | if (count > rDuration) | 819 | if (count > rDuration) |
807 | return QDateTime(); | 820 | return QDateTime(); |
808 | if (last && count == rDuration) | 821 | if (last && count == rDuration) |
809 | *last = true; | 822 | *last = true; |
810 | } | 823 | } |
811 | QDateTime endtime = mRecurStart.addSecs((count - 1)*freq); | 824 | QDateTime endtime = mRecurStart.addSecs((count - 1)*freq); |
812 | if (rDuration == 0) { | 825 | if (rDuration == 0) { |
813 | if (endtime > rEndDateTime) | 826 | if (endtime > rEndDateTime) |
814 | return QDateTime(); | 827 | return QDateTime(); |
815 | if (last && endtime == rEndDateTime) | 828 | if (last && endtime == rEndDateTime) |
816 | *last = true; | 829 | *last = true; |
817 | } | 830 | } |
818 | return endtime; | 831 | return endtime; |
819 | } | 832 | } |
820 | 833 | ||
821 | QDate Recurrence::getNextDate(const QDate &preDate, bool *last) const | 834 | QDate Recurrence::getNextDate(const QDate &preDate, bool *last) const |
822 | { | 835 | { |
823 | if (last) | 836 | if (last) |
824 | *last = false; | 837 | *last = false; |
825 | switch (recurs) | 838 | switch (recurs) |
826 | { | 839 | { |
827 | case rMinutely: | 840 | case rMinutely: |
828 | case rHourly: | 841 | case rHourly: |
829 | return getNextDateTime(QDateTime(preDate, QTime(23,59,59)), last).date(); | 842 | return getNextDateTime(QDateTime(preDate, QTime(23,59,59)), last).date(); |
830 | case rDaily: | 843 | case rDaily: |
831 | case rWeekly: | 844 | case rWeekly: |
832 | case rMonthlyPos: | 845 | case rMonthlyPos: |
833 | case rMonthlyDay: | 846 | case rMonthlyDay: |
834 | case rYearlyMonth: | 847 | case rYearlyMonth: |
835 | case rYearlyDay: | 848 | case rYearlyDay: |
836 | case rYearlyPos: | 849 | case rYearlyPos: |
837 | return getNextDateNoTime(preDate, last); | 850 | return getNextDateNoTime(preDate, last); |
838 | default: | 851 | default: |
839 | return QDate(); | 852 | return QDate(); |
840 | } | 853 | } |
841 | } | 854 | } |
842 | 855 | ||
843 | 856 | ||
844 | QDateTime Recurrence::getPreviousDateTime(const QDateTime &afterDateTime, bool *last) const | 857 | QDateTime Recurrence::getPreviousDateTime(const QDateTime &afterDateTime, bool *last) const |
845 | { | 858 | { |
846 | if (last) | 859 | if (last) |
847 | *last = false; | 860 | *last = false; |
848 | int freq; | 861 | int freq; |
849 | switch (recurs) | 862 | switch (recurs) |
850 | { | 863 | { |
851 | case rMinutely: | 864 | case rMinutely: |
852 | freq = rFreq * 60; | 865 | freq = rFreq * 60; |
853 | break; | 866 | break; |
854 | case rHourly: | 867 | case rHourly: |
855 | freq = rFreq * 3600; | 868 | freq = rFreq * 3600; |
856 | break; | 869 | break; |
857 | case rDaily: | 870 | case rDaily: |
858 | case rWeekly: | 871 | case rWeekly: |
859 | case rMonthlyPos: | 872 | case rMonthlyPos: |
860 | case rMonthlyDay: | 873 | case rMonthlyDay: |
861 | case rYearlyMonth: | 874 | case rYearlyMonth: |
862 | case rYearlyDay: | 875 | case rYearlyDay: |
863 | case rYearlyPos: { | 876 | case rYearlyPos: { |
864 | QDate afterDate = afterDateTime.date(); | 877 | QDate afterDate = afterDateTime.date(); |
865 | if (!mFloats && mRecurStart.time() < afterDateTime.time()) | 878 | if (!mFloats && mRecurStart.time() < afterDateTime.time()) |
866 | afterDate = afterDate.addDays(1); | 879 | afterDate = afterDate.addDays(1); |
867 | return QDateTime(getPreviousDateNoTime(afterDate, last), mRecurStart.time()); | 880 | return QDateTime(getPreviousDateNoTime(afterDate, last), mRecurStart.time()); |
868 | } | 881 | } |
869 | default: | 882 | default: |
870 | return QDateTime(); | 883 | return QDateTime(); |
871 | } | 884 | } |
872 | 885 | ||
873 | // It's a sub-daily recurrence | 886 | // It's a sub-daily recurrence |
874 | if (afterDateTime <= mRecurStart) | 887 | if (afterDateTime <= mRecurStart) |
875 | return QDateTime(); | 888 | return QDateTime(); |
876 | int count = (mRecurStart.secsTo(afterDateTime) - 1) / freq + 1; | 889 | int count = (mRecurStart.secsTo(afterDateTime) - 1) / freq + 1; |
877 | if (rDuration > 0) { | 890 | if (rDuration > 0) { |
878 | if (count > rDuration) | 891 | if (count > rDuration) |
879 | count = rDuration; | 892 | count = rDuration; |
880 | if (last && count == rDuration) | 893 | if (last && count == rDuration) |
881 | *last = true; | 894 | *last = true; |
882 | } | 895 | } |
883 | QDateTime endtime = mRecurStart.addSecs((count - 1)*freq); | 896 | QDateTime endtime = mRecurStart.addSecs((count - 1)*freq); |
884 | if (rDuration == 0) { | 897 | if (rDuration == 0) { |
885 | if (endtime > rEndDateTime) | 898 | if (endtime > rEndDateTime) |
886 | endtime = rEndDateTime; | 899 | endtime = rEndDateTime; |
887 | if (last && endtime == rEndDateTime) | 900 | if (last && endtime == rEndDateTime) |
888 | *last = true; | 901 | *last = true; |
889 | } | 902 | } |
890 | return endtime; | 903 | return endtime; |
891 | } | 904 | } |
892 | 905 | ||
893 | QDate Recurrence::getPreviousDate(const QDate &afterDate, bool *last) const | 906 | QDate Recurrence::getPreviousDate(const QDate &afterDate, bool *last) const |
894 | { | 907 | { |
895 | if (last) | 908 | if (last) |
896 | *last = false; | 909 | *last = false; |
897 | switch (recurs) | 910 | switch (recurs) |
898 | { | 911 | { |
899 | case rMinutely: | 912 | case rMinutely: |
900 | case rHourly: | 913 | case rHourly: |
901 | return getPreviousDateTime(QDateTime(afterDate, QTime(0,0,0)), last).date(); | 914 | return getPreviousDateTime(QDateTime(afterDate, QTime(0,0,0)), last).date(); |
902 | case rDaily: | 915 | case rDaily: |
903 | case rWeekly: | 916 | case rWeekly: |
904 | case rMonthlyPos: | 917 | case rMonthlyPos: |
905 | case rMonthlyDay: | 918 | case rMonthlyDay: |
906 | case rYearlyMonth: | 919 | case rYearlyMonth: |
907 | case rYearlyDay: | 920 | case rYearlyDay: |
908 | case rYearlyPos: | 921 | case rYearlyPos: |
909 | return getPreviousDateNoTime(afterDate, last); | 922 | return getPreviousDateNoTime(afterDate, last); |
910 | default: | 923 | default: |
911 | return QDate(); | 924 | return QDate(); |
912 | } | 925 | } |
913 | } | 926 | } |
914 | 927 | ||
915 | 928 | ||
916 | /***************************** PROTECTED FUNCTIONS ***************************/ | 929 | /***************************** PROTECTED FUNCTIONS ***************************/ |
917 | 930 | ||
918 | bool Recurrence::recursSecondly(const QDate &qd, int secondFreq) const | 931 | bool Recurrence::recursSecondly(const QDate &qd, int secondFreq) const |
919 | { | 932 | { |
920 | if ((qd >= mRecurStart.date()) && | 933 | if ((qd >= mRecurStart.date()) && |
diff --git a/libkcal/recurrence.h b/libkcal/recurrence.h index a0f6d84..b13d14f 100644 --- a/libkcal/recurrence.h +++ b/libkcal/recurrence.h | |||
@@ -99,303 +99,303 @@ class Recurrence | |||
99 | /** Set number of exception dates. */ | 99 | /** Set number of exception dates. */ |
100 | void setRecurExDatesCount(int count) { if (count >= 0) mRecurExDatesCount = count; } | 100 | void setRecurExDatesCount(int count) { if (count >= 0) mRecurExDatesCount = count; } |
101 | /** Set the calendar file version for backwards compatibility. | 101 | /** Set the calendar file version for backwards compatibility. |
102 | * @var version is the KOrganizer/libkcal version, e.g. 220 for KDE 2.2.0. | 102 | * @var version is the KOrganizer/libkcal version, e.g. 220 for KDE 2.2.0. |
103 | * Specify version = 0 to cancel compatibility mode. | 103 | * Specify version = 0 to cancel compatibility mode. |
104 | */ | 104 | */ |
105 | void setCompatVersion(int version = 0); | 105 | void setCompatVersion(int version = 0); |
106 | 106 | ||
107 | /** Returns the event's recurrence status. See the enumeration at the top | 107 | /** Returns the event's recurrence status. See the enumeration at the top |
108 | * of this file for possible values. */ | 108 | * of this file for possible values. */ |
109 | ushort doesRecur() const; | 109 | ushort doesRecur() const; |
110 | /** Returns true if the date specified is one on which the event will | 110 | /** Returns true if the date specified is one on which the event will |
111 | * recur. */ | 111 | * recur. */ |
112 | bool recursOnPure(const QDate &qd) const; | 112 | bool recursOnPure(const QDate &qd) const; |
113 | /** Returns true if the date/time specified is one at which the event will | 113 | /** Returns true if the date/time specified is one at which the event will |
114 | * recur. Times are rounded down to the nearest minute to determine the result. */ | 114 | * recur. Times are rounded down to the nearest minute to determine the result. */ |
115 | bool recursAtPure(const QDateTime &) const; | 115 | bool recursAtPure(const QDateTime &) const; |
116 | /** Turns off recurrence for the event. */ | 116 | /** Turns off recurrence for the event. */ |
117 | void unsetRecurs(); | 117 | void unsetRecurs(); |
118 | 118 | ||
119 | /** Returns the date of the next recurrence, after the specified date. | 119 | /** Returns the date of the next recurrence, after the specified date. |
120 | * @var preDate the date after which to find the recurrence. | 120 | * @var preDate the date after which to find the recurrence. |
121 | * @var last if non-null, *last is set to true if the next recurrence is the | 121 | * @var last if non-null, *last is set to true if the next recurrence is the |
122 | * last recurrence, else false. | 122 | * last recurrence, else false. |
123 | * Reply = date of next recurrence, or invalid date if none. | 123 | * Reply = date of next recurrence, or invalid date if none. |
124 | */ | 124 | */ |
125 | QDate getNextDate(const QDate& preDate, bool* last = 0) const; | 125 | QDate getNextDate(const QDate& preDate, bool* last = 0) const; |
126 | /** Returns the date and time of the next recurrence, after the specified date/time. | 126 | /** Returns the date and time of the next recurrence, after the specified date/time. |
127 | * If the recurrence has no time, the next date after the specified date is returned. | 127 | * If the recurrence has no time, the next date after the specified date is returned. |
128 | * @var preDate the date/time after which to find the recurrence. | 128 | * @var preDate the date/time after which to find the recurrence. |
129 | * @var last if non-null, *last is set to true if the next recurrence is the | 129 | * @var last if non-null, *last is set to true if the next recurrence is the |
130 | * last recurrence, else false. | 130 | * last recurrence, else false. |
131 | * Reply = date/time of next recurrence, or invalid date if none. | 131 | * Reply = date/time of next recurrence, or invalid date if none. |
132 | */ | 132 | */ |
133 | QDateTime getNextDateTime(const QDateTime& preDateTime, bool* last = 0) const; | 133 | QDateTime getNextDateTime(const QDateTime& preDateTime, bool* last = 0) const; |
134 | /** Returns the date of the last previous recurrence, before the specified date. | 134 | /** Returns the date of the last previous recurrence, before the specified date. |
135 | * @var afterDate the date before which to find the recurrence. | 135 | * @var afterDate the date before which to find the recurrence. |
136 | * @var last if non-null, *last is set to true if the previous recurrence is the | 136 | * @var last if non-null, *last is set to true if the previous recurrence is the |
137 | * last recurrence, else false. | 137 | * last recurrence, else false. |
138 | * Reply = date of previous recurrence, or invalid date if none. | 138 | * Reply = date of previous recurrence, or invalid date if none. |
139 | */ | 139 | */ |
140 | QDate getPreviousDate(const QDate& afterDate, bool* last = 0) const; | 140 | QDate getPreviousDate(const QDate& afterDate, bool* last = 0) const; |
141 | /** Returns the date and time of the last previous recurrence, before the specified date/time. | 141 | /** Returns the date and time of the last previous recurrence, before the specified date/time. |
142 | * If a time later than 00:00:00 is specified and the recurrence has no time, 00:00:00 on | 142 | * If a time later than 00:00:00 is specified and the recurrence has no time, 00:00:00 on |
143 | * the specified date is returned if that date recurs. | 143 | * the specified date is returned if that date recurs. |
144 | * @var afterDate the date/time before which to find the recurrence. | 144 | * @var afterDate the date/time before which to find the recurrence. |
145 | * @var last if non-null, *last is set to true if the previous recurrence is the | 145 | * @var last if non-null, *last is set to true if the previous recurrence is the |
146 | * last recurrence, else false. | 146 | * last recurrence, else false. |
147 | * Reply = date/time of previous recurrence, or invalid date if none. | 147 | * Reply = date/time of previous recurrence, or invalid date if none. |
148 | */ | 148 | */ |
149 | QDateTime getPreviousDateTime(const QDateTime& afterDateTime, bool* last = 0) const; | 149 | QDateTime getPreviousDateTime(const QDateTime& afterDateTime, bool* last = 0) const; |
150 | 150 | ||
151 | /** Returns frequency of recurrence, in terms of the recurrence time period type. */ | 151 | /** Returns frequency of recurrence, in terms of the recurrence time period type. */ |
152 | int frequency() const; | 152 | int frequency() const; |
153 | /** Returns the total number of recurrences, including the initial occurrence. */ | 153 | /** Returns the total number of recurrences, including the initial occurrence. */ |
154 | int duration() const; | 154 | int duration() const; |
155 | /** Sets the total number of times the event is to occur, including both the | 155 | /** Sets the total number of times the event is to occur, including both the |
156 | * first and last. */ | 156 | * first and last. */ |
157 | void setDuration(int duration); | 157 | void setDuration(int duration); |
158 | /** Returns the number of recurrences up to and including the date specified. */ | 158 | /** Returns the number of recurrences up to and including the date specified. */ |
159 | int durationTo(const QDate &) const; | 159 | int durationTo(const QDate &) const; |
160 | /** Returns the number of recurrences up to and including the date/time specified. */ | 160 | /** Returns the number of recurrences up to and including the date/time specified. */ |
161 | int durationTo(const QDateTime &) const; | 161 | int durationTo(const QDateTime &) const; |
162 | 162 | ||
163 | /** Returns the date of the last recurrence. | 163 | /** Returns the date of the last recurrence. |
164 | * An invalid date is returned if the recurrence has no end. | 164 | * An invalid date is returned if the recurrence has no end. |
165 | * Note: for some recurrence types, endDate() can involve significant calculation. | 165 | * Note: for some recurrence types, endDate() can involve significant calculation. |
166 | */ | 166 | */ |
167 | QDate endDate() const; | 167 | QDate endDate() const; |
168 | /** Returns the date and time of the last recurrence. | 168 | /** Returns the date and time of the last recurrence. |
169 | * An invalid date is returned if the recurrence has no end. | 169 | * An invalid date is returned if the recurrence has no end. |
170 | * Note: for some recurrence types, endDateTime() can involve significant calculation. | 170 | * Note: for some recurrence types, endDateTime() can involve significant calculation. |
171 | */ | 171 | */ |
172 | QDateTime endDateTime() const; | 172 | QDateTime endDateTime() const; |
173 | /** Returns a string representing the recurrence end date in the format | 173 | /** Returns a string representing the recurrence end date in the format |
174 | according to the user's locale settings. */ | 174 | according to the user's locale settings. */ |
175 | QString endDateStr(bool shortfmt=true) const; | 175 | QString endDateStr(bool shortfmt=true) const; |
176 | 176 | ||
177 | /** Sets an event to recur minutely. | 177 | /** Sets an event to recur minutely. |
178 | * @var _rFreq the frequency to recur, e.g. 2 is every other minute | 178 | * @var _rFreq the frequency to recur, e.g. 2 is every other minute |
179 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. | 179 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. |
180 | */ | 180 | */ |
181 | void setMinutely(int _rFreq, int duration); | 181 | void setMinutely(int _rFreq, int duration); |
182 | /** Sets an event to recur minutely. | 182 | /** Sets an event to recur minutely. |
183 | * @var _rFreq the frequency to recur, e.g. 2 is every other minute | 183 | * @var _rFreq the frequency to recur, e.g. 2 is every other minute |
184 | * @var endDateTime the ending date/time after which to stop recurring | 184 | * @var endDateTime the ending date/time after which to stop recurring |
185 | */ | 185 | */ |
186 | void setMinutely(int _rFreq, const QDateTime &endDateTime); | 186 | void setMinutely(int _rFreq, const QDateTime &endDateTime); |
187 | 187 | ||
188 | /** Sets an event to recur hourly. | 188 | /** Sets an event to recur hourly. |
189 | * @var _rFreq the frequency to recur, e.g. 2 is every other hour | 189 | * @var _rFreq the frequency to recur, e.g. 2 is every other hour |
190 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. | 190 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. |
191 | */ | 191 | */ |
192 | void setHourly(int _rFreq, int duration); | 192 | void setHourly(int _rFreq, int duration); |
193 | /** Sets an event to recur hourly. | 193 | /** Sets an event to recur hourly. |
194 | * @var _rFreq the frequency to recur, e.g. 2 is every other hour | 194 | * @var _rFreq the frequency to recur, e.g. 2 is every other hour |
195 | * @var endDateTime the ending date/time after which to stop recurring | 195 | * @var endDateTime the ending date/time after which to stop recurring |
196 | */ | 196 | */ |
197 | void setHourly(int _rFreq, const QDateTime &endDateTime); | 197 | void setHourly(int _rFreq, const QDateTime &endDateTime); |
198 | 198 | ||
199 | /** Sets an event to recur daily. | 199 | /** Sets an event to recur daily. |
200 | * @var _rFreq the frequency to recur, e.g. 2 is every other day | 200 | * @var _rFreq the frequency to recur, e.g. 2 is every other day |
201 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. | 201 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. |
202 | */ | 202 | */ |
203 | void setDaily(int _rFreq, int duration); | 203 | void setDaily(int _rFreq, int duration); |
204 | /** Sets an event to recur daily. | 204 | /** Sets an event to recur daily. |
205 | * @var _rFreq the frequency to recur, e.g. 2 is every other day | 205 | * @var _rFreq the frequency to recur, e.g. 2 is every other day |
206 | * @var endDate the ending date after which to stop recurring | 206 | * @var endDate the ending date after which to stop recurring |
207 | */ | 207 | */ |
208 | void setDaily(int _rFreq, const QDate &endDate); | 208 | void setDaily(int _rFreq, const QDate &endDate); |
209 | 209 | ||
210 | /** Sets an event to recur weekly. | 210 | /** Sets an event to recur weekly. |
211 | * @var _rFreq the frequency to recur, e.g. every other week etc. | 211 | * @var _rFreq the frequency to recur, e.g. every other week etc. |
212 | * @var _rDays a 7 bit array indicating which days on which to recur (bit 0 = Monday). | 212 | * @var _rDays a 7 bit array indicating which days on which to recur (bit 0 = Monday). |
213 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. | 213 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. |
214 | * @var weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday). | 214 | * @var weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday). |
215 | */ | 215 | */ |
216 | void setWeekly(int _rFreq, const QBitArray &_rDays, int duration, int weekStart = 1); | 216 | void setWeekly(int _rFreq, const QBitArray &_rDays, int duration, int weekStart = 1); |
217 | /** Sets an event to recur weekly. | 217 | /** Sets an event to recur weekly. |
218 | * @var _rFreq the frequency to recur, e.g. every other week etc. | 218 | * @var _rFreq the frequency to recur, e.g. every other week etc. |
219 | * @var _rDays a 7 bit array indicating which days on which to recur (bit 0 = Monday). | 219 | * @var _rDays a 7 bit array indicating which days on which to recur (bit 0 = Monday). |
220 | * @var endDate the date on which to stop recurring. | 220 | * @var endDate the date on which to stop recurring. |
221 | * @var weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday). | 221 | * @var weekStart the first day of the week (Monday=1 .. Sunday=7, default is Monday). |
222 | */ | 222 | */ |
223 | void setWeekly(int _rFreq, const QBitArray &_rDays, const QDate &endDate, int weekStart = 1); | 223 | void setWeekly(int _rFreq, const QBitArray &_rDays, const QDate &endDate, int weekStart = 1); |
224 | /** Returns the first day of the week. Monday=1 .. Sunday=7. */ | 224 | /** Returns the first day of the week. Monday=1 .. Sunday=7. */ |
225 | int weekStart() const { return rWeekStart; } | 225 | int weekStart() const { return rWeekStart; } |
226 | /** Returns week day mask (bit 0 = Monday). */ | 226 | /** Returns week day mask (bit 0 = Monday). */ |
227 | const QBitArray &days() const; | 227 | const QBitArray &days() const; |
228 | 228 | ||
229 | /** Sets an event to recur monthly. | 229 | /** Sets an event to recur monthly. |
230 | * @var type rMonthlyPos or rMonthlyDay | 230 | * @var type rMonthlyPos or rMonthlyDay |
231 | * @var _rFreq the frequency to recur, e.g. 3 for every third month. | 231 | * @var _rFreq the frequency to recur, e.g. 3 for every third month. |
232 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. | 232 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. |
233 | */ | 233 | */ |
234 | void setMonthly(short type, int _rFreq, int duration); | 234 | void setMonthly(short type, int _rFreq, int duration); |
235 | /** same as above, but with ending date not number of recurrences */ | 235 | /** same as above, but with ending date not number of recurrences */ |
236 | void setMonthly(short type, int _rFreq, const QDate &endDate); | 236 | void setMonthly(short type, int _rFreq, const QDate &endDate); |
237 | /** Adds a position to the recursMonthlyPos recurrence rule, if it is | 237 | /** Adds a position to the recursMonthlyPos recurrence rule, if it is |
238 | * set. | 238 | * set. |
239 | * @var _rPos the position in the month for the recurrence, with valid | 239 | * @var _rPos the position in the month for the recurrence, with valid |
240 | * values being 1-5 (5 weeks max in a month). | 240 | * values being 1-5 (5 weeks max in a month). |
241 | * @var _rDays the days for the position to recur on (bit 0 = Monday). | 241 | * @var _rDays the days for the position to recur on (bit 0 = Monday). |
242 | * Example: _rPos = 2, and bits 0 and 2 are set in _rDays: | 242 | * Example: _rPos = 2, and bits 0 and 2 are set in _rDays: |
243 | * the rule is to repeat every 2nd Monday and Wednesday in the month. | 243 | * the rule is to repeat every 2nd Monday and Wednesday in the month. |
244 | */ | 244 | */ |
245 | void addMonthlyPos(short _rPos, const QBitArray &_rDays); | 245 | void addMonthlyPos(short _rPos, const QBitArray &_rDays); |
246 | /** Adds a position the the recursMonthlyDay list. | 246 | /** Adds a position the the recursMonthlyDay list. |
247 | * @var _rDay the date in the month to recur. | 247 | * @var _rDay the date in the month to recur. |
248 | */ | 248 | */ |
249 | void addMonthlyDay(short _rDay); | 249 | void addMonthlyDay(short _rDay); |
250 | /** Returns list of day positions in months. */ | 250 | /** Returns list of day positions in months. */ |
251 | const QPtrList<rMonthPos> &monthPositions() const; | 251 | const QPtrList<rMonthPos> &monthPositions() const; |
252 | /** Returns list of day numbers of a month. */ | 252 | /** Returns list of day numbers of a month. */ |
253 | const QPtrList<int> &monthDays() const; | 253 | const QPtrList<int> &monthDays() const; |
254 | 254 | ||
255 | /** Sets an event to recur yearly. | 255 | /** Sets an event to recur yearly. |
256 | * @var type rYearlyMonth, rYearlyPos or rYearlyDay | 256 | * @var type rYearlyMonth, rYearlyPos or rYearlyDay |
257 | * @var freq the frequency to recur, e.g. 3 for every third year. | 257 | * @var freq the frequency to recur, e.g. 3 for every third year. |
258 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. | 258 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. |
259 | */ | 259 | */ |
260 | void setYearly(int type, int freq, int duration); | 260 | void setYearly(int type, int freq, int duration); |
261 | /** Sets an event to recur yearly ending at \a endDate. */ | 261 | /** Sets an event to recur yearly ending at \a endDate. */ |
262 | void setYearly(int type, int freq, const QDate &endDate); | 262 | void setYearly(int type, int freq, const QDate &endDate); |
263 | /** Sets an event to recur yearly on specified dates. | 263 | /** Sets an event to recur yearly on specified dates. |
264 | * The dates must be specified by calling addYearlyNum(). | 264 | * The dates must be specified by calling addYearlyNum(). |
265 | * @var type the way recurrences of February 29th are to be handled in non-leap years. | 265 | * @var type the way recurrences of February 29th are to be handled in non-leap years. |
266 | * @var freq the frequency to recur, e.g. 3 for every third year. | 266 | * @var freq the frequency to recur, e.g. 3 for every third year. |
267 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. | 267 | * @var duration the number of times the event is to occur, or -1 to recur indefinitely. |
268 | */ | 268 | */ |
269 | void setYearlyByDate(Feb29Type type, int freq, int duration); | 269 | void setYearlyByDate(Feb29Type type, int freq, int duration); |
270 | /** Sets an event to recur yearly ending at \a endDate. */ | 270 | /** Sets an event to recur yearly ending at \a endDate. */ |
271 | void setYearlyByDate(Feb29Type type, int freq, const QDate &endDate); | 271 | void setYearlyByDate(Feb29Type type, int freq, const QDate &endDate); |
272 | /** Adds position of day or month in year. | 272 | /** Adds position of day or month in year. |
273 | * N.B. for recursYearlyPos, addYearlyMonthPos() must also be called | 273 | * N.B. for recursYearlyPos, addYearlyMonthPos() must also be called |
274 | * to add positions within the month. */ | 274 | * to add positions within the month. */ |
275 | void addYearlyNum(short _rNum); | 275 | void addYearlyNum(short _rNum); |
276 | /** Adds a position to the recursYearlyPos recurrence rule, if it is set. | 276 | /** Adds a position to the recursYearlyPos recurrence rule, if it is set. |
277 | * N.B. addYearlyNum() must also be called to add recurrence months. | 277 | * N.B. addYearlyNum() must also be called to add recurrence months. |
278 | * Parameters are the same as for addMonthlyPos(). | 278 | * Parameters are the same as for addMonthlyPos(). |
279 | */ | 279 | */ |
280 | void addYearlyMonthPos(short _rPos, const QBitArray &_rDays); | 280 | void addYearlyMonthPos(short _rPos, const QBitArray &_rDays); |
281 | /** Returns positions of days or months in year. */ | 281 | /** Returns positions of days or months in year. */ |
282 | const QPtrList<int> &yearNums() const; | 282 | const QPtrList<int> &yearNums() const; |
283 | /** Returns list of day positions in months, for a recursYearlyPos recurrence rule. */ | 283 | /** Returns list of day positions in months, for a recursYearlyPos recurrence rule. */ |
284 | const QPtrList<rMonthPos> &yearMonthPositions() const; | 284 | const QPtrList<rMonthPos> &yearMonthPositions() const; |
285 | /** Returns how yearly recurrences of February 29th are handled. */ | 285 | /** Returns how yearly recurrences of February 29th are handled. */ |
286 | Feb29Type feb29YearlyType() const { return mFeb29YearlyType; } | 286 | Feb29Type feb29YearlyType() const { return mFeb29YearlyType; } |
287 | /** Sets the default method for handling yearly recurrences of February 29th. */ | 287 | /** Sets the default method for handling yearly recurrences of February 29th. */ |
288 | static void setFeb29YearlyTypeDefault(Feb29Type t) { mFeb29YearlyDefaultType = t; } | 288 | static void setFeb29YearlyTypeDefault(Feb29Type t) { mFeb29YearlyDefaultType = t; } |
289 | /** Returns the default method for handling yearly recurrences of February 29th. */ | 289 | /** Returns the default method for handling yearly recurrences of February 29th. */ |
290 | static Feb29Type setFeb29YearlyTypeDefault() { return mFeb29YearlyDefaultType; } | 290 | static Feb29Type setFeb29YearlyTypeDefault() { return mFeb29YearlyDefaultType; } |
291 | 291 | void addYearlyMonth(short _rPos ); // added LR | |
292 | /** | 292 | /** |
293 | Debug output. | 293 | Debug output. |
294 | */ | 294 | */ |
295 | void dump() const; | 295 | void dump() const; |
296 | QString recurrenceText() const; | 296 | QString recurrenceText() const; |
297 | bool getYearlyMonthMonths(int day, QValueList<int>&, | ||
298 | QValueList<int> &leaplist) const; | ||
297 | 299 | ||
298 | protected: | 300 | protected: |
299 | enum PeriodFunc { END_DATE_AND_COUNT, COUNT_TO_DATE, NEXT_AFTER_DATE }; | 301 | enum PeriodFunc { END_DATE_AND_COUNT, COUNT_TO_DATE, NEXT_AFTER_DATE }; |
300 | struct MonthlyData; friend struct MonthlyData; | 302 | struct MonthlyData; friend struct MonthlyData; |
301 | struct YearlyMonthData; friend struct YearlyMonthData; | 303 | struct YearlyMonthData; friend struct YearlyMonthData; |
302 | struct YearlyPosData; friend struct YearlyPosData; | 304 | struct YearlyPosData; friend struct YearlyPosData; |
303 | struct YearlyDayData; friend struct YearlyDayData; | 305 | struct YearlyDayData; friend struct YearlyDayData; |
304 | 306 | ||
305 | bool recursSecondly(const QDate &, int secondFreq) const; | 307 | bool recursSecondly(const QDate &, int secondFreq) const; |
306 | bool recursMinutelyAt(const QDateTime &dt, int minuteFreq) const; | 308 | bool recursMinutelyAt(const QDateTime &dt, int minuteFreq) const; |
307 | bool recursDaily(const QDate &) const; | 309 | bool recursDaily(const QDate &) const; |
308 | bool recursWeekly(const QDate &) const; | 310 | bool recursWeekly(const QDate &) const; |
309 | bool recursMonthly(const QDate &) const; | 311 | bool recursMonthly(const QDate &) const; |
310 | bool recursYearlyByMonth(const QDate &) const; | 312 | bool recursYearlyByMonth(const QDate &) const; |
311 | bool recursYearlyByPos(const QDate &) const; | 313 | bool recursYearlyByPos(const QDate &) const; |
312 | bool recursYearlyByDay(const QDate &) const; | 314 | bool recursYearlyByDay(const QDate &) const; |
313 | 315 | ||
314 | QDate getNextDateNoTime(const QDate& preDate, bool* last) const; | 316 | QDate getNextDateNoTime(const QDate& preDate, bool* last) const; |
315 | QDate getPreviousDateNoTime(const QDate& afterDate, bool* last) const; | 317 | QDate getPreviousDateNoTime(const QDate& afterDate, bool* last) const; |
316 | 318 | ||
317 | void addMonthlyPos_(short _rPos, const QBitArray &_rDays); | 319 | void addMonthlyPos_(short _rPos, const QBitArray &_rDays); |
318 | void setDailySub(short type, int freq, int duration); | 320 | void setDailySub(short type, int freq, int duration); |
319 | void setYearly_(short type, Feb29Type, int freq, int duration); | 321 | void setYearly_(short type, Feb29Type, int freq, int duration); |
320 | int recurCalc(PeriodFunc, QDate &enddate) const; | 322 | int recurCalc(PeriodFunc, QDate &enddate) const; |
321 | int recurCalc(PeriodFunc, QDateTime &endtime) const; | 323 | int recurCalc(PeriodFunc, QDateTime &endtime) const; |
322 | int secondlyCalc(PeriodFunc, QDateTime& endtime, int freq) const; | 324 | int secondlyCalc(PeriodFunc, QDateTime& endtime, int freq) const; |
323 | int dailyCalc(PeriodFunc, QDate &enddate) const; | 325 | int dailyCalc(PeriodFunc, QDate &enddate) const; |
324 | int weeklyCalc(PeriodFunc, QDate &enddate) const; | 326 | int weeklyCalc(PeriodFunc, QDate &enddate) const; |
325 | int weeklyCalcEndDate(QDate& enddate, int daysPerWeek) const; | 327 | int weeklyCalcEndDate(QDate& enddate, int daysPerWeek) const; |
326 | int weeklyCalcToDate(const QDate& enddate, int daysPerWeek) const; | 328 | int weeklyCalcToDate(const QDate& enddate, int daysPerWeek) const; |
327 | int weeklyCalcNextAfter(QDate& enddate, int daysPerWeek) const; | 329 | int weeklyCalcNextAfter(QDate& enddate, int daysPerWeek) const; |
328 | int monthlyCalc(PeriodFunc, QDate &enddate) const; | 330 | int monthlyCalc(PeriodFunc, QDate &enddate) const; |
329 | int monthlyCalcEndDate(QDate& enddate, MonthlyData&) const; | 331 | int monthlyCalcEndDate(QDate& enddate, MonthlyData&) const; |
330 | int monthlyCalcToDate(const QDate& enddate, MonthlyData&) const; | 332 | int monthlyCalcToDate(const QDate& enddate, MonthlyData&) const; |
331 | int monthlyCalcNextAfter(QDate& enddate, MonthlyData&) const; | 333 | int monthlyCalcNextAfter(QDate& enddate, MonthlyData&) const; |
332 | int yearlyMonthCalc(PeriodFunc, QDate &enddate) const; | 334 | int yearlyMonthCalc(PeriodFunc, QDate &enddate) const; |
333 | int yearlyMonthCalcEndDate(QDate& enddate, YearlyMonthData&) const; | 335 | int yearlyMonthCalcEndDate(QDate& enddate, YearlyMonthData&) const; |
334 | int yearlyMonthCalcToDate(const QDate& enddate, YearlyMonthData&) const; | 336 | int yearlyMonthCalcToDate(const QDate& enddate, YearlyMonthData&) const; |
335 | int yearlyMonthCalcNextAfter(QDate& enddate, YearlyMonthData&) const; | 337 | int yearlyMonthCalcNextAfter(QDate& enddate, YearlyMonthData&) const; |
336 | int yearlyPosCalc(PeriodFunc, QDate &enddate) const; | 338 | int yearlyPosCalc(PeriodFunc, QDate &enddate) const; |
337 | int yearlyPosCalcEndDate(QDate& enddate, YearlyPosData&) const; | 339 | int yearlyPosCalcEndDate(QDate& enddate, YearlyPosData&) const; |
338 | int yearlyPosCalcToDate(const QDate& enddate, YearlyPosData&) const; | 340 | int yearlyPosCalcToDate(const QDate& enddate, YearlyPosData&) const; |
339 | int yearlyPosCalcNextAfter(QDate& enddate, YearlyPosData&) const; | 341 | int yearlyPosCalcNextAfter(QDate& enddate, YearlyPosData&) const; |
340 | int yearlyDayCalc(PeriodFunc, QDate &enddate) const; | 342 | int yearlyDayCalc(PeriodFunc, QDate &enddate) const; |
341 | int yearlyDayCalcEndDate(QDate& enddate, YearlyDayData&) const; | 343 | int yearlyDayCalcEndDate(QDate& enddate, YearlyDayData&) const; |
342 | int yearlyDayCalcToDate(const QDate& enddate, YearlyDayData&) const; | 344 | int yearlyDayCalcToDate(const QDate& enddate, YearlyDayData&) const; |
343 | int yearlyDayCalcNextAfter(QDate& enddate, YearlyDayData&) const; | 345 | int yearlyDayCalcNextAfter(QDate& enddate, YearlyDayData&) const; |
344 | 346 | ||
345 | int countMonthlyPosDays() const; | 347 | int countMonthlyPosDays() const; |
346 | void getMonthlyPosDays(QValueList<int>&, int daysInMonth, | 348 | void getMonthlyPosDays(QValueList<int>&, int daysInMonth, |
347 | int startDayOfWeek) const; | 349 | int startDayOfWeek) const; |
348 | bool getMonthlyDayDays(QValueList<int>&, int daysInMonth) const; | 350 | bool getMonthlyDayDays(QValueList<int>&, int daysInMonth) const; |
349 | bool getYearlyMonthMonths(int day, QValueList<int>&, | ||
350 | QValueList<int> &leaplist) const; | ||
351 | 351 | ||
352 | int getFirstDayInWeek(int startDay, bool useWeekStart = true) const; | 352 | int getFirstDayInWeek(int startDay, bool useWeekStart = true) const; |
353 | int getLastDayInWeek(int endDay, bool useWeekStart = true) const; | 353 | int getLastDayInWeek(int endDay, bool useWeekStart = true) const; |
354 | QDate getFirstDateInMonth(const QDate& earliestDate) const; | 354 | QDate getFirstDateInMonth(const QDate& earliestDate) const; |
355 | QDate getLastDateInMonth(const QDate& latestDate) const; | 355 | QDate getLastDateInMonth(const QDate& latestDate) const; |
356 | QDate getFirstDateInYear(const QDate& earliestDate) const; | 356 | QDate getFirstDateInYear(const QDate& earliestDate) const; |
357 | QDate getLastDateInYear(const QDate& latestDate) const; | 357 | QDate getLastDateInYear(const QDate& latestDate) const; |
358 | 358 | ||
359 | private: | 359 | private: |
360 | // Prohibit copying | 360 | // Prohibit copying |
361 | Recurrence(const Recurrence&); | 361 | Recurrence(const Recurrence&); |
362 | Recurrence &operator=(const Recurrence&); | 362 | Recurrence &operator=(const Recurrence&); |
363 | 363 | ||
364 | short recurs; // should be one of the enums. | 364 | short recurs; // should be one of the enums. |
365 | 365 | ||
366 | int rWeekStart; // day which starts the week, Monday=1 .. Sunday=7 | 366 | int rWeekStart; // day which starts the week, Monday=1 .. Sunday=7 |
367 | QBitArray rDays; // array of days during week it recurs | 367 | QBitArray rDays; // array of days during week it recurs |
368 | 368 | ||
369 | QPtrList<rMonthPos> rMonthPositions; // list of positions during a month | 369 | QPtrList<rMonthPos> rMonthPositions; // list of positions during a month |
370 | // on which an event recurs | 370 | // on which an event recurs |
371 | 371 | ||
372 | QPtrList<int> rMonthDays; // list of days during a month on | 372 | QPtrList<int> rMonthDays; // list of days during a month on |
373 | // which the event recurs | 373 | // which the event recurs |
374 | 374 | ||
375 | QPtrList<int> rYearNums; // either months/days to recur on for rYearly, | 375 | QPtrList<int> rYearNums; // either months/days to recur on for rYearly, |
376 | // sorted in numerical order | 376 | // sorted in numerical order |
377 | 377 | ||
378 | int rFreq; // frequency of period | 378 | int rFreq; // frequency of period |
379 | 379 | ||
380 | // one of the following must be specified | 380 | // one of the following must be specified |
381 | int rDuration; // num times to recur (inc. first occurrence), -1 = infinite | 381 | int rDuration; // num times to recur (inc. first occurrence), -1 = infinite |
382 | QDateTime rEndDateTime; // date/time at which to end recurrence | 382 | QDateTime rEndDateTime; // date/time at which to end recurrence |
383 | 383 | ||
384 | QDateTime mRecurStart; // date/time of first recurrence | 384 | QDateTime mRecurStart; // date/time of first recurrence |
385 | bool mFloats; // the recurrence has no time, just a date | 385 | bool mFloats; // the recurrence has no time, just a date |
386 | bool mRecurReadOnly; | 386 | bool mRecurReadOnly; |
387 | int mRecurExDatesCount; // number of recurrences (in addition to rDuration) which are excluded | 387 | int mRecurExDatesCount; // number of recurrences (in addition to rDuration) which are excluded |
388 | Feb29Type mFeb29YearlyType; // how to handle yearly recurrences of February 29th | 388 | Feb29Type mFeb29YearlyType; // how to handle yearly recurrences of February 29th |
389 | static Feb29Type mFeb29YearlyDefaultType; // default value for mFeb29YearlyType | 389 | static Feb29Type mFeb29YearlyDefaultType; // default value for mFeb29YearlyType |
390 | 390 | ||
391 | // Backwards compatibility for KDE < 3.1. | 391 | // Backwards compatibility for KDE < 3.1. |
392 | int mCompatVersion; // calendar file version for backwards compatibility | 392 | int mCompatVersion; // calendar file version for backwards compatibility |
393 | short mCompatRecurs; // original 'recurs' in old calendar format, or rNone | 393 | short mCompatRecurs; // original 'recurs' in old calendar format, or rNone |
394 | int mCompatDuration; // original 'rDuration' in old calendar format, or 0 | 394 | int mCompatDuration; // original 'rDuration' in old calendar format, or 0 |
395 | 395 | ||
396 | Incidence *mParent; | 396 | Incidence *mParent; |
397 | }; | 397 | }; |
398 | 398 | ||
399 | } | 399 | } |
400 | 400 | ||
401 | #endif | 401 | #endif |