summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-07-29 20:08:52 (UTC)
committer zautrix <zautrix>2005-07-29 20:08:52 (UTC)
commite287df45507793e2e5ad16085a858153f3798941 (patch) (unidiff)
treef91ff66a8ac59254b9a0158e55d6254ca2928d75 /korganizer
parent48a8fa71f1985fea9df4981808796ef65f0f974a (diff)
downloadkdepimpi-e287df45507793e2e5ad16085a858153f3798941.zip
kdepimpi-e287df45507793e2e5ad16085a858153f3798941.tar.gz
kdepimpi-e287df45507793e2e5ad16085a858153f3798941.tar.bz2
fixx
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeditorrecurrence.cpp12
-rw-r--r--korganizer/koeditorrecurrence.h3
2 files changed, 11 insertions, 4 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp
index 89504db..0e74a99 100644
--- a/korganizer/koeditorrecurrence.cpp
+++ b/korganizer/koeditorrecurrence.cpp
@@ -1,1126 +1,1130 @@
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 23
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qfiledialog.h> 25#include <qfiledialog.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qlistbox.h> 32#include <qlistbox.h>
33#include <qspinbox.h> 33#include <qspinbox.h>
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qapplication.h> 35#include <qapplication.h>
36 36
37#include <kdialog.h> 37#include <kdialog.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <knumvalidator.h> 42#include <knumvalidator.h>
43 43
44#include <libkcal/event.h> 44#include <libkcal/event.h>
45#include <libkcal/todo.h> 45#include <libkcal/todo.h>
46 46
47#include <libkdepim/kdateedit.h> 47#include <libkdepim/kdateedit.h>
48 48
49#include "koprefs.h" 49#include "koprefs.h"
50 50
51#include "koeditorrecurrence.h" 51#include "koeditorrecurrence.h"
52 52
53/////////////////////////// RecurBase /////////////////////////////// 53/////////////////////////// RecurBase ///////////////////////////////
54 54
55RecurBase::RecurBase( QWidget *parent, const char *name ) : 55RecurBase::RecurBase( QWidget *parent, const char *name ) :
56 QWidget( parent, name ) 56 QWidget( parent, name )
57{ 57{
58 mFrequencyEdit = new QSpinBox( 1, 9999, 1, this ); 58 mFrequencyEdit = new QSpinBox( 1, 9999, 1, this );
59 mFrequencyEdit->setValue( 1 ); 59 mFrequencyEdit->setValue( 1 );
60} 60}
61 61
62QWidget *RecurBase::frequencyEdit() 62QWidget *RecurBase::frequencyEdit()
63{ 63{
64 return mFrequencyEdit; 64 return mFrequencyEdit;
65} 65}
66 66
67void RecurBase::setFrequency( int f ) 67void RecurBase::setFrequency( int f )
68{ 68{
69 if ( f < 1 ) f = 1; 69 if ( f < 1 ) f = 1;
70 70
71 mFrequencyEdit->setValue( f ); 71 mFrequencyEdit->setValue( f );
72} 72}
73 73
74int RecurBase::frequency() 74int RecurBase::frequency()
75{ 75{
76 return mFrequencyEdit->value(); 76 return mFrequencyEdit->value();
77} 77}
78 78
79/////////////////////////// RecurDaily /////////////////////////////// 79/////////////////////////// RecurDaily ///////////////////////////////
80 80
81RecurDaily::RecurDaily( QWidget *parent, const char *name ) : 81RecurDaily::RecurDaily( QWidget *parent, const char *name ) :
82 RecurBase( parent, name ) 82 RecurBase( parent, name )
83{ 83{
84 QBoxLayout *topLayout = new QHBoxLayout( this ); 84 QBoxLayout *topLayout = new QHBoxLayout( this );
85 topLayout->setSpacing( KDialog::spacingHint() ); 85 topLayout->setSpacing( KDialog::spacingHint() );
86 topLayout->setMargin( KDialog::marginHintSmall() ); 86 topLayout->setMargin( KDialog::marginHintSmall() );
87 87
88 QLabel *preLabel = new QLabel( i18n("Recur every"), this ); 88 QLabel *preLabel = new QLabel( i18n("Recur every"), this );
89 topLayout->addWidget( preLabel ); 89 topLayout->addWidget( preLabel );
90 90
91 topLayout->addWidget( frequencyEdit() ); 91 topLayout->addWidget( frequencyEdit() );
92 92
93 QLabel *postLabel = new QLabel( i18n("day(s)"), this ); 93 QLabel *postLabel = new QLabel( i18n("day(s)"), this );
94 topLayout->addWidget( postLabel ); 94 topLayout->addWidget( postLabel );
95} 95}
96 96
97 97
98/////////////////////////// RecurWeekly /////////////////////////////// 98/////////////////////////// RecurWeekly ///////////////////////////////
99 99
100RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) : 100RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) :
101 RecurBase( parent, name ) 101 RecurBase( parent, name )
102{ 102{
103 QBoxLayout *topLayout = new QVBoxLayout( this ); 103 QBoxLayout *topLayout = new QVBoxLayout( this );
104 topLayout->setSpacing( KDialog::spacingHint() ); 104 topLayout->setSpacing( KDialog::spacingHint() );
105 topLayout->setMargin( KDialog::marginHintSmall() ); 105 topLayout->setMargin( KDialog::marginHintSmall() );
106 106
107 //topLayout->addStretch( 1 ); 107 //topLayout->addStretch( 1 );
108 108
109 QBoxLayout *weeksLayout = new QHBoxLayout( topLayout ); 109 QBoxLayout *weeksLayout = new QHBoxLayout( topLayout );
110 110
111 QLabel *preLabel = new QLabel( i18n("Recur every"), this ); 111 QLabel *preLabel = new QLabel( i18n("Recur every"), this );
112 weeksLayout->addWidget( preLabel ); 112 weeksLayout->addWidget( preLabel );
113 113
114 weeksLayout->addWidget( frequencyEdit() ); 114 weeksLayout->addWidget( frequencyEdit() );
115 115
116 QLabel *postLabel = new QLabel( i18n("week(s) on:"), this ); 116 QLabel *postLabel = new QLabel( i18n("week(s) on:"), this );
117 weeksLayout->addWidget( postLabel ); 117 weeksLayout->addWidget( postLabel );
118 118
119 QHBox *dayBox = new QHBox( this ); 119 QHBox *dayBox = new QHBox( this );
120 topLayout->addWidget( dayBox, 1, AlignVCenter ); 120 topLayout->addWidget( dayBox, 1, AlignVCenter );
121 // TODO: Respect start of week setting 121 // TODO: Respect start of week setting
122 for ( int i = 0; i < 7; ++i ) { 122 for ( int i = 0; i < 7; ++i ) {
123 QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true ); 123 QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true );
124 int left = 1; 124 int left = 1;
125 if ( QApplication::desktop()->width() > 480 ) { 125 if ( QApplication::desktop()->width() > 480 ) {
126 ++left; 126 ++left;
127 if ( QApplication::desktop()->width() > 640 ) 127 if ( QApplication::desktop()->width() > 640 )
128 ++left; 128 ++left;
129 } 129 }
130 mDayBoxes[ i ] = new QCheckBox( weekDayName.left( left ), dayBox ); 130 mDayBoxes[ i ] = new QCheckBox( weekDayName.left( left ), dayBox );
131 } 131 }
132 132
133 topLayout->addStretch( ); 133 topLayout->addStretch( );
134} 134}
135 135
136void RecurWeekly::setDays( const QBitArray &days ) 136void RecurWeekly::setDays( const QBitArray &days )
137{ 137{
138 for ( int i = 0; i < 7; ++i ) { 138 for ( int i = 0; i < 7; ++i ) {
139 mDayBoxes[ i ]->setChecked( days.testBit( i ) ); 139 mDayBoxes[ i ]->setChecked( days.testBit( i ) );
140 } 140 }
141} 141}
142 142
143QBitArray RecurWeekly::days() 143QBitArray RecurWeekly::days()
144{ 144{
145 QBitArray days( 7 ); 145 QBitArray days( 7 );
146 146
147 for ( int i = 0; i < 7; ++i ) { 147 for ( int i = 0; i < 7; ++i ) {
148 days.setBit( i, mDayBoxes[ i ]->isChecked() ); 148 days.setBit( i, mDayBoxes[ i ]->isChecked() );
149 } 149 }
150 150
151 return days; 151 return days;
152} 152}
153 153
154/////////////////////////// RecurMonthly /////////////////////////////// 154/////////////////////////// RecurMonthly ///////////////////////////////
155 155
156RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) : 156RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) :
157 RecurBase( parent, name ) 157 RecurBase( parent, name )
158{ 158{
159 QBoxLayout *topLayout = new QVBoxLayout( this ); 159 QBoxLayout *topLayout = new QVBoxLayout( this );
160 topLayout->setSpacing( KDialog::spacingHint() ); 160 topLayout->setSpacing( KDialog::spacingHint() );
161 topLayout->setMargin( KDialog::marginHintSmall() ); 161 topLayout->setMargin( KDialog::marginHintSmall() );
162 162
163 163
164 QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); 164 QBoxLayout *freqLayout = new QHBoxLayout( topLayout );
165 165
166 QLabel *preLabel = new QLabel( i18n("every"), this ); 166 QLabel *preLabel = new QLabel( i18n("every"), this );
167 freqLayout->addWidget( preLabel ); 167 freqLayout->addWidget( preLabel );
168 168
169 freqLayout->addWidget( frequencyEdit() ); 169 freqLayout->addWidget( frequencyEdit() );
170 170
171 QLabel *postLabel = new QLabel( i18n("month(s)"), this ); 171 QLabel *postLabel = new QLabel( i18n("month(s)"), this );
172 freqLayout->addWidget( postLabel ); 172 freqLayout->addWidget( postLabel );
173 173
174 174
175 QButtonGroup *buttonGroup = new QButtonGroup( this ); 175 QButtonGroup *buttonGroup = new QButtonGroup( this );
176 buttonGroup->setFrameStyle( QFrame::NoFrame ); 176 buttonGroup->setFrameStyle( QFrame::NoFrame );
177 topLayout->addWidget( buttonGroup, 1, AlignVCenter ); 177 topLayout->addWidget( buttonGroup, 1, AlignVCenter );
178 178
179 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); 179 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 );
180 buttonLayout->setSpacing( KDialog::spacingHint() ); 180 buttonLayout->setSpacing( KDialog::spacingHint() );
181 buttonLayout->setMargin( KDialog::marginHintSmall() ); 181 buttonLayout->setMargin( KDialog::marginHintSmall() );
182 182
183 183
184 QString recurOnText; 184 QString recurOnText;
185 if ( QApplication::desktop()->width() > 320 ) { 185 if ( QApplication::desktop()->width() > 320 ) {
186 recurOnText = i18n("Recur on the"); 186 recurOnText = i18n("Recur on the");
187 } 187 }
188 188
189 mByDayRadio = new QRadioButton( recurOnText, buttonGroup ); 189 mByDayRadio = new QRadioButton( recurOnText, buttonGroup );
190 buttonLayout->addWidget( mByDayRadio, 0, 0 ); 190 buttonLayout->addWidget( mByDayRadio, 0, 0 );
191 191
192 mByDayCombo = new QComboBox( buttonGroup ); 192 mByDayCombo = new QComboBox( buttonGroup );
193 mByDayCombo->setSizeLimit( 7 ); 193 mByDayCombo->setSizeLimit( 7 );
194 mByDayCombo->insertItem( i18n("1st") ); 194 mByDayCombo->insertItem( i18n("1st") );
195 mByDayCombo->insertItem( i18n("2nd") ); 195 mByDayCombo->insertItem( i18n("2nd") );
196 mByDayCombo->insertItem( i18n("3rd") ); 196 mByDayCombo->insertItem( i18n("3rd") );
197 mByDayCombo->insertItem( i18n("4th") ); 197 mByDayCombo->insertItem( i18n("4th") );
198 mByDayCombo->insertItem( i18n("5th") ); 198 mByDayCombo->insertItem( i18n("5th") );
199 mByDayCombo->insertItem( i18n("6th") ); 199 mByDayCombo->insertItem( i18n("6th") );
200 mByDayCombo->insertItem( i18n("7th") ); 200 mByDayCombo->insertItem( i18n("7th") );
201 mByDayCombo->insertItem( i18n("8th") ); 201 mByDayCombo->insertItem( i18n("8th") );
202 mByDayCombo->insertItem( i18n("9th") ); 202 mByDayCombo->insertItem( i18n("9th") );
203 mByDayCombo->insertItem( i18n("10th") ); 203 mByDayCombo->insertItem( i18n("10th") );
204 mByDayCombo->insertItem( i18n("11th") ); 204 mByDayCombo->insertItem( i18n("11th") );
205 mByDayCombo->insertItem( i18n("12th") ); 205 mByDayCombo->insertItem( i18n("12th") );
206 mByDayCombo->insertItem( i18n("13th") ); 206 mByDayCombo->insertItem( i18n("13th") );
207 mByDayCombo->insertItem( i18n("14th") ); 207 mByDayCombo->insertItem( i18n("14th") );
208 mByDayCombo->insertItem( i18n("15th") ); 208 mByDayCombo->insertItem( i18n("15th") );
209 mByDayCombo->insertItem( i18n("16th") ); 209 mByDayCombo->insertItem( i18n("16th") );
210 mByDayCombo->insertItem( i18n("17th") ); 210 mByDayCombo->insertItem( i18n("17th") );
211 mByDayCombo->insertItem( i18n("18th") ); 211 mByDayCombo->insertItem( i18n("18th") );
212 mByDayCombo->insertItem( i18n("19th") ); 212 mByDayCombo->insertItem( i18n("19th") );
213 mByDayCombo->insertItem( i18n("20th") ); 213 mByDayCombo->insertItem( i18n("20th") );
214 mByDayCombo->insertItem( i18n("21st") ); 214 mByDayCombo->insertItem( i18n("21st") );
215 mByDayCombo->insertItem( i18n("22nd") ); 215 mByDayCombo->insertItem( i18n("22nd") );
216 mByDayCombo->insertItem( i18n("23rd") ); 216 mByDayCombo->insertItem( i18n("23rd") );
217 mByDayCombo->insertItem( i18n("24th") ); 217 mByDayCombo->insertItem( i18n("24th") );
218 mByDayCombo->insertItem( i18n("25th") ); 218 mByDayCombo->insertItem( i18n("25th") );
219 mByDayCombo->insertItem( i18n("26th") ); 219 mByDayCombo->insertItem( i18n("26th") );
220 mByDayCombo->insertItem( i18n("27th") ); 220 mByDayCombo->insertItem( i18n("27th") );
221 mByDayCombo->insertItem( i18n("28th") ); 221 mByDayCombo->insertItem( i18n("28th") );
222 mByDayCombo->insertItem( i18n("29th") ); 222 mByDayCombo->insertItem( i18n("29th") );
223 mByDayCombo->insertItem( i18n("30th") ); 223 mByDayCombo->insertItem( i18n("30th") );
224 mByDayCombo->insertItem( i18n("31st") ); 224 mByDayCombo->insertItem( i18n("31st") );
225 buttonLayout->addWidget( mByDayCombo, 0, 1 ); 225 buttonLayout->addWidget( mByDayCombo, 0, 1 );
226 226
227 QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup ); 227 QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup );
228 buttonLayout->addWidget( byDayLabel, 0, 2 ); 228 buttonLayout->addWidget( byDayLabel, 0, 2 );
229 229
230 230
231 mByPosRadio = new QRadioButton( recurOnText, buttonGroup); 231 mByPosRadio = new QRadioButton( recurOnText, buttonGroup);
232 buttonLayout->addWidget( mByPosRadio, 1, 0 ); 232 buttonLayout->addWidget( mByPosRadio, 1, 0 );
233 233
234 mByPosCountCombo = new QComboBox( buttonGroup ); 234 mByPosCountCombo = new QComboBox( buttonGroup );
235 mByPosCountCombo->insertItem( i18n("1st") ); 235 mByPosCountCombo->insertItem( i18n("1st") );
236 mByPosCountCombo->insertItem( i18n("2nd") ); 236 mByPosCountCombo->insertItem( i18n("2nd") );
237 mByPosCountCombo->insertItem( i18n("3rd") ); 237 mByPosCountCombo->insertItem( i18n("3rd") );
238 mByPosCountCombo->insertItem( i18n("4th") ); 238 mByPosCountCombo->insertItem( i18n("4th") );
239 mByPosCountCombo->insertItem( i18n("5th") ); 239 mByPosCountCombo->insertItem( i18n("5th") );
240 buttonLayout->addWidget( mByPosCountCombo, 1, 1 ); 240 buttonLayout->addWidget( mByPosCountCombo, 1, 1 );
241 241
242 mByPosWeekdayCombo = new QComboBox( buttonGroup ); 242 mByPosWeekdayCombo = new QComboBox( buttonGroup );
243 mByPosWeekdayCombo->insertItem( i18n("Monday") ); 243 mByPosWeekdayCombo->insertItem( i18n("Monday") );
244 mByPosWeekdayCombo->insertItem( i18n("Tuesday") ); 244 mByPosWeekdayCombo->insertItem( i18n("Tuesday") );
245 mByPosWeekdayCombo->insertItem( i18n("Wednesday") ); 245 mByPosWeekdayCombo->insertItem( i18n("Wednesday") );
246 mByPosWeekdayCombo->insertItem( i18n("Thursday") ); 246 mByPosWeekdayCombo->insertItem( i18n("Thursday") );
247 mByPosWeekdayCombo->insertItem( i18n("Friday") ); 247 mByPosWeekdayCombo->insertItem( i18n("Friday") );
248 mByPosWeekdayCombo->insertItem( i18n("Saturday") ); 248 mByPosWeekdayCombo->insertItem( i18n("Saturday") );
249 mByPosWeekdayCombo->insertItem( i18n("Sunday") ); 249 mByPosWeekdayCombo->insertItem( i18n("Sunday") );
250 buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 ); 250 buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 );
251} 251}
252 252
253void RecurMonthly::setByDay( int day ) 253void RecurMonthly::setByDay( int day )
254{ 254{
255 mByDayRadio->setChecked( true ); 255 mByDayRadio->setChecked( true );
256 mByDayCombo->setCurrentItem( day ); 256 mByDayCombo->setCurrentItem( day );
257} 257}
258 258
259void RecurMonthly::setByPos( int count, int weekday ) 259void RecurMonthly::setByPos( int count, int weekday )
260{ 260{
261 mByPosRadio->setChecked( true ); 261 mByPosRadio->setChecked( true );
262 mByPosCountCombo->setCurrentItem( count ); 262 mByPosCountCombo->setCurrentItem( count );
263 mByPosWeekdayCombo->setCurrentItem( weekday ); 263 mByPosWeekdayCombo->setCurrentItem( weekday );
264} 264}
265 265
266bool RecurMonthly::byDay() 266bool RecurMonthly::byDay()
267{ 267{
268 return mByDayRadio->isChecked(); 268 return mByDayRadio->isChecked();
269} 269}
270 270
271bool RecurMonthly::byPos() 271bool RecurMonthly::byPos()
272{ 272{
273 return mByPosRadio->isChecked(); 273 return mByPosRadio->isChecked();
274} 274}
275 275
276int RecurMonthly::day() 276int RecurMonthly::day()
277{ 277{
278 return mByDayCombo->currentItem() + 1; 278 return mByDayCombo->currentItem() + 1;
279} 279}
280 280
281int RecurMonthly::count() 281int RecurMonthly::count()
282{ 282{
283 return mByPosCountCombo->currentItem() + 1; 283 return mByPosCountCombo->currentItem() + 1;
284} 284}
285 285
286int RecurMonthly::weekday() 286int RecurMonthly::weekday()
287{ 287{
288 return mByPosWeekdayCombo->currentItem(); 288 return mByPosWeekdayCombo->currentItem();
289} 289}
290 290
291/////////////////////////// RecurYearly /////////////////////////////// 291/////////////////////////// RecurYearly ///////////////////////////////
292 292
293RecurYearly::RecurYearly( QWidget *parent, const char *name ) : 293RecurYearly::RecurYearly( QWidget *parent, const char *name ) :
294 RecurBase( parent, name ) 294 RecurBase( parent, name )
295{ 295{
296 QBoxLayout *topLayout = new QVBoxLayout( this ); 296 QBoxLayout *topLayout = new QVBoxLayout( this );
297 topLayout->setSpacing( KDialog::spacingHint() ); 297 topLayout->setSpacing( KDialog::spacingHint() );
298 topLayout->setMargin( KDialog::marginHintSmall() ); 298 topLayout->setMargin( KDialog::marginHintSmall() );
299 299
300 300
301 QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); 301 QBoxLayout *freqLayout = new QHBoxLayout( topLayout );
302 302
303 QLabel *preLabel = new QLabel( i18n("every"), this ); 303 QLabel *preLabel = new QLabel( i18n("every"), this );
304 freqLayout->addWidget( preLabel ); 304 freqLayout->addWidget( preLabel );
305 305
306 freqLayout->addWidget( frequencyEdit() ); 306 freqLayout->addWidget( frequencyEdit() );
307 307
308 QLabel *postLabel = new QLabel( i18n("year(s)"), this ); 308 QLabel *postLabel = new QLabel( i18n("year(s)"), this );
309 freqLayout->addWidget( postLabel ); 309 freqLayout->addWidget( postLabel );
310 310
311 311
312 QButtonGroup *buttonGroup = new QButtonGroup( this ); 312 QButtonGroup *buttonGroup = new QButtonGroup( this );
313 buttonGroup->setFrameStyle( QFrame::NoFrame ); 313 buttonGroup->setFrameStyle( QFrame::NoFrame );
314 topLayout->addWidget( buttonGroup, 1, AlignVCenter ); 314 topLayout->addWidget( buttonGroup, 1, AlignVCenter );
315 315
316 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 ); 316 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 );
317 317
318 mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup); 318 mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup);
319 buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight); 319 buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight);
320 mByDayLabel = new QLabel( i18n("%1 of ").arg(1), buttonGroup ); 320 mByDayLabel = new QLabel( i18n("%1 of ").arg(1), buttonGroup );
321 321
322 buttonLayout->addWidget( mByDayLabel, 0, 1 ); 322 buttonLayout->addWidget( mByDayLabel, 0, 1 );
323 mByMonthCombo = new QComboBox( buttonGroup ); 323 mByMonthCombo = new QComboBox( buttonGroup );
324 mByMonthCombo->insertItem( i18n("January") ); 324 mByMonthCombo->insertItem( i18n("January") );
325 mByMonthCombo->insertItem( i18n("February") ); 325 mByMonthCombo->insertItem( i18n("February") );
326 mByMonthCombo->insertItem( i18n("March") ); 326 mByMonthCombo->insertItem( i18n("March") );
327 mByMonthCombo->insertItem( i18n("April") ); 327 mByMonthCombo->insertItem( i18n("April") );
328 mByMonthCombo->insertItem( i18n("May") ); 328 mByMonthCombo->insertItem( i18n("May") );
329 mByMonthCombo->insertItem( i18n("June") ); 329 mByMonthCombo->insertItem( i18n("June") );
330 mByMonthCombo->insertItem( i18n("July") ); 330 mByMonthCombo->insertItem( i18n("July") );
331 mByMonthCombo->insertItem( i18n("August") ); 331 mByMonthCombo->insertItem( i18n("August") );
332 mByMonthCombo->insertItem( i18n("September") ); 332 mByMonthCombo->insertItem( i18n("September") );
333 mByMonthCombo->insertItem( i18n("October") ); 333 mByMonthCombo->insertItem( i18n("October") );
334 mByMonthCombo->insertItem( i18n("November") ); 334 mByMonthCombo->insertItem( i18n("November") );
335 mByMonthCombo->insertItem( i18n("December") ); 335 mByMonthCombo->insertItem( i18n("December") );
336 buttonLayout->addWidget( mByMonthCombo, 0, 2,Qt::AlignLeft ); 336 buttonLayout->addWidget( mByMonthCombo, 0, 2,Qt::AlignLeft );
337 if ( QApplication::desktop()->width() <= 640 ) { 337 if ( QApplication::desktop()->width() <= 640 ) {
338 mByMonthCombo->setSizeLimit( 6 ); 338 mByMonthCombo->setSizeLimit( 6 );
339 } 339 }
340 340
341 mByDayRadio = new QRadioButton( i18n("On day "), buttonGroup); 341 mByDayRadio = new QRadioButton( i18n("On day "), buttonGroup);
342 buttonLayout->addWidget( mByDayRadio, 1, 0 , Qt::AlignRight); 342 buttonLayout->addWidget( mByDayRadio, 1, 0 , Qt::AlignRight);
343 mDayOfLabel = new QLabel( i18n("%1 of the year").arg(1), buttonGroup ); 343 mDayOfLabel = new QLabel( i18n("%1 of the year").arg(1), buttonGroup );
344 buttonLayout->addMultiCellWidget( mDayOfLabel, 1, 1, 1,3 ); 344 buttonLayout->addMultiCellWidget( mDayOfLabel, 1, 1, 1,3 );
345 345
346} 346}
347 347
348void RecurYearly::setByDay( int doy ) 348void RecurYearly::setByDay( int doy )
349{ 349{
350 mByDayRadio->setChecked( true ); 350 mByDayRadio->setChecked( true );
351 mDayOfLabel->setText(i18n("%1 of the year").arg( doy ) ); 351 mDayOfLabel->setText(i18n("%1 of the year").arg( doy ) );
352} 352}
353 353
354void RecurYearly::setByMonth( int month, int day ) 354void RecurYearly::setByMonth( int month, int day )
355{ 355{
356 mByMonthRadio->setChecked( true ); 356 mByMonthRadio->setChecked( true );
357 mByMonthCombo->setCurrentItem( month - 1 ); 357 mByMonthCombo->setCurrentItem( month - 1 );
358 mByDayLabel->setText(i18n("%1 of ").arg( day ) ); 358 mByDayLabel->setText(i18n("%1 of ").arg( day ) );
359 mDay = day; 359 mDay = day;
360} 360}
361 361
362bool RecurYearly::byMonth() 362bool RecurYearly::byMonth()
363{ 363{
364 return mByMonthRadio->isChecked(); 364 return mByMonthRadio->isChecked();
365} 365}
366 366
367bool RecurYearly::byDay() 367bool RecurYearly::byDay()
368{ 368{
369 return mByDayRadio->isChecked(); 369 return mByDayRadio->isChecked();
370} 370}
371 371
372int RecurYearly::month() 372int RecurYearly::month()
373{ 373{
374 return mByMonthCombo->currentItem() + 1; 374 return mByMonthCombo->currentItem() + 1;
375} 375}
376int RecurYearly::day() 376int RecurYearly::day()
377{ 377{
378 return mDay;//mByDayCombo->currentItem() + 1; 378 return mDay;//mByDayCombo->currentItem() + 1;
379} 379}
380 380
381//////////////////////////// ExceptionsWidget ////////////////////////// 381//////////////////////////// ExceptionsWidget //////////////////////////
382 382
383ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : 383ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) :
384 QWidget( parent, name ) 384 QWidget( parent, name )
385{ 385{
386 QBoxLayout *topLayout = new QVBoxLayout( this ); 386 QBoxLayout *topLayout = new QVBoxLayout( this );
387 387
388 QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"), 388 QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"),
389 this ); 389 this );
390 topLayout->addWidget( groupBox ); 390 topLayout->addWidget( groupBox );
391 391
392 QWidget *box = new QWidget( groupBox ); 392 QWidget *box = new QWidget( groupBox );
393 393
394 QGridLayout *boxLayout = new QGridLayout( box ); 394 QGridLayout *boxLayout = new QGridLayout( box );
395 395
396 mExceptionDateEdit = new KDateEdit( box ); 396 mExceptionDateEdit = new KDateEdit( box );
397 boxLayout->addWidget( mExceptionDateEdit, 0, 0 ); 397 boxLayout->addWidget( mExceptionDateEdit, 0, 0 );
398 398
399 QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box ); 399 QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box );
400 boxLayout->addWidget( addExceptionButton, 1, 0 ); 400 boxLayout->addWidget( addExceptionButton, 1, 0 );
401 QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box ); 401 QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box );
402 boxLayout->addWidget( changeExceptionButton, 2, 0 ); 402 boxLayout->addWidget( changeExceptionButton, 2, 0 );
403 QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box ); 403 QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box );
404 boxLayout->addWidget( deleteExceptionButton, 3, 0 ); 404 boxLayout->addWidget( deleteExceptionButton, 3, 0 );
405 405
406 mExceptionList = new QListBox( box ); 406 mExceptionList = new QListBox( box );
407 boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 ); 407 boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 );
408 408
409 boxLayout->setRowStretch( 4, 1 ); 409 boxLayout->setRowStretch( 4, 1 );
410 boxLayout->setColStretch( 1, 3 ); 410 boxLayout->setColStretch( 1, 3 );
411 411
412 connect( addExceptionButton, SIGNAL( clicked() ), 412 connect( addExceptionButton, SIGNAL( clicked() ),
413 SLOT( addException() ) ); 413 SLOT( addException() ) );
414 connect( changeExceptionButton, SIGNAL( clicked() ), 414 connect( changeExceptionButton, SIGNAL( clicked() ),
415 SLOT( changeException() ) ); 415 SLOT( changeException() ) );
416 connect( deleteExceptionButton, SIGNAL( clicked() ), 416 connect( deleteExceptionButton, SIGNAL( clicked() ),
417 SLOT( deleteException() ) ); 417 SLOT( deleteException() ) );
418 if ( QApplication::desktop()->width() < 480 ) { 418 if ( QApplication::desktop()->width() < 480 ) {
419 setMinimumWidth( 220 ); 419 setMinimumWidth( 220 );
420 } else { 420 } else {
421 setMinimumWidth( 440 ); 421 setMinimumWidth( 440 );
422 mExceptionDateEdit->setMinimumWidth( 200 ); 422 mExceptionDateEdit->setMinimumWidth( 200 );
423 } 423 }
424} 424}
425 425
426void ExceptionsWidget::setDefaults( const QDateTime &from ) 426void ExceptionsWidget::setDefaults( const QDateTime &from )
427{ 427{
428 mExceptionDateEdit->setDate( from.date() ); 428 mExceptionDateEdit->setDate( from.date() );
429} 429}
430 430
431void ExceptionsWidget::addException() 431void ExceptionsWidget::addException()
432{ 432{
433 QDate date = mExceptionDateEdit->date(); 433 QDate date = mExceptionDateEdit->date();
434 QString dateStr = KGlobal::locale()->formatDate( date ); 434 QString dateStr = KGlobal::locale()->formatDate( date );
435 if( !mExceptionList->findItem( dateStr ) ) { 435 if( !mExceptionList->findItem( dateStr ) ) {
436 mExceptionDates.append( date ); 436 mExceptionDates.append( date );
437 mExceptionList->insertItem( dateStr ); 437 mExceptionList->insertItem( dateStr );
438 } 438 }
439} 439}
440 440
441void ExceptionsWidget::changeException() 441void ExceptionsWidget::changeException()
442{ 442{
443 int pos = mExceptionList->currentItem(); 443 int pos = mExceptionList->currentItem();
444 if ( pos < 0 ) return; 444 if ( pos < 0 ) return;
445 445
446 QDate date = mExceptionDateEdit->date(); 446 QDate date = mExceptionDateEdit->date();
447 mExceptionDates[ pos ] = date; 447 mExceptionDates[ pos ] = date;
448 mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos ); 448 mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos );
449} 449}
450 450
451void ExceptionsWidget::deleteException() 451void ExceptionsWidget::deleteException()
452{ 452{
453 int pos = mExceptionList->currentItem(); 453 int pos = mExceptionList->currentItem();
454 if ( pos < 0 ) return; 454 if ( pos < 0 ) return;
455 455
456 mExceptionDates.remove( mExceptionDates.at( pos ) ); 456 mExceptionDates.remove( mExceptionDates.at( pos ) );
457 mExceptionList->removeItem( pos ); 457 mExceptionList->removeItem( pos );
458} 458}
459 459
460void ExceptionsWidget::setDates( const DateList &dates ) 460void ExceptionsWidget::setDates( const DateList &dates )
461{ 461{
462 mExceptionList->clear(); 462 mExceptionList->clear();
463 mExceptionDates.clear(); 463 mExceptionDates.clear();
464 DateList::ConstIterator dit; 464 DateList::ConstIterator dit;
465 for ( dit = dates.begin(); dit != dates.end(); ++dit ) { 465 for ( dit = dates.begin(); dit != dates.end(); ++dit ) {
466 mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) ); 466 mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) );
467 mExceptionDates.append( *dit ); 467 mExceptionDates.append( *dit );
468 } 468 }
469} 469}
470 470
471DateList ExceptionsWidget::dates() 471DateList ExceptionsWidget::dates()
472{ 472{
473 return mExceptionDates; 473 return mExceptionDates;
474} 474}
475 475
476///////////////////////// ExceptionsDialog /////////////////////////// 476///////////////////////// ExceptionsDialog ///////////////////////////
477 477
478ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : 478ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) :
479 KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel ) 479 KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel )
480{ 480{
481 mExceptions = new ExceptionsWidget( this ); 481 mExceptions = new ExceptionsWidget( this );
482 setMainWidget( mExceptions ); 482 setMainWidget( mExceptions );
483 resize(220,10); 483 resize(220,10);
484} 484}
485 485
486void ExceptionsDialog::setDefaults( const QDateTime &from ) 486void ExceptionsDialog::setDefaults( const QDateTime &from )
487{ 487{
488 mExceptions->setDefaults( from ); 488 mExceptions->setDefaults( from );
489} 489}
490 490
491void ExceptionsDialog::setDates( const DateList &dates ) 491void ExceptionsDialog::setDates( const DateList &dates )
492{ 492{
493 mExceptions->setDates( dates ); 493 mExceptions->setDates( dates );
494} 494}
495 495
496DateList ExceptionsDialog::dates() 496DateList ExceptionsDialog::dates()
497{ 497{
498 return mExceptions->dates(); 498 return mExceptions->dates();
499} 499}
500 500
501///////////////////////// RecurrenceRangeWidget /////////////////////////// 501///////////////////////// RecurrenceRangeWidget ///////////////////////////
502 502
503RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, 503RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent,
504 const char *name ) 504 const char *name )
505 : QWidget( parent, name ) 505 : QWidget( parent, name )
506{ 506{
507 QBoxLayout *topLayout = new QVBoxLayout( this ); 507 QBoxLayout *topLayout = new QVBoxLayout( this );
508 508
509 mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"), 509 mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"),
510 this ); 510 this );
511 topLayout->addWidget( mRangeGroupBox ); 511 topLayout->addWidget( mRangeGroupBox );
512 512
513 QWidget *rangeBox = new QWidget( mRangeGroupBox ); 513 QWidget *rangeBox = new QWidget( mRangeGroupBox );
514 QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox ); 514 QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox );
515 rangeLayout->setSpacing( KDialog::spacingHint() ); 515 rangeLayout->setSpacing( KDialog::spacingHint() );
516 rangeLayout->setMargin( KDialog::marginHintSmall() ); 516 rangeLayout->setMargin( KDialog::marginHintSmall() );
517 517
518 mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); 518 mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox );
519 rangeLayout->addWidget( mStartDateLabel ); 519 rangeLayout->addWidget( mStartDateLabel );
520 520
521 QButtonGroup *rangeButtonGroup = new QButtonGroup; 521 mRangeButtonGroup = new QButtonGroup;
522 522
523 mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); 523 mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox );
524 rangeButtonGroup->insert( mNoEndDateButton ); 524 mRangeButtonGroup->insert( mNoEndDateButton );
525 rangeLayout->addWidget( mNoEndDateButton ); 525 rangeLayout->addWidget( mNoEndDateButton );
526 526
527 QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); 527 QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout );
528 durationLayout->setSpacing( KDialog::spacingHint() ); 528 durationLayout->setSpacing( KDialog::spacingHint() );
529 529
530 mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); 530 mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox );
531 rangeButtonGroup->insert( mEndDurationButton ); 531 mRangeButtonGroup->insert( mEndDurationButton );
532 durationLayout->addWidget( mEndDurationButton ); 532 durationLayout->addWidget( mEndDurationButton );
533 533
534 mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); 534 mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox );
535 durationLayout->addWidget( mEndDurationEdit ); 535 durationLayout->addWidget( mEndDurationEdit );
536 536
537 QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); 537 QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox );
538 durationLayout ->addWidget( endDurationLabel ); 538 durationLayout ->addWidget( endDurationLabel );
539 539
540 QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); 540 QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout );
541 endDateLayout->setSpacing( KDialog::spacingHint() ); 541 endDateLayout->setSpacing( KDialog::spacingHint() );
542 542
543 mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); 543 mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox );
544 rangeButtonGroup->insert( mEndDateButton ); 544 mRangeButtonGroup->insert( mEndDateButton );
545 endDateLayout->addWidget( mEndDateButton ); 545 endDateLayout->addWidget( mEndDateButton );
546 546
547 mEndDateEdit = new KDateEdit( rangeBox ); 547 mEndDateEdit = new KDateEdit( rangeBox );
548 endDateLayout->addWidget( mEndDateEdit ); 548 endDateLayout->addWidget( mEndDateEdit );
549 549
550 //endDateLayout->addStretch( 1 ); 550 //endDateLayout->addStretch( 1 );
551 551
552 connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), 552 connect( mNoEndDateButton, SIGNAL( toggled( bool ) ),
553 SLOT( showCurrentRange() ) ); 553 SLOT( showCurrentRange() ) );
554 connect( mEndDurationButton, SIGNAL( toggled( bool ) ), 554 connect( mEndDurationButton, SIGNAL( toggled( bool ) ),
555 SLOT( showCurrentRange() ) ); 555 SLOT( showCurrentRange() ) );
556 connect( mEndDateButton, SIGNAL( toggled( bool ) ), 556 connect( mEndDateButton, SIGNAL( toggled( bool ) ),
557 SLOT( showCurrentRange() ) ); 557 SLOT( showCurrentRange() ) );
558} 558}
559 559
560RecurrenceRangeWidget::~RecurrenceRangeWidget()
561{
562 delete mRangeButtonGroup;
563}
560void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) 564void RecurrenceRangeWidget::setDefaults( const QDateTime &from )
561{ 565{
562 mNoEndDateButton->setChecked( true ); 566 mNoEndDateButton->setChecked( true );
563 567
564 setDateTimes( from ); 568 setDateTimes( from );
565 mEndDateEdit->setDate( from.date() ); 569 mEndDateEdit->setDate( from.date() );
566} 570}
567 571
568void RecurrenceRangeWidget::setDuration( int duration ) 572void RecurrenceRangeWidget::setDuration( int duration )
569{ 573{
570 if ( duration == -1 ) { 574 if ( duration == -1 ) {
571 mNoEndDateButton->setChecked( true ); 575 mNoEndDateButton->setChecked( true );
572 } else if ( duration == 0 ) { 576 } else if ( duration == 0 ) {
573 mEndDateButton->setChecked( true ); 577 mEndDateButton->setChecked( true );
574 } else { 578 } else {
575 mEndDurationButton->setChecked( true ); 579 mEndDurationButton->setChecked( true );
576 mEndDurationEdit->setValue( duration ); 580 mEndDurationEdit->setValue( duration );
577 } 581 }
578} 582}
579 583
580int RecurrenceRangeWidget::duration() 584int RecurrenceRangeWidget::duration()
581{ 585{
582 if ( mNoEndDateButton->isChecked() ) { 586 if ( mNoEndDateButton->isChecked() ) {
583 return -1; 587 return -1;
584 } else if ( mEndDurationButton->isChecked() ) { 588 } else if ( mEndDurationButton->isChecked() ) {
585 return mEndDurationEdit->value(); 589 return mEndDurationEdit->value();
586 } else { 590 } else {
587 return 0; 591 return 0;
588 } 592 }
589} 593}
590 594
591void RecurrenceRangeWidget::setEndDate( const QDate &date ) 595void RecurrenceRangeWidget::setEndDate( const QDate &date )
592{ 596{
593 mEndDateEdit->setDate( date ); 597 mEndDateEdit->setDate( date );
594} 598}
595 599
596QDate RecurrenceRangeWidget::endDate() 600QDate RecurrenceRangeWidget::endDate()
597{ 601{
598 return mEndDateEdit->date(); 602 return mEndDateEdit->date();
599} 603}
600 604
601void RecurrenceRangeWidget::showCurrentRange() 605void RecurrenceRangeWidget::showCurrentRange()
602{ 606{
603 mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); 607 mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() );
604 mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); 608 mEndDateEdit->setEnabled( mEndDateButton->isChecked() );
605} 609}
606 610
607void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, 611void RecurrenceRangeWidget::setDateTimes( const QDateTime &start,
608 const QDateTime & ) 612 const QDateTime & )
609{ 613{
610 mStartDateLabel->setText( i18n("Start date: %1") 614 mStartDateLabel->setText( i18n("Start date: %1")
611 .arg( KGlobal::locale()->formatDate( start.date() ) ) ); 615 .arg( KGlobal::locale()->formatDate( start.date() ) ) );
612 616
613 if(!mEndDateButton->isChecked()) 617 if(!mEndDateButton->isChecked())
614 mEndDateEdit->setDate( start.date() ); 618 mEndDateEdit->setDate( start.date() );
615} 619}
616 620
617///////////////////////// RecurrenceRangeDialog /////////////////////////// 621///////////////////////// RecurrenceRangeDialog ///////////////////////////
618 622
619RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, 623RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent,
620 const char *name ) : 624 const char *name ) :
621 KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) 625 KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel )
622{ 626{
623 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); 627 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this );
624 setMainWidget( mRecurrenceRangeWidget ); 628 setMainWidget( mRecurrenceRangeWidget );
625} 629}
626 630
627void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) 631void RecurrenceRangeDialog::setDefaults( const QDateTime &from )
628{ 632{
629 mRecurrenceRangeWidget->setDefaults( from ); 633 mRecurrenceRangeWidget->setDefaults( from );
630} 634}
631 635
632void RecurrenceRangeDialog::setDuration( int duration ) 636void RecurrenceRangeDialog::setDuration( int duration )
633{ 637{
634 mRecurrenceRangeWidget->setDuration( duration ); 638 mRecurrenceRangeWidget->setDuration( duration );
635} 639}
636 640
637int RecurrenceRangeDialog::duration() 641int RecurrenceRangeDialog::duration()
638{ 642{
639 return mRecurrenceRangeWidget->duration(); 643 return mRecurrenceRangeWidget->duration();
640} 644}
641 645
642void RecurrenceRangeDialog::setEndDate( const QDate &date ) 646void RecurrenceRangeDialog::setEndDate( const QDate &date )
643{ 647{
644 mRecurrenceRangeWidget->setEndDate( date ); 648 mRecurrenceRangeWidget->setEndDate( date );
645} 649}
646 650
647QDate RecurrenceRangeDialog::endDate() 651QDate RecurrenceRangeDialog::endDate()
648{ 652{
649 return mRecurrenceRangeWidget->endDate(); 653 return mRecurrenceRangeWidget->endDate();
650} 654}
651 655
652void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, 656void RecurrenceRangeDialog::setDateTimes( const QDateTime &start,
653 const QDateTime &end ) 657 const QDateTime &end )
654{ 658{
655 mRecurrenceRangeWidget->setDateTimes( start, end ); 659 mRecurrenceRangeWidget->setDateTimes( start, end );
656} 660}
657 661
658//////////////////////////// RecurrenceChooser //////////////////////// 662//////////////////////////// RecurrenceChooser ////////////////////////
659 663
660RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : 664RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) :
661 QWidget( parent, name ) 665 QWidget( parent, name )
662{ 666{
663 QBoxLayout *topLayout = new QVBoxLayout( this ); 667 QBoxLayout *topLayout = new QVBoxLayout( this );
664 668
665 mTypeCombo = new QComboBox( this ); 669 mTypeCombo = new QComboBox( this );
666 mTypeCombo->insertItem( i18n("Daily") ); 670 mTypeCombo->insertItem( i18n("Daily") );
667 mTypeCombo->insertItem( i18n("Weekly") ); 671 mTypeCombo->insertItem( i18n("Weekly") );
668 mTypeCombo->insertItem( i18n("Monthly") ); 672 mTypeCombo->insertItem( i18n("Monthly") );
669 mTypeCombo->insertItem( i18n("Yearly") ); 673 mTypeCombo->insertItem( i18n("Yearly") );
670 674
671 topLayout->addWidget( mTypeCombo ); 675 topLayout->addWidget( mTypeCombo );
672 676
673 connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); 677 connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) );
674 678
675} 679}
676 680
677int RecurrenceChooser::type() 681int RecurrenceChooser::type()
678{ 682{
679 if ( mTypeCombo ) { 683 if ( mTypeCombo ) {
680 return mTypeCombo->currentItem(); 684 return mTypeCombo->currentItem();
681 } else { 685 } else {
682 if ( mDailyButton->isChecked() ) return Daily; 686 if ( mDailyButton->isChecked() ) return Daily;
683 else if ( mWeeklyButton->isChecked() ) return Weekly; 687 else if ( mWeeklyButton->isChecked() ) return Weekly;
684 else if ( mMonthlyButton->isChecked() ) return Monthly; 688 else if ( mMonthlyButton->isChecked() ) return Monthly;
685 else return Yearly; 689 else return Yearly;
686 } 690 }
687} 691}
688 692
689void RecurrenceChooser::setType( int type ) 693void RecurrenceChooser::setType( int type )
690{ 694{
691 if ( mTypeCombo ) { 695 if ( mTypeCombo ) {
692 mTypeCombo->setCurrentItem( type ); 696 mTypeCombo->setCurrentItem( type );
693 } else { 697 } else {
694 switch ( type ) { 698 switch ( type ) {
695 case Daily: 699 case Daily:
696 mDailyButton->setChecked( true ); 700 mDailyButton->setChecked( true );
697 break; 701 break;
698 case Weekly: 702 case Weekly:
699 mWeeklyButton->setChecked( true ); 703 mWeeklyButton->setChecked( true );
700 break; 704 break;
701 case Monthly: 705 case Monthly:
702 mMonthlyButton->setChecked( true ); 706 mMonthlyButton->setChecked( true );
703 break; 707 break;
704 case Yearly: 708 case Yearly:
705 default: 709 default:
706 mYearlyButton->setChecked( true ); 710 mYearlyButton->setChecked( true );
707 break; 711 break;
708 } 712 }
709 } 713 }
710} 714}
711 715
712void RecurrenceChooser::emitChoice() 716void RecurrenceChooser::emitChoice()
713{ 717{
714 emit chosen ( type() ); 718 emit chosen ( type() );
715} 719}
716 720
717/////////////////////////////// Main Widget ///////////////////////////// 721/////////////////////////////// Main Widget /////////////////////////////
718 722
719KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : 723KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) :
720 QWidget( parent, name ) 724 QWidget( parent, name )
721{ 725{
722 QGridLayout *topLayout = new QGridLayout( this, 2,2 ); 726 QGridLayout *topLayout = new QGridLayout( this, 2,2 );
723 topLayout->setSpacing( KDialog::spacingHint() ); 727 topLayout->setSpacing( KDialog::spacingHint() );
724 topLayout->setMargin( KDialog::marginHintSmall() ); 728 topLayout->setMargin( KDialog::marginHintSmall() );
725 729
726 mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); 730 mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this );
727 connect( mEnabledCheck, SIGNAL( toggled( bool ) ), 731 connect( mEnabledCheck, SIGNAL( toggled( bool ) ),
728 SLOT( setEnabled( bool ) ) ); 732 SLOT( setEnabled( bool ) ) );
729 topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); 733 topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 );
730 734
731 735
732 mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), 736 mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"),
733 this ); 737 this );
734 topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); 738 topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 );
735 739
736 if ( QApplication::desktop()->width() <= 640 ) { 740 if ( QApplication::desktop()->width() <= 640 ) {
737 mTimeGroupBox->hide(); 741 mTimeGroupBox->hide();
738 } 742 }
739 743
740// QFrame *timeFrame = new QFrame( mTimeGroupBox ); 744// QFrame *timeFrame = new QFrame( mTimeGroupBox );
741// QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); 745// QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame );
742// layoutTimeFrame->setSpacing( KDialog::spacingHint() ); 746// layoutTimeFrame->setSpacing( KDialog::spacingHint() );
743 747
744 mDateTimeLabel = new QLabel( mTimeGroupBox ); 748 mDateTimeLabel = new QLabel( mTimeGroupBox );
745// mDateTimeLabel = new QLabel( timeFrame ); 749// mDateTimeLabel = new QLabel( timeFrame );
746// layoutTimeFrame->addWidget( mDateTimeLabel ); 750// layoutTimeFrame->addWidget( mDateTimeLabel );
747 //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); 751 //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) );
748 //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); 752 //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) );
749 mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); 753 mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this );
750 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); 754 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 );
751 mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); 755 mRecurrenceChooser = new RecurrenceChooser( mRuleBox );
752 connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), 756 connect( mRecurrenceChooser, SIGNAL( chosen( int ) ),
753 SLOT( showCurrentRule( int ) ) ); 757 SLOT( showCurrentRule( int ) ) );
754 758
755 759
756 mRuleStack = new QWidgetStack( mRuleBox ); 760 mRuleStack = new QWidgetStack( mRuleBox );
757 761
758 mDaily = new RecurDaily( mRuleStack ); 762 mDaily = new RecurDaily( mRuleStack );
759 mRuleStack->addWidget( mDaily, 0 ); 763 mRuleStack->addWidget( mDaily, 0 );
760 764
761 mWeekly = new RecurWeekly( mRuleStack ); 765 mWeekly = new RecurWeekly( mRuleStack );
762 mRuleStack->addWidget( mWeekly, 0 ); 766 mRuleStack->addWidget( mWeekly, 0 );
763 767
764 mMonthly = new RecurMonthly( mRuleStack ); 768 mMonthly = new RecurMonthly( mRuleStack );
765 mRuleStack->addWidget( mMonthly, 0 ); 769 mRuleStack->addWidget( mMonthly, 0 );
766 770
767 mYearly = new RecurYearly( mRuleStack ); 771 mYearly = new RecurYearly( mRuleStack );
768 mRuleStack->addWidget( mYearly, 0 ); 772 mRuleStack->addWidget( mYearly, 0 );
769 773
770 showCurrentRule( mRecurrenceChooser->type() ); 774 showCurrentRule( mRecurrenceChooser->type() );
771 mRecurrenceRangeWidget = 0; 775 mRecurrenceRangeWidget = 0;
772 mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); 776 mRecurrenceRangeDialog = new RecurrenceRangeDialog( this );
773 mRecurrenceRange = mRecurrenceRangeDialog; 777 mRecurrenceRange = mRecurrenceRangeDialog;
774 mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), 778 mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."),
775 this ); 779 this );
776 780
777 connect( mRecurrenceRangeButton, SIGNAL( clicked() ), 781 connect( mRecurrenceRangeButton, SIGNAL( clicked() ),
778 SLOT( showRecurrenceRangeDialog() ) ); 782 SLOT( showRecurrenceRangeDialog() ) );
779 783
780 mExceptionsWidget = 0; 784 mExceptionsWidget = 0;
781 mExceptionsDialog = new ExceptionsDialog( this ); 785 mExceptionsDialog = new ExceptionsDialog( this );
782 mExceptions = mExceptionsDialog; 786 mExceptions = mExceptionsDialog;
783 mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); 787 mExceptionsButton = new QPushButton( i18n("Exceptions..."), this );
784 if ( QApplication::desktop()->width() < 320 ) { 788 if ( QApplication::desktop()->width() < 320 ) {
785 topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); 789 topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 );
786 topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); 790 topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 );
787 } else { 791 } else {
788 topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); 792 topLayout->addWidget( mRecurrenceRangeButton, 3, 0 );
789 topLayout->addWidget( mExceptionsButton, 3, 1 ); 793 topLayout->addWidget( mExceptionsButton, 3, 1 );
790 } 794 }
791 connect( mExceptionsButton, SIGNAL( clicked() ), 795 connect( mExceptionsButton, SIGNAL( clicked() ),
792 SLOT( showExceptionsDialog() ) ); 796 SLOT( showExceptionsDialog() ) );
793} 797}
794 798
795KOEditorRecurrence::~KOEditorRecurrence() 799KOEditorRecurrence::~KOEditorRecurrence()
796{ 800{
797} 801}
798 802
799void KOEditorRecurrence::setEnabled( bool enabled ) 803void KOEditorRecurrence::setEnabled( bool enabled )
800{ 804{
801// kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; 805// kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl;
802 806
803 mTimeGroupBox->setEnabled( enabled ); 807 mTimeGroupBox->setEnabled( enabled );
804 if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); 808 if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled );
805 if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); 809 if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled );
806 if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); 810 if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled );
807 if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); 811 if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled );
808 mRuleBox->setEnabled( enabled ); 812 mRuleBox->setEnabled( enabled );
809} 813}
810 814
811void KOEditorRecurrence::showCurrentRule( int current ) 815void KOEditorRecurrence::showCurrentRule( int current )
812{ 816{
813 switch ( current ) { 817 switch ( current ) {
814 case Daily: 818 case Daily:
815 mRuleStack->raiseWidget( mDaily ); 819 mRuleStack->raiseWidget( mDaily );
816 break; 820 break;
817 case Weekly: 821 case Weekly:
818 mRuleStack->raiseWidget( mWeekly ); 822 mRuleStack->raiseWidget( mWeekly );
819 break; 823 break;
820 case Monthly: 824 case Monthly:
821 mRuleStack->raiseWidget( mMonthly ); 825 mRuleStack->raiseWidget( mMonthly );
822 break; 826 break;
823 default: 827 default:
824 case Yearly: 828 case Yearly:
825 mRuleStack->raiseWidget( mYearly ); 829 mRuleStack->raiseWidget( mYearly );
826 break; 830 break;
827 } 831 }
828} 832}
829 833
830void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) 834void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end )
831{ 835{
832// kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; 836// kdDebug() << "KOEditorRecurrence::setDateTimes" << endl;
833 837
834 mRecurrenceRange->setDateTimes( start, end ); 838 mRecurrenceRange->setDateTimes( start, end );
835 mExceptions->setDefaults( end ); 839 mExceptions->setDefaults( end );
836 840
837} 841}
838void KOEditorRecurrence::setDefaultsDates( QDateTime from, QDateTime to ) 842void KOEditorRecurrence::setDefaultsDates( QDateTime from, QDateTime to )
839{ 843{
840 setDateTimes( from, to ); 844 setDateTimes( from, to );
841 QBitArray days( 7 ); 845 QBitArray days( 7 );
842 days.fill( 0 ); 846 days.fill( 0 );
843 days.setBit( from.date().dayOfWeek()- 1); 847 days.setBit( from.date().dayOfWeek()- 1);
844 mWeekly->setDays( days ); 848 mWeekly->setDays( days );
845 bool byPos = mMonthly->byPos(); 849 bool byPos = mMonthly->byPos();
846 if ( byPos ) 850 if ( byPos )
847 mMonthly->setByDay( from.date().day()-1 ); 851 mMonthly->setByDay( from.date().day()-1 );
848 mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); 852 mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 );
849 if ( ! byPos) 853 if ( ! byPos)
850 mMonthly->setByDay( from.date().day()-1 ); 854 mMonthly->setByDay( from.date().day()-1 );
851 855
852 bool byDay = mYearly->byDay(); 856 bool byDay = mYearly->byDay();
853 if ( ! byDay ) 857 if ( ! byDay )
854 mYearly->setByDay( from.date().dayOfYear() ); 858 mYearly->setByDay( from.date().dayOfYear() );
855 mYearly->setByMonth( from.date().month(), from.date().day() ); 859 mYearly->setByMonth( from.date().month(), from.date().day() );
856 if ( byDay ) 860 if ( byDay )
857 mYearly->setByDay( from.date().dayOfYear() ); 861 mYearly->setByDay( from.date().dayOfYear() );
858} 862}
859void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to ) 863void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to )
860{ 864{
861 865
862 // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); 866 // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() );
863 //setDateTimes( from, to ); 867 //setDateTimes( from, to );
864 868
865 bool enabled = false; 869 bool enabled = false;
866 mEnabledCheck->setChecked( enabled ); 870 mEnabledCheck->setChecked( enabled );
867 setEnabled( enabled ); 871 setEnabled( enabled );
868 872
869 mExceptions->setDefaults( to ); 873 mExceptions->setDefaults( to );
870 mRecurrenceRange->setDefaults( to ); 874 mRecurrenceRange->setDefaults( to );
871 875
872 mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); 876 mRecurrenceChooser->setType( RecurrenceChooser::Weekly );
873 showCurrentRule( mRecurrenceChooser->type() ); 877 showCurrentRule( mRecurrenceChooser->type() );
874 878
875 mDaily->setFrequency( 1 ); 879 mDaily->setFrequency( 1 );
876 mWeekly->setFrequency( 1 ); 880 mWeekly->setFrequency( 1 );
877 mMonthly->setFrequency( 1 ); 881 mMonthly->setFrequency( 1 );
878 mYearly->setFrequency( 1 ); 882 mYearly->setFrequency( 1 );
879 setDefaultsDates( from, to ); 883 setDefaultsDates( from, to );
880} 884}
881 885
882void KOEditorRecurrence::readEvent(Incidence *event) 886void KOEditorRecurrence::readEvent(Incidence *event)
883{ 887{
884 888
885 QDateTime dtEnd; 889 QDateTime dtEnd;
886 if ( event->typeID() == eventID ) 890 if ( event->typeID() == eventID )
887 dtEnd = ((Event*)event)->dtEnd(); 891 dtEnd = ((Event*)event)->dtEnd();
888 else 892 else
889 dtEnd = ((Todo*)event)->dtDue(); 893 dtEnd = ((Todo*)event)->dtDue();
890 894
891 setDefaults( event->dtStart(), dtEnd ); 895 setDefaults( event->dtStart(), dtEnd );
892 QBitArray rDays( 7 ); 896 QBitArray rDays( 7 );
893 QPtrList<Recurrence::rMonthPos> rmp; 897 QPtrList<Recurrence::rMonthPos> rmp;
894 QPtrList<int> rmd; 898 QPtrList<int> rmd;
895 int day = 0; 899 int day = 0;
896 int count = 0; 900 int count = 0;
897 int month = 0; 901 int month = 0;
898 setDateTimes( event->dtStart(), dtEnd ); 902 setDateTimes( event->dtStart(), dtEnd );
899 903
900 904
901 905
902 int recurs = event->doesRecur(); 906 int recurs = event->doesRecur();
903 907
904 mEnabledCheck->setChecked( recurs ); 908 mEnabledCheck->setChecked( recurs );
905 setEnabled( recurs ); 909 setEnabled( recurs );
906 910
907 int recurrenceType = RecurrenceChooser::Weekly; 911 int recurrenceType = RecurrenceChooser::Weekly;
908 if ( recurs ) { 912 if ( recurs ) {
909 Recurrence *r = event->recurrence(); 913 Recurrence *r = event->recurrence();
910 int f = r->frequency(); 914 int f = r->frequency();
911 switch ( recurs ) { 915 switch ( recurs ) {
912 case Recurrence::rNone: 916 case Recurrence::rNone:
913 setDefaults( event->dtStart(), dtEnd ); 917 setDefaults( event->dtStart(), dtEnd );
914 break; 918 break;
915 case Recurrence::rDaily: 919 case Recurrence::rDaily:
916 recurrenceType = RecurrenceChooser::Daily; 920 recurrenceType = RecurrenceChooser::Daily;
917 mDaily->setFrequency( f ); 921 mDaily->setFrequency( f );
918 break; 922 break;
919 case Recurrence::rWeekly: 923 case Recurrence::rWeekly:
920 recurrenceType = RecurrenceChooser::Weekly; 924 recurrenceType = RecurrenceChooser::Weekly;
921 mWeekly->setFrequency( f ); 925 mWeekly->setFrequency( f );
922 mWeekly->setDays( r->days() ); 926 mWeekly->setDays( r->days() );
923 break; 927 break;
924 case Recurrence::rMonthlyPos: 928 case Recurrence::rMonthlyPos:
925 // we only handle one possibility in the list right now, 929 // we only handle one possibility in the list right now,
926 // so I have hardcoded calls with first(). If we make the GUI 930 // so I have hardcoded calls with first(). If we make the GUI
927 // more extended, this can be changed. 931 // more extended, this can be changed.
928 recurrenceType = RecurrenceChooser::Monthly; 932 recurrenceType = RecurrenceChooser::Monthly;
929 933
930 rmp = r->monthPositions(); 934 rmp = r->monthPositions();
931 if ( rmp.first()->negative ) 935 if ( rmp.first()->negative )
932 count = 5 - rmp.first()->rPos - 1; 936 count = 5 - rmp.first()->rPos - 1;
933 else 937 else
934 count = rmp.first()->rPos - 1; 938 count = rmp.first()->rPos - 1;
935 day = 0; 939 day = 0;
936 while ( !rmp.first()->rDays.testBit( day ) ) ++day; 940 while ( !rmp.first()->rDays.testBit( day ) ) ++day;
937 mMonthly->setByPos( count, day ); 941 mMonthly->setByPos( count, day );
938 942
939 mMonthly->setFrequency( f ); 943 mMonthly->setFrequency( f );
940 944
941 break; 945 break;
942 case Recurrence::rMonthlyDay: 946 case Recurrence::rMonthlyDay:
943 recurrenceType = RecurrenceChooser::Monthly; 947 recurrenceType = RecurrenceChooser::Monthly;
944 948
945 rmd = r->monthDays(); 949 rmd = r->monthDays();
946 day = *rmd.first() - 1; 950 day = *rmd.first() - 1;
947 mMonthly->setByDay( day ); 951 mMonthly->setByDay( day );
948 952
949 mMonthly->setFrequency( f ); 953 mMonthly->setFrequency( f );
950 954
951 break; 955 break;
952 case Recurrence::rYearlyMonth: 956 case Recurrence::rYearlyMonth:
953 { 957 {
954 recurrenceType = RecurrenceChooser::Yearly; 958 recurrenceType = RecurrenceChooser::Yearly;
955 //qDebug("Recurrence::rYearlyMonth: "); 959 //qDebug("Recurrence::rYearlyMonth: ");
956 day = event->dtStart().date().day(); 960 day = event->dtStart().date().day();
957 rmd = r->yearNums(); 961 rmd = r->yearNums();
958 if ( rmd.count() > 0 ) 962 if ( rmd.count() > 0 )
959 month = *rmd.first(); 963 month = *rmd.first();
960 else 964 else
961 month = event->dtStart().date().month() ; 965 month = event->dtStart().date().month() ;
962 mYearly->setByMonth( month, day ); 966 mYearly->setByMonth( month, day );
963#if 0 967#if 0
964 //qDebug("2day = %d ",day ); 968 //qDebug("2day = %d ",day );
965 QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); 969 QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions();
966 int month; 970 int month;
967 if ( !monthlist.isEmpty() ) { 971 if ( !monthlist.isEmpty() ) {
968 month = monthlist.first()->rPos ; 972 month = monthlist.first()->rPos ;
969 } else { 973 } else {
970 month = event->dtStart().date().month() ; 974 month = event->dtStart().date().month() ;
971 } 975 }
972 mYearly->setByMonth( day, month ); 976 mYearly->setByMonth( day, month );
973#endif 977#endif
974 mYearly->setFrequency( f ); 978 mYearly->setFrequency( f );
975 } 979 }
976 980
977 break; 981 break;
978 case Recurrence::rYearlyDay: 982 case Recurrence::rYearlyDay:
979 //qDebug("Recurrence::rYearlyDay: "); 983 //qDebug("Recurrence::rYearlyDay: ");
980 recurrenceType = RecurrenceChooser::Yearly; 984 recurrenceType = RecurrenceChooser::Yearly;
981 mYearly->setByDay( event->dtStart().date().dayOfYear() ); 985 mYearly->setByDay( event->dtStart().date().dayOfYear() );
982 mYearly->setFrequency( f ); 986 mYearly->setFrequency( f );
983 break; 987 break;
984 default: 988 default:
985 setDefaults( event->dtStart(), dtEnd ); 989 setDefaults( event->dtStart(), dtEnd );
986 break; 990 break;
987 } 991 }
988 } 992 }
989 mRecurrenceChooser->setType( recurrenceType ); 993 mRecurrenceChooser->setType( recurrenceType );
990 showCurrentRule( recurrenceType ); 994 showCurrentRule( recurrenceType );
991 995
992 mRecurrenceRange->setDateTimes( event->dtStart() ); 996 mRecurrenceRange->setDateTimes( event->dtStart() );
993 997
994 if ( event->doesRecur() ) { 998 if ( event->doesRecur() ) {
995 Recurrence *r = event->recurrence(); 999 Recurrence *r = event->recurrence();
996 mRecurrenceRange->setDuration( r->duration() ); 1000 mRecurrenceRange->setDuration( r->duration() );
997 if ( r->duration() == 0 ) 1001 if ( r->duration() == 0 )
998 { 1002 {
999 if ( r->endDate() < event->dtStart().date() ) 1003 if ( r->endDate() < event->dtStart().date() )
1000 mRecurrenceRange->setEndDate( event->dtStart().date() ); 1004 mRecurrenceRange->setEndDate( event->dtStart().date() );
1001 else 1005 else
1002 mRecurrenceRange->setEndDate( r->endDate() ); 1006 mRecurrenceRange->setEndDate( r->endDate() );
1003 } else 1007 } else
1004 mRecurrenceRange->setEndDate( event->dtStart().date() ); 1008 mRecurrenceRange->setEndDate( event->dtStart().date() );
1005 } 1009 }
1006 1010
1007 mExceptions->setDates( event->exDates() ); 1011 mExceptions->setDates( event->exDates() );
1008} 1012}
1009 1013
1010void KOEditorRecurrence::writeEvent( Incidence *event ) 1014void KOEditorRecurrence::writeEvent( Incidence *event )
1011{ 1015{
1012 1016
1013 1017
1014 if ( !mEnabledCheck->isChecked() ) { 1018 if ( !mEnabledCheck->isChecked() ) {
1015 if ( event->doesRecur() ) 1019 if ( event->doesRecur() )
1016 event->recurrence()->unsetRecurs(); 1020 event->recurrence()->unsetRecurs();
1017 } else { 1021 } else {
1018 Recurrence *r = event->recurrence(); 1022 Recurrence *r = event->recurrence();
1019 1023
1020 // clear out any old settings; 1024 // clear out any old settings;
1021 r->unsetRecurs(); 1025 r->unsetRecurs();
1022 int duration = mRecurrenceRange->duration(); 1026 int duration = mRecurrenceRange->duration();
1023 QDate endDate; 1027 QDate endDate;
1024 if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); 1028 if ( duration == 0 ) endDate = mRecurrenceRange->endDate();
1025 1029
1026 int recurrenceType = mRecurrenceChooser->type(); 1030 int recurrenceType = mRecurrenceChooser->type();
1027 1031
1028 if ( recurrenceType == RecurrenceChooser::Daily ) { 1032 if ( recurrenceType == RecurrenceChooser::Daily ) {
1029 int freq = mDaily->frequency(); 1033 int freq = mDaily->frequency();
1030 if ( duration != 0 ) r->setDaily( freq, duration ); 1034 if ( duration != 0 ) r->setDaily( freq, duration );
1031 else r->setDaily( freq, endDate ); 1035 else r->setDaily( freq, endDate );
1032 } else if ( recurrenceType == RecurrenceChooser::Weekly ) { 1036 } else if ( recurrenceType == RecurrenceChooser::Weekly ) {
1033 int freq = mWeekly->frequency(); 1037 int freq = mWeekly->frequency();
1034 QBitArray days = mWeekly->days(); 1038 QBitArray days = mWeekly->days();
1035 int j; 1039 int j;
1036 bool found = false; 1040 bool found = false;
1037 for (j = 0; j < 7 ; ++j ) { 1041 for (j = 0; j < 7 ; ++j ) {
1038 found |=days.at(j); 1042 found |=days.at(j);
1039 } 1043 }
1040 if ( !found ) { 1044 if ( !found ) {
1041 days.setBit( event->dtStart().date().dayOfWeek()-1); 1045 days.setBit( event->dtStart().date().dayOfWeek()-1);
1042 //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); 1046 //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1);
1043 } 1047 }
1044 if ( duration != 0 ) r->setWeekly( freq, days, duration ); 1048 if ( duration != 0 ) r->setWeekly( freq, days, duration );
1045 else r->setWeekly( freq, days, endDate ); 1049 else r->setWeekly( freq, days, endDate );
1046 } else if ( recurrenceType == RecurrenceChooser::Monthly ) { 1050 } else if ( recurrenceType == RecurrenceChooser::Monthly ) {
1047 int freq = mMonthly->frequency(); 1051 int freq = mMonthly->frequency();
1048 if ( mMonthly->byPos() ) { 1052 if ( mMonthly->byPos() ) {
1049 int pos = mMonthly->count(); 1053 int pos = mMonthly->count();
1050 1054
1051 QBitArray days( 7 ); 1055 QBitArray days( 7 );
1052 days.fill( false ); 1056 days.fill( false );
1053 1057
1054 days.setBit( mMonthly->weekday() ); 1058 days.setBit( mMonthly->weekday() );
1055 if ( duration != 0 ) 1059 if ( duration != 0 )
1056 r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); 1060 r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
1057 else 1061 else
1058 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 1062 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
1059 r->addMonthlyPos( pos, days ); 1063 r->addMonthlyPos( pos, days );
1060 } else { 1064 } else {
1061 // it's by day 1065 // it's by day
1062 int day = mMonthly->day(); 1066 int day = mMonthly->day();
1063 1067
1064 if ( duration != 0 ) { 1068 if ( duration != 0 ) {
1065 r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); 1069 r->setMonthly( Recurrence::rMonthlyDay, freq, duration );
1066 } else { 1070 } else {
1067 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 1071 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
1068 } 1072 }
1069 r->addMonthlyDay( day ); 1073 r->addMonthlyDay( day );
1070 } 1074 }
1071 } else if ( recurrenceType == RecurrenceChooser::Yearly ) { 1075 } else if ( recurrenceType == RecurrenceChooser::Yearly ) {
1072 //qDebug("RecurrenceChooser::Yearly "); 1076 //qDebug("RecurrenceChooser::Yearly ");
1073 int freq = mYearly->frequency(); 1077 int freq = mYearly->frequency();
1074 if ( mYearly->byDay() ) { 1078 if ( mYearly->byDay() ) {
1075 if ( duration != 0 ) { 1079 if ( duration != 0 ) {
1076 r->setYearly( Recurrence::rYearlyDay, freq, duration ); 1080 r->setYearly( Recurrence::rYearlyDay, freq, duration );
1077 } else { 1081 } else {
1078 r->setYearly( Recurrence::rYearlyDay, freq, endDate ); 1082 r->setYearly( Recurrence::rYearlyDay, freq, endDate );
1079 } 1083 }
1080 r->addYearlyNum( event->dtStart().date().dayOfYear() ); 1084 r->addYearlyNum( event->dtStart().date().dayOfYear() );
1081 } else { 1085 } else {
1082 if ( duration != 0 ) { 1086 if ( duration != 0 ) {
1083 r->setYearly( Recurrence::rYearlyMonth, freq, duration ); 1087 r->setYearly( Recurrence::rYearlyMonth, freq, duration );
1084 } else { 1088 } else {
1085 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 1089 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
1086 } 1090 }
1087 r->addYearlyNum( mYearly->month() ); 1091 r->addYearlyNum( mYearly->month() );
1088 } 1092 }
1089 1093
1090 } 1094 }
1091 1095
1092 event->setExDates( mExceptions->dates() ); 1096 event->setExDates( mExceptions->dates() );
1093 } 1097 }
1094} 1098}
1095 1099
1096void KOEditorRecurrence::setDateTimeStr( const QString &str ) 1100void KOEditorRecurrence::setDateTimeStr( const QString &str )
1097{ 1101{
1098 mDateTimeLabel->setText( str ); 1102 mDateTimeLabel->setText( str );
1099} 1103}
1100 1104
1101bool KOEditorRecurrence::validateInput() 1105bool KOEditorRecurrence::validateInput()
1102{ 1106{
1103 // Check input here 1107 // Check input here
1104 1108
1105 return true; 1109 return true;
1106} 1110}
1107 1111
1108void KOEditorRecurrence::showExceptionsDialog() 1112void KOEditorRecurrence::showExceptionsDialog()
1109{ 1113{
1110 DateList dates = mExceptions->dates(); 1114 DateList dates = mExceptions->dates();
1111 int result = mExceptionsDialog->exec(); 1115 int result = mExceptionsDialog->exec();
1112 if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); 1116 if ( result == QDialog::Rejected ) mExceptions->setDates( dates );
1113} 1117}
1114 1118
1115void KOEditorRecurrence::showRecurrenceRangeDialog() 1119void KOEditorRecurrence::showRecurrenceRangeDialog()
1116{ 1120{
1117 int duration = mRecurrenceRange->duration(); 1121 int duration = mRecurrenceRange->duration();
1118 QDate endDate = mRecurrenceRange->endDate(); 1122 QDate endDate = mRecurrenceRange->endDate();
1119 1123
1120 int result = mRecurrenceRangeDialog->exec(); 1124 int result = mRecurrenceRangeDialog->exec();
1121 if ( result == QDialog::Rejected ) { 1125 if ( result == QDialog::Rejected ) {
1122 mRecurrenceRange->setDuration( duration ); 1126 mRecurrenceRange->setDuration( duration );
1123 mRecurrenceRange->setEndDate( endDate ); 1127 mRecurrenceRange->setEndDate( endDate );
1124 } 1128 }
1125 1129
1126} 1130}
diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h
index f398f62..75e0c73 100644
--- a/korganizer/koeditorrecurrence.h
+++ b/korganizer/koeditorrecurrence.h
@@ -1,324 +1,327 @@
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#include <qbuttongroup.h>
36 37
37#include <kdialogbase.h> 38#include <kdialogbase.h>
38 39
39#include <libkcal/event.h> 40#include <libkcal/event.h>
40 41
41#include "ktimeedit.h" 42#include "ktimeedit.h"
42 43
43class QWidgetStack; 44class QWidgetStack;
44class QSpinBox; 45class QSpinBox;
45 46
46class KDateEdit; 47class KDateEdit;
47 48
48using namespace KCal; 49using namespace KCal;
49 50
50class RecurBase : public QWidget 51class RecurBase : public QWidget
51{ 52{
52 public: 53 public:
53 RecurBase( QWidget *parent = 0, const char *name = 0 ); 54 RecurBase( QWidget *parent = 0, const char *name = 0 );
54 55
55 void setFrequency( int ); 56 void setFrequency( int );
56 int frequency(); 57 int frequency();
57 58
58 QWidget *frequencyEdit(); 59 QWidget *frequencyEdit();
59 60
60 private: 61 private:
61 QSpinBox *mFrequencyEdit; 62 QSpinBox *mFrequencyEdit;
62}; 63};
63 64
64class RecurDaily : public RecurBase 65class RecurDaily : public RecurBase
65{ 66{
66 public: 67 public:
67 RecurDaily( QWidget *parent = 0, const char *name = 0 ); 68 RecurDaily( QWidget *parent = 0, const char *name = 0 );
68}; 69};
69 70
70class RecurWeekly : public RecurBase 71class RecurWeekly : public RecurBase
71{ 72{
72 public: 73 public:
73 RecurWeekly( QWidget *parent = 0, const char *name = 0 ); 74 RecurWeekly( QWidget *parent = 0, const char *name = 0 );
74 75
75 void setDays( const QBitArray & ); 76 void setDays( const QBitArray & );
76 QBitArray days(); 77 QBitArray days();
77 78
78 private: 79 private:
79 QCheckBox *mDayBoxes[7]; 80 QCheckBox *mDayBoxes[7];
80}; 81};
81 82
82class RecurMonthly : public RecurBase 83class RecurMonthly : public RecurBase
83{ 84{
84 public: 85 public:
85 RecurMonthly( QWidget *parent = 0, const char *name = 0 ); 86 RecurMonthly( QWidget *parent = 0, const char *name = 0 );
86 87
87 void setByDay( int day ); 88 void setByDay( int day );
88 void setByPos( int count, int weekday ); 89 void setByPos( int count, int weekday );
89 90
90 bool byDay(); 91 bool byDay();
91 bool byPos(); 92 bool byPos();
92 93
93 int day(); 94 int day();
94 95
95 int count(); 96 int count();
96 int weekday(); 97 int weekday();
97 98
98 private: 99 private:
99 QRadioButton *mByDayRadio; 100 QRadioButton *mByDayRadio;
100 QComboBox *mByDayCombo; 101 QComboBox *mByDayCombo;
101 102
102 QRadioButton *mByPosRadio; 103 QRadioButton *mByPosRadio;
103 QComboBox *mByPosCountCombo; 104 QComboBox *mByPosCountCombo;
104 QComboBox *mByPosWeekdayCombo; 105 QComboBox *mByPosWeekdayCombo;
105}; 106};
106 107
107class RecurYearly : public RecurBase 108class RecurYearly : public RecurBase
108{ 109{
109 public: 110 public:
110 RecurYearly( QWidget *parent = 0, const char *name = 0 ); 111 RecurYearly( QWidget *parent = 0, const char *name = 0 );
111 112
112 void setByDay( int doy ); 113 void setByDay( int doy );
113 void setByMonth( int month, int day ); 114 void setByMonth( int month, int day );
114 115
115 bool byMonth(); 116 bool byMonth();
116 bool byDay(); 117 bool byDay();
117 118
118 int month(); 119 int month();
119 int day(); 120 int day();
120 121
121 private: 122 private:
122 int mDay; 123 int mDay;
123 QRadioButton *mByMonthRadio; 124 QRadioButton *mByMonthRadio;
124 QComboBox *mByMonthCombo; 125 QComboBox *mByMonthCombo;
125 QLabel* mByDayLabel; 126 QLabel* mByDayLabel;
126 QLabel* mDayOfLabel; 127 QLabel* mDayOfLabel;
127 QRadioButton *mByDayRadio; 128 QRadioButton *mByDayRadio;
128}; 129};
129 130
130class RecurrenceChooser : public QWidget 131class RecurrenceChooser : public QWidget
131{ 132{
132 Q_OBJECT 133 Q_OBJECT
133 public: 134 public:
134 RecurrenceChooser( QWidget *parent = 0, const char *name = 0 ); 135 RecurrenceChooser( QWidget *parent = 0, const char *name = 0 );
135 136
136 enum { Daily, Weekly, Monthly, Yearly }; 137 enum { Daily, Weekly, Monthly, Yearly };
137 138
138 void setType( int ); 139 void setType( int );
139 int type(); 140 int type();
140 141
141 signals: 142 signals:
142 void chosen( int ); 143 void chosen( int );
143 144
144 protected slots: 145 protected slots:
145 void emitChoice(); 146 void emitChoice();
146 147
147 private: 148 private:
148 QComboBox *mTypeCombo; 149 QComboBox *mTypeCombo;
149 150
150 QRadioButton *mDailyButton; 151 QRadioButton *mDailyButton;
151 QRadioButton *mWeeklyButton; 152 QRadioButton *mWeeklyButton;
152 QRadioButton *mMonthlyButton; 153 QRadioButton *mMonthlyButton;
153 QRadioButton *mYearlyButton; 154 QRadioButton *mYearlyButton;
154}; 155};
155 156
156class ExceptionsBase 157class ExceptionsBase
157{ 158{
158 public: 159 public:
159 virtual void setDefaults( const QDateTime &from ) = 0; 160 virtual void setDefaults( const QDateTime &from ) = 0;
160 virtual void setDates( const DateList & ) = 0; 161 virtual void setDates( const DateList & ) = 0;
161 virtual DateList dates() = 0; 162 virtual DateList dates() = 0;
162}; 163};
163 164
164class ExceptionsWidget : public QWidget, public ExceptionsBase 165class ExceptionsWidget : public QWidget, public ExceptionsBase
165{ 166{
166 Q_OBJECT 167 Q_OBJECT
167 public: 168 public:
168 ExceptionsWidget( QWidget *parent = 0, const char *name = 0 ); 169 ExceptionsWidget( QWidget *parent = 0, const char *name = 0 );
169 170
170 void setDefaults( const QDateTime &from ); 171 void setDefaults( const QDateTime &from );
171 172
172 void setDates( const DateList & ); 173 void setDates( const DateList & );
173 DateList dates(); 174 DateList dates();
174 175
175 protected slots: 176 protected slots:
176 void addException(); 177 void addException();
177 void changeException(); 178 void changeException();
178 void deleteException(); 179 void deleteException();
179 180
180 private: 181 private:
181 KDateEdit *mExceptionDateEdit; 182 KDateEdit *mExceptionDateEdit;
182 QListBox *mExceptionList; 183 QListBox *mExceptionList;
183 DateList mExceptionDates; 184 DateList mExceptionDates;
184}; 185};
185 186
186class ExceptionsDialog : public KDialogBase, public ExceptionsBase 187class ExceptionsDialog : public KDialogBase, public ExceptionsBase
187{ 188{
188 public: 189 public:
189 ExceptionsDialog( QWidget *parent, const char *name = 0 ); 190 ExceptionsDialog( QWidget *parent, const char *name = 0 );
190 191
191 void setDefaults( const QDateTime &from ); 192 void setDefaults( const QDateTime &from );
192 193
193 void setDates( const DateList & ); 194 void setDates( const DateList & );
194 DateList dates(); 195 DateList dates();
195 196
196 private: 197 private:
197 ExceptionsWidget *mExceptions; 198 ExceptionsWidget *mExceptions;
198}; 199};
199 200
200class RecurrenceRangeBase 201class RecurrenceRangeBase
201{ 202{
202 public: 203 public:
203 virtual void setDefaults( const QDateTime &from ) = 0; 204 virtual void setDefaults( const QDateTime &from ) = 0;
204 205
205 virtual void setDuration( int ) = 0; 206 virtual void setDuration( int ) = 0;
206 virtual int duration() = 0; 207 virtual int duration() = 0;
207 208
208 virtual void setEndDate( const QDate & ) = 0; 209 virtual void setEndDate( const QDate & ) = 0;
209 virtual QDate endDate() = 0; 210 virtual QDate endDate() = 0;
210 211
211 virtual void setDateTimes( const QDateTime &start, 212 virtual void setDateTimes( const QDateTime &start,
212 const QDateTime &end = QDateTime() ) = 0; 213 const QDateTime &end = QDateTime() ) = 0;
213}; 214};
214 215
215class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase 216class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase
216{ 217{
217 Q_OBJECT 218 Q_OBJECT
218 public: 219 public:
219 RecurrenceRangeWidget( QWidget *parent = 0, const char *name = 0 ); 220 RecurrenceRangeWidget( QWidget *parent = 0, const char *name = 0 );
221 ~RecurrenceRangeWidget();
220 222
221 void setDefaults( const QDateTime &from ); 223 void setDefaults( const QDateTime &from );
222 224
223 void setDuration( int ); 225 void setDuration( int );
224 int duration(); 226 int duration();
225 227
226 void setEndDate( const QDate & ); 228 void setEndDate( const QDate & );
227 QDate endDate(); 229 QDate endDate();
228 230
229 void setDateTimes( const QDateTime &start, 231 void setDateTimes( const QDateTime &start,
230 const QDateTime &end = QDateTime() ); 232 const QDateTime &end = QDateTime() );
231 233
232 protected slots: 234 protected slots:
233 void showCurrentRange(); 235 void showCurrentRange();
234 236
235 private: 237 private:
238 QButtonGroup *mRangeButtonGroup;
236 QGroupBox *mRangeGroupBox; 239 QGroupBox *mRangeGroupBox;
237 QLabel *mStartDateLabel; 240 QLabel *mStartDateLabel;
238 QRadioButton *mNoEndDateButton; 241 QRadioButton *mNoEndDateButton;
239 QRadioButton *mEndDurationButton; 242 QRadioButton *mEndDurationButton;
240 QSpinBox *mEndDurationEdit; 243 QSpinBox *mEndDurationEdit;
241 QRadioButton *mEndDateButton; 244 QRadioButton *mEndDateButton;
242 KDateEdit *mEndDateEdit; 245 KDateEdit *mEndDateEdit;
243}; 246};
244 247
245class RecurrenceRangeDialog : public KDialogBase, public RecurrenceRangeBase 248class RecurrenceRangeDialog : public KDialogBase, public RecurrenceRangeBase
246{ 249{
247 public: 250 public:
248 RecurrenceRangeDialog( QWidget *parent = 0, const char *name = 0 ); 251 RecurrenceRangeDialog( QWidget *parent = 0, const char *name = 0 );
249 252
250 void setDefaults( const QDateTime &from ); 253 void setDefaults( const QDateTime &from );
251 254
252 void setDuration( int ); 255 void setDuration( int );
253 int duration(); 256 int duration();
254 257
255 void setEndDate( const QDate & ); 258 void setEndDate( const QDate & );
256 QDate endDate(); 259 QDate endDate();
257 260
258 void setDateTimes( const QDateTime &start, 261 void setDateTimes( const QDateTime &start,
259 const QDateTime &end = QDateTime() ); 262 const QDateTime &end = QDateTime() );
260 263
261 private: 264 private:
262 RecurrenceRangeWidget *mRecurrenceRangeWidget; 265 RecurrenceRangeWidget *mRecurrenceRangeWidget;
263}; 266};
264 267
265class KOEditorRecurrence : public QWidget 268class KOEditorRecurrence : public QWidget
266{ 269{
267 Q_OBJECT 270 Q_OBJECT
268 public: 271 public:
269 KOEditorRecurrence ( QWidget *parent = 0, const char *name = 0 ); 272 KOEditorRecurrence ( QWidget *parent = 0, const char *name = 0 );
270 virtual ~KOEditorRecurrence(); 273 virtual ~KOEditorRecurrence();
271 274
272 enum { Daily, Weekly, Monthly, Yearly }; 275 enum { Daily, Weekly, Monthly, Yearly };
273 276
274 /** Read event object and setup widgets accordingly */ 277 /** Read event object and setup widgets accordingly */
275 void readEvent( Incidence * ); 278 void readEvent( Incidence * );
276 /** Write event settings to event object */ 279 /** Write event settings to event object */
277 void writeEvent( Incidence * ); 280 void writeEvent( Incidence * );
278 281
279 /** Check if the input is valid. */ 282 /** Check if the input is valid. */
280 bool validateInput(); 283 bool validateInput();
281 284
282 public slots: 285 public slots:
283 void setDefaultsDates( QDateTime from, QDateTime to ); 286 void setDefaultsDates( QDateTime from, QDateTime to );
284 void setDefaults( QDateTime from, QDateTime to ); 287 void setDefaults( QDateTime from, QDateTime to );
285 void setEnabled( bool ); 288 void setEnabled( bool );
286 void setDateTimes( QDateTime start, QDateTime end ); 289 void setDateTimes( QDateTime start, QDateTime end );
287 void setDateTimeStr( const QString & ); 290 void setDateTimeStr( const QString & );
288 291
289 signals: 292 signals:
290 void dateTimesChanged( QDateTime start, QDateTime end ); 293 void dateTimesChanged( QDateTime start, QDateTime end );
291 294
292 protected slots: 295 protected slots:
293 void showCurrentRule( int ); 296 void showCurrentRule( int );
294 void showExceptionsDialog(); 297 void showExceptionsDialog();
295 void showRecurrenceRangeDialog(); 298 void showRecurrenceRangeDialog();
296 299
297 private: 300 private:
298 QCheckBox *mEnabledCheck; 301 QCheckBox *mEnabledCheck;
299 302
300 QGroupBox *mTimeGroupBox; 303 QGroupBox *mTimeGroupBox;
301 QLabel *mDateTimeLabel; 304 QLabel *mDateTimeLabel;
302 305
303 QGroupBox *mRuleBox; 306 QGroupBox *mRuleBox;
304 QWidgetStack *mRuleStack; 307 QWidgetStack *mRuleStack;
305 RecurrenceChooser *mRecurrenceChooser; 308 RecurrenceChooser *mRecurrenceChooser;
306 309
307 RecurDaily *mDaily; 310 RecurDaily *mDaily;
308 RecurWeekly *mWeekly; 311 RecurWeekly *mWeekly;
309 RecurMonthly *mMonthly; 312 RecurMonthly *mMonthly;
310 RecurYearly *mYearly; 313 RecurYearly *mYearly;
311 314
312 RecurrenceRangeBase *mRecurrenceRange; 315 RecurrenceRangeBase *mRecurrenceRange;
313 RecurrenceRangeWidget *mRecurrenceRangeWidget; 316 RecurrenceRangeWidget *mRecurrenceRangeWidget;
314 RecurrenceRangeDialog *mRecurrenceRangeDialog; 317 RecurrenceRangeDialog *mRecurrenceRangeDialog;
315 QPushButton *mRecurrenceRangeButton; 318 QPushButton *mRecurrenceRangeButton;
316 319
317 ExceptionsBase *mExceptions; 320 ExceptionsBase *mExceptions;
318 ExceptionsDialog *mExceptionsDialog; 321 ExceptionsDialog *mExceptionsDialog;
319 ExceptionsWidget *mExceptionsWidget; 322 ExceptionsWidget *mExceptionsWidget;
320 QPushButton *mExceptionsButton; 323 QPushButton *mExceptionsButton;
321 324
322}; 325};
323 326
324#endif 327#endif