summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt1
-rw-r--r--korganizer/koeditorrecurrence.cpp2
2 files changed, 3 insertions, 0 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 37266bf..a864f1d 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,50 +1,51 @@
1Info about the changes in new versions of KDE-Pim/Pi 1Info about the changes in new versions of KDE-Pim/Pi
2 2
3********** VERSION 2.2.3 ************ 3********** VERSION 2.2.3 ************
4 4
5Fixed a problem with (non empty) exception dates of recurring events for newly created events.
5 6
6 7
7********** VERSION 2.2.2 ************ 8********** VERSION 2.2.2 ************
8 9
9KO/Pi: 10KO/Pi:
10Fixed a problem with the sort order of last modified date in list view. 11Fixed a problem with the sort order of last modified date in list view.
11KA/Pi: 12KA/Pi:
12Fixed a resource config read problem on windows. 13Fixed a resource config read problem on windows.
13 14
14 15
15********** VERSION 2.2.1 ************ 16********** VERSION 2.2.1 ************
16 17
17KO/Pi: 18KO/Pi:
18Fixed a problem displaying very long allday events in agenda view in single day mode. 19Fixed a problem displaying very long allday events in agenda view in single day mode.
19Fixed a problem with the default settings for new todos. 20Fixed a problem with the default settings for new todos.
20Added an error message dialog if saving of calendar files is not possible. 21Added an error message dialog if saving of calendar files is not possible.
21Made it impossible to close KO/Pi if saving fails. 22Made it impossible to close KO/Pi if saving fails.
22Fixed a problem adding calendars on windows such that these calendars can be used on the memory stick. 23Fixed a problem adding calendars on windows such that these calendars can be used on the memory stick.
23Added config options for conflict detection. 24Added config options for conflict detection.
24 25
25KA/Pi: 26KA/Pi:
26Added a config option to turn on asking before a contact is deleted. 27Added a config option to turn on asking before a contact is deleted.
27Fixed a problem with the default view and view selection at startup. 28Fixed a problem with the default view and view selection at startup.
28Formatted name is now set on import, if formatted name is empty. 29Formatted name is now set on import, if formatted name is empty.
29Fixed a problem of displaying images in the contact details view: 30Fixed a problem of displaying images in the contact details view:
30Now the wid/hei ratio is not changed. 31Now the wid/hei ratio is not changed.
31I a picture is larger than 128 pixels in wid or hei it is downscaled to 32I a picture is larger than 128 pixels in wid or hei it is downscaled to
32max 128 pixels wid/hei. 33max 128 pixels wid/hei.
33 34
34********** VERSION 2.2.0 ************ 35********** VERSION 2.2.0 ************
35 36
36New stable release! 37New stable release!
37Fixed some minor usability problems. 38Fixed some minor usability problems.
38Added writing of next alarm to a file for usage on pdaXrom. 39Added writing of next alarm to a file for usage on pdaXrom.
39 40
40 41
41************************************* 42*************************************
42 43
43You can find the complete changelog 44You can find the complete changelog
44from version 1.7.7 to 2.2.0 45from version 1.7.7 to 2.2.0
45in the source package or on 46in the source package or on
46 47
47http://www.pi-sync.net/html/changelog.html 48http://www.pi-sync.net/html/changelog.html
48 49
49 50
50 51
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp
index 0e74a99..e0380c4 100644
--- a/korganizer/koeditorrecurrence.cpp
+++ b/korganizer/koeditorrecurrence.cpp
@@ -1,1130 +1,1132 @@
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 mExceptionList->clear();
429 mExceptionDates.clear();
428 mExceptionDateEdit->setDate( from.date() ); 430 mExceptionDateEdit->setDate( from.date() );
429} 431}
430 432
431void ExceptionsWidget::addException() 433void ExceptionsWidget::addException()
432{ 434{
433 QDate date = mExceptionDateEdit->date(); 435 QDate date = mExceptionDateEdit->date();
434 QString dateStr = KGlobal::locale()->formatDate( date ); 436 QString dateStr = KGlobal::locale()->formatDate( date );
435 if( !mExceptionList->findItem( dateStr ) ) { 437 if( !mExceptionList->findItem( dateStr ) ) {
436 mExceptionDates.append( date ); 438 mExceptionDates.append( date );
437 mExceptionList->insertItem( dateStr ); 439 mExceptionList->insertItem( dateStr );
438 } 440 }
439} 441}
440 442
441void ExceptionsWidget::changeException() 443void ExceptionsWidget::changeException()
442{ 444{
443 int pos = mExceptionList->currentItem(); 445 int pos = mExceptionList->currentItem();
444 if ( pos < 0 ) return; 446 if ( pos < 0 ) return;
445 447
446 QDate date = mExceptionDateEdit->date(); 448 QDate date = mExceptionDateEdit->date();
447 mExceptionDates[ pos ] = date; 449 mExceptionDates[ pos ] = date;
448 mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos ); 450 mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos );
449} 451}
450 452
451void ExceptionsWidget::deleteException() 453void ExceptionsWidget::deleteException()
452{ 454{
453 int pos = mExceptionList->currentItem(); 455 int pos = mExceptionList->currentItem();
454 if ( pos < 0 ) return; 456 if ( pos < 0 ) return;
455 457
456 mExceptionDates.remove( mExceptionDates.at( pos ) ); 458 mExceptionDates.remove( mExceptionDates.at( pos ) );
457 mExceptionList->removeItem( pos ); 459 mExceptionList->removeItem( pos );
458} 460}
459 461
460void ExceptionsWidget::setDates( const DateList &dates ) 462void ExceptionsWidget::setDates( const DateList &dates )
461{ 463{
462 mExceptionList->clear(); 464 mExceptionList->clear();
463 mExceptionDates.clear(); 465 mExceptionDates.clear();
464 DateList::ConstIterator dit; 466 DateList::ConstIterator dit;
465 for ( dit = dates.begin(); dit != dates.end(); ++dit ) { 467 for ( dit = dates.begin(); dit != dates.end(); ++dit ) {
466 mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) ); 468 mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) );
467 mExceptionDates.append( *dit ); 469 mExceptionDates.append( *dit );
468 } 470 }
469} 471}
470 472
471DateList ExceptionsWidget::dates() 473DateList ExceptionsWidget::dates()
472{ 474{
473 return mExceptionDates; 475 return mExceptionDates;
474} 476}
475 477
476///////////////////////// ExceptionsDialog /////////////////////////// 478///////////////////////// ExceptionsDialog ///////////////////////////
477 479
478ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : 480ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) :
479 KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel ) 481 KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel )
480{ 482{
481 mExceptions = new ExceptionsWidget( this ); 483 mExceptions = new ExceptionsWidget( this );
482 setMainWidget( mExceptions ); 484 setMainWidget( mExceptions );
483 resize(220,10); 485 resize(220,10);
484} 486}
485 487
486void ExceptionsDialog::setDefaults( const QDateTime &from ) 488void ExceptionsDialog::setDefaults( const QDateTime &from )
487{ 489{
488 mExceptions->setDefaults( from ); 490 mExceptions->setDefaults( from );
489} 491}
490 492
491void ExceptionsDialog::setDates( const DateList &dates ) 493void ExceptionsDialog::setDates( const DateList &dates )
492{ 494{
493 mExceptions->setDates( dates ); 495 mExceptions->setDates( dates );
494} 496}
495 497
496DateList ExceptionsDialog::dates() 498DateList ExceptionsDialog::dates()
497{ 499{
498 return mExceptions->dates(); 500 return mExceptions->dates();
499} 501}
500 502
501///////////////////////// RecurrenceRangeWidget /////////////////////////// 503///////////////////////// RecurrenceRangeWidget ///////////////////////////
502 504
503RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, 505RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent,
504 const char *name ) 506 const char *name )
505 : QWidget( parent, name ) 507 : QWidget( parent, name )
506{ 508{
507 QBoxLayout *topLayout = new QVBoxLayout( this ); 509 QBoxLayout *topLayout = new QVBoxLayout( this );
508 510
509 mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"), 511 mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"),
510 this ); 512 this );
511 topLayout->addWidget( mRangeGroupBox ); 513 topLayout->addWidget( mRangeGroupBox );
512 514
513 QWidget *rangeBox = new QWidget( mRangeGroupBox ); 515 QWidget *rangeBox = new QWidget( mRangeGroupBox );
514 QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox ); 516 QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox );
515 rangeLayout->setSpacing( KDialog::spacingHint() ); 517 rangeLayout->setSpacing( KDialog::spacingHint() );
516 rangeLayout->setMargin( KDialog::marginHintSmall() ); 518 rangeLayout->setMargin( KDialog::marginHintSmall() );
517 519
518 mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); 520 mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox );
519 rangeLayout->addWidget( mStartDateLabel ); 521 rangeLayout->addWidget( mStartDateLabel );
520 522
521 mRangeButtonGroup = new QButtonGroup; 523 mRangeButtonGroup = new QButtonGroup;
522 524
523 mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); 525 mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox );
524 mRangeButtonGroup->insert( mNoEndDateButton ); 526 mRangeButtonGroup->insert( mNoEndDateButton );
525 rangeLayout->addWidget( mNoEndDateButton ); 527 rangeLayout->addWidget( mNoEndDateButton );
526 528
527 QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); 529 QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout );
528 durationLayout->setSpacing( KDialog::spacingHint() ); 530 durationLayout->setSpacing( KDialog::spacingHint() );
529 531
530 mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); 532 mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox );
531 mRangeButtonGroup->insert( mEndDurationButton ); 533 mRangeButtonGroup->insert( mEndDurationButton );
532 durationLayout->addWidget( mEndDurationButton ); 534 durationLayout->addWidget( mEndDurationButton );
533 535
534 mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); 536 mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox );
535 durationLayout->addWidget( mEndDurationEdit ); 537 durationLayout->addWidget( mEndDurationEdit );
536 538
537 QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); 539 QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox );
538 durationLayout ->addWidget( endDurationLabel ); 540 durationLayout ->addWidget( endDurationLabel );
539 541
540 QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); 542 QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout );
541 endDateLayout->setSpacing( KDialog::spacingHint() ); 543 endDateLayout->setSpacing( KDialog::spacingHint() );
542 544
543 mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); 545 mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox );
544 mRangeButtonGroup->insert( mEndDateButton ); 546 mRangeButtonGroup->insert( mEndDateButton );
545 endDateLayout->addWidget( mEndDateButton ); 547 endDateLayout->addWidget( mEndDateButton );
546 548
547 mEndDateEdit = new KDateEdit( rangeBox ); 549 mEndDateEdit = new KDateEdit( rangeBox );
548 endDateLayout->addWidget( mEndDateEdit ); 550 endDateLayout->addWidget( mEndDateEdit );
549 551
550 //endDateLayout->addStretch( 1 ); 552 //endDateLayout->addStretch( 1 );
551 553
552 connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), 554 connect( mNoEndDateButton, SIGNAL( toggled( bool ) ),
553 SLOT( showCurrentRange() ) ); 555 SLOT( showCurrentRange() ) );
554 connect( mEndDurationButton, SIGNAL( toggled( bool ) ), 556 connect( mEndDurationButton, SIGNAL( toggled( bool ) ),
555 SLOT( showCurrentRange() ) ); 557 SLOT( showCurrentRange() ) );
556 connect( mEndDateButton, SIGNAL( toggled( bool ) ), 558 connect( mEndDateButton, SIGNAL( toggled( bool ) ),
557 SLOT( showCurrentRange() ) ); 559 SLOT( showCurrentRange() ) );
558} 560}
559 561
560RecurrenceRangeWidget::~RecurrenceRangeWidget() 562RecurrenceRangeWidget::~RecurrenceRangeWidget()
561{ 563{
562 delete mRangeButtonGroup; 564 delete mRangeButtonGroup;
563} 565}
564void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) 566void RecurrenceRangeWidget::setDefaults( const QDateTime &from )
565{ 567{
566 mNoEndDateButton->setChecked( true ); 568 mNoEndDateButton->setChecked( true );
567 569
568 setDateTimes( from ); 570 setDateTimes( from );
569 mEndDateEdit->setDate( from.date() ); 571 mEndDateEdit->setDate( from.date() );
570} 572}
571 573
572void RecurrenceRangeWidget::setDuration( int duration ) 574void RecurrenceRangeWidget::setDuration( int duration )
573{ 575{
574 if ( duration == -1 ) { 576 if ( duration == -1 ) {
575 mNoEndDateButton->setChecked( true ); 577 mNoEndDateButton->setChecked( true );
576 } else if ( duration == 0 ) { 578 } else if ( duration == 0 ) {
577 mEndDateButton->setChecked( true ); 579 mEndDateButton->setChecked( true );
578 } else { 580 } else {
579 mEndDurationButton->setChecked( true ); 581 mEndDurationButton->setChecked( true );
580 mEndDurationEdit->setValue( duration ); 582 mEndDurationEdit->setValue( duration );
581 } 583 }
582} 584}
583 585
584int RecurrenceRangeWidget::duration() 586int RecurrenceRangeWidget::duration()
585{ 587{
586 if ( mNoEndDateButton->isChecked() ) { 588 if ( mNoEndDateButton->isChecked() ) {
587 return -1; 589 return -1;
588 } else if ( mEndDurationButton->isChecked() ) { 590 } else if ( mEndDurationButton->isChecked() ) {
589 return mEndDurationEdit->value(); 591 return mEndDurationEdit->value();
590 } else { 592 } else {
591 return 0; 593 return 0;
592 } 594 }
593} 595}
594 596
595void RecurrenceRangeWidget::setEndDate( const QDate &date ) 597void RecurrenceRangeWidget::setEndDate( const QDate &date )
596{ 598{
597 mEndDateEdit->setDate( date ); 599 mEndDateEdit->setDate( date );
598} 600}
599 601
600QDate RecurrenceRangeWidget::endDate() 602QDate RecurrenceRangeWidget::endDate()
601{ 603{
602 return mEndDateEdit->date(); 604 return mEndDateEdit->date();
603} 605}
604 606
605void RecurrenceRangeWidget::showCurrentRange() 607void RecurrenceRangeWidget::showCurrentRange()
606{ 608{
607 mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); 609 mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() );
608 mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); 610 mEndDateEdit->setEnabled( mEndDateButton->isChecked() );
609} 611}
610 612
611void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, 613void RecurrenceRangeWidget::setDateTimes( const QDateTime &start,
612 const QDateTime & ) 614 const QDateTime & )
613{ 615{
614 mStartDateLabel->setText( i18n("Start date: %1") 616 mStartDateLabel->setText( i18n("Start date: %1")
615 .arg( KGlobal::locale()->formatDate( start.date() ) ) ); 617 .arg( KGlobal::locale()->formatDate( start.date() ) ) );
616 618
617 if(!mEndDateButton->isChecked()) 619 if(!mEndDateButton->isChecked())
618 mEndDateEdit->setDate( start.date() ); 620 mEndDateEdit->setDate( start.date() );
619} 621}
620 622
621///////////////////////// RecurrenceRangeDialog /////////////////////////// 623///////////////////////// RecurrenceRangeDialog ///////////////////////////
622 624
623RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, 625RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent,
624 const char *name ) : 626 const char *name ) :
625 KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) 627 KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel )
626{ 628{
627 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); 629 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this );
628 setMainWidget( mRecurrenceRangeWidget ); 630 setMainWidget( mRecurrenceRangeWidget );
629} 631}
630 632
631void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) 633void RecurrenceRangeDialog::setDefaults( const QDateTime &from )
632{ 634{
633 mRecurrenceRangeWidget->setDefaults( from ); 635 mRecurrenceRangeWidget->setDefaults( from );
634} 636}
635 637
636void RecurrenceRangeDialog::setDuration( int duration ) 638void RecurrenceRangeDialog::setDuration( int duration )
637{ 639{
638 mRecurrenceRangeWidget->setDuration( duration ); 640 mRecurrenceRangeWidget->setDuration( duration );
639} 641}
640 642
641int RecurrenceRangeDialog::duration() 643int RecurrenceRangeDialog::duration()
642{ 644{
643 return mRecurrenceRangeWidget->duration(); 645 return mRecurrenceRangeWidget->duration();
644} 646}
645 647
646void RecurrenceRangeDialog::setEndDate( const QDate &date ) 648void RecurrenceRangeDialog::setEndDate( const QDate &date )
647{ 649{
648 mRecurrenceRangeWidget->setEndDate( date ); 650 mRecurrenceRangeWidget->setEndDate( date );
649} 651}
650 652
651QDate RecurrenceRangeDialog::endDate() 653QDate RecurrenceRangeDialog::endDate()
652{ 654{
653 return mRecurrenceRangeWidget->endDate(); 655 return mRecurrenceRangeWidget->endDate();
654} 656}
655 657
656void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, 658void RecurrenceRangeDialog::setDateTimes( const QDateTime &start,
657 const QDateTime &end ) 659 const QDateTime &end )
658{ 660{
659 mRecurrenceRangeWidget->setDateTimes( start, end ); 661 mRecurrenceRangeWidget->setDateTimes( start, end );
660} 662}
661 663
662//////////////////////////// RecurrenceChooser //////////////////////// 664//////////////////////////// RecurrenceChooser ////////////////////////
663 665
664RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : 666RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) :
665 QWidget( parent, name ) 667 QWidget( parent, name )
666{ 668{
667 QBoxLayout *topLayout = new QVBoxLayout( this ); 669 QBoxLayout *topLayout = new QVBoxLayout( this );
668 670
669 mTypeCombo = new QComboBox( this ); 671 mTypeCombo = new QComboBox( this );
670 mTypeCombo->insertItem( i18n("Daily") ); 672 mTypeCombo->insertItem( i18n("Daily") );
671 mTypeCombo->insertItem( i18n("Weekly") ); 673 mTypeCombo->insertItem( i18n("Weekly") );
672 mTypeCombo->insertItem( i18n("Monthly") ); 674 mTypeCombo->insertItem( i18n("Monthly") );
673 mTypeCombo->insertItem( i18n("Yearly") ); 675 mTypeCombo->insertItem( i18n("Yearly") );
674 676
675 topLayout->addWidget( mTypeCombo ); 677 topLayout->addWidget( mTypeCombo );
676 678
677 connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); 679 connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) );
678 680
679} 681}
680 682
681int RecurrenceChooser::type() 683int RecurrenceChooser::type()
682{ 684{
683 if ( mTypeCombo ) { 685 if ( mTypeCombo ) {
684 return mTypeCombo->currentItem(); 686 return mTypeCombo->currentItem();
685 } else { 687 } else {
686 if ( mDailyButton->isChecked() ) return Daily; 688 if ( mDailyButton->isChecked() ) return Daily;
687 else if ( mWeeklyButton->isChecked() ) return Weekly; 689 else if ( mWeeklyButton->isChecked() ) return Weekly;
688 else if ( mMonthlyButton->isChecked() ) return Monthly; 690 else if ( mMonthlyButton->isChecked() ) return Monthly;
689 else return Yearly; 691 else return Yearly;
690 } 692 }
691} 693}
692 694
693void RecurrenceChooser::setType( int type ) 695void RecurrenceChooser::setType( int type )
694{ 696{
695 if ( mTypeCombo ) { 697 if ( mTypeCombo ) {
696 mTypeCombo->setCurrentItem( type ); 698 mTypeCombo->setCurrentItem( type );
697 } else { 699 } else {
698 switch ( type ) { 700 switch ( type ) {
699 case Daily: 701 case Daily:
700 mDailyButton->setChecked( true ); 702 mDailyButton->setChecked( true );
701 break; 703 break;
702 case Weekly: 704 case Weekly:
703 mWeeklyButton->setChecked( true ); 705 mWeeklyButton->setChecked( true );
704 break; 706 break;
705 case Monthly: 707 case Monthly:
706 mMonthlyButton->setChecked( true ); 708 mMonthlyButton->setChecked( true );
707 break; 709 break;
708 case Yearly: 710 case Yearly:
709 default: 711 default:
710 mYearlyButton->setChecked( true ); 712 mYearlyButton->setChecked( true );
711 break; 713 break;
712 } 714 }
713 } 715 }
714} 716}
715 717
716void RecurrenceChooser::emitChoice() 718void RecurrenceChooser::emitChoice()
717{ 719{
718 emit chosen ( type() ); 720 emit chosen ( type() );
719} 721}
720 722
721/////////////////////////////// Main Widget ///////////////////////////// 723/////////////////////////////// Main Widget /////////////////////////////
722 724
723KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : 725KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) :
724 QWidget( parent, name ) 726 QWidget( parent, name )
725{ 727{
726 QGridLayout *topLayout = new QGridLayout( this, 2,2 ); 728 QGridLayout *topLayout = new QGridLayout( this, 2,2 );
727 topLayout->setSpacing( KDialog::spacingHint() ); 729 topLayout->setSpacing( KDialog::spacingHint() );
728 topLayout->setMargin( KDialog::marginHintSmall() ); 730 topLayout->setMargin( KDialog::marginHintSmall() );
729 731
730 mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); 732 mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this );
731 connect( mEnabledCheck, SIGNAL( toggled( bool ) ), 733 connect( mEnabledCheck, SIGNAL( toggled( bool ) ),
732 SLOT( setEnabled( bool ) ) ); 734 SLOT( setEnabled( bool ) ) );
733 topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); 735 topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 );
734 736
735 737
736 mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), 738 mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"),
737 this ); 739 this );
738 topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); 740 topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 );
739 741
740 if ( QApplication::desktop()->width() <= 640 ) { 742 if ( QApplication::desktop()->width() <= 640 ) {
741 mTimeGroupBox->hide(); 743 mTimeGroupBox->hide();
742 } 744 }
743 745
744// QFrame *timeFrame = new QFrame( mTimeGroupBox ); 746// QFrame *timeFrame = new QFrame( mTimeGroupBox );
745// QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); 747// QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame );
746// layoutTimeFrame->setSpacing( KDialog::spacingHint() ); 748// layoutTimeFrame->setSpacing( KDialog::spacingHint() );
747 749
748 mDateTimeLabel = new QLabel( mTimeGroupBox ); 750 mDateTimeLabel = new QLabel( mTimeGroupBox );
749// mDateTimeLabel = new QLabel( timeFrame ); 751// mDateTimeLabel = new QLabel( timeFrame );
750// layoutTimeFrame->addWidget( mDateTimeLabel ); 752// layoutTimeFrame->addWidget( mDateTimeLabel );
751 //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); 753 //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) );
752 //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); 754 //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) );
753 mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); 755 mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this );
754 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); 756 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 );
755 mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); 757 mRecurrenceChooser = new RecurrenceChooser( mRuleBox );
756 connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), 758 connect( mRecurrenceChooser, SIGNAL( chosen( int ) ),
757 SLOT( showCurrentRule( int ) ) ); 759 SLOT( showCurrentRule( int ) ) );
758 760
759 761
760 mRuleStack = new QWidgetStack( mRuleBox ); 762 mRuleStack = new QWidgetStack( mRuleBox );
761 763
762 mDaily = new RecurDaily( mRuleStack ); 764 mDaily = new RecurDaily( mRuleStack );
763 mRuleStack->addWidget( mDaily, 0 ); 765 mRuleStack->addWidget( mDaily, 0 );
764 766
765 mWeekly = new RecurWeekly( mRuleStack ); 767 mWeekly = new RecurWeekly( mRuleStack );
766 mRuleStack->addWidget( mWeekly, 0 ); 768 mRuleStack->addWidget( mWeekly, 0 );
767 769
768 mMonthly = new RecurMonthly( mRuleStack ); 770 mMonthly = new RecurMonthly( mRuleStack );
769 mRuleStack->addWidget( mMonthly, 0 ); 771 mRuleStack->addWidget( mMonthly, 0 );
770 772
771 mYearly = new RecurYearly( mRuleStack ); 773 mYearly = new RecurYearly( mRuleStack );
772 mRuleStack->addWidget( mYearly, 0 ); 774 mRuleStack->addWidget( mYearly, 0 );
773 775
774 showCurrentRule( mRecurrenceChooser->type() ); 776 showCurrentRule( mRecurrenceChooser->type() );
775 mRecurrenceRangeWidget = 0; 777 mRecurrenceRangeWidget = 0;
776 mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); 778 mRecurrenceRangeDialog = new RecurrenceRangeDialog( this );
777 mRecurrenceRange = mRecurrenceRangeDialog; 779 mRecurrenceRange = mRecurrenceRangeDialog;
778 mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), 780 mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."),
779 this ); 781 this );
780 782
781 connect( mRecurrenceRangeButton, SIGNAL( clicked() ), 783 connect( mRecurrenceRangeButton, SIGNAL( clicked() ),
782 SLOT( showRecurrenceRangeDialog() ) ); 784 SLOT( showRecurrenceRangeDialog() ) );
783 785
784 mExceptionsWidget = 0; 786 mExceptionsWidget = 0;
785 mExceptionsDialog = new ExceptionsDialog( this ); 787 mExceptionsDialog = new ExceptionsDialog( this );
786 mExceptions = mExceptionsDialog; 788 mExceptions = mExceptionsDialog;
787 mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); 789 mExceptionsButton = new QPushButton( i18n("Exceptions..."), this );
788 if ( QApplication::desktop()->width() < 320 ) { 790 if ( QApplication::desktop()->width() < 320 ) {
789 topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); 791 topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 );
790 topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); 792 topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 );
791 } else { 793 } else {
792 topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); 794 topLayout->addWidget( mRecurrenceRangeButton, 3, 0 );
793 topLayout->addWidget( mExceptionsButton, 3, 1 ); 795 topLayout->addWidget( mExceptionsButton, 3, 1 );
794 } 796 }
795 connect( mExceptionsButton, SIGNAL( clicked() ), 797 connect( mExceptionsButton, SIGNAL( clicked() ),
796 SLOT( showExceptionsDialog() ) ); 798 SLOT( showExceptionsDialog() ) );
797} 799}
798 800
799KOEditorRecurrence::~KOEditorRecurrence() 801KOEditorRecurrence::~KOEditorRecurrence()
800{ 802{
801} 803}
802 804
803void KOEditorRecurrence::setEnabled( bool enabled ) 805void KOEditorRecurrence::setEnabled( bool enabled )
804{ 806{
805// kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; 807// kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl;
806 808
807 mTimeGroupBox->setEnabled( enabled ); 809 mTimeGroupBox->setEnabled( enabled );
808 if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); 810 if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled );
809 if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); 811 if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled );
810 if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); 812 if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled );
811 if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); 813 if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled );
812 mRuleBox->setEnabled( enabled ); 814 mRuleBox->setEnabled( enabled );
813} 815}
814 816
815void KOEditorRecurrence::showCurrentRule( int current ) 817void KOEditorRecurrence::showCurrentRule( int current )
816{ 818{
817 switch ( current ) { 819 switch ( current ) {
818 case Daily: 820 case Daily:
819 mRuleStack->raiseWidget( mDaily ); 821 mRuleStack->raiseWidget( mDaily );
820 break; 822 break;
821 case Weekly: 823 case Weekly:
822 mRuleStack->raiseWidget( mWeekly ); 824 mRuleStack->raiseWidget( mWeekly );
823 break; 825 break;
824 case Monthly: 826 case Monthly:
825 mRuleStack->raiseWidget( mMonthly ); 827 mRuleStack->raiseWidget( mMonthly );
826 break; 828 break;
827 default: 829 default:
828 case Yearly: 830 case Yearly:
829 mRuleStack->raiseWidget( mYearly ); 831 mRuleStack->raiseWidget( mYearly );
830 break; 832 break;
831 } 833 }
832} 834}
833 835
834void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) 836void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end )
835{ 837{
836// kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; 838// kdDebug() << "KOEditorRecurrence::setDateTimes" << endl;
837 839
838 mRecurrenceRange->setDateTimes( start, end ); 840 mRecurrenceRange->setDateTimes( start, end );
839 mExceptions->setDefaults( end ); 841 mExceptions->setDefaults( end );
840 842
841} 843}
842void KOEditorRecurrence::setDefaultsDates( QDateTime from, QDateTime to ) 844void KOEditorRecurrence::setDefaultsDates( QDateTime from, QDateTime to )
843{ 845{
844 setDateTimes( from, to ); 846 setDateTimes( from, to );
845 QBitArray days( 7 ); 847 QBitArray days( 7 );
846 days.fill( 0 ); 848 days.fill( 0 );
847 days.setBit( from.date().dayOfWeek()- 1); 849 days.setBit( from.date().dayOfWeek()- 1);
848 mWeekly->setDays( days ); 850 mWeekly->setDays( days );
849 bool byPos = mMonthly->byPos(); 851 bool byPos = mMonthly->byPos();
850 if ( byPos ) 852 if ( byPos )
851 mMonthly->setByDay( from.date().day()-1 ); 853 mMonthly->setByDay( from.date().day()-1 );
852 mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); 854 mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 );
853 if ( ! byPos) 855 if ( ! byPos)
854 mMonthly->setByDay( from.date().day()-1 ); 856 mMonthly->setByDay( from.date().day()-1 );
855 857
856 bool byDay = mYearly->byDay(); 858 bool byDay = mYearly->byDay();
857 if ( ! byDay ) 859 if ( ! byDay )
858 mYearly->setByDay( from.date().dayOfYear() ); 860 mYearly->setByDay( from.date().dayOfYear() );
859 mYearly->setByMonth( from.date().month(), from.date().day() ); 861 mYearly->setByMonth( from.date().month(), from.date().day() );
860 if ( byDay ) 862 if ( byDay )
861 mYearly->setByDay( from.date().dayOfYear() ); 863 mYearly->setByDay( from.date().dayOfYear() );
862} 864}
863void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to ) 865void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to )
864{ 866{
865 867
866 // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); 868 // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() );
867 //setDateTimes( from, to ); 869 //setDateTimes( from, to );
868 870
869 bool enabled = false; 871 bool enabled = false;
870 mEnabledCheck->setChecked( enabled ); 872 mEnabledCheck->setChecked( enabled );
871 setEnabled( enabled ); 873 setEnabled( enabled );
872 874
873 mExceptions->setDefaults( to ); 875 mExceptions->setDefaults( to );
874 mRecurrenceRange->setDefaults( to ); 876 mRecurrenceRange->setDefaults( to );
875 877
876 mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); 878 mRecurrenceChooser->setType( RecurrenceChooser::Weekly );
877 showCurrentRule( mRecurrenceChooser->type() ); 879 showCurrentRule( mRecurrenceChooser->type() );
878 880
879 mDaily->setFrequency( 1 ); 881 mDaily->setFrequency( 1 );
880 mWeekly->setFrequency( 1 ); 882 mWeekly->setFrequency( 1 );
881 mMonthly->setFrequency( 1 ); 883 mMonthly->setFrequency( 1 );
882 mYearly->setFrequency( 1 ); 884 mYearly->setFrequency( 1 );
883 setDefaultsDates( from, to ); 885 setDefaultsDates( from, to );
884} 886}
885 887
886void KOEditorRecurrence::readEvent(Incidence *event) 888void KOEditorRecurrence::readEvent(Incidence *event)
887{ 889{
888 890
889 QDateTime dtEnd; 891 QDateTime dtEnd;
890 if ( event->typeID() == eventID ) 892 if ( event->typeID() == eventID )
891 dtEnd = ((Event*)event)->dtEnd(); 893 dtEnd = ((Event*)event)->dtEnd();
892 else 894 else
893 dtEnd = ((Todo*)event)->dtDue(); 895 dtEnd = ((Todo*)event)->dtDue();
894 896
895 setDefaults( event->dtStart(), dtEnd ); 897 setDefaults( event->dtStart(), dtEnd );
896 QBitArray rDays( 7 ); 898 QBitArray rDays( 7 );
897 QPtrList<Recurrence::rMonthPos> rmp; 899 QPtrList<Recurrence::rMonthPos> rmp;
898 QPtrList<int> rmd; 900 QPtrList<int> rmd;
899 int day = 0; 901 int day = 0;
900 int count = 0; 902 int count = 0;
901 int month = 0; 903 int month = 0;
902 setDateTimes( event->dtStart(), dtEnd ); 904 setDateTimes( event->dtStart(), dtEnd );
903 905
904 906
905 907
906 int recurs = event->doesRecur(); 908 int recurs = event->doesRecur();
907 909
908 mEnabledCheck->setChecked( recurs ); 910 mEnabledCheck->setChecked( recurs );
909 setEnabled( recurs ); 911 setEnabled( recurs );
910 912
911 int recurrenceType = RecurrenceChooser::Weekly; 913 int recurrenceType = RecurrenceChooser::Weekly;
912 if ( recurs ) { 914 if ( recurs ) {
913 Recurrence *r = event->recurrence(); 915 Recurrence *r = event->recurrence();
914 int f = r->frequency(); 916 int f = r->frequency();
915 switch ( recurs ) { 917 switch ( recurs ) {
916 case Recurrence::rNone: 918 case Recurrence::rNone:
917 setDefaults( event->dtStart(), dtEnd ); 919 setDefaults( event->dtStart(), dtEnd );
918 break; 920 break;
919 case Recurrence::rDaily: 921 case Recurrence::rDaily:
920 recurrenceType = RecurrenceChooser::Daily; 922 recurrenceType = RecurrenceChooser::Daily;
921 mDaily->setFrequency( f ); 923 mDaily->setFrequency( f );
922 break; 924 break;
923 case Recurrence::rWeekly: 925 case Recurrence::rWeekly:
924 recurrenceType = RecurrenceChooser::Weekly; 926 recurrenceType = RecurrenceChooser::Weekly;
925 mWeekly->setFrequency( f ); 927 mWeekly->setFrequency( f );
926 mWeekly->setDays( r->days() ); 928 mWeekly->setDays( r->days() );
927 break; 929 break;
928 case Recurrence::rMonthlyPos: 930 case Recurrence::rMonthlyPos:
929 // we only handle one possibility in the list right now, 931 // we only handle one possibility in the list right now,
930 // so I have hardcoded calls with first(). If we make the GUI 932 // so I have hardcoded calls with first(). If we make the GUI
931 // more extended, this can be changed. 933 // more extended, this can be changed.
932 recurrenceType = RecurrenceChooser::Monthly; 934 recurrenceType = RecurrenceChooser::Monthly;
933 935
934 rmp = r->monthPositions(); 936 rmp = r->monthPositions();
935 if ( rmp.first()->negative ) 937 if ( rmp.first()->negative )
936 count = 5 - rmp.first()->rPos - 1; 938 count = 5 - rmp.first()->rPos - 1;
937 else 939 else
938 count = rmp.first()->rPos - 1; 940 count = rmp.first()->rPos - 1;
939 day = 0; 941 day = 0;
940 while ( !rmp.first()->rDays.testBit( day ) ) ++day; 942 while ( !rmp.first()->rDays.testBit( day ) ) ++day;
941 mMonthly->setByPos( count, day ); 943 mMonthly->setByPos( count, day );
942 944
943 mMonthly->setFrequency( f ); 945 mMonthly->setFrequency( f );
944 946
945 break; 947 break;
946 case Recurrence::rMonthlyDay: 948 case Recurrence::rMonthlyDay:
947 recurrenceType = RecurrenceChooser::Monthly; 949 recurrenceType = RecurrenceChooser::Monthly;
948 950
949 rmd = r->monthDays(); 951 rmd = r->monthDays();
950 day = *rmd.first() - 1; 952 day = *rmd.first() - 1;
951 mMonthly->setByDay( day ); 953 mMonthly->setByDay( day );
952 954
953 mMonthly->setFrequency( f ); 955 mMonthly->setFrequency( f );
954 956
955 break; 957 break;
956 case Recurrence::rYearlyMonth: 958 case Recurrence::rYearlyMonth:
957 { 959 {
958 recurrenceType = RecurrenceChooser::Yearly; 960 recurrenceType = RecurrenceChooser::Yearly;
959 //qDebug("Recurrence::rYearlyMonth: "); 961 //qDebug("Recurrence::rYearlyMonth: ");
960 day = event->dtStart().date().day(); 962 day = event->dtStart().date().day();
961 rmd = r->yearNums(); 963 rmd = r->yearNums();
962 if ( rmd.count() > 0 ) 964 if ( rmd.count() > 0 )
963 month = *rmd.first(); 965 month = *rmd.first();
964 else 966 else
965 month = event->dtStart().date().month() ; 967 month = event->dtStart().date().month() ;
966 mYearly->setByMonth( month, day ); 968 mYearly->setByMonth( month, day );
967#if 0 969#if 0
968 //qDebug("2day = %d ",day ); 970 //qDebug("2day = %d ",day );
969 QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); 971 QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions();
970 int month; 972 int month;
971 if ( !monthlist.isEmpty() ) { 973 if ( !monthlist.isEmpty() ) {
972 month = monthlist.first()->rPos ; 974 month = monthlist.first()->rPos ;
973 } else { 975 } else {
974 month = event->dtStart().date().month() ; 976 month = event->dtStart().date().month() ;
975 } 977 }
976 mYearly->setByMonth( day, month ); 978 mYearly->setByMonth( day, month );
977#endif 979#endif
978 mYearly->setFrequency( f ); 980 mYearly->setFrequency( f );
979 } 981 }
980 982
981 break; 983 break;
982 case Recurrence::rYearlyDay: 984 case Recurrence::rYearlyDay:
983 //qDebug("Recurrence::rYearlyDay: "); 985 //qDebug("Recurrence::rYearlyDay: ");
984 recurrenceType = RecurrenceChooser::Yearly; 986 recurrenceType = RecurrenceChooser::Yearly;
985 mYearly->setByDay( event->dtStart().date().dayOfYear() ); 987 mYearly->setByDay( event->dtStart().date().dayOfYear() );
986 mYearly->setFrequency( f ); 988 mYearly->setFrequency( f );
987 break; 989 break;
988 default: 990 default:
989 setDefaults( event->dtStart(), dtEnd ); 991 setDefaults( event->dtStart(), dtEnd );
990 break; 992 break;
991 } 993 }
992 } 994 }
993 mRecurrenceChooser->setType( recurrenceType ); 995 mRecurrenceChooser->setType( recurrenceType );
994 showCurrentRule( recurrenceType ); 996 showCurrentRule( recurrenceType );
995 997
996 mRecurrenceRange->setDateTimes( event->dtStart() ); 998 mRecurrenceRange->setDateTimes( event->dtStart() );
997 999
998 if ( event->doesRecur() ) { 1000 if ( event->doesRecur() ) {
999 Recurrence *r = event->recurrence(); 1001 Recurrence *r = event->recurrence();
1000 mRecurrenceRange->setDuration( r->duration() ); 1002 mRecurrenceRange->setDuration( r->duration() );
1001 if ( r->duration() == 0 ) 1003 if ( r->duration() == 0 )
1002 { 1004 {
1003 if ( r->endDate() < event->dtStart().date() ) 1005 if ( r->endDate() < event->dtStart().date() )
1004 mRecurrenceRange->setEndDate( event->dtStart().date() ); 1006 mRecurrenceRange->setEndDate( event->dtStart().date() );
1005 else 1007 else
1006 mRecurrenceRange->setEndDate( r->endDate() ); 1008 mRecurrenceRange->setEndDate( r->endDate() );
1007 } else 1009 } else
1008 mRecurrenceRange->setEndDate( event->dtStart().date() ); 1010 mRecurrenceRange->setEndDate( event->dtStart().date() );
1009 } 1011 }
1010 1012
1011 mExceptions->setDates( event->exDates() ); 1013 mExceptions->setDates( event->exDates() );
1012} 1014}
1013 1015
1014void KOEditorRecurrence::writeEvent( Incidence *event ) 1016void KOEditorRecurrence::writeEvent( Incidence *event )
1015{ 1017{
1016 1018
1017 1019
1018 if ( !mEnabledCheck->isChecked() ) { 1020 if ( !mEnabledCheck->isChecked() ) {
1019 if ( event->doesRecur() ) 1021 if ( event->doesRecur() )
1020 event->recurrence()->unsetRecurs(); 1022 event->recurrence()->unsetRecurs();
1021 } else { 1023 } else {
1022 Recurrence *r = event->recurrence(); 1024 Recurrence *r = event->recurrence();
1023 1025
1024 // clear out any old settings; 1026 // clear out any old settings;
1025 r->unsetRecurs(); 1027 r->unsetRecurs();
1026 int duration = mRecurrenceRange->duration(); 1028 int duration = mRecurrenceRange->duration();
1027 QDate endDate; 1029 QDate endDate;
1028 if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); 1030 if ( duration == 0 ) endDate = mRecurrenceRange->endDate();
1029 1031
1030 int recurrenceType = mRecurrenceChooser->type(); 1032 int recurrenceType = mRecurrenceChooser->type();
1031 1033
1032 if ( recurrenceType == RecurrenceChooser::Daily ) { 1034 if ( recurrenceType == RecurrenceChooser::Daily ) {
1033 int freq = mDaily->frequency(); 1035 int freq = mDaily->frequency();
1034 if ( duration != 0 ) r->setDaily( freq, duration ); 1036 if ( duration != 0 ) r->setDaily( freq, duration );
1035 else r->setDaily( freq, endDate ); 1037 else r->setDaily( freq, endDate );
1036 } else if ( recurrenceType == RecurrenceChooser::Weekly ) { 1038 } else if ( recurrenceType == RecurrenceChooser::Weekly ) {
1037 int freq = mWeekly->frequency(); 1039 int freq = mWeekly->frequency();
1038 QBitArray days = mWeekly->days(); 1040 QBitArray days = mWeekly->days();
1039 int j; 1041 int j;
1040 bool found = false; 1042 bool found = false;
1041 for (j = 0; j < 7 ; ++j ) { 1043 for (j = 0; j < 7 ; ++j ) {
1042 found |=days.at(j); 1044 found |=days.at(j);
1043 } 1045 }
1044 if ( !found ) { 1046 if ( !found ) {
1045 days.setBit( event->dtStart().date().dayOfWeek()-1); 1047 days.setBit( event->dtStart().date().dayOfWeek()-1);
1046 //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); 1048 //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1);
1047 } 1049 }
1048 if ( duration != 0 ) r->setWeekly( freq, days, duration ); 1050 if ( duration != 0 ) r->setWeekly( freq, days, duration );
1049 else r->setWeekly( freq, days, endDate ); 1051 else r->setWeekly( freq, days, endDate );
1050 } else if ( recurrenceType == RecurrenceChooser::Monthly ) { 1052 } else if ( recurrenceType == RecurrenceChooser::Monthly ) {
1051 int freq = mMonthly->frequency(); 1053 int freq = mMonthly->frequency();
1052 if ( mMonthly->byPos() ) { 1054 if ( mMonthly->byPos() ) {
1053 int pos = mMonthly->count(); 1055 int pos = mMonthly->count();
1054 1056
1055 QBitArray days( 7 ); 1057 QBitArray days( 7 );
1056 days.fill( false ); 1058 days.fill( false );
1057 1059
1058 days.setBit( mMonthly->weekday() ); 1060 days.setBit( mMonthly->weekday() );
1059 if ( duration != 0 ) 1061 if ( duration != 0 )
1060 r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); 1062 r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
1061 else 1063 else
1062 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 1064 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
1063 r->addMonthlyPos( pos, days ); 1065 r->addMonthlyPos( pos, days );
1064 } else { 1066 } else {
1065 // it's by day 1067 // it's by day
1066 int day = mMonthly->day(); 1068 int day = mMonthly->day();
1067 1069
1068 if ( duration != 0 ) { 1070 if ( duration != 0 ) {
1069 r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); 1071 r->setMonthly( Recurrence::rMonthlyDay, freq, duration );
1070 } else { 1072 } else {
1071 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 1073 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
1072 } 1074 }
1073 r->addMonthlyDay( day ); 1075 r->addMonthlyDay( day );
1074 } 1076 }
1075 } else if ( recurrenceType == RecurrenceChooser::Yearly ) { 1077 } else if ( recurrenceType == RecurrenceChooser::Yearly ) {
1076 //qDebug("RecurrenceChooser::Yearly "); 1078 //qDebug("RecurrenceChooser::Yearly ");
1077 int freq = mYearly->frequency(); 1079 int freq = mYearly->frequency();
1078 if ( mYearly->byDay() ) { 1080 if ( mYearly->byDay() ) {
1079 if ( duration != 0 ) { 1081 if ( duration != 0 ) {
1080 r->setYearly( Recurrence::rYearlyDay, freq, duration ); 1082 r->setYearly( Recurrence::rYearlyDay, freq, duration );
1081 } else { 1083 } else {
1082 r->setYearly( Recurrence::rYearlyDay, freq, endDate ); 1084 r->setYearly( Recurrence::rYearlyDay, freq, endDate );
1083 } 1085 }
1084 r->addYearlyNum( event->dtStart().date().dayOfYear() ); 1086 r->addYearlyNum( event->dtStart().date().dayOfYear() );
1085 } else { 1087 } else {
1086 if ( duration != 0 ) { 1088 if ( duration != 0 ) {
1087 r->setYearly( Recurrence::rYearlyMonth, freq, duration ); 1089 r->setYearly( Recurrence::rYearlyMonth, freq, duration );
1088 } else { 1090 } else {
1089 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 1091 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
1090 } 1092 }
1091 r->addYearlyNum( mYearly->month() ); 1093 r->addYearlyNum( mYearly->month() );
1092 } 1094 }
1093 1095
1094 } 1096 }
1095 1097
1096 event->setExDates( mExceptions->dates() ); 1098 event->setExDates( mExceptions->dates() );
1097 } 1099 }
1098} 1100}
1099 1101
1100void KOEditorRecurrence::setDateTimeStr( const QString &str ) 1102void KOEditorRecurrence::setDateTimeStr( const QString &str )
1101{ 1103{
1102 mDateTimeLabel->setText( str ); 1104 mDateTimeLabel->setText( str );
1103} 1105}
1104 1106
1105bool KOEditorRecurrence::validateInput() 1107bool KOEditorRecurrence::validateInput()
1106{ 1108{
1107 // Check input here 1109 // Check input here
1108 1110
1109 return true; 1111 return true;
1110} 1112}
1111 1113
1112void KOEditorRecurrence::showExceptionsDialog() 1114void KOEditorRecurrence::showExceptionsDialog()
1113{ 1115{
1114 DateList dates = mExceptions->dates(); 1116 DateList dates = mExceptions->dates();
1115 int result = mExceptionsDialog->exec(); 1117 int result = mExceptionsDialog->exec();
1116 if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); 1118 if ( result == QDialog::Rejected ) mExceptions->setDates( dates );
1117} 1119}
1118 1120
1119void KOEditorRecurrence::showRecurrenceRangeDialog() 1121void KOEditorRecurrence::showRecurrenceRangeDialog()
1120{ 1122{
1121 int duration = mRecurrenceRange->duration(); 1123 int duration = mRecurrenceRange->duration();
1122 QDate endDate = mRecurrenceRange->endDate(); 1124 QDate endDate = mRecurrenceRange->endDate();
1123 1125
1124 int result = mRecurrenceRangeDialog->exec(); 1126 int result = mRecurrenceRangeDialog->exec();
1125 if ( result == QDialog::Rejected ) { 1127 if ( result == QDialog::Rejected ) {
1126 mRecurrenceRange->setDuration( duration ); 1128 mRecurrenceRange->setDuration( duration );
1127 mRecurrenceRange->setEndDate( endDate ); 1129 mRecurrenceRange->setEndDate( endDate );
1128 } 1130 }
1129 1131
1130} 1132}