summaryrefslogtreecommitdiff
path: root/library/tzselect.cpp
Unidiff
Diffstat (limited to 'library/tzselect.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/tzselect.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/library/tzselect.cpp b/library/tzselect.cpp
index 848dfb7..8dd427f 100644
--- a/library/tzselect.cpp
+++ b/library/tzselect.cpp
@@ -1,158 +1,159 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define QTOPIA_INTERNAL_TZSELECT_INC_LOCAL 21#define QTOPIA_INTERNAL_TZSELECT_INC_LOCAL
22 22
23#include "tzselect.h" 23#include "tzselect.h"
24#include "resource.h" 24#include "resource.h"
25#include "config.h" 25#include "config.h"
26#include <qtoolbutton.h> 26#include <qtoolbutton.h>
27#include <qfile.h> 27#include <qfile.h>
28#include <stdlib.h> 28#include <stdlib.h>
29 29
30#include <qcopchannel_qws.h> 30#include <qcopchannel_qws.h>
31#include <qpe/global.h>
31#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
32#include <qmessagebox.h> 33#include <qmessagebox.h>
33 34
34/*! 35/*!
35 \class TimeZoneSelector 36 \class TimeZoneSelector
36 37
37 \brief The TimeZoneSelector widget allows users to configure their time zone information. 38 \brief The TimeZoneSelector widget allows users to configure their time zone information.
38 39
39 \ingroup qtopiaemb 40 \ingroup qtopiaemb
40*/ 41*/
41 42
42class TimeZoneSelectorPrivate 43class TimeZoneSelectorPrivate
43{ 44{
44public: 45public:
45 TimeZoneSelectorPrivate() : includeLocal(FALSE) {} 46 TimeZoneSelectorPrivate() : includeLocal(FALSE) {}
46 bool includeLocal; 47 bool includeLocal;
47}; 48};
48 49
49TZCombo::TZCombo( QWidget *p, const char* n ) 50TZCombo::TZCombo( QWidget *p, const char* n )
50 : QComboBox( p, n ) 51 : QComboBox( p, n )
51{ 52{
52 updateZones(); 53 updateZones();
53 // check to see if TZ is set, if it is set the current item to that 54 // check to see if TZ is set, if it is set the current item to that
54 QString tz = getenv("TZ"); 55 QString tz = getenv("TZ");
55 if (parent()->inherits("TimeZoneSelector")) { 56 if (parent()->inherits("TimeZoneSelector")) {
56 if ( ((TimeZoneSelector *)parent())->localIncluded() ) { 57 if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
57 // overide to the 'local' type. 58 // overide to the 'local' type.
58 tz = "None"; 59 tz = "None";
59 } 60 }
60 } 61 }
61 if ( !tz.isNull() ) { 62 if ( !tz.isNull() ) {
62 int n = 0, 63 int n = 0,
63 index = 0; 64 index = 0;
64 for ( QStringList::Iterator it=identifiers.begin(); 65 for ( QStringList::Iterator it=identifiers.begin();
65 it!=identifiers.end(); ++it) { 66 it!=identifiers.end(); ++it) {
66 if ( *it == tz ) 67 if ( *it == tz )
67 index = n; 68 index = n;
68 n++; 69 n++;
69 } 70 }
70 setCurrentItem(index); 71 setCurrentItem(index);
71 } else { 72 } else {
72 setCurrentItem(0); 73 setCurrentItem(0);
73 } 74 }
74 75
75 76
76 77
77 // listen on QPE/System 78 // listen on QPE/System
78#if !defined(QT_NO_COP) 79#if !defined(QT_NO_COP)
79 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 80 QCopChannel *channel = new QCopChannel( "QPE/System", this );
80 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 81 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
81 this, SLOT(handleSystemChannel(const QCString&,const QByteArray&)) ); 82 this, SLOT(handleSystemChannel(const QCString&,const QByteArray&)) );
82#endif 83#endif
83 84
84 85
85} 86}
86 87
87TZCombo::~TZCombo() 88TZCombo::~TZCombo()
88{ 89{
89} 90}
90 91
91void TZCombo::updateZones() 92void TZCombo::updateZones()
92{ 93{
93 QString cur = currentText(); 94 QString cur = currentText();
94 clear(); 95 clear();
95 identifiers.clear(); 96 identifiers.clear();
96 int curix=0; 97 int curix=0;
97 QString tz = getenv("TZ"); 98 QString tz = getenv("TZ");
98 bool tzFound = FALSE; 99 bool tzFound = FALSE;
99 Config cfg("CityTime"); 100 Config cfg("CityTime");
100 cfg.setGroup("TimeZones"); 101 cfg.setGroup("TimeZones");
101 int listIndex = 0; 102 int listIndex = 0;
102 if (parent()->inherits("TimeZoneSelector")) { 103 if (parent()->inherits("TimeZoneSelector")) {
103 if ( ((TimeZoneSelector *)parent())->localIncluded() ) { 104 if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
104 // overide to the 'local' type. 105 // overide to the 'local' type.
105 identifiers.append( "None" ); 106 identifiers.append( "None" );
106 insertItem( tr("None") ); 107 insertItem( tr("None") );
107 if ( cur == tr("None")) 108 if ( cur == tr("None"))
108 curix = 0; 109 curix = 0;
109 listIndex++; 110 listIndex++;
110 } 111 }
111 } 112 }
112 int cfgIndex = 0; 113 int cfgIndex = 0;
113 while (1) { 114 while (1) {
114 QString zn = cfg.readEntry("Zone"+QString::number(cfgIndex), QString::null); 115 QString zn = cfg.readEntry("Zone"+QString::number(cfgIndex), QString::null);
115 if ( zn.isNull() ) 116 if ( zn.isNull() )
116 break; 117 break;
117 if ( zn == tz ) 118 if ( zn == tz )
118 tzFound = TRUE; 119 tzFound = TRUE;
119 QString nm = cfg.readEntry("ZoneName"+QString::number(cfgIndex)); 120 QString nm = cfg.readEntry("ZoneName"+QString::number(cfgIndex));
120 identifiers.append(zn); 121 identifiers.append(zn);
121 insertItem(nm); 122 insertItem(nm);
122 if ( nm == cur ) 123 if ( nm == cur )
123 curix = listIndex; 124 curix = listIndex;
124 ++cfgIndex; 125 ++cfgIndex;
125 ++listIndex; 126 ++listIndex;
126 } 127 }
127 if ( !listIndex ) { 128 if ( !listIndex ) {
128 QStringList list = timezoneDefaults(); 129 QStringList list = timezoneDefaults();
129 for ( QStringList::Iterator it = list.begin(); it!=list.end(); ++it ) { 130 for ( QStringList::Iterator it = list.begin(); it!=list.end(); ++it ) {
130 QString zn = *it; 131 QString zn = *it;
131 QString nm = *++it; 132 QString nm = *++it;
132 if ( zn == tz ) 133 if ( zn == tz )
133 tzFound = TRUE; 134 tzFound = TRUE;
134 if ( nm == cur ) 135 if ( nm == cur )
135 curix = listIndex; 136 curix = listIndex;
136 identifiers.append(zn); 137 identifiers.append(zn);
137 insertItem(nm); 138 insertItem(nm);
138 ++listIndex; 139 ++listIndex;
139 } 140 }
140 } 141 }
141 for (QStringList::Iterator it=extras.begin(); it!=extras.end(); ++it) { 142 for (QStringList::Iterator it=extras.begin(); it!=extras.end(); ++it) {
142 insertItem(*it); 143 insertItem(*it);
143 identifiers.append(*it); 144 identifiers.append(*it);
144 if ( *it == cur ) 145 if ( *it == cur )
145 curix = listIndex; 146 curix = listIndex;
146 ++listIndex; 147 ++listIndex;
147 } 148 }
148 if ( !tzFound && !tz.isEmpty()) { 149 if ( !tzFound && !tz.isEmpty()) {
149 int i = tz.find( '/' ); 150 int i = tz.find( '/' );
150 QString nm = tz.mid( i+1 ).replace(QRegExp("_"), " "); 151 QString nm = tz.mid( i+1 ).replace(QRegExp("_"), " ");
151 identifiers.append(tz); 152 identifiers.append(tz);
152 insertItem(nm); 153 insertItem(nm);
153 if ( nm == cur ) 154 if ( nm == cur )
154 curix = listIndex; 155 curix = listIndex;
155 ++listIndex; 156 ++listIndex;
156 } 157 }
157 setCurrentItem(curix); 158 setCurrentItem(curix);
158} 159}