Diffstat (limited to 'kaddressbook/addresseeeditorwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/addresseeeditorwidget.cpp | 56 |
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 @@ -86,9 +86,8 @@ AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension, { mAConfig = AddresseeConfig::instance(); - kdDebug(5720) << "AddresseeEditorWidget()" << endl; mFormattedNameType = NameEditDialog::CustomName; initGUI(); mCategoryDialog = 0; mCategoryEditDialog = 0; @@ -631,8 +630,9 @@ void AddresseeEditorWidget::setupTab2() 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 ) ) ); @@ -946,9 +946,8 @@ void AddresseeEditorWidget::setupTab3_1() 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(); @@ -1027,19 +1026,27 @@ void AddresseeEditorWidget::load() } 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() ); @@ -1061,16 +1068,15 @@ void AddresseeEditorWidget::save() 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; @@ -1113,8 +1119,28 @@ void AddresseeEditorWidget::save() } 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 ) @@ -1122,11 +1148,11 @@ 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 ); @@ -1168,9 +1194,9 @@ 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() ); |