$NetBSD: patch-ao,v 1.1 2006/07/24 12:43:40 markd Exp $ --- korganizer/koprefsdialog.cpp.orig 2005-09-10 20:24:47.000000000 +1200 +++ korganizer/koprefsdialog.cpp @@ -75,6 +75,7 @@ #include "stdcalendar.h" #include +#include KOPrefsDialogMain::KOPrefsDialogMain( QWidget *parent, const char *name ) : KPrefsModule( KOPrefs::instance(), parent, name ) @@ -169,67 +170,25 @@ class KOPrefsDialogTime : public KPrefsM connect( mTimeZoneCombo, SIGNAL( activated( int ) ), SLOT( slotWidChanged() ) ); - FILE *f; - char tempstring[101] = "Unknown"; - QString sCurrentlySet(i18n("Unknown")); + KTimezones *db; + const KTimezone *sCurrentlySet; int nCurrentlySet = 0; QStringList list; + db = new KTimezones(); // read the currently set time zone - #if defined(USE_SOLARIS) // MARCO - char buf[MAXPATHLEN]; - - snprintf(buf, MAXPATHLEN, - "/bin/fgrep 'TZ=' %s | /bin/head -n 1 | /bin/cut -b 4-", - INITFILE); - - if (f = popen(buf, "r")) - { - if (fgets(buf, MAXPATHLEN - 1, f) != NULL) - { - buf[strlen(buf) - 1] = '\0'; - sCurrentlySet = QString(buf); - } - pclose(f); - } - #else - if((f = fopen("/etc/timezone", "r")) != NULL) { - // get the currently set timezone - fgets(tempstring, 100, f); - tempstring[strlen(tempstring) - 1] = '\0'; - sCurrentlySet = QString(tempstring); - fclose(f); - } - #endif // !USE_SOLARIS + sCurrentlySet = db->local(); mTimeZoneCombo->insertItem(i18n("[No selection]")); // Read all system time zones - #if defined(USE_SOLARIS) // MARCO - snprintf(buf, MAXPATHLEN, - "/bin/find %s \\( -name src -prune \\) -o -type f -print | /bin/cut -b %d-", - ZONEINFODIR, strlen(ZONEINFODIR) + 2); - - if (f = popen(buf, "r")) - { - while(fgets(buf, MAXPATHLEN - 1, f) != NULL) - { - buf[strlen(buf) - 1] = '\0'; - list.append(buf); - } - pclose(f); - } - - #else - f = popen("grep -e ^[^#] /usr/share/zoneinfo/zone.tab | cut -f 3","r"); - if (!f) return; - while(fgets(tempstring, 100, f) != NULL) { - tempstring[strlen(tempstring)-1] = '\0'; - list.append(i18n(tempstring)); - tzonenames << tempstring; + const KTimezones::ZoneMap zones = db->allZones(); + for (KTimezones::ZoneMap::ConstIterator it = zones.begin(); it != zones.end(); ++it) + { + const KTimezone *zone = it.data(); + list.append(zone->name()); + tzonenames << zone->name(); } - pclose(f); - #endif // !USE_SOLARIS list.sort(); mTimeZoneCombo->insertStringList(list); @@ -237,7 +196,7 @@ class KOPrefsDialogTime : public KPrefsM // find the currently set time zone and select it for ( int i = 0; i < mTimeZoneCombo->count(); ++i ) { - if (mTimeZoneCombo->text(i) == sCurrentlySet) + if (mTimeZoneCombo->text(i) == sCurrentlySet->name()) { nCurrentlySet = i; break; @@ -246,6 +205,7 @@ class KOPrefsDialogTime : public KPrefsM mTimeZoneCombo->setCurrentItem(nCurrentlySet); QWhatsThis::add( mTimeZoneCombo, whatsThis ); + delete db; // holiday region selection QHBox *holidayRegBox = new QHBox( topFrame );