summaryrefslogtreecommitdiffabout
path: root/kaddressbook/addresseeeditorwidget.cpp
Unidiff
Diffstat (limited to 'kaddressbook/addresseeeditorwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp50
1 files changed, 38 insertions, 12 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
index 3cfc1f2..826c69b 100644
--- a/kaddressbook/addresseeeditorwidget.cpp
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -84,13 +84,12 @@ AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension,
84 : ExtensionWidget( core, parent, name ), mIsExtension( isExtension ), 84 : ExtensionWidget( core, parent, name ), mIsExtension( isExtension ),
85 mBlockSignals( false ) 85 mBlockSignals( false )
86{ 86{
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;
94 mCategoryEditDialog = 0; 93 mCategoryEditDialog = 0;
95 94
96 // Load the empty addressee as defaults 95 // Load the empty addressee as defaults
@@ -629,12 +628,13 @@ void AddresseeEditorWidget::setupTab2()
629 layout->addWidget( mSpouseEdit, 7, 2 ); 628 layout->addWidget( mSpouseEdit, 7, 2 );
630 629
631 label = new QLabel( i18n( "Birthday:" ), tab2 ); 630 label = new QLabel( i18n( "Birthday:" ), tab2 );
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 ) ) );
638 638
639 639
640#ifndef KAB_EMBEDDED 640#ifndef KAB_EMBEDDED
@@ -944,13 +944,12 @@ void AddresseeEditorWidget::setupTab3_1()
944 mTabWidget->addTab( tab3, i18n( "&Images" ) ); 944 mTabWidget->addTab( tab3, i18n( "&Images" ) );
945} 945}
946 946
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.
954 bool block = signalsBlocked(); 953 bool block = signalsBlocked();
955 blockSignals( true ); 954 blockSignals( true );
956 mBlockSignals = true; // used for internal signal blocking 955 mBlockSignals = true; // used for internal signal blocking
@@ -1025,23 +1024,31 @@ void AddresseeEditorWidget::load()
1025 1024
1026 mDirty = false; 1025 mDirty = false;
1027} 1026}
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
1045 mAddressee.setGeo( mGeoWidget->geo() ); 1052 mAddressee.setGeo( mGeoWidget->geo() );
1046 mAddressee.setPhoto( mImageWidget->photo() ); 1053 mAddressee.setPhoto( mImageWidget->photo() );
1047 mAddressee.setLogo( mImageWidget->logo() ); 1054 mAddressee.setLogo( mImageWidget->logo() );
@@ -1059,20 +1066,19 @@ void AddresseeEditorWidget::save()
1059 mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); 1066 mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() );
1060 mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); 1067 mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() );
1061 mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); 1068 mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() );
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();
1076 QStringList::Iterator iter; 1082 QStringList::Iterator iter;
1077 for ( iter = emails.begin(); iter != emails.end(); ++iter ) 1083 for ( iter = emails.begin(); iter != emails.end(); ++iter )
1078 mAddressee.removeEmail( *iter ); 1084 mAddressee.removeEmail( *iter );
@@ -1111,12 +1117,32 @@ void AddresseeEditorWidget::save()
1111 mAddressee.insertAddress( *addressIter ); 1117 mAddressee.insertAddress( *addressIter );
1112 mDirty = false; 1118 mDirty = false;
1113} 1119}
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
1120void AddresseeEditorWidget::nameTextChanged( const QString &text ) 1146void AddresseeEditorWidget::nameTextChanged( const QString &text )
1121{ 1147{
1122 // use the addressee class to parse the name for us 1148 // use the addressee class to parse the name for us
@@ -1166,13 +1192,13 @@ void AddresseeEditorWidget::nameBoxChanged()
1166 1192
1167void AddresseeEditorWidget::nameButtonClicked() 1193void AddresseeEditorWidget::nameButtonClicked()
1168{ 1194{
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() );
1176 mAddressee.setPrefix( dialog.prefix() ); 1202 mAddressee.setPrefix( dialog.prefix() );
1177 mAddressee.setSuffix( dialog.suffix() ); 1203 mAddressee.setSuffix( dialog.suffix() );
1178 mAddressee.setAdditionalName( dialog.additionalName() ); 1204 mAddressee.setAdditionalName( dialog.additionalName() );