summaryrefslogtreecommitdiff
path: root/libopie/orecurrancewidget.cpp
Side-by-side diff
Diffstat (limited to 'libopie/orecurrancewidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/orecurrancewidget.cpp56
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 @@
#include <qpe/timestring.h>
#include "orecurrancewidget.h"
// Global Templates for use in setting up the repeat label...
-const QString strDayTemplate = QObject::tr("Every");
-const QString strYearTemplate = QObject::tr("%1 %2 every ");
-const QString strMonthDateTemplate = QObject::tr("The %1 every ");
-const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every");
-const QString strWeekTemplate = QObject::tr("Every ");
-const QString dayLabel[] = { QObject::tr("Monday"),
- QObject::tr("Tuesday"),
- QObject::tr("Wednesday"),
- QObject::tr("Thursday"),
- QObject::tr("Friday"),
- QObject::tr("Saturday"),
- QObject::tr("Sunday") };
+// the problem is these strings get initialized before QPEApplication can install the translator -zecke
+namespace {
+QString strDayTemplate;
+QString strYearTemplate;
+QString strMonthDateTemplate;
+QString strMonthDayTemplate;
+QString strWeekTemplate;
+QString dayLabel[7];
+}
+/*
+ * static linkage to not polute the symbol table...
+ * The problem is that const and static linkage are resolved prior to installing a translator
+ * leading to that the above strings are translted but to the original we delay the init of these strings...
+ * -zecke
+ */
+static void fillStrings() {
+ strDayTemplate = QObject::tr("Every");
+ strYearTemplate = QObject::tr("%1 %2 every ");
+ strMonthDateTemplate = QObject::tr("The %1 every ");
+ strMonthDayTemplate = QObject::tr("The %1 %2 of every");
+ strWeekTemplate = QObject::tr("Every ");
+ dayLabel[0] = QObject::tr("Monday");
+ dayLabel[1] = QObject::tr("Tuesday");
+ dayLabel[2] = QObject::tr("Wednesday");
+ dayLabel[3] = QObject::tr("Thursday");
+ dayLabel[4] = QObject::tr("Friday");
+ dayLabel[5] = QObject::tr("Saturday");
+ dayLabel[6] = QObject::tr("Sunday");
+}
static QString numberPlacing( int x ); // return the proper word format for
// x (1st, 2nd, etc)
static int week( const QDate &dt ); // what week in the month is dt?
/**
@@ -43,12 +60,15 @@ ORecurranceWidget::ORecurranceWidget( bool startOnMonday,
WFlags fl )
: ORecurranceBase( parent, name, modal, fl ),
start( newStart ),
currInterval( None ),
startWeekOnMonday( startOnMonday )
{
+ if (strDayTemplate.isEmpty() )
+ fillStrings();
+
init();
fraType->setButton( currInterval );
chkNoEnd->setChecked( TRUE );
setupNone();
}
@@ -68,12 +88,14 @@ ORecurranceWidget::ORecurranceWidget( bool startOnMonday,
bool modal, WFlags fl)
: ORecurranceBase( parent, name, modal, fl ),
start( startDate ),
end( rp.endDate() ),
startWeekOnMonday( startOnMonday )
{
+ if (strDayTemplate.isEmpty() )
+ fillStrings();
// do some stuff with the repeat pattern
init();
setRecurrence( rp );
}
ORecurranceWidget::~ORecurranceWidget() {
@@ -81,13 +103,12 @@ ORecurranceWidget::~ORecurranceWidget() {
/**
* set the start date
* @param date the new start date
*/
void ORecurranceWidget::setStartDate( const QDate& date ) {
- qWarning("ORecurranceWidget::setStartDate");
setRecurrence( recurrence(), date );
}
/**
* set the recurrence
* @param rp The ORecur object with the new recurrence rules
*/
@@ -364,24 +385,25 @@ void ORecurranceWidget::slotWeekLabel() {
if ( bNeedCarriage )
str += ",\n" + *itStr;
else
str += ", " + *itStr;
}
}
- str = str.prepend( "on " );
+ str = str.prepend( tr("on ") );
+
lblWeekVar->setText( str );
}
void ORecurranceWidget::slotMonthLabel(int type) {
QString str;
if ( currInterval != Month || type > 1 )
return;
if ( type == 1 )
- str = strMonthDateTemplate.arg( numberPlacing(start.day()) );
+ str = strMonthDateTemplate.arg( numberPlacing(start.day()) );
else
- str = strMonthDayTemplate.arg( numberPlacing(week(start)))
- .arg( dayLabel[start.dayOfWeek() - 1] );
+ str = strMonthDayTemplate.arg( numberPlacing(week(start)))
+ .arg( dayLabel[start.dayOfWeek() - 1] );
lblRepeat->setText( str );
}
void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) {
startWeekOnMonday = onMonday;
// we need to make this unintrusive as possible...
int saveSpin = spinFreq->value();