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 @@ -9,43 +9,49 @@ ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +// changes by Maximilian Reiss <harlekin@handhelds.org> + #include "sun.h" #include "zonemap.h" #include <qpe/resource.h> #include <qpe/timestring.h> #include <qpe/qpeapplication.h> #include <qdatetime.h> #include <qfile.h> #include <qimage.h> #include <qlabel.h> #include <qlist.h> #include <qmessagebox.h> #include <qpixmap.h> #include <qpainter.h> #include <qregexp.h> #include <qtextstream.h> #include <qtimer.h> #include <qtoolbutton.h> +#include <qlayout.h> +#include <qhbox.h> +#include <qlistview.h> +#include <qwhatsthis.h> #include <limits.h> // the map file... static const char strZONEINFO[] = "/usr/share/zoneinfo/zone.tab"; static const char strMAP[] = "citytime/simple_grid_400"; // the maximum distance we'll allow the pointer to be away from a city // and still show the city's time static const int iTHRESHOLD = 50000; // The label offset (how far away from pointer) @@ -448,29 +454,84 @@ void ZoneMap::resizeEvent( QResizeEvent *e ) } void ZoneMap::showZones( void ) const { // go through the zones in the list and just display the values... QListIterator<ZoneField> itZone( zones ); for ( itZone.toFirst(); itZone.current(); ++itZone ) { ZoneField *pZone = itZone.current(); pZone->showStructure(); } } + +QWidget* ZoneMap::selectionWidget( QWidget *parent) { + + QWidget *returnWidget = new QWidget( parent ); + + QVBoxLayout *layout = new QVBoxLayout( returnWidget ); + QHBox *hBox = new QHBox( returnWidget ); + QListView *continentView = new QListView( hBox ); + continentView->addColumn( tr("Continent") ); + QWhatsThis::add( continentView, tr("Select a continent/country here, then select a city") ); + connect ( continentView, SIGNAL( clicked ( QListViewItem * ) ), this, SLOT( slotGetCities( QListViewItem * ) ) ); + + QStringList continentList; + QListIterator<ZoneField> itZone( zones ); + for ( itZone.toFirst(); itZone.current(); ++itZone ) { + ZoneField *pZone = itZone.current(); + if ( continentList.contains( pZone->country() ) == 0 ) { + QString name; + QListViewItem *item; + if ( !(pZone->country().length() > 24) ) { + name = pZone->country().left(pZone->country().length()-1 ); + } else { + name = pZone->country().left( 24 ); + } + item = new QListViewItem( continentView, name, pZone->country() ); + continentList.append( pZone->country() ); + } + } + + cityView = new QListView( hBox ); + cityView->addColumn( tr("City") ); + + layout->addWidget( hBox ); + return returnWidget; +} + +void ZoneMap::slotGetCities( QListViewItem * contItem) { + + cityView->clear(); + selectedCont = contItem->text( 1 ); + QListIterator<ZoneField> itZone( zones ); + for ( itZone.toFirst(); itZone.current(); ++itZone ) { + ZoneField *pZone = itZone.current(); + if ( pZone->country() == contItem->text( 1 ) ) { + QListViewItem *item; + item = new QListViewItem( cityView, pZone->city() ); + connect ( cityView, SIGNAL( clicked ( QListViewItem* ) ), this, SLOT( slotCitySelected( QListViewItem* ) ) ); + } + } +} + +void ZoneMap::slotCitySelected( QListViewItem *cityItem ) { + if ( cityItem ) { + emit signalTz( selectedCont, cityItem->text( 0 ) ); + } +} + void ZoneMap::drawCities( QPainter *p ) { - int x, - y, - j; + int x, y, j; // draw in the cities // for testing only as when you put it // on the small screen it looks awful and not to mention useless p->setPen( red ); QListIterator<ZoneField> itZone( zones ); for ( itZone.toFirst(), j = 0; itZone.current(); ++itZone, j++ ) { ZoneField *pZone = itZone.current(); zoneToWin( pZone->x(), pZone->y(), x, y ); if ( x > wImg ) x = x - wImg; p->drawRect( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE); } |