-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,380 +1,382 @@ | |||
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; |
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 |