kaddressbook
geowidget.h00001
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 TQCheckBox;
00041 class TQLabel;
00042 class TQSpinBox;
00043 class TQPushButton;
00044
00045 typedef struct {
00046 double latitude;
00047 double longitude;
00048 TQString country;
00049 } GeoData;
00050
00051 class GeoWidget : public KAB::ContactEditorWidget
00052 {
00053 Q_OBJECT
00054 TQ_OBJECT
00055
00056 public:
00057 GeoWidget( KABC::AddressBook *ab, TQWidget *parent, const char *name = 0 );
00058 ~GeoWidget();
00059
00060 void loadContact( KABC::Addressee *addr );
00061 void storeContact( KABC::Addressee *addr );
00062
00063 void setReadOnly( bool readOnly );
00064
00065 private slots:
00066 void editGeoData();
00067
00068 private:
00069 KDoubleSpinBox *mLatitudeBox;
00070 KDoubleSpinBox *mLongitudeBox;
00071
00072 TQCheckBox *mGeoIsValid;
00073 TQPushButton *mExtendedButton;
00074
00075 bool mReadOnly;
00076 };
00077
00078 class GeoDialog : public KDialogBase
00079 {
00080 Q_OBJECT
00081 TQ_OBJECT
00082
00083 public:
00084 GeoDialog( TQWidget *parent, const char *name = 0 );
00085 ~GeoDialog();
00086
00087 void setLatitude( double latitude );
00088 double latitude() const;
00089
00090 void setLongitude( double longitude );
00091 double longitude() const;
00092
00093 private slots:
00094 void updateInputs();
00095
00096 void sexagesimalInputChanged();
00097 void geoMapChanged();
00098 void cityInputChanged();
00099
00100 private:
00101 void loadCityList();
00102 double calculateCoordinate( const TQString& ) const;
00103 int nearestCity( double, double ) const;
00104
00105 GeoMapWidget *mMapWidget;
00106 KComboBox *mCityCombo;
00107
00108 TQSpinBox *mLatDegrees;
00109 TQSpinBox *mLatMinutes;
00110 TQSpinBox *mLatSeconds;
00111 KComboBox *mLatDirection;
00112
00113 TQSpinBox *mLongDegrees;
00114 TQSpinBox *mLongMinutes;
00115 TQSpinBox *mLongSeconds;
00116 KComboBox *mLongDirection;
00117
00118 double mLatitude;
00119 double mLongitude;
00120 TQMap<TQString, GeoData> mGeoDataMap;
00121 bool mUpdateSexagesimalInput;
00122 };
00123
00124 class GeoMapWidget : public TQWidget
00125 {
00126 Q_OBJECT
00127 TQ_OBJECT
00128
00129 public:
00130 GeoMapWidget( TQWidget *parent, const char *name = 0 );
00131 ~GeoMapWidget();
00132
00133 void setLatitude( double latitude );
00134 double latitude()const;
00135
00136 void setLongitude( double longitude );
00137 double longitude()const;
00138
00139 signals:
00140 void changed();
00141
00142 protected:
00143 virtual void mousePressEvent( TQMouseEvent* );
00144 virtual void paintEvent( TQPaintEvent* );
00145
00146 private:
00147 double mLatitude;
00148 double mLongitude;
00149 };
00150
00151 class GeoWidgetFactory : public KAB::ContactEditorWidgetFactory
00152 {
00153 public:
00154 KAB::ContactEditorWidget *createWidget( KABC::AddressBook *ab, TQWidget *parent, const char *name )
00155 {
00156 return new GeoWidget( ab, parent, name );
00157 }
00158
00159 TQString pageIdentifier() const { return "misc"; }
00160 };
00161
00162 #endif
|