summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp1
1 files changed, 1 insertions, 0 deletions
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
1216void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1216void 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
1238void KABCore::newContact() 1238void 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
1273void KABCore::addEmail( QString aStr ) 1274void 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
1307void KABCore::importVCard( const KURL &url, bool showPreview ) 1308void KABCore::importVCard( const KURL &url, bool showPreview )
1308{ 1309{
1309 mXXPortManager->importVCard( url, showPreview ); 1310 mXXPortManager->importVCard( url, showPreview );
1310} 1311}