addresseditwidget.h
00001 /* 00002 This file is part of KAddressBook. 00003 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of TQt, and distribute the resulting executable, 00021 without including the source code for TQt in the source distribution. 00022 */ 00023 00024 #ifndef ADDRESSEDITWIDGET_H 00025 #define ADDRESSEDITWIDGET_H 00026 00027 #include <tqwidget.h> 00028 00029 #include <kdialogbase.h> 00030 #include <tdeabc/address.h> 00031 #include <tdeabc/addressee.h> 00032 00033 #include "addresseeconfig.h" 00034 #include "typecombo.h" 00035 00036 class TQButtonGroup; 00037 class TQCheckBox; 00038 class TQListView; 00039 class TQTextEdit; 00040 class TQToolButton; 00041 00042 class KActiveLabel; 00043 class KComboBox; 00044 class KLineEdit; 00045 class TDEListView; 00046 00047 typedef TypeCombo<TDEABC::Address> AddressTypeCombo; 00048 00052 class AddressEditWidget : public TQWidget 00053 { 00054 Q_OBJECT 00055 00056 00057 public: 00058 AddressEditWidget( TQWidget *parent, const char *name = 0 ); 00059 ~AddressEditWidget(); 00060 00061 TDEABC::Address::List addresses(); 00062 void setAddresses( const TDEABC::Addressee &addr, 00063 const TDEABC::Address::List &list ); 00064 void updateAddressee( const TDEABC::Addressee &addr ); 00065 00066 void updateTypeCombo( const TDEABC::Address::List&, KComboBox* ); 00067 TDEABC::Address currentAddress( KComboBox*, int ); 00068 00069 void setReadOnly( bool readOnly ); 00070 00071 signals: 00072 void modified(); 00073 00074 protected slots: 00075 void updateAddressEdit(); 00076 00077 void edit(); 00078 00079 private: 00080 AddressTypeCombo *mTypeCombo; 00081 00082 TQPushButton *mEditButton; 00083 KActiveLabel *mAddressField; 00084 00085 TDEABC::Address::List mAddressList; 00086 TDEABC::Addressee mAddressee; 00087 int mIndex; 00088 }; 00089 00093 class AddressEditDialog : public KDialogBase 00094 { 00095 Q_OBJECT 00096 00097 00098 public: 00099 AddressEditDialog( const TDEABC::Address::List &list, int selected, 00100 TQWidget *parent, const char *name = 0 ); 00101 ~AddressEditDialog(); 00102 00103 TDEABC::Address::List addresses(); 00104 bool changed() const; 00105 00106 protected slots: 00107 void addAddress(); 00108 void removeAddress(); 00109 void changeType(); 00110 void editLabel(); 00111 00112 void updateAddressEdits(); 00113 void modified(); 00114 00115 private: 00116 void saveAddress( TDEABC::Address &addr ); 00117 void fillCountryCombo(); 00118 TQStringList sortLocaleAware( const TQStringList& ); 00119 00120 AddressTypeCombo *mTypeCombo; 00121 TQTextEdit *mStreetTextEdit; 00122 KComboBox *mCountryCombo; 00123 KLineEdit *mRegionEdit; 00124 KLineEdit *mLocalityEdit; 00125 KLineEdit *mPostalCodeEdit; 00126 KLineEdit *mPOBoxEdit; 00127 TQCheckBox *mPreferredCheckBox; 00128 00129 TQPushButton *mRemoveButton; 00130 TQPushButton *mChangeTypeButton; 00131 00132 TDEABC::Address::List mAddressList; 00133 TDEABC::Address *mPreviousAddress; 00134 bool mChanged; 00135 00136 TQString mLabel; 00137 }; 00138 00142 class AddressTypeDialog : public KDialogBase 00143 { 00144 public: 00145 AddressTypeDialog( int type, TQWidget *parent ); 00146 ~AddressTypeDialog(); 00147 00148 int type() const; 00149 00150 private: 00151 TQButtonGroup *mGroup; 00152 00153 TDEABC::Address::TypeList mTypeList; 00154 }; 00155 00156 #endif