kaddressbook

phoneeditwidget.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 PHONEEDITWIDGET_H
00025 #define PHONEEDITWIDGET_H
00026 
00027 #include <kcombobox.h>
00028 #include <kdialogbase.h>
00029 
00030 #include "addresseeconfig.h"
00031 
00032 class QButtonGroup;
00033 class QCheckBox;
00034 class QSignalMapper;
00035 
00036 class KLineEdit;
00037 class KComboBox;
00038 
00039 class PhoneTypeCombo : public KComboBox
00040 {
00041   Q_OBJECT
00042 
00043   public:
00044     PhoneTypeCombo( QWidget *parent );
00045     ~PhoneTypeCombo();
00046 
00047     void setType( int type );
00048     int type() const;
00049 
00050   signals:
00051     void modified();
00052 
00053   protected slots:
00054     void selected( int );
00055     void otherSelected();
00056 
00057   private:
00058     void update();
00059 
00060     int mType;
00061     int mLastSelected;
00062     QValueList<int> mTypeList;
00063 };
00064 
00065 class PhoneNumberWidget : public QWidget
00066 {
00067   Q_OBJECT
00068 
00069   public:
00070     PhoneNumberWidget( QWidget *parent );
00071 
00072     void setNumber( const KABC::PhoneNumber &number );
00073     KABC::PhoneNumber number() const;
00074 
00075     void setReadOnly( bool readOnly );
00076 
00077   signals:
00078     void modified();
00079 
00080   private:
00081     PhoneTypeCombo *mTypeCombo;
00082     KLineEdit *mNumberEdit;
00083     KABC::PhoneNumber mNumber;
00084 };
00085 
00089 class PhoneEditWidget : public QWidget
00090 {
00091   Q_OBJECT
00092 
00093   public:
00094     PhoneEditWidget( QWidget *parent, const char *name = 0 );
00095     ~PhoneEditWidget();
00096 
00097     void setPhoneNumbers( const KABC::PhoneNumber::List &list );
00098     KABC::PhoneNumber::List phoneNumbers() const;
00099 
00100     void setReadOnly( bool readOnly );
00101 
00102   signals:
00103     void modified();
00104 
00105   protected slots:
00106     void add();
00107     void remove();
00108     void changed();
00109     void changed( int pos );
00110 
00111   private:
00112     void updateWidgets();
00113     void updateButtons();
00114 
00115     KABC::PhoneNumber::List mPhoneNumberList;
00116     QPtrList<PhoneNumberWidget> mWidgets;
00117 
00118     QPushButton *mAddButton;
00119     QPushButton *mRemoveButton;
00120     QVBoxLayout *mWidgetLayout;
00121 
00122     bool mReadOnly;
00123     QSignalMapper *mMapper;
00124 };
00125 
00129 class PhoneTypeDialog : public KDialogBase
00130 {
00131   Q_OBJECT
00132   public:
00133     PhoneTypeDialog( int type, QWidget *parent );
00134 
00135     int type() const;
00136 
00137   private:
00138     int mType;
00139     KABC::PhoneNumber::TypeList mTypeList;
00140 
00141     QButtonGroup *mGroup;
00142     QCheckBox *mPreferredBox;
00143 };
00144 
00145 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys