summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-11 09:11:35 (UTC)
committer zautrix <zautrix>2004-10-11 09:11:35 (UTC)
commit5ec2ee22f69f6b3d78b505a4a44b6b0deff29645 (patch) (side-by-side diff)
treee5c7b6f21b9541a870f296d69a4ab7f82db82b13
parentea40295e233db219dc2431960e18fb4398ddb75c (diff)
downloadkdepimpi-5ec2ee22f69f6b3d78b505a4a44b6b0deff29645.zip
kdepimpi-5ec2ee22f69f6b3d78b505a4a44b6b0deff29645.tar.gz
kdepimpi-5ec2ee22f69f6b3d78b505a4a44b6b0deff29645.tar.bz2
added support for gender/children
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp214
-rw-r--r--kaddressbook/addresseeeditorwidget.h2
2 files changed, 130 insertions, 86 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
index 826c69b..dbbf7fe 100644
--- a/kaddressbook/addresseeeditorwidget.cpp
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -507,283 +507,310 @@ qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
// Categories
button = new QPushButton( i18n( "Categories" ), categoryBox );
connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) );
mCategoryEdit = new KLineEdit( categoryBox );
mCategoryEdit->setReadOnly( true );
connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
mSecrecyWidget = new SecrecyWidget( categoryBox );
connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 );
*/
// Build the layout and add to the tab widget
layout->activate(); // required
mTabWidget->addTab( tab1_1, i18n( "&Address" ) );
}
void AddresseeEditorWidget::setupTab2()
{
// This is the Details tab
QWidget *tab2 = new QWidget( mTabWidget );
QGridLayout *layout = new QGridLayout( tab2, 8, 3 );
layout->setMargin( KDialogBase::marginHintSmall() );
layout->setSpacing( KDialogBase::spacingHintSmall() );
QLabel *label;
KSeparator* bar;
///////////////////////
// Office info
// Department
label = new QLabel( tab2 );
//US loadIcon call is ambiguous. Add one more parameter
//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) );
label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) );
layout->addMultiCellWidget( label, 0, 1, 0, 0 );
label = new QLabel( i18n( "Department:" ), tab2 );
layout->addWidget( label, 0, 1 );
mDepartmentEdit = new KLineEdit( tab2 );
connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mDepartmentEdit );
layout->addWidget( mDepartmentEdit, 0, 2 );
label = new QLabel( i18n( "Office:" ), tab2 );
layout->addWidget( label, 1, 1 );
mOfficeEdit = new KLineEdit( tab2 );
connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mOfficeEdit );
layout->addWidget( mOfficeEdit, 1, 2 );
label = new QLabel( i18n( "Profession:" ), tab2 );
layout->addWidget( label, 2, 1 );
mProfessionEdit = new KLineEdit( tab2 );
connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mProfessionEdit );
layout->addWidget( mProfessionEdit, 2, 2 );
label = new QLabel( i18n( "Manager\'s name:" ), tab2 );
//US layout->addWidget( label, 0, 3 );
layout->addWidget( label, 3, 1 );
mManagerEdit = new KLineEdit( tab2 );
connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mManagerEdit );
//US layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 );
layout->addWidget( mManagerEdit, 3, 2 );
label = new QLabel( i18n( "Assistant's name:" ), tab2 );
//US layout->addWidget( label, 1, 3 );
layout->addWidget( label, 4, 1 );
mAssistantEdit = new KLineEdit( tab2 );
connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mAssistantEdit );
//US layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 );
layout->addWidget( mAssistantEdit, 4, 2 );
bar = new KSeparator( KSeparator::HLine, tab2 );
//US layout->addMultiCellWidget( bar, 3, 3, 0, 5 );
layout->addMultiCellWidget( bar, 5, 5, 0, 2 );
/////////////////////////////////////////////////
// Personal info
- label = new QLabel( tab2 );
+ //label = new QLabel( tab2 );
//US loadIcon call is ambiguous. Add one more parameter
//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
- label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
+ //label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
//US layout->addMultiCellWidget( label, 4, 5, 0, 0 );
- layout->addMultiCellWidget( label, 6, 7, 0, 0 );
-
- label = new QLabel( i18n( "Nick name:" ), tab2 );
-//US layout->addWidget( label, 4, 1 );
- layout->addWidget( label, 6, 1 );
- mNicknameEdit = new KLineEdit( tab2 );
- connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
- SLOT( textChanged( const QString& ) ) );
- label->setBuddy( mNicknameEdit );
-//US layout->addWidget( mNicknameEdit, 4, 2 );
- layout->addWidget( mNicknameEdit, 6, 2 );
-
- label = new QLabel( i18n( "Spouse's name:" ), tab2 );
-//US layout->addWidget( label, 5, 1 );
- layout->addWidget( label, 7, 1 );
- mSpouseEdit = new KLineEdit( tab2 );
- connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
- SLOT( textChanged( const QString& ) ) );
- label->setBuddy( mSpouseEdit );
-//US layout->addWidget( mSpouseEdit, 5, 2 );
- layout->addWidget( mSpouseEdit, 7, 2 );
-
- label = new QLabel( i18n( "Birthday:" ), tab2 );
-//US layout->addWidget( label, 4, 3 );
- layout->addWidget( label, 8, 1 );
- mBirthdayPicker = new KDateEdit( tab2 );
- mBirthdayPicker->toggleDateFormat();
- mBirthdayPicker->setHandleInvalid( true );
- connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ),
- SLOT( dateChanged( QDate ) ) );
-
+ //layout->addMultiCellWidget( label, 6, 7, 0, 0 );
+
+
+ int iii = 6;
+
+ if ( QApplication::desktop()->width() == 640 ) {
+ QHBox * nbox = new QHBox ( tab2 );
+ label = new QLabel( i18n( "Nick name:" )+" ", nbox );
+ layout->addWidget( label, iii, 1 );
+ mNicknameEdit = new KLineEdit( nbox );
+ connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mNicknameEdit );
+
+ label = new QLabel( " "+i18n( "Spouse's name:" )+" ", nbox );
+ layout->addWidget( label, iii, 1 );
+ mSpouseEdit = new KLineEdit( nbox );
+ connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mSpouseEdit );
+ layout->addWidget( mSpouseEdit, iii, 2 );
+ layout->addMultiCellWidget( nbox, iii, iii, 1, 2 );
+ ++iii;
+
+ } else {
+ label = new QLabel( i18n( "Nick name:" ), tab2 );
+ layout->addWidget( label, iii, 1 );
+ mNicknameEdit = new KLineEdit( tab2 );
+ connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mNicknameEdit );
+ layout->addWidget( mNicknameEdit, iii, 2 );
+ ++iii;
+
+ label = new QLabel( i18n( "Spouse's name:" ), tab2 );
+ layout->addWidget( label, iii, 1 );
+ mSpouseEdit = new KLineEdit( tab2 );
+ connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mSpouseEdit );
+ layout->addWidget( mSpouseEdit, iii, 2 );
+ ++iii;
+ }
-#ifndef KAB_EMBEDDED
- //US invalid dates are handdled by the KDateEdit widget itself
- connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ),
- SLOT( invalidDate() ) );
- connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ),
- SLOT( emitModified() ) );
-#endif //KAB_EMBEDDED
+ label = new QLabel( i18n( "Children's names:" ), tab2 );
+ layout->addWidget( label, iii, 1 );
+ mChildEdit = new KLineEdit( tab2 );
+ connect( mChildEdit, SIGNAL( textChanged( const QString& ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mChildEdit );
+ layout->addWidget( mChildEdit, iii, 2 );
+ ++iii;
+ if ( QApplication::desktop()->width() == 640 ) {
+ QHBox * nbox = new QHBox ( tab2 );
+ label = new QLabel( i18n( "Birthday:" )+" ", nbox );
+ layout->addWidget( label, iii, 1 );
+ mBirthdayPicker = new KDateEdit( nbox );
+ mBirthdayPicker->toggleDateFormat();
+ mBirthdayPicker->setHandleInvalid( true );
+ connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ),
+ SLOT( dateChanged( QDate ) ) );
- label->setBuddy( mBirthdayPicker );
-//US layout->addWidget( mBirthdayPicker, 4, 4 );
- layout->addWidget( mBirthdayPicker, 8, 2 );
-
- label = new QLabel( i18n( "Anniversary:" ), tab2 );
-//US layout->addWidget( label, 5, 3 );
- layout->addWidget( label, 9, 1 );
- mAnniversaryPicker = new KDateEdit( tab2 );
- mAnniversaryPicker->setHandleInvalid( true );
- connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ),
- SLOT( dateChanged( QDate ) ) );
-#ifndef KAB_EMBEDDED
- //US invalid dates are handled by the KDateEdit widget itself
- connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ),
- SLOT( invalidDate() ) );
- connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ),
- SLOT( emitModified() ) );
-#endif //KAB_EMBEDDED
+ label->setBuddy( mBirthdayPicker );
+
+ label = new QLabel( " "+i18n( "Anniversary:" )+" ", nbox );
+ layout->addWidget( label, iii, 1 );
+ mAnniversaryPicker = new KDateEdit( nbox );
+ mAnniversaryPicker->setHandleInvalid( true );
+ connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ),
+ SLOT( dateChanged( QDate ) ) );
- label->setBuddy( mAnniversaryPicker );
-//US layout->addWidget( mAnniversaryPicker, 5, 4 );
- layout->addWidget( mAnniversaryPicker, 9, 2 );
+ label->setBuddy( mAnniversaryPicker );
+ layout->addMultiCellWidget( nbox, iii, iii, 1, 2 );
+ ++iii;
+
+ } else {
+
+ label = new QLabel( i18n( "Birthday:" ), tab2 );
+ layout->addWidget( label, iii, 1 );
+ mBirthdayPicker = new KDateEdit( tab2 );
+ mBirthdayPicker->toggleDateFormat();
+ mBirthdayPicker->setHandleInvalid( true );
+ connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ),
+ SLOT( dateChanged( QDate ) ) );
+
+ label->setBuddy( mBirthdayPicker );
+ layout->addWidget( mBirthdayPicker, iii, 2 );
+ ++iii;
+
+ label = new QLabel( i18n( "Anniversary:" ), tab2 );
+ layout->addWidget( label, iii, 1 );
+ mAnniversaryPicker = new KDateEdit( tab2 );
+ mAnniversaryPicker->setHandleInvalid( true );
+ connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ),
+ SLOT( dateChanged( QDate ) ) );
+
+ label->setBuddy( mAnniversaryPicker );
+ layout->addWidget( mAnniversaryPicker, iii, 2 );
+ ++iii;
-/*US
- bar = new KSeparator( KSeparator::HLine, tab2 );
- layout->addMultiCellWidget( bar, 6, 6, 0, 5 );
-
- //////////////////////////////////////
- // Notes
- label = new QLabel( i18n( "Note:" ), tab2 );
- label->setAlignment( Qt::AlignTop | Qt::AlignLeft );
- layout->addWidget( label, 7, 0 );
-#ifndef KAB_EMBEDDED
- mNoteEdit = new QTextEdit( tab2 );
- mNoteEdit->setWordWrap( QTextEdit::WidgetWidth );
- mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() );
-#else //KAB_EMBEDDED
- mNoteEdit = new QMultiLineEdit( tab2 );
-//US mNoteEdit->setWordWrap( QTextEdit::WidgetWidth );
-//US mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() );
-qDebug("AddresseeEditorWidget::setupTab2 has to be changed");
-#endif //KAB_EMBEDDED
- connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) );
- label->setBuddy( mNoteEdit );
- layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 );
-*/
+ }
+
+ label = new QLabel( i18n( "Gender:" ), tab2 );
+ layout->addWidget( label, iii, 1 );
+ mGenderBox = new QComboBox ( tab2 );
+ mGenderBox->insertItem ( i18n( "ALIEN (gender undefined)" ));
+ mGenderBox->insertItem ( i18n( "female" ));
+ mGenderBox->insertItem ( i18n( "male" ));
+ connect( mGenderBox, SIGNAL( activated ( const QString & ) ),
+ SLOT( textChanged( const QString& ) ) );
+ label->setBuddy( mGenderBox );
+ layout->addWidget( mGenderBox, iii, 2 );
+ ++iii;
// Build the layout and add to the tab widget
layout->activate(); // required
mTabWidget->addTab( tab2, i18n( "&Details" ) );
}
void AddresseeEditorWidget::setupTab2_1()
{
// This is the Details tab
QWidget *tab2_2 = new QWidget( mTabWidget );
QGridLayout *layout = new QGridLayout( tab2_2, 1, 2 );
layout->setMargin( KDialogBase::marginHintSmall() );
layout->setSpacing( KDialogBase::spacingHintSmall() );
QLabel *label;
KSeparator* bar;
/*US
///////////////////////
// Office info
// Department
label = new QLabel( tab2 );
//US loadIcon call is ambiguous. Add one more parameter
//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) );
label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) );
layout->addMultiCellWidget( label, 0, 1, 0, 0 );
label = new QLabel( i18n( "Department:" ), tab2 );
layout->addWidget( label, 0, 1 );
mDepartmentEdit = new KLineEdit( tab2 );
connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mDepartmentEdit );
layout->addWidget( mDepartmentEdit, 0, 2 );
label = new QLabel( i18n( "Office:" ), tab2 );
layout->addWidget( label, 1, 1 );
mOfficeEdit = new KLineEdit( tab2 );
connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mOfficeEdit );
layout->addWidget( mOfficeEdit, 1, 2 );
label = new QLabel( i18n( "Profession:" ), tab2 );
layout->addWidget( label, 2, 1 );
mProfessionEdit = new KLineEdit( tab2 );
connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mProfessionEdit );
layout->addWidget( mProfessionEdit, 2, 2 );
label = new QLabel( i18n( "Manager\'s name:" ), tab2 );
layout->addWidget( label, 0, 3 );
mManagerEdit = new KLineEdit( tab2 );
connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mManagerEdit );
layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 );
label = new QLabel( i18n( "Assistant's name:" ), tab2 );
layout->addWidget( label, 1, 3 );
mAssistantEdit = new KLineEdit( tab2 );
connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mAssistantEdit );
layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 );
bar = new KSeparator( KSeparator::HLine, tab2 );
layout->addMultiCellWidget( bar, 3, 3, 0, 5 );
/////////////////////////////////////////////////
// Personal info
label = new QLabel( tab2 );
//US loadIcon call is ambiguous. Add one more parameter
//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
layout->addMultiCellWidget( label, 4, 5, 0, 0 );
label = new QLabel( i18n( "Nick name:" ), tab2 );
layout->addWidget( label, 4, 1 );
mNicknameEdit = new KLineEdit( tab2 );
connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mNicknameEdit );
layout->addWidget( mNicknameEdit, 4, 2 );
label = new QLabel( i18n( "Spouse's name:" ), tab2 );
layout->addWidget( label, 5, 1 );
mSpouseEdit = new KLineEdit( tab2 );
connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( textChanged( const QString& ) ) );
label->setBuddy( mSpouseEdit );
layout->addWidget( mSpouseEdit, 5, 2 );
@@ -920,256 +947,271 @@ void AddresseeEditorWidget::setupTab3_1()
// Sound
#ifndef KAB_EMBEDDED
mSoundWidget = new SoundWidget( tab3 );
mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() );
connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop );
#else //KAB_EMBEDDED
//US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed");
#endif //KAB_EMBEDDED
//////////////////////////////////////
// Images
mImageWidget = new ImageWidget( tab3 );
mImageWidget->setMinimumSize( mImageWidget->sizeHint() );
connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop );
/*US
//////////////////////////////////////
// Keys
mKeyWidget = new KeyWidget( tab3 );
mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() );
connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop );
*/
mTabWidget->addTab( tab3, i18n( "&Images" ) );
}
void AddresseeEditorWidget::load()
{
// Block signals in case anything tries to emit modified
// CS: This doesn't seem to work.
bool block = signalsBlocked();
blockSignals( true );
mBlockSignals = true; // used for internal signal blocking
mNameEdit->setText( mAddressee.assembledName() );
if ( mAddressee.formattedName().isEmpty() ) {
//US KConfig config( "kaddressbookrc" );
KConfig config( locateLocal("config", "kaddressbookrc") );
config.setGroup( "General" );
mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 );
mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
} else {
if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) )
mFormattedNameType = NameEditDialog::SimpleName;
else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) )
mFormattedNameType = NameEditDialog::FullName;
else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) )
mFormattedNameType = NameEditDialog::ReverseName;
else
mFormattedNameType = NameEditDialog::CustomName;
}
mFormattedNameLabel->setText( mAddressee.formattedName() );
mRoleEdit->setText( mAddressee.role() );
mOrgEdit->setText( mAddressee.organization() );
//US mURLEdit->setURL( mAddressee.url().url() );
mURLEdit->setText( mAddressee.url().prettyURL() );
//US?? mURLEdit->home( false );
// mNoteEdit->setText( mAddressee.note() );
mNoteEdit->setText( mAddressee.note() );
mEmailWidget->setEmails( mAddressee.emails() );
mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() );
mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() );
mBirthdayPicker->setDate( mAddressee.birthday().date() );
//US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom(
//US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) );
QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ),
"%Y-%m-%d"); // = Qt::ISODate
mAnniversaryPicker->setDate( dt );
mNicknameEdit->setText( mAddressee.nickName() );
mCategoryEdit->setText( mAddressee.categories().join( "," ) );
mGeoWidget->setGeo( mAddressee.geo() );
mImageWidget->setPhoto( mAddressee.photo() );
mImageWidget->setLogo( mAddressee.logo() );
mKeyWidget->setKeys( mAddressee.keys() );
mSecrecyWidget->setSecrecy( mAddressee.secrecy() );
#ifndef KAB_EMBEDDED
mSoundWidget->setSound( mAddressee.sound() );
#else //KAB_EMBEDDED
//US qDebug("AddresseeEditorWidget::load has to be changed 2");
#endif //KAB_EMBEDDED
// Load customs
mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) );
mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) );
+ mChildEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Children" ) );
mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) );
mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) );
mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) );
mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) );
mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) );
-
+ QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
+ if ( gen == "female" )
+ mGenderBox->setCurrentItem ( 1 );
+ else if ( gen == "male" )
+ mGenderBox->setCurrentItem ( 2 );
+ else
+ mGenderBox->setCurrentItem ( 0 );
blockSignals( block );
mBlockSignals = false;
mDirty = false;
}
void AddresseeEditorWidget::save()
{
if ( !dirty() ) {
return;
}
mAddressee.setRole( mRoleEdit->text() );
mAddressee.setOrganization( mOrgEdit->text() );
mAddressee.setUrl( KURL( mURLEdit->text() ) );
mAddressee.setNote( mNoteEdit->text() );
if ( mBirthdayPicker->inputIsValid() ) {
QDate da = mBirthdayPicker->date();
if ( da > QDate::currentDate() )
da.setYMD(da.year()-100, da.month(), da.day() );
mAddressee.setBirthday( QDateTime( da ) );
qDebug("bday %s ",da.toString().latin1());
}
else {
mAddressee.setBirthday( QDateTime() );
mBirthdayPicker->clear();
}
mAddressee.setNickName( mNicknameEdit->text() );
mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) );
mAddressee.setGeo( mGeoWidget->geo() );
mAddressee.setPhoto( mImageWidget->photo() );
mAddressee.setLogo( mImageWidget->logo() );
mAddressee.setKeys( mKeyWidget->keys() );
#ifndef KAB_EMBEDDED
mAddressee.setSound( mSoundWidget->sound() );
#else //KAB_EMBEDDED
//US qDebug("AddresseeEditorWidget::save sound not supported");
#endif //KAB_EMBEDDED
mAddressee.setSecrecy( mSecrecyWidget->secrecy() );
// save custom fields
mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() );
mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() );
+ mAddressee.insertCustom( "KADDRESSBOOK", "X-Children", mChildEdit->text() );
mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() );
mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() );
mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() );
mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() );
mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() );
if ( mAnniversaryPicker->inputIsValid() ) {
QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate);
mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
}
else {
mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" );
mAnniversaryPicker->clear();
}
-
+ int gen = mGenderBox->currentItem ();
+ if ( gen == 1 )
+ mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
+ else if ( gen == 2 )
+ mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
+ else
+ mAddressee.removeCustom( "KADDRESSBOOK", "X-Gender" );
+
// Save the email addresses
QStringList emails = mAddressee.emails();
QStringList::Iterator iter;
for ( iter = emails.begin(); iter != emails.end(); ++iter )
mAddressee.removeEmail( *iter );
emails = mEmailWidget->emails();
bool first = true;
for ( iter = emails.begin(); iter != emails.end(); ++iter ) {
mAddressee.insertEmail( *iter, first );
first = false;
}
// Save the phone numbers
KABC::PhoneNumber::List phoneNumbers;
KABC::PhoneNumber::List::Iterator phoneIter;
phoneNumbers = mAddressee.phoneNumbers();
for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
++phoneIter )
mAddressee.removePhoneNumber( *phoneIter );
phoneNumbers = mPhoneEditWidget->phoneNumbers();
for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
++phoneIter )
mAddressee.insertPhoneNumber( *phoneIter );
// Save the addresses
KABC::Address::List addresses;
KABC::Address::List::Iterator addressIter;
addresses = mAddressee.addresses();
for ( addressIter = addresses.begin(); addressIter != addresses.end();
++addressIter )
mAddressee.removeAddress( *addressIter );
addresses = mAddressEditWidget->addresses();
for ( addressIter = addresses.begin(); addressIter != addresses.end();
++addressIter )
mAddressee.insertAddress( *addressIter );
mDirty = false;
}
bool AddresseeEditorWidget::dirty()
{
if ( ! mDirty ) {
if ( mBirthdayPicker->inputIsValid() ) {
QDate da = mBirthdayPicker->date();
if ( !(da == mAddressee.birthday().date()))
mDirty = true;
}
else {
mBirthdayPicker->clear();
}
if ( mAnniversaryPicker->inputIsValid() ) {
QDate da = mAnniversaryPicker->date();
if ( da != KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ),
"%Y-%m-%d"))
mDirty = true;
}
else {
mAnniversaryPicker->clear();
}
}
return mDirty;
}
void AddresseeEditorWidget::nameTextChanged( const QString &text )
{
// use the addressee class to parse the name for us
mAConfig->setUid( mAddressee.uid() );
if ( mAConfig->automaticNameParsing() ) {
if ( !mAddressee.formattedName().isEmpty() ) {
QString fn = mAddressee.formattedName();
mAddressee.setNameFromString( text );
mAddressee.setFormattedName( fn );
} else {
// use extra addressee to avoid a formatted name assignment
Addressee addr;
addr.setNameFromString( text );
mAddressee.setPrefix( addr.prefix() );
mAddressee.setGivenName( addr.givenName() );
mAddressee.setAdditionalName( addr.additionalName() );
mAddressee.setFamilyName( addr.familyName() );
mAddressee.setSuffix( addr.suffix() );
}
}
nameBoxChanged();
emitModified();
}
void AddresseeEditorWidget::nameBoxChanged()
{
KABC::Addressee addr;
mAConfig->setUid( mAddressee.uid() );
diff --git a/kaddressbook/addresseeeditorwidget.h b/kaddressbook/addresseeeditorwidget.h
index b9d9e25..995f30e 100644
--- a/kaddressbook/addresseeeditorwidget.h
+++ b/kaddressbook/addresseeeditorwidget.h
@@ -67,118 +67,120 @@ namespace KPIM
namespace KABC { class AddressBook; }
class AddresseeEditorWidget : public ExtensionWidget
{
Q_OBJECT
public:
AddresseeEditorWidget( KABCore *core, bool isExtension,
QWidget *parent, const char *name = 0 );
~AddresseeEditorWidget();
void setAddressee( const KABC::Addressee& );
const KABC::Addressee &addressee();
void contactsSelectionChanged();
void load();
void save();
bool dirty();
QString title() const;
QString identifier() const;
protected slots:
void textChanged( const QString& );
void pageChanged( QWidget *wdg );
/**
Emits the modified signal and sets the dirty flag. Any slot
that modifies data should use this method instead of calling emit
modified() directly.
*/
void emitModified();
void dateChanged( QDate );
void invalidDate();
void nameTextChanged( const QString& );
void nameBoxChanged();
void nameButtonClicked();
void categoryButtonClicked();
/**
Called whenever the categories change in the categories dialog.
*/
void categoriesSelected( const QStringList& );
/**
Edits which categories are available in the CategorySelectDialog.
*/
void editCategories();
private:
AddresseeConfig * mAConfig;
void initGUI();
void setupTab1();
void setupTab1_1();
void setupTab2();
void setupTab2_1();
void setupTab3();
void setupTab3_1();
KABC::Addressee mAddressee;
int mFormattedNameType;
bool mDirty;
bool mIsExtension;
bool mBlockSignals;
// GUI
KPIM::CategorySelectDialog *mCategoryDialog;
KPIM::CategoryEditDialog *mCategoryEditDialog;
QTabWidget *mTabWidget;
// Tab1 and Tab1_1
KLineEdit *mNameEdit;
KLineEdit *mRoleEdit;
KLineEdit *mOrgEdit;
KSqueezedTextLabel *mFormattedNameLabel;
AddressEditWidget *mAddressEditWidget;
EmailEditWidget *mEmailWidget;
PhoneEditWidget *mPhoneEditWidget;
KLineEdit *mURLEdit;
KLineEdit *mIMAddressEdit;
KLineEdit *mCategoryEdit;
SecrecyWidget *mSecrecyWidget;
KSqueezedTextLabel *mNameLabel;
// Tab2 and Tab2_2
KLineEdit *mDepartmentEdit;
KLineEdit *mOfficeEdit;
KLineEdit *mProfessionEdit;
KLineEdit *mManagerEdit;
KLineEdit *mAssistantEdit;
KLineEdit *mNicknameEdit;
KLineEdit *mSpouseEdit;
+ KLineEdit *mChildEdit;
+ QComboBox *mGenderBox;
KDateEdit *mBirthdayPicker;
KDateEdit *mAnniversaryPicker;
#ifndef KAB_EMBEDDED
QTextEdit *mNoteEdit;
#else //KAB_EMBEDDED
QMultiLineEdit *mNoteEdit;
#endif //KAB_EMBEDDED
QSpinBox *mTimeZoneSpin;
QSpinBox *mGeoLat;
QSpinBox *mGeoLon;
// Tab3
GeoWidget *mGeoWidget;
ImageWidget *mImageWidget;
#ifndef KAB_EMBEDDED
SoundWidget *mSoundWidget;
#endif //KAB_EMBEDDED
KeyWidget *mKeyWidget;
};
#endif