kaddressbook

geowidget.h
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of TQt, and distribute the resulting executable,
21 without including the source code for TQt in the source distribution.
22*/
23
24#ifndef GEOWIDGET_H
25#define GEOWIDGET_H
26
27#include <kdialogbase.h>
28
29#include "contacteditorwidget.h"
30
31namespace TDEABC {
32class Geo;
33}
34
35class GeoMapWidget;
36
37class KComboBox;
38class KDoubleSpinBox;
39
40class TQCheckBox;
41class TQLabel;
42class TQSpinBox;
43class TQPushButton;
44
45typedef struct {
46 double latitude;
47 double longitude;
48 TQString country;
49} GeoData;
50
51class GeoWidget : public KAB::ContactEditorWidget
52{
53 TQ_OBJECT
54
55
56 public:
57 GeoWidget( TDEABC::AddressBook *ab, TQWidget *parent, const char *name = 0 );
58 ~GeoWidget();
59
60 void loadContact( TDEABC::Addressee *addr );
61 void storeContact( TDEABC::Addressee *addr );
62
63 void setReadOnly( bool readOnly );
64
65 private slots:
66 void editGeoData();
67
68 private:
69 KDoubleSpinBox *mLatitudeBox;
70 KDoubleSpinBox *mLongitudeBox;
71
72 TQCheckBox *mGeoIsValid;
73 TQPushButton *mExtendedButton;
74
75 bool mReadOnly;
76};
77
78class GeoDialog : public KDialogBase
79{
80 TQ_OBJECT
81
82
83 public:
84 GeoDialog( TQWidget *parent, const char *name = 0 );
85 ~GeoDialog();
86
87 void setLatitude( double latitude );
88 double latitude() const;
89
90 void setLongitude( double longitude );
91 double longitude() const;
92
93 private slots:
94 void updateInputs();
95
96 void sexagesimalInputChanged();
97 void geoMapChanged();
98 void cityInputChanged();
99
100 private:
101 void loadCityList();
102 double calculateCoordinate( const TQString& ) const;
103 int nearestCity( double, double ) const;
104
105 GeoMapWidget *mMapWidget;
106 KComboBox *mCityCombo;
107
108 TQSpinBox *mLatDegrees;
109 TQSpinBox *mLatMinutes;
110 TQSpinBox *mLatSeconds;
111 KComboBox *mLatDirection;
112
113 TQSpinBox *mLongDegrees;
114 TQSpinBox *mLongMinutes;
115 TQSpinBox *mLongSeconds;
116 KComboBox *mLongDirection;
117
118 double mLatitude;
119 double mLongitude;
120 TQMap<TQString, GeoData> mGeoDataMap;
121 bool mUpdateSexagesimalInput;
122};
123
124class GeoMapWidget : public TQWidget
125{
126 TQ_OBJECT
127
128
129 public:
130 GeoMapWidget( TQWidget *parent, const char *name = 0 );
131 ~GeoMapWidget();
132
133 void setLatitude( double latitude );
134 double latitude()const;
135
136 void setLongitude( double longitude );
137 double longitude()const;
138
139 signals:
140 void changed();
141
142 protected:
143 virtual void mousePressEvent( TQMouseEvent* );
144 virtual void paintEvent( TQPaintEvent* );
145
146 private:
147 double mLatitude;
148 double mLongitude;
149};
150
151class GeoWidgetFactory : public KAB::ContactEditorWidgetFactory
152{
153 public:
154 KAB::ContactEditorWidget *createWidget( TDEABC::AddressBook *ab, TQWidget *parent, const char *name )
155 {
156 return new GeoWidget( ab, parent, name );
157 }
158
159 TQString pageIdentifier() const { return "misc"; }
160};
161
162#endif