summaryrefslogtreecommitdiffabout
path: root/kaddressbook/addresseeeditorwidget.cpp
authorzautrix <zautrix>2004-09-13 21:35:12 (UTC)
committer zautrix <zautrix>2004-09-13 21:35:12 (UTC)
commitbd6b4acb39498ffea3beea7d9b5f7620b60c14db (patch) (unidiff)
treee2d7425b7bb49fbcb7acb5ced497ac1fed06dfaf /kaddressbook/addresseeeditorwidget.cpp
parent06eabf6e82c0390699d11fd12580d91261829431 (diff)
downloadkdepimpi-bd6b4acb39498ffea3beea7d9b5f7620b60c14db.zip
kdepimpi-bd6b4acb39498ffea3beea7d9b5f7620b60c14db.tar.gz
kdepimpi-bd6b4acb39498ffea3beea7d9b5f7620b60c14db.tar.bz2
Many bugfixes
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
@@ -87,7 +87,6 @@ AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension,
87 87
88 mAConfig = AddresseeConfig::instance(); 88 mAConfig = AddresseeConfig::instance();
89 89
90 kdDebug(5720) << "AddresseeEditorWidget()" << endl;
91 mFormattedNameType = NameEditDialog::CustomName; 90 mFormattedNameType = NameEditDialog::CustomName;
92 initGUI(); 91 initGUI();
93 mCategoryDialog = 0; 92 mCategoryDialog = 0;
@@ -632,6 +631,7 @@ void AddresseeEditorWidget::setupTab2()
632//US layout->addWidget( label, 4, 3 ); 631//US layout->addWidget( label, 4, 3 );
633 layout->addWidget( label, 8, 1 ); 632 layout->addWidget( label, 8, 1 );
634 mBirthdayPicker = new KDateEdit( tab2 ); 633 mBirthdayPicker = new KDateEdit( tab2 );
634 mBirthdayPicker->toggleDateFormat();
635 mBirthdayPicker->setHandleInvalid( true ); 635 mBirthdayPicker->setHandleInvalid( true );
636 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), 636 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ),
637 SLOT( dateChanged( QDate ) ) ); 637 SLOT( dateChanged( QDate ) ) );
@@ -947,7 +947,6 @@ void AddresseeEditorWidget::setupTab3_1()
947 947
948void AddresseeEditorWidget::load() 948void AddresseeEditorWidget::load()
949{ 949{
950 kdDebug(5720) << "AddresseeEditorWidget::load()" << endl;
951 950
952 // Block signals in case anything tries to emit modified 951 // Block signals in case anything tries to emit modified
953 // CS: This doesn't seem to work. 952 // CS: This doesn't seem to work.
@@ -1028,17 +1027,25 @@ void AddresseeEditorWidget::load()
1028 1027
1029void AddresseeEditorWidget::save() 1028void AddresseeEditorWidget::save()
1030{ 1029{
1031 if ( !mDirty ) return; 1030 if ( !dirty() ) {
1031 return;
1032 }
1032 1033
1033 mAddressee.setRole( mRoleEdit->text() ); 1034 mAddressee.setRole( mRoleEdit->text() );
1034 mAddressee.setOrganization( mOrgEdit->text() ); 1035 mAddressee.setOrganization( mOrgEdit->text() );
1035 mAddressee.setUrl( KURL( mURLEdit->text() ) ); 1036 mAddressee.setUrl( KURL( mURLEdit->text() ) );
1036 mAddressee.setNote( mNoteEdit->text() ); 1037 mAddressee.setNote( mNoteEdit->text() );
1037 if ( mBirthdayPicker->inputIsValid() ) 1038 if ( mBirthdayPicker->inputIsValid() ) {
1038 mAddressee.setBirthday( QDateTime( mBirthdayPicker->date() ) ); 1039 QDate da = mBirthdayPicker->date();
1039 else 1040 if ( da > QDate::currentDate() )
1041 da.setYMD(da.year()-100, da.month(), da.day() );
1042 mAddressee.setBirthday( QDateTime( da ) );
1043 qDebug("bday %s ",da.toString().latin1());
1044 }
1045 else {
1040 mAddressee.setBirthday( QDateTime() ); 1046 mAddressee.setBirthday( QDateTime() );
1041 1047 mBirthdayPicker->clear();
1048 }
1042 mAddressee.setNickName( mNicknameEdit->text() ); 1049 mAddressee.setNickName( mNicknameEdit->text() );
1043 mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); 1050 mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) );
1044 1051
@@ -1062,14 +1069,13 @@ void AddresseeEditorWidget::save()
1062 mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); 1069 mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() );
1063 mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); 1070 mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() );
1064 if ( mAnniversaryPicker->inputIsValid() ) { 1071 if ( mAnniversaryPicker->inputIsValid() ) {
1065
1066//US mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary",
1067//US mAnniversaryPicker->date().toString( Qt::ISODate ) );
1068 QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate); 1072 QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate);
1069 mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 1073 mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
1070 } 1074 }
1071 else 1075 else {
1072 mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); 1076 mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" );
1077 mAnniversaryPicker->clear();
1078 }
1073 1079
1074 // Save the email addresses 1080 // Save the email addresses
1075 QStringList emails = mAddressee.emails(); 1081 QStringList emails = mAddressee.emails();
@@ -1114,6 +1120,26 @@ void AddresseeEditorWidget::save()
1114 1120
1115bool AddresseeEditorWidget::dirty() 1121bool AddresseeEditorWidget::dirty()
1116{ 1122{
1123
1124 if ( ! mDirty ) {
1125 if ( mBirthdayPicker->inputIsValid() ) {
1126 QDate da = mBirthdayPicker->date();
1127 if ( !(da == mAddressee.birthday().date()))
1128 mDirty = true;
1129 }
1130 else {
1131 mBirthdayPicker->clear();
1132 }
1133 if ( mAnniversaryPicker->inputIsValid() ) {
1134 QDate da = mAnniversaryPicker->date();
1135 if ( da != KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ),
1136 "%Y-%m-%d"))
1137 mDirty = true;
1138 }
1139 else {
1140 mAnniversaryPicker->clear();
1141 }
1142 }
1117 return mDirty; 1143 return mDirty;
1118} 1144}
1119 1145
@@ -1123,9 +1149,9 @@ void AddresseeEditorWidget::nameTextChanged( const QString &text )
1123 mAConfig->setUid( mAddressee.uid() ); 1149 mAConfig->setUid( mAddressee.uid() );
1124 if ( mAConfig->automaticNameParsing() ) { 1150 if ( mAConfig->automaticNameParsing() ) {
1125 if ( !mAddressee.formattedName().isEmpty() ) { 1151 if ( !mAddressee.formattedName().isEmpty() ) {
1126 QString fn = mAddressee.formattedName(); 1152 QString fn = mAddressee.formattedName();
1127 mAddressee.setNameFromString( text ); 1153 mAddressee.setNameFromString( text );
1128 mAddressee.setFormattedName( fn ); 1154 mAddressee.setFormattedName( fn );
1129 } else { 1155 } else {
1130 // use extra addressee to avoid a formatted name assignment 1156 // use extra addressee to avoid a formatted name assignment
1131 Addressee addr; 1157 Addressee addr;
@@ -1169,7 +1195,7 @@ void AddresseeEditorWidget::nameButtonClicked()
1169 // show the name dialog. 1195 // show the name dialog.
1170 NameEditDialog dialog( mAddressee, mFormattedNameType, this ); 1196 NameEditDialog dialog( mAddressee, mFormattedNameType, this );
1171 1197
1172 if ( dialog.exec() ) { 1198 if ( KApplication::execDialog( &dialog) ) {
1173 if ( dialog.changed() ) { 1199 if ( dialog.changed() ) {
1174 mAddressee.setFamilyName( dialog.familyName() ); 1200 mAddressee.setFamilyName( dialog.familyName() );
1175 mAddressee.setGivenName( dialog.givenName() ); 1201 mAddressee.setGivenName( dialog.givenName() );