summaryrefslogtreecommitdiff
path: root/library
authorzecke <zecke>2002-10-01 10:40:16 (UTC)
committer zecke <zecke>2002-10-01 10:40:16 (UTC)
commitc79aa2c8de0f508d45b993521b5c11e39de221e9 (patch) (unidiff)
treec132b7cd24fc5604ce52840daccb873edd2e53e5 /library
parent61fdbd044d40cb3c93eab5a1ba262964a9413c66 (diff)
downloadopie-c79aa2c8de0f508d45b993521b5c11e39de221e9.zip
opie-c79aa2c8de0f508d45b993521b5c11e39de221e9.tar.gz
opie-c79aa2c8de0f508d45b993521b5c11e39de221e9.tar.bz2
Patch by stelian
to fix problem with timezone switching The CityTime settngs app writes in to CityTime where the tzselector wanted to read from WorldTime thank
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/tzselect.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/tzselect.cpp b/library/tzselect.cpp
index e16b8d4..9436867 100644
--- a/library/tzselect.cpp
+++ b/library/tzselect.cpp
@@ -1,275 +1,275 @@
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 "global.h" 25#include "global.h"
26#include "config.h" 26#include "config.h"
27#include <qtoolbutton.h> 27#include <qtoolbutton.h>
28#include <qfile.h> 28#include <qfile.h>
29#include <stdlib.h> 29#include <stdlib.h>
30 30
31#ifdef Q_WS_QWS 31#ifdef Q_WS_QWS
32#include <qcopchannel_qws.h> 32#include <qcopchannel_qws.h>
33#endif 33#endif
34 34
35class TimeZoneSelectorPrivate 35class TimeZoneSelectorPrivate
36{ 36{
37public: 37public:
38 TimeZoneSelectorPrivate() : includeLocal(FALSE) {} 38 TimeZoneSelectorPrivate() : includeLocal(FALSE) {}
39 bool includeLocal; 39 bool includeLocal;
40}; 40};
41 41
42TZCombo::TZCombo( QWidget *p, const char* n ) 42TZCombo::TZCombo( QWidget *p, const char* n )
43 : QComboBox( p, n ) 43 : QComboBox( p, n )
44{ 44{
45 updateZones(); 45 updateZones();
46 // check to see if TZ is set, if it is set the current item to that 46 // check to see if TZ is set, if it is set the current item to that
47 QString tz = getenv("TZ"); 47 QString tz = getenv("TZ");
48 if (parent()->inherits("TimeZoneSelector")) { 48 if (parent()->inherits("TimeZoneSelector")) {
49 if ( ((TimeZoneSelector *)parent())->localIncluded() ) { 49 if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
50 // overide to the 'local' type. 50 // overide to the 'local' type.
51 tz = "None"; 51 tz = "None";
52 } 52 }
53 } 53 }
54 if ( !tz.isNull() ) { 54 if ( !tz.isNull() ) {
55 int n = 0, 55 int n = 0,
56 index = 0; 56 index = 0;
57 for ( QStringList::Iterator it=identifiers.begin(); 57 for ( QStringList::Iterator it=identifiers.begin();
58 it!=identifiers.end(); ++it) { 58 it!=identifiers.end(); ++it) {
59 if ( *it == tz ) 59 if ( *it == tz )
60 index = n; 60 index = n;
61 n++; 61 n++;
62 } 62 }
63 setCurrentItem(index); 63 setCurrentItem(index);
64 } else { 64 } else {
65 setCurrentItem(0); 65 setCurrentItem(0);
66 } 66 }
67 67
68 68
69 69
70 // listen on QPE/System 70 // listen on QPE/System
71#if defined(Q_WS_QWS) 71#if defined(Q_WS_QWS)
72#if !defined(QT_NO_COP) 72#if !defined(QT_NO_COP)
73 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 73 QCopChannel *channel = new QCopChannel( "QPE/System", this );
74 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 74 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
75 this, SLOT(handleSystemChannel(const QCString&, const QByteArray&)) ); 75 this, SLOT(handleSystemChannel(const QCString&, const QByteArray&)) );
76#endif 76#endif
77#endif 77#endif
78 78
79 79
80} 80}
81 81
82TZCombo::~TZCombo() 82TZCombo::~TZCombo()
83{ 83{
84} 84}
85 85
86void TZCombo::updateZones() 86void TZCombo::updateZones()
87{ 87{
88 QString cur = currentText(); 88 QString cur = currentText();
89 clear(); 89 clear();
90 identifiers.clear(); 90 identifiers.clear();
91 int curix=0; 91 int curix=0;
92 QString tz = getenv("TZ"); 92 QString tz = getenv("TZ");
93 bool tzFound = FALSE; 93 bool tzFound = FALSE;
94 Config cfg("WorldTime"); 94 Config cfg("CityTime");
95 cfg.setGroup("TimeZones"); 95 cfg.setGroup("TimeZones");
96 int listIndex = 0; 96 int listIndex = 0;
97 if (parent()->inherits("TimeZoneSelector")) { 97 if (parent()->inherits("TimeZoneSelector")) {
98 if ( ((TimeZoneSelector *)parent())->localIncluded() ) { 98 if ( ((TimeZoneSelector *)parent())->localIncluded() ) {
99 // overide to the 'local' type. 99 // overide to the 'local' type.
100 identifiers.append( "None" ); 100 identifiers.append( "None" );
101 insertItem( tr("None") ); 101 insertItem( tr("None") );
102 if ( cur == tr("None")) 102 if ( cur == tr("None"))
103 curix = 0; 103 curix = 0;
104 listIndex++; 104 listIndex++;
105 } 105 }
106 } 106 }
107 int cfgIndex = 0; 107 int cfgIndex = 0;
108 while (1) { 108 while (1) {
109 QString zn = cfg.readEntry("Zone"+QString::number(cfgIndex), QString::null); 109 QString zn = cfg.readEntry("Zone"+QString::number(cfgIndex), QString::null);
110 if ( zn.isNull() ) 110 if ( zn.isNull() )
111 break; 111 break;
112 if ( zn == tz ) 112 if ( zn == tz )
113 tzFound = TRUE; 113 tzFound = TRUE;
114 QString nm = cfg.readEntry("ZoneName"+QString::number(cfgIndex)); 114 QString nm = cfg.readEntry("ZoneName"+QString::number(cfgIndex));
115 identifiers.append(zn); 115 identifiers.append(zn);
116 insertItem(nm); 116 insertItem(nm);
117 if ( nm == cur ) 117 if ( nm == cur )
118 curix = listIndex; 118 curix = listIndex;
119 ++cfgIndex; 119 ++cfgIndex;
120 ++listIndex; 120 ++listIndex;
121 } 121 }
122 if ( !listIndex ) { 122 if ( !listIndex ) {
123 QStringList list = timezoneDefaults(); 123 QStringList list = timezoneDefaults();
124 for ( QStringList::Iterator it = list.begin(); it!=list.end(); ++it ) { 124 for ( QStringList::Iterator it = list.begin(); it!=list.end(); ++it ) {
125 QString zn = *it; 125 QString zn = *it;
126 QString nm = *++it; 126 QString nm = *++it;
127 if ( zn == tz ) 127 if ( zn == tz )
128 tzFound = TRUE; 128 tzFound = TRUE;
129 if ( nm == cur ) 129 if ( nm == cur )
130 curix = listIndex; 130 curix = listIndex;
131 identifiers.append(zn); 131 identifiers.append(zn);
132 insertItem(nm); 132 insertItem(nm);
133 ++listIndex; 133 ++listIndex;
134 } 134 }
135 } 135 }
136 for (QStringList::Iterator it=extras.begin(); it!=extras.end(); ++it) { 136 for (QStringList::Iterator it=extras.begin(); it!=extras.end(); ++it) {
137 insertItem(*it); 137 insertItem(*it);
138 identifiers.append(*it); 138 identifiers.append(*it);
139 if ( *it == cur ) 139 if ( *it == cur )
140 curix = listIndex; 140 curix = listIndex;
141 ++listIndex; 141 ++listIndex;
142 } 142 }
143 if ( !tzFound && !tz.isEmpty()) { 143 if ( !tzFound && !tz.isEmpty()) {
144 int i = tz.find( '/' ); 144 int i = tz.find( '/' );
145 QString nm = tz.mid( i+1 ).replace(QRegExp("_"), " "); 145 QString nm = tz.mid( i+1 ).replace(QRegExp("_"), " ");
146 identifiers.append(tz); 146 identifiers.append(tz);
147 insertItem(nm); 147 insertItem(nm);
148 if ( nm == cur ) 148 if ( nm == cur )
149 curix = listIndex; 149 curix = listIndex;
150 ++listIndex; 150 ++listIndex;
151 } 151 }
152 setCurrentItem(curix); 152 setCurrentItem(curix);
153} 153}
154 154
155 155
156void TZCombo::keyPressEvent( QKeyEvent *e ) 156void TZCombo::keyPressEvent( QKeyEvent *e )
157{ 157{
158 // ### should popup() in Qt 3.0 (it's virtual there) 158 // ### should popup() in Qt 3.0 (it's virtual there)
159// updateZones(); 159// updateZones();
160 QComboBox::keyPressEvent(e); 160 QComboBox::keyPressEvent(e);
161} 161}
162 162
163void TZCombo::mousePressEvent(QMouseEvent*e) 163void TZCombo::mousePressEvent(QMouseEvent*e)
164{ 164{
165 // ### should popup() in Qt 3.0 (it's virtual there) 165 // ### should popup() in Qt 3.0 (it's virtual there)
166// updateZones(); 166// updateZones();
167 QComboBox::mousePressEvent(e); 167 QComboBox::mousePressEvent(e);
168} 168}
169 169
170QString TZCombo::currZone() const 170QString TZCombo::currZone() const
171{ 171{
172 return identifiers[currentItem()]; 172 return identifiers[currentItem()];
173} 173}
174 174
175void TZCombo::setCurrZone( const QString& id ) 175void TZCombo::setCurrZone( const QString& id )
176{ 176{
177 for (int i=0; i< count(); i++) { 177 for (int i=0; i< count(); i++) {
178 if ( identifiers[i] == id ) { 178 if ( identifiers[i] == id ) {
179 setCurrentItem(i); 179 setCurrentItem(i);
180 return; 180 return;
181} 181}
182 } 182 }
183 insertItem(id); 183 insertItem(id);
184 setCurrentItem( count() - 1); 184 setCurrentItem( count() - 1);
185 identifiers.append(id); 185 identifiers.append(id);
186 extras.append(id); 186 extras.append(id);
187} 187}
188 188
189 189
190 190
191void TZCombo::handleSystemChannel(const QCString&msg, const QByteArray&) 191void TZCombo::handleSystemChannel(const QCString&msg, const QByteArray&)
192{ 192{
193 if ( msg == "timeZoneListChange()" ) { 193 if ( msg == "timeZoneListChange()" ) {
194 updateZones(); 194 updateZones();
195 } 195 }
196} 196}
197 197
198 198
199TimeZoneSelector::TimeZoneSelector(QWidget* p, const char* n) : 199TimeZoneSelector::TimeZoneSelector(QWidget* p, const char* n) :
200 QHBox(p,n) 200 QHBox(p,n)
201{ 201{
202 d = new TimeZoneSelectorPrivate(); 202 d = new TimeZoneSelectorPrivate();
203 // build the combobox before we do any updates... 203 // build the combobox before we do any updates...
204 cmbTz = new TZCombo( this, "timezone combo" ); 204 cmbTz = new TZCombo( this, "timezone combo" );
205 205
206 cmdTz = new QToolButton( this, "timezone button" ); 206 cmdTz = new QToolButton( this, "timezone button" );
207 cmdTz->setIconSet( Resource::loadIconSet( "citytime_icon" ) ); 207 cmdTz->setIconSet( Resource::loadIconSet( "citytime_icon" ) );
208 cmdTz->setMaximumSize( cmdTz->sizeHint() ); 208 cmdTz->setMaximumSize( cmdTz->sizeHint() );
209 209
210 // set up a connection to catch a newly selected item and throw our 210 // set up a connection to catch a newly selected item and throw our
211 // signal 211 // signal
212 QObject::connect( cmbTz, SIGNAL( activated( int ) ), 212 QObject::connect( cmbTz, SIGNAL( activated( int ) ),
213 this, SLOT( slotTzActive( int ) ) ); 213 this, SLOT( slotTzActive( int ) ) );
214 QObject::connect( cmdTz, SIGNAL( clicked() ), 214 QObject::connect( cmdTz, SIGNAL( clicked() ),
215 this, SLOT( slotExecute() ) ); 215 this, SLOT( slotExecute() ) );
216} 216}
217 217
218TimeZoneSelector::~TimeZoneSelector() 218TimeZoneSelector::~TimeZoneSelector()
219{ 219{
220} 220}
221 221
222void TimeZoneSelector::setLocalIncluded(bool b) 222void TimeZoneSelector::setLocalIncluded(bool b)
223{ 223{
224 d->includeLocal = b; 224 d->includeLocal = b;
225 cmbTz->updateZones(); 225 cmbTz->updateZones();
226} 226}
227 227
228bool TimeZoneSelector::localIncluded() const 228bool TimeZoneSelector::localIncluded() const
229{ 229{
230 return d->includeLocal; 230 return d->includeLocal;
231} 231}
232 232
233 233
234QString TimeZoneSelector::currentZone() const 234QString TimeZoneSelector::currentZone() const
235{ 235{
236 return cmbTz->currZone(); 236 return cmbTz->currZone();
237} 237}
238 238
239void TimeZoneSelector::setCurrentZone( const QString& id ) 239void TimeZoneSelector::setCurrentZone( const QString& id )
240{ 240{
241 cmbTz->setCurrZone( id ); 241 cmbTz->setCurrZone( id );
242} 242}
243 243
244void TimeZoneSelector::slotTzActive( int ) 244void TimeZoneSelector::slotTzActive( int )
245{ 245{
246 emit signalNewTz( cmbTz->currZone() ); 246 emit signalNewTz( cmbTz->currZone() );
247} 247}
248 248
249void TimeZoneSelector::slotExecute( void ) 249void TimeZoneSelector::slotExecute( void )
250{ 250{
251 // execute the world time application... 251 // execute the world time application...
252 Global::execute( "citytime" ); 252 Global::execute( "citytime" );
253} 253}
254 254
255QStringList timezoneDefaults( void ) 255QStringList timezoneDefaults( void )
256{ 256{
257 QStringList tzs; 257 QStringList tzs;
258 // load up the list just like the file format (citytime.cpp) 258 // load up the list just like the file format (citytime.cpp)
259 tzs.append( "America/New_York" ); 259 tzs.append( "America/New_York" );
260 tzs.append( "New York" ); 260 tzs.append( "New York" );
261 tzs.append( "America/Los_Angeles" ); 261 tzs.append( "America/Los_Angeles" );
262 tzs.append( "Los Angeles" ); 262 tzs.append( "Los Angeles" );
263 tzs.append( "Australia/Brisbane" ); 263 tzs.append( "Australia/Brisbane" );
264 tzs.append( "Brisbane" ); 264 tzs.append( "Brisbane" );
265 tzs.append( "Europe/Berlin" ); 265 tzs.append( "Europe/Berlin" );
266 tzs.append( "Berlin" ); 266 tzs.append( "Berlin" );
267 tzs.append( "Asia/Tokyo" ); 267 tzs.append( "Asia/Tokyo" );
268 tzs.append( "Tokyo" ); 268 tzs.append( "Tokyo" );
269 tzs.append( "America/Denver" ); 269 tzs.append( "America/Denver" );
270 tzs.append( "Denver" ); 270 tzs.append( "Denver" );
271 271
272 return tzs; 272 return tzs;
273} 273}
274 274
275 275