customfieldswidget.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef CUSTOMFIELDSWIDGET_H
00025 #define CUSTOMFIELDSWIDGET_H
00026
00027 #include <kabc/addressee.h>
00028 #include <kdialogbase.h>
00029 #include <klocale.h>
00030
00031 #include <qmap.h>
00032 #include <qpair.h>
00033 #include <qstringlist.h>
00034 #include <qvaluevector.h>
00035 #include <qwidget.h>
00036
00037 #include "contacteditorwidget.h"
00038
00039 class QCheckBox;
00040 class QGridLayout;
00041 class QLabel;
00042 class QPushButton;
00043 class QVBoxLayout;
00044 class QWidget;
00045
00046 class KComboBox;
00047 class KLineEdit;
00048
00049 typedef struct {
00050 QString mIdentifier;
00051 QString mTitle;
00052 bool mGlobal;
00053
00054 QLabel *mLabel;
00055 QWidget *mWidget;
00056 QHBoxLayout *mLayout;
00057 } FieldRecord;
00058
00059 typedef QValueList<FieldRecord> FieldRecordList;
00060
00061 class AddFieldDialog : public KDialogBase
00062 {
00063 Q_OBJECT
00064
00065 public:
00066 AddFieldDialog( QWidget *parent, const char *name = 0 );
00067
00068 QString title() const;
00069 QString identifier() const;
00070 QString type() const;
00071 bool isGlobal() const;
00072
00073 private slots:
00074 void nameChanged( const QString& );
00075
00076 private:
00077 KLineEdit *mTitle;
00078 KComboBox *mType;
00079 QCheckBox *mGlobal;
00080
00081 QValueVector<QString> mTypeList;
00082 QValueVector<QString> mTypeName;
00083 };
00084
00085 class FieldWidget : public QWidget
00086 {
00087 Q_OBJECT
00088
00089 public:
00090 FieldWidget( QWidget *parent, const char *name = 0 );
00091
00092 void addField( const QString &identifier, const QString &title,
00093 const QString &type, bool isGlobal );
00094
00095 void removeField( const QString &identifier );
00096
00097 void loadContact( KABC::Addressee *addr );
00098 void storeContact( KABC::Addressee *addr );
00099 void setReadOnly( bool readOnly );
00100
00101 FieldRecordList fields() const { return mFieldList; }
00102
00103 void removeLocalFields();
00104
00105 signals:
00106 void changed();
00107
00108 private:
00109 void recalculateLayout();
00110
00111 QVBoxLayout *mGlobalLayout;
00112 QVBoxLayout *mLocalLayout;
00113 QFrame *mSeparator;
00114
00115 FieldRecordList mFieldList;
00116 };
00117
00118 class CustomFieldsWidget : public KAB::ContactEditorWidget
00119 {
00120 Q_OBJECT
00121
00122 public:
00123 CustomFieldsWidget( KABC::AddressBook *ab, QWidget *parent, const char *name = 0 );
00124
00125 void loadContact( KABC::Addressee *addr );
00126 void storeContact( KABC::Addressee *addr );
00127 void setReadOnly( bool readOnly );
00128
00129 private slots:
00130 void addField();
00131 void removeField();
00132
00133 private:
00134 void initGUI();
00135
00136 QStringList marshallFields( bool ) const;
00137
00138 QPushButton *mAddButton;
00139 QPushButton *mRemoveButton;
00140 QGridLayout *mLayout;
00141
00142 FieldWidget *mFieldWidget;
00143
00144 KABC::Addressee mAddressee;
00145 };
00146
00147 class CustomFieldsWidgetFactory : public KAB::ContactEditorWidgetFactory
00148 {
00149 public:
00150 KAB::ContactEditorWidget *createWidget( KABC::AddressBook *ab, QWidget *parent, const char *name )
00151 {
00152 return new CustomFieldsWidget( ab, parent, name );
00153 }
00154
00155 QString pageTitle() const { return i18n( "Custom Fields" ); }
00156 QString pageIdentifier() const { return "custom_fields"; }
00157 };
00158
00159 void splitField( const QString&, QString&, QString&, QString& );
00160
00161 #endif
This file is part of the documentation for kaddressbook Library Version 3.3.2.