author | ulf69 <ulf69> | 2004-07-09 08:02:25 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-09 08:02:25 (UTC) |
commit | d91c533ffc42d7bf48fa1326754894b2c30b6831 (patch) (unidiff) | |
tree | ba1eada897522030f17ccdf1afd4d4d96a65464e /kaddressbook | |
parent | 82dabc14cc446fb8c0486cd4c32064e3866d2be9 (diff) | |
download | kdepimpi-d91c533ffc42d7bf48fa1326754894b2c30b6831.zip kdepimpi-d91c533ffc42d7bf48fa1326754894b2c30b6831.tar.gz kdepimpi-d91c533ffc42d7bf48fa1326754894b2c30b6831.tar.bz2 |
changed the IntDateFormat from type int to enum, for easier categorization
-rw-r--r-- | kaddressbook/addresseeeditordialog.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/addresseeeditorwidget.cpp | 6 |
2 files changed, 1 insertions, 6 deletions
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp index d8c1aca..5e42640 100644 --- a/kaddressbook/addresseeeditordialog.cpp +++ b/kaddressbook/addresseeeditordialog.cpp | |||
@@ -1,122 +1,121 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qapplication.h> | 25 | #include <qapplication.h> |
26 | 26 | ||
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | #include <klocale.h> | 28 | #include <klocale.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | 30 | ||
31 | #include "addresseeeditorwidget.h" | 31 | #include "addresseeeditorwidget.h" |
32 | #include "kabcore.h" | 32 | #include "kabcore.h" |
33 | 33 | ||
34 | #include "addresseeeditordialog.h" | 34 | #include "addresseeeditordialog.h" |
35 | 35 | ||
36 | AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, | 36 | AddresseeEditorDialog::AddresseeEditorDialog( KABCore *core, QWidget *parent, |
37 | const char *name ) | 37 | const char *name ) |
38 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), | 38 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Contact" ), |
39 | KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, | 39 | KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply, |
40 | KDialogBase::Ok, parent, name, true ) | 40 | KDialogBase::Ok, parent, name, true ) |
41 | { | 41 | { |
42 | 42 | ||
43 | 43 | ||
44 | QWidget *page = plainPage(); | 44 | QWidget *page = plainPage(); |
45 | 45 | ||
46 | QVBoxLayout *layout = new QVBoxLayout( page ); | 46 | QVBoxLayout *layout = new QVBoxLayout( page ); |
47 | 47 | ||
48 | mEditorWidget = new AddresseeEditorWidget( core, false, page ); | 48 | mEditorWidget = new AddresseeEditorWidget( core, false, page ); |
49 | connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ), | 49 | connect( mEditorWidget, SIGNAL( modified( const KABC::Addressee::List& ) ), |
50 | SLOT( widgetModified() ) ); | 50 | SLOT( widgetModified() ) ); |
51 | layout->addWidget( mEditorWidget ); | 51 | layout->addWidget( mEditorWidget ); |
52 | 52 | ||
53 | enableButton( KDialogBase::Apply, false ); | 53 | enableButton( KDialogBase::Apply, false ); |
54 | if ( QApplication::desktop()->width() < 480 ) { | 54 | if ( QApplication::desktop()->width() < 480 ) { |
55 | hideButtons(); | 55 | hideButtons(); |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
59 | AddresseeEditorDialog::~AddresseeEditorDialog() | 59 | AddresseeEditorDialog::~AddresseeEditorDialog() |
60 | { | 60 | { |
61 | qDebug("AddresseeEditorDialog::~AddresseeEditorDialog()"); | ||
62 | //emit editorDestroyed( mEditorWidget->addressee().uid() ); | 61 | //emit editorDestroyed( mEditorWidget->addressee().uid() ); |
63 | } | 62 | } |
64 | 63 | ||
65 | void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) | 64 | void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) |
66 | { | 65 | { |
67 | enableButton( KDialogBase::Apply, false ); | 66 | enableButton( KDialogBase::Apply, false ); |
68 | 67 | ||
69 | mEditorWidget->setAddressee( addr ); | 68 | mEditorWidget->setAddressee( addr ); |
70 | } | 69 | } |
71 | 70 | ||
72 | KABC::Addressee AddresseeEditorDialog::addressee() | 71 | KABC::Addressee AddresseeEditorDialog::addressee() |
73 | { | 72 | { |
74 | return mEditorWidget->addressee(); | 73 | return mEditorWidget->addressee(); |
75 | } | 74 | } |
76 | 75 | ||
77 | bool AddresseeEditorDialog::dirty() | 76 | bool AddresseeEditorDialog::dirty() |
78 | { | 77 | { |
79 | return mEditorWidget->dirty(); | 78 | return mEditorWidget->dirty(); |
80 | } | 79 | } |
81 | 80 | ||
82 | void AddresseeEditorDialog::slotApply() | 81 | void AddresseeEditorDialog::slotApply() |
83 | { | 82 | { |
84 | if ( mEditorWidget->dirty() ) { | 83 | if ( mEditorWidget->dirty() ) { |
85 | mEditorWidget->save(); | 84 | mEditorWidget->save(); |
86 | emit contactModified( mEditorWidget->addressee() ); | 85 | emit contactModified( mEditorWidget->addressee() ); |
87 | } | 86 | } |
88 | 87 | ||
89 | enableButton( KDialogBase::Apply, false ); | 88 | enableButton( KDialogBase::Apply, false ); |
90 | 89 | ||
91 | KDialogBase::slotApply(); | 90 | KDialogBase::slotApply(); |
92 | } | 91 | } |
93 | 92 | ||
94 | void AddresseeEditorDialog:: accept () | 93 | void AddresseeEditorDialog:: accept () |
95 | { | 94 | { |
96 | slotOk(); | 95 | slotOk(); |
97 | 96 | ||
98 | } | 97 | } |
99 | void AddresseeEditorDialog::slotOk() | 98 | void AddresseeEditorDialog::slotOk() |
100 | { | 99 | { |
101 | slotApply(); | 100 | slotApply(); |
102 | 101 | ||
103 | //KDialogBase::slotOk(); | 102 | //KDialogBase::slotOk(); |
104 | emit okClicked(); | 103 | emit okClicked(); |
105 | QDialog::accept(); | 104 | QDialog::accept(); |
106 | } | 105 | } |
107 | 106 | ||
108 | void AddresseeEditorDialog::widgetModified() | 107 | void AddresseeEditorDialog::widgetModified() |
109 | { | 108 | { |
110 | enableButton( KDialogBase::Apply, true ); | 109 | enableButton( KDialogBase::Apply, true ); |
111 | } | 110 | } |
112 | 111 | ||
113 | void AddresseeEditorDialog::slotCancel() | 112 | void AddresseeEditorDialog::slotCancel() |
114 | { | 113 | { |
115 | KDialogBase::slotCancel(); | 114 | KDialogBase::slotCancel(); |
116 | 115 | ||
117 | 116 | ||
118 | } | 117 | } |
119 | 118 | ||
120 | #ifndef KAB_EMBEDDED | 119 | #ifndef KAB_EMBEDDED |
121 | #include "addresseeeditordialog.moc" | 120 | #include "addresseeeditordialog.moc" |
122 | #endif //KAB_EMBEDDED | 121 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 4365ee5..3cfc1f2 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp | |||
@@ -940,261 +940,257 @@ void AddresseeEditorWidget::setupTab3_1() | |||
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 | ||
948 | void AddresseeEditorWidget::load() | 948 | void AddresseeEditorWidget::load() |
949 | { | 949 | { |
950 | kdDebug(5720) << "AddresseeEditorWidget::load()" << endl; | 950 | kdDebug(5720) << "AddresseeEditorWidget::load()" << endl; |
951 | 951 | ||
952 | // Block signals in case anything tries to emit modified | 952 | // Block signals in case anything tries to emit modified |
953 | // CS: This doesn't seem to work. | 953 | // CS: This doesn't seem to work. |
954 | bool block = signalsBlocked(); | 954 | bool block = signalsBlocked(); |
955 | blockSignals( true ); | 955 | blockSignals( true ); |
956 | mBlockSignals = true; // used for internal signal blocking | 956 | mBlockSignals = true; // used for internal signal blocking |
957 | 957 | ||
958 | mNameEdit->setText( mAddressee.assembledName() ); | 958 | mNameEdit->setText( mAddressee.assembledName() ); |
959 | 959 | ||
960 | if ( mAddressee.formattedName().isEmpty() ) { | 960 | if ( mAddressee.formattedName().isEmpty() ) { |
961 | //US KConfig config( "kaddressbookrc" ); | 961 | //US KConfig config( "kaddressbookrc" ); |
962 | KConfig config( locateLocal("config", "kaddressbookrc") ); | 962 | KConfig config( locateLocal("config", "kaddressbookrc") ); |
963 | config.setGroup( "General" ); | 963 | config.setGroup( "General" ); |
964 | mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); | 964 | mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); |
965 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); | 965 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); |
966 | } else { | 966 | } else { |
967 | if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) | 967 | if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) |
968 | mFormattedNameType = NameEditDialog::SimpleName; | 968 | mFormattedNameType = NameEditDialog::SimpleName; |
969 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) | 969 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) |
970 | mFormattedNameType = NameEditDialog::FullName; | 970 | mFormattedNameType = NameEditDialog::FullName; |
971 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) | 971 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) |
972 | mFormattedNameType = NameEditDialog::ReverseName; | 972 | mFormattedNameType = NameEditDialog::ReverseName; |
973 | else | 973 | else |
974 | mFormattedNameType = NameEditDialog::CustomName; | 974 | mFormattedNameType = NameEditDialog::CustomName; |
975 | } | 975 | } |
976 | 976 | ||
977 | mFormattedNameLabel->setText( mAddressee.formattedName() ); | 977 | mFormattedNameLabel->setText( mAddressee.formattedName() ); |
978 | 978 | ||
979 | mRoleEdit->setText( mAddressee.role() ); | 979 | mRoleEdit->setText( mAddressee.role() ); |
980 | mOrgEdit->setText( mAddressee.organization() ); | 980 | mOrgEdit->setText( mAddressee.organization() ); |
981 | 981 | ||
982 | //US mURLEdit->setURL( mAddressee.url().url() ); | 982 | //US mURLEdit->setURL( mAddressee.url().url() ); |
983 | mURLEdit->setText( mAddressee.url().prettyURL() ); | 983 | mURLEdit->setText( mAddressee.url().prettyURL() ); |
984 | //US?? mURLEdit->home( false ); | 984 | //US?? mURLEdit->home( false ); |
985 | 985 | ||
986 | // mNoteEdit->setText( mAddressee.note() ); | 986 | // mNoteEdit->setText( mAddressee.note() ); |
987 | mNoteEdit->setText( mAddressee.note() ); | 987 | mNoteEdit->setText( mAddressee.note() ); |
988 | mEmailWidget->setEmails( mAddressee.emails() ); | 988 | mEmailWidget->setEmails( mAddressee.emails() ); |
989 | mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); | 989 | mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); |
990 | mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); | 990 | mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); |
991 | mBirthdayPicker->setDate( mAddressee.birthday().date() ); | 991 | mBirthdayPicker->setDate( mAddressee.birthday().date() ); |
992 | 992 | ||
993 | //US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( | 993 | //US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( |
994 | //US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); | 994 | //US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); |
995 | QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), | 995 | QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), |
996 | "%Y-%m-%d"); // = Qt::ISODate | 996 | "%Y-%m-%d"); // = Qt::ISODate |
997 | mAnniversaryPicker->setDate( dt ); | 997 | mAnniversaryPicker->setDate( dt ); |
998 | 998 | ||
999 | 999 | ||
1000 | mNicknameEdit->setText( mAddressee.nickName() ); | 1000 | mNicknameEdit->setText( mAddressee.nickName() ); |
1001 | mCategoryEdit->setText( mAddressee.categories().join( "," ) ); | 1001 | mCategoryEdit->setText( mAddressee.categories().join( "," ) ); |
1002 | 1002 | ||
1003 | mGeoWidget->setGeo( mAddressee.geo() ); | 1003 | mGeoWidget->setGeo( mAddressee.geo() ); |
1004 | mImageWidget->setPhoto( mAddressee.photo() ); | 1004 | mImageWidget->setPhoto( mAddressee.photo() ); |
1005 | mImageWidget->setLogo( mAddressee.logo() ); | 1005 | mImageWidget->setLogo( mAddressee.logo() ); |
1006 | mKeyWidget->setKeys( mAddressee.keys() ); | 1006 | mKeyWidget->setKeys( mAddressee.keys() ); |
1007 | mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); | 1007 | mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); |
1008 | #ifndef KAB_EMBEDDED | 1008 | #ifndef KAB_EMBEDDED |
1009 | mSoundWidget->setSound( mAddressee.sound() ); | 1009 | mSoundWidget->setSound( mAddressee.sound() ); |
1010 | #else //KAB_EMBEDDED | 1010 | #else //KAB_EMBEDDED |
1011 | //US qDebug("AddresseeEditorWidget::load has to be changed 2"); | 1011 | //US qDebug("AddresseeEditorWidget::load has to be changed 2"); |
1012 | #endif //KAB_EMBEDDED | 1012 | #endif //KAB_EMBEDDED |
1013 | 1013 | ||
1014 | // Load customs | 1014 | // Load customs |
1015 | mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); | 1015 | mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); |
1016 | mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); | 1016 | mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); |
1017 | mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); | 1017 | mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); |
1018 | mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); | 1018 | mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); |
1019 | mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); | 1019 | mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); |
1020 | mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); | 1020 | mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); |
1021 | mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); | 1021 | mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); |
1022 | 1022 | ||
1023 | blockSignals( block ); | 1023 | blockSignals( block ); |
1024 | mBlockSignals = false; | 1024 | mBlockSignals = false; |
1025 | 1025 | ||
1026 | mDirty = false; | 1026 | mDirty = false; |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | void AddresseeEditorWidget::save() | 1029 | void AddresseeEditorWidget::save() |
1030 | { | 1030 | { |
1031 | if ( !mDirty ) return; | 1031 | if ( !mDirty ) return; |
1032 | 1032 | ||
1033 | mAddressee.setRole( mRoleEdit->text() ); | 1033 | mAddressee.setRole( mRoleEdit->text() ); |
1034 | mAddressee.setOrganization( mOrgEdit->text() ); | 1034 | mAddressee.setOrganization( mOrgEdit->text() ); |
1035 | mAddressee.setUrl( KURL( mURLEdit->text() ) ); | 1035 | mAddressee.setUrl( KURL( mURLEdit->text() ) ); |
1036 | mAddressee.setNote( mNoteEdit->text() ); | 1036 | mAddressee.setNote( mNoteEdit->text() ); |
1037 | if ( mBirthdayPicker->inputIsValid() ) | 1037 | if ( mBirthdayPicker->inputIsValid() ) |
1038 | mAddressee.setBirthday( QDateTime( mBirthdayPicker->date() ) ); | 1038 | mAddressee.setBirthday( QDateTime( mBirthdayPicker->date() ) ); |
1039 | else | 1039 | else |
1040 | mAddressee.setBirthday( QDateTime() ); | 1040 | mAddressee.setBirthday( QDateTime() ); |
1041 | 1041 | ||
1042 | mAddressee.setNickName( mNicknameEdit->text() ); | 1042 | mAddressee.setNickName( mNicknameEdit->text() ); |
1043 | mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); | 1043 | mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); |
1044 | 1044 | ||
1045 | mAddressee.setGeo( mGeoWidget->geo() ); | 1045 | mAddressee.setGeo( mGeoWidget->geo() ); |
1046 | mAddressee.setPhoto( mImageWidget->photo() ); | 1046 | mAddressee.setPhoto( mImageWidget->photo() ); |
1047 | mAddressee.setLogo( mImageWidget->logo() ); | 1047 | mAddressee.setLogo( mImageWidget->logo() ); |
1048 | mAddressee.setKeys( mKeyWidget->keys() ); | 1048 | mAddressee.setKeys( mKeyWidget->keys() ); |
1049 | #ifndef KAB_EMBEDDED | 1049 | #ifndef KAB_EMBEDDED |
1050 | mAddressee.setSound( mSoundWidget->sound() ); | 1050 | mAddressee.setSound( mSoundWidget->sound() ); |
1051 | #else //KAB_EMBEDDED | 1051 | #else //KAB_EMBEDDED |
1052 | //US qDebug("AddresseeEditorWidget::save sound not supported"); | 1052 | //US qDebug("AddresseeEditorWidget::save sound not supported"); |
1053 | #endif //KAB_EMBEDDED | 1053 | #endif //KAB_EMBEDDED |
1054 | mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); | 1054 | mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); |
1055 | 1055 | ||
1056 | // save custom fields | 1056 | // save custom fields |
1057 | mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); | 1057 | mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); |
1058 | mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); | 1058 | mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); |
1059 | mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); | 1059 | mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); |
1060 | mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); | 1060 | mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); |
1061 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); | 1061 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); |
1062 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); | 1062 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); |
1063 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); | 1063 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); |
1064 | if ( mAnniversaryPicker->inputIsValid() ) { | 1064 | if ( mAnniversaryPicker->inputIsValid() ) { |
1065 | 1065 | ||
1066 | //US mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", | 1066 | //US mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", |
1067 | //US mAnniversaryPicker->date().toString( Qt::ISODate ) ); | 1067 | //US mAnniversaryPicker->date().toString( Qt::ISODate ) ); |
1068 | int orgformat = KGlobal::locale()->getIntDateFormat(); | 1068 | QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate); |
1069 | QDate da = mAnniversaryPicker->date(); | ||
1070 | KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate | ||
1071 | QString dt = KGlobal::locale()->formatDate(da, true); | ||
1072 | KGlobal::locale()->setIntDateFormat(orgformat ); | ||
1073 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 1069 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
1074 | } | 1070 | } |
1075 | else | 1071 | else |
1076 | mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); | 1072 | mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); |
1077 | 1073 | ||
1078 | // Save the email addresses | 1074 | // Save the email addresses |
1079 | QStringList emails = mAddressee.emails(); | 1075 | QStringList emails = mAddressee.emails(); |
1080 | QStringList::Iterator iter; | 1076 | QStringList::Iterator iter; |
1081 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) | 1077 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) |
1082 | mAddressee.removeEmail( *iter ); | 1078 | mAddressee.removeEmail( *iter ); |
1083 | 1079 | ||
1084 | emails = mEmailWidget->emails(); | 1080 | emails = mEmailWidget->emails(); |
1085 | bool first = true; | 1081 | bool first = true; |
1086 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) { | 1082 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) { |
1087 | mAddressee.insertEmail( *iter, first ); | 1083 | mAddressee.insertEmail( *iter, first ); |
1088 | first = false; | 1084 | first = false; |
1089 | } | 1085 | } |
1090 | 1086 | ||
1091 | // Save the phone numbers | 1087 | // Save the phone numbers |
1092 | KABC::PhoneNumber::List phoneNumbers; | 1088 | KABC::PhoneNumber::List phoneNumbers; |
1093 | KABC::PhoneNumber::List::Iterator phoneIter; | 1089 | KABC::PhoneNumber::List::Iterator phoneIter; |
1094 | phoneNumbers = mAddressee.phoneNumbers(); | 1090 | phoneNumbers = mAddressee.phoneNumbers(); |
1095 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); | 1091 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); |
1096 | ++phoneIter ) | 1092 | ++phoneIter ) |
1097 | mAddressee.removePhoneNumber( *phoneIter ); | 1093 | mAddressee.removePhoneNumber( *phoneIter ); |
1098 | 1094 | ||
1099 | phoneNumbers = mPhoneEditWidget->phoneNumbers(); | 1095 | phoneNumbers = mPhoneEditWidget->phoneNumbers(); |
1100 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); | 1096 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); |
1101 | ++phoneIter ) | 1097 | ++phoneIter ) |
1102 | mAddressee.insertPhoneNumber( *phoneIter ); | 1098 | mAddressee.insertPhoneNumber( *phoneIter ); |
1103 | 1099 | ||
1104 | // Save the addresses | 1100 | // Save the addresses |
1105 | KABC::Address::List addresses; | 1101 | KABC::Address::List addresses; |
1106 | KABC::Address::List::Iterator addressIter; | 1102 | KABC::Address::List::Iterator addressIter; |
1107 | addresses = mAddressee.addresses(); | 1103 | addresses = mAddressee.addresses(); |
1108 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); | 1104 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); |
1109 | ++addressIter ) | 1105 | ++addressIter ) |
1110 | mAddressee.removeAddress( *addressIter ); | 1106 | mAddressee.removeAddress( *addressIter ); |
1111 | 1107 | ||
1112 | addresses = mAddressEditWidget->addresses(); | 1108 | addresses = mAddressEditWidget->addresses(); |
1113 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); | 1109 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); |
1114 | ++addressIter ) | 1110 | ++addressIter ) |
1115 | mAddressee.insertAddress( *addressIter ); | 1111 | mAddressee.insertAddress( *addressIter ); |
1116 | mDirty = false; | 1112 | mDirty = false; |
1117 | } | 1113 | } |
1118 | 1114 | ||
1119 | bool AddresseeEditorWidget::dirty() | 1115 | bool AddresseeEditorWidget::dirty() |
1120 | { | 1116 | { |
1121 | return mDirty; | 1117 | return mDirty; |
1122 | } | 1118 | } |
1123 | 1119 | ||
1124 | void AddresseeEditorWidget::nameTextChanged( const QString &text ) | 1120 | void AddresseeEditorWidget::nameTextChanged( const QString &text ) |
1125 | { | 1121 | { |
1126 | // use the addressee class to parse the name for us | 1122 | // use the addressee class to parse the name for us |
1127 | mAConfig->setUid( mAddressee.uid() ); | 1123 | mAConfig->setUid( mAddressee.uid() ); |
1128 | if ( mAConfig->automaticNameParsing() ) { | 1124 | if ( mAConfig->automaticNameParsing() ) { |
1129 | if ( !mAddressee.formattedName().isEmpty() ) { | 1125 | if ( !mAddressee.formattedName().isEmpty() ) { |
1130 | QString fn = mAddressee.formattedName(); | 1126 | QString fn = mAddressee.formattedName(); |
1131 | mAddressee.setNameFromString( text ); | 1127 | mAddressee.setNameFromString( text ); |
1132 | mAddressee.setFormattedName( fn ); | 1128 | mAddressee.setFormattedName( fn ); |
1133 | } else { | 1129 | } else { |
1134 | // use extra addressee to avoid a formatted name assignment | 1130 | // use extra addressee to avoid a formatted name assignment |
1135 | Addressee addr; | 1131 | Addressee addr; |
1136 | addr.setNameFromString( text ); | 1132 | addr.setNameFromString( text ); |
1137 | mAddressee.setPrefix( addr.prefix() ); | 1133 | mAddressee.setPrefix( addr.prefix() ); |
1138 | mAddressee.setGivenName( addr.givenName() ); | 1134 | mAddressee.setGivenName( addr.givenName() ); |
1139 | mAddressee.setAdditionalName( addr.additionalName() ); | 1135 | mAddressee.setAdditionalName( addr.additionalName() ); |
1140 | mAddressee.setFamilyName( addr.familyName() ); | 1136 | mAddressee.setFamilyName( addr.familyName() ); |
1141 | mAddressee.setSuffix( addr.suffix() ); | 1137 | mAddressee.setSuffix( addr.suffix() ); |
1142 | } | 1138 | } |
1143 | } | 1139 | } |
1144 | 1140 | ||
1145 | nameBoxChanged(); | 1141 | nameBoxChanged(); |
1146 | 1142 | ||
1147 | emitModified(); | 1143 | emitModified(); |
1148 | } | 1144 | } |
1149 | 1145 | ||
1150 | void AddresseeEditorWidget::nameBoxChanged() | 1146 | void AddresseeEditorWidget::nameBoxChanged() |
1151 | { | 1147 | { |
1152 | KABC::Addressee addr; | 1148 | KABC::Addressee addr; |
1153 | mAConfig->setUid( mAddressee.uid() ); | 1149 | mAConfig->setUid( mAddressee.uid() ); |
1154 | if ( mAConfig->automaticNameParsing() ) { | 1150 | if ( mAConfig->automaticNameParsing() ) { |
1155 | addr.setNameFromString( mNameEdit->text() ); | 1151 | addr.setNameFromString( mNameEdit->text() ); |
1156 | mNameLabel->hide(); | 1152 | mNameLabel->hide(); |
1157 | mNameEdit->show(); | 1153 | mNameEdit->show(); |
1158 | } else { | 1154 | } else { |
1159 | addr = mAddressee; | 1155 | addr = mAddressee; |
1160 | mNameEdit->hide(); | 1156 | mNameEdit->hide(); |
1161 | mNameLabel->setText( mNameEdit->text() ); | 1157 | mNameLabel->setText( mNameEdit->text() ); |
1162 | mNameLabel->show(); | 1158 | mNameLabel->show(); |
1163 | } | 1159 | } |
1164 | 1160 | ||
1165 | if ( mFormattedNameType != NameEditDialog::CustomName ) { | 1161 | if ( mFormattedNameType != NameEditDialog::CustomName ) { |
1166 | mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); | 1162 | mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); |
1167 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); | 1163 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); |
1168 | } | 1164 | } |
1169 | } | 1165 | } |
1170 | 1166 | ||
1171 | void AddresseeEditorWidget::nameButtonClicked() | 1167 | void AddresseeEditorWidget::nameButtonClicked() |
1172 | { | 1168 | { |
1173 | // show the name dialog. | 1169 | // show the name dialog. |
1174 | NameEditDialog dialog( mAddressee, mFormattedNameType, this ); | 1170 | NameEditDialog dialog( mAddressee, mFormattedNameType, this ); |
1175 | 1171 | ||
1176 | if ( dialog.exec() ) { | 1172 | if ( dialog.exec() ) { |
1177 | if ( dialog.changed() ) { | 1173 | if ( dialog.changed() ) { |
1178 | mAddressee.setFamilyName( dialog.familyName() ); | 1174 | mAddressee.setFamilyName( dialog.familyName() ); |
1179 | mAddressee.setGivenName( dialog.givenName() ); | 1175 | mAddressee.setGivenName( dialog.givenName() ); |
1180 | mAddressee.setPrefix( dialog.prefix() ); | 1176 | mAddressee.setPrefix( dialog.prefix() ); |
1181 | mAddressee.setSuffix( dialog.suffix() ); | 1177 | mAddressee.setSuffix( dialog.suffix() ); |
1182 | mAddressee.setAdditionalName( dialog.additionalName() ); | 1178 | mAddressee.setAdditionalName( dialog.additionalName() ); |
1183 | mFormattedNameType = dialog.formattedNameType(); | 1179 | mFormattedNameType = dialog.formattedNameType(); |
1184 | if ( mFormattedNameType == NameEditDialog::CustomName ) { | 1180 | if ( mFormattedNameType == NameEditDialog::CustomName ) { |
1185 | mFormattedNameLabel->setText( dialog.customFormattedName() ); | 1181 | mFormattedNameLabel->setText( dialog.customFormattedName() ); |
1186 | mAddressee.setFormattedName( dialog.customFormattedName() ); | 1182 | mAddressee.setFormattedName( dialog.customFormattedName() ); |
1187 | } | 1183 | } |
1188 | // Update the name edit. | 1184 | // Update the name edit. |
1189 | bool block = mNameEdit->signalsBlocked(); | 1185 | bool block = mNameEdit->signalsBlocked(); |
1190 | mNameEdit->blockSignals( true ); | 1186 | mNameEdit->blockSignals( true ); |
1191 | mNameEdit->setText( mAddressee.assembledName() ); | 1187 | mNameEdit->setText( mAddressee.assembledName() ); |
1192 | mNameEdit->blockSignals( block ); | 1188 | mNameEdit->blockSignals( block ); |
1193 | 1189 | ||
1194 | // Update the combo box. | 1190 | // Update the combo box. |
1195 | nameBoxChanged(); | 1191 | nameBoxChanged(); |
1196 | 1192 | ||
1197 | emitModified(); | 1193 | emitModified(); |
1198 | } | 1194 | } |
1199 | } | 1195 | } |
1200 | } | 1196 | } |