summaryrefslogtreecommitdiffabout
path: root/kaddressbook/addresseeeditorwidget.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/addresseeeditorwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp56
1 files changed, 41 insertions, 15 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
index 3cfc1f2..826c69b 100644
--- a/kaddressbook/addresseeeditorwidget.cpp
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -82,17 +82,16 @@
AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension,
QWidget *parent, const char *name )
: ExtensionWidget( core, parent, name ), mIsExtension( isExtension ),
mBlockSignals( false )
{
mAConfig = AddresseeConfig::instance();
- kdDebug(5720) << "AddresseeEditorWidget()" << endl;
mFormattedNameType = NameEditDialog::CustomName;
initGUI();
mCategoryDialog = 0;
mCategoryEditDialog = 0;
// Load the empty addressee as defaults
load();
@@ -627,16 +626,17 @@ void AddresseeEditorWidget::setupTab2()
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 ) ) );
#ifndef KAB_EMBEDDED
//US invalid dates are handdled by the KDateEdit widget itself
connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ),
@@ -942,17 +942,16 @@ void AddresseeEditorWidget::setupTab3_1()
layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop );
*/
mTabWidget->addTab( tab3, i18n( "&Images" ) );
}
void AddresseeEditorWidget::load()
{
- kdDebug(5720) << "AddresseeEditorWidget::load()" << endl;
// 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() );
@@ -1023,27 +1022,35 @@ void AddresseeEditorWidget::load()
blockSignals( block );
mBlockSignals = false;
mDirty = false;
}
void AddresseeEditorWidget::save()
{
- if ( !mDirty ) return;
+ if ( !dirty() ) {
+ return;
+ }
mAddressee.setRole( mRoleEdit->text() );
mAddressee.setOrganization( mOrgEdit->text() );
mAddressee.setUrl( KURL( mURLEdit->text() ) );
mAddressee.setNote( mNoteEdit->text() );
- if ( mBirthdayPicker->inputIsValid() )
- mAddressee.setBirthday( QDateTime( mBirthdayPicker->date() ) );
- else
+ 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
@@ -1057,24 +1064,23 @@ void AddresseeEditorWidget::save()
mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() );
mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->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() ) {
-
-//US mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary",
-//US mAnniversaryPicker->date().toString( Qt::ISODate ) );
QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate);
mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
}
- else
+ else {
mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" );
+ mAnniversaryPicker->clear();
+ }
// 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();
@@ -1109,28 +1115,48 @@ void AddresseeEditorWidget::save()
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 );
+ 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() );
@@ -1164,17 +1190,17 @@ void AddresseeEditorWidget::nameBoxChanged()
}
}
void AddresseeEditorWidget::nameButtonClicked()
{
// show the name dialog.
NameEditDialog dialog( mAddressee, mFormattedNameType, this );
- if ( dialog.exec() ) {
+ if ( KApplication::execDialog( &dialog) ) {
if ( dialog.changed() ) {
mAddressee.setFamilyName( dialog.familyName() );
mAddressee.setGivenName( dialog.givenName() );
mAddressee.setPrefix( dialog.prefix() );
mAddressee.setSuffix( dialog.suffix() );
mAddressee.setAdditionalName( dialog.additionalName() );
mFormattedNameType = dialog.formattedNameType();
if ( mFormattedNameType == NameEditDialog::CustomName ) {