geoeditwidget.h

00001 /*
00002     This file is part of Akonadi Contact.
00003 
00004     Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or modify it
00007     under the terms of the GNU Library General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or (at your
00009     option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful, but WITHOUT
00012     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014     License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to the
00018     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019     02110-1301, USA.
00020 */
00021 
00022 #ifndef GEOEDITWIDGET_H
00023 #define GEOEDITWIDGET_H
00024 
00025 #include <kabc/geo.h>
00026 #include <kdialog.h>
00027 
00028 #include <QtGui/QWidget>
00029 
00030 namespace KABC
00031 {
00032 class Addressee;
00033 }
00034 
00035 class QDoubleSpinBox;
00036 class QLabel;
00037 class QPushButton;
00038 class QSpinBox;
00039 
00040 class KComboBox;
00041 
00042 class GeoMapWidget;
00043 
00044 class GeoEditWidget : public QWidget
00045 {
00046   Q_OBJECT
00047 
00048   public:
00049     GeoEditWidget( QWidget *parent = 0 );
00050     ~GeoEditWidget();
00051 
00052     void loadContact( const KABC::Addressee &contact );
00053     void storeContact( KABC::Addressee &contact ) const;
00054 
00055     void setReadOnly( bool readOnly );
00056 
00057   private Q_SLOTS:
00058     void changeClicked();
00059 
00060   private:
00061     void updateView();
00062 
00063     GeoMapWidget *mMap;
00064     QLabel *mLatitudeLabel;
00065     QLabel *mLongitudeLabel;
00066     QPushButton *mChangeButton;
00067     KABC::Geo mCoordinates;
00068     bool mReadOnly;
00069 };
00070 
00071 class GeoDialog : public KDialog
00072 {
00073   Q_OBJECT
00074 
00075   public:
00076     GeoDialog( const KABC::Geo &coordinates, QWidget *parent );
00077 
00078     KABC::Geo coordinates() const;
00079 
00080   private:
00081     enum ExceptType {
00082       ExceptNone,
00083       ExceptSexagesimal,
00084       ExceptDecimal
00085     };
00086 
00087   private Q_SLOTS:
00088     void updateInputs( ExceptType type = ExceptNone );
00089 
00090     void decimalInputChanged();
00091     void sexagesimalInputChanged();
00092     void cityInputChanged();
00093 
00094   private:
00095     void loadCityList();
00096     int nearestCity( double, double ) const;
00097 
00098     typedef struct {
00099       double latitude;
00100       double longitude;
00101       QString country;
00102     } GeoData;
00103 
00104     KComboBox *mCityCombo;
00105 
00106     QDoubleSpinBox *mLatitude;
00107     QDoubleSpinBox *mLongitude;
00108 
00109     QSpinBox *mLatDegrees;
00110     QSpinBox *mLatMinutes;
00111     QSpinBox *mLatSeconds;
00112     KComboBox *mLatDirection;
00113 
00114     QSpinBox *mLongDegrees;
00115     QSpinBox *mLongMinutes;
00116     QSpinBox *mLongSeconds;
00117     KComboBox *mLongDirection;
00118 
00119     KABC::Geo mCoordinates;
00120     QMap<QString, GeoData> mGeoDataMap;
00121     bool mUpdateSexagesimalInput;
00122 };
00123 
00124 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys