akonadi
addresseditwidget.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 ADDRESSEDITWIDGET_H 00023 #define ADDRESSEDITWIDGET_H 00024 00025 #include <QtGui/QWidget> 00026 00027 #include <kabc/address.h> 00028 #include <kabc/addressee.h> 00029 #include <kcombobox.h> 00030 #include <kdialog.h> 00031 00032 class QCheckBox; 00033 class QLabel; 00034 00035 class KLineEdit; 00036 class KTextEdit; 00037 00041 class AddressSelectionWidget : public KComboBox 00042 { 00043 Q_OBJECT 00044 00045 public: 00051 AddressSelectionWidget( QWidget *parent = 0 ); 00052 00056 virtual ~AddressSelectionWidget(); 00057 00061 void setAddresses( const KABC::Address::List &addresses ); 00062 00066 void setCurrentAddress( const KABC::Address &address ); 00067 00071 KABC::Address currentAddress() const; 00072 00073 Q_SIGNALS: 00080 void selectionChanged( const KABC::Address &address ); 00081 00082 private Q_SLOTS: 00083 void selected( int ); 00084 00085 private: 00086 void updateView(); 00087 00088 KABC::Address::List mAddresses; 00089 }; 00090 00094 class AddressTypeCombo : public KComboBox 00095 { 00096 Q_OBJECT 00097 00098 public: 00104 AddressTypeCombo( QWidget *parent = 0 ); 00105 00109 ~AddressTypeCombo(); 00110 00114 void setType( KABC::Address::Type type ); 00115 00119 KABC::Address::Type type() const; 00120 00121 private Q_SLOTS: 00122 void selected( int ); 00123 void otherSelected(); 00124 00125 private: 00126 void update(); 00127 00128 KABC::Address::Type mType; 00129 int mLastSelected; 00130 QList<int> mTypeList; 00131 }; 00132 00136 class AddressEditWidget : public QWidget 00137 { 00138 Q_OBJECT 00139 00140 public: 00141 explicit AddressEditWidget( QWidget *parent = 0 ); 00142 ~AddressEditWidget(); 00143 00144 void loadContact( const KABC::Addressee &contact ); 00145 void storeContact( KABC::Addressee &contact ) const; 00146 00147 void setReadOnly( bool readOnly ); 00148 00149 public Q_SLOTS: 00150 void updateName( const QString &name ); 00151 00152 private Q_SLOTS: 00153 void updateAddressView(); 00154 void createAddress(); 00155 void editAddress(); 00156 void deleteAddress(); 00157 00158 private: 00159 void updateButtons(); 00160 void fixPreferredAddress( const KABC::Address &preferredAddress ); 00161 00162 AddressSelectionWidget *mAddressSelectionWidget; 00163 00164 QLabel *mAddressView; 00165 QPushButton *mCreateButton; 00166 QPushButton *mEditButton; 00167 QPushButton *mDeleteButton; 00168 00169 KABC::Address::List mAddressList; 00170 QString mName; 00171 bool mReadOnly; 00172 }; 00173 00177 class AddressEditDialog : public KDialog 00178 { 00179 Q_OBJECT 00180 00181 public: 00182 AddressEditDialog( QWidget *parent = 0 ); 00183 ~AddressEditDialog(); 00184 00185 void setAddress( const KABC::Address &address ); 00186 KABC::Address address() const; 00187 00188 private Q_SLOTS: 00189 void editLabel(); 00190 00191 private: 00192 void fillCountryCombo(); 00193 00194 AddressTypeCombo *mTypeCombo; 00195 KTextEdit *mStreetTextEdit; 00196 KComboBox *mCountryCombo; 00197 KLineEdit *mRegionEdit; 00198 KLineEdit *mLocalityEdit; 00199 KLineEdit *mPostalCodeEdit; 00200 KLineEdit *mPOBoxEdit; 00201 QCheckBox *mPreferredCheckBox; 00202 00203 KABC::Address mAddress; 00204 QString mLabel; 00205 }; 00206 00207 #endif