kaddressbook Library API Documentation

geowidget.h

00001 /* 00002 This file is part of KAddressBook. 00003 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of Qt, and distribute the resulting executable, 00021 without including the source code for Qt in the source distribution. 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
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:51:12 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003