[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdebase/kcontrol/locale
From:       Hans Petter Bieker <bieker () kde ! org>
Date:       2003-01-03 21:45:30
[Download RAW message or body]

CVS commit by bieker: 

Use KCalendarSystem when printing day names.


  M +29 -12    localetime.cpp   1.53
  M +2 -0      localetime.h   1.18


--- kdebase/kcontrol/locale/localetime.cpp  #1.52:1.53
@@ -38,4 +38,5 @@
 #include <kstandarddirs.h>
 #include <kdebug.h>
+#include <kcalendarsystem.h>
 
 #include "toplevel.h"
@@ -235,9 +236,5 @@ KLocaleConfigTime::KLocaleConfigTime(KLo
            this, SLOT(slotWeekStartDayChanged(int)));
 
-  QStringList tmpDays;
-  tmpDays << I18N_NOOP("Monday") << I18N_NOOP("Tuesday") << I18N_NOOP("Wednesday")
-          << I18N_NOOP("Thursday") << I18N_NOOP("Friday") << I18N_NOOP("Saturday")
-          << I18N_NOOP("Sunday");
-  m_comboWeekStartDay->insertStringList(tmpDays);
+  updateWeekDayNames();
 
   m_chDateMonthNamePossessive = new QCheckBox(this, I18N_NOOP("Use declined form of month name"));
@@ -335,4 +332,6 @@ void KLocaleConfigTime::slotCalendarSyst
 
   m_locale->setCalendar(calendarType);
+
+  updateWeekDayNames();
 }
 
@@ -449,11 +448,5 @@ void KLocaleConfigTime::slotTranslate()
   m_comboDateFmtShort->setEditText(old);
 
-  m_comboWeekStartDay->changeItem(m_locale->translate("Monday"),    0);
-  m_comboWeekStartDay->changeItem(m_locale->translate("Tuesday"),   1);
-  m_comboWeekStartDay->changeItem(m_locale->translate("Wednesday"), 2);
-  m_comboWeekStartDay->changeItem(m_locale->translate("Thursday"),  3);
-  m_comboWeekStartDay->changeItem(m_locale->translate("Friday"),    4);
-  m_comboWeekStartDay->changeItem(m_locale->translate("Saturday"),  5);
-  m_comboWeekStartDay->changeItem(m_locale->translate("Sunday"),    6);
+  updateWeekDayNames();
 
   while ( m_comboCalendarSystem->count() < 2 )
@@ -532,4 +525,28 @@ void KLocaleConfigTime::slotTranslate()
        "names should be used in dates.</p>");
     QWhatsThis::add( m_chDateMonthNamePossessive,  str );
+  }
+}
+
+void KLocaleConfigTime::updateWeekDayNames()
+{
+  const KCalendarSystem * calendar = m_locale->calendar();
+
+  for ( int i = 1; ; ++i )
+  {
+    QString str = calendar->weekDayName(i);
+    bool outsideComboList = m_comboWeekStartDay->count() < i;
+
+    if ( str.isNull() )
+    {
+      if ( outsideComboList )
+        break;
+      else
+        m_comboWeekStartDay->removeItem(i - 1);
+    }
+        
+    if ( outsideComboList )
+      m_comboWeekStartDay->insertItem(str, i - 1);
+    else
+      m_comboWeekStartDay->changeItem(str, i - 1);
   }
 }

--- kdebase/kcontrol/locale/localetime.h  #1.17:1.18
@@ -73,4 +73,6 @@ private slots:
 
 private:
+  void updateWeekDayNames();
+
   QValueList<StringPair> timeMap() const;
   QValueList<StringPair> dateMap() const;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic