summaryrefslogtreecommitdiff
path: root/core/settings/citytime
authorar <ar>2004-05-02 17:31:50 (UTC)
committer ar <ar>2004-05-02 17:31:50 (UTC)
commita210b9a597ba0c929d95c38ffbaf972916c7b8a7 (patch) (unidiff)
treece121d5017eb054222c86e0afb6057a28ea7bf8a /core/settings/citytime
parent18759e9156c96795831120408a9da0d3b4ec71a4 (diff)
downloadopie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.zip
opie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.tar.gz
opie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.tar.bz2
- convert qDebug to odebug
Diffstat (limited to 'core/settings/citytime') (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/citytime/citytime.cpp94
-rw-r--r--core/settings/citytime/citytimebase.cpp120
-rw-r--r--core/settings/citytime/zonemap.cpp402
3 files changed, 314 insertions, 302 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
40CityTime::CityTime( QWidget *parent, const char* name, 44CityTime::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,
118CityTime::~CityTime() 122CityTime::~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()
158void CityTime::timerEvent( QTimerEvent *e ) 162void 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
diff --git a/core/settings/citytime/citytimebase.cpp b/core/settings/citytime/citytimebase.cpp
index 323929b..77cb91d 100644
--- a/core/settings/citytime/citytimebase.cpp
+++ b/core/settings/citytime/citytimebase.cpp
@@ -3,10 +3,14 @@
3// changes by Maximilian Reiss <harlekin@handhelds.org> 3// changes by Maximilian Reiss <harlekin@handhelds.org>
4 4
5#include "citytimebase.h" 5#include "citytimebase.h"
6#include "zonemap.h"
7
8/* OPIE */
9#include <opie2/odebug.h>
6 10
11/* QT */
7#include <qlabel.h> 12#include <qlabel.h>
8#include <qtoolbutton.h> 13#include <qtoolbutton.h>
9#include "zonemap.h"
10#include <qlayout.h> 14#include <qlayout.h>
11#include <qwhatsthis.h> 15#include <qwhatsthis.h>
12 16
@@ -19,7 +23,7 @@ CityTimeBase::CityTimeBase( QWidget* parent, const char* name, WFlags )
19 : QWidget( parent, name, WStyle_ContextHelp ) 23 : QWidget( parent, name, WStyle_ContextHelp )
20{ 24{
21 if ( !name ) 25 if ( !name )
22 setName( "CityTimeBase" ); 26 setName( "CityTimeBase" );
23 setCaption( tr( "City Time" ) ); 27 setCaption( tr( "City Time" ) );
24 CityTimeBaseLayout = new QVBoxLayout( this ); 28 CityTimeBaseLayout = new QVBoxLayout( this );
25 CityTimeBaseLayout->setSpacing( 3 ); 29 CityTimeBaseLayout->setSpacing( 3 );
@@ -341,71 +345,71 @@ bool CityTimeBase::event( QEvent* ev )
341{ 345{
342 bool ret = QWidget::event( ev ); 346 bool ret = QWidget::event( ev );
343 if ( ev->type() == QEvent::ApplicationFontChange ) { 347 if ( ev->type() == QEvent::ApplicationFontChange ) {
344 QFont cmdCity7_font( cmdCity7->font() ); 348 QFont cmdCity7_font( cmdCity7->font() );
345 cmdCity7_font.setBold( TRUE ); 349 cmdCity7_font.setBold( TRUE );
346 cmdCity7->setFont( cmdCity7_font ); 350 cmdCity7->setFont( cmdCity7_font );
347 QFont lblCTime9_font( lblCTime9->font() ); 351 QFont lblCTime9_font( lblCTime9->font() );
348 lblCTime9_font.setPointSize( 10 ); 352 lblCTime9_font.setPointSize( 10 );
349 lblCTime9->setFont( lblCTime9_font ); 353 lblCTime9->setFont( lblCTime9_font );
350 QFont cmdCity8_font( cmdCity8->font() ); 354 QFont cmdCity8_font( cmdCity8->font() );
351 cmdCity8_font.setBold( TRUE ); 355 cmdCity8_font.setBold( TRUE );
352 cmdCity8->setFont( cmdCity8_font ); 356 cmdCity8->setFont( cmdCity8_font );
353 QFont cmdCity2_font( cmdCity2->font() ); 357 QFont cmdCity2_font( cmdCity2->font() );
354 cmdCity2_font.setBold( TRUE ); 358 cmdCity2_font.setBold( TRUE );
355 cmdCity2->setFont( cmdCity2_font ); 359 cmdCity2->setFont( cmdCity2_font );
356 QFont lblCTime6_font( lblCTime6->font() ); 360 QFont lblCTime6_font( lblCTime6->font() );
357 lblCTime6_font.setPointSize( 10 ); 361 lblCTime6_font.setPointSize( 10 );
358 lblCTime6->setFont( lblCTime6_font ); 362 lblCTime6->setFont( lblCTime6_font );
359 QFont cmdCity6_font( cmdCity6->font() ); 363 QFont cmdCity6_font( cmdCity6->font() );
360 cmdCity6_font.setBold( TRUE ); 364 cmdCity6_font.setBold( TRUE );
361 cmdCity6->setFont( cmdCity6_font ); 365 cmdCity6->setFont( cmdCity6_font );
362 QFont cmdCity4_font( cmdCity4->font() ); 366 QFont cmdCity4_font( cmdCity4->font() );
363 cmdCity4_font.setBold( TRUE ); 367 cmdCity4_font.setBold( TRUE );
364 cmdCity4->setFont( cmdCity4_font ); 368 cmdCity4->setFont( cmdCity4_font );
365 QFont lblCTime5_font( lblCTime5->font() ); 369 QFont lblCTime5_font( lblCTime5->font() );
366 lblCTime5_font.setPointSize( 10 ); 370 lblCTime5_font.setPointSize( 10 );
367 lblCTime5->setFont( lblCTime5_font ); 371 lblCTime5->setFont( lblCTime5_font );
368 QFont lblCTime2_font( lblCTime2->font() ); 372 QFont lblCTime2_font( lblCTime2->font() );
369 lblCTime2_font.setPointSize( 10 ); 373 lblCTime2_font.setPointSize( 10 );
370 lblCTime2->setFont( lblCTime2_font ); 374 lblCTime2->setFont( lblCTime2_font );
371 QFont lblCTime1_font( lblCTime1->font() ); 375 QFont lblCTime1_font( lblCTime1->font() );
372 lblCTime1_font.setPointSize( 10 ); 376 lblCTime1_font.setPointSize( 10 );
373 lblCTime1->setFont( lblCTime1_font ); 377 lblCTime1->setFont( lblCTime1_font );
374 QFont cmdCity3_font( cmdCity3->font() ); 378 QFont cmdCity3_font( cmdCity3->font() );
375 cmdCity3_font.setBold( TRUE ); 379 cmdCity3_font.setBold( TRUE );
376 cmdCity3->setFont( cmdCity3_font ); 380 cmdCity3->setFont( cmdCity3_font );
377 QFont lblCTime8_font( lblCTime8->font() ); 381 QFont lblCTime8_font( lblCTime8->font() );
378 lblCTime8_font.setPointSize( 10 ); 382 lblCTime8_font.setPointSize( 10 );
379 lblCTime8->setFont( lblCTime8_font ); 383 lblCTime8->setFont( lblCTime8_font );
380 QFont cmdCity1_font( cmdCity1->font() ); 384 QFont cmdCity1_font( cmdCity1->font() );
381 cmdCity1_font.setBold( TRUE ); 385 cmdCity1_font.setBold( TRUE );
382 cmdCity1->setFont( cmdCity1_font ); 386 cmdCity1->setFont( cmdCity1_font );
383 QFont lblCTime7_font( lblCTime7->font() ); 387 QFont lblCTime7_font( lblCTime7->font() );
384 lblCTime7_font.setPointSize( 10 ); 388 lblCTime7_font.setPointSize( 10 );
385 lblCTime7->setFont( lblCTime7_font ); 389 lblCTime7->setFont( lblCTime7_font );
386 QFont lblCTime4_font( lblCTime4->font() ); 390 QFont lblCTime4_font( lblCTime4->font() );
387 lblCTime4_font.setPointSize( 10 ); 391 lblCTime4_font.setPointSize( 10 );
388 lblCTime4->setFont( lblCTime4_font ); 392 lblCTime4->setFont( lblCTime4_font );
389 QFont cmdCity5_font( cmdCity5->font() ); 393 QFont cmdCity5_font( cmdCity5->font() );
390 cmdCity5_font.setBold( TRUE ); 394 cmdCity5_font.setBold( TRUE );
391 cmdCity5->setFont( cmdCity5_font ); 395 cmdCity5->setFont( cmdCity5_font );
392 QFont lblCTime3_font( lblCTime3->font() ); 396 QFont lblCTime3_font( lblCTime3->font() );
393 lblCTime3_font.setPointSize( 10 ); 397 lblCTime3_font.setPointSize( 10 );
394 lblCTime3->setFont( lblCTime3_font ); 398 lblCTime3->setFont( lblCTime3_font );
395 QFont cmdCity9_font( cmdCity9->font() ); 399 QFont cmdCity9_font( cmdCity9->font() );
396 cmdCity9_font.setBold( TRUE ); 400 cmdCity9_font.setBold( TRUE );
397 cmdCity9->setFont( cmdCity9_font ); 401 cmdCity9->setFont( cmdCity9_font );
398 } 402 }
399 return ret; 403 return ret;
400} 404}
401 405
402void CityTimeBase::beginNewTz() 406void CityTimeBase::beginNewTz()
403{ 407{
404 qWarning( "CityTimeBase::beginNewTz(): Not implemented yet!" ); 408 owarn << "CityTimeBase::beginNewTz(): Not implemented yet!" << oendl;
405} 409}
406 410
407void CityTimeBase::slotNewTz(const QString &, const QString &) 411void CityTimeBase::slotNewTz(const QString &, const QString &)
408{ 412{
409 qWarning( "CityTimeBase::slotNewTz(const QString &, const QString &): Not implemented yet!" ); 413 owarn << "CityTimeBase::slotNewTz(const QString &, const QString &): Not implemented yet!" << oendl;
410} 414}
411 415
diff --git a/core/settings/citytime/zonemap.cpp b/core/settings/citytime/zonemap.cpp
index b6843d2..e4a25ef 100644
--- a/core/settings/citytime/zonemap.cpp
+++ b/core/settings/citytime/zonemap.cpp
@@ -23,9 +23,12 @@
23#include "sun.h" 23#include "sun.h"
24#include "zonemap.h" 24#include "zonemap.h"
25 25
26/* OPIE */
26#include <qpe/resource.h> 27#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
29#include <opie2/odebug.h>
28 30
31/* QT */
29#include <qfile.h> 32#include <qfile.h>
30#include <qlabel.h> 33#include <qlabel.h>
31#include <qmessagebox.h> 34#include <qmessagebox.h>
@@ -37,6 +40,7 @@
37#include <qlistview.h> 40#include <qlistview.h>
38#include <qwhatsthis.h> 41#include <qwhatsthis.h>
39 42
43/* STD */
40#include <limits.h> 44#include <limits.h>
41 45
42// the map file... 46// the map file...
@@ -61,12 +65,12 @@ static void dayNight( QImage *pImage );
61ZoneField::ZoneField( const QString& strLine ) 65ZoneField::ZoneField( const QString& strLine )
62{ 66{
63 // make a bunch of RegExp's to match the data from the line 67 // make a bunch of RegExp's to match the data from the line
64 QRegExp regCoord( "[-+][0-9]+" );// the latitude 68 QRegExp regCoord( "[-+][0-9]+" ); // the latitude
65 QRegExp regCountry( "[A-Za-z]+/" ); // the country (not good enough) 69 QRegExp regCountry( "[A-Za-z]+/" ); // the country (not good enough)
66 QRegExp regCity( "[A-Za-z_-]*" ); // the city 70 QRegExp regCity( "[A-Za-z_-]*" ); // the city
67 71
68 int iStart, 72 int iStart,
69 iStop, 73 iStop,
70 iLen, 74 iLen,
71 tmp; 75 tmp;
72 QString strTmp; 76 QString strTmp;
@@ -75,65 +79,65 @@ ZoneField::ZoneField( const QString& strLine )
75 strCountryCode = strLine.left( 2 ); 79 strCountryCode = strLine.left( 2 );
76 iStart = regCoord.match( strLine, 0, &iLen ); 80 iStart = regCoord.match( strLine, 0, &iLen );
77 if ( iStart >= 0 ) { 81 if ( iStart >= 0 ) {
78 strTmp = strLine.mid( iStart, iLen ); 82 strTmp = strLine.mid( iStart, iLen );
79 tmp = strTmp.toInt(); 83 tmp = strTmp.toInt();
80 // okay, there are two versions of the format, make a decision based on 84 // okay, there are two versions of the format, make a decision based on
81 // the size... 85 // the size...
82 // Oh BTW, we are storing everything in seconds! 86 // Oh BTW, we are storing everything in seconds!
83 if ( iLen < 7 ) { 87 if ( iLen < 7 ) {
84 _y = tmp / 100; 88 _y = tmp / 100;
85 _y *= 60; 89 _y *= 60;
86 _y += tmp % 100; 90 _y += tmp % 100;
87 _y *= 60; 91 _y *= 60;
88 } else { 92 } else {
89 _y = tmp / 10000; 93 _y = tmp / 10000;
90 _y *= 60; 94 _y *= 60;
91 tmp %= 10000; 95 tmp %= 10000;
92 _y += tmp / 100; 96 _y += tmp / 100;
93 _y *= 60; 97 _y *= 60;
94 tmp %= 100; 98 tmp %= 100;
95 _y += tmp; 99 _y += tmp;
96 } 100 }
97 } 101 }
98 iStart = regCoord.match( strLine, iStart + iLen, &iLen ); 102 iStart = regCoord.match( strLine, iStart + iLen, &iLen );
99 if ( iStart >= 0 ) { 103 if ( iStart >= 0 ) {
100 strTmp = strLine.mid( iStart, iLen ); 104 strTmp = strLine.mid( iStart, iLen );
101 tmp = strTmp.toInt(); 105 tmp = strTmp.toInt();
102 if ( iLen < 8 ) { 106 if ( iLen < 8 ) {
103 _x = tmp / 100; 107 _x = tmp / 100;
104 _x *= 60; 108 _x *= 60;
105 _x += tmp % 100; 109 _x += tmp % 100;
106 _x *= 60; 110 _x *= 60;
107 } else { 111 } else {
108 _x = tmp / 10000; 112 _x = tmp / 10000;
109 _x *= 60; 113 _x *= 60;
110 tmp %= 10000; 114 tmp %= 10000;
111 _x += tmp / 100; 115 _x += tmp / 100;
112 _x *= 60; 116 _x *= 60;
113 tmp %= 100; 117 tmp %= 100;
114 _x += tmp; 118 _x += tmp;
115 } 119 }
116 } 120 }
117 iStart = regCountry.match( strLine, 0, &iLen ); 121 iStart = regCountry.match( strLine, 0, &iLen );
118 // help with the shortcoming in 2.x regexp... 122 // help with the shortcoming in 2.x regexp...
119 iStop = strLine.findRev( '/' ); 123 iStop = strLine.findRev( '/' );
120 if ( iStart >= 0 ) { 124 if ( iStart >= 0 ) {
121 iLen = (iStop - iStart) + 1; 125 iLen = (iStop - iStart) + 1;
122 strCountry = strLine.mid( iStart, iLen ); 126 strCountry = strLine.mid( iStart, iLen );
123 } 127 }
124 // now match the city... 128 // now match the city...
125 iStart = regCity.match( strLine, iStart + iLen, &iLen ); 129 iStart = regCity.match( strLine, iStart + iLen, &iLen );
126 if ( iStart >= 0 ) { 130 if ( iStart >= 0 ) {
127 strCity = strLine.mid( iStart, iLen ); 131 strCity = strLine.mid( iStart, iLen );
128 } 132 }
129} 133}
130 134
131void ZoneField::showStructure( void ) const 135void ZoneField::showStructure( void ) const
132{ 136{
133 qDebug( "Country: %s", strCountry.latin1() ); 137 odebug << "Country: " << strCountry << "" << oendl;
134 qDebug( "City: %s", strCity.latin1() ); 138 odebug << "City: " << strCity << "" << oendl;
135 qDebug( "x: %d", _x ); 139 odebug << "x: " << _x << "" << oendl;
136 qDebug( "y: %d\n", _y ); 140 odebug << "y: " << _y << "\n" << oendl;
137} 141}
138 142
139ZoneMap::ZoneMap( QWidget *parent, const char* name ) 143ZoneMap::ZoneMap( QWidget *parent, const char* name )
@@ -207,21 +211,21 @@ void ZoneMap::readZones( void )
207{ 211{
208 QFile fZone( strZONEINFO ); 212 QFile fZone( strZONEINFO );
209 if ( !fZone.open( IO_ReadOnly ) ) { 213 if ( !fZone.open( IO_ReadOnly ) ) {
210 QMessageBox::warning (this, 214 QMessageBox::warning (this,
211 tr( "Unable to Find Timezone Info" ), 215 tr( "Unable to Find Timezone Info" ),
212 tr( "<p>Unable to find any timezone information in %1" ) 216 tr( "<p>Unable to find any timezone information in %1" )
213 .arg( strZONEINFO )); 217 .arg( strZONEINFO ));
214 exit(-1); 218 exit(-1);
215 } else { 219 } else {
216 QTextStream tZone( &fZone ); 220 QTextStream tZone( &fZone );
217 while ( !tZone.atEnd() ) { 221 while ( !tZone.atEnd() ) {
218 QString strLine = tZone.readLine(); 222 QString strLine = tZone.readLine();
219 // only pass on lines that aren't comments 223 // only pass on lines that aren't comments
220 if ( strLine[0] != '#' ) { 224 if ( strLine[0] != '#' ) {
221 zones.append( new ZoneField( strLine ) ); 225 zones.append( new ZoneField( strLine ) );
222 } 226 }
223 } 227 }
224 fZone.close(); 228 fZone.close();
225 } 229 }
226} 230}
227 231
@@ -245,8 +249,8 @@ void ZoneMap::viewportMouseReleaseEvent( QMouseEvent* )
245 // more for "mouse clicks" 249 // more for "mouse clicks"
246 norm.stop(); 250 norm.stop();
247 if ( pLast != NULL ) { 251 if ( pLast != NULL ) {
248 emit signalTz( pLast->country(), pLast->city() ); 252 emit signalTz( pLast->country(), pLast->city() );
249 pLast = NULL; 253 pLast = NULL;
250 } 254 }
251 tHide->start( 2000, true ); 255 tHide->start( 2000, true );
252} 256}
@@ -254,33 +258,33 @@ void ZoneMap::viewportMouseReleaseEvent( QMouseEvent* )
254void ZoneMap::keyPressEvent( QKeyEvent *ke ) 258void ZoneMap::keyPressEvent( QKeyEvent *ke )
255{ 259{
256 switch ( ke->key() ) { 260 switch ( ke->key() ) {
257 case Key_Left: 261 case Key_Left:
258 case Key_Right: 262 case Key_Right:
259 case Key_Up: 263 case Key_Up:
260 case Key_Down: { 264 case Key_Down: {
261 tHide->stop(); 265 tHide->stop();
262 if ( !cursor ) 266 if ( !cursor )
263 slotFindCity( QPoint( contentsWidth(), contentsHeight() ) / 2 ); 267 slotFindCity( QPoint( contentsWidth(), contentsHeight() ) / 2 );
264 ZoneField *city = findCityNear( cursor, ke->key() ); 268 ZoneField *city = findCityNear( cursor, ke->key() );
265 if ( city ) { 269 if ( city ) {
266 cursor = city; 270 cursor = city;
267 int tmpx, tmpy; 271 int tmpx, tmpy;
268 zoneToWin( cursor->x(), cursor->y(), tmpx, tmpy ); 272 zoneToWin( cursor->x(), cursor->y(), tmpx, tmpy );
269 ensureVisible( tmpx, tmpy ); 273 ensureVisible( tmpx, tmpy );
270 showCity( cursor ); 274 showCity( cursor );
271 tHide->start( 3000, true ); 275 tHide->start( 3000, true );
272 } 276 }
273 } 277 }
274 break; 278 break;
275 279
276 case Key_Space: 280 case Key_Space:
277 case Key_Enter: 281 case Key_Enter:
278 case Key_Return: 282 case Key_Return:
279 if ( cursor ) { 283 if ( cursor ) {
280 emit signalTz( cursor->country(), cursor->city() ); 284 emit signalTz( cursor->country(), cursor->city() );
281 tHide->start( 0, true ); 285 tHide->start( 0, true );
282 } 286 }
283 break; 287 break;
284 } 288 }
285} 289}
286 290
@@ -292,35 +296,35 @@ ZoneField *ZoneMap::findCityNear( ZoneField *city, int key )
292 296
293 QListIterator<ZoneField> it( zones ); 297 QListIterator<ZoneField> it( zones );
294 for (; it.current(); ++it) { 298 for (; it.current(); ++it) {
295 pZone = it.current(); 299 pZone = it.current();
296 long dx = (pZone->x() - city->x())/100; 300 long dx = (pZone->x() - city->x())/100;
297 long dy = (pZone->y() - city->y())/100; 301 long dy = (pZone->y() - city->y())/100;
298 switch ( key ) { 302 switch ( key ) {
299 case Key_Right: 303 case Key_Right:
300 case Key_Left: 304 case Key_Left:
301 if ( key == Key_Left ) 305 if ( key == Key_Left )
302 dx = -dx; 306 dx = -dx;
303 if ( dx > 0 ) { 307 if ( dx > 0 ) {
304 long dist = QABS(dy)*4 + dx; 308 long dist = QABS(dy)*4 + dx;
305 if ( dist < ddist ) { 309 if ( dist < ddist ) {
306 ddist = dist; 310 ddist = dist;
307 pClosest = pZone; 311 pClosest = pZone;
308 } 312 }
309 } 313 }
310 break; 314 break;
311 case Key_Down: 315 case Key_Down:
312 case Key_Up: 316 case Key_Up:
313 if ( key == Key_Down ) 317 if ( key == Key_Down )
314 dy = -dy; 318 dy = -dy;
315 if ( dy > 0 ) { 319 if ( dy > 0 ) {
316 long dist = QABS(dx)*4 + dy; 320 long dist = QABS(dx)*4 + dy;
317 if ( dist < ddist ) { 321 if ( dist < ddist ) {
318 ddist = dist; 322 ddist = dist;
319 pClosest = pZone; 323 pClosest = pZone;
320 } 324 }
321 } 325 }
322 break; 326 break;
323 } 327 }
324 } 328 }
325 329
326 return pClosest; 330 return pClosest;
@@ -351,20 +355,20 @@ void ZoneMap::slotFindCity( const QPoint &pos )
351 pClosest = 0; 355 pClosest = 0;
352 lClosest = LONG_MAX; 356 lClosest = LONG_MAX;
353 for (; it.current(); ++it) { 357 for (; it.current(); ++it) {
354 pZone = it.current(); 358 pZone = it.current();
355 // use the manhattenLength, a good enough of an appoximation here 359 // use the manhattenLength, a good enough of an appoximation here
356 lDistance = QABS( x - pZone->x() ) + QABS( y - pZone->y() ); 360 lDistance = QABS( x - pZone->x() ) + QABS( y - pZone->y() );
357 // first to zero wins! 361 // first to zero wins!
358 if ( lDistance < lClosest ) { 362 if ( lDistance < lClosest ) {
359 lClosest = lDistance; 363 lClosest = lDistance;
360 pClosest = pZone; 364 pClosest = pZone;
361 } 365 }
362 } 366 }
363 367
364 // Okay, we found the closest city, but it might still be too far away. 368 // Okay, we found the closest city, but it might still be too far away.
365 if ( lClosest <= iTHRESHOLD ) { 369 if ( lClosest <= iTHRESHOLD ) {
366 showCity( pClosest ); 370 showCity( pClosest );
367 cursor = pClosest; 371 cursor = pClosest;
368 } 372 }
369} 373}
370 374
@@ -381,51 +385,51 @@ void ZoneMap::showCity( ZoneField *city )
381 QString strSave; 385 QString strSave;
382 char *p = getenv( "TZ" ); 386 char *p = getenv( "TZ" );
383 if ( p ) { 387 if ( p ) {
384 strSave = p; 388 strSave = p;
385 } 389 }
386 // set the timezone :) 390 // set the timezone :)
387 setenv( "TZ", strCountry + strCity, true ); 391 setenv( "TZ", strCountry + strCity, true );
388 lblCity->setText( strCity.replace( QRegExp("_"), " ") + "\n" + 392 lblCity->setText( strCity.replace( QRegExp("_"), " ") + "\n" +
389 TimeString::shortTime( ampm ) ); 393 TimeString::shortTime( ampm ) );
390 lblCity->setMinimumSize( lblCity->sizeHint() ); 394 lblCity->setMinimumSize( lblCity->sizeHint() );
391 // undue our damage... 395 // undue our damage...
392 unsetenv( "TZ" ); 396 unsetenv( "TZ" );
393 if ( p ) 397 if ( p )
394 setenv( "TZ", strSave, true ); 398 setenv( "TZ", strSave, true );
395 // Now decide where to move the label, x & y can be reused 399 // Now decide where to move the label, x & y can be reused
396 int tmpx, tmpy, x, y; 400 int tmpx, tmpy, x, y;
397 zoneToWin( pLast->x(), pLast->y(), tmpx, tmpy ); 401 zoneToWin( pLast->x(), pLast->y(), tmpx, tmpy );
398 contentsToViewport(tmpx, tmpy, x, y); 402 contentsToViewport(tmpx, tmpy, x, y);
399 if ( lblCity->width() > drawableW - x ) { 403 if ( lblCity->width() > drawableW - x ) {
400 // oops... try putting it on the right 404 // oops... try putting it on the right
401 x = x - lblCity->width() - iLABELOFFSET; 405 x = x - lblCity->width() - iLABELOFFSET;
402 } else { 406 } else {
403 // the default... 407 // the default...
404 x += iLABELOFFSET; 408 x += iLABELOFFSET;
405 } 409 }
406 if ( lblCity->height() > drawableH - y ) { 410 if ( lblCity->height() > drawableH - y ) {
407 // move it up... 411 // move it up...
408 y = y - lblCity->height() - iLABELOFFSET; 412 y = y - lblCity->height() - iLABELOFFSET;
409 } else if ( y < 0 ) { 413 } else if ( y < 0 ) {
410 // the city is actually off the screen... 414 // the city is actually off the screen...
411 // this only happens on the a zoom when you are near the top, 415 // this only happens on the a zoom when you are near the top,
412 // a quick workaround.. 416 // a quick workaround..
413 y = iLABELOFFSET; 417 y = iLABELOFFSET;
414 } else { 418 } else {
415 // the default 419 // the default
416 y += iLABELOFFSET; 420 y += iLABELOFFSET;
417 } 421 }
418 422
419 // draw in the city and the label 423 // draw in the city and the label
420 if ( pRepaint ) { 424 if ( pRepaint ) {
421 int repx, 425 int repx,
422 repy; 426 repy;
423 zoneToWin( pRepaint->x(), pRepaint->y(), repx, repy ); 427 zoneToWin( pRepaint->x(), pRepaint->y(), repx, repy );
424 updateContents( repx - iCITYOFFSET, repy - iCITYOFFSET, 428 updateContents( repx - iCITYOFFSET, repy - iCITYOFFSET,
425 iCITYSIZE, iCITYSIZE ); 429 iCITYSIZE, iCITYSIZE );
426 } 430 }
427 updateContents( tmpx - iCITYOFFSET, tmpy - iCITYOFFSET, iCITYSIZE, 431 updateContents( tmpx - iCITYOFFSET, tmpy - iCITYOFFSET, iCITYSIZE,
428 iCITYSIZE ); 432 iCITYSIZE );
429 pRepaint = pLast; 433 pRepaint = pLast;
430 434
431 lblCity->move( x, y ); 435 lblCity->move( x, y );
@@ -439,10 +443,10 @@ void ZoneMap::resizeEvent( QResizeEvent *e )
439 cmdZoom->move( _size.width() - cmdZoom->width(), 443 cmdZoom->move( _size.width() - cmdZoom->width(),
440 _size.height() - cmdZoom->height() ); 444 _size.height() - cmdZoom->height() );
441 if ( !bZoom ) { 445 if ( !bZoom ) {
442 drawableW = width() - 2 * frameWidth(); 446 drawableW = width() - 2 * frameWidth();
443 drawableH = height() - 2 * frameWidth(); 447 drawableH = height() - 2 * frameWidth();
444 makeMap( drawableW, drawableH ); 448 makeMap( drawableW, drawableH );
445 resizeContents( drawableW, drawableH ); 449 resizeContents( drawableW, drawableH );
446 } 450 }
447} 451}
448 452
@@ -451,8 +455,8 @@ void ZoneMap::showZones( void ) const
451 // go through the zones in the list and just display the values... 455 // go through the zones in the list and just display the values...
452 QListIterator<ZoneField> itZone( zones ); 456 QListIterator<ZoneField> itZone( zones );
453 for ( itZone.toFirst(); itZone.current(); ++itZone ) { 457 for ( itZone.toFirst(); itZone.current(); ++itZone ) {
454 ZoneField *pZone = itZone.current(); 458 ZoneField *pZone = itZone.current();
455 pZone->showStructure(); 459 pZone->showStructure();
456 } 460 }
457} 461}
458 462
@@ -471,7 +475,7 @@ QWidget* ZoneMap::selectionWidget( QWidget *parent) {
471 QStringList continentList; 475 QStringList continentList;
472 QListIterator<ZoneField> itZone( zones ); 476 QListIterator<ZoneField> itZone( zones );
473 for ( itZone.toFirst(); itZone.current(); ++itZone ) { 477 for ( itZone.toFirst(); itZone.current(); ++itZone ) {
474 ZoneField *pZone = itZone.current(); 478 ZoneField *pZone = itZone.current();
475 if ( continentList.contains( pZone->country() ) == 0 ) { 479 if ( continentList.contains( pZone->country() ) == 0 ) {
476 QString name; 480 QString name;
477 QListViewItem *item; 481 QListViewItem *item;
@@ -498,7 +502,7 @@ void ZoneMap::slotGetCities( QListViewItem * contItem) {
498 selectedCont = contItem->text( 1 ); 502 selectedCont = contItem->text( 1 );
499 QListIterator<ZoneField> itZone( zones ); 503 QListIterator<ZoneField> itZone( zones );
500 for ( itZone.toFirst(); itZone.current(); ++itZone ) { 504 for ( itZone.toFirst(); itZone.current(); ++itZone ) {
501 ZoneField *pZone = itZone.current(); 505 ZoneField *pZone = itZone.current();
502 if ( pZone->country() == contItem->text( 1 ) ) { 506 if ( pZone->country() == contItem->text( 1 ) ) {
503 QListViewItem *item; 507 QListViewItem *item;
504 item = new QListViewItem( cityView, pZone->city() ); 508 item = new QListViewItem( cityView, pZone->city() );
@@ -522,11 +526,11 @@ void ZoneMap::drawCities( QPainter *p )
522 p->setPen( red ); 526 p->setPen( red );
523 QListIterator<ZoneField> itZone( zones ); 527 QListIterator<ZoneField> itZone( zones );
524 for ( itZone.toFirst(), j = 0; itZone.current(); ++itZone, j++ ) { 528 for ( itZone.toFirst(), j = 0; itZone.current(); ++itZone, j++ ) {
525 ZoneField *pZone = itZone.current(); 529 ZoneField *pZone = itZone.current();
526 zoneToWin( pZone->x(), pZone->y(), x, y ); 530 zoneToWin( pZone->x(), pZone->y(), x, y );
527 if ( x > wImg ) 531 if ( x > wImg )
528 x = x - wImg; 532 x = x - wImg;
529 p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE); 533 p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE);
530 } 534 }
531} 535}
532 536
@@ -563,20 +567,20 @@ static void dayNight(QImage *pImage)
563 iMid = ( relw * ( 24*60 - pTm->tm_hour * 60 - pTm->tm_min ) ) / ( 24*60 ); 567 iMid = ( relw * ( 24*60 - pTm->tm_hour * 60 - pTm->tm_min ) ) / ( 24*60 );
564 568
565 for ( i = 0; i < hImage; i++ ) { 569 for ( i = 0; i < hImage; i++ ) {
566 if ( wtab[i] > 0 ) { 570 if ( wtab[i] > 0 ) {
567 iStart = iMid - wtab[i]; 571 iStart = iMid - wtab[i];
568 iStop = iMid + wtab[i]; 572 iStop = iMid + wtab[i];
569 if ( iStart < 0 ) { 573 if ( iStart < 0 ) {
570 darken( pImage, iStop, wImage + iStart, i ); 574 darken( pImage, iStop, wImage + iStart, i );
571 } else if ( iStop > wImage ) { 575 } else if ( iStop > wImage ) {
572 darken( pImage, iStop - wImage, iStart, i ); 576 darken( pImage, iStop - wImage, iStart, i );
573 } else { 577 } else {
574 darken( pImage, 0, iStart, i ); 578 darken( pImage, 0, iStart, i );
575 darken( pImage, iStop, wImage, i ); 579 darken( pImage, iStop, wImage, i );
576 } 580 }
577 } else { 581 } else {
578 darken( pImage, 0, wImage, i ); 582 darken( pImage, 0, wImage, i );
579 } 583 }
580 } 584 }
581} 585}
582 586
@@ -591,8 +595,8 @@ static inline void darken( QImage *pImage, int start, int stop, int row )
591 595
592 p = pImage->scanLine( row ); 596 p = pImage->scanLine( row );
593 for ( j = start; j <= stop; j++ ) { 597 for ( j = start; j <= stop; j++ ) {
594 if ( p[j] < colors ) 598 if ( p[j] < colors )
595 p[j] += colors; 599 p[j] += colors;
596 } 600 }
597} 601}
598 602
@@ -600,11 +604,11 @@ void ZoneMap::makeMap( int w, int h )
600{ 604{
601 QImage imgOrig = Resource::loadImage( strMAP ); 605 QImage imgOrig = Resource::loadImage( strMAP );
602 if ( imgOrig.isNull() ) { 606 if ( imgOrig.isNull() ) {
603 QMessageBox::warning( this, 607 QMessageBox::warning( this,
604 tr( "Couldn't Find Map" ), 608 tr( "Couldn't Find Map" ),
605 tr( "<p>Couldn't load map: %1, exiting") 609 tr( "<p>Couldn't load map: %1, exiting")
606 .arg( strMAP ) ); 610 .arg( strMAP ) );
607 exit(-1); 611 exit(-1);
608 } 612 }
609 613
610 // set up the color table for darkening... 614 // set up the color table for darkening...
@@ -614,15 +618,15 @@ void ZoneMap::makeMap( int w, int h )
614 imgOrig.setNumColors( 2 * numColors ); 618 imgOrig.setNumColors( 2 * numColors );
615 // darken the new ones... 619 // darken the new ones...
616 for ( int i = 0; i < numColors; i++ ) { 620 for ( int i = 0; i < numColors; i++ ) {
617 QRgb rgb = imgOrig.color( i ); 621 QRgb rgb = imgOrig.color( i );
618 imgOrig.setColor ( i + numColors, qRgb( 2 * qRed( rgb ) / 3, 622 imgOrig.setColor ( i + numColors, qRgb( 2 * qRed( rgb ) / 3,
619 2 * qGreen( rgb ) / 3, 2 * qBlue( rgb ) / 3 ) ); 623 2 * qGreen( rgb ) / 3, 2 * qBlue( rgb ) / 3 ) );
620 } 624 }
621 625
622 // else go one with making the map... 626 // else go one with making the map...
623 if ( bIllum ) { 627 if ( bIllum ) {
624 // do a daylight mask 628 // do a daylight mask
625 dayNight(&imgOrig); 629 dayNight(&imgOrig);
626 } 630 }
627 // redo the width and height 631 // redo the width and height
628 wImg = w; 632 wImg = w;
@@ -654,7 +658,7 @@ void ZoneMap::drawContents( QPainter *p, int cx, int cy, int cw, int ch )
654 pixmapH = pixCurr->height(); 658 pixmapH = pixCurr->height();
655 if ( !bZoom && ( ( pixmapW != drawableW ) || 659 if ( !bZoom && ( ( pixmapW != drawableW ) ||
656 ( pixmapH != drawableH) ) ) { 660 ( pixmapH != drawableH) ) ) {
657 makeMap( drawableW, drawableH ); 661 makeMap( drawableW, drawableH );
658 } 662 }
659 663
660 // taken from the scrollview example... 664 // taken from the scrollview example...
@@ -665,27 +669,27 @@ void ZoneMap::drawContents( QPainter *p, int cx, int cy, int cw, int ch )
665 int leftcol= cx / colwidth; 669 int leftcol= cx / colwidth;
666 int rightcol= ( cx + cw + colwidth - 1 ) / colwidth; 670 int rightcol= ( cx + cw + colwidth - 1 ) / colwidth;
667 for ( int r = toprow; r <= bottomrow; r++ ) { 671 for ( int r = toprow; r <= bottomrow; r++ ) {
668 int py = r * rowheight; 672 int py = r * rowheight;
669 for ( int c = leftcol; c <= rightcol; c++ ) { 673 for ( int c = leftcol; c <= rightcol; c++ ) {
670 int px = c * colwidth; 674 int px = c * colwidth;
671 p->drawPixmap( px, py, *pixCurr ); 675 p->drawPixmap( px, py, *pixCurr );
672 } 676 }
673 } 677 }
674 678
675 // Draw that city! 679 // Draw that city!
676 if ( pLast ) 680 if ( pLast )
677 drawCity( p, pLast ); 681 drawCity( p, pLast );
678} 682}
679 683
680void ZoneMap::slotZoom( bool setZoom ) 684void ZoneMap::slotZoom( bool setZoom )
681{ 685{
682 bZoom = setZoom; 686 bZoom = setZoom;
683 if ( bZoom ) { 687 if ( bZoom ) {
684 makeMap( 2 * wImg , 2 * hImg ); 688 makeMap( 2 * wImg , 2 * hImg );
685 resizeContents( wImg, hImg ); 689 resizeContents( wImg, hImg );
686 } else { 690 } else {
687 makeMap( drawableW, drawableH ); 691 makeMap( drawableW, drawableH );
688 resizeContents( drawableW, drawableH ); 692 resizeContents( drawableW, drawableH );
689 } 693 }
690} 694}
691 695
@@ -711,9 +715,9 @@ void ZoneMap::slotRedraw( void )
711 int x, 715 int x,
712 y; 716 y;
713 if ( pRepaint ) { 717 if ( pRepaint ) {
714 pLast = 0; 718 pLast = 0;
715 zoneToWin(pRepaint->x(), pRepaint->y(), x, y); 719 zoneToWin(pRepaint->x(), pRepaint->y(), x, y);
716 updateContents( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE); 720 updateContents( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE);
717 pRepaint = 0; 721 pRepaint = 0;
718 } 722 }
719} 723}