Diffstat (limited to 'core/settings/citytime/zonemap.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/citytime/zonemap.cpp | 67 |
1 files changed, 64 insertions, 3 deletions
diff --git a/core/settings/citytime/zonemap.cpp b/core/settings/citytime/zonemap.cpp index 1d60aee..872e786 100644 --- a/core/settings/citytime/zonemap.cpp +++ b/core/settings/citytime/zonemap.cpp | |||
@@ -20,2 +20,4 @@ | |||
20 | 20 | ||
21 | // changes by Maximilian Reiss <harlekin@handhelds.org> | ||
22 | |||
21 | #include "sun.h" | 23 | #include "sun.h" |
@@ -39,2 +41,6 @@ | |||
39 | #include <qtoolbutton.h> | 41 | #include <qtoolbutton.h> |
42 | #include <qlayout.h> | ||
43 | #include <qhbox.h> | ||
44 | #include <qlistview.h> | ||
45 | #include <qwhatsthis.h> | ||
40 | 46 | ||
@@ -459,7 +465,62 @@ void ZoneMap::showZones( void ) const | |||
459 | 465 | ||
466 | |||
467 | QWidget* ZoneMap::selectionWidget( QWidget *parent) { | ||
468 | |||
469 | QWidget *returnWidget = new QWidget( parent ); | ||
470 | |||
471 | QVBoxLayout *layout = new QVBoxLayout( returnWidget ); | ||
472 | QHBox *hBox = new QHBox( returnWidget ); | ||
473 | QListView *continentView = new QListView( hBox ); | ||
474 | continentView->addColumn( tr("Continent") ); | ||
475 | QWhatsThis::add( continentView, tr("Select a continent/country here, then select a city") ); | ||
476 | connect ( continentView, SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( slotGetCities( QListViewItem * ) ) ); | ||
477 | |||
478 | QStringList continentList; | ||
479 | QListIterator<ZoneField> itZone( zones ); | ||
480 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { | ||
481 | ZoneField *pZone = itZone.current(); | ||
482 | if ( continentList.contains( pZone->country() ) == 0 ) { | ||
483 | QString name; | ||
484 | QListViewItem *item; | ||
485 | if ( !(pZone->country().length() > 24) ) { | ||
486 | name = pZone->country().left(pZone->country().length()-1 ); | ||
487 | } else { | ||
488 | name = pZone->country().left( 24 ); | ||
489 | } | ||
490 | item = new QListViewItem( continentView, name, pZone->country() ); | ||
491 | continentList.append( pZone->country() ); | ||
492 | } | ||
493 | } | ||
494 | |||
495 | cityView = new QListView( hBox ); | ||
496 | cityView->addColumn( tr("City") ); | ||
497 | |||
498 | layout->addWidget( hBox ); | ||
499 | return returnWidget; | ||
500 | } | ||
501 | |||
502 | void ZoneMap::slotGetCities( QListViewItem * contItem) { | ||
503 | |||
504 | cityView->clear(); | ||
505 | selectedCont = contItem->text( 1 ); | ||
506 | QListIterator<ZoneField> itZone( zones ); | ||
507 | for ( itZone.toFirst(); itZone.current(); ++itZone ) { | ||
508 | ZoneField *pZone = itZone.current(); | ||
509 | if ( pZone->country() == contItem->text( 1 ) ) { | ||
510 | QListViewItem *item; | ||
511 | item = new QListViewItem( cityView, pZone->city() ); | ||
512 | connect ( cityView, SIGNAL( clicked ( QListViewItem* ) ), this, SLOT( slotCitySelected( QListViewItem* ) ) ); | ||
513 | } | ||
514 | } | ||
515 | } | ||
516 | |||
517 | void ZoneMap::slotCitySelected( QListViewItem *cityItem ) { | ||
518 | if ( cityItem ) { | ||
519 | emit signalTz( selectedCont, cityItem->text( 0 ) ); | ||
520 | } | ||
521 | } | ||
522 | |||
460 | void ZoneMap::drawCities( QPainter *p ) | 523 | void ZoneMap::drawCities( QPainter *p ) |
461 | { | 524 | { |
462 | int x, | 525 | int x, y, j; |
463 | y, | ||
464 | j; | ||
465 | // draw in the cities | 526 | // draw in the cities |