00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#ifndef GEOWIDGET_H
00025
#define GEOWIDGET_H
00026
00027
#include <kdialogbase.h>
00028
00029
#include "contacteditorwidget.h"
00030
00031
namespace KABC {
00032
class Geo;
00033 }
00034
00035
class GeoMapWidget;
00036
00037
class KComboBox;
00038
class KDoubleSpinBox;
00039
00040
class QCheckBox;
00041
class QLabel;
00042
class QSpinBox;
00043
class QPushButton;
00044
00045
typedef struct {
00046
double latitude;
00047
double longitude;
00048
QString country;
00049 } GeoData;
00050
00051
class GeoWidget :
public KAB::ContactEditorWidget
00052 {
00053 Q_OBJECT
00054
00055
public:
00056 GeoWidget( KABC::AddressBook *ab,
QWidget *parent,
const char *name = 0 );
00057 ~GeoWidget();
00058
00059
void loadContact( KABC::Addressee *addr );
00060
void storeContact( KABC::Addressee *addr );
00061
00062
void setReadOnly(
bool readOnly );
00063
00064
private slots:
00065
void editGeoData();
00066
00067
private:
00068 KDoubleSpinBox *mLatitudeBox;
00069 KDoubleSpinBox *mLongitudeBox;
00070
00071
QCheckBox *mGeoIsValid;
00072
QPushButton *mExtendedButton;
00073
00074
bool mReadOnly;
00075 };
00076
00077
class GeoDialog :
public KDialogBase
00078 {
00079 Q_OBJECT
00080
00081
public:
00082 GeoDialog(
QWidget *parent,
const char *name = 0 );
00083 ~GeoDialog();
00084
00085
void setLatitude(
double latitude );
00086
double latitude() const;
00087
00088
void setLongitude(
double longitude );
00089
double longitude() const;
00090
00091 private slots:
00092
void updateInputs();
00093
00094
void sexagesimalInputChanged();
00095
void geoMapChanged();
00096
void cityInputChanged();
00097
00098 private:
00099
void loadCityList();
00100
double calculateCoordinate( const
QString& );
00101
int nearestCity(
double,
double );
00102
00103 GeoMapWidget *mMapWidget;
00104 KComboBox *mCityCombo;
00105
00106
QSpinBox *mLatDegrees;
00107
QSpinBox *mLatMinutes;
00108
QSpinBox *mLatSeconds;
00109 KComboBox *mLatDirection;
00110
00111
QSpinBox *mLongDegrees;
00112
QSpinBox *mLongMinutes;
00113
QSpinBox *mLongSeconds;
00114 KComboBox *mLongDirection;
00115
00116
double mLatitude;
00117
double mLongitude;
00118
QMap<QString, GeoData> mGeoDataMap;
00119
bool mUpdateSexagesimalInput;
00120 };
00121
00122 class GeoMapWidget : public
QWidget
00123 {
00124 Q_OBJECT
00125
00126
public:
00127 GeoMapWidget( QWidget *parent,
const char *name = 0 );
00128 ~GeoMapWidget();
00129
00130
void setLatitude(
double latitude );
00131
double latitude()const;
00132
00133
void setLongitude(
double longitude );
00134
double longitude()const;
00135
00136 signals:
00137
void changed();
00138
00139 protected:
00140 virtual
void mousePressEvent(
QMouseEvent* );
00141 virtual
void paintEvent(
QPaintEvent* );
00142
00143 private:
00144
double mLatitude;
00145
double mLongitude;
00146 };
00147
00148 class GeoWidgetFactory : public KAB::ContactEditorWidgetFactory
00149 {
00150
public:
00151 KAB::ContactEditorWidget *createWidget( KABC::AddressBook *ab, QWidget *parent,
const char *name )
00152 {
00153
return new GeoWidget( ab, parent, name );
00154 }
00155
00156 QString pageIdentifier()
const {
return "misc"; }
00157 };
00158
00159
#endif