-rw-r--r-- | core/settings/citytime/zonemap.cpp | 2 | ||||
-rw-r--r-- | pics/simple_grid_400.png | bin | 4533 -> 0 bytes |
2 files changed, 1 insertions, 1 deletions
diff --git a/core/settings/citytime/zonemap.cpp b/core/settings/citytime/zonemap.cpp index 337f4d9..1d60aee 100644 --- a/core/settings/citytime/zonemap.cpp +++ b/core/settings/citytime/zonemap.cpp | |||
@@ -1,237 +1,237 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "sun.h" | 21 | #include "sun.h" |
22 | #include "zonemap.h" | 22 | #include "zonemap.h" |
23 | 23 | ||
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/timestring.h> | 25 | #include <qpe/timestring.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | 27 | ||
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qimage.h> | 30 | #include <qimage.h> |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qlist.h> | 32 | #include <qlist.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | #include <qtimer.h> | 38 | #include <qtimer.h> |
39 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
40 | 40 | ||
41 | #include <limits.h> | 41 | #include <limits.h> |
42 | 42 | ||
43 | // the map file... | 43 | // the map file... |
44 | static const char strZONEINFO[] = "/usr/share/zoneinfo/zone.tab"; | 44 | static const char strZONEINFO[] = "/usr/share/zoneinfo/zone.tab"; |
45 | static const char strMAP[] = "simple_grid_400"; | 45 | static const char strMAP[] = "citytime/simple_grid_400"; |
46 | 46 | ||
47 | // the maximum distance we'll allow the pointer to be away from a city | 47 | // the maximum distance we'll allow the pointer to be away from a city |
48 | // and still show the city's time | 48 | // and still show the city's time |
49 | static const int iTHRESHOLD = 50000; | 49 | static const int iTHRESHOLD = 50000; |
50 | 50 | ||
51 | // The label offset (how far away from pointer) | 51 | // The label offset (how far away from pointer) |
52 | static const int iLABELOFFSET = 8; | 52 | static const int iLABELOFFSET = 8; |
53 | 53 | ||
54 | // the size of the dot to draw, and where to start it | 54 | // the size of the dot to draw, and where to start it |
55 | static const int iCITYSIZE = 3; | 55 | static const int iCITYSIZE = 3; |
56 | const int iCITYOFFSET = 2; | 56 | const int iCITYOFFSET = 2; |
57 | 57 | ||
58 | // the darkening function | 58 | // the darkening function |
59 | static inline void darken( QImage *pImage, int start, int stop, int row ); | 59 | static inline void darken( QImage *pImage, int start, int stop, int row ); |
60 | static void dayNight( QImage *pImage ); | 60 | static void dayNight( QImage *pImage ); |
61 | 61 | ||
62 | ZoneField::ZoneField( const QString& strLine ) | 62 | ZoneField::ZoneField( const QString& strLine ) |
63 | { | 63 | { |
64 | // make a bunch of RegExp's to match the data from the line | 64 | // make a bunch of RegExp's to match the data from the line |
65 | QRegExp regCoord( "[-+][0-9]+" );// the latitude | 65 | QRegExp regCoord( "[-+][0-9]+" );// the latitude |
66 | QRegExp regCountry( "[A-Za-z]+/" ); // the country (not good enough) | 66 | QRegExp regCountry( "[A-Za-z]+/" ); // the country (not good enough) |
67 | QRegExp regCity( "[A-Za-z_-]*" ); // the city | 67 | QRegExp regCity( "[A-Za-z_-]*" ); // the city |
68 | 68 | ||
69 | int iStart, | 69 | int iStart, |
70 | iStop, | 70 | iStop, |
71 | iLen, | 71 | iLen, |
72 | tmp; | 72 | tmp; |
73 | QString strTmp; | 73 | QString strTmp; |
74 | // we should be able to assume that the country code is always the first | 74 | // we should be able to assume that the country code is always the first |
75 | // two chars, so just grap them and let it go... | 75 | // two chars, so just grap them and let it go... |
76 | strCountryCode = strLine.left( 2 ); | 76 | strCountryCode = strLine.left( 2 ); |
77 | iStart = regCoord.match( strLine, 0, &iLen ); | 77 | iStart = regCoord.match( strLine, 0, &iLen ); |
78 | if ( iStart >= 0 ) { | 78 | if ( iStart >= 0 ) { |
79 | strTmp = strLine.mid( iStart, iLen ); | 79 | strTmp = strLine.mid( iStart, iLen ); |
80 | tmp = strTmp.toInt(); | 80 | tmp = strTmp.toInt(); |
81 | // okay, there are two versions of the format, make a decision based on | 81 | // okay, there are two versions of the format, make a decision based on |
82 | // the size... | 82 | // the size... |
83 | // Oh BTW, we are storing everything in seconds! | 83 | // Oh BTW, we are storing everything in seconds! |
84 | if ( iLen < 7 ) { | 84 | if ( iLen < 7 ) { |
85 | _y = tmp / 100; | 85 | _y = tmp / 100; |
86 | _y *= 60; | 86 | _y *= 60; |
87 | _y += tmp % 100; | 87 | _y += tmp % 100; |
88 | _y *= 60; | 88 | _y *= 60; |
89 | } else { | 89 | } else { |
90 | _y = tmp / 10000; | 90 | _y = tmp / 10000; |
91 | _y *= 60; | 91 | _y *= 60; |
92 | tmp %= 10000; | 92 | tmp %= 10000; |
93 | _y += tmp / 100; | 93 | _y += tmp / 100; |
94 | _y *= 60; | 94 | _y *= 60; |
95 | tmp %= 100; | 95 | tmp %= 100; |
96 | _y += tmp; | 96 | _y += tmp; |
97 | } | 97 | } |
98 | } | 98 | } |
99 | iStart = regCoord.match( strLine, iStart + iLen, &iLen ); | 99 | iStart = regCoord.match( strLine, iStart + iLen, &iLen ); |
100 | if ( iStart >= 0 ) { | 100 | if ( iStart >= 0 ) { |
101 | strTmp = strLine.mid( iStart, iLen ); | 101 | strTmp = strLine.mid( iStart, iLen ); |
102 | tmp = strTmp.toInt(); | 102 | tmp = strTmp.toInt(); |
103 | if ( iLen < 8 ) { | 103 | if ( iLen < 8 ) { |
104 | _x = tmp / 100; | 104 | _x = tmp / 100; |
105 | _x *= 60; | 105 | _x *= 60; |
106 | _x += tmp % 100; | 106 | _x += tmp % 100; |
107 | _x *= 60; | 107 | _x *= 60; |
108 | } else { | 108 | } else { |
109 | _x = tmp / 10000; | 109 | _x = tmp / 10000; |
110 | _x *= 60; | 110 | _x *= 60; |
111 | tmp %= 10000; | 111 | tmp %= 10000; |
112 | _x += tmp / 100; | 112 | _x += tmp / 100; |
113 | _x *= 60; | 113 | _x *= 60; |
114 | tmp %= 100; | 114 | tmp %= 100; |
115 | _x += tmp; | 115 | _x += tmp; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | iStart = regCountry.match( strLine, 0, &iLen ); | 118 | iStart = regCountry.match( strLine, 0, &iLen ); |
119 | // help with the shortcoming in 2.x regexp... | 119 | // help with the shortcoming in 2.x regexp... |
120 | iStop = strLine.findRev( '/' ); | 120 | iStop = strLine.findRev( '/' ); |
121 | if ( iStart >= 0 ) { | 121 | if ( iStart >= 0 ) { |
122 | iLen = (iStop - iStart) + 1; | 122 | iLen = (iStop - iStart) + 1; |
123 | strCountry = strLine.mid( iStart, iLen ); | 123 | strCountry = strLine.mid( iStart, iLen ); |
124 | } | 124 | } |
125 | // now match the city... | 125 | // now match the city... |
126 | iStart = regCity.match( strLine, iStart + iLen, &iLen ); | 126 | iStart = regCity.match( strLine, iStart + iLen, &iLen ); |
127 | if ( iStart >= 0 ) { | 127 | if ( iStart >= 0 ) { |
128 | strCity = strLine.mid( iStart, iLen ); | 128 | strCity = strLine.mid( iStart, iLen ); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | void ZoneField::showStructure( void ) const | 132 | void ZoneField::showStructure( void ) const |
133 | { | 133 | { |
134 | qDebug( "Country: %s", strCountry.latin1() ); | 134 | qDebug( "Country: %s", strCountry.latin1() ); |
135 | qDebug( "City: %s", strCity.latin1() ); | 135 | qDebug( "City: %s", strCity.latin1() ); |
136 | qDebug( "x: %d", _x ); | 136 | qDebug( "x: %d", _x ); |
137 | qDebug( "y: %d\n", _y ); | 137 | qDebug( "y: %d\n", _y ); |
138 | } | 138 | } |
139 | 139 | ||
140 | ZoneMap::ZoneMap( QWidget *parent, const char* name ) | 140 | ZoneMap::ZoneMap( QWidget *parent, const char* name ) |
141 | : QScrollView( parent, name ), | 141 | : QScrollView( parent, name ), |
142 | pLast( 0 ), | 142 | pLast( 0 ), |
143 | pRepaint( 0 ), | 143 | pRepaint( 0 ), |
144 | ox( 0 ), | 144 | ox( 0 ), |
145 | oy( 0 ), | 145 | oy( 0 ), |
146 | drawableW( -1 ), | 146 | drawableW( -1 ), |
147 | drawableH( -1 ), | 147 | drawableH( -1 ), |
148 | bZoom( FALSE ), | 148 | bZoom( FALSE ), |
149 | bIllum( TRUE ), | 149 | bIllum( TRUE ), |
150 | cursor( 0 ) | 150 | cursor( 0 ) |
151 | { | 151 | { |
152 | viewport()->setFocusPolicy( StrongFocus ); | 152 | viewport()->setFocusPolicy( StrongFocus ); |
153 | 153 | ||
154 | // set mouse tracking so we can use the mouse move event | 154 | // set mouse tracking so we can use the mouse move event |
155 | zones.setAutoDelete( true ); | 155 | zones.setAutoDelete( true ); |
156 | // get the map loaded | 156 | // get the map loaded |
157 | // just set the current image to point | 157 | // just set the current image to point |
158 | pixCurr = new QPixmap(); | 158 | pixCurr = new QPixmap(); |
159 | 159 | ||
160 | QPixmap pixZoom = Resource::loadPixmap( "mag" ); | 160 | QPixmap pixZoom = Resource::loadPixmap( "mag" ); |
161 | 161 | ||
162 | cmdZoom = new QToolButton( this, "Zoom command" ); | 162 | cmdZoom = new QToolButton( this, "Zoom command" ); |
163 | cmdZoom->setPixmap( pixZoom ); | 163 | cmdZoom->setPixmap( pixZoom ); |
164 | cmdZoom->setToggleButton( true ); | 164 | cmdZoom->setToggleButton( true ); |
165 | 165 | ||
166 | cmdZoom->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, | 166 | cmdZoom->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, |
167 | (QSizePolicy::SizeType)0, | 167 | (QSizePolicy::SizeType)0, |
168 | cmdZoom->sizePolicy().hasHeightForWidth() ) ); | 168 | cmdZoom->sizePolicy().hasHeightForWidth() ) ); |
169 | cmdZoom->setMaximumSize( cmdZoom->sizeHint() ); | 169 | cmdZoom->setMaximumSize( cmdZoom->sizeHint() ); |
170 | // probably don't need this, but just in case... | 170 | // probably don't need this, but just in case... |
171 | cmdZoom->move( width() - cmdZoom->width(), height() - cmdZoom->height() ); | 171 | cmdZoom->move( width() - cmdZoom->width(), height() - cmdZoom->height() ); |
172 | 172 | ||
173 | 173 | ||
174 | lblCity = new QLabel( tr( "CITY" ), this, "City Label" ); | 174 | lblCity = new QLabel( tr( "CITY" ), this, "City Label" ); |
175 | lblCity->setMinimumSize( lblCity->sizeHint() ); | 175 | lblCity->setMinimumSize( lblCity->sizeHint() ); |
176 | lblCity->setFrameStyle( QFrame::Plain | QFrame::Box ); | 176 | lblCity->setFrameStyle( QFrame::Plain | QFrame::Box ); |
177 | lblCity->setBackgroundColor( yellow ); | 177 | lblCity->setBackgroundColor( yellow ); |
178 | lblCity->hide(); | 178 | lblCity->hide(); |
179 | 179 | ||
180 | // A timer to make sure the label gets hidden | 180 | // A timer to make sure the label gets hidden |
181 | tHide = new QTimer( this, "Label Timer" ); | 181 | tHide = new QTimer( this, "Label Timer" ); |
182 | QObject::connect( tHide, SIGNAL( timeout() ), | 182 | QObject::connect( tHide, SIGNAL( timeout() ), |
183 | lblCity, SLOT( hide() ) ); | 183 | lblCity, SLOT( hide() ) ); |
184 | QObject::connect( tHide, SIGNAL( timeout() ), | 184 | QObject::connect( tHide, SIGNAL( timeout() ), |
185 | this, SLOT( slotRedraw() ) ); | 185 | this, SLOT( slotRedraw() ) ); |
186 | QTimer *tUpdate = new QTimer( this, "Update Timer" ); | 186 | QTimer *tUpdate = new QTimer( this, "Update Timer" ); |
187 | QObject::connect( tUpdate, SIGNAL( timeout() ), | 187 | QObject::connect( tUpdate, SIGNAL( timeout() ), |
188 | this, SLOT( slotUpdate() ) ); | 188 | this, SLOT( slotUpdate() ) ); |
189 | QObject::connect( qApp, SIGNAL( timeChanged() ), | 189 | QObject::connect( qApp, SIGNAL( timeChanged() ), |
190 | this, SLOT( slotUpdate() ) ); | 190 | this, SLOT( slotUpdate() ) ); |
191 | QObject::connect( cmdZoom, SIGNAL( toggled( bool ) ), | 191 | QObject::connect( cmdZoom, SIGNAL( toggled( bool ) ), |
192 | this, SLOT( slotZoom( bool ) ) ); | 192 | this, SLOT( slotZoom( bool ) ) ); |
193 | QObject::connect( &norm, SIGNAL( signalNewPoint( const QPoint& ) ), | 193 | QObject::connect( &norm, SIGNAL( signalNewPoint( const QPoint& ) ), |
194 | this, SLOT( slotFindCity( const QPoint& ) ) ); | 194 | this, SLOT( slotFindCity( const QPoint& ) ) ); |
195 | QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), | 195 | QObject::connect( qApp, SIGNAL( clockChanged( bool ) ), |
196 | this, SLOT( changeClock( bool ) ) ); | 196 | this, SLOT( changeClock( bool ) ) ); |
197 | // update the sun's movement every 5 minutes | 197 | // update the sun's movement every 5 minutes |
198 | tUpdate->start( 5 * 60 * 1000 ); | 198 | tUpdate->start( 5 * 60 * 1000 ); |
199 | // May as well read in the timezone information too... | 199 | // May as well read in the timezone information too... |
200 | readZones(); | 200 | readZones(); |
201 | } | 201 | } |
202 | 202 | ||
203 | ZoneMap::~ZoneMap() | 203 | ZoneMap::~ZoneMap() |
204 | { | 204 | { |
205 | } | 205 | } |
206 | 206 | ||
207 | void ZoneMap::readZones( void ) | 207 | void ZoneMap::readZones( void ) |
208 | { | 208 | { |
209 | QFile fZone( strZONEINFO ); | 209 | QFile fZone( strZONEINFO ); |
210 | if ( !fZone.open( IO_ReadOnly ) ) { | 210 | if ( !fZone.open( IO_ReadOnly ) ) { |
211 | QMessageBox::warning (this, | 211 | QMessageBox::warning (this, |
212 | tr( "Unable to Find Timezone Info" ), | 212 | tr( "Unable to Find Timezone Info" ), |
213 | tr( "<p>Unable to find any timezone information in %1" ) | 213 | tr( "<p>Unable to find any timezone information in %1" ) |
214 | .arg( strZONEINFO )); | 214 | .arg( strZONEINFO )); |
215 | exit(-1); | 215 | exit(-1); |
216 | } else { | 216 | } else { |
217 | QTextStream tZone( &fZone ); | 217 | QTextStream tZone( &fZone ); |
218 | while ( !tZone.atEnd() ) { | 218 | while ( !tZone.atEnd() ) { |
219 | QString strLine = tZone.readLine(); | 219 | QString strLine = tZone.readLine(); |
220 | // only pass on lines that aren't comments | 220 | // only pass on lines that aren't comments |
221 | if ( strLine[0] != '#' ) { | 221 | if ( strLine[0] != '#' ) { |
222 | zones.append( new ZoneField( strLine ) ); | 222 | zones.append( new ZoneField( strLine ) ); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | fZone.close(); | 225 | fZone.close(); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | 228 | ||
229 | void ZoneMap::viewportMousePressEvent( QMouseEvent* event ) | 229 | void ZoneMap::viewportMousePressEvent( QMouseEvent* event ) |
230 | { | 230 | { |
231 | // add the mouse event into the normalizer, and get the average, | 231 | // add the mouse event into the normalizer, and get the average, |
232 | // pass it along | 232 | // pass it along |
233 | slotRedraw(); | 233 | slotRedraw(); |
234 | norm.start(); | 234 | norm.start(); |
235 | norm.addEvent( event->pos() ); | 235 | norm.addEvent( event->pos() ); |
236 | } | 236 | } |
237 | 237 | ||
diff --git a/pics/simple_grid_400.png b/pics/simple_grid_400.png deleted file mode 100644 index 5e0e21d..0000000 --- a/pics/simple_grid_400.png +++ b/dev/null | |||
Binary files differ | |||