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 <tdeabc/addressee.h>
00028 #include <kdialogbase.h>
00029 #include <tdelocale.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
00066 public:
00067 AddFieldDialog( TQWidget *parent, const char *name = 0 );
00068
00069 TQString title() const;
00070 TQString identifier() const;
00071 TQString type() const;
00072 bool isGlobal() const;
00073
00074 private slots:
00075 void nameChanged( const TQString& );
00076
00077 private:
00078 KLineEdit *mTitle;
00079 KComboBox *mType;
00080 TQCheckBox *mGlobal;
00081
00082 TQValueVector<TQString> mTypeList;
00083 TQValueVector<TQString> mTypeName;
00084 };
00085
00086 class FieldWidget : public TQWidget
00087 {
00088 Q_OBJECT
00089
00090
00091 public:
00092 FieldWidget( TQWidget *parent, const char *name = 0 );
00093
00094 void addField( const TQString &identifier, const TQString &title,
00095 const TQString &type, bool isGlobal );
00096
00097 void removeField( const TQString &identifier );
00098
00099 void loadContact( TDEABC::Addressee *addr );
00100 void storeContact( TDEABC::Addressee *addr );
00101 void setReadOnly( bool readOnly );
00102
00103 FieldRecordList fields() const { return mFieldList; }
00104
00105 void removeLocalFields();
00106 void clearFields();
00107
00108 signals:
00109 void changed();
00110
00111 private:
00112 void recalculateLayout();
00113
00114 TQVBoxLayout *mGlobalLayout;
00115 TQVBoxLayout *mLocalLayout;
00116 TQFrame *mSeparator;
00117
00118 FieldRecordList mFieldList;
00119 };
00120
00121 class CustomFieldsWidget : public KAB::ContactEditorWidget
00122 {
00123 Q_OBJECT
00124
00125
00126 public:
00127 CustomFieldsWidget( TDEABC::AddressBook *ab, TQWidget *parent, const char *name = 0 );
00128
00129 void loadContact( TDEABC::Addressee *addr );
00130 void storeContact( TDEABC::Addressee *addr );
00131 void setReadOnly( bool readOnly );
00132
00133 private slots:
00134 void addField();
00135 void removeField();
00136
00137 private:
00138 void initGUI();
00139
00140 TQStringList marshallFields( bool ) const;
00141
00142 TQPushButton *mAddButton;
00143 TQPushButton *mRemoveButton;
00144 TQGridLayout *mLayout;
00145
00146 FieldWidget *mFieldWidget;
00147
00148 TDEABC::Addressee mAddressee;
00149 };
00150
00151 class CustomFieldsWidgetFactory : public KAB::ContactEditorWidgetFactory
00152 {
00153 public:
00154 KAB::ContactEditorWidget *createWidget( TDEABC::AddressBook *ab, TQWidget *parent, const char *name )
00155 {
00156 return new CustomFieldsWidget( ab, parent, name );
00157 }
00158
00159 TQString pageTitle() const { return i18n( "Custom Fields" ); }
00160 TQString pageIdentifier() const { return "custom_fields"; }
00161 };
00162
00163 void splitField( const TQString&, TQString&, TQString&, TQString& );
00164
00165 #endif