Diffstat (limited to 'core/settings/citytime/zonemap.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/citytime/zonemap.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/core/settings/citytime/zonemap.cpp b/core/settings/citytime/zonemap.cpp index b83da59..b6843d2 100644 --- a/core/settings/citytime/zonemap.cpp +++ b/core/settings/citytime/zonemap.cpp | |||
@@ -142,102 +142,102 @@ ZoneMap::ZoneMap( QWidget *parent, const char* name ) | |||
142 | pRepaint( 0 ), | 142 | pRepaint( 0 ), |
143 | ox( 0 ), | 143 | ox( 0 ), |
144 | oy( 0 ), | 144 | oy( 0 ), |
145 | drawableW( -1 ), | 145 | drawableW( -1 ), |
146 | drawableH( -1 ), | 146 | drawableH( -1 ), |
147 | bZoom( FALSE ), | 147 | bZoom( FALSE ), |
148 | bIllum( TRUE ), | 148 | bIllum( TRUE ), |
149 | cursor( 0 ) | 149 | cursor( 0 ) |
150 | { | 150 | { |
151 | viewport()->setFocusPolicy( StrongFocus ); | 151 | viewport()->setFocusPolicy( StrongFocus ); |
152 | 152 | ||
153 | // set mouse tracking so we can use the mouse move event | 153 | // set mouse tracking so we can use the mouse move event |
154 | zones.setAutoDelete( true ); | 154 | zones.setAutoDelete( true ); |
155 | // get the map loaded | 155 | // get the map loaded |
156 | // just set the current image to point | 156 | // just set the current image to point |
157 | pixCurr = new QPixmap(); | 157 | pixCurr = new QPixmap(); |
158 | 158 | ||
159 | QPixmap pixZoom = Resource::loadPixmap( "mag" ); | 159 | QPixmap pixZoom = Resource::loadPixmap( "mag" ); |
160 | 160 | ||
161 | cmdZoom = new QToolButton( this, "Zoom command" ); | 161 | cmdZoom = new QToolButton( this, "Zoom command" ); |
162 | cmdZoom->setPixmap( pixZoom ); | 162 | cmdZoom->setPixmap( pixZoom ); |
163 | cmdZoom->setToggleButton( true ); | 163 | cmdZoom->setToggleButton( true ); |
164 | 164 | ||
165 | cmdZoom->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, | 165 | cmdZoom->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, |
166 | (QSizePolicy::SizeType)0, | 166 | (QSizePolicy::SizeType)0, |
167 | cmdZoom->sizePolicy().hasHeightForWidth() ) ); | 167 | cmdZoom->sizePolicy().hasHeightForWidth() ) ); |
168 | cmdZoom->setMaximumSize( cmdZoom->sizeHint() ); | 168 | cmdZoom->setMaximumSize( cmdZoom->sizeHint() ); |
169 | // probably don't need this, but just in case... | 169 | // probably don't need this, but just in case... |
170 | cmdZoom->move( width() - cmdZoom->width(), height() - cmdZoom->height() ); | 170 | cmdZoom->move( width() - cmdZoom->width(), height() - cmdZoom->height() ); |
171 | 171 | ||
172 | 172 | ||
173 | lblCity = new QLabel( tr( "CITY" ), this, "City Label" ); | 173 | lblCity = new QLabel( tr( "CITY" ), this, "City Label" ); |
174 | lblCity->setMinimumSize( lblCity->sizeHint() ); | 174 | lblCity->setMinimumSize( lblCity->sizeHint() ); |
175 | lblCity->setFrameStyle( QFrame::Plain | QFrame::Box ); | 175 | lblCity->setFrameStyle( QFrame::Plain | QFrame::Box ); |
176 | lblCity->setBackgroundColor( yellow ); | 176 | lblCity->setBackgroundColor( yellow ); |
177 | lblCity->hide(); | 177 | lblCity->hide(); |
178 | 178 | ||
179 | // A timer to make sure the label gets hidden | 179 | // A timer to make sure the label gets hidden |
180 | tHide = new QTimer( this, "Label Timer" ); | 180 | tHide = new QTimer( this, "Label Timer" ); |
181 | QObject::connect( tHide, SIGNAL( timeout() ), | 181 | QObject::connect( tHide, SIGNAL( timeout() ), |
182 | lblCity, SLOT( hide() ) ); | 182 | lblCity, SLOT( hide() ) ); |
183 | QObject::connect( tHide, SIGNAL( timeout() ), | 183 | QObject::connect( tHide, SIGNAL( timeout() ), |
184 | this, SLOT( slotRedraw() ) ); | 184 | this, SLOT( slotRedraw() ) ); |
185 | QTimer *tUpdate = new QTimer( this, "Update Timer" ); | 185 | QTimer *tUpdate = new QTimer( this, "Update Timer" ); |
186 | QObject::connect( tUpdate, SIGNAL( timeout() ), | 186 | QObject::connect( tUpdate, SIGNAL( timeout() ), |
187 | this, SLOT( slotUpdate() ) ); | 187 | this, SLOT( slotUpdate() ) ); |
188 | QObject::connect( qApp, SIGNAL( timeChanged() ), | 188 | QObject::connect( qApp, SIGNAL( timeChanged() ), |
189 | this, SLOT( slotUpdate() ) ); | 189 | this, SLOT( slotUpdate() ) ); |
190 | QObject::connect( cmdZoom, SIGNAL( toggled( bool ) ), | 190 | QObject::connect( cmdZoom, SIGNAL( toggled(bool) ), |
191 | this, SLOT( slotZoom( bool ) ) ); | 191 | this, SLOT( slotZoom(bool) ) ); |
192 | QObject::connect( &norm, SIGNAL( signalNewPoint( const QPoint& ) ), | 192 | QObject::connect( &norm, SIGNAL( signalNewPoint(const QPoint&) ), |
193 | this, SLOT( slotFindCity( const QPoint& ) ) ); | 193 | this, SLOT( slotFindCity(const QPoint&) ) ); |
194 | QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), | 194 | QObject::connect( qApp, SIGNAL( clockChanged(bool) ), |
195 | this, SLOT( changeClock( bool ) ) ); | 195 | this, SLOT( changeClock(bool) ) ); |
196 | // update the sun's movement every 5 minutes | 196 | // update the sun's movement every 5 minutes |
197 | tUpdate->start( 5 * 60 * 1000 ); | 197 | tUpdate->start( 5 * 60 * 1000 ); |
198 | // May as well read in the timezone information too... | 198 | // May as well read in the timezone information too... |
199 | readZones(); | 199 | readZones(); |
200 | } | 200 | } |
201 | 201 | ||
202 | ZoneMap::~ZoneMap() | 202 | ZoneMap::~ZoneMap() |
203 | { | 203 | { |
204 | } | 204 | } |
205 | 205 | ||
206 | void ZoneMap::readZones( void ) | 206 | void ZoneMap::readZones( void ) |
207 | { | 207 | { |
208 | QFile fZone( strZONEINFO ); | 208 | QFile fZone( strZONEINFO ); |
209 | if ( !fZone.open( IO_ReadOnly ) ) { | 209 | if ( !fZone.open( IO_ReadOnly ) ) { |
210 | QMessageBox::warning (this, | 210 | QMessageBox::warning (this, |
211 | tr( "Unable to Find Timezone Info" ), | 211 | tr( "Unable to Find Timezone Info" ), |
212 | tr( "<p>Unable to find any timezone information in %1" ) | 212 | tr( "<p>Unable to find any timezone information in %1" ) |
213 | .arg( strZONEINFO )); | 213 | .arg( strZONEINFO )); |
214 | exit(-1); | 214 | exit(-1); |
215 | } else { | 215 | } else { |
216 | QTextStream tZone( &fZone ); | 216 | QTextStream tZone( &fZone ); |
217 | while ( !tZone.atEnd() ) { | 217 | while ( !tZone.atEnd() ) { |
218 | QString strLine = tZone.readLine(); | 218 | QString strLine = tZone.readLine(); |
219 | // only pass on lines that aren't comments | 219 | // only pass on lines that aren't comments |
220 | if ( strLine[0] != '#' ) { | 220 | if ( strLine[0] != '#' ) { |
221 | zones.append( new ZoneField( strLine ) ); | 221 | zones.append( new ZoneField( strLine ) ); |
222 | } | 222 | } |
223 | } | 223 | } |
224 | fZone.close(); | 224 | fZone.close(); |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | void ZoneMap::viewportMousePressEvent( QMouseEvent* event ) | 228 | void ZoneMap::viewportMousePressEvent( QMouseEvent* event ) |
229 | { | 229 | { |
230 | // add the mouse event into the normalizer, and get the average, | 230 | // add the mouse event into the normalizer, and get the average, |
231 | // pass it along | 231 | // pass it along |
232 | slotRedraw(); | 232 | slotRedraw(); |
233 | norm.start(); | 233 | norm.start(); |
234 | norm.addEvent( event->pos() ); | 234 | norm.addEvent( event->pos() ); |
235 | } | 235 | } |
236 | 236 | ||
237 | void ZoneMap::viewportMouseMoveEvent( QMouseEvent* event ) | 237 | void ZoneMap::viewportMouseMoveEvent( QMouseEvent* event ) |
238 | { | 238 | { |
239 | norm.addEvent( event->pos() ); | 239 | norm.addEvent( event->pos() ); |
240 | } | 240 | } |
241 | 241 | ||
242 | void ZoneMap::viewportMouseReleaseEvent( QMouseEvent* ) | 242 | void ZoneMap::viewportMouseReleaseEvent( QMouseEvent* ) |
243 | { | 243 | { |
@@ -421,133 +421,133 @@ void ZoneMap::showCity( ZoneField *city ) | |||
421 | int repx, | 421 | int repx, |
422 | repy; | 422 | repy; |
423 | zoneToWin( pRepaint->x(), pRepaint->y(), repx, repy ); | 423 | zoneToWin( pRepaint->x(), pRepaint->y(), repx, repy ); |
424 | updateContents( repx - iCITYOFFSET, repy - iCITYOFFSET, | 424 | updateContents( repx - iCITYOFFSET, repy - iCITYOFFSET, |
425 | iCITYSIZE, iCITYSIZE ); | 425 | iCITYSIZE, iCITYSIZE ); |
426 | } | 426 | } |
427 | updateContents( tmpx - iCITYOFFSET, tmpy - iCITYOFFSET, iCITYSIZE, | 427 | updateContents( tmpx - iCITYOFFSET, tmpy - iCITYOFFSET, iCITYSIZE, |
428 | iCITYSIZE ); | 428 | iCITYSIZE ); |
429 | pRepaint = pLast; | 429 | pRepaint = pLast; |
430 | 430 | ||
431 | lblCity->move( x, y ); | 431 | lblCity->move( x, y ); |
432 | lblCity->show(); | 432 | lblCity->show(); |
433 | } | 433 | } |
434 | 434 | ||
435 | void ZoneMap::resizeEvent( QResizeEvent *e ) | 435 | void ZoneMap::resizeEvent( QResizeEvent *e ) |
436 | { | 436 | { |
437 | // keep the zoom button down in the corner | 437 | // keep the zoom button down in the corner |
438 | QSize _size = e->size(); | 438 | QSize _size = e->size(); |
439 | cmdZoom->move( _size.width() - cmdZoom->width(), | 439 | cmdZoom->move( _size.width() - cmdZoom->width(), |
440 | _size.height() - cmdZoom->height() ); | 440 | _size.height() - cmdZoom->height() ); |
441 | if ( !bZoom ) { | 441 | if ( !bZoom ) { |
442 | drawableW = width() - 2 * frameWidth(); | 442 | drawableW = width() - 2 * frameWidth(); |
443 | drawableH = height() - 2 * frameWidth(); | 443 | drawableH = height() - 2 * frameWidth(); |
444 | makeMap( drawableW, drawableH ); | 444 | makeMap( drawableW, drawableH ); |
445 | resizeContents( drawableW, drawableH ); | 445 | resizeContents( drawableW, drawableH ); |
446 | } | 446 | } |
447 | } | 447 | } |
448 | 448 | ||
449 | void ZoneMap::showZones( void ) const | 449 | void ZoneMap::showZones( void ) const |
450 | { | 450 | { |
451 | // go through the zones in the list and just display the values... | 451 | // go through the zones in the list and just display the values... |
452 | QListIterator<ZoneField> itZone( zones ); | 452 | QListIterator<ZoneField> itZone( zones ); |
453 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { | 453 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { |
454 | ZoneField *pZone = itZone.current(); | 454 | ZoneField *pZone = itZone.current(); |
455 | pZone->showStructure(); | 455 | pZone->showStructure(); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | QWidget* ZoneMap::selectionWidget( QWidget *parent) { | 460 | QWidget* ZoneMap::selectionWidget( QWidget *parent) { |
461 | 461 | ||
462 | QWidget *returnWidget = new QWidget( parent ); | 462 | QWidget *returnWidget = new QWidget( parent ); |
463 | 463 | ||
464 | QVBoxLayout *layout = new QVBoxLayout( returnWidget ); | 464 | QVBoxLayout *layout = new QVBoxLayout( returnWidget ); |
465 | QHBox *hBox = new QHBox( returnWidget ); | 465 | QHBox *hBox = new QHBox( returnWidget ); |
466 | QListView *continentView = new QListView( hBox ); | 466 | QListView *continentView = new QListView( hBox ); |
467 | continentView->addColumn( tr("Continent") ); | 467 | continentView->addColumn( tr("Continent") ); |
468 | QWhatsThis::add( continentView, tr("Select a continent/country here, then select a city") ); | 468 | QWhatsThis::add( continentView, tr("Select a continent/country here, then select a city") ); |
469 | connect ( continentView, SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( slotGetCities( QListViewItem * ) ) ); | 469 | connect ( continentView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( slotGetCities(QListViewItem*) ) ); |
470 | 470 | ||
471 | QStringList continentList; | 471 | QStringList continentList; |
472 | QListIterator<ZoneField> itZone( zones ); | 472 | QListIterator<ZoneField> itZone( zones ); |
473 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { | 473 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { |
474 | ZoneField *pZone = itZone.current(); | 474 | ZoneField *pZone = itZone.current(); |
475 | if ( continentList.contains( pZone->country() ) == 0 ) { | 475 | if ( continentList.contains( pZone->country() ) == 0 ) { |
476 | QString name; | 476 | QString name; |
477 | QListViewItem *item; | 477 | QListViewItem *item; |
478 | if ( !(pZone->country().length() > 24) ) { | 478 | if ( !(pZone->country().length() > 24) ) { |
479 | name = pZone->country().left(pZone->country().length()-1 ); | 479 | name = pZone->country().left(pZone->country().length()-1 ); |
480 | } else { | 480 | } else { |
481 | name = pZone->country().left( 24 ); | 481 | name = pZone->country().left( 24 ); |
482 | } | 482 | } |
483 | item = new QListViewItem( continentView, name, pZone->country() ); | 483 | item = new QListViewItem( continentView, name, pZone->country() ); |
484 | continentList.append( pZone->country() ); | 484 | continentList.append( pZone->country() ); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | 487 | ||
488 | cityView = new QListView( hBox ); | 488 | cityView = new QListView( hBox ); |
489 | cityView->addColumn( tr("City") ); | 489 | cityView->addColumn( tr("City") ); |
490 | 490 | ||
491 | layout->addWidget( hBox ); | 491 | layout->addWidget( hBox ); |
492 | return returnWidget; | 492 | return returnWidget; |
493 | } | 493 | } |
494 | 494 | ||
495 | void ZoneMap::slotGetCities( QListViewItem * contItem) { | 495 | void ZoneMap::slotGetCities( QListViewItem * contItem) { |
496 | 496 | ||
497 | cityView->clear(); | 497 | cityView->clear(); |
498 | selectedCont = contItem->text( 1 ); | 498 | selectedCont = contItem->text( 1 ); |
499 | QListIterator<ZoneField> itZone( zones ); | 499 | QListIterator<ZoneField> itZone( zones ); |
500 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { | 500 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { |
501 | ZoneField *pZone = itZone.current(); | 501 | ZoneField *pZone = itZone.current(); |
502 | if ( pZone->country() == contItem->text( 1 ) ) { | 502 | if ( pZone->country() == contItem->text( 1 ) ) { |
503 | QListViewItem *item; | 503 | QListViewItem *item; |
504 | item = new QListViewItem( cityView, pZone->city() ); | 504 | item = new QListViewItem( cityView, pZone->city() ); |
505 | connect ( cityView, SIGNAL( clicked ( QListViewItem* ) ), this, SLOT( slotCitySelected( QListViewItem* ) ) ); | 505 | connect ( cityView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( slotCitySelected(QListViewItem*) ) ); |
506 | } | 506 | } |
507 | } | 507 | } |
508 | } | 508 | } |
509 | 509 | ||
510 | void ZoneMap::slotCitySelected( QListViewItem *cityItem ) { | 510 | void ZoneMap::slotCitySelected( QListViewItem *cityItem ) { |
511 | if ( cityItem ) { | 511 | if ( cityItem ) { |
512 | emit signalTz( selectedCont, cityItem->text( 0 ) ); | 512 | emit signalTz( selectedCont, cityItem->text( 0 ) ); |
513 | } | 513 | } |
514 | } | 514 | } |
515 | 515 | ||
516 | void ZoneMap::drawCities( QPainter *p ) | 516 | void ZoneMap::drawCities( QPainter *p ) |
517 | { | 517 | { |
518 | int x, y, j; | 518 | int x, y, j; |
519 | // draw in the cities | 519 | // draw in the cities |
520 | // for testing only as when you put it | 520 | // for testing only as when you put it |
521 | // on the small screen it looks awful and not to mention useless | 521 | // on the small screen it looks awful and not to mention useless |
522 | p->setPen( red ); | 522 | p->setPen( red ); |
523 | QListIterator<ZoneField> itZone( zones ); | 523 | QListIterator<ZoneField> itZone( zones ); |
524 | for ( itZone.toFirst(), j = 0; itZone.current(); ++itZone, j++ ) { | 524 | for ( itZone.toFirst(), j = 0; itZone.current(); ++itZone, j++ ) { |
525 | ZoneField *pZone = itZone.current(); | 525 | ZoneField *pZone = itZone.current(); |
526 | zoneToWin( pZone->x(), pZone->y(), x, y ); | 526 | zoneToWin( pZone->x(), pZone->y(), x, y ); |
527 | if ( x > wImg ) | 527 | if ( x > wImg ) |
528 | x = x - wImg; | 528 | x = x - wImg; |
529 | p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE); | 529 | p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE); |
530 | } | 530 | } |
531 | } | 531 | } |
532 | 532 | ||
533 | static void dayNight(QImage *pImage) | 533 | static void dayNight(QImage *pImage) |
534 | { | 534 | { |
535 | // create a mask the functions from sun.h | 535 | // create a mask the functions from sun.h |
536 | double dJulian, | 536 | double dJulian, |
537 | dSunRad, | 537 | dSunRad, |
538 | dSunDecl, | 538 | dSunDecl, |
539 | dSunRadius, | 539 | dSunRadius, |
540 | dSunLong; | 540 | dSunLong; |
541 | int wImage = pImage->width(), | 541 | int wImage = pImage->width(), |
542 | hImage = pImage->height(), | 542 | hImage = pImage->height(), |
543 | iStart, | 543 | iStart, |
544 | iStop, | 544 | iStop, |
545 | iMid, | 545 | iMid, |
546 | relw, | 546 | relw, |
547 | i; | 547 | i; |
548 | short wtab[ wImage ]; | 548 | short wtab[ wImage ]; |
549 | time_t tCurrent; | 549 | time_t tCurrent; |
550 | struct tm *pTm; | 550 | struct tm *pTm; |
551 | 551 | ||
552 | // get the position of the sun bassed on our current time... | 552 | // get the position of the sun bassed on our current time... |
553 | tCurrent = time( NULL ); | 553 | tCurrent = time( NULL ); |