summaryrefslogtreecommitdiff
path: root/core/settings/citytime/zonemap.cpp
Side-by-side diff
Diffstat (limited to 'core/settings/citytime/zonemap.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/settings/citytime/zonemap.cpp67
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
@@ -15,12 +15,14 @@
**
** 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>
@@ -34,12 +36,16 @@
#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";
@@ -454,17 +460,72 @@ void ZoneMap::showZones( void ) const
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++ ) {