author | ar <ar> | 2004-05-02 17:31:50 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-02 17:31:50 (UTC) |
commit | a210b9a597ba0c929d95c38ffbaf972916c7b8a7 (patch) (side-by-side diff) | |
tree | ce121d5017eb054222c86e0afb6057a28ea7bf8a /core/settings/citytime/zonemap.cpp | |
parent | 18759e9156c96795831120408a9da0d3b4ec71a4 (diff) | |
download | opie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.zip opie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.tar.gz opie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.tar.bz2 |
- convert qDebug to odebug
Diffstat (limited to 'core/settings/citytime/zonemap.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/citytime/zonemap.cpp | 402 |
1 files changed, 203 insertions, 199 deletions
diff --git a/core/settings/citytime/zonemap.cpp b/core/settings/citytime/zonemap.cpp index b6843d2..e4a25ef 100644 --- a/core/settings/citytime/zonemap.cpp +++ b/core/settings/citytime/zonemap.cpp @@ -25,5 +25,8 @@ +/* OPIE */ #include <qpe/resource.h> #include <qpe/qpeapplication.h> +#include <opie2/odebug.h> +/* QT */ #include <qfile.h> @@ -39,2 +42,3 @@ +/* STD */ #include <limits.h> @@ -63,3 +67,3 @@ ZoneField::ZoneField( const QString& strLine ) // make a bunch of RegExp's to match the data from the line - QRegExp regCoord( "[-+][0-9]+" ); // the latitude + QRegExp regCoord( "[-+][0-9]+" ); // the latitude QRegExp regCountry( "[A-Za-z]+/" ); // the country (not good enough) @@ -68,3 +72,3 @@ ZoneField::ZoneField( const QString& strLine ) int iStart, - iStop, + iStop, iLen, @@ -77,21 +81,21 @@ ZoneField::ZoneField( const QString& strLine ) if ( iStart >= 0 ) { - strTmp = strLine.mid( iStart, iLen ); - tmp = strTmp.toInt(); - // okay, there are two versions of the format, make a decision based on - // the size... - // Oh BTW, we are storing everything in seconds! - if ( iLen < 7 ) { - _y = tmp / 100; - _y *= 60; - _y += tmp % 100; - _y *= 60; - } else { - _y = tmp / 10000; - _y *= 60; - tmp %= 10000; - _y += tmp / 100; - _y *= 60; - tmp %= 100; - _y += tmp; - } + strTmp = strLine.mid( iStart, iLen ); + tmp = strTmp.toInt(); + // okay, there are two versions of the format, make a decision based on + // the size... + // Oh BTW, we are storing everything in seconds! + if ( iLen < 7 ) { + _y = tmp / 100; + _y *= 60; + _y += tmp % 100; + _y *= 60; + } else { + _y = tmp / 10000; + _y *= 60; + tmp %= 10000; + _y += tmp / 100; + _y *= 60; + tmp %= 100; + _y += tmp; + } } @@ -99,18 +103,18 @@ ZoneField::ZoneField( const QString& strLine ) if ( iStart >= 0 ) { - strTmp = strLine.mid( iStart, iLen ); - tmp = strTmp.toInt(); - if ( iLen < 8 ) { - _x = tmp / 100; - _x *= 60; - _x += tmp % 100; - _x *= 60; - } else { - _x = tmp / 10000; - _x *= 60; - tmp %= 10000; - _x += tmp / 100; - _x *= 60; - tmp %= 100; - _x += tmp; - } + strTmp = strLine.mid( iStart, iLen ); + tmp = strTmp.toInt(); + if ( iLen < 8 ) { + _x = tmp / 100; + _x *= 60; + _x += tmp % 100; + _x *= 60; + } else { + _x = tmp / 10000; + _x *= 60; + tmp %= 10000; + _x += tmp / 100; + _x *= 60; + tmp %= 100; + _x += tmp; + } } @@ -120,4 +124,4 @@ ZoneField::ZoneField( const QString& strLine ) if ( iStart >= 0 ) { - iLen = (iStop - iStart) + 1; - strCountry = strLine.mid( iStart, iLen ); + iLen = (iStop - iStart) + 1; + strCountry = strLine.mid( iStart, iLen ); } @@ -126,3 +130,3 @@ ZoneField::ZoneField( const QString& strLine ) if ( iStart >= 0 ) { - strCity = strLine.mid( iStart, iLen ); + strCity = strLine.mid( iStart, iLen ); } @@ -132,6 +136,6 @@ void ZoneField::showStructure( void ) const { - qDebug( "Country: %s", strCountry.latin1() ); - qDebug( "City: %s", strCity.latin1() ); - qDebug( "x: %d", _x ); - qDebug( "y: %d\n", _y ); + odebug << "Country: " << strCountry << "" << oendl; + odebug << "City: " << strCity << "" << oendl; + odebug << "x: " << _x << "" << oendl; + odebug << "y: " << _y << "\n" << oendl; } @@ -209,17 +213,17 @@ void ZoneMap::readZones( void ) 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); + 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(); + 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(); } @@ -247,4 +251,4 @@ void ZoneMap::viewportMouseReleaseEvent( QMouseEvent* ) if ( pLast != NULL ) { - emit signalTz( pLast->country(), pLast->city() ); - pLast = NULL; + emit signalTz( pLast->country(), pLast->city() ); + pLast = NULL; } @@ -256,29 +260,29 @@ void ZoneMap::keyPressEvent( QKeyEvent *ke ) switch ( ke->key() ) { - case Key_Left: - case Key_Right: - case Key_Up: - case Key_Down: { - tHide->stop(); - if ( !cursor ) - slotFindCity( QPoint( contentsWidth(), contentsHeight() ) / 2 ); - ZoneField *city = findCityNear( cursor, ke->key() ); - if ( city ) { - cursor = city; - int tmpx, tmpy; - zoneToWin( cursor->x(), cursor->y(), tmpx, tmpy ); - ensureVisible( tmpx, tmpy ); - showCity( cursor ); - tHide->start( 3000, true ); - } - } - break; - - case Key_Space: - case Key_Enter: - case Key_Return: - if ( cursor ) { - emit signalTz( cursor->country(), cursor->city() ); - tHide->start( 0, true ); - } - break; + case Key_Left: + case Key_Right: + case Key_Up: + case Key_Down: { + tHide->stop(); + if ( !cursor ) + slotFindCity( QPoint( contentsWidth(), contentsHeight() ) / 2 ); + ZoneField *city = findCityNear( cursor, ke->key() ); + if ( city ) { + cursor = city; + int tmpx, tmpy; + zoneToWin( cursor->x(), cursor->y(), tmpx, tmpy ); + ensureVisible( tmpx, tmpy ); + showCity( cursor ); + tHide->start( 3000, true ); + } + } + break; + + case Key_Space: + case Key_Enter: + case Key_Return: + if ( cursor ) { + emit signalTz( cursor->country(), cursor->city() ); + tHide->start( 0, true ); + } + break; } @@ -294,31 +298,31 @@ ZoneField *ZoneMap::findCityNear( ZoneField *city, int key ) for (; it.current(); ++it) { - pZone = it.current(); - long dx = (pZone->x() - city->x())/100; - long dy = (pZone->y() - city->y())/100; - switch ( key ) { - case Key_Right: - case Key_Left: - if ( key == Key_Left ) - dx = -dx; - if ( dx > 0 ) { - long dist = QABS(dy)*4 + dx; - if ( dist < ddist ) { - ddist = dist; - pClosest = pZone; - } - } - break; - case Key_Down: - case Key_Up: - if ( key == Key_Down ) - dy = -dy; - if ( dy > 0 ) { - long dist = QABS(dx)*4 + dy; - if ( dist < ddist ) { - ddist = dist; - pClosest = pZone; - } - } - break; - } + pZone = it.current(); + long dx = (pZone->x() - city->x())/100; + long dy = (pZone->y() - city->y())/100; + switch ( key ) { + case Key_Right: + case Key_Left: + if ( key == Key_Left ) + dx = -dx; + if ( dx > 0 ) { + long dist = QABS(dy)*4 + dx; + if ( dist < ddist ) { + ddist = dist; + pClosest = pZone; + } + } + break; + case Key_Down: + case Key_Up: + if ( key == Key_Down ) + dy = -dy; + if ( dy > 0 ) { + long dist = QABS(dx)*4 + dy; + if ( dist < ddist ) { + ddist = dist; + pClosest = pZone; + } + } + break; + } } @@ -353,10 +357,10 @@ void ZoneMap::slotFindCity( const QPoint &pos ) for (; it.current(); ++it) { - pZone = it.current(); - // use the manhattenLength, a good enough of an appoximation here - lDistance = QABS( x - pZone->x() ) + QABS( y - pZone->y() ); - // first to zero wins! - if ( lDistance < lClosest ) { - lClosest = lDistance; - pClosest = pZone; - } + pZone = it.current(); + // use the manhattenLength, a good enough of an appoximation here + lDistance = QABS( x - pZone->x() ) + QABS( y - pZone->y() ); + // first to zero wins! + if ( lDistance < lClosest ) { + lClosest = lDistance; + pClosest = pZone; + } } @@ -365,4 +369,4 @@ void ZoneMap::slotFindCity( const QPoint &pos ) if ( lClosest <= iTHRESHOLD ) { - showCity( pClosest ); - cursor = pClosest; + showCity( pClosest ); + cursor = pClosest; } @@ -383,3 +387,3 @@ void ZoneMap::showCity( ZoneField *city ) if ( p ) { - strSave = p; + strSave = p; } @@ -388,3 +392,3 @@ void ZoneMap::showCity( ZoneField *city ) lblCity->setText( strCity.replace( QRegExp("_"), " ") + "\n" + - TimeString::shortTime( ampm ) ); + TimeString::shortTime( ampm ) ); lblCity->setMinimumSize( lblCity->sizeHint() ); @@ -393,3 +397,3 @@ void ZoneMap::showCity( ZoneField *city ) if ( p ) - setenv( "TZ", strSave, true ); + setenv( "TZ", strSave, true ); // Now decide where to move the label, x & y can be reused @@ -399,19 +403,19 @@ void ZoneMap::showCity( ZoneField *city ) if ( lblCity->width() > drawableW - x ) { - // oops... try putting it on the right - x = x - lblCity->width() - iLABELOFFSET; + // oops... try putting it on the right + x = x - lblCity->width() - iLABELOFFSET; } else { - // the default... - x += iLABELOFFSET; + // the default... + x += iLABELOFFSET; } if ( lblCity->height() > drawableH - y ) { - // move it up... - y = y - lblCity->height() - iLABELOFFSET; + // move it up... + y = y - lblCity->height() - iLABELOFFSET; } else if ( y < 0 ) { - // the city is actually off the screen... - // this only happens on the a zoom when you are near the top, - // a quick workaround.. - y = iLABELOFFSET; + // the city is actually off the screen... + // this only happens on the a zoom when you are near the top, + // a quick workaround.. + y = iLABELOFFSET; } else { - // the default - y += iLABELOFFSET; + // the default + y += iLABELOFFSET; } @@ -420,10 +424,10 @@ void ZoneMap::showCity( ZoneField *city ) if ( pRepaint ) { - int repx, - repy; - zoneToWin( pRepaint->x(), pRepaint->y(), repx, repy ); - updateContents( repx - iCITYOFFSET, repy - iCITYOFFSET, - iCITYSIZE, iCITYSIZE ); + int repx, + repy; + zoneToWin( pRepaint->x(), pRepaint->y(), repx, repy ); + updateContents( repx - iCITYOFFSET, repy - iCITYOFFSET, + iCITYSIZE, iCITYSIZE ); } updateContents( tmpx - iCITYOFFSET, tmpy - iCITYOFFSET, iCITYSIZE, - iCITYSIZE ); + iCITYSIZE ); pRepaint = pLast; @@ -441,6 +445,6 @@ void ZoneMap::resizeEvent( QResizeEvent *e ) if ( !bZoom ) { - drawableW = width() - 2 * frameWidth(); - drawableH = height() - 2 * frameWidth(); - makeMap( drawableW, drawableH ); - resizeContents( drawableW, drawableH ); + drawableW = width() - 2 * frameWidth(); + drawableH = height() - 2 * frameWidth(); + makeMap( drawableW, drawableH ); + resizeContents( drawableW, drawableH ); } @@ -453,4 +457,4 @@ void ZoneMap::showZones( void ) const for ( itZone.toFirst(); itZone.current(); ++itZone ) { - ZoneField *pZone = itZone.current(); - pZone->showStructure(); + ZoneField *pZone = itZone.current(); + pZone->showStructure(); } @@ -473,3 +477,3 @@ QWidget* ZoneMap::selectionWidget( QWidget *parent) { for ( itZone.toFirst(); itZone.current(); ++itZone ) { - ZoneField *pZone = itZone.current(); + ZoneField *pZone = itZone.current(); if ( continentList.contains( pZone->country() ) == 0 ) { @@ -500,3 +504,3 @@ void ZoneMap::slotGetCities( QListViewItem * contItem) { for ( itZone.toFirst(); itZone.current(); ++itZone ) { - ZoneField *pZone = itZone.current(); + ZoneField *pZone = itZone.current(); if ( pZone->country() == contItem->text( 1 ) ) { @@ -524,7 +528,7 @@ void ZoneMap::drawCities( QPainter *p ) 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); + 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); } @@ -565,16 +569,16 @@ static void dayNight(QImage *pImage) for ( i = 0; i < hImage; i++ ) { - if ( wtab[i] > 0 ) { - iStart = iMid - wtab[i]; - iStop = iMid + wtab[i]; - if ( iStart < 0 ) { - darken( pImage, iStop, wImage + iStart, i ); - } else if ( iStop > wImage ) { - darken( pImage, iStop - wImage, iStart, i ); - } else { - darken( pImage, 0, iStart, i ); - darken( pImage, iStop, wImage, i ); - } - } else { - darken( pImage, 0, wImage, i ); - } + if ( wtab[i] > 0 ) { + iStart = iMid - wtab[i]; + iStop = iMid + wtab[i]; + if ( iStart < 0 ) { + darken( pImage, iStop, wImage + iStart, i ); + } else if ( iStop > wImage ) { + darken( pImage, iStop - wImage, iStart, i ); + } else { + darken( pImage, 0, iStart, i ); + darken( pImage, iStop, wImage, i ); + } + } else { + darken( pImage, 0, wImage, i ); + } } @@ -593,4 +597,4 @@ static inline void darken( QImage *pImage, int start, int stop, int row ) for ( j = start; j <= stop; j++ ) { - if ( p[j] < colors ) - p[j] += colors; + if ( p[j] < colors ) + p[j] += colors; } @@ -602,7 +606,7 @@ void ZoneMap::makeMap( int w, int h ) if ( imgOrig.isNull() ) { - QMessageBox::warning( this, - tr( "Couldn't Find Map" ), - tr( "<p>Couldn't load map: %1, exiting") + QMessageBox::warning( this, + tr( "Couldn't Find Map" ), + tr( "<p>Couldn't load map: %1, exiting") .arg( strMAP ) ); - exit(-1); + exit(-1); } @@ -616,5 +620,5 @@ void ZoneMap::makeMap( int w, int h ) for ( int i = 0; i < numColors; i++ ) { - QRgb rgb = imgOrig.color( i ); - imgOrig.setColor ( i + numColors, qRgb( 2 * qRed( rgb ) / 3, - 2 * qGreen( rgb ) / 3, 2 * qBlue( rgb ) / 3 ) ); + QRgb rgb = imgOrig.color( i ); + imgOrig.setColor ( i + numColors, qRgb( 2 * qRed( rgb ) / 3, + 2 * qGreen( rgb ) / 3, 2 * qBlue( rgb ) / 3 ) ); } @@ -623,4 +627,4 @@ void ZoneMap::makeMap( int w, int h ) if ( bIllum ) { - // do a daylight mask - dayNight(&imgOrig); + // do a daylight mask + dayNight(&imgOrig); } @@ -656,3 +660,3 @@ void ZoneMap::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) ( pixmapH != drawableH) ) ) { - makeMap( drawableW, drawableH ); + makeMap( drawableW, drawableH ); } @@ -667,7 +671,7 @@ void ZoneMap::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) for ( int r = toprow; r <= bottomrow; r++ ) { - int py = r * rowheight; - for ( int c = leftcol; c <= rightcol; c++ ) { - int px = c * colwidth; - p->drawPixmap( px, py, *pixCurr ); - } + int py = r * rowheight; + for ( int c = leftcol; c <= rightcol; c++ ) { + int px = c * colwidth; + p->drawPixmap( px, py, *pixCurr ); + } } @@ -676,3 +680,3 @@ void ZoneMap::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) if ( pLast ) - drawCity( p, pLast ); + drawCity( p, pLast ); } @@ -683,7 +687,7 @@ void ZoneMap::slotZoom( bool setZoom ) if ( bZoom ) { - makeMap( 2 * wImg , 2 * hImg ); - resizeContents( wImg, hImg ); + makeMap( 2 * wImg , 2 * hImg ); + resizeContents( wImg, hImg ); } else { - makeMap( drawableW, drawableH ); - resizeContents( drawableW, drawableH ); + makeMap( drawableW, drawableH ); + resizeContents( drawableW, drawableH ); } @@ -713,5 +717,5 @@ void ZoneMap::slotRedraw( void ) if ( pRepaint ) { - pLast = 0; - zoneToWin(pRepaint->x(), pRepaint->y(), x, y); - updateContents( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE); + pLast = 0; + zoneToWin(pRepaint->x(), pRepaint->y(), x, y); + updateContents( x - iCITYOFFSET, y - iCITYOFFSET, iCITYSIZE, iCITYSIZE); pRepaint = 0; |