author | ar <ar> | 2004-05-02 17:31:50 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-02 17:31:50 (UTC) |
commit | a210b9a597ba0c929d95c38ffbaf972916c7b8a7 (patch) (unidiff) | |
tree | ce121d5017eb054222c86e0afb6057a28ea7bf8a /core/settings/citytime/zonemap.cpp | |
parent | 18759e9156c96795831120408a9da0d3b4ec71a4 (diff) | |
download | opie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.zip opie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.tar.gz opie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.tar.bz2 |
- convert qDebug to odebug
Diffstat (limited to 'core/settings/citytime/zonemap.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/citytime/zonemap.cpp | 402 |
1 files changed, 203 insertions, 199 deletions
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 ); | |||
61 | ZoneField::ZoneField( const QString& strLine ) | 65 | ZoneField::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 | ||
131 | void ZoneField::showStructure( void ) const | 135 | void 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 | ||
139 | ZoneMap::ZoneMap( QWidget *parent, const char* name ) | 143 | ZoneMap::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* ) | |||
254 | void ZoneMap::keyPressEvent( QKeyEvent *ke ) | 258 | void 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 | ||
680 | void ZoneMap::slotZoom( bool setZoom ) | 684 | void 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 | } |