kaddressbook

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 Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
00022 */
00023 
00024 #ifndef ADDRESSEDITWIDGET_H
00025 #define ADDRESSEDITWIDGET_H
00026 
00027 #include <qwidget.h>
00028 
00029 #include <kdialogbase.h>
00030 #include <kabc/address.h>
00031 #include <kabc/addressee.h>
00032 
00033 #include "addresseeconfig.h"
00034 #include "typecombo.h"
00035 
00036 class QButtonGroup;
00037 class QCheckBox;
00038 class QListView;
00039 class QTextEdit;
00040 class QToolButton;
00041 
00042 class KActiveLabel;
00043 class KComboBox;
00044 class KLineEdit;
00045 class KListView;
00046 
00047 typedef TypeCombo<KABC::Address> AddressTypeCombo;
00048 
00052 class AddressEditWidget : public QWidget
00053 {
00054   Q_OBJECT
00055 
00056   public:
00057     AddressEditWidget( QWidget *parent, const char *name = 0 );
00058     ~AddressEditWidget();
00059 
00060     KABC::Address::List addresses();
00061     void setAddresses( const KABC::Addressee &addr,
00062                        const KABC::Address::List &list );
00063     void updateAddressee( const KABC::Addressee &addr );
00064 
00065     void updateTypeCombo( const KABC::Address::List&, KComboBox* );
00066     KABC::Address currentAddress( KComboBox*, int );
00067 
00068     void setReadOnly( bool readOnly );
00069 
00070   signals:
00071     void modified();
00072 
00073   protected slots:
00074     void updateAddressEdit();
00075 
00076     void edit();
00077 
00078   private:
00079     AddressTypeCombo *mTypeCombo;
00080 
00081     QPushButton *mEditButton;
00082     KActiveLabel *mAddressField;
00083 
00084     KABC::Address::List mAddressList;
00085     KABC::Addressee mAddressee;
00086     int mIndex;
00087 };
00088 
00092 class AddressEditDialog : public KDialogBase
00093 {
00094   Q_OBJECT
00095 
00096   public:
00097     AddressEditDialog( const KABC::Address::List &list, int selected,
00098                        QWidget *parent, const char *name = 0 );
00099     ~AddressEditDialog();
00100 
00101     KABC::Address::List addresses();
00102     bool changed() const;
00103 
00104   protected slots:
00105     void addAddress();
00106     void removeAddress();
00107     void changeType();
00108     void editLabel();
00109 
00110     void updateAddressEdits();
00111     void modified();
00112 
00113   private:
00114     void saveAddress( KABC::Address &addr );
00115     void fillCountryCombo();
00116     QStringList sortLocaleAware( const QStringList& );
00117 
00118     AddressTypeCombo *mTypeCombo;
00119     QTextEdit *mStreetTextEdit;
00120     KComboBox *mCountryCombo;
00121     KLineEdit *mRegionEdit;
00122     KLineEdit *mLocalityEdit;
00123     KLineEdit *mPostalCodeEdit;
00124     KLineEdit *mPOBoxEdit;
00125     QCheckBox *mPreferredCheckBox;
00126 
00127     QPushButton *mRemoveButton;
00128     QPushButton *mChangeTypeButton;
00129 
00130     KABC::Address::List mAddressList;
00131     KABC::Address *mPreviousAddress;
00132     bool mChanged;
00133 
00134     QString mLabel;
00135 };
00136 
00140 class AddressTypeDialog : public KDialogBase
00141 {
00142   public:
00143     AddressTypeDialog( int type, QWidget *parent );
00144     ~AddressTypeDialog();
00145 
00146     int type() const;
00147 
00148   private:
00149     QButtonGroup *mGroup;
00150 
00151     KABC::Address::TypeList mTypeList;
00152 };
00153 
00154 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys