26 #include <tqcheckbox.h>
27 #include <tqcombobox.h>
28 #include <tqdatetimeedit.h>
30 #include <tqobjectlist.h>
31 #include <tqspinbox.h>
33 #include <tqtextedit.h>
34 #include <tqwidgetfactory.h>
36 #include <kdatepicker.h>
37 #include <kdatetimewidget.h>
39 #include <klineedit.h>
40 #include <kstandarddirs.h>
42 #include <libtdepim/designerfields.h>
44 #include "customfieldswidget.h"
46 #include "advancedcustomfields.h"
48 class KABCStorage :
public KPIM::DesignerFields::Storage
51 KABCStorage( TDEABC::Addressee *a,
const TQString &ns )
52 : mAddressee( a ), mNs( ns )
60 const TQStringList customs = mAddressee->customs();
61 TQStringList::ConstIterator it;
62 for ( it = customs.begin(); it != customs.end(); ++it ) {
63 TQString app, name, value;
64 splitField( *it, app, name, value );
65 if ( app == mNs ) keys.append( name );
71 TQString read(
const TQString &key )
73 return mAddressee->custom( mNs, key );
76 void write(
const TQString &key,
const TQString &value )
78 mAddressee->insertCustom( mNs, key, value );
82 TDEABC::Addressee *mAddressee;
87 AdvancedCustomFields::AdvancedCustomFields(
const TQString &uiFile, TDEABC::AddressBook *ab,
88 TQWidget *parent,
const char *name )
89 : KAB::ContactEditorWidget( ab, parent, name )
94 void AdvancedCustomFields::loadContact( TDEABC::Addressee *addr )
97 if ( mFields->identifier().upper() ==
"KADDRESSBOOK" ||
98 TQRegExp(
"^Form\\d\\d?$" ).search( mFields->identifier() ) >= 0 ) {
101 ns = mFields->identifier();
104 KABCStorage storage( addr, ns );
105 mFields->load( &storage );
108 void AdvancedCustomFields::storeContact( TDEABC::Addressee *addr )
111 if ( mFields->identifier().upper() ==
"KADDRESSBOOK" ||
112 TQRegExp(
"^Form\\d\\d?$" ).search( mFields->identifier() ) >= 0 ) {
115 ns = mFields->identifier();
118 KABCStorage storage( addr, ns );
119 mFields->save( &storage );
122 void AdvancedCustomFields::setReadOnly(
bool readOnly )
124 mFields->setReadOnly( readOnly );
127 void AdvancedCustomFields::initGUI(
const TQString &uiFile )
129 TQVBoxLayout *layout =
new TQVBoxLayout(
this, KDialog::marginHint(),
130 KDialog::spacingHint() );
132 mFields =
new KPIM::DesignerFields( uiFile,
this );
133 layout->addWidget( mFields );
135 connect( mFields, TQ_SIGNAL( modified() ), TQ_SLOT( setModified() ) );
138 TQString AdvancedCustomFields::pageIdentifier()
const
140 return mFields->identifier();
143 TQString AdvancedCustomFields::pageTitle()
const
145 return mFields->title();
148 #include "advancedcustomfields.moc"