-rw-r--r-- | korganizer/kdatenavigator.cpp | 7 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index 7d0c516..b420351 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -1,364 +1,367 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 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 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | 35 | ||
36 | #include "koglobals.h" | 36 | #include "koglobals.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #ifndef KORG_NOPLUGINS | 38 | #ifndef KORG_NOPLUGINS |
39 | #include "kocore.h" | 39 | #include "kocore.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #include "navigatorbar.h" | 44 | #include "navigatorbar.h" |
45 | 45 | ||
46 | #include "kdatenavigator.h" | 46 | #include "kdatenavigator.h" |
47 | 47 | ||
48 | KDateNavigator::KDateNavigator( QWidget *parent, Calendar *calendar, | 48 | KDateNavigator::KDateNavigator( QWidget *parent, Calendar *calendar, |
49 | bool show_week_nums, const char *name, | 49 | bool show_week_nums, const char *name, |
50 | QDate startDate ) | 50 | QDate startDate ) |
51 | : QFrame(parent, name), | 51 | : QFrame(parent, name), |
52 | updateTimer(0L) | 52 | updateTimer(0L) |
53 | { | 53 | { |
54 | mCalendar = calendar; | 54 | mCalendar = calendar; |
55 | 55 | ||
56 | setFrameStyle(QFrame::NoFrame); | 56 | setFrameStyle(QFrame::NoFrame); |
57 | 57 | ||
58 | QGridLayout *topLayout = new QGridLayout(this,8,8); | 58 | QGridLayout *topLayout = new QGridLayout(this,8,8); |
59 | 59 | ||
60 | if (! startDate.isValid()) { | 60 | if (! startDate.isValid()) { |
61 | kdDebug() << "KDateNavigator::KDateNavigator(): an invalid date was passed as a parameter!" << endl; | 61 | kdDebug() << "KDateNavigator::KDateNavigator(): an invalid date was passed as a parameter!" << endl; |
62 | startDate = QDate::currentDate(); | 62 | startDate = QDate::currentDate(); |
63 | } | 63 | } |
64 | 64 | ||
65 | mSelectedDates.append(startDate); | 65 | mSelectedDates.append(startDate); |
66 | m_MthYr = startDate; | 66 | m_MthYr = startDate; |
67 | m_bShowWeekNums = show_week_nums; | 67 | m_bShowWeekNums = show_week_nums; |
68 | 68 | ||
69 | setFont( KOPrefs::instance()->mDateNavigatorFont ); | 69 | setFont( KOPrefs::instance()->mDateNavigatorFont ); |
70 | mNavigatorBar = new NavigatorBar( startDate, this ); | 70 | mNavigatorBar = new NavigatorBar( startDate, this ); |
71 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); | 71 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); |
72 | //mNavigatorBar->resize( 1,1); | 72 | //mNavigatorBar->resize( 1,1); |
73 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 73 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
74 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 74 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
75 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 75 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
76 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 76 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
77 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); | 77 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); |
78 | 78 | ||
79 | // get the day of the week on the first day | 79 | // get the day of the week on the first day |
80 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 80 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
81 | m_fstDayOfWk = dayone.dayOfWeek(); | 81 | m_fstDayOfWk = dayone.dayOfWeek(); |
82 | 82 | ||
83 | int i; | 83 | int i; |
84 | 84 | ||
85 | // Set up the heading fields. | 85 | // Set up the heading fields. |
86 | for( i = 0; i < 7; i++ ) { | 86 | for( i = 0; i < 7; i++ ) { |
87 | headings[i] = new QLabel("",this); | 87 | headings[i] = new QLabel("",this); |
88 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); | 88 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); |
89 | headings[i]->setAlignment(AlignCenter); | 89 | headings[i]->setAlignment(AlignCenter); |
90 | 90 | ||
91 | topLayout->addWidget(headings[i],1,i+1); | 91 | topLayout->addWidget(headings[i],1,i+1); |
92 | } | 92 | } |
93 | 93 | ||
94 | // Create the weeknumber labels | 94 | // Create the weeknumber labels |
95 | for( i = 0; i < 6; i++ ) { | 95 | for( i = 0; i < 6; i++ ) { |
96 | weeknos[i] = new QLabel(this); | 96 | weeknos[i] = new QLabel(this); |
97 | weeknos[i]->setAlignment(AlignCenter); | 97 | weeknos[i]->setAlignment(AlignCenter); |
98 | //weeknos[i]->setFont(QFont("Arial", 10)); | 98 | //weeknos[i]->setFont(QFont("Arial", 10)); |
99 | if(!show_week_nums) { | 99 | if(!show_week_nums) { |
100 | weeknos[i]->hide(); | 100 | weeknos[i]->hide(); |
101 | } | 101 | } |
102 | weeknos[i]->installEventFilter(this); | 102 | weeknos[i]->installEventFilter(this); |
103 | 103 | ||
104 | topLayout->addWidget(weeknos[i],i+2,0); | 104 | topLayout->addWidget(weeknos[i],i+2,0); |
105 | } | 105 | } |
106 | 106 | ||
107 | daymatrix = new KODayMatrix( this, mCalendar, dayone, | 107 | daymatrix = new KODayMatrix( this, mCalendar, dayone, |
108 | "KDateNavigator::DayMatrix"); | 108 | "KDateNavigator::DayMatrix"); |
109 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 109 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
110 | daymatrix->setLineWidth(1); | 110 | daymatrix->setLineWidth(1); |
111 | 111 | ||
112 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), | 112 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), |
113 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 113 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
114 | 114 | ||
115 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), | 115 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), |
116 | SIGNAL( eventDropped( Event * ) ) ); | 116 | SIGNAL( eventDropped( Event * ) ) ); |
117 | 117 | ||
118 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); | 118 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); |
119 | 119 | ||
120 | // read settings from configuration file. | 120 | // read settings from configuration file. |
121 | updateConfig(); | 121 | updateConfig(); |
122 | enableRollover(FollowMonth); | 122 | enableRollover(FollowMonth); |
123 | setFixedSize ( sizeHint() ); | 123 | setFixedSize ( sizeHint() ); |
124 | } | 124 | } |
125 | 125 | ||
126 | void KDateNavigator::enableRollover(RolloverType r) | 126 | void KDateNavigator::enableRollover(RolloverType r) |
127 | { | 127 | { |
128 | switch(r) | 128 | switch(r) |
129 | { | 129 | { |
130 | case None : | 130 | case None : |
131 | if (updateTimer) | 131 | if (updateTimer) |
132 | { | 132 | { |
133 | updateTimer->stop(); | 133 | updateTimer->stop(); |
134 | delete updateTimer; | 134 | delete updateTimer; |
135 | updateTimer=0L; | 135 | updateTimer=0L; |
136 | } | 136 | } |
137 | break; | 137 | break; |
138 | case FollowDay : | 138 | case FollowDay : |
139 | case FollowMonth : | 139 | case FollowMonth : |
140 | if (!updateTimer) | 140 | if (!updateTimer) |
141 | { | 141 | { |
142 | updateTimer = new QTimer(this); | 142 | updateTimer = new QTimer(this); |
143 | QObject::connect(updateTimer,SIGNAL(timeout()), | 143 | QObject::connect(updateTimer,SIGNAL(timeout()), |
144 | this,SLOT(possiblyPastMidnight())); | 144 | this,SLOT(possiblyPastMidnight())); |
145 | } | 145 | } |
146 | updateTimer->start(0,true); | 146 | updateTimer->start(0,true); |
147 | lastDayChecked = QDate::currentDate(); | 147 | lastDayChecked = QDate::currentDate(); |
148 | } | 148 | } |
149 | updateRollover=r; | 149 | updateRollover=r; |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | KDateNavigator::~KDateNavigator() | 153 | KDateNavigator::~KDateNavigator() |
154 | { | 154 | { |
155 | } | 155 | } |
156 | 156 | ||
157 | 157 | ||
158 | void KDateNavigator::passedMidnight() | 158 | void KDateNavigator::passedMidnight() |
159 | { | 159 | { |
160 | QDate today = QDate::currentDate(); | 160 | QDate today = QDate::currentDate(); |
161 | bool emitMonth = false; | 161 | bool emitMonth = false; |
162 | 162 | ||
163 | if (today.month() != lastDayChecked.month()) | 163 | if (today.month() != lastDayChecked.month()) |
164 | { | 164 | { |
165 | if (updateRollover==FollowMonth && | 165 | if (updateRollover==FollowMonth && |
166 | daymatrix->isEndOfMonth()) { | 166 | daymatrix->isEndOfMonth()) { |
167 | goNextMonth(); | 167 | goNextMonth(); |
168 | emitMonth=true; | 168 | emitMonth=true; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | daymatrix->recalculateToday(); | 171 | daymatrix->recalculateToday(); |
172 | daymatrix->repaint(); | 172 | daymatrix->repaint(); |
173 | emit dayPassed(today); | 173 | emit dayPassed(today); |
174 | if (emitMonth) { emit monthPassed(today); } | 174 | if (emitMonth) { emit monthPassed(today); } |
175 | } | 175 | } |
176 | 176 | ||
177 | /* slot */ void KDateNavigator::possiblyPastMidnight() | 177 | /* slot */ void KDateNavigator::possiblyPastMidnight() |
178 | { | 178 | { |
179 | if (lastDayChecked!=QDate::currentDate()) | 179 | if (lastDayChecked!=QDate::currentDate()) |
180 | { | 180 | { |
181 | passedMidnight(); | 181 | passedMidnight(); |
182 | lastDayChecked=QDate::currentDate(); | 182 | lastDayChecked=QDate::currentDate(); |
183 | } | 183 | } |
184 | // Set the timer to go off 1 second after midnight | 184 | // Set the timer to go off 1 second after midnight |
185 | // or after 8 minutes, whichever comes first. | 185 | // or after 8 minutes, whichever comes first. |
186 | if (updateTimer) | 186 | if (updateTimer) |
187 | { | 187 | { |
188 | QTime now = QTime::currentTime(); | 188 | QTime now = QTime::currentTime(); |
189 | QTime midnight = QTime(23,59,59); | 189 | QTime midnight = QTime(23,59,59); |
190 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); | 190 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); |
191 | 191 | ||
192 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) | 192 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) |
193 | //.arg(now.toString()).arg(midnight.toString())); | 193 | //.arg(now.toString()).arg(midnight.toString())); |
194 | 194 | ||
195 | updateTimer->stop(); | 195 | updateTimer->stop(); |
196 | updateTimer->start(msecsWait,true); | 196 | updateTimer->start(msecsWait,true); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | void KDateNavigator::updateDates() | 200 | void KDateNavigator::updateDates() |
201 | { | 201 | { |
202 | // Find the first day of the week of the current month. | 202 | // Find the first day of the week of the current month. |
203 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); | 203 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); |
204 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); | 204 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); |
205 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); | 205 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); |
206 | //int di = d1 - d2 + 1; | 206 | //int di = d1 - d2 + 1; |
207 | dayone = dayone.addDays( -d2 + 1 ); | 207 | dayone = dayone.addDays( -d2 + 1 ); |
208 | 208 | ||
209 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); | 209 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); |
210 | 210 | ||
211 | // If month begins on Monday and Monday is first day of week, | 211 | // If month begins on Monday and Monday is first day of week, |
212 | // month should begin on second line. Sunday doesn't have this problem. | 212 | // month should begin on second line. Sunday doesn't have this problem. |
213 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && | 213 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && |
214 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; | 214 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; |
215 | 215 | ||
216 | // update the matrix dates | 216 | // update the matrix dates |
217 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; | 217 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |
218 | 218 | ||
219 | 219 | ||
220 | daymatrix->updateView(dayone.addDays(index)); | 220 | daymatrix->updateView(dayone.addDays(index)); |
221 | //each updateDates is followed by an updateView -> repaint is issued there ! | 221 | //each updateDates is followed by an updateView -> repaint is issued there ! |
222 | // daymatrix->repaint(); | 222 | // daymatrix->repaint(); |
223 | } | 223 | } |
224 | 224 | ||
225 | void KDateNavigator::updateDayMatrix() | 225 | void KDateNavigator::updateDayMatrix() |
226 | { | 226 | { |
227 | daymatrix->updateView(); | 227 | daymatrix->updateView(); |
228 | daymatrix->repaint(); | 228 | daymatrix->repaint(); |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | void KDateNavigator::updateView() | 232 | void KDateNavigator::updateView() |
233 | { | 233 | { |
234 | 234 | ||
235 | setUpdatesEnabled( false ); | 235 | setUpdatesEnabled( false ); |
236 | 236 | ||
237 | int i; | 237 | int i; |
238 | 238 | ||
239 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; | 239 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; |
240 | daymatrix->updateView(); | 240 | daymatrix->updateView(); |
241 | 241 | ||
242 | // set the week numbers. | 242 | // set the week numbers. |
243 | for(i = 0; i < 6; i++) { | 243 | for(i = 0; i < 6; i++) { |
244 | QString weeknum; | 244 | QString weeknum; |
245 | // remember, according to ISO 8601, the first week of the year is the | 245 | // remember, according to ISO 8601, the first week of the year is the |
246 | // first week that contains a thursday. Thus we must subtract off 4, | 246 | // first week that contains a thursday. Thus we must subtract off 4, |
247 | // not just 1. | 247 | // not just 1. |
248 | 248 | ||
249 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); | 249 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); |
250 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); | 250 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); |
251 | 251 | ||
252 | int add = 0; | ||
253 | if ( ! KGlobal::locale()->weekStartsMonday() ) | ||
254 | ++add; | ||
252 | if (dayOfYear % 7 != 0) | 255 | if (dayOfYear % 7 != 0) |
253 | weeknum.setNum(dayOfYear / 7 + 1); | 256 | weeknum.setNum(dayOfYear / 7 + 1+add); |
254 | else | 257 | else |
255 | weeknum.setNum(dayOfYear / 7); | 258 | weeknum.setNum(dayOfYear / 7 +add); |
256 | weeknos[i]->setText(weeknum); | 259 | weeknos[i]->setText(weeknum); |
257 | } | 260 | } |
258 | 261 | ||
259 | setUpdatesEnabled( true ); | 262 | setUpdatesEnabled( true ); |
260 | // kdDebug() << "updateView() -> repaint()" << endl; | 263 | // kdDebug() << "updateView() -> repaint()" << endl; |
261 | repaint(); | 264 | repaint(); |
262 | daymatrix->repaint(); | 265 | daymatrix->repaint(); |
263 | } | 266 | } |
264 | 267 | ||
265 | void KDateNavigator::updateConfig() | 268 | void KDateNavigator::updateConfig() |
266 | { | 269 | { |
267 | int day; | 270 | int day; |
268 | for(int i=0; i<7; i++) { | 271 | for(int i=0; i<7; i++) { |
269 | // take the first letter of the day name to be the abbreviation | 272 | // take the first letter of the day name to be the abbreviation |
270 | if (KGlobal::locale()->weekStartsMonday()) { | 273 | if (KGlobal::locale()->weekStartsMonday()) { |
271 | day = i+1; | 274 | day = i+1; |
272 | } else { | 275 | } else { |
273 | if (i==0) day = 7; | 276 | if (i==0) day = 7; |
274 | else day = i; | 277 | else day = i; |
275 | } | 278 | } |
276 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, | 279 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, |
277 | true ); | 280 | true ); |
278 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); | 281 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); |
279 | headings[i]->setText( dayName ); | 282 | headings[i]->setText( dayName ); |
280 | } | 283 | } |
281 | updateDates(); | 284 | updateDates(); |
282 | updateView(); | 285 | updateView(); |
283 | } | 286 | } |
284 | 287 | ||
285 | void KDateNavigator::setShowWeekNums(bool enabled) | 288 | void KDateNavigator::setShowWeekNums(bool enabled) |
286 | { | 289 | { |
287 | m_bShowWeekNums = enabled; | 290 | m_bShowWeekNums = enabled; |
288 | for(int i=0; i<6; i++) { | 291 | for(int i=0; i<6; i++) { |
289 | if(enabled) | 292 | if(enabled) |
290 | weeknos[i]->show(); | 293 | weeknos[i]->show(); |
291 | else | 294 | else |
292 | weeknos[i]->hide(); | 295 | weeknos[i]->hide(); |
293 | } | 296 | } |
294 | resize(size()); | 297 | resize(size()); |
295 | } | 298 | } |
296 | 299 | ||
297 | void KDateNavigator::selectDates(const DateList& dateList) | 300 | void KDateNavigator::selectDates(const DateList& dateList) |
298 | { | 301 | { |
299 | 302 | ||
300 | if (dateList.count() > 0) { | 303 | if (dateList.count() > 0) { |
301 | mNavigatorBar->selectDates( dateList ); | 304 | mNavigatorBar->selectDates( dateList ); |
302 | mSelectedDates = dateList; | 305 | mSelectedDates = dateList; |
303 | 306 | ||
304 | // set our record of the month and year that this datetbl is | 307 | // set our record of the month and year that this datetbl is |
305 | // displaying. | 308 | // displaying. |
306 | m_MthYr = mSelectedDates.first(); | 309 | m_MthYr = mSelectedDates.first(); |
307 | 310 | ||
308 | 311 | ||
309 | // set our record of the first day of the week of the current | 312 | // set our record of the first day of the week of the current |
310 | // month. This needs to be done before calling dayToIndex, since it | 313 | // month. This needs to be done before calling dayToIndex, since it |
311 | // relies on this information being up to date. | 314 | // relies on this information being up to date. |
312 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 315 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
313 | m_fstDayOfWk = dayone.dayOfWeek(); | 316 | m_fstDayOfWk = dayone.dayOfWeek(); |
314 | 317 | ||
315 | updateDates(); | 318 | updateDates(); |
316 | 319 | ||
317 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 320 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
318 | 321 | ||
319 | updateView(); | 322 | updateView(); |
320 | } | 323 | } |
321 | } | 324 | } |
322 | 325 | ||
323 | int KDateNavigator::dayNum(int row, int col) | 326 | int KDateNavigator::dayNum(int row, int col) |
324 | { | 327 | { |
325 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; | 328 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; |
326 | } | 329 | } |
327 | 330 | ||
328 | int KDateNavigator::dayToIndex(int dayNum) | 331 | int KDateNavigator::dayToIndex(int dayNum) |
329 | { | 332 | { |
330 | int row, col; | 333 | int row, col; |
331 | 334 | ||
332 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; | 335 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; |
333 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) | 336 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) |
334 | row++; | 337 | row++; |
335 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; | 338 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; |
336 | return row * 7 + col; | 339 | return row * 7 + col; |
337 | } | 340 | } |
338 | 341 | ||
339 | void KDateNavigator::wheelEvent (QWheelEvent *e) | 342 | void KDateNavigator::wheelEvent (QWheelEvent *e) |
340 | { | 343 | { |
341 | if(e->delta()>0) emit goPrevious(); | 344 | if(e->delta()>0) emit goPrevious(); |
342 | else emit goNext(); | 345 | else emit goNext(); |
343 | 346 | ||
344 | e->accept(); | 347 | e->accept(); |
345 | } | 348 | } |
346 | 349 | ||
347 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) | 350 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) |
348 | { | 351 | { |
349 | if (e->type() == QEvent::MouseButtonPress) { | 352 | if (e->type() == QEvent::MouseButtonPress) { |
350 | int i; | 353 | int i; |
351 | for(i=0;i<6;++i) { | 354 | for(i=0;i<6;++i) { |
352 | if (o == weeknos[i]) { | 355 | if (o == weeknos[i]) { |
353 | QDate weekstart = daymatrix->getDate(i*7); | 356 | QDate weekstart = daymatrix->getDate(i*7); |
354 | emit weekClicked(weekstart); | 357 | emit weekClicked(weekstart); |
355 | break; | 358 | break; |
356 | } | 359 | } |
357 | } | 360 | } |
358 | return true; | 361 | return true; |
359 | } else { | 362 | } else { |
360 | return false; | 363 | return false; |
361 | } | 364 | } |
362 | } | 365 | } |
363 | 366 | ||
364 | //#include "kdatenavigator.moc" | 367 | //#include "kdatenavigator.moc" |
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index 584d1ed..4209e10 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -543,597 +543,597 @@ RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, | |||
543 | SLOT( showCurrentRange() ) ); | 543 | SLOT( showCurrentRange() ) ); |
544 | connect( mEndDurationButton, SIGNAL( toggled( bool ) ), | 544 | connect( mEndDurationButton, SIGNAL( toggled( bool ) ), |
545 | SLOT( showCurrentRange() ) ); | 545 | SLOT( showCurrentRange() ) ); |
546 | connect( mEndDateButton, SIGNAL( toggled( bool ) ), | 546 | connect( mEndDateButton, SIGNAL( toggled( bool ) ), |
547 | SLOT( showCurrentRange() ) ); | 547 | SLOT( showCurrentRange() ) ); |
548 | } | 548 | } |
549 | 549 | ||
550 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) | 550 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) |
551 | { | 551 | { |
552 | mNoEndDateButton->setChecked( true ); | 552 | mNoEndDateButton->setChecked( true ); |
553 | 553 | ||
554 | setDateTimes( from ); | 554 | setDateTimes( from ); |
555 | mEndDateEdit->setDate( from.date() ); | 555 | mEndDateEdit->setDate( from.date() ); |
556 | } | 556 | } |
557 | 557 | ||
558 | void RecurrenceRangeWidget::setDuration( int duration ) | 558 | void RecurrenceRangeWidget::setDuration( int duration ) |
559 | { | 559 | { |
560 | if ( duration == -1 ) { | 560 | if ( duration == -1 ) { |
561 | mNoEndDateButton->setChecked( true ); | 561 | mNoEndDateButton->setChecked( true ); |
562 | } else if ( duration == 0 ) { | 562 | } else if ( duration == 0 ) { |
563 | mEndDateButton->setChecked( true ); | 563 | mEndDateButton->setChecked( true ); |
564 | } else { | 564 | } else { |
565 | mEndDurationButton->setChecked( true ); | 565 | mEndDurationButton->setChecked( true ); |
566 | mEndDurationEdit->setValue( duration ); | 566 | mEndDurationEdit->setValue( duration ); |
567 | } | 567 | } |
568 | } | 568 | } |
569 | 569 | ||
570 | int RecurrenceRangeWidget::duration() | 570 | int RecurrenceRangeWidget::duration() |
571 | { | 571 | { |
572 | if ( mNoEndDateButton->isChecked() ) { | 572 | if ( mNoEndDateButton->isChecked() ) { |
573 | return -1; | 573 | return -1; |
574 | } else if ( mEndDurationButton->isChecked() ) { | 574 | } else if ( mEndDurationButton->isChecked() ) { |
575 | return mEndDurationEdit->value(); | 575 | return mEndDurationEdit->value(); |
576 | } else { | 576 | } else { |
577 | return 0; | 577 | return 0; |
578 | } | 578 | } |
579 | } | 579 | } |
580 | 580 | ||
581 | void RecurrenceRangeWidget::setEndDate( const QDate &date ) | 581 | void RecurrenceRangeWidget::setEndDate( const QDate &date ) |
582 | { | 582 | { |
583 | mEndDateEdit->setDate( date ); | 583 | mEndDateEdit->setDate( date ); |
584 | } | 584 | } |
585 | 585 | ||
586 | QDate RecurrenceRangeWidget::endDate() | 586 | QDate RecurrenceRangeWidget::endDate() |
587 | { | 587 | { |
588 | return mEndDateEdit->date(); | 588 | return mEndDateEdit->date(); |
589 | } | 589 | } |
590 | 590 | ||
591 | void RecurrenceRangeWidget::showCurrentRange() | 591 | void RecurrenceRangeWidget::showCurrentRange() |
592 | { | 592 | { |
593 | mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); | 593 | mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); |
594 | mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); | 594 | mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); |
595 | } | 595 | } |
596 | 596 | ||
597 | void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, | 597 | void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, |
598 | const QDateTime & ) | 598 | const QDateTime & ) |
599 | { | 599 | { |
600 | mStartDateLabel->setText( i18n("Start date: %1") | 600 | mStartDateLabel->setText( i18n("Start date: %1") |
601 | .arg( KGlobal::locale()->formatDate( start.date() ) ) ); | 601 | .arg( KGlobal::locale()->formatDate( start.date() ) ) ); |
602 | 602 | ||
603 | if(!mEndDateButton->isChecked()) | 603 | if(!mEndDateButton->isChecked()) |
604 | mEndDateEdit->setDate( start.date() ); | 604 | mEndDateEdit->setDate( start.date() ); |
605 | } | 605 | } |
606 | 606 | ||
607 | ///////////////////////// RecurrenceRangeDialog /////////////////////////// | 607 | ///////////////////////// RecurrenceRangeDialog /////////////////////////// |
608 | 608 | ||
609 | RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, | 609 | RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, |
610 | const char *name ) : | 610 | const char *name ) : |
611 | KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) | 611 | KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) |
612 | { | 612 | { |
613 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); | 613 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); |
614 | setMainWidget( mRecurrenceRangeWidget ); | 614 | setMainWidget( mRecurrenceRangeWidget ); |
615 | } | 615 | } |
616 | 616 | ||
617 | void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) | 617 | void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) |
618 | { | 618 | { |
619 | mRecurrenceRangeWidget->setDefaults( from ); | 619 | mRecurrenceRangeWidget->setDefaults( from ); |
620 | } | 620 | } |
621 | 621 | ||
622 | void RecurrenceRangeDialog::setDuration( int duration ) | 622 | void RecurrenceRangeDialog::setDuration( int duration ) |
623 | { | 623 | { |
624 | mRecurrenceRangeWidget->setDuration( duration ); | 624 | mRecurrenceRangeWidget->setDuration( duration ); |
625 | } | 625 | } |
626 | 626 | ||
627 | int RecurrenceRangeDialog::duration() | 627 | int RecurrenceRangeDialog::duration() |
628 | { | 628 | { |
629 | return mRecurrenceRangeWidget->duration(); | 629 | return mRecurrenceRangeWidget->duration(); |
630 | } | 630 | } |
631 | 631 | ||
632 | void RecurrenceRangeDialog::setEndDate( const QDate &date ) | 632 | void RecurrenceRangeDialog::setEndDate( const QDate &date ) |
633 | { | 633 | { |
634 | mRecurrenceRangeWidget->setEndDate( date ); | 634 | mRecurrenceRangeWidget->setEndDate( date ); |
635 | } | 635 | } |
636 | 636 | ||
637 | QDate RecurrenceRangeDialog::endDate() | 637 | QDate RecurrenceRangeDialog::endDate() |
638 | { | 638 | { |
639 | return mRecurrenceRangeWidget->endDate(); | 639 | return mRecurrenceRangeWidget->endDate(); |
640 | } | 640 | } |
641 | 641 | ||
642 | void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, | 642 | void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, |
643 | const QDateTime &end ) | 643 | const QDateTime &end ) |
644 | { | 644 | { |
645 | mRecurrenceRangeWidget->setDateTimes( start, end ); | 645 | mRecurrenceRangeWidget->setDateTimes( start, end ); |
646 | } | 646 | } |
647 | 647 | ||
648 | //////////////////////////// RecurrenceChooser //////////////////////// | 648 | //////////////////////////// RecurrenceChooser //////////////////////// |
649 | 649 | ||
650 | RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : | 650 | RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : |
651 | QWidget( parent, name ) | 651 | QWidget( parent, name ) |
652 | { | 652 | { |
653 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 653 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
654 | 654 | ||
655 | if ( KOPrefs::instance()->mCompactDialogs ) { | 655 | if ( KOPrefs::instance()->mCompactDialogs ) { |
656 | mTypeCombo = new QComboBox( this ); | 656 | mTypeCombo = new QComboBox( this ); |
657 | mTypeCombo->insertItem( i18n("Daily") ); | 657 | mTypeCombo->insertItem( i18n("Daily") ); |
658 | mTypeCombo->insertItem( i18n("Weekly") ); | 658 | mTypeCombo->insertItem( i18n("Weekly") ); |
659 | mTypeCombo->insertItem( i18n("Monthly") ); | 659 | mTypeCombo->insertItem( i18n("Monthly") ); |
660 | mTypeCombo->insertItem( i18n("Yearly") ); | 660 | mTypeCombo->insertItem( i18n("Yearly") ); |
661 | 661 | ||
662 | topLayout->addWidget( mTypeCombo ); | 662 | topLayout->addWidget( mTypeCombo ); |
663 | 663 | ||
664 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); | 664 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); |
665 | } else { | 665 | } else { |
666 | mTypeCombo = 0; | 666 | mTypeCombo = 0; |
667 | 667 | ||
668 | QButtonGroup *ruleButtonGroup = new QButtonGroup( 1, Horizontal, this ); | 668 | QButtonGroup *ruleButtonGroup = new QButtonGroup( 1, Horizontal, this ); |
669 | ruleButtonGroup->setFrameStyle( QFrame::NoFrame ); | 669 | ruleButtonGroup->setFrameStyle( QFrame::NoFrame ); |
670 | topLayout->addWidget( ruleButtonGroup ); | 670 | topLayout->addWidget( ruleButtonGroup ); |
671 | 671 | ||
672 | mDailyButton = new QRadioButton( i18n("Daily"), ruleButtonGroup ); | 672 | mDailyButton = new QRadioButton( i18n("Daily"), ruleButtonGroup ); |
673 | mWeeklyButton = new QRadioButton( i18n("Weekly"), ruleButtonGroup ); | 673 | mWeeklyButton = new QRadioButton( i18n("Weekly"), ruleButtonGroup ); |
674 | mMonthlyButton = new QRadioButton( i18n("Monthly"), ruleButtonGroup ); | 674 | mMonthlyButton = new QRadioButton( i18n("Monthly"), ruleButtonGroup ); |
675 | mYearlyButton = new QRadioButton( i18n("Yearly"), ruleButtonGroup ); | 675 | mYearlyButton = new QRadioButton( i18n("Yearly"), ruleButtonGroup ); |
676 | 676 | ||
677 | connect( mDailyButton, SIGNAL( toggled( bool ) ), | 677 | connect( mDailyButton, SIGNAL( toggled( bool ) ), |
678 | SLOT( emitChoice() ) ); | 678 | SLOT( emitChoice() ) ); |
679 | connect( mWeeklyButton, SIGNAL( toggled( bool ) ), | 679 | connect( mWeeklyButton, SIGNAL( toggled( bool ) ), |
680 | SLOT( emitChoice() ) ); | 680 | SLOT( emitChoice() ) ); |
681 | connect( mMonthlyButton, SIGNAL( toggled( bool ) ), | 681 | connect( mMonthlyButton, SIGNAL( toggled( bool ) ), |
682 | SLOT( emitChoice() ) ); | 682 | SLOT( emitChoice() ) ); |
683 | connect( mYearlyButton, SIGNAL( toggled( bool ) ), | 683 | connect( mYearlyButton, SIGNAL( toggled( bool ) ), |
684 | SLOT( emitChoice() ) ); | 684 | SLOT( emitChoice() ) ); |
685 | } | 685 | } |
686 | } | 686 | } |
687 | 687 | ||
688 | int RecurrenceChooser::type() | 688 | int RecurrenceChooser::type() |
689 | { | 689 | { |
690 | if ( mTypeCombo ) { | 690 | if ( mTypeCombo ) { |
691 | return mTypeCombo->currentItem(); | 691 | return mTypeCombo->currentItem(); |
692 | } else { | 692 | } else { |
693 | if ( mDailyButton->isChecked() ) return Daily; | 693 | if ( mDailyButton->isChecked() ) return Daily; |
694 | else if ( mWeeklyButton->isChecked() ) return Weekly; | 694 | else if ( mWeeklyButton->isChecked() ) return Weekly; |
695 | else if ( mMonthlyButton->isChecked() ) return Monthly; | 695 | else if ( mMonthlyButton->isChecked() ) return Monthly; |
696 | else return Yearly; | 696 | else return Yearly; |
697 | } | 697 | } |
698 | } | 698 | } |
699 | 699 | ||
700 | void RecurrenceChooser::setType( int type ) | 700 | void RecurrenceChooser::setType( int type ) |
701 | { | 701 | { |
702 | if ( mTypeCombo ) { | 702 | if ( mTypeCombo ) { |
703 | mTypeCombo->setCurrentItem( type ); | 703 | mTypeCombo->setCurrentItem( type ); |
704 | } else { | 704 | } else { |
705 | switch ( type ) { | 705 | switch ( type ) { |
706 | case Daily: | 706 | case Daily: |
707 | mDailyButton->setChecked( true ); | 707 | mDailyButton->setChecked( true ); |
708 | break; | 708 | break; |
709 | case Weekly: | 709 | case Weekly: |
710 | mWeeklyButton->setChecked( true ); | 710 | mWeeklyButton->setChecked( true ); |
711 | break; | 711 | break; |
712 | case Monthly: | 712 | case Monthly: |
713 | mMonthlyButton->setChecked( true ); | 713 | mMonthlyButton->setChecked( true ); |
714 | break; | 714 | break; |
715 | case Yearly: | 715 | case Yearly: |
716 | default: | 716 | default: |
717 | mYearlyButton->setChecked( true ); | 717 | mYearlyButton->setChecked( true ); |
718 | break; | 718 | break; |
719 | } | 719 | } |
720 | } | 720 | } |
721 | } | 721 | } |
722 | 722 | ||
723 | void RecurrenceChooser::emitChoice() | 723 | void RecurrenceChooser::emitChoice() |
724 | { | 724 | { |
725 | emit chosen ( type() ); | 725 | emit chosen ( type() ); |
726 | } | 726 | } |
727 | 727 | ||
728 | /////////////////////////////// Main Widget ///////////////////////////// | 728 | /////////////////////////////// Main Widget ///////////////////////////// |
729 | 729 | ||
730 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : | 730 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : |
731 | QWidget( parent, name ) | 731 | QWidget( parent, name ) |
732 | { | 732 | { |
733 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); | 733 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); |
734 | topLayout->setSpacing( KDialog::spacingHint() ); | 734 | topLayout->setSpacing( KDialog::spacingHint() ); |
735 | 735 | ||
736 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); | 736 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); |
737 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), | 737 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), |
738 | SLOT( setEnabled( bool ) ) ); | 738 | SLOT( setEnabled( bool ) ) ); |
739 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); | 739 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); |
740 | 740 | ||
741 | 741 | ||
742 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Appointment Time "), | 742 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Appointment Time "), |
743 | this ); | 743 | this ); |
744 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); | 744 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); |
745 | 745 | ||
746 | if ( KOPrefs::instance()->mCompactDialogs ) { | 746 | if ( KOPrefs::instance()->mCompactDialogs ) { |
747 | mTimeGroupBox->hide(); | 747 | mTimeGroupBox->hide(); |
748 | } | 748 | } |
749 | 749 | ||
750 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); | 750 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); |
751 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); | 751 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); |
752 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); | 752 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); |
753 | 753 | ||
754 | mDateTimeLabel = new QLabel( mTimeGroupBox ); | 754 | mDateTimeLabel = new QLabel( mTimeGroupBox ); |
755 | // mDateTimeLabel = new QLabel( timeFrame ); | 755 | // mDateTimeLabel = new QLabel( timeFrame ); |
756 | // layoutTimeFrame->addWidget( mDateTimeLabel ); | 756 | // layoutTimeFrame->addWidget( mDateTimeLabel ); |
757 | 757 | ||
758 | Qt::Orientation orientation; | 758 | Qt::Orientation orientation; |
759 | if ( KOPrefs::instance()->mCompactDialogs ) orientation = Horizontal; | 759 | if ( KOPrefs::instance()->mCompactDialogs ) orientation = Horizontal; |
760 | else orientation = Vertical; | 760 | else orientation = Vertical; |
761 | 761 | ||
762 | mRuleBox = new QGroupBox( 1, orientation, i18n("Recurrence Rule"), this ); | 762 | mRuleBox = new QGroupBox( 1, orientation, i18n("Recurrence Rule"), this ); |
763 | if ( KOPrefs::instance()->mCompactDialogs ) { | 763 | if ( KOPrefs::instance()->mCompactDialogs ) { |
764 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); | 764 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); |
765 | } else { | 765 | } else { |
766 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); | 766 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); |
767 | } | 767 | } |
768 | 768 | ||
769 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); | 769 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); |
770 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), | 770 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), |
771 | SLOT( showCurrentRule( int ) ) ); | 771 | SLOT( showCurrentRule( int ) ) ); |
772 | 772 | ||
773 | if ( !KOPrefs::instance()->mCompactDialogs ) { | 773 | if ( !KOPrefs::instance()->mCompactDialogs ) { |
774 | QFrame *ruleSepFrame = new QFrame( mRuleBox ); | 774 | QFrame *ruleSepFrame = new QFrame( mRuleBox ); |
775 | ruleSepFrame->setFrameStyle( QFrame::VLine | QFrame::Sunken ); | 775 | ruleSepFrame->setFrameStyle( QFrame::VLine | QFrame::Sunken ); |
776 | } | 776 | } |
777 | 777 | ||
778 | mRuleStack = new QWidgetStack( mRuleBox ); | 778 | mRuleStack = new QWidgetStack( mRuleBox ); |
779 | 779 | ||
780 | mDaily = new RecurDaily( mRuleStack ); | 780 | mDaily = new RecurDaily( mRuleStack ); |
781 | mRuleStack->addWidget( mDaily, 0 ); | 781 | mRuleStack->addWidget( mDaily, 0 ); |
782 | 782 | ||
783 | mWeekly = new RecurWeekly( mRuleStack ); | 783 | mWeekly = new RecurWeekly( mRuleStack ); |
784 | mRuleStack->addWidget( mWeekly, 0 ); | 784 | mRuleStack->addWidget( mWeekly, 0 ); |
785 | 785 | ||
786 | mMonthly = new RecurMonthly( mRuleStack ); | 786 | mMonthly = new RecurMonthly( mRuleStack ); |
787 | mRuleStack->addWidget( mMonthly, 0 ); | 787 | mRuleStack->addWidget( mMonthly, 0 ); |
788 | 788 | ||
789 | mYearly = new RecurYearly( mRuleStack ); | 789 | mYearly = new RecurYearly( mRuleStack ); |
790 | mRuleStack->addWidget( mYearly, 0 ); | 790 | mRuleStack->addWidget( mYearly, 0 ); |
791 | 791 | ||
792 | showCurrentRule( mRecurrenceChooser->type() ); | 792 | showCurrentRule( mRecurrenceChooser->type() ); |
793 | 793 | ||
794 | if ( KOPrefs::instance()->mCompactDialogs ) { | 794 | if ( KOPrefs::instance()->mCompactDialogs ) { |
795 | mRecurrenceRangeWidget = 0; | 795 | mRecurrenceRangeWidget = 0; |
796 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); | 796 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); |
797 | mRecurrenceRange = mRecurrenceRangeDialog; | 797 | mRecurrenceRange = mRecurrenceRangeDialog; |
798 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), | 798 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), |
799 | this ); | 799 | this ); |
800 | 800 | ||
801 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), | 801 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), |
802 | SLOT( showRecurrenceRangeDialog() ) ); | 802 | SLOT( showRecurrenceRangeDialog() ) ); |
803 | 803 | ||
804 | mExceptionsWidget = 0; | 804 | mExceptionsWidget = 0; |
805 | mExceptionsDialog = new ExceptionsDialog( this ); | 805 | mExceptionsDialog = new ExceptionsDialog( this ); |
806 | mExceptions = mExceptionsDialog; | 806 | mExceptions = mExceptionsDialog; |
807 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); | 807 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); |
808 | if ( QApplication::desktop()->width() < 320 ) { | 808 | if ( QApplication::desktop()->width() < 320 ) { |
809 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); | 809 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); |
810 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); | 810 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); |
811 | } else { | 811 | } else { |
812 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); | 812 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); |
813 | topLayout->addWidget( mExceptionsButton, 3, 1 ); | 813 | topLayout->addWidget( mExceptionsButton, 3, 1 ); |
814 | } | 814 | } |
815 | connect( mExceptionsButton, SIGNAL( clicked() ), | 815 | connect( mExceptionsButton, SIGNAL( clicked() ), |
816 | SLOT( showExceptionsDialog() ) ); | 816 | SLOT( showExceptionsDialog() ) ); |
817 | 817 | ||
818 | } else { | 818 | } else { |
819 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); | 819 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); |
820 | mRecurrenceRangeDialog = 0; | 820 | mRecurrenceRangeDialog = 0; |
821 | mRecurrenceRange = mRecurrenceRangeWidget; | 821 | mRecurrenceRange = mRecurrenceRangeWidget; |
822 | mRecurrenceRangeButton = 0; | 822 | mRecurrenceRangeButton = 0; |
823 | topLayout->addWidget( mRecurrenceRangeWidget, 3, 0 ); | 823 | topLayout->addWidget( mRecurrenceRangeWidget, 3, 0 ); |
824 | 824 | ||
825 | mExceptionsWidget = new ExceptionsWidget( this ); | 825 | mExceptionsWidget = new ExceptionsWidget( this ); |
826 | mExceptionsDialog = 0; | 826 | mExceptionsDialog = 0; |
827 | mExceptions = mExceptionsWidget; | 827 | mExceptions = mExceptionsWidget; |
828 | mExceptionsButton = 0; | 828 | mExceptionsButton = 0; |
829 | topLayout->addWidget( mExceptionsWidget, 3, 1 ); | 829 | topLayout->addWidget( mExceptionsWidget, 3, 1 ); |
830 | } | 830 | } |
831 | } | 831 | } |
832 | 832 | ||
833 | KOEditorRecurrence::~KOEditorRecurrence() | 833 | KOEditorRecurrence::~KOEditorRecurrence() |
834 | { | 834 | { |
835 | } | 835 | } |
836 | 836 | ||
837 | void KOEditorRecurrence::setEnabled( bool enabled ) | 837 | void KOEditorRecurrence::setEnabled( bool enabled ) |
838 | { | 838 | { |
839 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; | 839 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; |
840 | 840 | ||
841 | mTimeGroupBox->setEnabled( enabled ); | 841 | mTimeGroupBox->setEnabled( enabled ); |
842 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); | 842 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); |
843 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); | 843 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); |
844 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); | 844 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); |
845 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); | 845 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); |
846 | mRuleBox->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 | days.setBit( from.date().dayOfWeek()- 1); |
899 | mWeekly->setDays( days ); | 899 | mWeekly->setDays( days ); |
900 | mMonthly->setFrequency( 1 ); | 900 | mMonthly->setFrequency( 1 ); |
901 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | 901 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); |
902 | mMonthly->setByDay( from.date().day()-1 ); | 902 | mMonthly->setByDay( from.date().day()-1 ); |
903 | mYearly->setFrequency( 1 ); | 903 | mYearly->setFrequency( 1 ); |
904 | mYearly->setByDay( from.date().dayOfYear() ); | 904 | mYearly->setByDay( from.date().dayOfYear() ); |
905 | mYearly->setByMonth( from.date().month(), from.date().day() ); | 905 | mYearly->setByMonth( from.date().month(), from.date().day() ); |
906 | } | 906 | } |
907 | 907 | ||
908 | void KOEditorRecurrence::readEvent(Event *event) | 908 | void KOEditorRecurrence::readEvent(Event *event) |
909 | { | 909 | { |
910 | setDefaults( event->dtStart(), event->dtEnd(), true ); | 910 | setDefaults( event->dtStart(), event->dtEnd(), true ); |
911 | QBitArray rDays( 7 ); | 911 | QBitArray rDays( 7 ); |
912 | QPtrList<Recurrence::rMonthPos> rmp; | 912 | QPtrList<Recurrence::rMonthPos> rmp; |
913 | QPtrList<int> rmd; | 913 | QPtrList<int> rmd; |
914 | int day = 0; | 914 | int day = 0; |
915 | int count = 0; | 915 | int count = 0; |
916 | int month = 0; | 916 | int month = 0; |
917 | setDateTimes( event->dtStart(), event->dtEnd() ); | 917 | setDateTimes( event->dtStart(), event->dtEnd() ); |
918 | 918 | ||
919 | Recurrence *r = event->recurrence(); | 919 | Recurrence *r = event->recurrence(); |
920 | int f = r->frequency(); | 920 | int f = r->frequency(); |
921 | 921 | ||
922 | int recurs = r->doesRecur(); | 922 | int recurs = r->doesRecur(); |
923 | 923 | ||
924 | mEnabledCheck->setChecked( recurs ); | 924 | mEnabledCheck->setChecked( recurs ); |
925 | setEnabled( recurs ); | 925 | setEnabled( recurs ); |
926 | 926 | ||
927 | int recurrenceType = RecurrenceChooser::Weekly; | 927 | int recurrenceType = RecurrenceChooser::Weekly; |
928 | 928 | ||
929 | switch ( recurs ) { | 929 | switch ( recurs ) { |
930 | case Recurrence::rNone: | 930 | case Recurrence::rNone: |
931 | setDefaults( event->dtStart(), event->dtEnd(), true ); | 931 | setDefaults( event->dtStart(), event->dtEnd(), true ); |
932 | break; | 932 | break; |
933 | case Recurrence::rDaily: | 933 | case Recurrence::rDaily: |
934 | recurrenceType = RecurrenceChooser::Daily; | 934 | recurrenceType = RecurrenceChooser::Daily; |
935 | mDaily->setFrequency( f ); | 935 | mDaily->setFrequency( f ); |
936 | break; | 936 | break; |
937 | case Recurrence::rWeekly: | 937 | case Recurrence::rWeekly: |
938 | recurrenceType = RecurrenceChooser::Weekly; | 938 | recurrenceType = RecurrenceChooser::Weekly; |
939 | mWeekly->setFrequency( f ); | 939 | mWeekly->setFrequency( f ); |
940 | mWeekly->setDays( r->days() ); | 940 | mWeekly->setDays( r->days() ); |
941 | break; | 941 | break; |
942 | case Recurrence::rMonthlyPos: | 942 | case Recurrence::rMonthlyPos: |
943 | // we only handle one possibility in the list right now, | 943 | // we only handle one possibility in the list right now, |
944 | // 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 |
945 | // more extended, this can be changed. | 945 | // more extended, this can be changed. |
946 | recurrenceType = RecurrenceChooser::Monthly; | 946 | recurrenceType = RecurrenceChooser::Monthly; |
947 | 947 | ||
948 | rmp = r->monthPositions(); | 948 | rmp = r->monthPositions(); |
949 | if ( rmp.first()->negative ) | 949 | if ( rmp.first()->negative ) |
950 | count = 5 - rmp.first()->rPos - 1; | 950 | count = 5 - rmp.first()->rPos - 1; |
951 | else | 951 | else |
952 | count = rmp.first()->rPos - 1; | 952 | count = rmp.first()->rPos - 1; |
953 | day = 0; | 953 | day = 0; |
954 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; | 954 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; |
955 | mMonthly->setByPos( count, day ); | 955 | mMonthly->setByPos( count, day ); |
956 | 956 | ||
957 | mMonthly->setFrequency( f ); | 957 | mMonthly->setFrequency( f ); |
958 | 958 | ||
959 | break; | 959 | break; |
960 | case Recurrence::rMonthlyDay: | 960 | case Recurrence::rMonthlyDay: |
961 | recurrenceType = RecurrenceChooser::Monthly; | 961 | recurrenceType = RecurrenceChooser::Monthly; |
962 | 962 | ||
963 | rmd = r->monthDays(); | 963 | rmd = r->monthDays(); |
964 | day = *rmd.first() - 1; | 964 | day = *rmd.first() - 1; |
965 | mMonthly->setByDay( day ); | 965 | mMonthly->setByDay( day ); |
966 | 966 | ||
967 | mMonthly->setFrequency( f ); | 967 | mMonthly->setFrequency( f ); |
968 | 968 | ||
969 | break; | 969 | break; |
970 | case Recurrence::rYearlyMonth: | 970 | case Recurrence::rYearlyMonth: |
971 | { | 971 | { |
972 | recurrenceType = RecurrenceChooser::Yearly; | 972 | recurrenceType = RecurrenceChooser::Yearly; |
973 | qDebug("Recurrence::rYearlyMonth: "); | 973 | qDebug("Recurrence::rYearlyMonth: "); |
974 | day = event->dtStart().date().day(); | 974 | day = event->dtStart().date().day(); |
975 | rmd = r->yearNums(); | 975 | rmd = r->yearNums(); |
976 | if ( rmd.count() > 0 ) | 976 | if ( rmd.count() > 0 ) |
977 | month = *rmd.first(); | 977 | month = *rmd.first(); |
978 | else | 978 | else |
979 | month = event->dtStart().date().month() ; | 979 | month = event->dtStart().date().month() ; |
980 | mYearly->setByMonth( month, day ); | 980 | mYearly->setByMonth( month, day ); |
981 | #if 0 | 981 | #if 0 |
982 | qDebug("2day = %d ",day ); | 982 | qDebug("2day = %d ",day ); |
983 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); | 983 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); |
984 | int month; | 984 | int month; |
985 | if ( !monthlist.isEmpty() ) { | 985 | if ( !monthlist.isEmpty() ) { |
986 | month = monthlist.first()->rPos ; | 986 | month = monthlist.first()->rPos ; |
987 | } else { | 987 | } else { |
988 | month = event->dtStart().date().month() ; | 988 | month = event->dtStart().date().month() ; |
989 | } | 989 | } |
990 | mYearly->setByMonth( day, month ); | 990 | mYearly->setByMonth( day, month ); |
991 | #endif | 991 | #endif |
992 | mYearly->setFrequency( f ); | 992 | mYearly->setFrequency( f ); |
993 | } | 993 | } |
994 | 994 | ||
995 | break; | 995 | break; |
996 | case Recurrence::rYearlyDay: | 996 | case Recurrence::rYearlyDay: |
997 | qDebug("Recurrence::rYearlyDay: "); | 997 | qDebug("Recurrence::rYearlyDay: "); |
998 | recurrenceType = RecurrenceChooser::Yearly; | 998 | recurrenceType = RecurrenceChooser::Yearly; |
999 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); | 999 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); |
1000 | mYearly->setFrequency( f ); | 1000 | mYearly->setFrequency( f ); |
1001 | break; | 1001 | break; |
1002 | default: | 1002 | default: |
1003 | setDefaults( event->dtStart(), event->dtEnd(), true ); | 1003 | setDefaults( event->dtStart(), event->dtEnd(), true ); |
1004 | break; | 1004 | break; |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | mRecurrenceChooser->setType( recurrenceType ); | 1007 | mRecurrenceChooser->setType( recurrenceType ); |
1008 | showCurrentRule( recurrenceType ); | 1008 | showCurrentRule( recurrenceType ); |
1009 | 1009 | ||
1010 | mRecurrenceRange->setDateTimes( event->dtStart() ); | 1010 | mRecurrenceRange->setDateTimes( event->dtStart() ); |
1011 | 1011 | ||
1012 | if ( r->doesRecur() ) { | 1012 | if ( r->doesRecur() ) { |
1013 | mRecurrenceRange->setDuration( r->duration() ); | 1013 | mRecurrenceRange->setDuration( r->duration() ); |
1014 | if ( r->duration() == 0 ) | 1014 | if ( r->duration() == 0 ) |
1015 | { | 1015 | { |
1016 | if ( r->endDate() < event->dtStart().date() ) | 1016 | if ( r->endDate() < event->dtStart().date() ) |
1017 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 1017 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
1018 | else | 1018 | else |
1019 | mRecurrenceRange->setEndDate( r->endDate() ); | 1019 | mRecurrenceRange->setEndDate( r->endDate() ); |
1020 | } else | 1020 | } else |
1021 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 1021 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | mExceptions->setDates( event->exDates() ); | 1024 | mExceptions->setDates( event->exDates() ); |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | void KOEditorRecurrence::writeEvent( Event *event ) | 1027 | void KOEditorRecurrence::writeEvent( Event *event ) |
1028 | { | 1028 | { |
1029 | Recurrence *r = event->recurrence(); | 1029 | Recurrence *r = event->recurrence(); |
1030 | 1030 | ||
1031 | // clear out any old settings; | 1031 | // clear out any old settings; |
1032 | r->unsetRecurs(); | 1032 | r->unsetRecurs(); |
1033 | 1033 | ||
1034 | if ( mEnabledCheck->isChecked() ) { | 1034 | if ( mEnabledCheck->isChecked() ) { |
1035 | int duration = mRecurrenceRange->duration(); | 1035 | int duration = mRecurrenceRange->duration(); |
1036 | QDate endDate; | 1036 | QDate endDate; |
1037 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); | 1037 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); |
1038 | 1038 | ||
1039 | int recurrenceType = mRecurrenceChooser->type(); | 1039 | int recurrenceType = mRecurrenceChooser->type(); |
1040 | 1040 | ||
1041 | if ( recurrenceType == RecurrenceChooser::Daily ) { | 1041 | if ( recurrenceType == RecurrenceChooser::Daily ) { |
1042 | int freq = mDaily->frequency(); | 1042 | int freq = mDaily->frequency(); |
1043 | if ( duration != 0 ) r->setDaily( freq, duration ); | 1043 | if ( duration != 0 ) r->setDaily( freq, duration ); |
1044 | else r->setDaily( freq, endDate ); | 1044 | else r->setDaily( freq, endDate ); |
1045 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { | 1045 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { |
1046 | int freq = mWeekly->frequency(); | 1046 | int freq = mWeekly->frequency(); |
1047 | QBitArray days = mWeekly->days(); | 1047 | QBitArray days = mWeekly->days(); |
1048 | int j; | 1048 | int j; |
1049 | bool found = false; | 1049 | bool found = false; |
1050 | for (j = 0; j < 7 ; ++j ) { | 1050 | for (j = 0; j < 7 ; ++j ) { |
1051 | found |=days.at(j); | 1051 | found |=days.at(j); |
1052 | } | 1052 | } |
1053 | if ( !found ) { | 1053 | if ( !found ) { |
1054 | days.setBit( event->dtStart().date().dayOfWeek()-1); | 1054 | days.setBit( event->dtStart().date().dayOfWeek()-1); |
1055 | qDebug("bit set %d "); | 1055 | qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); |
1056 | } | 1056 | } |
1057 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); | 1057 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); |
1058 | else r->setWeekly( freq, days, endDate ); | 1058 | else r->setWeekly( freq, days, endDate ); |
1059 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { | 1059 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { |
1060 | int freq = mMonthly->frequency(); | 1060 | int freq = mMonthly->frequency(); |
1061 | if ( mMonthly->byPos() ) { | 1061 | if ( mMonthly->byPos() ) { |
1062 | int pos = mMonthly->count(); | 1062 | int pos = mMonthly->count(); |
1063 | 1063 | ||
1064 | QBitArray days( 7 ); | 1064 | QBitArray days( 7 ); |
1065 | days.fill( false ); | 1065 | days.fill( false ); |
1066 | 1066 | ||
1067 | days.setBit( mMonthly->weekday() ); | 1067 | days.setBit( mMonthly->weekday() ); |
1068 | if ( duration != 0 ) | 1068 | if ( duration != 0 ) |
1069 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); | 1069 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); |
1070 | else | 1070 | else |
1071 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 1071 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
1072 | r->addMonthlyPos( pos, days ); | 1072 | r->addMonthlyPos( pos, days ); |
1073 | } else { | 1073 | } else { |
1074 | // it's by day | 1074 | // it's by day |
1075 | int day = mMonthly->day(); | 1075 | int day = mMonthly->day(); |
1076 | 1076 | ||
1077 | if ( duration != 0 ) { | 1077 | if ( duration != 0 ) { |
1078 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); | 1078 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); |
1079 | } else { | 1079 | } else { |
1080 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 1080 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
1081 | } | 1081 | } |
1082 | r->addMonthlyDay( day ); | 1082 | r->addMonthlyDay( day ); |
1083 | } | 1083 | } |
1084 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { | 1084 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { |
1085 | qDebug("RecurrenceChooser::Yearly "); | 1085 | qDebug("RecurrenceChooser::Yearly "); |
1086 | int freq = mYearly->frequency(); | 1086 | int freq = mYearly->frequency(); |
1087 | if ( mYearly->byDay() ) { | 1087 | if ( mYearly->byDay() ) { |
1088 | if ( duration != 0 ) { | 1088 | if ( duration != 0 ) { |
1089 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); | 1089 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); |
1090 | } else { | 1090 | } else { |
1091 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); | 1091 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); |
1092 | } | 1092 | } |
1093 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); | 1093 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); |
1094 | } else { | 1094 | } else { |
1095 | if ( duration != 0 ) { | 1095 | if ( duration != 0 ) { |
1096 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | 1096 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); |
1097 | } else { | 1097 | } else { |
1098 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 1098 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
1099 | } | 1099 | } |
1100 | r->addYearlyNum( mYearly->month() ); | 1100 | r->addYearlyNum( mYearly->month() ); |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | event->setExDates( mExceptions->dates() ); | 1105 | event->setExDates( mExceptions->dates() ); |
1106 | } | 1106 | } |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) | 1109 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) |
1110 | { | 1110 | { |
1111 | mDateTimeLabel->setText( str ); | 1111 | mDateTimeLabel->setText( str ); |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | bool KOEditorRecurrence::validateInput() | 1114 | bool KOEditorRecurrence::validateInput() |
1115 | { | 1115 | { |
1116 | // Check input here | 1116 | // Check input here |
1117 | 1117 | ||
1118 | return true; | 1118 | return true; |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | void KOEditorRecurrence::showExceptionsDialog() | 1121 | void KOEditorRecurrence::showExceptionsDialog() |
1122 | { | 1122 | { |
1123 | DateList dates = mExceptions->dates(); | 1123 | DateList dates = mExceptions->dates(); |
1124 | int result = mExceptionsDialog->exec(); | 1124 | int result = mExceptionsDialog->exec(); |
1125 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); | 1125 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | void KOEditorRecurrence::showRecurrenceRangeDialog() | 1128 | void KOEditorRecurrence::showRecurrenceRangeDialog() |
1129 | { | 1129 | { |
1130 | int duration = mRecurrenceRange->duration(); | 1130 | int duration = mRecurrenceRange->duration(); |
1131 | QDate endDate = mRecurrenceRange->endDate(); | 1131 | QDate endDate = mRecurrenceRange->endDate(); |
1132 | 1132 | ||
1133 | int result = mRecurrenceRangeDialog->exec(); | 1133 | int result = mRecurrenceRangeDialog->exec(); |
1134 | if ( result == QDialog::Rejected ) { | 1134 | if ( result == QDialog::Rejected ) { |
1135 | mRecurrenceRange->setDuration( duration ); | 1135 | mRecurrenceRange->setDuration( duration ); |
1136 | mRecurrenceRange->setEndDate( endDate ); | 1136 | mRecurrenceRange->setEndDate( endDate ); |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | } | 1139 | } |