Diffstat (limited to 'core/settings/citytime/citytime.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/citytime/citytime.cpp | 94 |
1 files changed, 49 insertions, 45 deletions
diff --git a/core/settings/citytime/citytime.cpp b/core/settings/citytime/citytime.cpp index 721285d..d73bda1 100644 --- a/core/settings/citytime/citytime.cpp +++ b/core/settings/citytime/citytime.cpp | |||
@@ -23,18 +23,22 @@ | |||
23 | #include "zonemap.h" | 23 | #include "zonemap.h" |
24 | #include "citytime.h" | 24 | #include "citytime.h" |
25 | 25 | ||
26 | /* OPIE */ | ||
26 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
28 | #include <qpe/tzselect.h> | 29 | #include <qpe/tzselect.h> |
29 | #if !defined(QT_NO_COP) | 30 | #if !defined(QT_NO_COP) |
30 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
31 | #endif | 32 | #endif |
33 | #include <opie2/odebug.h> | ||
32 | 34 | ||
35 | /* QT */ | ||
33 | #include <qlabel.h> | 36 | #include <qlabel.h> |
34 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
35 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
36 | #include <qlayout.h> | 39 | #include <qlayout.h> |
37 | 40 | ||
41 | /* STD */ | ||
38 | #include <stdlib.h> | 42 | #include <stdlib.h> |
39 | 43 | ||
40 | CityTime::CityTime( QWidget *parent, const char* name, | 44 | CityTime::CityTime( QWidget *parent, const char* name, |
@@ -46,7 +50,7 @@ CityTime::CityTime( QWidget *parent, const char* name, | |||
46 | Config config( "qpe" ); | 50 | Config config( "qpe" ); |
47 | config.setGroup( "Time" ); | 51 | config.setGroup( "Time" ); |
48 | bWhichClock = config.readBoolEntry( "AMPM", TRUE ); | 52 | bWhichClock = config.readBoolEntry( "AMPM", TRUE ); |
49 | qDebug( QString("%1").arg(bWhichClock) ); | 53 | odebug << QString("%1").arg(bWhichClock) << oendl; |
50 | frmMap->changeClock( bWhichClock ); | 54 | frmMap->changeClock( bWhichClock ); |
51 | 55 | ||
52 | char *pEnv; | 56 | char *pEnv; |
@@ -118,33 +122,33 @@ CityTime::CityTime( QWidget *parent, const char* name, | |||
118 | CityTime::~CityTime() | 122 | CityTime::~CityTime() |
119 | { | 123 | { |
120 | if ( changed ) { | 124 | if ( changed ) { |
121 | Config cfg("CityTime"); | 125 | Config cfg("CityTime"); |
122 | cfg.setGroup("TimeZones"); | 126 | cfg.setGroup("TimeZones"); |
123 | QListIterator<QToolButton> itCity( listCities ); | 127 | QListIterator<QToolButton> itCity( listCities ); |
124 | int i; | 128 | int i; |
125 | bool realTzWritten = FALSE; | 129 | bool realTzWritten = FALSE; |
126 | for ( i = 0, itCity.toFirst(); i < CITIES; i++, ++itCity ) { | 130 | for ( i = 0, itCity.toFirst(); i < CITIES; i++, ++itCity ) { |
127 | if ( !strCityTz[i].isNull() ) { | 131 | if ( !strCityTz[i].isNull() ) { |
128 | cfg.writeEntry("Zone"+QString::number(i), strCityTz[i]); | 132 | cfg.writeEntry("Zone"+QString::number(i), strCityTz[i]); |
129 | cfg.writeEntry("ZoneName"+QString::number(i), itCity.current()->text()); | 133 | cfg.writeEntry("ZoneName"+QString::number(i), itCity.current()->text()); |
130 | if ( strCityTz[i] == strRealTz ) | 134 | if ( strCityTz[i] == strRealTz ) |
131 | realTzWritten = TRUE; | 135 | realTzWritten = TRUE; |
132 | } | 136 | } |
133 | } | 137 | } |
134 | if ( realTzWritten ) { | 138 | if ( realTzWritten ) { |
135 | cfg.removeEntry("Zone"+QString::number(CITIES)); | 139 | cfg.removeEntry("Zone"+QString::number(CITIES)); |
136 | cfg.removeEntry("ZoneName"+QString::number(CITIES)); | 140 | cfg.removeEntry("ZoneName"+QString::number(CITIES)); |
137 | } else { | 141 | } else { |
138 | cfg.writeEntry("Zone"+QString::number(CITIES), strRealTz); | 142 | cfg.writeEntry("Zone"+QString::number(CITIES), strRealTz); |
139 | if ( nameRealTz.isEmpty() ) { | 143 | if ( nameRealTz.isEmpty() ) { |
140 | int i = strRealTz.find( '/' ); | 144 | int i = strRealTz.find( '/' ); |
141 | nameRealTz = strRealTz.mid( i+1 ); | 145 | nameRealTz = strRealTz.mid( i+1 ); |
142 | } | 146 | } |
143 | cfg.writeEntry("ZoneName"+QString::number(CITIES), nameRealTz); | 147 | cfg.writeEntry("ZoneName"+QString::number(CITIES), nameRealTz); |
144 | } | 148 | } |
145 | QCopEnvelope ( "QPE/System", "timeZoneListChange()" ); | 149 | QCopEnvelope ( "QPE/System", "timeZoneListChange()" ); |
146 | 150 | ||
147 | changed = FALSE; | 151 | changed = FALSE; |
148 | } | 152 | } |
149 | // restore the timezone, just in case we messed with it and | 153 | // restore the timezone, just in case we messed with it and |
150 | // are destroyed at an inoppurtune moment | 154 | // are destroyed at an inoppurtune moment |
@@ -158,7 +162,7 @@ CityTime::~CityTime() | |||
158 | void CityTime::timerEvent( QTimerEvent *e ) | 162 | void CityTime::timerEvent( QTimerEvent *e ) |
159 | { | 163 | { |
160 | if ( e ) | 164 | if ( e ) |
161 | killTimer( timerId ); | 165 | killTimer( timerId ); |
162 | // change the time again!! | 166 | // change the time again!! |
163 | showTime(); | 167 | showTime(); |
164 | int ms = 1000 - QTime::currentTime().msec(); | 168 | int ms = 1000 - QTime::currentTime().msec(); |
@@ -180,7 +184,7 @@ void CityTime::showTime( void ) | |||
180 | for ( i = 0, itTime.toFirst(); i < CITIES; i++, ++itTime) { | 184 | for ( i = 0, itTime.toFirst(); i < CITIES; i++, ++itTime) { |
181 | if ( !strCityTz[i].isNull() ) { | 185 | if ( !strCityTz[i].isNull() ) { |
182 | if ( setenv( "TZ", strCityTz[i], true ) == 0 ) { | 186 | if ( setenv( "TZ", strCityTz[i], true ) == 0 ) { |
183 | itTime.current()->setText( TimeString::shortTime( bWhichClock ) ); | 187 | itTime.current()->setText( TimeString::shortTime( bWhichClock ) ); |
184 | } else { | 188 | } else { |
185 | QMessageBox::critical( this, tr( "Time Changing" ), | 189 | QMessageBox::critical( this, tr( "Time Changing" ), |
186 | tr( "There was a problem setting timezone %1" ) | 190 | tr( "There was a problem setting timezone %1" ) |
@@ -223,7 +227,7 @@ void CityTime::slotNewTz( const QString & strNewCountry, | |||
223 | cmdTmp->toggle(); | 227 | cmdTmp->toggle(); |
224 | // we can actually break, since there is only one button | 228 | // we can actually break, since there is only one button |
225 | // that is ever pressed! | 229 | // that is ever pressed! |
226 | changed = TRUE; | 230 | changed = TRUE; |
227 | break; | 231 | break; |
228 | } | 232 | } |
229 | } | 233 | } |
@@ -241,15 +245,15 @@ void CityTime::readInTimes( void ) | |||
241 | nameRealTz = QString::null; | 245 | nameRealTz = QString::null; |
242 | QString zn; | 246 | QString zn; |
243 | for ( ; i < CITIES ; i++ ) { | 247 | for ( ; i < CITIES ; i++ ) { |
244 | zn = cfg.readEntry("Zone"+QString::number(i), QString::null); | 248 | zn = cfg.readEntry("Zone"+QString::number(i), QString::null); |
245 | if ( zn.isNull() ) | 249 | if ( zn.isNull() ) |
246 | break; | 250 | break; |
247 | QString nm = cfg.readEntry("ZoneName"+QString::number(i)); | 251 | QString nm = cfg.readEntry("ZoneName"+QString::number(i)); |
248 | strCityTz[i] = zn; | 252 | strCityTz[i] = zn; |
249 | itCity.current()->setText(nm); | 253 | itCity.current()->setText(nm); |
250 | if ( zn == strRealTz ) | 254 | if ( zn == strRealTz ) |
251 | nameRealTz = nm; | 255 | nameRealTz = nm; |
252 | ++itCity; | 256 | ++itCity; |
253 | } | 257 | } |
254 | if ( i == 0 ) { | 258 | if ( i == 0 ) { |
255 | // write in our own in a shameless self promotion and some humor | 259 | // write in our own in a shameless self promotion and some humor |
@@ -263,12 +267,12 @@ void CityTime::readInTimes( void ) | |||
263 | } | 267 | } |
264 | } | 268 | } |
265 | if ( nameRealTz.isEmpty() ) { | 269 | if ( nameRealTz.isEmpty() ) { |
266 | //remember the current time zone even if we don't have room | 270 | //remember the current time zone even if we don't have room |
267 | //to show it. | 271 | //to show it. |
268 | zn = cfg.readEntry("Zone"+QString::number(CITIES), QString::null); | 272 | zn = cfg.readEntry("Zone"+QString::number(CITIES), QString::null); |
269 | if ( zn == strRealTz ) | 273 | if ( zn == strRealTz ) |
270 | nameRealTz = cfg.readEntry("ZoneName"+QString::number(CITIES)); | 274 | nameRealTz = cfg.readEntry("ZoneName"+QString::number(CITIES)); |
271 | i++; | 275 | i++; |
272 | } | 276 | } |
273 | } | 277 | } |
274 | 278 | ||