-rw-r--r-- | kaddressbook/addresseeeditordialog.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/kaddressbook/addresseeeditordialog.cpp b/kaddressbook/addresseeeditordialog.cpp index a84fc61..b5a60f2 100644 --- a/kaddressbook/addresseeeditordialog.cpp +++ b/kaddressbook/addresseeeditordialog.cpp | |||
@@ -22,97 +22,97 @@ | |||
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 | //emit editorDestroyed( mEditorWidget->addressee().uid() ); | 61 | //emit editorDestroyed( mEditorWidget->addressee().uid() ); |
62 | } | 62 | } |
63 | 63 | ||
64 | void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) | 64 | void AddresseeEditorDialog::setAddressee( const KABC::Addressee &addr ) |
65 | { | 65 | { |
66 | enableButton( KDialogBase::Apply, false ); | 66 | enableButton( KDialogBase::Apply, false ); |
67 | 67 | ||
68 | mEditorWidget->setAddressee( addr ); | 68 | mEditorWidget->setAddressee( addr ); |
69 | 69 | ||
70 | this->setCaption("Edit " + addr.formattedName()); | 70 | this->setCaption(i18n ("Edit ") + addr.formattedName()); |
71 | } | 71 | } |
72 | 72 | ||
73 | KABC::Addressee AddresseeEditorDialog::addressee() | 73 | KABC::Addressee AddresseeEditorDialog::addressee() |
74 | { | 74 | { |
75 | return mEditorWidget->addressee(); | 75 | return mEditorWidget->addressee(); |
76 | } | 76 | } |
77 | 77 | ||
78 | bool AddresseeEditorDialog::dirty() | 78 | bool AddresseeEditorDialog::dirty() |
79 | { | 79 | { |
80 | return mEditorWidget->dirty(); | 80 | return mEditorWidget->dirty(); |
81 | } | 81 | } |
82 | 82 | ||
83 | void AddresseeEditorDialog::slotApply() | 83 | void AddresseeEditorDialog::slotApply() |
84 | { | 84 | { |
85 | if ( mEditorWidget->dirty() ) { | 85 | if ( mEditorWidget->dirty() ) { |
86 | mEditorWidget->save(); | 86 | mEditorWidget->save(); |
87 | emit contactModified( mEditorWidget->addressee() ); | 87 | emit contactModified( mEditorWidget->addressee() ); |
88 | } | 88 | } |
89 | 89 | ||
90 | enableButton( KDialogBase::Apply, false ); | 90 | enableButton( KDialogBase::Apply, false ); |
91 | 91 | ||
92 | KDialogBase::slotApply(); | 92 | KDialogBase::slotApply(); |
93 | } | 93 | } |
94 | 94 | ||
95 | void AddresseeEditorDialog:: accept () | 95 | void AddresseeEditorDialog:: accept () |
96 | { | 96 | { |
97 | slotOk(); | 97 | slotOk(); |
98 | 98 | ||
99 | } | 99 | } |
100 | void AddresseeEditorDialog::slotOk() | 100 | void AddresseeEditorDialog::slotOk() |
101 | { | 101 | { |
102 | slotApply(); | 102 | slotApply(); |
103 | 103 | ||
104 | //KDialogBase::slotOk(); | 104 | //KDialogBase::slotOk(); |
105 | emit okClicked(); | 105 | emit okClicked(); |
106 | QDialog::accept(); | 106 | QDialog::accept(); |
107 | } | 107 | } |
108 | 108 | ||
109 | void AddresseeEditorDialog::widgetModified() | 109 | void AddresseeEditorDialog::widgetModified() |
110 | { | 110 | { |
111 | enableButton( KDialogBase::Apply, true ); | 111 | enableButton( KDialogBase::Apply, true ); |
112 | } | 112 | } |
113 | 113 | ||
114 | void AddresseeEditorDialog::slotCancel() | 114 | void AddresseeEditorDialog::slotCancel() |
115 | { | 115 | { |
116 | KDialogBase::slotCancel(); | 116 | KDialogBase::slotCancel(); |
117 | 117 | ||
118 | 118 | ||
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 3f9b546..e1a490d 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1215,96 +1215,97 @@ void KABCore::contactModified( const KABC::Addressee &addr ) | |||
1215 | 1215 | ||
1216 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | 1216 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) |
1217 | { | 1217 | { |
1218 | 1218 | ||
1219 | Command *command = 0; | 1219 | Command *command = 0; |
1220 | QString uid; | 1220 | QString uid; |
1221 | 1221 | ||
1222 | // check if it exists already | 1222 | // check if it exists already |
1223 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1223 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1224 | if ( origAddr.isEmpty() ) | 1224 | if ( origAddr.isEmpty() ) |
1225 | command = new PwNewCommand( mAddressBook, addr ); | 1225 | command = new PwNewCommand( mAddressBook, addr ); |
1226 | else { | 1226 | else { |
1227 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1227 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1228 | uid = addr.uid(); | 1228 | uid = addr.uid(); |
1229 | } | 1229 | } |
1230 | 1230 | ||
1231 | UndoStack::instance()->push( command ); | 1231 | UndoStack::instance()->push( command ); |
1232 | RedoStack::instance()->clear(); | 1232 | RedoStack::instance()->clear(); |
1233 | if ( updateDetails ) | 1233 | if ( updateDetails ) |
1234 | mDetails->setAddressee( addr ); | 1234 | mDetails->setAddressee( addr ); |
1235 | setModified( true ); | 1235 | setModified( true ); |
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | void KABCore::newContact() | 1238 | void KABCore::newContact() |
1239 | { | 1239 | { |
1240 | 1240 | ||
1241 | 1241 | ||
1242 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1242 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1243 | 1243 | ||
1244 | QPtrList<KRES::Resource> kresResources; | 1244 | QPtrList<KRES::Resource> kresResources; |
1245 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1245 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1246 | KABC::Resource *resource; | 1246 | KABC::Resource *resource; |
1247 | while ( ( resource = it.current() ) != 0 ) { | 1247 | while ( ( resource = it.current() ) != 0 ) { |
1248 | ++it; | 1248 | ++it; |
1249 | if ( !resource->readOnly() ) { | 1249 | if ( !resource->readOnly() ) { |
1250 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1250 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1251 | if ( res ) | 1251 | if ( res ) |
1252 | kresResources.append( res ); | 1252 | kresResources.append( res ); |
1253 | } | 1253 | } |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1256 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1257 | resource = static_cast<KABC::Resource*>( res ); | 1257 | resource = static_cast<KABC::Resource*>( res ); |
1258 | 1258 | ||
1259 | if ( resource ) { | 1259 | if ( resource ) { |
1260 | KABC::Addressee addr; | 1260 | KABC::Addressee addr; |
1261 | addr.setResource( resource ); | 1261 | addr.setResource( resource ); |
1262 | mEditorDialog->setAddressee( addr ); | 1262 | mEditorDialog->setAddressee( addr ); |
1263 | mEditorDialog->setCaption( i18n("Edit new contact")); | ||
1263 | KApplication::execDialog ( mEditorDialog ); | 1264 | KApplication::execDialog ( mEditorDialog ); |
1264 | 1265 | ||
1265 | } else | 1266 | } else |
1266 | return; | 1267 | return; |
1267 | 1268 | ||
1268 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1269 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1269 | 1270 | ||
1270 | 1271 | ||
1271 | } | 1272 | } |
1272 | 1273 | ||
1273 | void KABCore::addEmail( QString aStr ) | 1274 | void KABCore::addEmail( QString aStr ) |
1274 | { | 1275 | { |
1275 | #ifndef KAB_EMBEDDED | 1276 | #ifndef KAB_EMBEDDED |
1276 | QString fullName, email; | 1277 | QString fullName, email; |
1277 | 1278 | ||
1278 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1279 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1279 | 1280 | ||
1280 | // Try to lookup the addressee matching the email address | 1281 | // Try to lookup the addressee matching the email address |
1281 | bool found = false; | 1282 | bool found = false; |
1282 | QStringList emailList; | 1283 | QStringList emailList; |
1283 | KABC::AddressBook::Iterator it; | 1284 | KABC::AddressBook::Iterator it; |
1284 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1285 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1285 | emailList = (*it).emails(); | 1286 | emailList = (*it).emails(); |
1286 | if ( emailList.contains( email ) > 0 ) { | 1287 | if ( emailList.contains( email ) > 0 ) { |
1287 | found = true; | 1288 | found = true; |
1288 | (*it).setNameFromString( fullName ); | 1289 | (*it).setNameFromString( fullName ); |
1289 | editContact( (*it).uid() ); | 1290 | editContact( (*it).uid() ); |
1290 | } | 1291 | } |
1291 | } | 1292 | } |
1292 | 1293 | ||
1293 | if ( !found ) { | 1294 | if ( !found ) { |
1294 | KABC::Addressee addr; | 1295 | KABC::Addressee addr; |
1295 | addr.setNameFromString( fullName ); | 1296 | addr.setNameFromString( fullName ); |
1296 | addr.insertEmail( email, true ); | 1297 | addr.insertEmail( email, true ); |
1297 | 1298 | ||
1298 | mAddressBook->insertAddressee( addr ); | 1299 | mAddressBook->insertAddressee( addr ); |
1299 | mViewManager->refreshView( addr.uid() ); | 1300 | mViewManager->refreshView( addr.uid() ); |
1300 | editContact( addr.uid() ); | 1301 | editContact( addr.uid() ); |
1301 | } | 1302 | } |
1302 | #else //KAB_EMBEDDED | 1303 | #else //KAB_EMBEDDED |
1303 | qDebug("KABCore::addEmail finsih method"); | 1304 | qDebug("KABCore::addEmail finsih method"); |
1304 | #endif //KAB_EMBEDDED | 1305 | #endif //KAB_EMBEDDED |
1305 | } | 1306 | } |
1306 | 1307 | ||
1307 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1308 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1308 | { | 1309 | { |
1309 | mXXPortManager->importVCard( url, showPreview ); | 1310 | mXXPortManager->importVCard( url, showPreview ); |
1310 | } | 1311 | } |