-rw-r--r-- | libopie2/opiepim/ui/opimrecurrencewidget.cpp | 8 | ||||
-rw-r--r-- | libopie2/opiepim/ui/opimrecurrencewidget.h | 10 |
2 files changed, 9 insertions, 9 deletions
diff --git a/libopie2/opiepim/ui/opimrecurrencewidget.cpp b/libopie2/opiepim/ui/opimrecurrencewidget.cpp index 90c1a5f..ee7f3a3 100644 --- a/libopie2/opiepim/ui/opimrecurrencewidget.cpp +++ b/libopie2/opiepim/ui/opimrecurrencewidget.cpp | |||
@@ -1,634 +1,636 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qlabel.h> | 2 | #include <qlabel.h> |
3 | #include <qpopupmenu.h> | 3 | #include <qpopupmenu.h> |
4 | #include <qspinbox.h> | 4 | #include <qspinbox.h> |
5 | 5 | ||
6 | #include <qpe/timestring.h> | 6 | #include <qpe/timestring.h> |
7 | 7 | ||
8 | #include "opimrecurrencewidget.h" | 8 | #include "opimrecurrencewidget.h" |
9 | 9 | ||
10 | |||
11 | using namespace Opie; | ||
10 | // Global Templates for use in setting up the repeat label... | 12 | // Global Templates for use in setting up the repeat label... |
11 | // the problem is these strings get initialized before QPEApplication can install the translator -zecke | 13 | // the problem is these strings get initialized before QPEApplication can install the translator -zecke |
12 | namespace { | 14 | namespace { |
13 | QString strDayTemplate; | 15 | QString strDayTemplate; |
14 | QString strYearTemplate; | 16 | QString strYearTemplate; |
15 | QString strMonthDateTemplate; | 17 | QString strMonthDateTemplate; |
16 | QString strMonthDayTemplate; | 18 | QString strMonthDayTemplate; |
17 | QString strWeekTemplate; | 19 | QString strWeekTemplate; |
18 | QString dayLabel[7]; | 20 | QString dayLabel[7]; |
19 | } | 21 | } |
20 | 22 | ||
21 | /* | 23 | /* |
22 | * static linkage to not polute the symbol table... | 24 | * static linkage to not polute the symbol table... |
23 | * The problem is that const and static linkage are resolved prior to installing a translator | 25 | * The problem is that const and static linkage are resolved prior to installing a translator |
24 | * leading to that the above strings are translted but to the original we delay the init of these strings... | 26 | * leading to that the above strings are translted but to the original we delay the init of these strings... |
25 | * -zecke | 27 | * -zecke |
26 | */ | 28 | */ |
27 | static void fillStrings() { | 29 | static void fillStrings() { |
28 | strDayTemplate = QObject::tr("Every"); | 30 | strDayTemplate = QObject::tr("Every"); |
29 | strYearTemplate = QObject::tr("%1 %2 every "); | 31 | strYearTemplate = QObject::tr("%1 %2 every "); |
30 | strMonthDateTemplate = QObject::tr("The %1 every "); | 32 | strMonthDateTemplate = QObject::tr("The %1 every "); |
31 | strMonthDayTemplate = QObject::tr("The %1 %2 of every"); | 33 | strMonthDayTemplate = QObject::tr("The %1 %2 of every"); |
32 | strWeekTemplate = QObject::tr("Every "); | 34 | strWeekTemplate = QObject::tr("Every "); |
33 | dayLabel[0] = QObject::tr("Monday"); | 35 | dayLabel[0] = QObject::tr("Monday"); |
34 | dayLabel[1] = QObject::tr("Tuesday"); | 36 | dayLabel[1] = QObject::tr("Tuesday"); |
35 | dayLabel[2] = QObject::tr("Wednesday"); | 37 | dayLabel[2] = QObject::tr("Wednesday"); |
36 | dayLabel[3] = QObject::tr("Thursday"); | 38 | dayLabel[3] = QObject::tr("Thursday"); |
37 | dayLabel[4] = QObject::tr("Friday"); | 39 | dayLabel[4] = QObject::tr("Friday"); |
38 | dayLabel[5] = QObject::tr("Saturday"); | 40 | dayLabel[5] = QObject::tr("Saturday"); |
39 | dayLabel[6] = QObject::tr("Sunday"); | 41 | dayLabel[6] = QObject::tr("Sunday"); |
40 | } | 42 | } |
41 | 43 | ||
42 | static QString numberPlacing( int x );// return the proper word format for | 44 | static QString numberPlacing( int x );// return the proper word format for |
43 | // x (1st, 2nd, etc) | 45 | // x (1st, 2nd, etc) |
44 | static int week( const QDate &dt ); // what week in the month is dt? | 46 | static int week( const QDate &dt ); // what week in the month is dt? |
45 | 47 | ||
46 | /** | 48 | /** |
47 | * Constructs the Widget | 49 | * Constructs the Widget |
48 | * @param startOnMonday Does the week start on monday | 50 | * @param startOnMonday Does the week start on monday |
49 | * @param newStart The start date of the recurrence | 51 | * @param newStart The start date of the recurrence |
50 | * @param parent The parent widget | 52 | * @param parent The parent widget |
51 | * @param name the name of object | 53 | * @param name the name of object |
52 | * @param modal if the dialog should be modal | 54 | * @param modal if the dialog should be modal |
53 | * @param fl Additional window flags | 55 | * @param fl Additional window flags |
54 | */ | 56 | */ |
55 | OPimRecurrenceWidget::OPimRecurrenceWidget( bool startOnMonday, | 57 | OPimRecurrenceWidget::OPimRecurrenceWidget( bool startOnMonday, |
56 | const QDate& newStart, | 58 | const QDate& newStart, |
57 | QWidget* parent, | 59 | QWidget* parent, |
58 | const char* name, | 60 | const char* name, |
59 | bool modal, | 61 | bool modal, |
60 | WFlags fl ) | 62 | WFlags fl ) |
61 | : OPimRecurrenceBase( parent, name, modal, fl ), | 63 | : OPimRecurrenceBase( parent, name, modal, fl ), |
62 | start( newStart ), | 64 | start( newStart ), |
63 | currInterval( None ), | 65 | currInterval( None ), |
64 | startWeekOnMonday( startOnMonday ) | 66 | startWeekOnMonday( startOnMonday ) |
65 | { | 67 | { |
66 | if (strDayTemplate.isEmpty() ) | 68 | if (strDayTemplate.isEmpty() ) |
67 | fillStrings(); | 69 | fillStrings(); |
68 | 70 | ||
69 | init(); | 71 | init(); |
70 | fraType->setButton( currInterval ); | 72 | fraType->setButton( currInterval ); |
71 | chkNoEnd->setChecked( TRUE ); | 73 | chkNoEnd->setChecked( TRUE ); |
72 | setupNone(); | 74 | setupNone(); |
73 | } | 75 | } |
74 | 76 | ||
75 | /** | 77 | /** |
76 | * Different constructor | 78 | * Different constructor |
77 | * @param startOnMonday Does the week start on monday? | 79 | * @param startOnMonday Does the week start on monday? |
78 | * @param rp Already set OPimRecurrence object | 80 | * @param rp Already set OPimRecurrence object |
79 | * @param startDate The start date | 81 | * @param startDate The start date |
80 | * @param parent The parent widget | 82 | * @param parent The parent widget |
81 | * @param name The name of the object | 83 | * @param name The name of the object |
82 | * @param modal | 84 | * @param modal |
83 | * @param fl The flags for window | 85 | * @param fl The flags for window |
84 | */ | 86 | */ |
85 | OPimRecurrenceWidget::OPimRecurrenceWidget( bool startOnMonday, | 87 | OPimRecurrenceWidget::OPimRecurrenceWidget( bool startOnMonday, |
86 | const OPimRecurrence& rp, const QDate& startDate, | 88 | const Opie::OPimRecurrence& rp, const QDate& startDate, |
87 | QWidget* parent, const char* name, | 89 | QWidget* parent, const char* name, |
88 | bool modal, WFlags fl) | 90 | bool modal, WFlags fl) |
89 | : OPimRecurrenceBase( parent, name, modal, fl ), | 91 | : OPimRecurrenceBase( parent, name, modal, fl ), |
90 | start( startDate ), | 92 | start( startDate ), |
91 | end( rp.endDate() ), | 93 | end( rp.endDate() ), |
92 | startWeekOnMonday( startOnMonday ) | 94 | startWeekOnMonday( startOnMonday ) |
93 | { | 95 | { |
94 | if (strDayTemplate.isEmpty() ) | 96 | if (strDayTemplate.isEmpty() ) |
95 | fillStrings(); | 97 | fillStrings(); |
96 | // do some stuff with the repeat pattern | 98 | // do some stuff with the repeat pattern |
97 | init(); | 99 | init(); |
98 | setRecurrence( rp ); | 100 | setRecurrence( rp ); |
99 | } | 101 | } |
100 | 102 | ||
101 | OPimRecurrenceWidget::~OPimRecurrenceWidget() { | 103 | OPimRecurrenceWidget::~OPimRecurrenceWidget() { |
102 | } | 104 | } |
103 | 105 | ||
104 | /** | 106 | /** |
105 | * set the start date | 107 | * set the start date |
106 | * @param date the new start date | 108 | * @param date the new start date |
107 | */ | 109 | */ |
108 | void OPimRecurrenceWidget::setStartDate( const QDate& date ) { | 110 | void OPimRecurrenceWidget::setStartDate( const QDate& date ) { |
109 | setRecurrence( recurrence(), date ); | 111 | setRecurrence( recurrence(), date ); |
110 | } | 112 | } |
111 | /** | 113 | /** |
112 | * set the recurrence | 114 | * set the recurrence |
113 | * @param rp The OPimRecurrence object with the new recurrence rules | 115 | * @param rp The OPimRecurrence object with the new recurrence rules |
114 | */ | 116 | */ |
115 | void OPimRecurrenceWidget::setRecurrence( const OPimRecurrence& rp ) { | 117 | void OPimRecurrenceWidget::setRecurrence( const Opie::OPimRecurrence& rp ) { |
116 | setRecurrence( rp, start ); | 118 | setRecurrence( rp, start ); |
117 | } | 119 | } |
118 | 120 | ||
119 | /** | 121 | /** |
120 | * overloaded method taking OPimRecurrence and a new start date | 122 | * overloaded method taking OPimRecurrence and a new start date |
121 | * @param rp Recurrence rule | 123 | * @param rp Recurrence rule |
122 | * @param date The new start date | 124 | * @param date The new start date |
123 | */ | 125 | */ |
124 | void OPimRecurrenceWidget::setRecurrence( const OPimRecurrence& rp, const QDate& date ) { | 126 | void OPimRecurrenceWidget::setRecurrence( const Opie::OPimRecurrence& rp, const QDate& date ) { |
125 | start = date; | 127 | start = date; |
126 | end = rp.endDate(); | 128 | end = rp.endDate(); |
127 | switch ( rp.type() ) { | 129 | switch ( rp.type() ) { |
128 | default: | 130 | default: |
129 | case OPimRecurrence::NoRepeat: | 131 | case OPimRecurrence::NoRepeat: |
130 | currInterval = None; | 132 | currInterval = None; |
131 | setupNone(); | 133 | setupNone(); |
132 | break; | 134 | break; |
133 | case OPimRecurrence::Daily: | 135 | case OPimRecurrence::Daily: |
134 | currInterval = Day; | 136 | currInterval = Day; |
135 | setupDaily(); | 137 | setupDaily(); |
136 | break; | 138 | break; |
137 | case OPimRecurrence::Weekly: | 139 | case OPimRecurrence::Weekly: |
138 | currInterval = Week; | 140 | currInterval = Week; |
139 | setupWeekly(); | 141 | setupWeekly(); |
140 | int day, buttons; | 142 | int day, buttons; |
141 | for ( day = 0x01, buttons = 0; buttons < 7; | 143 | for ( day = 0x01, buttons = 0; buttons < 7; |
142 | day = day << 1, buttons++ ) { | 144 | day = day << 1, buttons++ ) { |
143 | if ( rp.days() & day ) { | 145 | if ( rp.days() & day ) { |
144 | if ( startWeekOnMonday ) | 146 | if ( startWeekOnMonday ) |
145 | fraExtra->setButton( buttons ); | 147 | fraExtra->setButton( buttons ); |
146 | else { | 148 | else { |
147 | if ( buttons == 7 ) | 149 | if ( buttons == 7 ) |
148 | fraExtra->setButton( 0 ); | 150 | fraExtra->setButton( 0 ); |
149 | else | 151 | else |
150 | fraExtra->setButton( buttons + 1 ); | 152 | fraExtra->setButton( buttons + 1 ); |
151 | } | 153 | } |
152 | } | 154 | } |
153 | } | 155 | } |
154 | slotWeekLabel(); | 156 | slotWeekLabel(); |
155 | break; | 157 | break; |
156 | case OPimRecurrence::MonthlyDay: | 158 | case OPimRecurrence::MonthlyDay: |
157 | currInterval = Month; | 159 | currInterval = Month; |
158 | setupMonthly(); | 160 | setupMonthly(); |
159 | fraExtra->setButton( 0 ); | 161 | fraExtra->setButton( 0 ); |
160 | slotMonthLabel( 0 ); | 162 | slotMonthLabel( 0 ); |
161 | break; | 163 | break; |
162 | case OPimRecurrence::MonthlyDate: | 164 | case OPimRecurrence::MonthlyDate: |
163 | currInterval = Month; | 165 | currInterval = Month; |
164 | setupMonthly(); | 166 | setupMonthly(); |
165 | fraExtra->setButton( 1 ); | 167 | fraExtra->setButton( 1 ); |
166 | slotMonthLabel( 1 ); | 168 | slotMonthLabel( 1 ); |
167 | break; | 169 | break; |
168 | case OPimRecurrence::Yearly: | 170 | case OPimRecurrence::Yearly: |
169 | currInterval = Year; | 171 | currInterval = Year; |
170 | setupYearly(); | 172 | setupYearly(); |
171 | break; | 173 | break; |
172 | } | 174 | } |
173 | fraType->setButton( currInterval ); | 175 | fraType->setButton( currInterval ); |
174 | spinFreq->setValue( rp.frequency() ); | 176 | spinFreq->setValue( rp.frequency() ); |
175 | if ( !rp.hasEndDate() ) { | 177 | if ( !rp.hasEndDate() ) { |
176 | cmdEnd->setText( tr("No End Date") ); | 178 | cmdEnd->setText( tr("No End Date") ); |
177 | chkNoEnd->setChecked( TRUE ); | 179 | chkNoEnd->setChecked( TRUE ); |
178 | } else | 180 | } else |
179 | cmdEnd->setText( TimeString::shortDate( end ) ); | 181 | cmdEnd->setText( TimeString::shortDate( end ) ); |
180 | } | 182 | } |
181 | 183 | ||
182 | /** | 184 | /** |
183 | * the user selected recurrence rule. | 185 | * the user selected recurrence rule. |
184 | * @return The recurrence rule. | 186 | * @return The recurrence rule. |
185 | */ | 187 | */ |
186 | OPimRecurrence OPimRecurrenceWidget::recurrence()const { | 188 | OPimRecurrence OPimRecurrenceWidget::recurrence()const { |
187 | QListIterator<QToolButton> it( listRTypeButtons ); | 189 | QListIterator<QToolButton> it( listRTypeButtons ); |
188 | QListIterator<QToolButton> itExtra( listExtra ); | 190 | QListIterator<QToolButton> itExtra( listExtra ); |
189 | OPimRecurrence rpTmp; | 191 | OPimRecurrence rpTmp; |
190 | int i; | 192 | int i; |
191 | for ( i = 0; *it; ++it, i++ ) { | 193 | for ( i = 0; *it; ++it, i++ ) { |
192 | if ( (*it)->isOn() ) { | 194 | if ( (*it)->isOn() ) { |
193 | switch ( i ) { | 195 | switch ( i ) { |
194 | case None: | 196 | case None: |
195 | rpTmp.setType( OPimRecurrence::NoRepeat ); | 197 | rpTmp.setType( OPimRecurrence::NoRepeat ); |
196 | break; | 198 | break; |
197 | case Day: | 199 | case Day: |
198 | rpTmp.setType( OPimRecurrence::Daily ); | 200 | rpTmp.setType( OPimRecurrence::Daily ); |
199 | break; | 201 | break; |
200 | case Week:{ | 202 | case Week:{ |
201 | rpTmp.setType( OPimRecurrence::Weekly ); | 203 | rpTmp.setType( OPimRecurrence::Weekly ); |
202 | int day; | 204 | int day; |
203 | int day2 = 0; | 205 | int day2 = 0; |
204 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { | 206 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { |
205 | if ( (*itExtra)->isOn() ) { | 207 | if ( (*itExtra)->isOn() ) { |
206 | if ( startWeekOnMonday ) | 208 | if ( startWeekOnMonday ) |
207 | day2 |= day; | 209 | day2 |= day; |
208 | else { | 210 | else { |
209 | if ( day == 1 ) | 211 | if ( day == 1 ) |
210 | day2 |= Event::SUN; | 212 | day2 |= Event::SUN; |
211 | else | 213 | else |
212 | day2 |= day >> 1; | 214 | day2 |= day >> 1; |
213 | } | 215 | } |
214 | } | 216 | } |
215 | } | 217 | } |
216 | rpTmp.setDays( day2 ); | 218 | rpTmp.setDays( day2 ); |
217 | } | 219 | } |
218 | break; | 220 | break; |
219 | case Month: | 221 | case Month: |
220 | if ( cmdExtra1->isOn() ) | 222 | if ( cmdExtra1->isOn() ) |
221 | rpTmp.setType( OPimRecurrence::MonthlyDay ); | 223 | rpTmp.setType( OPimRecurrence::MonthlyDay ); |
222 | else if ( cmdExtra2->isOn() ) | 224 | else if ( cmdExtra2->isOn() ) |
223 | rpTmp.setType( OPimRecurrence::MonthlyDate ); | 225 | rpTmp.setType( OPimRecurrence::MonthlyDate ); |
224 | // figure out the montly day... | 226 | // figure out the montly day... |
225 | rpTmp.setPosition( week( start ) ); | 227 | rpTmp.setPosition( week( start ) ); |
226 | break; | 228 | break; |
227 | case Year: | 229 | case Year: |
228 | rpTmp.setType( OPimRecurrence::Yearly ); | 230 | rpTmp.setType( OPimRecurrence::Yearly ); |
229 | break; | 231 | break; |
230 | } | 232 | } |
231 | break; // no need to keep looking! | 233 | break; // no need to keep looking! |
232 | } | 234 | } |
233 | } | 235 | } |
234 | rpTmp.setFrequency(spinFreq->value() ); | 236 | rpTmp.setFrequency(spinFreq->value() ); |
235 | rpTmp.setHasEndDate( !chkNoEnd->isChecked() ); | 237 | rpTmp.setHasEndDate( !chkNoEnd->isChecked() ); |
236 | if ( rpTmp.hasEndDate() ) { | 238 | if ( rpTmp.hasEndDate() ) { |
237 | rpTmp.setEndDate( end ); | 239 | rpTmp.setEndDate( end ); |
238 | } | 240 | } |
239 | // timestamp it... | 241 | // timestamp it... |
240 | // rpTmp.setCreateTime( ); current DateTime is already set -zecke | 242 | // rpTmp.setCreateTime( ); current DateTime is already set -zecke |
241 | return rpTmp; | 243 | return rpTmp; |
242 | } | 244 | } |
243 | 245 | ||
244 | /** | 246 | /** |
245 | * Return the end date of the recurrence. This is only | 247 | * Return the end date of the recurrence. This is only |
246 | * valid if the recurrence rule does contain an enddate | 248 | * valid if the recurrence rule does contain an enddate |
247 | */ | 249 | */ |
248 | QDate OPimRecurrenceWidget::endDate()const { | 250 | QDate OPimRecurrenceWidget::endDate()const { |
249 | return end; | 251 | return end; |
250 | } | 252 | } |
251 | void OPimRecurrenceWidget::slotSetRType(int rtype) { | 253 | void OPimRecurrenceWidget::slotSetRType(int rtype) { |
252 | // now call the right function based on the type... | 254 | // now call the right function based on the type... |
253 | currInterval = static_cast<repeatButtons>(rtype); | 255 | currInterval = static_cast<repeatButtons>(rtype); |
254 | switch ( currInterval ) { | 256 | switch ( currInterval ) { |
255 | case None: | 257 | case None: |
256 | setupNone(); | 258 | setupNone(); |
257 | break; | 259 | break; |
258 | case Day: | 260 | case Day: |
259 | setupDaily(); | 261 | setupDaily(); |
260 | break; | 262 | break; |
261 | case Week: | 263 | case Week: |
262 | setupWeekly(); | 264 | setupWeekly(); |
263 | slotWeekLabel(); | 265 | slotWeekLabel(); |
264 | break; | 266 | break; |
265 | case Month: | 267 | case Month: |
266 | setupMonthly(); | 268 | setupMonthly(); |
267 | cmdExtra2->setOn( TRUE ); | 269 | cmdExtra2->setOn( TRUE ); |
268 | slotMonthLabel( 1 ); | 270 | slotMonthLabel( 1 ); |
269 | break; | 271 | break; |
270 | case Year: | 272 | case Year: |
271 | setupYearly(); | 273 | setupYearly(); |
272 | break; | 274 | break; |
273 | } | 275 | } |
274 | } | 276 | } |
275 | void OPimRecurrenceWidget::endDateChanged(int y, int m, int d) { | 277 | void OPimRecurrenceWidget::endDateChanged(int y, int m, int d) { |
276 | end.setYMD( y, m, d ); | 278 | end.setYMD( y, m, d ); |
277 | if ( end < start ) | 279 | if ( end < start ) |
278 | end = start; | 280 | end = start; |
279 | cmdEnd->setText( TimeString::shortDate( end ) ); | 281 | cmdEnd->setText( TimeString::shortDate( end ) ); |
280 | repeatPicker->setDate( end.year(), end.month(), end.day() ); | 282 | repeatPicker->setDate( end.year(), end.month(), end.day() ); |
281 | } | 283 | } |
282 | void OPimRecurrenceWidget::slotNoEnd( bool unused) { | 284 | void OPimRecurrenceWidget::slotNoEnd( bool unused) { |
283 | // if the item was toggled, then go ahead and set it to the maximum date | 285 | // if the item was toggled, then go ahead and set it to the maximum date |
284 | if ( unused ) { | 286 | if ( unused ) { |
285 | end.setYMD( 3000, 12, 31 ); | 287 | end.setYMD( 3000, 12, 31 ); |
286 | cmdEnd->setText( tr("No End Date") ); | 288 | cmdEnd->setText( tr("No End Date") ); |
287 | } else { | 289 | } else { |
288 | end = start; | 290 | end = start; |
289 | cmdEnd->setText( TimeString::shortDate(end) ); | 291 | cmdEnd->setText( TimeString::shortDate(end) ); |
290 | } | 292 | } |
291 | } | 293 | } |
292 | void OPimRecurrenceWidget::setupRepeatLabel( const QString& s) { | 294 | void OPimRecurrenceWidget::setupRepeatLabel( const QString& s) { |
293 | lblVar1->setText( s ); | 295 | lblVar1->setText( s ); |
294 | } | 296 | } |
295 | void OPimRecurrenceWidget::setupRepeatLabel( int x) { | 297 | void OPimRecurrenceWidget::setupRepeatLabel( int x) { |
296 | // change the spelling based on the value of x | 298 | // change the spelling based on the value of x |
297 | QString strVar2; | 299 | QString strVar2; |
298 | 300 | ||
299 | if ( x > 1 ) | 301 | if ( x > 1 ) |
300 | lblVar1->show(); | 302 | lblVar1->show(); |
301 | else | 303 | else |
302 | lblVar1->hide(); | 304 | lblVar1->hide(); |
303 | 305 | ||
304 | switch ( currInterval ) { | 306 | switch ( currInterval ) { |
305 | case None: | 307 | case None: |
306 | break; | 308 | break; |
307 | case Day: | 309 | case Day: |
308 | if ( x > 1 ) | 310 | if ( x > 1 ) |
309 | strVar2 = tr( "days" ); | 311 | strVar2 = tr( "days" ); |
310 | else | 312 | else |
311 | strVar2 = tr( "day" ); | 313 | strVar2 = tr( "day" ); |
312 | break; | 314 | break; |
313 | case Week: | 315 | case Week: |
314 | if ( x > 1 ) | 316 | if ( x > 1 ) |
315 | strVar2 = tr( "weeks" ); | 317 | strVar2 = tr( "weeks" ); |
316 | else | 318 | else |
317 | strVar2 = tr( "week" ); | 319 | strVar2 = tr( "week" ); |
318 | break; | 320 | break; |
319 | case Month: | 321 | case Month: |
320 | if ( x > 1 ) | 322 | if ( x > 1 ) |
321 | strVar2 = tr( "months" ); | 323 | strVar2 = tr( "months" ); |
322 | else | 324 | else |
323 | strVar2 = tr( "month" ); | 325 | strVar2 = tr( "month" ); |
324 | break; | 326 | break; |
325 | case Year: | 327 | case Year: |
326 | if ( x > 1 ) | 328 | if ( x > 1 ) |
327 | strVar2 = tr( "years" ); | 329 | strVar2 = tr( "years" ); |
328 | else | 330 | else |
329 | strVar2 = tr( "year" ); | 331 | strVar2 = tr( "year" ); |
330 | break; | 332 | break; |
331 | } | 333 | } |
332 | if ( !strVar2.isNull() ) | 334 | if ( !strVar2.isNull() ) |
333 | lblVar2->setText( strVar2 ); | 335 | lblVar2->setText( strVar2 ); |
334 | } | 336 | } |
335 | void OPimRecurrenceWidget::slotWeekLabel() { | 337 | void OPimRecurrenceWidget::slotWeekLabel() { |
336 | QString str; | 338 | QString str; |
337 | QListIterator<QToolButton> it( listExtra ); | 339 | QListIterator<QToolButton> it( listExtra ); |
338 | unsigned int i; | 340 | unsigned int i; |
339 | unsigned int keepMe; | 341 | unsigned int keepMe; |
340 | bool bNeedCarriage = FALSE; | 342 | bool bNeedCarriage = FALSE; |
341 | // don't do something we'll regret!!! | 343 | // don't do something we'll regret!!! |
342 | if ( currInterval != Week ) | 344 | if ( currInterval != Week ) |
343 | return; | 345 | return; |
344 | 346 | ||
345 | if ( startWeekOnMonday ) | 347 | if ( startWeekOnMonday ) |
346 | keepMe = start.dayOfWeek() - 1; | 348 | keepMe = start.dayOfWeek() - 1; |
347 | else | 349 | else |
348 | keepMe = start.dayOfWeek() % 7; | 350 | keepMe = start.dayOfWeek() % 7; |
349 | 351 | ||
350 | QStringList list; | 352 | QStringList list; |
351 | for ( i = 0; *it; ++it, i++ ) { | 353 | for ( i = 0; *it; ++it, i++ ) { |
352 | // a crazy check, if you are repeating weekly, the current day | 354 | // a crazy check, if you are repeating weekly, the current day |
353 | // must be selected!!! | 355 | // must be selected!!! |
354 | if ( i == keepMe && !( (*it)->isOn() ) ) | 356 | if ( i == keepMe && !( (*it)->isOn() ) ) |
355 | (*it)->setOn( TRUE ); | 357 | (*it)->setOn( TRUE ); |
356 | if ( (*it)->isOn() ) { | 358 | if ( (*it)->isOn() ) { |
357 | if ( startWeekOnMonday ) | 359 | if ( startWeekOnMonday ) |
358 | list.append( dayLabel[i] ); | 360 | list.append( dayLabel[i] ); |
359 | else { | 361 | else { |
360 | if ( i == 0 ) | 362 | if ( i == 0 ) |
361 | list.append( dayLabel[6] ); | 363 | list.append( dayLabel[6] ); |
362 | else | 364 | else |
363 | list.append( dayLabel[i - 1] ); | 365 | list.append( dayLabel[i - 1] ); |
364 | } | 366 | } |
365 | } | 367 | } |
366 | } | 368 | } |
367 | QStringList::Iterator itStr; | 369 | QStringList::Iterator itStr; |
368 | for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { | 370 | for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) { |
369 | if ( i == 3 ) | 371 | if ( i == 3 ) |
370 | bNeedCarriage = TRUE; | 372 | bNeedCarriage = TRUE; |
371 | else | 373 | else |
372 | bNeedCarriage = FALSE; | 374 | bNeedCarriage = FALSE; |
373 | if ( str.isNull() ) | 375 | if ( str.isNull() ) |
374 | str = *itStr; | 376 | str = *itStr; |
375 | else if ( i == list.count() - 1 ) { | 377 | else if ( i == list.count() - 1 ) { |
376 | if ( i < 2 ) | 378 | if ( i < 2 ) |
377 | str += tr(" and ") + *itStr; | 379 | str += tr(" and ") + *itStr; |
378 | else { | 380 | else { |
379 | if ( bNeedCarriage ) | 381 | if ( bNeedCarriage ) |
380 | str += tr( ",\nand " ) + *itStr; | 382 | str += tr( ",\nand " ) + *itStr; |
381 | else | 383 | else |
382 | str += tr( ", and " ) + *itStr; | 384 | str += tr( ", and " ) + *itStr; |
383 | } | 385 | } |
384 | } else { | 386 | } else { |
385 | if ( bNeedCarriage ) | 387 | if ( bNeedCarriage ) |
386 | str += ",\n" + *itStr; | 388 | str += ",\n" + *itStr; |
387 | else | 389 | else |
388 | str += ", " + *itStr; | 390 | str += ", " + *itStr; |
389 | } | 391 | } |
390 | } | 392 | } |
391 | str = str.prepend( tr("on ") ); | 393 | str = str.prepend( tr("on ") ); |
392 | 394 | ||
393 | lblWeekVar->setText( str ); | 395 | lblWeekVar->setText( str ); |
394 | } | 396 | } |
395 | void OPimRecurrenceWidget::slotMonthLabel(int type) { | 397 | void OPimRecurrenceWidget::slotMonthLabel(int type) { |
396 | QString str; | 398 | QString str; |
397 | if ( currInterval != Month || type > 1 ) | 399 | if ( currInterval != Month || type > 1 ) |
398 | return; | 400 | return; |
399 | if ( type == 1 ) | 401 | if ( type == 1 ) |
400 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); | 402 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); |
401 | else | 403 | else |
402 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) | 404 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) |
403 | .arg( dayLabel[start.dayOfWeek() - 1] ); | 405 | .arg( dayLabel[start.dayOfWeek() - 1] ); |
404 | lblRepeat->setText( str ); | 406 | lblRepeat->setText( str ); |
405 | } | 407 | } |
406 | void OPimRecurrenceWidget::slotChangeStartOfWeek( bool onMonday ) { | 408 | void OPimRecurrenceWidget::slotChangeStartOfWeek( bool onMonday ) { |
407 | startWeekOnMonday = onMonday; | 409 | startWeekOnMonday = onMonday; |
408 | // we need to make this unintrusive as possible... | 410 | // we need to make this unintrusive as possible... |
409 | int saveSpin = spinFreq->value(); | 411 | int saveSpin = spinFreq->value(); |
410 | char days = 0; | 412 | char days = 0; |
411 | int day; | 413 | int day; |
412 | QListIterator<QToolButton> itExtra( listExtra ); | 414 | QListIterator<QToolButton> itExtra( listExtra ); |
413 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { | 415 | for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) { |
414 | if ( (*itExtra)->isOn() ) { | 416 | if ( (*itExtra)->isOn() ) { |
415 | if ( !startWeekOnMonday ) | 417 | if ( !startWeekOnMonday ) |
416 | days |= day; | 418 | days |= day; |
417 | else { | 419 | else { |
418 | if ( day == 1 ) | 420 | if ( day == 1 ) |
419 | days |= OPimRecurrence::SUN; | 421 | days |= OPimRecurrence::SUN; |
420 | else | 422 | else |
421 | days |= day >> 1; | 423 | days |= day >> 1; |
422 | } | 424 | } |
423 | } | 425 | } |
424 | } | 426 | } |
425 | setupWeekly(); | 427 | setupWeekly(); |
426 | spinFreq->setValue( saveSpin ); | 428 | spinFreq->setValue( saveSpin ); |
427 | int buttons; | 429 | int buttons; |
428 | for ( day = 0x01, buttons = 0; buttons < 7; | 430 | for ( day = 0x01, buttons = 0; buttons < 7; |
429 | day = day << 1, buttons++ ) { | 431 | day = day << 1, buttons++ ) { |
430 | if ( days & day ) { | 432 | if ( days & day ) { |
431 | if ( startWeekOnMonday ) | 433 | if ( startWeekOnMonday ) |
432 | fraExtra->setButton( buttons ); | 434 | fraExtra->setButton( buttons ); |
433 | else { | 435 | else { |
434 | if ( buttons == 7 ) | 436 | if ( buttons == 7 ) |
435 | fraExtra->setButton( 0 ); | 437 | fraExtra->setButton( 0 ); |
436 | else | 438 | else |
437 | fraExtra->setButton( buttons + 1 ); | 439 | fraExtra->setButton( buttons + 1 ); |
438 | } | 440 | } |
439 | } | 441 | } |
440 | } | 442 | } |
441 | slotWeekLabel(); | 443 | slotWeekLabel(); |
442 | } | 444 | } |
443 | void OPimRecurrenceWidget::setupNone() { | 445 | void OPimRecurrenceWidget::setupNone() { |
444 | lblRepeat->setText( tr("No Repeat") ); | 446 | lblRepeat->setText( tr("No Repeat") ); |
445 | lblVar1->hide(); | 447 | lblVar1->hide(); |
446 | lblVar2->hide(); | 448 | lblVar2->hide(); |
447 | hideExtras(); | 449 | hideExtras(); |
448 | cmdEnd->hide(); | 450 | cmdEnd->hide(); |
449 | lblFreq->hide(); | 451 | lblFreq->hide(); |
450 | lblEvery->hide(); | 452 | lblEvery->hide(); |
451 | lblFreq->hide(); | 453 | lblFreq->hide(); |
452 | spinFreq->hide(); | 454 | spinFreq->hide(); |
453 | lblEnd->hide(); | 455 | lblEnd->hide(); |
454 | lblWeekVar->hide(); | 456 | lblWeekVar->hide(); |
455 | } | 457 | } |
456 | void OPimRecurrenceWidget::setupDaily() { | 458 | void OPimRecurrenceWidget::setupDaily() { |
457 | hideExtras(); | 459 | hideExtras(); |
458 | lblWeekVar->hide(); | 460 | lblWeekVar->hide(); |
459 | spinFreq->setValue( 1 ); | 461 | spinFreq->setValue( 1 ); |
460 | lblFreq->setText( tr("day(s)") ); | 462 | lblFreq->setText( tr("day(s)") ); |
461 | lblVar2->show(); | 463 | lblVar2->show(); |
462 | showRepeatStuff(); | 464 | showRepeatStuff(); |
463 | lblRepeat->setText( strDayTemplate ); | 465 | lblRepeat->setText( strDayTemplate ); |
464 | setupRepeatLabel( 1 ); | 466 | setupRepeatLabel( 1 ); |
465 | } | 467 | } |
466 | void OPimRecurrenceWidget::setupWeekly() { | 468 | void OPimRecurrenceWidget::setupWeekly() { |
467 | // reshow the buttons... | 469 | // reshow the buttons... |
468 | fraExtra->setTitle( tr("Repeat On") ); | 470 | fraExtra->setTitle( tr("Repeat On") ); |
469 | fraExtra->setExclusive( FALSE ); | 471 | fraExtra->setExclusive( FALSE ); |
470 | fraExtra->show(); | 472 | fraExtra->show(); |
471 | if ( startWeekOnMonday ) { | 473 | if ( startWeekOnMonday ) { |
472 | cmdExtra1->setText( tr("Mon") ); | 474 | cmdExtra1->setText( tr("Mon") ); |
473 | cmdExtra2->setText( tr("Tue") ); | 475 | cmdExtra2->setText( tr("Tue") ); |
474 | cmdExtra3->setText( tr("Wed") ); | 476 | cmdExtra3->setText( tr("Wed") ); |
475 | cmdExtra4->setText( tr("Thu") ); | 477 | cmdExtra4->setText( tr("Thu") ); |
476 | cmdExtra5->setText( tr("Fri") ); | 478 | cmdExtra5->setText( tr("Fri") ); |
477 | cmdExtra6->setText( tr("Sat") ); | 479 | cmdExtra6->setText( tr("Sat") ); |
478 | cmdExtra7->setText( tr("Sun") ); | 480 | cmdExtra7->setText( tr("Sun") ); |
479 | } else { | 481 | } else { |
480 | cmdExtra1->setText( tr("Sun") ); | 482 | cmdExtra1->setText( tr("Sun") ); |
481 | cmdExtra2->setText( tr("Mon") ); | 483 | cmdExtra2->setText( tr("Mon") ); |
482 | cmdExtra3->setText( tr("Tue") ); | 484 | cmdExtra3->setText( tr("Tue") ); |
483 | cmdExtra4->setText( tr("Wed") ); | 485 | cmdExtra4->setText( tr("Wed") ); |
484 | cmdExtra5->setText( tr("Thu") ); | 486 | cmdExtra5->setText( tr("Thu") ); |
485 | cmdExtra6->setText( tr("Fri") ); | 487 | cmdExtra6->setText( tr("Fri") ); |
486 | cmdExtra7->setText( tr("Sat") ); | 488 | cmdExtra7->setText( tr("Sat") ); |
487 | } | 489 | } |
488 | // I hope clustering these improve performance.... | 490 | // I hope clustering these improve performance.... |
489 | cmdExtra1->setOn( FALSE ); | 491 | cmdExtra1->setOn( FALSE ); |
490 | cmdExtra2->setOn( FALSE ); | 492 | cmdExtra2->setOn( FALSE ); |
491 | cmdExtra3->setOn( FALSE ); | 493 | cmdExtra3->setOn( FALSE ); |
492 | cmdExtra4->setOn( FALSE ); | 494 | cmdExtra4->setOn( FALSE ); |
493 | cmdExtra5->setOn( FALSE ); | 495 | cmdExtra5->setOn( FALSE ); |
494 | cmdExtra6->setOn( FALSE ); | 496 | cmdExtra6->setOn( FALSE ); |
495 | cmdExtra7->setOn( FALSE ); | 497 | cmdExtra7->setOn( FALSE ); |
496 | 498 | ||
497 | cmdExtra1->show(); | 499 | cmdExtra1->show(); |
498 | cmdExtra2->show(); | 500 | cmdExtra2->show(); |
499 | cmdExtra3->show(); | 501 | cmdExtra3->show(); |
500 | cmdExtra4->show(); | 502 | cmdExtra4->show(); |
501 | cmdExtra5->show(); | 503 | cmdExtra5->show(); |
502 | cmdExtra6->show(); | 504 | cmdExtra6->show(); |
503 | cmdExtra7->show(); | 505 | cmdExtra7->show(); |
504 | 506 | ||
505 | lblWeekVar->show(); | 507 | lblWeekVar->show(); |
506 | spinFreq->setValue( 1 ); | 508 | spinFreq->setValue( 1 ); |
507 | // might as well set the day too... | 509 | // might as well set the day too... |
508 | if ( startWeekOnMonday ) { | 510 | if ( startWeekOnMonday ) { |
509 | fraExtra->setButton( start.dayOfWeek() - 1 ); | 511 | fraExtra->setButton( start.dayOfWeek() - 1 ); |
510 | } else { | 512 | } else { |
511 | fraExtra->setButton( start.dayOfWeek() % 7 ); | 513 | fraExtra->setButton( start.dayOfWeek() % 7 ); |
512 | } | 514 | } |
513 | lblFreq->setText( tr("week(s)") ); | 515 | lblFreq->setText( tr("week(s)") ); |
514 | lblVar2->show(); | 516 | lblVar2->show(); |
515 | showRepeatStuff(); | 517 | showRepeatStuff(); |
516 | setupRepeatLabel( 1 ); | 518 | setupRepeatLabel( 1 ); |
517 | } | 519 | } |
518 | void OPimRecurrenceWidget::setupMonthly() { | 520 | void OPimRecurrenceWidget::setupMonthly() { |
519 | hideExtras(); | 521 | hideExtras(); |
520 | lblWeekVar->hide(); | 522 | lblWeekVar->hide(); |
521 | fraExtra->setTitle( tr("Repeat By") ); | 523 | fraExtra->setTitle( tr("Repeat By") ); |
522 | fraExtra->setExclusive( TRUE ); | 524 | fraExtra->setExclusive( TRUE ); |
523 | fraExtra->show(); | 525 | fraExtra->show(); |
524 | cmdExtra1->setText( tr("Day") ); | 526 | cmdExtra1->setText( tr("Day") ); |
525 | cmdExtra1->show(); | 527 | cmdExtra1->show(); |
526 | cmdExtra2->setText( tr("Date") ); | 528 | cmdExtra2->setText( tr("Date") ); |
527 | cmdExtra2->show(); | 529 | cmdExtra2->show(); |
528 | spinFreq->setValue( 1 ); | 530 | spinFreq->setValue( 1 ); |
529 | lblFreq->setText( tr("month(s)") ); | 531 | lblFreq->setText( tr("month(s)") ); |
530 | lblVar2->show(); | 532 | lblVar2->show(); |
531 | showRepeatStuff(); | 533 | showRepeatStuff(); |
532 | setupRepeatLabel( 1 ); | 534 | setupRepeatLabel( 1 ); |
533 | } | 535 | } |
534 | void OPimRecurrenceWidget::setupYearly() { | 536 | void OPimRecurrenceWidget::setupYearly() { |
535 | hideExtras(); | 537 | hideExtras(); |
536 | lblWeekVar->hide(); | 538 | lblWeekVar->hide(); |
537 | spinFreq->setValue( 1 ); | 539 | spinFreq->setValue( 1 ); |
538 | lblFreq->setText( tr("year(s)") ); | 540 | lblFreq->setText( tr("year(s)") ); |
539 | lblFreq->show(); | 541 | lblFreq->show(); |
540 | lblFreq->show(); | 542 | lblFreq->show(); |
541 | showRepeatStuff(); | 543 | showRepeatStuff(); |
542 | lblVar2->show(); | 544 | lblVar2->show(); |
543 | QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) ); | 545 | QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) ); |
544 | lblRepeat->setText( strEvery ); | 546 | lblRepeat->setText( strEvery ); |
545 | setupRepeatLabel( 1 ); | 547 | setupRepeatLabel( 1 ); |
546 | 548 | ||
547 | } | 549 | } |
548 | void OPimRecurrenceWidget::init() { | 550 | void OPimRecurrenceWidget::init() { |
549 | QPopupMenu *m1 = new QPopupMenu( this ); | 551 | QPopupMenu *m1 = new QPopupMenu( this ); |
550 | repeatPicker = new DateBookMonth( m1, 0, TRUE ); | 552 | repeatPicker = new DateBookMonth( m1, 0, TRUE ); |
551 | m1->insertItem( repeatPicker ); | 553 | m1->insertItem( repeatPicker ); |
552 | cmdEnd->setPopup( m1 ); | 554 | cmdEnd->setPopup( m1 ); |
553 | cmdEnd->setPopupDelay( 0 ); | 555 | cmdEnd->setPopupDelay( 0 ); |
554 | 556 | ||
555 | QObject::connect( repeatPicker, SIGNAL(dateClicked(int,int,int)), | 557 | QObject::connect( repeatPicker, SIGNAL(dateClicked(int,int,int)), |
556 | this, SLOT(endDateChanged(int,int,int)) ); | 558 | this, SLOT(endDateChanged(int,int,int)) ); |
557 | QObject::connect( qApp, SIGNAL(weekChanged(bool)), | 559 | QObject::connect( qApp, SIGNAL(weekChanged(bool)), |
558 | this, SLOT(slotChangeStartOfWeek(bool)) ); | 560 | this, SLOT(slotChangeStartOfWeek(bool)) ); |
559 | 561 | ||
560 | listRTypeButtons.setAutoDelete( TRUE ); | 562 | listRTypeButtons.setAutoDelete( TRUE ); |
561 | listRTypeButtons.append( cmdNone ); | 563 | listRTypeButtons.append( cmdNone ); |
562 | listRTypeButtons.append( cmdDay ); | 564 | listRTypeButtons.append( cmdDay ); |
563 | listRTypeButtons.append( cmdWeek ); | 565 | listRTypeButtons.append( cmdWeek ); |
564 | listRTypeButtons.append( cmdMonth ); | 566 | listRTypeButtons.append( cmdMonth ); |
565 | listRTypeButtons.append( cmdYear ); | 567 | listRTypeButtons.append( cmdYear ); |
566 | 568 | ||
567 | listExtra.setAutoDelete( TRUE ); | 569 | listExtra.setAutoDelete( TRUE ); |
568 | listExtra.append( cmdExtra1 ); | 570 | listExtra.append( cmdExtra1 ); |
569 | listExtra.append( cmdExtra2 ); | 571 | listExtra.append( cmdExtra2 ); |
570 | listExtra.append( cmdExtra3 ); | 572 | listExtra.append( cmdExtra3 ); |
571 | listExtra.append( cmdExtra4 ); | 573 | listExtra.append( cmdExtra4 ); |
572 | listExtra.append( cmdExtra5 ); | 574 | listExtra.append( cmdExtra5 ); |
573 | listExtra.append( cmdExtra6 ); | 575 | listExtra.append( cmdExtra6 ); |
574 | listExtra.append( cmdExtra7 ); | 576 | listExtra.append( cmdExtra7 ); |
575 | } | 577 | } |
576 | void OPimRecurrenceWidget::hideExtras() { | 578 | void OPimRecurrenceWidget::hideExtras() { |
577 | // hide the extra buttons... | 579 | // hide the extra buttons... |
578 | fraExtra->hide(); | 580 | fraExtra->hide(); |
579 | chkNoEnd->hide(); | 581 | chkNoEnd->hide(); |
580 | QListIterator<QToolButton> it( listExtra ); | 582 | QListIterator<QToolButton> it( listExtra ); |
581 | for ( ; *it; ++it ) { | 583 | for ( ; *it; ++it ) { |
582 | (*it)->hide(); | 584 | (*it)->hide(); |
583 | (*it)->setOn( FALSE ); | 585 | (*it)->setOn( FALSE ); |
584 | } | 586 | } |
585 | } | 587 | } |
586 | void OPimRecurrenceWidget::showRepeatStuff() { | 588 | void OPimRecurrenceWidget::showRepeatStuff() { |
587 | cmdEnd->show(); | 589 | cmdEnd->show(); |
588 | chkNoEnd->show(); | 590 | chkNoEnd->show(); |
589 | lblFreq->show(); | 591 | lblFreq->show(); |
590 | lblEvery->show(); | 592 | lblEvery->show(); |
591 | lblFreq->show(); | 593 | lblFreq->show(); |
592 | spinFreq->show(); | 594 | spinFreq->show(); |
593 | lblEnd->show(); | 595 | lblEnd->show(); |
594 | lblRepeat->setText( tr("Every") ); | 596 | lblRepeat->setText( tr("Every") ); |
595 | } | 597 | } |
596 | 598 | ||
597 | 599 | ||
598 | static int week( const QDate &start ) | 600 | static int week( const QDate &start ) |
599 | { | 601 | { |
600 | // figure out the week... | 602 | // figure out the week... |
601 | int stop = start.day(), | 603 | int stop = start.day(), |
602 | sentinel = start.dayOfWeek(), | 604 | sentinel = start.dayOfWeek(), |
603 | dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(), | 605 | dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(), |
604 | week = 1, | 606 | week = 1, |
605 | i; | 607 | i; |
606 | for ( i = 1; i < stop; i++ ) { | 608 | for ( i = 1; i < stop; i++ ) { |
607 | if ( dayOfWeek++ == sentinel ) | 609 | if ( dayOfWeek++ == sentinel ) |
608 | week++; | 610 | week++; |
609 | if ( dayOfWeek > 7 ) | 611 | if ( dayOfWeek > 7 ) |
610 | dayOfWeek = 0; | 612 | dayOfWeek = 0; |
611 | } | 613 | } |
612 | return week; | 614 | return week; |
613 | } | 615 | } |
614 | 616 | ||
615 | static QString numberPlacing( int x ) | 617 | static QString numberPlacing( int x ) |
616 | { | 618 | { |
617 | // I hope this works in other languages besides english... | 619 | // I hope this works in other languages besides english... |
618 | QString str = QString::number( x ); | 620 | QString str = QString::number( x ); |
619 | switch ( x % 10 ) { | 621 | switch ( x % 10 ) { |
620 | case 1: | 622 | case 1: |
621 | str += QWidget::tr( "st" ); | 623 | str += QWidget::tr( "st" ); |
622 | break; | 624 | break; |
623 | case 2: | 625 | case 2: |
624 | str += QWidget::tr( "nd" ); | 626 | str += QWidget::tr( "nd" ); |
625 | break; | 627 | break; |
626 | case 3: | 628 | case 3: |
627 | str += QWidget::tr( "rd" ); | 629 | str += QWidget::tr( "rd" ); |
628 | break; | 630 | break; |
629 | default: | 631 | default: |
630 | str += QWidget::tr( "th" ); | 632 | str += QWidget::tr( "th" ); |
631 | break; | 633 | break; |
632 | } | 634 | } |
633 | return str; | 635 | return str; |
634 | } | 636 | } |
diff --git a/libopie2/opiepim/ui/opimrecurrencewidget.h b/libopie2/opiepim/ui/opimrecurrencewidget.h index 3f28565..2c315b3 100644 --- a/libopie2/opiepim/ui/opimrecurrencewidget.h +++ b/libopie2/opiepim/ui/opimrecurrencewidget.h | |||
@@ -1,93 +1,91 @@ | |||
1 | /* | 1 | /* |
2 | * GPL and based on the widget from TT | 2 | * GPL and based on the widget from TT |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef OPIE_PIM_RECURRENCE_WIDGET_H | 5 | #ifndef OPIE_PIM_RECURRENCE_WIDGET_H |
6 | #define OPIE_PIM_RECURRENCE_WIDGET_H | 6 | #define OPIE_PIM_RECURRENCE_WIDGET_H |
7 | 7 | ||
8 | #include <opie2/opimrecurrence.h> | 8 | #include <opie2/opimrecurrence.h> |
9 | 9 | ||
10 | #include <qpe/datebookmonth.h> | 10 | #include <qpe/datebookmonth.h> |
11 | 11 | ||
12 | #include <qlist.h> | 12 | #include <qlist.h> |
13 | #include <qtoolbutton.h> | 13 | #include <qtoolbutton.h> |
14 | #include <qcheckbox.h> | 14 | #include <qcheckbox.h> |
15 | #include <qdatetime.h> | 15 | #include <qdatetime.h> |
16 | #include <qbuttongroup.h> | 16 | #include <qbuttongroup.h> |
17 | 17 | ||
18 | #include "opimrecurrencebase.h" | 18 | #include "opimrecurrencebase.h" |
19 | 19 | ||
20 | using namespace Opie; | ||
21 | |||
22 | /** | 20 | /** |
23 | * A widget to let the user select rules for recurrences. | 21 | * A widget to let the user select rules for recurrences. |
24 | * This widget can take care of weekly, monthly, daily and yearly recurrence | 22 | * This widget can take care of weekly, monthly, daily and yearly recurrence |
25 | * It is used inside todolist and datebook. | 23 | * It is used inside todolist and datebook. |
26 | * | 24 | * |
27 | * | 25 | * |
28 | * @short Widget of selecting Recurrance | 26 | * @short Widget of selecting Recurrance |
29 | * @author Trolltech, Holger Freyther | 27 | * @author Trolltech, Holger Freyther |
30 | * @version 0.9 | 28 | * @version 0.9 |
31 | */ | 29 | */ |
32 | class OPimRecurrenceWidget : public OPimRecurrenceBase { | 30 | class OPimRecurrenceWidget : public OPimRecurrenceBase { |
33 | Q_OBJECT | 31 | Q_OBJECT |
34 | public: | 32 | public: |
35 | OPimRecurrenceWidget( bool startOnMonday, | 33 | OPimRecurrenceWidget( bool startOnMonday, |
36 | const QDate& start, QWidget* parent = 0, | 34 | const QDate& start, QWidget* parent = 0, |
37 | const char* name = 0, bool modal = TRUE, | 35 | const char* name = 0, bool modal = TRUE, |
38 | WFlags fl = 0 ); | 36 | WFlags fl = 0 ); |
39 | OPimRecurrenceWidget( bool startOnMonday, | 37 | OPimRecurrenceWidget( bool startOnMonday, |
40 | const OPimRecurrence& rp, const QDate& start, | 38 | const Opie::OPimRecurrence& rp, const QDate& start, |
41 | QWidget* parent = 0, const char* name =0, | 39 | QWidget* parent = 0, const char* name =0, |
42 | bool modal = TRUE, WFlags = 0 ); | 40 | bool modal = TRUE, WFlags = 0 ); |
43 | ~OPimRecurrenceWidget(); | 41 | ~OPimRecurrenceWidget(); |
44 | OPimRecurrence recurrence()const; | 42 | Opie::OPimRecurrence recurrence()const; |
45 | QDate endDate()const; | 43 | QDate endDate()const; |
46 | 44 | ||
47 | public slots: | 45 | public slots: |
48 | void slotSetRType( int ); | 46 | void slotSetRType( int ); |
49 | /** | 47 | /** |
50 | * set the new end date | 48 | * set the new end date |
51 | */ | 49 | */ |
52 | void endDateChanged( int, int, int ); | 50 | void endDateChanged( int, int, int ); |
53 | /** | 51 | /** |
54 | * enable/disable end date | 52 | * enable/disable end date |
55 | */ | 53 | */ |
56 | void slotNoEnd( bool unused ); | 54 | void slotNoEnd( bool unused ); |
57 | void setStartDate( const QDate& ); | 55 | void setStartDate( const QDate& ); |
58 | void setRecurrence( const OPimRecurrence& recur, const QDate& start ); | 56 | void setRecurrence( const Opie::OPimRecurrence& recur, const QDate& start ); |
59 | void setRecurrence( const OPimRecurrence& recur ); | 57 | void setRecurrence( const Opie::OPimRecurrence& recur ); |
60 | 58 | ||
61 | private slots: | 59 | private slots: |
62 | void setupRepeatLabel( const QString& ); | 60 | void setupRepeatLabel( const QString& ); |
63 | void setupRepeatLabel( int ); | 61 | void setupRepeatLabel( int ); |
64 | void slotWeekLabel(); | 62 | void slotWeekLabel(); |
65 | void slotMonthLabel( int ); | 63 | void slotMonthLabel( int ); |
66 | void slotChangeStartOfWeek( bool onMonday ); | 64 | void slotChangeStartOfWeek( bool onMonday ); |
67 | 65 | ||
68 | private: | 66 | private: |
69 | void setupNone(); | 67 | void setupNone(); |
70 | void setupDaily(); | 68 | void setupDaily(); |
71 | void setupWeekly(); | 69 | void setupWeekly(); |
72 | void setupMonthly(); | 70 | void setupMonthly(); |
73 | void setupYearly(); | 71 | void setupYearly(); |
74 | 72 | ||
75 | enum repeatButtons { None, Day, Week, Month, Year }; | 73 | enum repeatButtons { None, Day, Week, Month, Year }; |
76 | void init(); | 74 | void init(); |
77 | void hideExtras(); | 75 | void hideExtras(); |
78 | void showRepeatStuff(); | 76 | void showRepeatStuff(); |
79 | 77 | ||
80 | QList<QToolButton> listRTypeButtons; | 78 | QList<QToolButton> listRTypeButtons; |
81 | QList<QToolButton> listExtra; | 79 | QList<QToolButton> listExtra; |
82 | QDate start; // only used in one spot... | 80 | QDate start; // only used in one spot... |
83 | QDate end; | 81 | QDate end; |
84 | repeatButtons currInterval; | 82 | repeatButtons currInterval; |
85 | bool startWeekOnMonday : 1; | 83 | bool startWeekOnMonday : 1; |
86 | DateBookMonth *repeatPicker; | 84 | DateBookMonth *repeatPicker; |
87 | 85 | ||
88 | class Private; | 86 | class Private; |
89 | Private *d; | 87 | Private *d; |
90 | 88 | ||
91 | }; | 89 | }; |
92 | 90 | ||
93 | #endif | 91 | #endif |