Diffstat (limited to 'libopie/orecurrancewidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/orecurrancewidget.cpp | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/libopie/orecurrancewidget.cpp b/libopie/orecurrancewidget.cpp index 471249d..be8ec30 100644 --- a/libopie/orecurrancewidget.cpp +++ b/libopie/orecurrancewidget.cpp | |||
@@ -5,25 +5,42 @@ | |||
5 | 5 | ||
6 | #include <qpe/timestring.h> | 6 | #include <qpe/timestring.h> |
7 | 7 | ||
8 | #include "orecurrancewidget.h" | 8 | #include "orecurrancewidget.h" |
9 | 9 | ||
10 | // Global Templates for use in setting up the repeat label... | 10 | // Global Templates for use in setting up the repeat label... |
11 | const QString strDayTemplate = QObject::tr("Every"); | 11 | // the problem is these strings get initialized before QPEApplication can install the translator -zecke |
12 | const QString strYearTemplate = QObject::tr("%1 %2 every "); | 12 | namespace { |
13 | const QString strMonthDateTemplate = QObject::tr("The %1 every "); | 13 | QString strDayTemplate; |
14 | const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every"); | 14 | QString strYearTemplate; |
15 | const QString strWeekTemplate = QObject::tr("Every "); | 15 | QString strMonthDateTemplate; |
16 | const QString dayLabel[] = { QObject::tr("Monday"), | 16 | QString strMonthDayTemplate; |
17 | QObject::tr("Tuesday"), | 17 | QString strWeekTemplate; |
18 | QObject::tr("Wednesday"), | 18 | QString dayLabel[7]; |
19 | QObject::tr("Thursday"), | 19 | } |
20 | QObject::tr("Friday"), | ||
21 | QObject::tr("Saturday"), | ||
22 | QObject::tr("Sunday") }; | ||
23 | 20 | ||
21 | /* | ||
22 | * static linkage to not polute the symbol table... | ||
23 | * 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... | ||
25 | * -zecke | ||
26 | */ | ||
27 | static void fillStrings() { | ||
28 | strDayTemplate = QObject::tr("Every"); | ||
29 | strYearTemplate = QObject::tr("%1 %2 every "); | ||
30 | strMonthDateTemplate = QObject::tr("The %1 every "); | ||
31 | strMonthDayTemplate = QObject::tr("The %1 %2 of every"); | ||
32 | strWeekTemplate = QObject::tr("Every "); | ||
33 | dayLabel[0] = QObject::tr("Monday"); | ||
34 | dayLabel[1] = QObject::tr("Tuesday"); | ||
35 | dayLabel[2] = QObject::tr("Wednesday"); | ||
36 | dayLabel[3] = QObject::tr("Thursday"); | ||
37 | dayLabel[4] = QObject::tr("Friday"); | ||
38 | dayLabel[5] = QObject::tr("Saturday"); | ||
39 | dayLabel[6] = QObject::tr("Sunday"); | ||
40 | } | ||
24 | 41 | ||
25 | static QString numberPlacing( int x );// return the proper word format for | 42 | static QString numberPlacing( int x );// return the proper word format for |
26 | // x (1st, 2nd, etc) | 43 | // x (1st, 2nd, etc) |
27 | static int week( const QDate &dt ); // what week in the month is dt? | 44 | static int week( const QDate &dt ); // what week in the month is dt? |
28 | 45 | ||
29 | /** | 46 | /** |
@@ -43,12 +60,15 @@ ORecurranceWidget::ORecurranceWidget( bool startOnMonday, | |||
43 | WFlags fl ) | 60 | WFlags fl ) |
44 | : ORecurranceBase( parent, name, modal, fl ), | 61 | : ORecurranceBase( parent, name, modal, fl ), |
45 | start( newStart ), | 62 | start( newStart ), |
46 | currInterval( None ), | 63 | currInterval( None ), |
47 | startWeekOnMonday( startOnMonday ) | 64 | startWeekOnMonday( startOnMonday ) |
48 | { | 65 | { |
66 | if (strDayTemplate.isEmpty() ) | ||
67 | fillStrings(); | ||
68 | |||
49 | init(); | 69 | init(); |
50 | fraType->setButton( currInterval ); | 70 | fraType->setButton( currInterval ); |
51 | chkNoEnd->setChecked( TRUE ); | 71 | chkNoEnd->setChecked( TRUE ); |
52 | setupNone(); | 72 | setupNone(); |
53 | } | 73 | } |
54 | 74 | ||
@@ -68,12 +88,14 @@ ORecurranceWidget::ORecurranceWidget( bool startOnMonday, | |||
68 | bool modal, WFlags fl) | 88 | bool modal, WFlags fl) |
69 | : ORecurranceBase( parent, name, modal, fl ), | 89 | : ORecurranceBase( parent, name, modal, fl ), |
70 | start( startDate ), | 90 | start( startDate ), |
71 | end( rp.endDate() ), | 91 | end( rp.endDate() ), |
72 | startWeekOnMonday( startOnMonday ) | 92 | startWeekOnMonday( startOnMonday ) |
73 | { | 93 | { |
94 | if (strDayTemplate.isEmpty() ) | ||
95 | fillStrings(); | ||
74 | // do some stuff with the repeat pattern | 96 | // do some stuff with the repeat pattern |
75 | init(); | 97 | init(); |
76 | setRecurrence( rp ); | 98 | setRecurrence( rp ); |
77 | } | 99 | } |
78 | 100 | ||
79 | ORecurranceWidget::~ORecurranceWidget() { | 101 | ORecurranceWidget::~ORecurranceWidget() { |
@@ -81,13 +103,12 @@ ORecurranceWidget::~ORecurranceWidget() { | |||
81 | 103 | ||
82 | /** | 104 | /** |
83 | * set the start date | 105 | * set the start date |
84 | * @param date the new start date | 106 | * @param date the new start date |
85 | */ | 107 | */ |
86 | void ORecurranceWidget::setStartDate( const QDate& date ) { | 108 | void ORecurranceWidget::setStartDate( const QDate& date ) { |
87 | qWarning("ORecurranceWidget::setStartDate"); | ||
88 | setRecurrence( recurrence(), date ); | 109 | setRecurrence( recurrence(), date ); |
89 | } | 110 | } |
90 | /** | 111 | /** |
91 | * set the recurrence | 112 | * set the recurrence |
92 | * @param rp The ORecur object with the new recurrence rules | 113 | * @param rp The ORecur object with the new recurrence rules |
93 | */ | 114 | */ |
@@ -364,24 +385,25 @@ void ORecurranceWidget::slotWeekLabel() { | |||
364 | if ( bNeedCarriage ) | 385 | if ( bNeedCarriage ) |
365 | str += ",\n" + *itStr; | 386 | str += ",\n" + *itStr; |
366 | else | 387 | else |
367 | str += ", " + *itStr; | 388 | str += ", " + *itStr; |
368 | } | 389 | } |
369 | } | 390 | } |
370 | str = str.prepend( "on " ); | 391 | str = str.prepend( tr("on ") ); |
392 | |||
371 | lblWeekVar->setText( str ); | 393 | lblWeekVar->setText( str ); |
372 | } | 394 | } |
373 | void ORecurranceWidget::slotMonthLabel(int type) { | 395 | void ORecurranceWidget::slotMonthLabel(int type) { |
374 | QString str; | 396 | QString str; |
375 | if ( currInterval != Month || type > 1 ) | 397 | if ( currInterval != Month || type > 1 ) |
376 | return; | 398 | return; |
377 | if ( type == 1 ) | 399 | if ( type == 1 ) |
378 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); | 400 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); |
379 | else | 401 | else |
380 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) | 402 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) |
381 | .arg( dayLabel[start.dayOfWeek() - 1] ); | 403 | .arg( dayLabel[start.dayOfWeek() - 1] ); |
382 | lblRepeat->setText( str ); | 404 | lblRepeat->setText( str ); |
383 | } | 405 | } |
384 | void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) { | 406 | void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) { |
385 | startWeekOnMonday = onMonday; | 407 | startWeekOnMonday = onMonday; |
386 | // we need to make this unintrusive as possible... | 408 | // we need to make this unintrusive as possible... |
387 | int saveSpin = spinFreq->value(); | 409 | int saveSpin = spinFreq->value(); |