summaryrefslogtreecommitdiff
path: root/core/settings/citytime/zonemap.cpp
Side-by-side diff
Diffstat (limited to 'core/settings/citytime/zonemap.cpp') (more/less context) (ignore 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
@@ -1,63 +1,69 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** 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)
static const int iLABELOFFSET = 8;
// the size of the dot to draw, and where to start it
static const int iCITYSIZE = 3;
const int iCITYOFFSET = 2;
// the darkening function
static inline void darken( QImage *pImage, int start, int stop, int row );
static void dayNight( QImage *pImage );
ZoneField::ZoneField( const QString& strLine )
{
@@ -436,53 +442,108 @@ void ZoneMap::showCity( ZoneField *city )
void ZoneMap::resizeEvent( QResizeEvent *e )
{
// keep the zoom button down in the corner
QSize _size = e->size();
cmdZoom->move( _size.width() - cmdZoom->width(),
_size.height() - cmdZoom->height() );
if ( !bZoom ) {
drawableW = width() - 2 * frameWidth();
drawableH = height() - 2 * frameWidth();
makeMap( drawableW, drawableH );
resizeContents( drawableW, drawableH );
}
}
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);
}
}
static void dayNight(QImage *pImage)
{
// create a mask the functions from sun.h
double dJulian,
dSunRad,
dSunDecl,
dSunRadius,
dSunLong;
int wImage = pImage->width(),
hImage = pImage->height(),