summaryrefslogtreecommitdiffabout
path: root/kaddressbook/geowidget.h
Unidiff
Diffstat (limited to 'kaddressbook/geowidget.h') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/geowidget.h155
1 files changed, 155 insertions, 0 deletions
diff --git a/kaddressbook/geowidget.h b/kaddressbook/geowidget.h
new file mode 100644
index 0000000..3d39691
--- a/dev/null
+++ b/kaddressbook/geowidget.h
@@ -0,0 +1,155 @@
1/*
2 This file is part of KAddressBook.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#ifndef GEOWIDGET_H
25#define GEOWIDGET_H
26
27#include <qmap.h>
28
29#include <qwidget.h>
30#include <kdialogbase.h>
31
32namespace KABC {
33class Geo;
34}
35
36class GeoMapWidget;
37
38class KComboBox;
39class KDoubleSpinBox;
40
41class QCheckBox;
42class QLabel;
43class QSpinBox;
44class QPushButton;
45
46typedef struct {
47 double latitude;
48 double longitude;
49 QString country;
50} GeoData;
51
52class GeoWidget : public QWidget
53{
54 Q_OBJECT
55
56 public:
57 GeoWidget( QWidget *parent, const char *name = 0 );
58 ~GeoWidget();
59
60 /**
61 Sets the geo object.
62 */
63 void setGeo( const KABC::Geo &geo );
64
65 /**
66 Returns a geo object.
67 */
68 KABC::Geo geo() const;
69
70 signals:
71 void changed();
72
73 private slots:
74 void editGeoData();
75
76 private:
77 KDoubleSpinBox *mLatitudeBox;
78 KDoubleSpinBox *mLongitudeBox;
79
80 QCheckBox *mGeoIsValid;
81 QPushButton *mExtendedButton;
82};
83
84class GeoDialog : public KDialogBase
85{
86 Q_OBJECT
87
88 public:
89 GeoDialog( QWidget *parent, const char *name = 0 );
90 ~GeoDialog();
91
92 void setLatitude( double latitude );
93 double latitude() const;
94
95 void setLongitude( double longitude );
96 double longitude() const;
97
98 private slots:
99 void updateInputs();
100
101 void sexagesimalInputChanged();
102 void geoMapChanged();
103 void cityInputChanged();
104
105 private:
106 void loadCityList();
107 double calculateCoordinate( const QString& );
108 int nearestCity( double, double );
109
110 GeoMapWidget *mMapWidget;
111 KComboBox *mCityCombo;
112
113 QSpinBox *mLatDegrees;
114 QSpinBox *mLatMinutes;
115 QSpinBox *mLatSeconds;
116 KComboBox *mLatDirection;
117
118 QSpinBox *mLongDegrees;
119 QSpinBox *mLongMinutes;
120 QSpinBox *mLongSeconds;
121 KComboBox *mLongDirection;
122
123 double mLatitude;
124 double mLongitude;
125 QMap<QString, GeoData> mGeoDataMap;
126 bool mUpdateSexagesimalInput;
127};
128
129class GeoMapWidget : public QWidget
130{
131 Q_OBJECT
132
133 public:
134 GeoMapWidget( QWidget *parent, const char *name = 0 );
135 ~GeoMapWidget();
136
137 void setLatitude( double latitude );
138 double latitude()const;
139
140 void setLongitude( double longitude );
141 double longitude()const;
142
143 signals:
144 void changed();
145
146 protected:
147 virtual void mousePressEvent( QMouseEvent* );
148 virtual void paintEvent( QPaintEvent* );
149
150 private:
151 double mLatitude;
152 double mLongitude;
153};
154
155#endif