kaddressbook
customfieldswidget.h00001
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 <tqmap.h>
00032 #include <tqpair.h>
00033 #include <tqstringlist.h>
00034 #include <tqvaluevector.h>
00035 #include <tqwidget.h>
00036
00037 #include "contacteditorwidget.h"
00038
00039 class TQCheckBox;
00040 class TQGridLayout;
00041 class TQLabel;
00042 class TQPushButton;
00043 class TQVBoxLayout;
00044 class TQWidget;
00045
00046 class KComboBox;
00047 class KLineEdit;
00048
00049 typedef struct {
00050 TQString mIdentifier;
00051 TQString mTitle;
00052 bool mGlobal;
00053
00054 TQLabel *mLabel;
00055 TQWidget *mWidget;
00056 TQHBoxLayout *mLayout;
00057 } FieldRecord;
00058
00059 typedef TQValueList<FieldRecord> FieldRecordList;
00060
00061 class AddFieldDialog : public KDialogBase
00062 {
00063 Q_OBJECT
00064
00065 public:
00066 AddFieldDialog( TQWidget *parent, const char *name = 0 );
00067
00068 TQString title() const;
00069 TQString identifier() const;
00070 TQString type() const;
00071 bool isGlobal() const;
00072
00073 private slots:
00074 void nameChanged( const TQString& );
00075
00076 private:
00077 KLineEdit *mTitle;
00078 KComboBox *mType;
00079 TQCheckBox *mGlobal;
00080
00081 TQValueVector<TQString> mTypeList;
00082 TQValueVector<TQString> mTypeName;
00083 };
00084
00085 class FieldWidget : public QWidget
00086 {
00087 Q_OBJECT
00088
00089 public:
00090 FieldWidget( TQWidget *parent, const char *name = 0 );
00091
00092 void addField( const TQString &identifier, const TQString &title,
00093 const TQString &type, bool isGlobal );
00094
00095 void removeField( const TQString &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 void clearFields();
00105
00106 signals:
00107 void changed();
00108
00109 private:
00110 void recalculateLayout();
00111
00112 TQVBoxLayout *mGlobalLayout;
00113 TQVBoxLayout *mLocalLayout;
00114 TQFrame *mSeparator;
00115
00116 FieldRecordList mFieldList;
00117 };
00118
00119 class CustomFieldsWidget : public KAB::ContactEditorWidget
00120 {
00121 Q_OBJECT
00122
00123 public:
00124 CustomFieldsWidget( KABC::AddressBook *ab, TQWidget *parent, const char *name = 0 );
00125
00126 void loadContact( KABC::Addressee *addr );
00127 void storeContact( KABC::Addressee *addr );
00128 void setReadOnly( bool readOnly );
00129
00130 private slots:
00131 void addField();
00132 void removeField();
00133
00134 private:
00135 void initGUI();
00136
00137 TQStringList marshallFields( bool ) const;
00138
00139 TQPushButton *mAddButton;
00140 TQPushButton *mRemoveButton;
00141 TQGridLayout *mLayout;
00142
00143 FieldWidget *mFieldWidget;
00144
00145 KABC::Addressee mAddressee;
00146 };
00147
00148 class CustomFieldsWidgetFactory : public KAB::ContactEditorWidgetFactory
00149 {
00150 public:
00151 KAB::ContactEditorWidget *createWidget( KABC::AddressBook *ab, TQWidget *parent, const char *name )
00152 {
00153 return new CustomFieldsWidget( ab, parent, name );
00154 }
00155
00156 TQString pageTitle() const { return i18n( "Custom Fields" ); }
00157 TQString pageIdentifier() const { return "custom_fields"; }
00158 };
00159
00160 void splitField( const TQString&, TQString&, TQString&, TQString& );
00161
00162 #endif
|