2 Copyright (c) 2010 Bertjan Broeksema <broeksema@kde.org>
3 Copyright (C) 2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
10 This library is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #ifndef INCIDENCEEDITOR_INCIDENCERECURRENCE_H
22 #define INCIDENCEEDITOR_INCIDENCERECURRENCE_H
24 #include "incidenceeditor-ng.h"
26 #include <KLocalizedString>
29 class EventOrTodoDesktop
;
30 class EventOrTodoMore
;
33 namespace IncidenceEditorNG
{
35 class IncidenceDateTime
;
37 /// Keep this in sync with the values in mUi->mRecurrenceTypeCombo
39 RecurrenceTypeNone
= 0,
42 RecurrenceTypeMonthly
,
44 RecurrenceTypeUnknown
// keep this one at the end always
47 class INCIDENCEEDITORS_NG_EXPORT IncidenceRecurrence
: public IncidenceEditor
51 #ifdef KDEPIM_MOBILE_UI
52 IncidenceRecurrence( IncidenceDateTime
*dateTime
, Ui::EventOrTodoMore
*ui
);
54 IncidenceRecurrence( IncidenceDateTime
*dateTime
, Ui::EventOrTodoDesktop
*ui
);
57 virtual void load( const KCalCore::Incidence::Ptr
&incidence
);
58 virtual void save( const KCalCore::Incidence::Ptr
&incidence
);
59 virtual bool isDirty() const;
61 RecurrenceType
currentRecurrenceType() const;
64 void recurrenceChanged( IncidenceEditorNG::RecurrenceType type
);
69 void handleDateTimeToggle();
70 void handleEndAfterOccurrencesChange( int currentValue
);
71 void handleExceptionDateChange( const QDate
¤tDate
);
72 void handleFrequencyChange();
73 void handleRecurrenceTypeChange( int currentIndex
);
74 void removeExceptions();
75 void updateRemoveExceptionButton();
76 void updateWeekDays( const QDate
&newStartDate
);
79 KLocalizedString
subsOrdinal( const KLocalizedString
&text
, int number
) const;
81 * Return the day in the month/year on which the event recurs, starting at the
82 * beginning/end. Both return a positive number.
84 short dayOfMonthFromStart() const;
85 short dayOfMonthFromEnd() const;
86 short dayOfYearFromStart() const; // We don't need from end for year
89 /** Returns the week number (1-5) of the month in which the start date occurs. */
90 short monthWeekFromStart() const;
91 short monthWeekFromEnd() const;
93 /** DO NOT USE THIS METHOD DIRECTLY
94 use subsOrdinal() instead for i18n * */
95 QString
numberToString( int number
) const;
96 void selectMonthlyItem( KCalCore::Recurrence
*recurrence
, ushort recurenceType
);
97 void selectYearlyItem( KCalCore::Recurrence
*recurrence
, ushort recurenceType
);
99 void setDuration( int duration
);
100 void setExceptionDates( const KCalCore::DateList
&dates
);
101 void setFrequency( int freq
);
102 void toggleRecurrenceWidgets( bool enable
);
103 /** Returns an array with the weekday on which the event occurs set to 1 */
104 QBitArray
weekday() const;
107 * Return how many times the weekday represented by @param date occurs in
108 * the month of @param date.
110 int weekdayCountForMonth( const QDate
&date
) const;
113 #ifdef KDEPIM_MOBILE_UI
114 Ui::EventOrTodoMore
*mUi
;
116 Ui::EventOrTodoDesktop
*mUi
;
119 IncidenceDateTime
*mDateTime
;
120 KCalCore::DateList mExceptionDates
;
122 // So we can easily detect if the user changed the type,
123 // without going through complicated recurrence logic:
124 int mMonthlyInitialType
;
125 int mYearlyInitialType
;