summaryrefslogtreecommitdiff
path: root/misc/kdepim3/patches/patch-ao
blob: f3cf9bae723b3ac7c667956b466d99b66c53dbf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
$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 <kdepimmacros.h>
 
+#include <ktimezones.h>
 
 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 );