Diffstat (limited to 'core/pim/datebook/repeatentry.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/repeatentry.cpp | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/core/pim/datebook/repeatentry.cpp b/core/pim/datebook/repeatentry.cpp index 5637c4d..b1a162d 100644 --- a/core/pim/datebook/repeatentry.cpp +++ b/core/pim/datebook/repeatentry.cpp | |||
@@ -24,65 +24,87 @@ | |||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/timestring.h> | 25 | #include <qpe/timestring.h> |
26 | 26 | ||
27 | #include <qbuttongroup.h> | 27 | #include <qbuttongroup.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qpopupmenu.h> | 29 | #include <qpopupmenu.h> |
30 | #include <qspinbox.h> | 30 | #include <qspinbox.h> |
31 | #include <qtoolbutton.h> | 31 | #include <qtoolbutton.h> |
32 | 32 | ||
33 | #include <time.h> | 33 | #include <time.h> |
34 | 34 | ||
35 | // Global Templates for use in setting up the repeat label... | 35 | // Global Templates for use in setting up the repeat label... |
36 | const QString strDayTemplate = QObject::tr("Every"); | 36 | // the problem is these strings get initialized before QPEApplication can install the translator -zecke |
37 | const QString strYearTemplate = QObject::tr("%1 %2 every "); | 37 | namespace { |
38 | const QString strMonthDateTemplate = QObject::tr("The %1 every "); | 38 | QString strDayTemplate; |
39 | const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every"); | 39 | QString strYearTemplate; |
40 | const QString strWeekTemplate = QObject::tr("Every "); | 40 | QString strMonthDateTemplate; |
41 | const QString dayLabel[] = { QObject::tr("Monday"), | 41 | QString strMonthDayTemplate; |
42 | QObject::tr("Tuesday"), | 42 | QString strWeekTemplate; |
43 | QObject::tr("Wednesday"), | 43 | QString dayLabel[7]; |
44 | QObject::tr("Thursday"), | 44 | } |
45 | QObject::tr("Friday"), | 45 | |
46 | QObject::tr("Saturday"), | 46 | /* |
47 | QObject::tr("Sunday") }; | 47 | * static linkage to not polute the symbol table... |
48 | 48 | * The problem is that const and static linkage are resolved prior to installing a translator | |
49 | * leading to that the above strings are translted but to the original we delay the init of these strings... | ||
50 | * -zecke | ||
51 | */ | ||
52 | static void fillStrings() { | ||
53 | strDayTemplate = QObject::tr("Every"); | ||
54 | strYearTemplate = QObject::tr("%1 %2 every "); | ||
55 | strMonthDateTemplate = QObject::tr("The %1 every "); | ||
56 | strMonthDayTemplate = QObject::tr("The %1 %1 of every"); | ||
57 | strWeekTemplate = QObject::tr("Every "); | ||
58 | dayLabel[0] = QObject::tr("Monday"); | ||
59 | dayLabel[1] = QObject::tr("Tuesday"); | ||
60 | dayLabel[2] = QObject::tr("Wednesday"); | ||
61 | dayLabel[3] = QObject::tr("Thursday"); | ||
62 | dayLabel[4] = QObject::tr("Friday"); | ||
63 | dayLabel[5] = QObject::tr("Saturday"); | ||
64 | dayLabel[6] = QObject::tr("Sunday"); | ||
65 | } | ||
49 | 66 | ||
50 | static QString numberPlacing( int x );// return the proper word format for | 67 | static QString numberPlacing( int x );// return the proper word format for |
51 | // x (1st, 2nd, etc) | 68 | // x (1st, 2nd, etc) |
52 | static int week( const QDate &dt ); // what week in the month is dt? | 69 | static int week( const QDate &dt ); // what week in the month is dt? |
53 | 70 | ||
54 | RepeatEntry::RepeatEntry( bool startOnMonday, | 71 | RepeatEntry::RepeatEntry( bool startOnMonday, |
55 | const QDate &newStart, QWidget *parent, | 72 | const QDate &newStart, QWidget *parent, |
56 | const char *name, bool modal, WFlags fl ) | 73 | const char *name, bool modal, WFlags fl ) |
57 | : RepeatEntryBase( parent, name, modal, fl ), | 74 | : RepeatEntryBase( parent, name, modal, fl ), |
58 | start( newStart ), | 75 | start( newStart ), |
59 | currInterval( NONE ), | 76 | currInterval( NONE ), |
60 | startWeekOnMonday( startOnMonday ) | 77 | startWeekOnMonday( startOnMonday ) |
61 | { | 78 | { |
79 | if (strDayTemplate.isEmpty() ) | ||
80 | fillStrings(); | ||
81 | |||
62 | init(); | 82 | init(); |
63 | fraType->setButton( currInterval ); | 83 | fraType->setButton( currInterval ); |
64 | chkNoEnd->setChecked( TRUE ); | 84 | chkNoEnd->setChecked( TRUE ); |
65 | setupNone(); | 85 | setupNone(); |
66 | } | 86 | } |
67 | 87 | ||
68 | RepeatEntry::RepeatEntry( bool startOnMonday, const Event::RepeatPattern &rp, | 88 | RepeatEntry::RepeatEntry( bool startOnMonday, const Event::RepeatPattern &rp, |
69 | const QDate &startDate, | 89 | const QDate &startDate, |
70 | QWidget *parent, const char *name, bool modal, | 90 | QWidget *parent, const char *name, bool modal, |
71 | WFlags fl ) | 91 | WFlags fl ) |
72 | : RepeatEntryBase( parent, name, modal, fl ), | 92 | : RepeatEntryBase( parent, name, modal, fl ), |
73 | start( startDate ), | 93 | start( startDate ), |
74 | end( rp.endDate() ), | 94 | end( rp.endDate() ), |
75 | startWeekOnMonday( startOnMonday ) | 95 | startWeekOnMonday( startOnMonday ) |
76 | { | 96 | { |
97 | if (strDayTemplate.isEmpty() ) | ||
98 | fillStrings(); | ||
77 | // do some stuff with the repeat pattern | 99 | // do some stuff with the repeat pattern |
78 | init(); | 100 | init(); |
79 | switch ( rp.type ) { | 101 | switch ( rp.type ) { |
80 | default: | 102 | default: |
81 | case Event::NoRepeat: | 103 | case Event::NoRepeat: |
82 | currInterval = NONE; | 104 | currInterval = NONE; |
83 | setupNone(); | 105 | setupNone(); |
84 | break; | 106 | break; |
85 | case Event::Daily: | 107 | case Event::Daily: |
86 | currInterval = DAY; | 108 | currInterval = DAY; |
87 | setupDaily(); | 109 | setupDaily(); |
88 | break; | 110 | break; |
@@ -491,25 +513,25 @@ void RepeatEntry::slotWeekLabel() | |||
491 | if ( bNeedCarriage ) | 513 | if ( bNeedCarriage ) |
492 | str += tr( ",\nand " ) + *itStr; | 514 | str += tr( ",\nand " ) + *itStr; |
493 | else | 515 | else |
494 | str += tr( ", and " ) + *itStr; | 516 | str += tr( ", and " ) + *itStr; |
495 | } | 517 | } |
496 | } else { | 518 | } else { |
497 | if ( bNeedCarriage ) | 519 | if ( bNeedCarriage ) |
498 | str += ",\n" + *itStr; | 520 | str += ",\n" + *itStr; |
499 | else | 521 | else |
500 | str += ", " + *itStr; | 522 | str += ", " + *itStr; |
501 | } | 523 | } |
502 | } | 524 | } |
503 | str = str.prepend( "on " ); | 525 | str = str.prepend( tr("on ") ); |
504 | lblWeekVar->setText( str ); | 526 | lblWeekVar->setText( str ); |
505 | } | 527 | } |
506 | 528 | ||
507 | void RepeatEntry::slotMonthLabel( int type ) | 529 | void RepeatEntry::slotMonthLabel( int type ) |
508 | { | 530 | { |
509 | QString str; | 531 | QString str; |
510 | if ( currInterval != MONTH || type > 1 ) | 532 | if ( currInterval != MONTH || type > 1 ) |
511 | return; | 533 | return; |
512 | if ( type == 1 ) | 534 | if ( type == 1 ) |
513 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); | 535 | str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); |
514 | else | 536 | else |
515 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) | 537 | str = strMonthDayTemplate.arg( numberPlacing(week(start))) |