summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp56
-rw-r--r--kaddressbook/mainembedded.cpp15
-rw-r--r--kaddressbook/nameeditdialog.cpp7
3 files changed, 58 insertions, 20 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
index 3cfc1f2..826c69b 100644
--- a/kaddressbook/addresseeeditorwidget.cpp
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -66,49 +66,48 @@
66#include <ksqueezedtextlabel.h> 66#include <ksqueezedtextlabel.h>
67 67
68#include <libkdepim/categoryeditdialog.h> 68#include <libkdepim/categoryeditdialog.h>
69#include <libkdepim/categoryselectdialog.h> 69#include <libkdepim/categoryselectdialog.h>
70 70
71#include <libkdepim/kdateedit.h> 71#include <libkdepim/kdateedit.h>
72 72
73#include "addresseditwidget.h" 73#include "addresseditwidget.h"
74#include "emaileditwidget.h" 74#include "emaileditwidget.h"
75#include "kabcore.h" 75#include "kabcore.h"
76#include "kabprefs.h" 76#include "kabprefs.h"
77 77
78#include "addresseeeditorwidget.h" 78#include "addresseeeditorwidget.h"
79 79
80 80
81 81
82AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension, 82AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension,
83 QWidget *parent, const char *name ) 83 QWidget *parent, const char *name )
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
97 load(); 96 load();
98 97
99 mDirty = false; 98 mDirty = false;
100} 99}
101 100
102AddresseeEditorWidget::~AddresseeEditorWidget() 101AddresseeEditorWidget::~AddresseeEditorWidget()
103{ 102{
104 kdDebug(5720) << "~AddresseeEditorWidget()" << endl; 103 kdDebug(5720) << "~AddresseeEditorWidget()" << endl;
105} 104}
106 105
107void AddresseeEditorWidget::contactsSelectionChanged() 106void AddresseeEditorWidget::contactsSelectionChanged()
108{ 107{
109 KABC::Addressee::List list = selectedContacts(); 108 KABC::Addressee::List list = selectedContacts();
110 109
111 mAddressee = list[ 0 ]; 110 mAddressee = list[ 0 ];
112 load(); 111 load();
113} 112}
114 113
@@ -611,48 +610,49 @@ void AddresseeEditorWidget::setupTab2()
611 label = new QLabel( i18n( "Nick name:" ), tab2 ); 610 label = new QLabel( i18n( "Nick name:" ), tab2 );
612//US layout->addWidget( label, 4, 1 ); 611//US layout->addWidget( label, 4, 1 );
613 layout->addWidget( label, 6, 1 ); 612 layout->addWidget( label, 6, 1 );
614 mNicknameEdit = new KLineEdit( tab2 ); 613 mNicknameEdit = new KLineEdit( tab2 );
615 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), 614 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
616 SLOT( textChanged( const QString& ) ) ); 615 SLOT( textChanged( const QString& ) ) );
617 label->setBuddy( mNicknameEdit ); 616 label->setBuddy( mNicknameEdit );
618//US layout->addWidget( mNicknameEdit, 4, 2 ); 617//US layout->addWidget( mNicknameEdit, 4, 2 );
619 layout->addWidget( mNicknameEdit, 6, 2 ); 618 layout->addWidget( mNicknameEdit, 6, 2 );
620 619
621 label = new QLabel( i18n( "Spouse's name:" ), tab2 ); 620 label = new QLabel( i18n( "Spouse's name:" ), tab2 );
622//US layout->addWidget( label, 5, 1 ); 621//US layout->addWidget( label, 5, 1 );
623 layout->addWidget( label, 7, 1 ); 622 layout->addWidget( label, 7, 1 );
624 mSpouseEdit = new KLineEdit( tab2 ); 623 mSpouseEdit = new KLineEdit( tab2 );
625 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), 624 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
626 SLOT( textChanged( const QString& ) ) ); 625 SLOT( textChanged( const QString& ) ) );
627 label->setBuddy( mSpouseEdit ); 626 label->setBuddy( mSpouseEdit );
628//US layout->addWidget( mSpouseEdit, 5, 2 ); 627//US layout->addWidget( mSpouseEdit, 5, 2 );
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
641 //US invalid dates are handdled by the KDateEdit widget itself 641 //US invalid dates are handdled by the KDateEdit widget itself
642 connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), 642 connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ),
643 SLOT( invalidDate() ) ); 643 SLOT( invalidDate() ) );
644 connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), 644 connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ),
645 SLOT( emitModified() ) ); 645 SLOT( emitModified() ) );
646#endif //KAB_EMBEDDED 646#endif //KAB_EMBEDDED
647 647
648 label->setBuddy( mBirthdayPicker ); 648 label->setBuddy( mBirthdayPicker );
649//US layout->addWidget( mBirthdayPicker, 4, 4 ); 649//US layout->addWidget( mBirthdayPicker, 4, 4 );
650 layout->addWidget( mBirthdayPicker, 8, 2 ); 650 layout->addWidget( mBirthdayPicker, 8, 2 );
651 651
652 label = new QLabel( i18n( "Anniversary:" ), tab2 ); 652 label = new QLabel( i18n( "Anniversary:" ), tab2 );
653//US layout->addWidget( label, 5, 3 ); 653//US layout->addWidget( label, 5, 3 );
654 layout->addWidget( label, 9, 1 ); 654 layout->addWidget( label, 9, 1 );
655 mAnniversaryPicker = new KDateEdit( tab2 ); 655 mAnniversaryPicker = new KDateEdit( tab2 );
656 mAnniversaryPicker->setHandleInvalid( true ); 656 mAnniversaryPicker->setHandleInvalid( true );
657 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), 657 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ),
658 SLOT( dateChanged( QDate ) ) ); 658 SLOT( dateChanged( QDate ) ) );
@@ -926,49 +926,48 @@ void AddresseeEditorWidget::setupTab3_1()
926#else //KAB_EMBEDDED 926#else //KAB_EMBEDDED
927//US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); 927//US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed");
928#endif //KAB_EMBEDDED 928#endif //KAB_EMBEDDED
929 929
930 ////////////////////////////////////// 930 //////////////////////////////////////
931 // Images 931 // Images
932 mImageWidget = new ImageWidget( tab3 ); 932 mImageWidget = new ImageWidget( tab3 );
933 mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); 933 mImageWidget->setMinimumSize( mImageWidget->sizeHint() );
934 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 934 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
935 layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop ); 935 layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop );
936/*US 936/*US
937 ////////////////////////////////////// 937 //////////////////////////////////////
938 // Keys 938 // Keys
939 mKeyWidget = new KeyWidget( tab3 ); 939 mKeyWidget = new KeyWidget( tab3 );
940 mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); 940 mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() );
941 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 941 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
942 layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); 942 layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop );
943*/ 943*/
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
957 956
958 mNameEdit->setText( mAddressee.assembledName() ); 957 mNameEdit->setText( mAddressee.assembledName() );
959 958
960 if ( mAddressee.formattedName().isEmpty() ) { 959 if ( mAddressee.formattedName().isEmpty() ) {
961//US KConfig config( "kaddressbookrc" ); 960//US KConfig config( "kaddressbookrc" );
962 KConfig config( locateLocal("config", "kaddressbookrc") ); 961 KConfig config( locateLocal("config", "kaddressbookrc") );
963 config.setGroup( "General" ); 962 config.setGroup( "General" );
964 mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); 963 mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 );
965 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 964 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
966 } else { 965 } else {
967 if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) 966 if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) )
968 mFormattedNameType = NameEditDialog::SimpleName; 967 mFormattedNameType = NameEditDialog::SimpleName;
969 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) 968 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) )
970 mFormattedNameType = NameEditDialog::FullName; 969 mFormattedNameType = NameEditDialog::FullName;
971 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) 970 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) )
972 mFormattedNameType = NameEditDialog::ReverseName; 971 mFormattedNameType = NameEditDialog::ReverseName;
973 else 972 else
974 mFormattedNameType = NameEditDialog::CustomName; 973 mFormattedNameType = NameEditDialog::CustomName;
@@ -1007,190 +1006,217 @@ void AddresseeEditorWidget::load()
1007 mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); 1006 mSecrecyWidget->setSecrecy( mAddressee.secrecy() );
1008#ifndef KAB_EMBEDDED 1007#ifndef KAB_EMBEDDED
1009 mSoundWidget->setSound( mAddressee.sound() ); 1008 mSoundWidget->setSound( mAddressee.sound() );
1010#else //KAB_EMBEDDED 1009#else //KAB_EMBEDDED
1011//US qDebug("AddresseeEditorWidget::load has to be changed 2"); 1010//US qDebug("AddresseeEditorWidget::load has to be changed 2");
1012#endif //KAB_EMBEDDED 1011#endif //KAB_EMBEDDED
1013 1012
1014 // Load customs 1013 // Load customs
1015 mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); 1014 mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) );
1016 mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); 1015 mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) );
1017 mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); 1016 mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) );
1018 mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); 1017 mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) );
1019 mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); 1018 mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) );
1020 mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); 1019 mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) );
1021 mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); 1020 mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) );
1022 1021
1023 blockSignals( block ); 1022 blockSignals( block );
1024 mBlockSignals = false; 1023 mBlockSignals = false;
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() );
1048 mAddressee.setKeys( mKeyWidget->keys() ); 1055 mAddressee.setKeys( mKeyWidget->keys() );
1049#ifndef KAB_EMBEDDED 1056#ifndef KAB_EMBEDDED
1050 mAddressee.setSound( mSoundWidget->sound() ); 1057 mAddressee.setSound( mSoundWidget->sound() );
1051#else //KAB_EMBEDDED 1058#else //KAB_EMBEDDED
1052//US qDebug("AddresseeEditorWidget::save sound not supported"); 1059//US qDebug("AddresseeEditorWidget::save sound not supported");
1053#endif //KAB_EMBEDDED 1060#endif //KAB_EMBEDDED
1054 mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); 1061 mAddressee.setSecrecy( mSecrecyWidget->secrecy() );
1055 1062
1056 // save custom fields 1063 // save custom fields
1057 mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); 1064 mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() );
1058 mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); 1065 mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() );
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 );
1079 1085
1080 emails = mEmailWidget->emails(); 1086 emails = mEmailWidget->emails();
1081 bool first = true; 1087 bool first = true;
1082 for ( iter = emails.begin(); iter != emails.end(); ++iter ) { 1088 for ( iter = emails.begin(); iter != emails.end(); ++iter ) {
1083 mAddressee.insertEmail( *iter, first ); 1089 mAddressee.insertEmail( *iter, first );
1084 first = false; 1090 first = false;
1085 } 1091 }
1086 1092
1087 // Save the phone numbers 1093 // Save the phone numbers
1088 KABC::PhoneNumber::List phoneNumbers; 1094 KABC::PhoneNumber::List phoneNumbers;
1089 KABC::PhoneNumber::List::Iterator phoneIter; 1095 KABC::PhoneNumber::List::Iterator phoneIter;
1090 phoneNumbers = mAddressee.phoneNumbers(); 1096 phoneNumbers = mAddressee.phoneNumbers();
1091 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); 1097 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
1092 ++phoneIter ) 1098 ++phoneIter )
1093 mAddressee.removePhoneNumber( *phoneIter ); 1099 mAddressee.removePhoneNumber( *phoneIter );
1094 1100
1095 phoneNumbers = mPhoneEditWidget->phoneNumbers(); 1101 phoneNumbers = mPhoneEditWidget->phoneNumbers();
1096 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); 1102 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
1097 ++phoneIter ) 1103 ++phoneIter )
1098 mAddressee.insertPhoneNumber( *phoneIter ); 1104 mAddressee.insertPhoneNumber( *phoneIter );
1099 1105
1100 // Save the addresses 1106 // Save the addresses
1101 KABC::Address::List addresses; 1107 KABC::Address::List addresses;
1102 KABC::Address::List::Iterator addressIter; 1108 KABC::Address::List::Iterator addressIter;
1103 addresses = mAddressee.addresses(); 1109 addresses = mAddressee.addresses();
1104 for ( addressIter = addresses.begin(); addressIter != addresses.end(); 1110 for ( addressIter = addresses.begin(); addressIter != addresses.end();
1105 ++addressIter ) 1111 ++addressIter )
1106 mAddressee.removeAddress( *addressIter ); 1112 mAddressee.removeAddress( *addressIter );
1107 1113
1108 addresses = mAddressEditWidget->addresses(); 1114 addresses = mAddressEditWidget->addresses();
1109 for ( addressIter = addresses.begin(); addressIter != addresses.end(); 1115 for ( addressIter = addresses.begin(); addressIter != addresses.end();
1110 ++addressIter ) 1116 ++addressIter )
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
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;
1132 addr.setNameFromString( text ); 1158 addr.setNameFromString( text );
1133 mAddressee.setPrefix( addr.prefix() ); 1159 mAddressee.setPrefix( addr.prefix() );
1134 mAddressee.setGivenName( addr.givenName() ); 1160 mAddressee.setGivenName( addr.givenName() );
1135 mAddressee.setAdditionalName( addr.additionalName() ); 1161 mAddressee.setAdditionalName( addr.additionalName() );
1136 mAddressee.setFamilyName( addr.familyName() ); 1162 mAddressee.setFamilyName( addr.familyName() );
1137 mAddressee.setSuffix( addr.suffix() ); 1163 mAddressee.setSuffix( addr.suffix() );
1138 } 1164 }
1139 } 1165 }
1140 1166
1141 nameBoxChanged(); 1167 nameBoxChanged();
1142 1168
1143 emitModified(); 1169 emitModified();
1144} 1170}
1145 1171
1146void AddresseeEditorWidget::nameBoxChanged() 1172void AddresseeEditorWidget::nameBoxChanged()
1147{ 1173{
1148 KABC::Addressee addr; 1174 KABC::Addressee addr;
1149 mAConfig->setUid( mAddressee.uid() ); 1175 mAConfig->setUid( mAddressee.uid() );
1150 if ( mAConfig->automaticNameParsing() ) { 1176 if ( mAConfig->automaticNameParsing() ) {
1151 addr.setNameFromString( mNameEdit->text() ); 1177 addr.setNameFromString( mNameEdit->text() );
1152 mNameLabel->hide(); 1178 mNameLabel->hide();
1153 mNameEdit->show(); 1179 mNameEdit->show();
1154 } else { 1180 } else {
1155 addr = mAddressee; 1181 addr = mAddressee;
1156 mNameEdit->hide(); 1182 mNameEdit->hide();
1157 mNameLabel->setText( mNameEdit->text() ); 1183 mNameLabel->setText( mNameEdit->text() );
1158 mNameLabel->show(); 1184 mNameLabel->show();
1159 } 1185 }
1160 1186
1161 if ( mFormattedNameType != NameEditDialog::CustomName ) { 1187 if ( mFormattedNameType != NameEditDialog::CustomName ) {
1162 mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 1188 mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
1163 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 1189 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
1164 } 1190 }
1165} 1191}
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() );
1179 mFormattedNameType = dialog.formattedNameType(); 1205 mFormattedNameType = dialog.formattedNameType();
1180 if ( mFormattedNameType == NameEditDialog::CustomName ) { 1206 if ( mFormattedNameType == NameEditDialog::CustomName ) {
1181 mFormattedNameLabel->setText( dialog.customFormattedName() ); 1207 mFormattedNameLabel->setText( dialog.customFormattedName() );
1182 mAddressee.setFormattedName( dialog.customFormattedName() ); 1208 mAddressee.setFormattedName( dialog.customFormattedName() );
1183 } 1209 }
1184 // Update the name edit. 1210 // Update the name edit.
1185 bool block = mNameEdit->signalsBlocked(); 1211 bool block = mNameEdit->signalsBlocked();
1186 mNameEdit->blockSignals( true ); 1212 mNameEdit->blockSignals( true );
1187 mNameEdit->setText( mAddressee.assembledName() ); 1213 mNameEdit->setText( mAddressee.assembledName() );
1188 mNameEdit->blockSignals( block ); 1214 mNameEdit->blockSignals( block );
1189 1215
1190 // Update the combo box. 1216 // Update the combo box.
1191 nameBoxChanged(); 1217 nameBoxChanged();
1192 1218
1193 emitModified(); 1219 emitModified();
1194 } 1220 }
1195 } 1221 }
1196} 1222}
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index d781f67..4230c07 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -50,48 +50,63 @@ int main( int argc, char **argv )
50 printf(" KA/E is exiting now. Bye!\n"); 50 printf(" KA/E is exiting now. Bye!\n");
51 exitHelp = true; 51 exitHelp = true;
52 } 52 }
53 } 53 }
54 if ( ! exitHelp ) { 54 if ( ! exitHelp ) {
55 55
56 KGlobal::setAppName( "kaddressbook" ); 56 KGlobal::setAppName( "kaddressbook" );
57#ifndef DESKTOP_VERSION 57#ifndef DESKTOP_VERSION
58 if ( QApplication::desktop()->width() > 320 ) 58 if ( QApplication::desktop()->width() > 320 )
59 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 59 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
60 else 60 else
61 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 61 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
62#else 62#else
63 QString fileName ; 63 QString fileName ;
64 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; 64 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
65 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 65 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
66 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 66 QApplication::addLibraryPath ( qApp->applicationDirPath () );
67 67
68#endif 68#endif
69 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 69 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
70 KAddressBookMain m ; 70 KAddressBookMain m ;
71//US MainWindow m; 71//US MainWindow m;
72 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 72 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
73 73
74 {
75 KConfig kon ( locateLocal( "config", "korganizerrc" ) );
76 kon.setGroup("Locale");
77 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) );
78 QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( "");
79 KGlobal::locale()->setHore24Format( !kon.readBoolEntry( "PreferredTime",0 ) );
80 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
81 dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" );
82 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
83 kon.setGroup("Time & Date");
84 KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ),
85 kon.readNumEntry( "DaylightsavingStart", 90),
86 kon.readNumEntry( "DaylightsavingEnd",304) );
87 KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") );
88 }
74#ifndef DESKTOP_VERSION 89#ifndef DESKTOP_VERSION
75 a.showMainWidget( &m ); 90 a.showMainWidget( &m );
76#else 91#else
77 a.setMainWidget( &m ); 92 a.setMainWidget( &m );
78 m.resize (640, 480 ); 93 m.resize (640, 480 );
79 m.show(); 94 m.show();
80#endif 95#endif
81 a.exec(); 96 a.exec();
82 97
83 } 98 }
84 qDebug("KA: Bye! "); 99 qDebug("KA: Bye! ");
85} 100}
86 101
87/* 102/*
88#include <stdlib.h> 103#include <stdlib.h>
89 104
90#include <qstring.h> 105#include <qstring.h>
91 106
92#include <kabc/stdaddressbook.h> 107#include <kabc/stdaddressbook.h>
93#include <kaboutdata.h> 108#include <kaboutdata.h>
94#include <kcmdlineargs.h> 109#include <kcmdlineargs.h>
95#include <kcrash.h> 110#include <kcrash.h>
96#include <kdebug.h> 111#include <kdebug.h>
97#include <klocale.h> 112#include <klocale.h>
diff --git a/kaddressbook/nameeditdialog.cpp b/kaddressbook/nameeditdialog.cpp
index fb7eb22..8213c2b 100644
--- a/kaddressbook/nameeditdialog.cpp
+++ b/kaddressbook/nameeditdialog.cpp
@@ -88,49 +88,49 @@ NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type,
88 label->setBuddy( mFamilyNameEdit ); 88 label->setBuddy( mFamilyNameEdit );
89 layout->addMultiCellWidget( mFamilyNameEdit, 3, 3, 1, 2 ); 89 layout->addMultiCellWidget( mFamilyNameEdit, 3, 3, 1, 2 );
90 90
91 label = new QLabel( i18n( "Honorific suffixes:" ), page ); 91 label = new QLabel( i18n( "Honorific suffixes:" ), page );
92 layout->addWidget( label, 4, 0 ); 92 layout->addWidget( label, 4, 0 );
93 mSuffixCombo = new KComboBox( page ); 93 mSuffixCombo = new KComboBox( page );
94 mSuffixCombo->setDuplicatesEnabled( false ); 94 mSuffixCombo->setDuplicatesEnabled( false );
95 mSuffixCombo->setEditable( true ); 95 mSuffixCombo->setEditable( true );
96 label->setBuddy( mSuffixCombo ); 96 label->setBuddy( mSuffixCombo );
97 layout->addMultiCellWidget( mSuffixCombo, 4, 4, 1, 2 ); 97 layout->addMultiCellWidget( mSuffixCombo, 4, 4, 1, 2 );
98 98
99 mFormattedNameCombo = new KComboBox( page ); 99 mFormattedNameCombo = new KComboBox( page );
100 mFormattedNameCombo->setMaximumWidth(100); 100 mFormattedNameCombo->setMaximumWidth(100);
101 101
102 layout->addMultiCellWidget( mFormattedNameCombo, 5, 5, 0, 0 ); 102 layout->addMultiCellWidget( mFormattedNameCombo, 5, 5, 0, 0 );
103 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( typeChanged( int ) ) ); 103 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( typeChanged( int ) ) );
104 104
105 mFormattedNameEdit = new KLineEdit( page ); 105 mFormattedNameEdit = new KLineEdit( page );
106 mFormattedNameEdit->setEnabled( type == CustomName ); 106 mFormattedNameEdit->setEnabled( type == CustomName );
107 layout->addMultiCellWidget( mFormattedNameEdit, 5, 5, 1, 2 ); 107 layout->addMultiCellWidget( mFormattedNameEdit, 5, 5, 1, 2 );
108 108
109 mParseBox = new QCheckBox( i18n( "Parse name automatically" ), page ); 109 mParseBox = new QCheckBox( i18n( "Parse name automatically" ), page );
110 connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( parseBoxChanged(bool) ) ); 110 connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( parseBoxChanged(bool) ) );
111 connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( modified() ) ); 111 connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( modified() ) );
112 layout->addMultiCellWidget( mParseBox, 6, 6, 0, 1 ); 112 layout->addMultiCellWidget( mParseBox, 6, 6, 0, 2 );
113 113
114 // Fill in the values 114 // Fill in the values
115 mFamilyNameEdit->setText( addr.familyName() ); 115 mFamilyNameEdit->setText( addr.familyName() );
116 mGivenNameEdit->setText( addr.givenName() ); 116 mGivenNameEdit->setText( addr.givenName() );
117 mAdditionalNameEdit->setText( addr.additionalName() ); 117 mAdditionalNameEdit->setText( addr.additionalName() );
118 mFormattedNameEdit->setText( addr.formattedName() ); 118 mFormattedNameEdit->setText( addr.formattedName() );
119 119
120 // Prefix and suffix combos 120 // Prefix and suffix combos
121//US KConfig config( "kabcrc" ); 121//US KConfig config( "kabcrc" );
122 KConfig config( locateLocal("config", "kabcrc") ); 122 KConfig config( locateLocal("config", "kabcrc") );
123 config.setGroup( "General" ); 123 config.setGroup( "General" );
124 124
125 QStringList sTitle; 125 QStringList sTitle;
126 sTitle += i18n( "Dr." ); 126 sTitle += i18n( "Dr." );
127 sTitle += i18n( "Miss" ); 127 sTitle += i18n( "Miss" );
128 sTitle += i18n( "Mr." ); 128 sTitle += i18n( "Mr." );
129 sTitle += i18n( "Mrs." ); 129 sTitle += i18n( "Mrs." );
130 sTitle += i18n( "Ms." ); 130 sTitle += i18n( "Ms." );
131 sTitle += i18n( "Prof." ); 131 sTitle += i18n( "Prof." );
132 sTitle += config.readListEntry( "Prefixes" ); 132 sTitle += config.readListEntry( "Prefixes" );
133 sTitle.sort(); 133 sTitle.sort();
134 134
135 QStringList sSuffix; 135 QStringList sSuffix;
136 sSuffix += i18n( "I" ); 136 sSuffix += i18n( "I" );
@@ -154,52 +154,49 @@ NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type,
154 154
155 AddresseeConfig::instance()->setUid( addr.uid() ); 155 AddresseeConfig::instance()->setUid( addr.uid() );
156 mParseBox->setChecked( AddresseeConfig::instance()->automaticNameParsing() ); 156 mParseBox->setChecked( AddresseeConfig::instance()->automaticNameParsing() );
157 157
158#ifndef KAB_EMBEDDED 158#ifndef KAB_EMBEDDED
159 KAcceleratorManager::manage( this ); 159 KAcceleratorManager::manage( this );
160#endif //KAB_EMBEDDED 160#endif //KAB_EMBEDDED
161 161
162 connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 162 connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
163 connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 163 connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
164 connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 164 connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
165 connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 165 connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
166 connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 166 connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
167 connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 167 connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
168 connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 168 connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
169 connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 169 connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
170 connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 170 connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
171 connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 171 connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
172 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( modified() ) ); 172 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( modified() ) );
173 connect( mFormattedNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 173 connect( mFormattedNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
174 174
175 updateTypeCombo(); 175 updateTypeCombo();
176 mFormattedNameCombo->setCurrentItem( type ); 176 mFormattedNameCombo->setCurrentItem( type );
177 177
178#ifdef KAB_EMBEDDED 178
179 resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300));
180#endif //KAB_EMBEDDED
181
182 mChanged = false; 179 mChanged = false;
183} 180}
184 181
185NameEditDialog::~NameEditDialog() 182NameEditDialog::~NameEditDialog()
186{ 183{
187} 184}
188 185
189QString NameEditDialog::familyName() const 186QString NameEditDialog::familyName() const
190{ 187{
191 return mFamilyNameEdit->text(); 188 return mFamilyNameEdit->text();
192} 189}
193 190
194QString NameEditDialog::givenName() const 191QString NameEditDialog::givenName() const
195{ 192{
196 return mGivenNameEdit->text(); 193 return mGivenNameEdit->text();
197} 194}
198 195
199QString NameEditDialog::prefix() const 196QString NameEditDialog::prefix() const
200{ 197{
201 return mPrefixCombo->currentText(); 198 return mPrefixCombo->currentText();
202} 199}
203 200
204QString NameEditDialog::suffix() const 201QString NameEditDialog::suffix() const
205{ 202{