summaryrefslogtreecommitdiff
path: root/core/settings/citytime/zonemap.h
Unidiff
Diffstat (limited to 'core/settings/citytime/zonemap.h') (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/citytime/zonemap.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/core/settings/citytime/zonemap.h b/core/settings/citytime/zonemap.h
index c9c2035..ea0142b 100644
--- a/core/settings/citytime/zonemap.h
+++ b/core/settings/citytime/zonemap.h
@@ -7,43 +7,44 @@
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#ifndef ZONEMAP_H 21#ifndef ZONEMAP_H
22#define ZONEMAP_H 22#define ZONEMAP_H
23 23
24#include "stylusnormalizer.h" 24#include "stylusnormalizer.h"
25 25
26#include <qlist.h> 26#include <qlist.h>
27#include <qscrollview.h> 27#include <qscrollview.h>
28#include <qstring.h> 28#include <qstring.h>
29 29
30extern const int iCITYOFFSET; 30extern const int iCITYOFFSET;
31 31
32class QImage; 32class QImage;
33class QComboBox; 33class QComboBox;
34class QLabel; 34class QLabel;
35class QTimer; 35class QTimer;
36class QToolButton; 36class QToolButton;
37 37class QListViewItem;
38class QListView;
38 39
39 40
40class ZoneField 41class ZoneField
41{ 42{
42public: 43public:
43 ZoneField( const QString & ); 44 ZoneField( const QString & );
44 void showStructure( void ) const; 45 void showStructure( void ) const;
45 inline int x( void ) const { return _x; }; 46 inline int x( void ) const { return _x; };
46 inline int y( void ) const { return _y; }; 47 inline int y( void ) const { return _y; };
47 48
48 inline QString city( void ) const { return strCity; }; 49 inline QString city( void ) const { return strCity; };
49 inline QString country( void ) const { return strCountry; }; 50 inline QString country( void ) const { return strCountry; };
@@ -54,65 +55,72 @@ private:
54 QString strCountryCode; 55 QString strCountryCode;
55 QString strCountry; 56 QString strCountry;
56 QString strCity; 57 QString strCity;
57}; 58};
58 59
59class ZoneMap : public QScrollView 60class ZoneMap : public QScrollView
60{ 61{
61 Q_OBJECT 62 Q_OBJECT
62public: 63public:
63 ZoneMap( QWidget *parent = 0, const char *name = 0 ); 64 ZoneMap( QWidget *parent = 0, const char *name = 0 );
64 ~ZoneMap(); 65 ~ZoneMap();
65 void showZones( void ) const; 66 void showZones( void ) const;
67 QWidget* selectionWidget( QWidget* parent );
66 // convert between the pixels on the image and the coordinates in the 68 // convert between the pixels on the image and the coordinates in the
67 // database 69 // database
68 inline bool zoneToWin( int zoneX, int zoneY, int &winX, int &winY ) const; 70 inline bool zoneToWin( int zoneX, int zoneY, int &winX, int &winY ) const;
69 inline bool winToZone( int winX, int winY, int &zoneX, int &zoneY ) const; 71 inline bool winToZone( int winX, int winY, int &zoneX, int &zoneY ) const;
70 72
71public slots: 73public slots:
72 void slotZoom( bool setZoom ); 74 void slotZoom( bool setZoom );
73 void slotIllum( bool setIllum ); 75 void slotIllum( bool setIllum );
74 void slotUpdate( void ); 76 void slotUpdate( void );
75 void slotRedraw( void ); 77 void slotRedraw( void );
76 void slotFindCity( const QPoint &pos ); // Find the closest city 78 void slotFindCity( const QPoint &pos ); // Find the closest city
77 void changeClock( bool ); 79 void changeClock( bool );
78 80
79signals: 81signals:
80 void signalTz( const QString &newCountry, const QString &newCity ); 82 void signalTz( const QString &newCountry, const QString &newCity );
81 83
82protected: 84protected:
83 virtual void viewportMouseMoveEvent( QMouseEvent *event ); 85 virtual void viewportMouseMoveEvent( QMouseEvent *event );
84 virtual void viewportMousePressEvent( QMouseEvent *event ); 86 virtual void viewportMousePressEvent( QMouseEvent *event );
85 virtual void viewportMouseReleaseEvent( QMouseEvent *event ); 87 virtual void viewportMouseReleaseEvent( QMouseEvent *event );
86 virtual void keyPressEvent( QKeyEvent * ); 88 virtual void keyPressEvent( QKeyEvent * );
87 virtual void resizeEvent( QResizeEvent *); 89 virtual void resizeEvent( QResizeEvent *);
88 virtual void drawContents( QPainter *p, int cx, int cy, int cw, int ch ); 90 virtual void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
89 91
92private slots:
93 void slotGetCities( QListViewItem * );
94 void slotCitySelected( QListViewItem * );
90private: 95private:
91 ZoneField *findCityNear( ZoneField *city, int key ); 96 ZoneField *findCityNear( ZoneField *city, int key );
92 void showCity( ZoneField *city ); 97 void showCity( ZoneField *city );
93 void drawCities( QPainter *p );// put all the cities on the map (ugly) 98 void drawCities( QPainter *p );// put all the cities on the map (ugly)
94 void drawCity( QPainter *p, const ZoneField *pCity ); // draw the given city on the map 99 void drawCity( QPainter *p, const ZoneField *pCity ); // draw the given city on the map
95 void readZones( void ); // Read in the zone information from the file 100 void readZones( void ); // Read in the zone information from the file
96 void zoom( void ); // Zoom the map... 101 void zoom( void ); // Zoom the map...
97 void makeMap( int width, int height ); 102 void makeMap( int width, int height );
98 QPixmap* pixCurr; // image to be drawn on the screen 103 QPixmap* pixCurr; // image to be drawn on the screen
99 QLabel* lblCity; // the "tool-tip" that shows up when you pick a city... 104 QLabel* lblCity; // the "tool-tip" that shows up when you pick a city...
100 QToolButton *cmdZoom; // our zoom option... 105 QToolButton *cmdZoom; // our zoom option...
101 QTimer*tHide; // the timer to hide the "tool tip" 106 QTimer*tHide; // the timer to hide the "tool tip"
102 ZoneField *pLast; // the last known good city that was found... 107 ZoneField *pLast; // the last known good city that was found...
103 ZoneField *pRepaint; // save the location to maximize the repaint... 108 ZoneField *pRepaint; // save the location to maximize the repaint...
104 QList<ZoneField> zones; // a linked list to hold all this information 109 QList<ZoneField> zones; // a linked list to hold all this information
105 StylusNormalizer norm; 110 StylusNormalizer norm;
106 111
112 QListView *cityView;
113 QString selectedCont;
114
107 //the True width and height of the map... 115 //the True width and height of the map...
108 int wImg; 116 int wImg;
109 int hImg; 117 int hImg;
110 // the pixel points that correspond to (0, 0); 118 // the pixel points that correspond to (0, 0);
111 int ox; 119 int ox;
112 int oy; 120 int oy;
113 121
114 // the drawable area of the map... 122 // the drawable area of the map...
115 int drawableW; 123 int drawableW;
116 int drawableH; 124 int drawableH;
117 125
118 bool bZoom; // a flag to indicate zoom is active 126 bool bZoom; // a flag to indicate zoom is active
@@ -134,24 +142,24 @@ inline bool ZoneMap::zoneToWin( int zoneX, int zoneY,
134 winX = iCITYOFFSET; 142 winX = iCITYOFFSET;
135 } 143 }
136 144
137 if ( winY >= hImg ) { 145 if ( winY >= hImg ) {
138 winY = hImg - iCITYOFFSET; 146 winY = hImg - iCITYOFFSET;
139 } else if ( winY <= 0 ) { 147 } else if ( winY <= 0 ) {
140 winY = iCITYOFFSET; 148 winY = iCITYOFFSET;
141 } 149 }
142 // perhaps in the future there will be some real error checking 150 // perhaps in the future there will be some real error checking
143 // for now just return true... 151 // for now just return true...
144 return true; 152 return true;
145} 153}
146 154
147inline bool ZoneMap::winToZone( int winX, int winY, 155inline bool ZoneMap::winToZone( int winX, int winY,
148 int &zoneX, int &zoneY ) const 156 int &zoneX, int &zoneY ) const
149{ 157{
150 zoneY = ( 648000 * ( oy - winY ) ) / hImg; 158 zoneY = ( 648000 * ( oy - winY ) ) / hImg;
151 zoneX = ( 1296000 * ( winX - ox ) ) / wImg; 159 zoneX = ( 1296000 * ( winX - ox ) ) / wImg;
152 // perhaps in the future there will be some real error checking 160 // perhaps in the future there will be some real error checking
153 // for now just return true... 161 // for now just return true...
154 return true; 162 return true;
155} 163}
156 164
157#endif 165#endif