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.cpp16
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 )
pRepaint( 0 ),
ox( 0 ),
oy( 0 ),
drawableW( -1 ),
drawableH( -1 ),
bZoom( FALSE ),
bIllum( TRUE ),
cursor( 0 )
{
viewport()->setFocusPolicy( StrongFocus );
// set mouse tracking so we can use the mouse move event
zones.setAutoDelete( true );
// get the map loaded
// just set the current image to point
pixCurr = new QPixmap();
QPixmap pixZoom = Resource::loadPixmap( "mag" );
cmdZoom = new QToolButton( this, "Zoom command" );
cmdZoom->setPixmap( pixZoom );
cmdZoom->setToggleButton( true );
cmdZoom->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0,
(QSizePolicy::SizeType)0,
cmdZoom->sizePolicy().hasHeightForWidth() ) );
cmdZoom->setMaximumSize( cmdZoom->sizeHint() );
// probably don't need this, but just in case...
cmdZoom->move( width() - cmdZoom->width(), height() - cmdZoom->height() );
lblCity = new QLabel( tr( "CITY" ), this, "City Label" );
lblCity->setMinimumSize( lblCity->sizeHint() );
lblCity->setFrameStyle( QFrame::Plain | QFrame::Box );
lblCity->setBackgroundColor( yellow );
lblCity->hide();
// A timer to make sure the label gets hidden
tHide = new QTimer( this, "Label Timer" );
QObject::connect( tHide, SIGNAL( timeout() ),
lblCity, SLOT( hide() ) );
QObject::connect( tHide, SIGNAL( timeout() ),
this, SLOT( slotRedraw() ) );
QTimer *tUpdate = new QTimer( this, "Update Timer" );
QObject::connect( tUpdate, SIGNAL( timeout() ),
this, SLOT( slotUpdate() ) );
QObject::connect( qApp, SIGNAL( timeChanged() ),
this, SLOT( slotUpdate() ) );
- QObject::connect( cmdZoom, SIGNAL( toggled( bool ) ),
- this, SLOT( slotZoom( bool ) ) );
- QObject::connect( &norm, SIGNAL( signalNewPoint( const QPoint& ) ),
- this, SLOT( slotFindCity( const QPoint& ) ) );
- QObject::connect( qApp, SIGNAL( clockChanged( bool ) ),
- this, SLOT( changeClock( bool ) ) );
+ QObject::connect( cmdZoom, SIGNAL( toggled(bool) ),
+ this, SLOT( slotZoom(bool) ) );
+ QObject::connect( &norm, SIGNAL( signalNewPoint(const QPoint&) ),
+ this, SLOT( slotFindCity(const QPoint&) ) );
+ QObject::connect( qApp, SIGNAL( clockChanged(bool) ),
+ this, SLOT( changeClock(bool) ) );
// update the sun's movement every 5 minutes
tUpdate->start( 5 * 60 * 1000 );
// May as well read in the timezone information too...
readZones();
}
ZoneMap::~ZoneMap()
{
}
void ZoneMap::readZones( void )
{
QFile fZone( strZONEINFO );
if ( !fZone.open( IO_ReadOnly ) ) {
QMessageBox::warning (this,
tr( "Unable to Find Timezone Info" ),
tr( "<p>Unable to find any timezone information in %1" )
.arg( strZONEINFO ));
exit(-1);
} else {
QTextStream tZone( &fZone );
while ( !tZone.atEnd() ) {
QString strLine = tZone.readLine();
// only pass on lines that aren't comments
if ( strLine[0] != '#' ) {
zones.append( new ZoneField( strLine ) );
}
}
fZone.close();
}
}
void ZoneMap::viewportMousePressEvent( QMouseEvent* event )
{
// add the mouse event into the normalizer, and get the average,
// pass it along
slotRedraw();
norm.start();
norm.addEvent( event->pos() );
}
void ZoneMap::viewportMouseMoveEvent( QMouseEvent* event )
{
norm.addEvent( event->pos() );
}
void ZoneMap::viewportMouseReleaseEvent( QMouseEvent* )
{
@@ -421,133 +421,133 @@ void ZoneMap::showCity( ZoneField *city )
int repx,
repy;
zoneToWin( pRepaint->x(), pRepaint->y(), repx, repy );
updateContents( repx - iCITYOFFSET, repy - iCITYOFFSET,
iCITYSIZE, iCITYSIZE );
}
updateContents( tmpx - iCITYOFFSET, tmpy - iCITYOFFSET, iCITYSIZE,
iCITYSIZE );
pRepaint = pLast;
lblCity->move( x, y );
lblCity->show();
}
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 * ) ) );
+ 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* ) ) );
+ 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;
// 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(),
iStart,
iStop,
iMid,
relw,
i;
short wtab[ wImage ];
time_t tCurrent;
struct tm *pTm;
// get the position of the sun bassed on our current time...
tCurrent = time( NULL );