-rw-r--r-- | kaddressbook/kabcore.cpp | 1 |
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 | |||
@@ -1167,192 +1167,193 @@ void KABCore::incrementalSearch( const QString& text ) | |||
1167 | { | 1167 | { |
1168 | QString stext; | 1168 | QString stext; |
1169 | if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { | 1169 | if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { |
1170 | stext = "*" + text; | 1170 | stext = "*" + text; |
1171 | } else { | 1171 | } else { |
1172 | stext = text; | 1172 | stext = text; |
1173 | } | 1173 | } |
1174 | mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); | 1174 | mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); |
1175 | } | 1175 | } |
1176 | 1176 | ||
1177 | void KABCore::setModified() | 1177 | void KABCore::setModified() |
1178 | { | 1178 | { |
1179 | setModified( true ); | 1179 | setModified( true ); |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | void KABCore::setModifiedWOrefresh() | 1182 | void KABCore::setModifiedWOrefresh() |
1183 | { | 1183 | { |
1184 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1184 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1185 | mModified = true; | 1185 | mModified = true; |
1186 | mActionSave->setEnabled( mModified ); | 1186 | mActionSave->setEnabled( mModified ); |
1187 | 1187 | ||
1188 | 1188 | ||
1189 | } | 1189 | } |
1190 | void KABCore::setModified( bool modified ) | 1190 | void KABCore::setModified( bool modified ) |
1191 | { | 1191 | { |
1192 | mModified = modified; | 1192 | mModified = modified; |
1193 | mActionSave->setEnabled( mModified ); | 1193 | mActionSave->setEnabled( mModified ); |
1194 | 1194 | ||
1195 | if ( modified ) | 1195 | if ( modified ) |
1196 | mJumpButtonBar->recreateButtons(); | 1196 | mJumpButtonBar->recreateButtons(); |
1197 | 1197 | ||
1198 | mViewManager->refreshView(); | 1198 | mViewManager->refreshView(); |
1199 | 1199 | ||
1200 | } | 1200 | } |
1201 | 1201 | ||
1202 | bool KABCore::modified() const | 1202 | bool KABCore::modified() const |
1203 | { | 1203 | { |
1204 | return mModified; | 1204 | return mModified; |
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1207 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1208 | { | 1208 | { |
1209 | addrModified( addr ); | 1209 | addrModified( addr ); |
1210 | #if 0 // debug only | 1210 | #if 0 // debug only |
1211 | KABC::Addressee ad = addr; | 1211 | KABC::Addressee ad = addr; |
1212 | ad.computeCsum( "123"); | 1212 | ad.computeCsum( "123"); |
1213 | #endif | 1213 | #endif |
1214 | } | 1214 | } |
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 | } |
1311 | void KABCore::importFromOL() | 1312 | void KABCore::importFromOL() |
1312 | { | 1313 | { |
1313 | #ifdef _OL_IMPORT_ | 1314 | #ifdef _OL_IMPORT_ |
1314 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1315 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1315 | idgl->exec(); | 1316 | idgl->exec(); |
1316 | KABC::Addressee::List list = idgl->getAddressList(); | 1317 | KABC::Addressee::List list = idgl->getAddressList(); |
1317 | if ( list.count() > 0 ) { | 1318 | if ( list.count() > 0 ) { |
1318 | KABC::Addressee::List listNew; | 1319 | KABC::Addressee::List listNew; |
1319 | KABC::Addressee::List listExisting; | 1320 | KABC::Addressee::List listExisting; |
1320 | KABC::Addressee::List::Iterator it; | 1321 | KABC::Addressee::List::Iterator it; |
1321 | KABC::AddressBook::Iterator iter; | 1322 | KABC::AddressBook::Iterator iter; |
1322 | for ( it = list.begin(); it != list.end(); ++it ) { | 1323 | for ( it = list.begin(); it != list.end(); ++it ) { |
1323 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1324 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1324 | listNew.append( (*it) ); | 1325 | listNew.append( (*it) ); |
1325 | else | 1326 | else |
1326 | listExisting.append( (*it) ); | 1327 | listExisting.append( (*it) ); |
1327 | } | 1328 | } |
1328 | if ( listExisting.count() > 0 ) | 1329 | if ( listExisting.count() > 0 ) |
1329 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1330 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1330 | if ( listNew.count() > 0 ) { | 1331 | if ( listNew.count() > 0 ) { |
1331 | pasteWithNewUid = false; | 1332 | pasteWithNewUid = false; |
1332 | pasteContacts( listNew ); | 1333 | pasteContacts( listNew ); |
1333 | pasteWithNewUid = true; | 1334 | pasteWithNewUid = true; |
1334 | } | 1335 | } |
1335 | } | 1336 | } |
1336 | delete idgl; | 1337 | delete idgl; |
1337 | #endif | 1338 | #endif |
1338 | } | 1339 | } |
1339 | 1340 | ||
1340 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1341 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1341 | { | 1342 | { |
1342 | mXXPortManager->importVCard( vCard, showPreview ); | 1343 | mXXPortManager->importVCard( vCard, showPreview ); |
1343 | } | 1344 | } |
1344 | 1345 | ||
1345 | //US added a second method without defaultparameter | 1346 | //US added a second method without defaultparameter |
1346 | void KABCore::editContact2() { | 1347 | void KABCore::editContact2() { |
1347 | editContact( QString::null ); | 1348 | editContact( QString::null ); |
1348 | } | 1349 | } |
1349 | 1350 | ||
1350 | void KABCore::editContact( const QString &uid ) | 1351 | void KABCore::editContact( const QString &uid ) |
1351 | { | 1352 | { |
1352 | 1353 | ||
1353 | if ( mExtensionManager->isQuickEditVisible() ) | 1354 | if ( mExtensionManager->isQuickEditVisible() ) |
1354 | return; | 1355 | return; |
1355 | 1356 | ||
1356 | // First, locate the contact entry | 1357 | // First, locate the contact entry |
1357 | QString localUID = uid; | 1358 | QString localUID = uid; |
1358 | if ( localUID.isNull() ) { | 1359 | if ( localUID.isNull() ) { |