summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index ea87929..b0cb986 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -980,1956 +980,1958 @@ void KABCore::setCategories()
980 QStringList addrCategories = addr.categories(); 980 QStringList addrCategories = addr.categories();
981 QStringList::Iterator catIt; 981 QStringList::Iterator catIt;
982 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 982 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
983 if ( !addrCategories.contains( *catIt ) ) 983 if ( !addrCategories.contains( *catIt ) )
984 addrCategories.append( *catIt ); 984 addrCategories.append( *catIt );
985 } 985 }
986 addr.setCategories( addrCategories ); 986 addr.setCategories( addrCategories );
987 } 987 }
988 988
989 mAddressBook->insertAddressee( addr ); 989 mAddressBook->insertAddressee( addr );
990 } 990 }
991 } 991 }
992 992
993 if ( uids.count() > 0 ) 993 if ( uids.count() > 0 )
994 setModified( true ); 994 setModified( true );
995} 995}
996 996
997void KABCore::setSearchFields( const KABC::Field::List &fields ) 997void KABCore::setSearchFields( const KABC::Field::List &fields )
998{ 998{
999 mIncSearchWidget->setFields( fields ); 999 mIncSearchWidget->setFields( fields );
1000} 1000}
1001 1001
1002void KABCore::incrementalSearch( const QString& text ) 1002void KABCore::incrementalSearch( const QString& text )
1003{ 1003{
1004 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1004 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1005} 1005}
1006 1006
1007void KABCore::setModified() 1007void KABCore::setModified()
1008{ 1008{
1009 setModified( true ); 1009 setModified( true );
1010} 1010}
1011 1011
1012void KABCore::setModifiedWOrefresh() 1012void KABCore::setModifiedWOrefresh()
1013{ 1013{
1014 // qDebug("KABCore::setModifiedWOrefresh() "); 1014 // qDebug("KABCore::setModifiedWOrefresh() ");
1015 mModified = true; 1015 mModified = true;
1016 mActionSave->setEnabled( mModified ); 1016 mActionSave->setEnabled( mModified );
1017#ifdef DESKTOP_VERSION 1017#ifdef DESKTOP_VERSION
1018 mDetails->refreshView(); 1018 mDetails->refreshView();
1019#endif 1019#endif
1020 1020
1021} 1021}
1022void KABCore::setModified( bool modified ) 1022void KABCore::setModified( bool modified )
1023{ 1023{
1024 mModified = modified; 1024 mModified = modified;
1025 mActionSave->setEnabled( mModified ); 1025 mActionSave->setEnabled( mModified );
1026 1026
1027 if ( modified ) 1027 if ( modified )
1028 mJumpButtonBar->recreateButtons(); 1028 mJumpButtonBar->recreateButtons();
1029 1029
1030 mViewManager->refreshView(); 1030 mViewManager->refreshView();
1031 mDetails->refreshView(); 1031 mDetails->refreshView();
1032 1032
1033} 1033}
1034 1034
1035bool KABCore::modified() const 1035bool KABCore::modified() const
1036{ 1036{
1037 return mModified; 1037 return mModified;
1038} 1038}
1039 1039
1040void KABCore::contactModified( const KABC::Addressee &addr ) 1040void KABCore::contactModified( const KABC::Addressee &addr )
1041{ 1041{
1042 1042
1043 Command *command = 0; 1043 Command *command = 0;
1044 QString uid; 1044 QString uid;
1045 1045
1046 // check if it exists already 1046 // check if it exists already
1047 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1047 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1048 if ( origAddr.isEmpty() ) 1048 if ( origAddr.isEmpty() )
1049 command = new PwNewCommand( mAddressBook, addr ); 1049 command = new PwNewCommand( mAddressBook, addr );
1050 else { 1050 else {
1051 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1051 command = new PwEditCommand( mAddressBook, origAddr, addr );
1052 uid = addr.uid(); 1052 uid = addr.uid();
1053 } 1053 }
1054 1054
1055 UndoStack::instance()->push( command ); 1055 UndoStack::instance()->push( command );
1056 RedoStack::instance()->clear(); 1056 RedoStack::instance()->clear();
1057 1057
1058 setModified( true ); 1058 setModified( true );
1059} 1059}
1060 1060
1061void KABCore::newContact() 1061void KABCore::newContact()
1062{ 1062{
1063 1063
1064 1064
1065 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1065 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1066 1066
1067 QPtrList<KRES::Resource> kresResources; 1067 QPtrList<KRES::Resource> kresResources;
1068 QPtrListIterator<KABC::Resource> it( kabcResources ); 1068 QPtrListIterator<KABC::Resource> it( kabcResources );
1069 KABC::Resource *resource; 1069 KABC::Resource *resource;
1070 while ( ( resource = it.current() ) != 0 ) { 1070 while ( ( resource = it.current() ) != 0 ) {
1071 ++it; 1071 ++it;
1072 if ( !resource->readOnly() ) { 1072 if ( !resource->readOnly() ) {
1073 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1073 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1074 if ( res ) 1074 if ( res )
1075 kresResources.append( res ); 1075 kresResources.append( res );
1076 } 1076 }
1077 } 1077 }
1078 1078
1079 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1079 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1080 resource = static_cast<KABC::Resource*>( res ); 1080 resource = static_cast<KABC::Resource*>( res );
1081 1081
1082 if ( resource ) { 1082 if ( resource ) {
1083 KABC::Addressee addr; 1083 KABC::Addressee addr;
1084 addr.setResource( resource ); 1084 addr.setResource( resource );
1085 mEditorDialog->setAddressee( addr ); 1085 mEditorDialog->setAddressee( addr );
1086 KApplication::execDialog ( mEditorDialog ); 1086 KApplication::execDialog ( mEditorDialog );
1087 1087
1088 } else 1088 } else
1089 return; 1089 return;
1090 1090
1091 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1091 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1092 1092
1093 1093
1094} 1094}
1095 1095
1096void KABCore::addEmail( QString aStr ) 1096void KABCore::addEmail( QString aStr )
1097{ 1097{
1098#ifndef KAB_EMBEDDED 1098#ifndef KAB_EMBEDDED
1099 QString fullName, email; 1099 QString fullName, email;
1100 1100
1101 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1101 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1102 1102
1103 // Try to lookup the addressee matching the email address 1103 // Try to lookup the addressee matching the email address
1104 bool found = false; 1104 bool found = false;
1105 QStringList emailList; 1105 QStringList emailList;
1106 KABC::AddressBook::Iterator it; 1106 KABC::AddressBook::Iterator it;
1107 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1107 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1108 emailList = (*it).emails(); 1108 emailList = (*it).emails();
1109 if ( emailList.contains( email ) > 0 ) { 1109 if ( emailList.contains( email ) > 0 ) {
1110 found = true; 1110 found = true;
1111 (*it).setNameFromString( fullName ); 1111 (*it).setNameFromString( fullName );
1112 editContact( (*it).uid() ); 1112 editContact( (*it).uid() );
1113 } 1113 }
1114 } 1114 }
1115 1115
1116 if ( !found ) { 1116 if ( !found ) {
1117 KABC::Addressee addr; 1117 KABC::Addressee addr;
1118 addr.setNameFromString( fullName ); 1118 addr.setNameFromString( fullName );
1119 addr.insertEmail( email, true ); 1119 addr.insertEmail( email, true );
1120 1120
1121 mAddressBook->insertAddressee( addr ); 1121 mAddressBook->insertAddressee( addr );
1122 mViewManager->refreshView( addr.uid() ); 1122 mViewManager->refreshView( addr.uid() );
1123 editContact( addr.uid() ); 1123 editContact( addr.uid() );
1124 } 1124 }
1125#else //KAB_EMBEDDED 1125#else //KAB_EMBEDDED
1126 qDebug("KABCore::addEmail finsih method"); 1126 qDebug("KABCore::addEmail finsih method");
1127#endif //KAB_EMBEDDED 1127#endif //KAB_EMBEDDED
1128} 1128}
1129 1129
1130void KABCore::importVCard( const KURL &url, bool showPreview ) 1130void KABCore::importVCard( const KURL &url, bool showPreview )
1131{ 1131{
1132 mXXPortManager->importVCard( url, showPreview ); 1132 mXXPortManager->importVCard( url, showPreview );
1133} 1133}
1134void KABCore::importFromOL() 1134void KABCore::importFromOL()
1135{ 1135{
1136#ifdef _WIN32_ 1136#ifdef _WIN32_
1137 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1137 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1138 idgl->exec(); 1138 idgl->exec();
1139 KABC::Addressee::List list = idgl->getAddressList(); 1139 KABC::Addressee::List list = idgl->getAddressList();
1140 if ( list.count() > 0 ) { 1140 if ( list.count() > 0 ) {
1141 KABC::Addressee::List listNew; 1141 KABC::Addressee::List listNew;
1142 KABC::Addressee::List listExisting; 1142 KABC::Addressee::List listExisting;
1143 KABC::Addressee::List::Iterator it; 1143 KABC::Addressee::List::Iterator it;
1144 KABC::AddressBook::Iterator iter; 1144 KABC::AddressBook::Iterator iter;
1145 for ( it = list.begin(); it != list.end(); ++it ) { 1145 for ( it = list.begin(); it != list.end(); ++it ) {
1146 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1146 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1147 listNew.append( (*it) ); 1147 listNew.append( (*it) );
1148 else 1148 else
1149 listExisting.append( (*it) ); 1149 listExisting.append( (*it) );
1150 } 1150 }
1151 if ( listExisting.count() > 0 ) 1151 if ( listExisting.count() > 0 )
1152 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1152 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1153 if ( listNew.count() > 0 ) { 1153 if ( listNew.count() > 0 ) {
1154 pasteWithNewUid = false; 1154 pasteWithNewUid = false;
1155 pasteContacts( listNew ); 1155 pasteContacts( listNew );
1156 pasteWithNewUid = true; 1156 pasteWithNewUid = true;
1157 } 1157 }
1158 } 1158 }
1159 delete idgl; 1159 delete idgl;
1160#endif 1160#endif
1161} 1161}
1162 1162
1163void KABCore::importVCard( const QString &vCard, bool showPreview ) 1163void KABCore::importVCard( const QString &vCard, bool showPreview )
1164{ 1164{
1165 mXXPortManager->importVCard( vCard, showPreview ); 1165 mXXPortManager->importVCard( vCard, showPreview );
1166} 1166}
1167 1167
1168//US added a second method without defaultparameter 1168//US added a second method without defaultparameter
1169void KABCore::editContact2() { 1169void KABCore::editContact2() {
1170 editContact( QString::null ); 1170 editContact( QString::null );
1171} 1171}
1172 1172
1173void KABCore::editContact( const QString &uid ) 1173void KABCore::editContact( const QString &uid )
1174{ 1174{
1175 1175
1176 if ( mExtensionManager->isQuickEditVisible() ) 1176 if ( mExtensionManager->isQuickEditVisible() )
1177 return; 1177 return;
1178 1178
1179 // First, locate the contact entry 1179 // First, locate the contact entry
1180 QString localUID = uid; 1180 QString localUID = uid;
1181 if ( localUID.isNull() ) { 1181 if ( localUID.isNull() ) {
1182 QStringList uidList = mViewManager->selectedUids(); 1182 QStringList uidList = mViewManager->selectedUids();
1183 if ( uidList.count() > 0 ) 1183 if ( uidList.count() > 0 )
1184 localUID = *( uidList.at( 0 ) ); 1184 localUID = *( uidList.at( 0 ) );
1185 } 1185 }
1186 1186
1187 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1187 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1188 if ( !addr.isEmpty() ) { 1188 if ( !addr.isEmpty() ) {
1189 mEditorDialog->setAddressee( addr ); 1189 mEditorDialog->setAddressee( addr );
1190 KApplication::execDialog ( mEditorDialog ); 1190 KApplication::execDialog ( mEditorDialog );
1191 } 1191 }
1192} 1192}
1193 1193
1194/** 1194/**
1195 Shows or edits the detail view for the given uid. If the uid is QString::null, 1195 Shows or edits the detail view for the given uid. If the uid is QString::null,
1196 the method will try to find a selected addressee in the view. 1196 the method will try to find a selected addressee in the view.
1197 */ 1197 */
1198void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1198void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1199{ 1199{
1200 if ( mMultipleViewsAtOnce ) 1200 if ( mMultipleViewsAtOnce )
1201 { 1201 {
1202 editContact( uid ); 1202 editContact( uid );
1203 } 1203 }
1204 else 1204 else
1205 { 1205 {
1206 setDetailsVisible( true ); 1206 setDetailsVisible( true );
1207 mActionDetails->setChecked(true); 1207 mActionDetails->setChecked(true);
1208 } 1208 }
1209 1209
1210} 1210}
1211 1211
1212void KABCore::save() 1212void KABCore::save()
1213{ 1213{
1214 if (syncManager->blockSave()) 1214 if (syncManager->blockSave())
1215 return; 1215 return;
1216 if ( !mModified ) 1216 if ( !mModified )
1217 return; 1217 return;
1218 1218
1219 syncManager->setBlockSave(true); 1219 syncManager->setBlockSave(true);
1220 QString text = i18n( "There was an error while attempting to save\n the " 1220 QString text = i18n( "There was an error while attempting to save\n the "
1221 "address book. Please check that some \nother application is " 1221 "address book. Please check that some \nother application is "
1222 "not using it. " ); 1222 "not using it. " );
1223 message(i18n("Saving addressbook ... ")); 1223 message(i18n("Saving addressbook ... "));
1224#ifndef KAB_EMBEDDED 1224#ifndef KAB_EMBEDDED
1225 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1225 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1226 if ( !b || !b->save() ) { 1226 if ( !b || !b->save() ) {
1227 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1227 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1228 } 1228 }
1229#else //KAB_EMBEDDED 1229#else //KAB_EMBEDDED
1230 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1230 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1231 if ( !b || !b->save() ) { 1231 if ( !b || !b->save() ) {
1232 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1232 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1233 } 1233 }
1234#endif //KAB_EMBEDDED 1234#endif //KAB_EMBEDDED
1235 1235
1236 message(i18n("Addressbook saved!")); 1236 message(i18n("Addressbook saved!"));
1237 setModified( false ); 1237 setModified( false );
1238 syncManager->setBlockSave(false); 1238 syncManager->setBlockSave(false);
1239} 1239}
1240 1240
1241 1241
1242void KABCore::undo() 1242void KABCore::undo()
1243{ 1243{
1244 UndoStack::instance()->undo(); 1244 UndoStack::instance()->undo();
1245 1245
1246 // Refresh the view 1246 // Refresh the view
1247 mViewManager->refreshView(); 1247 mViewManager->refreshView();
1248} 1248}
1249 1249
1250void KABCore::redo() 1250void KABCore::redo()
1251{ 1251{
1252 RedoStack::instance()->redo(); 1252 RedoStack::instance()->redo();
1253 1253
1254 // Refresh the view 1254 // Refresh the view
1255 mViewManager->refreshView(); 1255 mViewManager->refreshView();
1256} 1256}
1257 1257
1258void KABCore::setJumpButtonBarVisible( bool visible ) 1258void KABCore::setJumpButtonBarVisible( bool visible )
1259{ 1259{
1260 if (mMultipleViewsAtOnce) 1260 if (mMultipleViewsAtOnce)
1261 { 1261 {
1262 if ( visible ) 1262 if ( visible )
1263 mJumpButtonBar->show(); 1263 mJumpButtonBar->show();
1264 else 1264 else
1265 mJumpButtonBar->hide(); 1265 mJumpButtonBar->hide();
1266 } 1266 }
1267 else 1267 else
1268 { 1268 {
1269 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1269 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1270 if (mViewManager->isVisible()) 1270 if (mViewManager->isVisible())
1271 { 1271 {
1272 if ( visible ) 1272 if ( visible )
1273 mJumpButtonBar->show(); 1273 mJumpButtonBar->show();
1274 else 1274 else
1275 mJumpButtonBar->hide(); 1275 mJumpButtonBar->hide();
1276 } 1276 }
1277 else 1277 else
1278 { 1278 {
1279 mJumpButtonBar->hide(); 1279 mJumpButtonBar->hide();
1280 } 1280 }
1281 } 1281 }
1282} 1282}
1283 1283
1284 1284
1285void KABCore::setDetailsToState() 1285void KABCore::setDetailsToState()
1286{ 1286{
1287 setDetailsVisible( mActionDetails->isChecked() ); 1287 setDetailsVisible( mActionDetails->isChecked() );
1288} 1288}
1289 1289
1290 1290
1291 1291
1292void KABCore::setDetailsVisible( bool visible ) 1292void KABCore::setDetailsVisible( bool visible )
1293{ 1293{
1294 if (visible && mDetails->isHidden()) 1294 if (visible && mDetails->isHidden())
1295 { 1295 {
1296 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1296 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1297 if ( addrList.count() > 0 ) 1297 if ( addrList.count() > 0 )
1298 mDetails->setAddressee( addrList[ 0 ] ); 1298 mDetails->setAddressee( addrList[ 0 ] );
1299 } 1299 }
1300 1300
1301 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1301 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1302 // the listview and the detailview. We do that by changing the splitbar size. 1302 // the listview and the detailview. We do that by changing the splitbar size.
1303 if (mMultipleViewsAtOnce) 1303 if (mMultipleViewsAtOnce)
1304 { 1304 {
1305 if ( visible ) 1305 if ( visible )
1306 mDetails->show(); 1306 mDetails->show();
1307 else 1307 else
1308 mDetails->hide(); 1308 mDetails->hide();
1309 } 1309 }
1310 else 1310 else
1311 { 1311 {
1312 if ( visible ) { 1312 if ( visible ) {
1313 mViewManager->hide(); 1313 mViewManager->hide();
1314 mDetails->show(); 1314 mDetails->show();
1315 mIncSearchWidget->setFocus(); 1315 mIncSearchWidget->setFocus();
1316 } 1316 }
1317 else { 1317 else {
1318 mViewManager->show(); 1318 mViewManager->show();
1319 mDetails->hide(); 1319 mDetails->hide();
1320 mViewManager->setFocusAV(); 1320 mViewManager->setFocusAV();
1321 } 1321 }
1322 setJumpButtonBarVisible( !visible ); 1322 setJumpButtonBarVisible( !visible );
1323 } 1323 }
1324 1324
1325} 1325}
1326 1326
1327void KABCore::extensionChanged( int id ) 1327void KABCore::extensionChanged( int id )
1328{ 1328{
1329 //change the details view only for non desktop systems 1329 //change the details view only for non desktop systems
1330#ifndef DESKTOP_VERSION 1330#ifndef DESKTOP_VERSION
1331 1331
1332 if (id == 0) 1332 if (id == 0)
1333 { 1333 {
1334 //the user disabled the extension. 1334 //the user disabled the extension.
1335 1335
1336 if (mMultipleViewsAtOnce) 1336 if (mMultipleViewsAtOnce)
1337 { // enable detailsview again 1337 { // enable detailsview again
1338 setDetailsVisible( true ); 1338 setDetailsVisible( true );
1339 mActionDetails->setChecked( true ); 1339 mActionDetails->setChecked( true );
1340 } 1340 }
1341 else 1341 else
1342 { //go back to the listview 1342 { //go back to the listview
1343 setDetailsVisible( false ); 1343 setDetailsVisible( false );
1344 mActionDetails->setChecked( false ); 1344 mActionDetails->setChecked( false );
1345 mActionDetails->setEnabled(true); 1345 mActionDetails->setEnabled(true);
1346 } 1346 }
1347 1347
1348 } 1348 }
1349 else 1349 else
1350 { 1350 {
1351 //the user enabled the extension. 1351 //the user enabled the extension.
1352 setDetailsVisible( false ); 1352 setDetailsVisible( false );
1353 mActionDetails->setChecked( false ); 1353 mActionDetails->setChecked( false );
1354 1354
1355 if (!mMultipleViewsAtOnce) 1355 if (!mMultipleViewsAtOnce)
1356 { 1356 {
1357 mActionDetails->setEnabled(false); 1357 mActionDetails->setEnabled(false);
1358 } 1358 }
1359 1359
1360 mExtensionManager->setSelectionChanged(); 1360 mExtensionManager->setSelectionChanged();
1361 1361
1362 } 1362 }
1363 1363
1364#endif// DESKTOP_VERSION 1364#endif// DESKTOP_VERSION
1365 1365
1366} 1366}
1367 1367
1368 1368
1369void KABCore::extensionModified( const KABC::Addressee::List &list ) 1369void KABCore::extensionModified( const KABC::Addressee::List &list )
1370{ 1370{
1371 1371
1372 if ( list.count() != 0 ) { 1372 if ( list.count() != 0 ) {
1373 KABC::Addressee::List::ConstIterator it; 1373 KABC::Addressee::List::ConstIterator it;
1374 for ( it = list.begin(); it != list.end(); ++it ) 1374 for ( it = list.begin(); it != list.end(); ++it )
1375 mAddressBook->insertAddressee( *it ); 1375 mAddressBook->insertAddressee( *it );
1376 if ( list.count() > 1 ) 1376 if ( list.count() > 1 )
1377 setModified(); 1377 setModified();
1378 else 1378 else
1379 setModifiedWOrefresh(); 1379 setModifiedWOrefresh();
1380 } 1380 }
1381 if ( list.count() == 0 ) 1381 if ( list.count() == 0 )
1382 mViewManager->refreshView(); 1382 mViewManager->refreshView();
1383 else 1383 else
1384 mViewManager->refreshView( list[ 0 ].uid() ); 1384 mViewManager->refreshView( list[ 0 ].uid() );
1385 1385
1386 1386
1387 1387
1388} 1388}
1389 1389
1390QString KABCore::getNameByPhone( const QString &phone ) 1390QString KABCore::getNameByPhone( const QString &phone )
1391{ 1391{
1392#ifndef KAB_EMBEDDED 1392#ifndef KAB_EMBEDDED
1393 QRegExp r( "[/*/-/ ]" ); 1393 QRegExp r( "[/*/-/ ]" );
1394 QString localPhone( phone ); 1394 QString localPhone( phone );
1395 1395
1396 bool found = false; 1396 bool found = false;
1397 QString ownerName = ""; 1397 QString ownerName = "";
1398 KABC::AddressBook::Iterator iter; 1398 KABC::AddressBook::Iterator iter;
1399 KABC::PhoneNumber::List::Iterator phoneIter; 1399 KABC::PhoneNumber::List::Iterator phoneIter;
1400 KABC::PhoneNumber::List phoneList; 1400 KABC::PhoneNumber::List phoneList;
1401 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1401 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1402 phoneList = (*iter).phoneNumbers(); 1402 phoneList = (*iter).phoneNumbers();
1403 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1403 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1404 ++phoneIter) { 1404 ++phoneIter) {
1405 // Get rid of separator chars so just the numbers are compared. 1405 // Get rid of separator chars so just the numbers are compared.
1406 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1406 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1407 ownerName = (*iter).formattedName(); 1407 ownerName = (*iter).formattedName();
1408 found = true; 1408 found = true;
1409 } 1409 }
1410 } 1410 }
1411 } 1411 }
1412 1412
1413 return ownerName; 1413 return ownerName;
1414#else //KAB_EMBEDDED 1414#else //KAB_EMBEDDED
1415 qDebug("KABCore::getNameByPhone finsih method"); 1415 qDebug("KABCore::getNameByPhone finsih method");
1416 return ""; 1416 return "";
1417#endif //KAB_EMBEDDED 1417#endif //KAB_EMBEDDED
1418 1418
1419} 1419}
1420 1420
1421void KABCore::openConfigDialog() 1421void KABCore::openConfigDialog()
1422{ 1422{
1423 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1423 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1424 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1424 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1425 ConfigureDialog->addModule(kabcfg ); 1425 ConfigureDialog->addModule(kabcfg );
1426 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1426 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1427 ConfigureDialog->addModule(kdelibcfg ); 1427 ConfigureDialog->addModule(kdelibcfg );
1428 1428
1429 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1429 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1430 this, SLOT( configurationChanged() ) ); 1430 this, SLOT( configurationChanged() ) );
1431 connect( ConfigureDialog, SIGNAL( okClicked() ), 1431 connect( ConfigureDialog, SIGNAL( okClicked() ),
1432 this, SLOT( configurationChanged() ) ); 1432 this, SLOT( configurationChanged() ) );
1433 saveSettings(); 1433 saveSettings();
1434#ifndef DESKTOP_VERSION 1434#ifndef DESKTOP_VERSION
1435 ConfigureDialog->showMaximized(); 1435 ConfigureDialog->showMaximized();
1436#endif 1436#endif
1437 if ( ConfigureDialog->exec() ) 1437 if ( ConfigureDialog->exec() )
1438 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1438 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1439 delete ConfigureDialog; 1439 delete ConfigureDialog;
1440} 1440}
1441 1441
1442void KABCore::openLDAPDialog() 1442void KABCore::openLDAPDialog()
1443{ 1443{
1444#ifndef KAB_EMBEDDED 1444#ifndef KAB_EMBEDDED
1445 if ( !mLdapSearchDialog ) { 1445 if ( !mLdapSearchDialog ) {
1446 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1446 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1447 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1447 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1448 SLOT( refreshView() ) ); 1448 SLOT( refreshView() ) );
1449 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1449 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1450 SLOT( setModified() ) ); 1450 SLOT( setModified() ) );
1451 } else 1451 } else
1452 mLdapSearchDialog->restoreSettings(); 1452 mLdapSearchDialog->restoreSettings();
1453 1453
1454 if ( mLdapSearchDialog->isOK() ) 1454 if ( mLdapSearchDialog->isOK() )
1455 mLdapSearchDialog->exec(); 1455 mLdapSearchDialog->exec();
1456#else //KAB_EMBEDDED 1456#else //KAB_EMBEDDED
1457 qDebug("KABCore::openLDAPDialog() finsih method"); 1457 qDebug("KABCore::openLDAPDialog() finsih method");
1458#endif //KAB_EMBEDDED 1458#endif //KAB_EMBEDDED
1459} 1459}
1460 1460
1461void KABCore::print() 1461void KABCore::print()
1462{ 1462{
1463#ifndef KAB_EMBEDDED 1463#ifndef KAB_EMBEDDED
1464 KPrinter printer; 1464 KPrinter printer;
1465 if ( !printer.setup( this ) ) 1465 if ( !printer.setup( this ) )
1466 return; 1466 return;
1467 1467
1468 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1468 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1469 mViewManager->selectedUids(), this ); 1469 mViewManager->selectedUids(), this );
1470 1470
1471 wizard.exec(); 1471 wizard.exec();
1472#else //KAB_EMBEDDED 1472#else //KAB_EMBEDDED
1473 qDebug("KABCore::print() finsih method"); 1473 qDebug("KABCore::print() finsih method");
1474#endif //KAB_EMBEDDED 1474#endif //KAB_EMBEDDED
1475 1475
1476} 1476}
1477 1477
1478 1478
1479void KABCore::addGUIClient( KXMLGUIClient *client ) 1479void KABCore::addGUIClient( KXMLGUIClient *client )
1480{ 1480{
1481 if ( mGUIClient ) 1481 if ( mGUIClient )
1482 mGUIClient->insertChildClient( client ); 1482 mGUIClient->insertChildClient( client );
1483 else 1483 else
1484 KMessageBox::error( this, "no KXMLGUICLient"); 1484 KMessageBox::error( this, "no KXMLGUICLient");
1485} 1485}
1486 1486
1487 1487
1488void KABCore::configurationChanged() 1488void KABCore::configurationChanged()
1489{ 1489{
1490 mExtensionManager->reconfigure(); 1490 mExtensionManager->reconfigure();
1491} 1491}
1492 1492
1493void KABCore::addressBookChanged() 1493void KABCore::addressBookChanged()
1494{ 1494{
1495/*US 1495/*US
1496 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1496 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1497 while ( it.current() ) { 1497 while ( it.current() ) {
1498 if ( it.current()->dirty() ) { 1498 if ( it.current()->dirty() ) {
1499 QString text = i18n( "Data has been changed externally. Unsaved " 1499 QString text = i18n( "Data has been changed externally. Unsaved "
1500 "changes will be lost." ); 1500 "changes will be lost." );
1501 KMessageBox::information( this, text ); 1501 KMessageBox::information( this, text );
1502 } 1502 }
1503 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1503 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1504 ++it; 1504 ++it;
1505 } 1505 }
1506*/ 1506*/
1507 if (mEditorDialog) 1507 if (mEditorDialog)
1508 { 1508 {
1509 if (mEditorDialog->dirty()) 1509 if (mEditorDialog->dirty())
1510 { 1510 {
1511 QString text = i18n( "Data has been changed externally. Unsaved " 1511 QString text = i18n( "Data has been changed externally. Unsaved "
1512 "changes will be lost." ); 1512 "changes will be lost." );
1513 KMessageBox::information( this, text ); 1513 KMessageBox::information( this, text );
1514 } 1514 }
1515 QString currentuid = mEditorDialog->addressee().uid(); 1515 QString currentuid = mEditorDialog->addressee().uid();
1516 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1516 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1517 } 1517 }
1518 mViewManager->refreshView(); 1518 mViewManager->refreshView();
1519// mDetails->refreshView(); 1519// mDetails->refreshView();
1520 1520
1521 1521
1522} 1522}
1523 1523
1524AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1524AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1525 const char *name ) 1525 const char *name )
1526{ 1526{
1527 1527
1528 if ( mEditorDialog == 0 ) { 1528 if ( mEditorDialog == 0 ) {
1529 mEditorDialog = new AddresseeEditorDialog( this, parent, 1529 mEditorDialog = new AddresseeEditorDialog( this, parent,
1530 name ? name : "editorDialog" ); 1530 name ? name : "editorDialog" );
1531 1531
1532 1532
1533 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1533 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1534 SLOT( contactModified( const KABC::Addressee& ) ) ); 1534 SLOT( contactModified( const KABC::Addressee& ) ) );
1535 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1535 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1536 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1536 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1537 } 1537 }
1538 1538
1539 return mEditorDialog; 1539 return mEditorDialog;
1540} 1540}
1541 1541
1542void KABCore::slotEditorDestroyed( const QString &uid ) 1542void KABCore::slotEditorDestroyed( const QString &uid )
1543{ 1543{
1544 //mEditorDict.remove( uid ); 1544 //mEditorDict.remove( uid );
1545} 1545}
1546 1546
1547void KABCore::initGUI() 1547void KABCore::initGUI()
1548{ 1548{
1549#ifndef KAB_EMBEDDED 1549#ifndef KAB_EMBEDDED
1550 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1550 QHBoxLayout *topLayout = new QHBoxLayout( this );
1551 topLayout->setSpacing( KDialogBase::spacingHint() ); 1551 topLayout->setSpacing( KDialogBase::spacingHint() );
1552 1552
1553 mExtensionBarSplitter = new QSplitter( this ); 1553 mExtensionBarSplitter = new QSplitter( this );
1554 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1554 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1555 1555
1556 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1556 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1557 1557
1558 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1558 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1559 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1559 mIncSearchWidget = new IncSearchWidget( viewSpace );
1560 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1560 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1561 SLOT( incrementalSearch( const QString& ) ) ); 1561 SLOT( incrementalSearch( const QString& ) ) );
1562 1562
1563 mViewManager = new ViewManager( this, viewSpace ); 1563 mViewManager = new ViewManager( this, viewSpace );
1564 viewSpace->setStretchFactor( mViewManager, 1 ); 1564 viewSpace->setStretchFactor( mViewManager, 1 );
1565 1565
1566 mDetails = new ViewContainer( mDetailsSplitter ); 1566 mDetails = new ViewContainer( mDetailsSplitter );
1567 1567
1568 mJumpButtonBar = new JumpButtonBar( this, this ); 1568 mJumpButtonBar = new JumpButtonBar( this, this );
1569 1569
1570 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1570 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1571 1571
1572 topLayout->addWidget( mExtensionBarSplitter ); 1572 topLayout->addWidget( mExtensionBarSplitter );
1573 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1573 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1574 topLayout->addWidget( mJumpButtonBar ); 1574 topLayout->addWidget( mJumpButtonBar );
1575 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1575 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1576 1576
1577 mXXPortManager = new XXPortManager( this, this ); 1577 mXXPortManager = new XXPortManager( this, this );
1578 1578
1579#else //KAB_EMBEDDED 1579#else //KAB_EMBEDDED
1580 //US initialize viewMenu before settingup viewmanager. 1580 //US initialize viewMenu before settingup viewmanager.
1581 // Viewmanager needs this menu to plugin submenues. 1581 // Viewmanager needs this menu to plugin submenues.
1582 viewMenu = new QPopupMenu( this ); 1582 viewMenu = new QPopupMenu( this );
1583 settingsMenu = new QPopupMenu( this ); 1583 settingsMenu = new QPopupMenu( this );
1584 //filterMenu = new QPopupMenu( this ); 1584 //filterMenu = new QPopupMenu( this );
1585 ImportMenu = new QPopupMenu( this ); 1585 ImportMenu = new QPopupMenu( this );
1586 ExportMenu = new QPopupMenu( this ); 1586 ExportMenu = new QPopupMenu( this );
1587 syncMenu = new QPopupMenu( this ); 1587 syncMenu = new QPopupMenu( this );
1588 changeMenu= new QPopupMenu( this ); 1588 changeMenu= new QPopupMenu( this );
1589 1589
1590//US since we have no splitter for the embedded system, setup 1590//US since we have no splitter for the embedded system, setup
1591// a layout with two frames. One left and one right. 1591// a layout with two frames. One left and one right.
1592 1592
1593 QBoxLayout *topLayout; 1593 QBoxLayout *topLayout;
1594 1594
1595 // = new QHBoxLayout( this ); 1595 // = new QHBoxLayout( this );
1596// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1596// QBoxLayout *topLayout = (QBoxLayout*)layout();
1597 1597
1598// QWidget *mainBox = new QWidget( this ); 1598// QWidget *mainBox = new QWidget( this );
1599// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1599// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1600 1600
1601#ifdef DESKTOP_VERSION 1601#ifdef DESKTOP_VERSION
1602 topLayout = new QHBoxLayout( this ); 1602 topLayout = new QHBoxLayout( this );
1603 1603
1604 1604
1605 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1605 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1606 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1606 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1607 1607
1608 topLayout->addWidget(mMiniSplitter ); 1608 topLayout->addWidget(mMiniSplitter );
1609 1609
1610 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1610 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1611 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1611 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1612 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1612 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1613 mDetails = new ViewContainer( mMiniSplitter ); 1613 mDetails = new ViewContainer( mMiniSplitter );
1614 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1614 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1615#else 1615#else
1616 if ( QApplication::desktop()->width() > 480 ) { 1616 if ( QApplication::desktop()->width() > 480 ) {
1617 topLayout = new QHBoxLayout( this ); 1617 topLayout = new QHBoxLayout( this );
1618 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1618 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1619 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1619 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1620 } else { 1620 } else {
1621 1621
1622 topLayout = new QHBoxLayout( this ); 1622 topLayout = new QHBoxLayout( this );
1623 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1623 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1624 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1624 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1625 } 1625 }
1626 1626
1627 topLayout->addWidget(mMiniSplitter ); 1627 topLayout->addWidget(mMiniSplitter );
1628 mViewManager = new ViewManager( this, mMiniSplitter ); 1628 mViewManager = new ViewManager( this, mMiniSplitter );
1629 mDetails = new ViewContainer( mMiniSplitter ); 1629 mDetails = new ViewContainer( mMiniSplitter );
1630 1630
1631 1631
1632 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1632 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1633#endif 1633#endif
1634 //eh->hide(); 1634 //eh->hide();
1635 // topLayout->addWidget(mExtensionManager ); 1635 // topLayout->addWidget(mExtensionManager );
1636 1636
1637 1637
1638/*US 1638/*US
1639#ifndef KAB_NOSPLITTER 1639#ifndef KAB_NOSPLITTER
1640 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1640 QHBoxLayout *topLayout = new QHBoxLayout( this );
1641//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1641//US topLayout->setSpacing( KDialogBase::spacingHint() );
1642 topLayout->setSpacing( 10 ); 1642 topLayout->setSpacing( 10 );
1643 1643
1644 mDetailsSplitter = new QSplitter( this ); 1644 mDetailsSplitter = new QSplitter( this );
1645 1645
1646 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1646 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1647 1647
1648 mViewManager = new ViewManager( this, viewSpace ); 1648 mViewManager = new ViewManager( this, viewSpace );
1649 viewSpace->setStretchFactor( mViewManager, 1 ); 1649 viewSpace->setStretchFactor( mViewManager, 1 );
1650 1650
1651 mDetails = new ViewContainer( mDetailsSplitter ); 1651 mDetails = new ViewContainer( mDetailsSplitter );
1652 1652
1653 topLayout->addWidget( mDetailsSplitter ); 1653 topLayout->addWidget( mDetailsSplitter );
1654 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1654 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1655#else //KAB_NOSPLITTER 1655#else //KAB_NOSPLITTER
1656 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1656 QHBoxLayout *topLayout = new QHBoxLayout( this );
1657//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1657//US topLayout->setSpacing( KDialogBase::spacingHint() );
1658 topLayout->setSpacing( 10 ); 1658 topLayout->setSpacing( 10 );
1659 1659
1660// mDetailsSplitter = new QSplitter( this ); 1660// mDetailsSplitter = new QSplitter( this );
1661 1661
1662 QVBox *viewSpace = new QVBox( this ); 1662 QVBox *viewSpace = new QVBox( this );
1663 1663
1664 mViewManager = new ViewManager( this, viewSpace ); 1664 mViewManager = new ViewManager( this, viewSpace );
1665 viewSpace->setStretchFactor( mViewManager, 1 ); 1665 viewSpace->setStretchFactor( mViewManager, 1 );
1666 1666
1667 mDetails = new ViewContainer( this ); 1667 mDetails = new ViewContainer( this );
1668 1668
1669 topLayout->addWidget( viewSpace ); 1669 topLayout->addWidget( viewSpace );
1670// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1670// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1671 topLayout->addWidget( mDetails ); 1671 topLayout->addWidget( mDetails );
1672#endif //KAB_NOSPLITTER 1672#endif //KAB_NOSPLITTER
1673*/ 1673*/
1674 1674
1675 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1675 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1676 syncManager->setBlockSave(false); 1676 syncManager->setBlockSave(false);
1677 1677
1678 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1678 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1679 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1679 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1680 syncManager->setDefaultFileName( sentSyncFile()); 1680 syncManager->setDefaultFileName( sentSyncFile());
1681 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1681 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1682 1682
1683#endif //KAB_EMBEDDED 1683#endif //KAB_EMBEDDED
1684 initActions(); 1684 initActions();
1685 1685
1686#ifdef KAB_EMBEDDED 1686#ifdef KAB_EMBEDDED
1687 addActionsManually(); 1687 addActionsManually();
1688 //US make sure the export and import menues are initialized before creating the xxPortManager. 1688 //US make sure the export and import menues are initialized before creating the xxPortManager.
1689 mXXPortManager = new XXPortManager( this, this ); 1689 mXXPortManager = new XXPortManager( this, this );
1690 1690
1691 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1691 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1692 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1692 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1693 // mActionQuit->plug ( mMainWindow->toolBar()); 1693 // mActionQuit->plug ( mMainWindow->toolBar());
1694 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1694 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1695 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1695 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1696 // mIncSearchWidget->hide(); 1696 // mIncSearchWidget->hide();
1697 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1697 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1698 SLOT( incrementalSearch( const QString& ) ) ); 1698 SLOT( incrementalSearch( const QString& ) ) );
1699 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1699 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1700 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1700 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1701 1701
1702 mJumpButtonBar = new JumpButtonBar( this, this ); 1702 mJumpButtonBar = new JumpButtonBar( this, this );
1703 1703
1704 topLayout->addWidget( mJumpButtonBar ); 1704 topLayout->addWidget( mJumpButtonBar );
1705//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1705//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1706 1706
1707// mMainWindow->getIconToolBar()->raise(); 1707// mMainWindow->getIconToolBar()->raise();
1708 1708
1709#endif //KAB_EMBEDDED 1709#endif //KAB_EMBEDDED
1710 1710
1711} 1711}
1712void KABCore::initActions() 1712void KABCore::initActions()
1713{ 1713{
1714//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1714//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1715 1715
1716#ifndef KAB_EMBEDDED 1716#ifndef KAB_EMBEDDED
1717 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1717 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1718 SLOT( clipboardDataChanged() ) ); 1718 SLOT( clipboardDataChanged() ) );
1719#endif //KAB_EMBEDDED 1719#endif //KAB_EMBEDDED
1720 1720
1721 // file menu 1721 // file menu
1722 if ( mIsPart ) { 1722 if ( mIsPart ) {
1723 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1723 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1724 SLOT( sendMail() ), actionCollection(), 1724 SLOT( sendMail() ), actionCollection(),
1725 "kaddressbook_mail" ); 1725 "kaddressbook_mail" );
1726 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1726 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1727 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1727 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1728 1728
1729 } else { 1729 } else {
1730 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1730 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1731 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1731 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1732 } 1732 }
1733 1733
1734 1734
1735 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1735 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1736 SLOT( save() ), actionCollection(), "file_sync" ); 1736 SLOT( save() ), actionCollection(), "file_sync" );
1737 1737
1738 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1738 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1739 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1739 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1740 1740
1741 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1741 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1742 this, SLOT( mailVCard() ), 1742 this, SLOT( mailVCard() ),
1743 actionCollection(), "file_mail_vcard"); 1743 actionCollection(), "file_mail_vcard");
1744 1744
1745 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1745 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1746 SLOT( export2phone() ), actionCollection(), 1746 SLOT( export2phone() ), actionCollection(),
1747 "kaddressbook_ex2phone" ); 1747 "kaddressbook_ex2phone" );
1748 1748
1749 mActionBeamVCard = 0; 1749 mActionBeamVCard = 0;
1750 mActionBeam = 0; 1750 mActionBeam = 0;
1751 1751
1752#ifndef DESKTOP_VERSION 1752#ifndef DESKTOP_VERSION
1753 if ( Ir::supported() ) { 1753 if ( Ir::supported() ) {
1754 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1754 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1755 SLOT( beamVCard() ), actionCollection(), 1755 SLOT( beamVCard() ), actionCollection(),
1756 "kaddressbook_beam_vcard" ); 1756 "kaddressbook_beam_vcard" );
1757 1757
1758 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1758 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1759 SLOT( beamMySelf() ), actionCollection(), 1759 SLOT( beamMySelf() ), actionCollection(),
1760 "kaddressbook_beam_myself" ); 1760 "kaddressbook_beam_myself" );
1761 } 1761 }
1762#endif 1762#endif
1763 1763
1764 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1764 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1765 this, SLOT( editContact2() ), 1765 this, SLOT( editContact2() ),
1766 actionCollection(), "file_properties" ); 1766 actionCollection(), "file_properties" );
1767 1767
1768#ifdef KAB_EMBEDDED 1768#ifdef KAB_EMBEDDED
1769 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1769 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1770 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1770 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1771 mMainWindow, SLOT( exit() ), 1771 mMainWindow, SLOT( exit() ),
1772 actionCollection(), "quit" ); 1772 actionCollection(), "quit" );
1773#endif //KAB_EMBEDDED 1773#endif //KAB_EMBEDDED
1774 1774
1775 // edit menu 1775 // edit menu
1776 if ( mIsPart ) { 1776 if ( mIsPart ) {
1777 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1777 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1778 SLOT( copyContacts() ), actionCollection(), 1778 SLOT( copyContacts() ), actionCollection(),
1779 "kaddressbook_copy" ); 1779 "kaddressbook_copy" );
1780 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1780 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1781 SLOT( cutContacts() ), actionCollection(), 1781 SLOT( cutContacts() ), actionCollection(),
1782 "kaddressbook_cut" ); 1782 "kaddressbook_cut" );
1783 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1783 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1784 SLOT( pasteContacts() ), actionCollection(), 1784 SLOT( pasteContacts() ), actionCollection(),
1785 "kaddressbook_paste" ); 1785 "kaddressbook_paste" );
1786 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1786 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1787 SLOT( selectAllContacts() ), actionCollection(), 1787 SLOT( selectAllContacts() ), actionCollection(),
1788 "kaddressbook_select_all" ); 1788 "kaddressbook_select_all" );
1789 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1789 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1790 SLOT( undo() ), actionCollection(), 1790 SLOT( undo() ), actionCollection(),
1791 "kaddressbook_undo" ); 1791 "kaddressbook_undo" );
1792 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1792 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1793 this, SLOT( redo() ), actionCollection(), 1793 this, SLOT( redo() ), actionCollection(),
1794 "kaddressbook_redo" ); 1794 "kaddressbook_redo" );
1795 } else { 1795 } else {
1796 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1796 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1797 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1797 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1798 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1798 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1799 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1799 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1800 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1800 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1801 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1801 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1802 } 1802 }
1803 1803
1804 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1804 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1805 Key_Delete, this, SLOT( deleteContacts() ), 1805 Key_Delete, this, SLOT( deleteContacts() ),
1806 actionCollection(), "edit_delete" ); 1806 actionCollection(), "edit_delete" );
1807 1807
1808 mActionUndo->setEnabled( false ); 1808 mActionUndo->setEnabled( false );
1809 mActionRedo->setEnabled( false ); 1809 mActionRedo->setEnabled( false );
1810 1810
1811 // settings menu 1811 // settings menu
1812#ifdef KAB_EMBEDDED 1812#ifdef KAB_EMBEDDED
1813//US special menuentry to configure the addressbook resources. On KDE 1813//US special menuentry to configure the addressbook resources. On KDE
1814// you do that through the control center !!! 1814// you do that through the control center !!!
1815 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1815 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1816 SLOT( configureResources() ), actionCollection(), 1816 SLOT( configureResources() ), actionCollection(),
1817 "kaddressbook_configure_resources" ); 1817 "kaddressbook_configure_resources" );
1818#endif //KAB_EMBEDDED 1818#endif //KAB_EMBEDDED
1819 1819
1820 if ( mIsPart ) { 1820 if ( mIsPart ) {
1821 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1821 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1822 SLOT( openConfigDialog() ), actionCollection(), 1822 SLOT( openConfigDialog() ), actionCollection(),
1823 "kaddressbook_configure" ); 1823 "kaddressbook_configure" );
1824 1824
1825 //US not implemented yet 1825 //US not implemented yet
1826 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1826 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1827 // this, SLOT( configureKeyBindings() ), actionCollection(), 1827 // this, SLOT( configureKeyBindings() ), actionCollection(),
1828 // "kaddressbook_configure_shortcuts" ); 1828 // "kaddressbook_configure_shortcuts" );
1829#ifdef KAB_EMBEDDED 1829#ifdef KAB_EMBEDDED
1830 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1830 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1831 mActionConfigureToolbars->setEnabled( false ); 1831 mActionConfigureToolbars->setEnabled( false );
1832#endif //KAB_EMBEDDED 1832#endif //KAB_EMBEDDED
1833 1833
1834 } else { 1834 } else {
1835 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1835 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1836 1836
1837 //US not implemented yet 1837 //US not implemented yet
1838 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1838 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1839 } 1839 }
1840 1840
1841 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1841 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1842 actionCollection(), "options_show_jump_bar" ); 1842 actionCollection(), "options_show_jump_bar" );
1843 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1843 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1844 1844
1845 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1845 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1846 actionCollection(), "options_show_details" ); 1846 actionCollection(), "options_show_details" );
1847 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1847 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1848 1848
1849 1849
1850 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 1850 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
1851 SLOT( toggleBeamReceive() ), actionCollection(), 1851 SLOT( toggleBeamReceive() ), actionCollection(),
1852 "kaddressbook_beam_rec" ); 1852 "kaddressbook_beam_rec" );
1853 1853
1854 1854
1855 // misc 1855 // misc
1856 // only enable LDAP lookup if we can handle the protocol 1856 // only enable LDAP lookup if we can handle the protocol
1857#ifndef KAB_EMBEDDED 1857#ifndef KAB_EMBEDDED
1858 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1858 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1859 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1859 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1860 this, SLOT( openLDAPDialog() ), actionCollection(), 1860 this, SLOT( openLDAPDialog() ), actionCollection(),
1861 "ldap_lookup" ); 1861 "ldap_lookup" );
1862 } 1862 }
1863#else //KAB_EMBEDDED 1863#else //KAB_EMBEDDED
1864 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1864 //qDebug("KABCore::initActions() LDAP has to be implemented");
1865#endif //KAB_EMBEDDED 1865#endif //KAB_EMBEDDED
1866 1866
1867 1867
1868 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1868 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1869 SLOT( setWhoAmI() ), actionCollection(), 1869 SLOT( setWhoAmI() ), actionCollection(),
1870 "set_personal" ); 1870 "set_personal" );
1871 1871
1872 1872
1873 1873
1874 1874
1875 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1875 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1876 SLOT( setCategories() ), actionCollection(), 1876 SLOT( setCategories() ), actionCollection(),
1877 "edit_set_categories" ); 1877 "edit_set_categories" );
1878 1878
1879 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1879 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1880 SLOT( removeVoice() ), actionCollection(), 1880 SLOT( removeVoice() ), actionCollection(),
1881 "remove_voice" ); 1881 "remove_voice" );
1882 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1882 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1883 SLOT( importFromOL() ), actionCollection(), 1883 SLOT( importFromOL() ), actionCollection(),
1884 "import_OL" ); 1884 "import_OL" );
1885#ifdef KAB_EMBEDDED 1885#ifdef KAB_EMBEDDED
1886 mActionLicence = new KAction( i18n( "Licence" ), 0, 1886 mActionLicence = new KAction( i18n( "Licence" ), 0,
1887 this, SLOT( showLicence() ), actionCollection(), 1887 this, SLOT( showLicence() ), actionCollection(),
1888 "licence_about_data" ); 1888 "licence_about_data" );
1889 mActionFaq = new KAction( i18n( "Faq" ), 0, 1889 mActionFaq = new KAction( i18n( "Faq" ), 0,
1890 this, SLOT( faq() ), actionCollection(), 1890 this, SLOT( faq() ), actionCollection(),
1891 "faq_about_data" ); 1891 "faq_about_data" );
1892 mActionWN = new KAction( i18n( "What's New?" ), 0, 1892 mActionWN = new KAction( i18n( "What's New?" ), 0,
1893 this, SLOT( whatsnew() ), actionCollection(), 1893 this, SLOT( whatsnew() ), actionCollection(),
1894 "wn" ); 1894 "wn" );
1895 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 1895 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
1896 this, SLOT( synchowto() ), actionCollection(), 1896 this, SLOT( synchowto() ), actionCollection(),
1897 "sync" ); 1897 "sync" );
1898 1898
1899 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1899 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1900 this, SLOT( createAboutData() ), actionCollection(), 1900 this, SLOT( createAboutData() ), actionCollection(),
1901 "kaddressbook_about_data" ); 1901 "kaddressbook_about_data" );
1902#endif //KAB_EMBEDDED 1902#endif //KAB_EMBEDDED
1903 1903
1904 clipboardDataChanged(); 1904 clipboardDataChanged();
1905 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1905 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1906 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1906 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1907} 1907}
1908 1908
1909//US we need this function, to plug all actions into the correct menues. 1909//US we need this function, to plug all actions into the correct menues.
1910// KDE uses a XML format to plug the actions, but we work her without this overhead. 1910// KDE uses a XML format to plug the actions, but we work her without this overhead.
1911void KABCore::addActionsManually() 1911void KABCore::addActionsManually()
1912{ 1912{
1913//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1913//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1914 1914
1915#ifdef KAB_EMBEDDED 1915#ifdef KAB_EMBEDDED
1916 QPopupMenu *fileMenu = new QPopupMenu( this ); 1916 QPopupMenu *fileMenu = new QPopupMenu( this );
1917 QPopupMenu *editMenu = new QPopupMenu( this ); 1917 QPopupMenu *editMenu = new QPopupMenu( this );
1918 QPopupMenu *helpMenu = new QPopupMenu( this ); 1918 QPopupMenu *helpMenu = new QPopupMenu( this );
1919 1919
1920 KToolBar* tb = mMainWindow->toolBar(); 1920 KToolBar* tb = mMainWindow->toolBar();
1921 1921
1922#ifdef DESKTOP_VERSION 1922#ifdef DESKTOP_VERSION
1923 QMenuBar* mb = mMainWindow->menuBar(); 1923 QMenuBar* mb = mMainWindow->menuBar();
1924 1924
1925 //US setup menubar. 1925 //US setup menubar.
1926 //Disable the following block if you do not want to have a menubar. 1926 //Disable the following block if you do not want to have a menubar.
1927 mb->insertItem( "&File", fileMenu ); 1927 mb->insertItem( "&File", fileMenu );
1928 mb->insertItem( "&Edit", editMenu ); 1928 mb->insertItem( "&Edit", editMenu );
1929 mb->insertItem( "&View", viewMenu ); 1929 mb->insertItem( "&View", viewMenu );
1930 mb->insertItem( "&Settings", settingsMenu ); 1930 mb->insertItem( "&Settings", settingsMenu );
1931 mb->insertItem( i18n("Synchronize"), syncMenu ); 1931 mb->insertItem( i18n("Synchronize"), syncMenu );
1932 mb->insertItem( "&Change selected", changeMenu ); 1932 mb->insertItem( "&Change selected", changeMenu );
1933 mb->insertItem( "&Help", helpMenu ); 1933 mb->insertItem( "&Help", helpMenu );
1934 mIncSearchWidget = new IncSearchWidget( tb ); 1934 mIncSearchWidget = new IncSearchWidget( tb );
1935 // tb->insertWidget(-1, 0, mIncSearchWidget); 1935 // tb->insertWidget(-1, 0, mIncSearchWidget);
1936 1936
1937#else 1937#else
1938 //US setup toolbar 1938 //US setup toolbar
1939 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1939 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1940 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1940 QPopupMenu *popupBarTB = new QPopupMenu( this );
1941 menuBarTB->insertItem( "ME", popupBarTB); 1941 menuBarTB->insertItem( "ME", popupBarTB);
1942 tb->insertWidget(-1, 0, menuBarTB); 1942 tb->insertWidget(-1, 0, menuBarTB);
1943 mIncSearchWidget = new IncSearchWidget( tb ); 1943 mIncSearchWidget = new IncSearchWidget( tb );
1944 1944
1945 tb->enableMoving(false); 1945 tb->enableMoving(false);
1946 popupBarTB->insertItem( "&File", fileMenu ); 1946 popupBarTB->insertItem( "&File", fileMenu );
1947 popupBarTB->insertItem( "&Edit", editMenu ); 1947 popupBarTB->insertItem( "&Edit", editMenu );
1948 popupBarTB->insertItem( "&View", viewMenu ); 1948 popupBarTB->insertItem( "&View", viewMenu );
1949 popupBarTB->insertItem( "&Settings", settingsMenu ); 1949 popupBarTB->insertItem( "&Settings", settingsMenu );
1950 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1950 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1951 mViewManager->getFilterAction()->plug ( popupBarTB); 1951 mViewManager->getFilterAction()->plug ( popupBarTB);
1952 popupBarTB->insertItem( "&Change selected", changeMenu ); 1952 popupBarTB->insertItem( "&Change selected", changeMenu );
1953 popupBarTB->insertItem( "&Help", helpMenu ); 1953 popupBarTB->insertItem( "&Help", helpMenu );
1954 if (QApplication::desktop()->width() > 320 ) { 1954 if (QApplication::desktop()->width() > 320 ) {
1955 // mViewManager->getFilterAction()->plug ( tb); 1955 // mViewManager->getFilterAction()->plug ( tb);
1956 } 1956 }
1957#endif 1957#endif
1958 // mActionQuit->plug ( mMainWindow->toolBar()); 1958 // mActionQuit->plug ( mMainWindow->toolBar());
1959 1959
1960 1960
1961 1961
1962 //US Now connect the actions with the menue entries. 1962 //US Now connect the actions with the menue entries.
1963 mActionPrint->plug( fileMenu ); 1963 mActionPrint->plug( fileMenu );
1964 mActionMail->plug( fileMenu ); 1964 mActionMail->plug( fileMenu );
1965 fileMenu->insertSeparator(); 1965 fileMenu->insertSeparator();
1966 1966
1967 mActionNewContact->plug( fileMenu ); 1967 mActionNewContact->plug( fileMenu );
1968 mActionNewContact->plug( tb ); 1968 mActionNewContact->plug( tb );
1969 1969
1970 mActionEditAddressee->plug( fileMenu ); 1970 mActionEditAddressee->plug( fileMenu );
1971 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1971 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1972 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1972 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1973 mActionEditAddressee->plug( tb ); 1973 mActionEditAddressee->plug( tb );
1974 1974
1975 fileMenu->insertSeparator(); 1975 fileMenu->insertSeparator();
1976 mActionSave->plug( fileMenu ); 1976 mActionSave->plug( fileMenu );
1977 fileMenu->insertItem( "&Import", ImportMenu ); 1977 fileMenu->insertItem( "&Import", ImportMenu );
1978 fileMenu->insertItem( "&Export", ExportMenu ); 1978 fileMenu->insertItem( "&Export", ExportMenu );
1979 fileMenu->insertSeparator(); 1979 fileMenu->insertSeparator();
1980 mActionMailVCard->plug( fileMenu ); 1980 mActionMailVCard->plug( fileMenu );
1981#ifndef DESKTOP_VERSION 1981#ifndef DESKTOP_VERSION
1982 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1982 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1983 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1983 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1984#endif 1984#endif
1985 fileMenu->insertSeparator(); 1985 fileMenu->insertSeparator();
1986 mActionQuit->plug( fileMenu ); 1986 mActionQuit->plug( fileMenu );
1987#ifdef _WIN32_ 1987#ifdef _WIN32_
1988 mActionImportOL->plug( ImportMenu ); 1988 mActionImportOL->plug( ImportMenu );
1989#endif 1989#endif
1990 // edit menu 1990 // edit menu
1991 mActionUndo->plug( editMenu ); 1991 mActionUndo->plug( editMenu );
1992 mActionRedo->plug( editMenu ); 1992 mActionRedo->plug( editMenu );
1993 editMenu->insertSeparator(); 1993 editMenu->insertSeparator();
1994 mActionCut->plug( editMenu ); 1994 mActionCut->plug( editMenu );
1995 mActionCopy->plug( editMenu ); 1995 mActionCopy->plug( editMenu );
1996 mActionPaste->plug( editMenu ); 1996 mActionPaste->plug( editMenu );
1997 mActionDelete->plug( editMenu ); 1997 mActionDelete->plug( editMenu );
1998 editMenu->insertSeparator(); 1998 editMenu->insertSeparator();
1999 mActionSelectAll->plug( editMenu ); 1999 mActionSelectAll->plug( editMenu );
2000 2000
2001 mActionRemoveVoice->plug( changeMenu ); 2001 mActionRemoveVoice->plug( changeMenu );
2002 // settings menu 2002 // settings menu
2003//US special menuentry to configure the addressbook resources. On KDE 2003//US special menuentry to configure the addressbook resources. On KDE
2004// you do that through the control center !!! 2004// you do that through the control center !!!
2005 mActionConfigResources->plug( settingsMenu ); 2005 mActionConfigResources->plug( settingsMenu );
2006 settingsMenu->insertSeparator(); 2006 settingsMenu->insertSeparator();
2007 2007
2008 mActionConfigKAddressbook->plug( settingsMenu ); 2008 mActionConfigKAddressbook->plug( settingsMenu );
2009 2009
2010 if ( mIsPart ) { 2010 if ( mIsPart ) {
2011 //US not implemented yet 2011 //US not implemented yet
2012 //mActionConfigShortcuts->plug( settingsMenu ); 2012 //mActionConfigShortcuts->plug( settingsMenu );
2013 //mActionConfigureToolbars->plug( settingsMenu ); 2013 //mActionConfigureToolbars->plug( settingsMenu );
2014 2014
2015 } else { 2015 } else {
2016 //US not implemented yet 2016 //US not implemented yet
2017 //mActionKeyBindings->plug( settingsMenu ); 2017 //mActionKeyBindings->plug( settingsMenu );
2018 } 2018 }
2019 2019
2020 settingsMenu->insertSeparator(); 2020 settingsMenu->insertSeparator();
2021 2021
2022 mActionJumpBar->plug( settingsMenu ); 2022 mActionJumpBar->plug( settingsMenu );
2023 mActionDetails->plug( settingsMenu ); 2023 mActionDetails->plug( settingsMenu );
2024 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2024 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2025 mActionDetails->plug( tb ); 2025 mActionDetails->plug( tb );
2026 settingsMenu->insertSeparator(); 2026 settingsMenu->insertSeparator();
2027 mActionBR->plug(settingsMenu ); 2027 mActionBR->plug(settingsMenu );
2028 settingsMenu->insertSeparator(); 2028 settingsMenu->insertSeparator();
2029 2029
2030 mActionWhoAmI->plug( settingsMenu ); 2030 mActionWhoAmI->plug( settingsMenu );
2031 mActionCategories->plug( settingsMenu ); 2031 mActionCategories->plug( settingsMenu );
2032 2032
2033 2033
2034 mActionWN->plug( helpMenu ); 2034 mActionWN->plug( helpMenu );
2035 mActionSyncHowto->plug( helpMenu ); 2035 mActionSyncHowto->plug( helpMenu );
2036 mActionLicence->plug( helpMenu ); 2036 mActionLicence->plug( helpMenu );
2037 mActionFaq->plug( helpMenu ); 2037 mActionFaq->plug( helpMenu );
2038 mActionAboutKAddressbook->plug( helpMenu ); 2038 mActionAboutKAddressbook->plug( helpMenu );
2039 2039
2040 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2040 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2041 2041
2042 mActionSave->plug( tb ); 2042 mActionSave->plug( tb );
2043 mViewManager->getFilterAction()->plug ( tb); 2043 mViewManager->getFilterAction()->plug ( tb);
2044 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2044 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2045 mActionUndo->plug( tb ); 2045 mActionUndo->plug( tb );
2046 mActionDelete->plug( tb ); 2046 mActionDelete->plug( tb );
2047 mActionRedo->plug( tb ); 2047 mActionRedo->plug( tb );
2048 } 2048 }
2049 } else { 2049 } else {
2050 if (KABPrefs::instance()->mMultipleViewsAtOnce ) 2050 if (KABPrefs::instance()->mMultipleViewsAtOnce )
2051 mActionSave->plug( tb ); 2051 mActionSave->plug( tb );
2052 } 2052 }
2053 //mActionQuit->plug ( tb ); 2053 //mActionQuit->plug ( tb );
2054 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2054 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2055 2055
2056 //US link the searchwidget first to this. 2056 //US link the searchwidget first to this.
2057 // The real linkage to the toolbar happens later. 2057 // The real linkage to the toolbar happens later.
2058//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2058//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2059//US tb->insertItem( mIncSearchWidget ); 2059//US tb->insertItem( mIncSearchWidget );
2060/*US 2060/*US
2061 mIncSearchWidget = new IncSearchWidget( tb ); 2061 mIncSearchWidget = new IncSearchWidget( tb );
2062 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2062 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2063 SLOT( incrementalSearch( const QString& ) ) ); 2063 SLOT( incrementalSearch( const QString& ) ) );
2064 2064
2065 mJumpButtonBar = new JumpButtonBar( this, this ); 2065 mJumpButtonBar = new JumpButtonBar( this, this );
2066 2066
2067//US topLayout->addWidget( mJumpButtonBar ); 2067//US topLayout->addWidget( mJumpButtonBar );
2068 this->layout()->add( mJumpButtonBar ); 2068 this->layout()->add( mJumpButtonBar );
2069*/ 2069*/
2070 2070
2071#endif //KAB_EMBEDDED 2071#endif //KAB_EMBEDDED
2072 2072
2073 mActionExport2phone->plug( ExportMenu ); 2073 mActionExport2phone->plug( ExportMenu );
2074 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2074 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2075 syncManager->fillSyncMenu(); 2075 syncManager->fillSyncMenu();
2076 2076
2077} 2077}
2078void KABCore::showLicence() 2078void KABCore::showLicence()
2079{ 2079{
2080 KApplication::showLicence(); 2080 KApplication::showLicence();
2081} 2081}
2082void KABCore::removeVoice() 2082void KABCore::removeVoice()
2083{ 2083{
2084 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2084 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2085 return; 2085 return;
2086 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2086 KABC::Addressee::List list = mViewManager->selectedAddressees();
2087 KABC::Addressee::List::Iterator it; 2087 KABC::Addressee::List::Iterator it;
2088 for ( it = list.begin(); it != list.end(); ++it ) { 2088 for ( it = list.begin(); it != list.end(); ++it ) {
2089 2089
2090 if ( (*it).removeVoice() ) 2090 if ( (*it).removeVoice() )
2091 contactModified((*it) ); 2091 contactModified((*it) );
2092 } 2092 }
2093} 2093}
2094 2094
2095 2095
2096 2096
2097void KABCore::clipboardDataChanged() 2097void KABCore::clipboardDataChanged()
2098{ 2098{
2099 2099
2100 if ( mReadWrite ) 2100 if ( mReadWrite )
2101 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2101 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2102 2102
2103} 2103}
2104 2104
2105void KABCore::updateActionMenu() 2105void KABCore::updateActionMenu()
2106{ 2106{
2107 UndoStack *undo = UndoStack::instance(); 2107 UndoStack *undo = UndoStack::instance();
2108 RedoStack *redo = RedoStack::instance(); 2108 RedoStack *redo = RedoStack::instance();
2109 2109
2110 if ( undo->isEmpty() ) 2110 if ( undo->isEmpty() )
2111 mActionUndo->setText( i18n( "Undo" ) ); 2111 mActionUndo->setText( i18n( "Undo" ) );
2112 else 2112 else
2113 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2113 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2114 2114
2115 mActionUndo->setEnabled( !undo->isEmpty() ); 2115 mActionUndo->setEnabled( !undo->isEmpty() );
2116 2116
2117 if ( !redo->top() ) 2117 if ( !redo->top() )
2118 mActionRedo->setText( i18n( "Redo" ) ); 2118 mActionRedo->setText( i18n( "Redo" ) );
2119 else 2119 else
2120 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2120 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2121 2121
2122 mActionRedo->setEnabled( !redo->isEmpty() ); 2122 mActionRedo->setEnabled( !redo->isEmpty() );
2123} 2123}
2124 2124
2125void KABCore::configureKeyBindings() 2125void KABCore::configureKeyBindings()
2126{ 2126{
2127#ifndef KAB_EMBEDDED 2127#ifndef KAB_EMBEDDED
2128 KKeyDialog::configure( actionCollection(), true ); 2128 KKeyDialog::configure( actionCollection(), true );
2129#else //KAB_EMBEDDED 2129#else //KAB_EMBEDDED
2130 qDebug("KABCore::configureKeyBindings() not implemented"); 2130 qDebug("KABCore::configureKeyBindings() not implemented");
2131#endif //KAB_EMBEDDED 2131#endif //KAB_EMBEDDED
2132} 2132}
2133 2133
2134#ifdef KAB_EMBEDDED 2134#ifdef KAB_EMBEDDED
2135void KABCore::configureResources() 2135void KABCore::configureResources()
2136{ 2136{
2137 KRES::KCMKResources dlg( this, "" , 0 ); 2137 KRES::KCMKResources dlg( this, "" , 0 );
2138 2138
2139 if ( !dlg.exec() ) 2139 if ( !dlg.exec() )
2140 return; 2140 return;
2141 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2141 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2142} 2142}
2143#endif //KAB_EMBEDDED 2143#endif //KAB_EMBEDDED
2144 2144
2145 2145
2146/* this method will be called through the QCop interface from Ko/Pi to select addresses 2146/* this method will be called through the QCop interface from Ko/Pi to select addresses
2147 * for the attendees list of an event. 2147 * for the attendees list of an event.
2148 */ 2148 */
2149void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2149void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2150{ 2150{
2151 QStringList nameList; 2151 QStringList nameList;
2152 QStringList emailList; 2152 QStringList emailList;
2153 QStringList uidList; 2153 QStringList uidList;
2154 2154
2155 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2155 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2156 uint i=0; 2156 uint i=0;
2157 for (i=0; i < list.count(); i++) 2157 for (i=0; i < list.count(); i++)
2158 { 2158 {
2159 nameList.append(list[i].realName()); 2159 nameList.append(list[i].realName());
2160 emailList.append(list[i].preferredEmail()); 2160 emailList.append(list[i].preferredEmail());
2161 uidList.append(list[i].uid()); 2161 uidList.append(list[i].uid());
2162 } 2162 }
2163 2163
2164 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2164 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2165 2165
2166} 2166}
2167 2167
2168/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2168/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2169 * to put them into the calendar. 2169 * to put them into the calendar.
2170 */ 2170 */
2171void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2171void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2172{ 2172{
2173 // qDebug("KABCore::requestForBirthdayList"); 2173 // qDebug("KABCore::requestForBirthdayList");
2174 QStringList birthdayList; 2174 QStringList birthdayList;
2175 QStringList anniversaryList; 2175 QStringList anniversaryList;
2176 QStringList realNameList; 2176 QStringList realNameList;
2177 QStringList preferredEmailList; 2177 QStringList preferredEmailList;
2178 QStringList assembledNameList; 2178 QStringList assembledNameList;
2179 QStringList uidList; 2179 QStringList uidList;
2180 2180
2181 KABC::AddressBook::Iterator it; 2181 KABC::AddressBook::Iterator it;
2182 2182
2183 int count = 0; 2183 int count = 0;
2184 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2184 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2185 ++count; 2185 ++count;
2186 } 2186 }
2187 QProgressBar bar(count,0 ); 2187 QProgressBar bar(count,0 );
2188 int w = 300; 2188 int w = 300;
2189 if ( QApplication::desktop()->width() < 320 ) 2189 if ( QApplication::desktop()->width() < 320 )
2190 w = 220; 2190 w = 220;
2191 int h = bar.sizeHint().height() ; 2191 int h = bar.sizeHint().height() ;
2192 int dw = QApplication::desktop()->width(); 2192 int dw = QApplication::desktop()->width();
2193 int dh = QApplication::desktop()->height(); 2193 int dh = QApplication::desktop()->height();
2194 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2194 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2195 bar.show(); 2195 bar.show();
2196 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2196 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2197 qApp->processEvents(); 2197 qApp->processEvents();
2198 2198
2199 QDate bday; 2199 QDate bday;
2200 QString anni; 2200 QString anni;
2201 QString formattedbday; 2201 QString formattedbday;
2202 2202
2203 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2203 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2204 { 2204 {
2205 if ( ! bar.isVisible() ) 2205 if ( ! bar.isVisible() )
2206 return; 2206 return;
2207 bar.setProgress( count++ ); 2207 bar.setProgress( count++ );
2208 qApp->processEvents(); 2208 qApp->processEvents();
2209 bday = (*it).birthday().date(); 2209 bday = (*it).birthday().date();
2210 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2210 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2211 2211
2212 if ( bday.isValid() || !anni.isEmpty()) 2212 if ( bday.isValid() || !anni.isEmpty())
2213 { 2213 {
2214 if (bday.isValid()) 2214 if (bday.isValid())
2215 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2215 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2216 else 2216 else
2217 formattedbday = "NOTVALID"; 2217 formattedbday = "NOTVALID";
2218 if (anni.isEmpty()) 2218 if (anni.isEmpty())
2219 anni = "INVALID"; 2219 anni = "INVALID";
2220 2220
2221 birthdayList.append(formattedbday); 2221 birthdayList.append(formattedbday);
2222 anniversaryList.append(anni); //should be ISODate 2222 anniversaryList.append(anni); //should be ISODate
2223 realNameList.append((*it).realName()); 2223 realNameList.append((*it).realName());
2224 preferredEmailList.append((*it).preferredEmail()); 2224 preferredEmailList.append((*it).preferredEmail());
2225 assembledNameList.append((*it).assembledName()); 2225 assembledNameList.append((*it).assembledName());
2226 uidList.append((*it).uid()); 2226 uidList.append((*it).uid());
2227 2227
2228 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2228 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2229 } 2229 }
2230 } 2230 }
2231 2231
2232 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2232 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2233 2233
2234} 2234}
2235 2235
2236/* this method will be called through the QCop interface from other apps to show details of a contact. 2236/* this method will be called through the QCop interface from other apps to show details of a contact.
2237 */ 2237 */
2238void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2238void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2239{ 2239{
2240 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2240 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2241 2241
2242 QString foundUid = QString::null; 2242 QString foundUid = QString::null;
2243 if ( ! uid.isEmpty() ) { 2243 if ( ! uid.isEmpty() ) {
2244 Addressee adrr = mAddressBook->findByUid( uid ); 2244 Addressee adrr = mAddressBook->findByUid( uid );
2245 if ( !adrr.isEmpty() ) { 2245 if ( !adrr.isEmpty() ) {
2246 foundUid = uid; 2246 foundUid = uid;
2247 } 2247 }
2248 if ( email == "sendbacklist" ) { 2248 if ( email == "sendbacklist" ) {
2249 //qDebug("ssssssssssssssssssssssend "); 2249 //qDebug("ssssssssssssssssssssssend ");
2250 QStringList nameList; 2250 QStringList nameList;
2251 QStringList emailList; 2251 QStringList emailList;
2252 QStringList uidList; 2252 QStringList uidList;
2253 nameList.append(adrr.realName()); 2253 nameList.append(adrr.realName());
2254 emailList = adrr.emails(); 2254 emailList = adrr.emails();
2255 uidList.append( adrr.preferredEmail()); 2255 uidList.append( adrr.preferredEmail());
2256 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2256 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2257 return; 2257 return;
2258 } 2258 }
2259 2259
2260 } 2260 }
2261 2261
2262 if ( email == "sendbacklist" ) 2262 if ( email == "sendbacklist" )
2263 return; 2263 return;
2264 if (foundUid.isEmpty()) 2264 if (foundUid.isEmpty())
2265 { 2265 {
2266 //find the uid of the person first 2266 //find the uid of the person first
2267 Addressee::List namelist; 2267 Addressee::List namelist;
2268 Addressee::List emaillist; 2268 Addressee::List emaillist;
2269 2269
2270 if (!name.isEmpty()) 2270 if (!name.isEmpty())
2271 namelist = mAddressBook->findByName( name ); 2271 namelist = mAddressBook->findByName( name );
2272 2272
2273 if (!email.isEmpty()) 2273 if (!email.isEmpty())
2274 emaillist = mAddressBook->findByEmail( email ); 2274 emaillist = mAddressBook->findByEmail( email );
2275 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2275 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2276 //check if we have a match in Namelist and Emaillist 2276 //check if we have a match in Namelist and Emaillist
2277 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2277 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2278 foundUid = emaillist[0].uid(); 2278 foundUid = emaillist[0].uid();
2279 } 2279 }
2280 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2280 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2281 foundUid = namelist[0].uid(); 2281 foundUid = namelist[0].uid();
2282 else 2282 else
2283 { 2283 {
2284 for (int i = 0; i < namelist.count(); i++) 2284 for (int i = 0; i < namelist.count(); i++)
2285 { 2285 {
2286 for (int j = 0; j < emaillist.count(); j++) 2286 for (int j = 0; j < emaillist.count(); j++)
2287 { 2287 {
2288 if (namelist[i] == emaillist[j]) 2288 if (namelist[i] == emaillist[j])
2289 { 2289 {
2290 foundUid = namelist[i].uid(); 2290 foundUid = namelist[i].uid();
2291 } 2291 }
2292 } 2292 }
2293 } 2293 }
2294 } 2294 }
2295 } 2295 }
2296 else 2296 else
2297 { 2297 {
2298 foundUid = uid; 2298 foundUid = uid;
2299 } 2299 }
2300 2300
2301 if (!foundUid.isEmpty()) 2301 if (!foundUid.isEmpty())
2302 { 2302 {
2303 2303
2304 // raise Ka/Pi if it is in the background 2304 // raise Ka/Pi if it is in the background
2305#ifndef DESKTOP_VERSION 2305#ifndef DESKTOP_VERSION
2306#ifndef KORG_NODCOP 2306#ifndef KORG_NODCOP
2307 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2307 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2308#endif 2308#endif
2309#endif 2309#endif
2310 2310
2311 mMainWindow->showMaximized(); 2311 mMainWindow->showMaximized();
2312 mMainWindow-> raise(); 2312 mMainWindow-> raise();
2313 2313
2314 mViewManager->setSelected( "", false); 2314 mViewManager->setSelected( "", false);
2315 mViewManager->refreshView( "" ); 2315 mViewManager->refreshView( "" );
2316 mViewManager->setSelected( foundUid, true ); 2316 mViewManager->setSelected( foundUid, true );
2317 mViewManager->refreshView( foundUid ); 2317 mViewManager->refreshView( foundUid );
2318 2318
2319 if ( !mMultipleViewsAtOnce ) 2319 if ( !mMultipleViewsAtOnce )
2320 { 2320 {
2321 setDetailsVisible( true ); 2321 setDetailsVisible( true );
2322 mActionDetails->setChecked(true); 2322 mActionDetails->setChecked(true);
2323 } 2323 }
2324 } 2324 }
2325} 2325}
2326 2326
2327void KABCore::whatsnew() 2327void KABCore::whatsnew()
2328{ 2328{
2329 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2329 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2330} 2330}
2331void KABCore::synchowto() 2331void KABCore::synchowto()
2332{ 2332{
2333 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2333 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2334} 2334}
2335 2335
2336void KABCore::faq() 2336void KABCore::faq()
2337{ 2337{
2338 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2338 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2339} 2339}
2340 2340
2341#include <libkcal/syncdefines.h> 2341#include <libkcal/syncdefines.h>
2342 2342
2343KABC::Addressee KABCore::getLastSyncAddressee() 2343KABC::Addressee KABCore::getLastSyncAddressee()
2344{ 2344{
2345 Addressee lse; 2345 Addressee lse;
2346 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2346 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2347 2347
2348 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2348 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2349 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2349 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2350 if (lse.isEmpty()) { 2350 if (lse.isEmpty()) {
2351 qDebug("Creating new last-syncAddressee "); 2351 qDebug("Creating new last-syncAddressee ");
2352 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2352 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2353 QString sum = ""; 2353 QString sum = "";
2354 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2354 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2355 sum = "E: "; 2355 sum = "E: ";
2356 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2356 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2357 lse.setRevision( mLastAddressbookSync ); 2357 lse.setRevision( mLastAddressbookSync );
2358 lse.setCategories( i18n("SyncEvent") ); 2358 lse.setCategories( i18n("SyncEvent") );
2359 mAddressBook->insertAddressee( lse ); 2359 mAddressBook->insertAddressee( lse );
2360 } 2360 }
2361 return lse; 2361 return lse;
2362} 2362}
2363int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2363int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2364{ 2364{
2365 2365
2366 //void setZaurusId(int id); 2366 //void setZaurusId(int id);
2367 // int zaurusId() const; 2367 // int zaurusId() const;
2368 // void setZaurusUid(int id); 2368 // void setZaurusUid(int id);
2369 // int zaurusUid() const; 2369 // int zaurusUid() const;
2370 // void setZaurusStat(int id); 2370 // void setZaurusStat(int id);
2371 // int zaurusStat() const; 2371 // int zaurusStat() const;
2372 // 0 equal 2372 // 0 equal
2373 // 1 take local 2373 // 1 take local
2374 // 2 take remote 2374 // 2 take remote
2375 // 3 cancel 2375 // 3 cancel
2376 QDateTime lastSync = mLastAddressbookSync; 2376 QDateTime lastSync = mLastAddressbookSync;
2377 QDateTime localMod = local->revision(); 2377 QDateTime localMod = local->revision();
2378 QDateTime remoteMod = remote->revision(); 2378 QDateTime remoteMod = remote->revision();
2379 2379
2380 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2380 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2381 2381
2382 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2382 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2383 bool remCh, locCh; 2383 bool remCh, locCh;
2384 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2384 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2385 2385
2386 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2386 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2387 locCh = ( localMod > mLastAddressbookSync ); 2387 locCh = ( localMod > mLastAddressbookSync );
2388 if ( !remCh && ! locCh ) { 2388 if ( !remCh && ! locCh ) {
2389 //qDebug("both not changed "); 2389 //qDebug("both not changed ");
2390 lastSync = localMod.addDays(1); 2390 lastSync = localMod.addDays(1);
2391 if ( mode <= SYNC_PREF_ASK ) 2391 if ( mode <= SYNC_PREF_ASK )
2392 return 0; 2392 return 0;
2393 } else { 2393 } else {
2394 if ( locCh ) { 2394 if ( locCh ) {
2395 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2395 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2396 lastSync = localMod.addDays( -1 ); 2396 lastSync = localMod.addDays( -1 );
2397 if ( !remCh ) 2397 if ( !remCh )
2398 remoteMod =( lastSync.addDays( -1 ) ); 2398 remoteMod =( lastSync.addDays( -1 ) );
2399 } else { 2399 } else {
2400 //qDebug(" not loc changed "); 2400 //qDebug(" not loc changed ");
2401 lastSync = localMod.addDays( 1 ); 2401 lastSync = localMod.addDays( 1 );
2402 if ( remCh ) 2402 if ( remCh )
2403 remoteMod =( lastSync.addDays( 1 ) ); 2403 remoteMod =( lastSync.addDays( 1 ) );
2404 2404
2405 } 2405 }
2406 } 2406 }
2407 full = true; 2407 full = true;
2408 if ( mode < SYNC_PREF_ASK ) 2408 if ( mode < SYNC_PREF_ASK )
2409 mode = SYNC_PREF_ASK; 2409 mode = SYNC_PREF_ASK;
2410 } else { 2410 } else {
2411 if ( localMod == remoteMod ) 2411 if ( localMod == remoteMod )
2412 return 0; 2412 return 0;
2413 2413
2414 } 2414 }
2415 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2415 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2416 2416
2417 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2417 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2418 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2418 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2419 //full = true; //debug only 2419 //full = true; //debug only
2420 if ( full ) { 2420 if ( full ) {
2421 bool equ = ( (*local) == (*remote) ); 2421 bool equ = ( (*local) == (*remote) );
2422 if ( equ ) { 2422 if ( equ ) {
2423 //qDebug("equal "); 2423 //qDebug("equal ");
2424 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2424 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2425 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2425 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2426 } 2426 }
2427 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2427 if ( mode < SYNC_PREF_FORCE_LOCAL )
2428 return 0; 2428 return 0;
2429 2429
2430 }//else //debug only 2430 }//else //debug only
2431 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2431 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2432 } 2432 }
2433 int result; 2433 int result;
2434 bool localIsNew; 2434 bool localIsNew;
2435 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2435 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2436 2436
2437 if ( full && mode < SYNC_PREF_NEWEST ) 2437 if ( full && mode < SYNC_PREF_NEWEST )
2438 mode = SYNC_PREF_ASK; 2438 mode = SYNC_PREF_ASK;
2439 2439
2440 switch( mode ) { 2440 switch( mode ) {
2441 case SYNC_PREF_LOCAL: 2441 case SYNC_PREF_LOCAL:
2442 if ( lastSync > remoteMod ) 2442 if ( lastSync > remoteMod )
2443 return 1; 2443 return 1;
2444 if ( lastSync > localMod ) 2444 if ( lastSync > localMod )
2445 return 2; 2445 return 2;
2446 return 1; 2446 return 1;
2447 break; 2447 break;
2448 case SYNC_PREF_REMOTE: 2448 case SYNC_PREF_REMOTE:
2449 if ( lastSync > remoteMod ) 2449 if ( lastSync > remoteMod )
2450 return 1; 2450 return 1;
2451 if ( lastSync > localMod ) 2451 if ( lastSync > localMod )
2452 return 2; 2452 return 2;
2453 return 2; 2453 return 2;
2454 break; 2454 break;
2455 case SYNC_PREF_NEWEST: 2455 case SYNC_PREF_NEWEST:
2456 if ( localMod > remoteMod ) 2456 if ( localMod > remoteMod )
2457 return 1; 2457 return 1;
2458 else 2458 else
2459 return 2; 2459 return 2;
2460 break; 2460 break;
2461 case SYNC_PREF_ASK: 2461 case SYNC_PREF_ASK:
2462 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2462 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2463 if ( lastSync > remoteMod ) 2463 if ( lastSync > remoteMod )
2464 return 1; 2464 return 1;
2465 if ( lastSync > localMod ) 2465 if ( lastSync > localMod )
2466 return 2; 2466 return 2;
2467 localIsNew = localMod >= remoteMod; 2467 localIsNew = localMod >= remoteMod;
2468 //qDebug("conflict! ************************************** "); 2468 //qDebug("conflict! ************************************** ");
2469 { 2469 {
2470 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2470 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2471 result = acd.executeD(localIsNew); 2471 result = acd.executeD(localIsNew);
2472 return result; 2472 return result;
2473 } 2473 }
2474 break; 2474 break;
2475 case SYNC_PREF_FORCE_LOCAL: 2475 case SYNC_PREF_FORCE_LOCAL:
2476 return 1; 2476 return 1;
2477 break; 2477 break;
2478 case SYNC_PREF_FORCE_REMOTE: 2478 case SYNC_PREF_FORCE_REMOTE:
2479 return 2; 2479 return 2;
2480 break; 2480 break;
2481 2481
2482 default: 2482 default:
2483 // SYNC_PREF_TAKE_BOTH not implemented 2483 // SYNC_PREF_TAKE_BOTH not implemented
2484 break; 2484 break;
2485 } 2485 }
2486 return 0; 2486 return 0;
2487} 2487}
2488 2488
2489 2489
2490bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2490bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2491{ 2491{
2492 bool syncOK = true; 2492 bool syncOK = true;
2493 int addedAddressee = 0; 2493 int addedAddressee = 0;
2494 int addedAddresseeR = 0; 2494 int addedAddresseeR = 0;
2495 int deletedAddresseeR = 0; 2495 int deletedAddresseeR = 0;
2496 int deletedAddresseeL = 0; 2496 int deletedAddresseeL = 0;
2497 int changedLocal = 0; 2497 int changedLocal = 0;
2498 int changedRemote = 0; 2498 int changedRemote = 0;
2499 2499
2500 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2500 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2501 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2501 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2502 2502
2503 //QPtrList<Addressee> el = local->rawAddressees(); 2503 //QPtrList<Addressee> el = local->rawAddressees();
2504 Addressee addresseeR; 2504 Addressee addresseeR;
2505 QString uid; 2505 QString uid;
2506 int take; 2506 int take;
2507 Addressee addresseeL; 2507 Addressee addresseeL;
2508 Addressee addresseeRSync; 2508 Addressee addresseeRSync;
2509 Addressee addresseeLSync; 2509 Addressee addresseeLSync;
2510 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2510 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2511 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2511 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2512 bool fullDateRange = false; 2512 bool fullDateRange = false;
2513 local->resetTempSyncStat(); 2513 local->resetTempSyncStat();
2514 mLastAddressbookSync = QDateTime::currentDateTime(); 2514 mLastAddressbookSync = QDateTime::currentDateTime();
2515 if ( syncManager->syncWithDesktop() ) { 2515 if ( syncManager->syncWithDesktop() ) {
2516 remote->removeSyncInfo( QString());//remove all info 2516 // remote->removeSyncInfo( QString());//remove all info
2517 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2517 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2518 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2518 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2519 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2519 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2520 } else { 2520 } else {
2521 qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); 2521 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2522 } 2522 }
2523 } 2523 }
2524 QDateTime modifiedCalendar = mLastAddressbookSync; 2524 QDateTime modifiedCalendar = mLastAddressbookSync;
2525 addresseeLSync = getLastSyncAddressee(); 2525 addresseeLSync = getLastSyncAddressee();
2526 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2526 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2527 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2527 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2528 if ( !addresseeR.isEmpty() ) { 2528 if ( !addresseeR.isEmpty() ) {
2529 addresseeRSync = addresseeR; 2529 addresseeRSync = addresseeR;
2530 remote->removeAddressee(addresseeR ); 2530 remote->removeAddressee(addresseeR );
2531 2531
2532 } else { 2532 } else {
2533 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2533 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2534 addresseeRSync = addresseeLSync ; 2534 addresseeRSync = addresseeLSync ;
2535 } else { 2535 } else {
2536 qDebug("FULLDATE 1"); 2536 qDebug("FULLDATE 1");
2537 fullDateRange = true; 2537 fullDateRange = true;
2538 Addressee newAdd; 2538 Addressee newAdd;
2539 addresseeRSync = newAdd; 2539 addresseeRSync = newAdd;
2540 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2540 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2541 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2541 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2542 addresseeRSync.setRevision( mLastAddressbookSync ); 2542 addresseeRSync.setRevision( mLastAddressbookSync );
2543 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2543 addresseeRSync.setCategories( i18n("SyncAddressee") );
2544 } 2544 }
2545 } 2545 }
2546 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2546 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2547 qDebug("FULLDATE 2"); 2547 qDebug("FULLDATE 2");
2548 fullDateRange = true; 2548 fullDateRange = true;
2549 } 2549 }
2550 if ( ! fullDateRange ) { 2550 if ( ! fullDateRange ) {
2551 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2551 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2552 2552
2553 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2553 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2554 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2554 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2555 fullDateRange = true; 2555 fullDateRange = true;
2556 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2556 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2557 } 2557 }
2558 } 2558 }
2559 // fullDateRange = true; // debug only! 2559 // fullDateRange = true; // debug only!
2560 if ( fullDateRange ) 2560 if ( fullDateRange )
2561 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2561 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2562 else 2562 else
2563 mLastAddressbookSync = addresseeLSync.revision(); 2563 mLastAddressbookSync = addresseeLSync.revision();
2564 // for resyncing if own file has changed 2564 // for resyncing if own file has changed
2565 // PENDING fixme later when implemented 2565 // PENDING fixme later when implemented
2566#if 0 2566#if 0
2567 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2567 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2568 mLastAddressbookSync = loadedFileVersion; 2568 mLastAddressbookSync = loadedFileVersion;
2569 qDebug("setting mLastAddressbookSync "); 2569 qDebug("setting mLastAddressbookSync ");
2570 } 2570 }
2571#endif 2571#endif
2572 2572
2573 //qDebug("*************************** "); 2573 //qDebug("*************************** ");
2574 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2574 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2575 QStringList er = remote->uidList(); 2575 QStringList er = remote->uidList();
2576 Addressee inR ;//= er.first(); 2576 Addressee inR ;//= er.first();
2577 Addressee inL; 2577 Addressee inL;
2578 2578
2579 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2579 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2580 2580
2581 int modulo = (er.count()/10)+1; 2581 int modulo = (er.count()/10)+1;
2582 int incCounter = 0; 2582 int incCounter = 0;
2583 while ( incCounter < er.count()) { 2583 while ( incCounter < er.count()) {
2584 if (syncManager->isProgressBarCanceled()) 2584 if (syncManager->isProgressBarCanceled())
2585 return false; 2585 return false;
2586 if ( incCounter % modulo == 0 ) 2586 if ( incCounter % modulo == 0 )
2587 syncManager->showProgressBar(incCounter); 2587 syncManager->showProgressBar(incCounter);
2588 2588
2589 uid = er[ incCounter ]; 2589 uid = er[ incCounter ];
2590 bool skipIncidence = false; 2590 bool skipIncidence = false;
2591 if ( uid.left(19) == QString("last-syncAddressee-") ) 2591 if ( uid.left(19) == QString("last-syncAddressee-") )
2592 skipIncidence = true; 2592 skipIncidence = true;
2593 QString idS,OidS; 2593 QString idS,OidS;
2594 qApp->processEvents(); 2594 qApp->processEvents();
2595 if ( !skipIncidence ) { 2595 if ( !skipIncidence ) {
2596 inL = local->findByUid( uid ); 2596 inL = local->findByUid( uid );
2597 inR = remote->findByUid( uid ); 2597 inR = remote->findByUid( uid );
2598 //inL.setResource( 0 ); 2598 //inL.setResource( 0 );
2599 //inR.setResource( 0 ); 2599 //inR.setResource( 0 );
2600 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2600 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2601 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2601 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2602 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2602 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2603 //qDebug("take %d %s ", take, inL.summary().latin1()); 2603 //qDebug("take %d %s ", take, inL.summary().latin1());
2604 if ( take == 3 ) 2604 if ( take == 3 )
2605 return false; 2605 return false;
2606 if ( take == 1 ) {// take local 2606 if ( take == 1 ) {// take local
2607 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2607 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2608 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2608 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2609 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2609 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2610 local->insertAddressee( inL, false ); 2610 local->insertAddressee( inL, false );
2611 idS = inR.externalUID(); 2611 idS = inR.externalUID();
2612 OidS = inR.originalExternalUID(); 2612 OidS = inR.originalExternalUID();
2613 } 2613 }
2614 else 2614 else
2615 idS = inR.IDStr(); 2615 idS = inR.IDStr();
2616 remote->removeAddressee( inR ); 2616 remote->removeAddressee( inR );
2617 inR = inL; 2617 inR = inL;
2618 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2618 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2619 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2619 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2620 inR.setOriginalExternalUID( OidS ); 2620 inR.setOriginalExternalUID( OidS );
2621 inR.setExternalUID( idS ); 2621 inR.setExternalUID( idS );
2622 if ( syncManager->syncWithDesktop() ) 2622 if ( syncManager->syncWithDesktop() )
2623 inR.setIDStr( "changed" ); 2623 inR.setIDStr("changed" );
2624 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2624 } else { 2625 } else {
2625 inR.setIDStr( idS ); 2626 inR.setIDStr( idS );
2626 } 2627 }
2627 inR.setResource( 0 ); 2628 inR.setResource( 0 );
2628 remote->insertAddressee( inR , false); 2629 remote->insertAddressee( inR , false);
2629 ++changedRemote; 2630 ++changedRemote;
2630 } else { // take == 2 take remote 2631 } else { // take == 2 take remote
2631 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2632 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2632 if ( inR.revision().date().year() < 2004 ) 2633 if ( inR.revision().date().year() < 2004 )
2633 inR.setRevision( modifiedCalendar ); 2634 inR.setRevision( modifiedCalendar );
2634 } 2635 }
2635 idS = inL.IDStr(); 2636 idS = inL.IDStr();
2636 local->removeAddressee( inL ); 2637 local->removeAddressee( inL );
2637 inL = inR; 2638 inL = inR;
2638 inL.setIDStr( idS ); 2639 inL.setIDStr( idS );
2639 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2640 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2640 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2641 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2641 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2642 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2642 } 2643 }
2643 inL.setResource( 0 ); 2644 inL.setResource( 0 );
2644 local->insertAddressee( inL , false ); 2645 local->insertAddressee( inL , false );
2645 ++changedLocal; 2646 ++changedLocal;
2646 } 2647 }
2647 } 2648 }
2648 } 2649 }
2649 } else { // no conflict 2650 } else { // no conflict
2650 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2651 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2651 QString des = addresseeLSync.note(); 2652 QString des = addresseeLSync.note();
2652 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2653 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2653 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2654 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2654 remote->insertAddressee( inR, false ); 2655 remote->insertAddressee( inR, false );
2655 ++deletedAddresseeR; 2656 ++deletedAddresseeR;
2656 } else { 2657 } else {
2657 inR.setRevision( modifiedCalendar ); 2658 inR.setRevision( modifiedCalendar );
2658 remote->insertAddressee( inR, false ); 2659 remote->insertAddressee( inR, false );
2659 inL = inR; 2660 inL = inR;
2660 inL.setResource( 0 ); 2661 inL.setResource( 0 );
2661 local->insertAddressee( inL , false); 2662 local->insertAddressee( inL , false);
2662 ++addedAddressee; 2663 ++addedAddressee;
2663 } 2664 }
2664 } else { 2665 } else {
2665 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2666 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2666 inR.setRevision( modifiedCalendar ); 2667 inR.setRevision( modifiedCalendar );
2667 remote->insertAddressee( inR, false ); 2668 remote->insertAddressee( inR, false );
2668 inR.setResource( 0 ); 2669 inR.setResource( 0 );
2669 local->insertAddressee( inR, false ); 2670 local->insertAddressee( inR, false );
2670 ++addedAddressee; 2671 ++addedAddressee;
2671 } else { 2672 } else {
2672 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2673 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2673 remote->removeAddressee( inR ); 2674 remote->removeAddressee( inR );
2674 ++deletedAddresseeR; 2675 ++deletedAddresseeR;
2675 } 2676 }
2676 } 2677 }
2677 } 2678 }
2678 } 2679 }
2679 ++incCounter; 2680 ++incCounter;
2680 } 2681 }
2681 er.clear(); 2682 er.clear();
2682 QStringList el = local->uidList(); 2683 QStringList el = local->uidList();
2683 modulo = (el.count()/10)+1; 2684 modulo = (el.count()/10)+1;
2684 2685
2685 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2686 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2686 incCounter = 0; 2687 incCounter = 0;
2687 while ( incCounter < el.count()) { 2688 while ( incCounter < el.count()) {
2688 qApp->processEvents(); 2689 qApp->processEvents();
2689 if (syncManager->isProgressBarCanceled()) 2690 if (syncManager->isProgressBarCanceled())
2690 return false; 2691 return false;
2691 if ( incCounter % modulo == 0 ) 2692 if ( incCounter % modulo == 0 )
2692 syncManager->showProgressBar(incCounter); 2693 syncManager->showProgressBar(incCounter);
2693 uid = el[ incCounter ]; 2694 uid = el[ incCounter ];
2694 bool skipIncidence = false; 2695 bool skipIncidence = false;
2695 if ( uid.left(19) == QString("last-syncAddressee-") ) 2696 if ( uid.left(19) == QString("last-syncAddressee-") )
2696 skipIncidence = true; 2697 skipIncidence = true;
2697 if ( !skipIncidence ) { 2698 if ( !skipIncidence ) {
2698 inL = local->findByUid( uid ); 2699 inL = local->findByUid( uid );
2699 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2700 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2700 inR = remote->findByUid( uid ); 2701 inR = remote->findByUid( uid );
2701 if ( inR.isEmpty() ) { 2702 if ( inR.isEmpty() ) {
2702 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2703 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2703 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2704 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2704 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2705 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2705 local->removeAddressee( inL ); 2706 local->removeAddressee( inL );
2706 ++deletedAddresseeL; 2707 ++deletedAddresseeL;
2707 } else { 2708 } else {
2708 if ( ! syncManager->mWriteBackExistingOnly ) { 2709 if ( ! syncManager->mWriteBackExistingOnly ) {
2709 inL.removeID(mCurrentSyncDevice ); 2710 inL.removeID(mCurrentSyncDevice );
2710 ++addedAddresseeR; 2711 ++addedAddresseeR;
2711 inL.setRevision( modifiedCalendar ); 2712 inL.setRevision( modifiedCalendar );
2712 local->insertAddressee( inL, false ); 2713 local->insertAddressee( inL, false );
2713 inR = inL; 2714 inR = inL;
2714 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2715 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2715 inR.setResource( 0 ); 2716 inR.setResource( 0 );
2716 remote->insertAddressee( inR, false ); 2717 remote->insertAddressee( inR, false );
2717 } 2718 }
2718 } 2719 }
2719 } else { 2720 } else {
2720 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2721 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2721 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2722 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2722 local->removeAddressee( inL ); 2723 local->removeAddressee( inL );
2723 ++deletedAddresseeL; 2724 ++deletedAddresseeL;
2724 } else { 2725 } else {
2725 if ( ! syncManager->mWriteBackExistingOnly ) { 2726 if ( ! syncManager->mWriteBackExistingOnly ) {
2726 ++addedAddresseeR; 2727 ++addedAddresseeR;
2727 inL.setRevision( modifiedCalendar ); 2728 inL.setRevision( modifiedCalendar );
2728 local->insertAddressee( inL, false ); 2729 local->insertAddressee( inL, false );
2729 inR = inL; 2730 inR = inL;
2730 inR.setResource( 0 ); 2731 inR.setResource( 0 );
2731 remote->insertAddressee( inR, false ); 2732 remote->insertAddressee( inR, false );
2732 } 2733 }
2733 } 2734 }
2734 } 2735 }
2735 } 2736 }
2736 } 2737 }
2737 } 2738 }
2738 ++incCounter; 2739 ++incCounter;
2739 } 2740 }
2740 el.clear(); 2741 el.clear();
2741 syncManager->hideProgressBar(); 2742 syncManager->hideProgressBar();
2742 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2743 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2743 // get rid of micro seconds 2744 // get rid of micro seconds
2744 QTime t = mLastAddressbookSync.time(); 2745 QTime t = mLastAddressbookSync.time();
2745 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2746 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2746 addresseeLSync.setRevision( mLastAddressbookSync ); 2747 addresseeLSync.setRevision( mLastAddressbookSync );
2747 addresseeRSync.setRevision( mLastAddressbookSync ); 2748 addresseeRSync.setRevision( mLastAddressbookSync );
2748 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2749 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2749 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2750 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2750 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2751 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2751 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2752 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2752 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2753 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2753 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2754 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2754 addresseeRSync.setNote( "" ) ; 2755 addresseeRSync.setNote( "" ) ;
2755 addresseeLSync.setNote( "" ); 2756 addresseeLSync.setNote( "" );
2756 2757
2757 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2758 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2758 remote->insertAddressee( addresseeRSync, false ); 2759 remote->insertAddressee( addresseeRSync, false );
2759 local->insertAddressee( addresseeLSync, false ); 2760 local->insertAddressee( addresseeLSync, false );
2760 QString mes; 2761 QString mes;
2761 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2762 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2762 if ( syncManager->mShowSyncSummary ) { 2763 if ( syncManager->mShowSyncSummary ) {
2763 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2764 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2764 } 2765 }
2765 qDebug( mes ); 2766 qDebug( mes );
2766 return syncOK; 2767 return syncOK;
2767} 2768}
2768 2769
2769 2770
2770//this is a overwritten callbackmethods from the syncinterface 2771//this is a overwritten callbackmethods from the syncinterface
2771bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2772bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2772{ 2773{
2773 2774
2774 //pending prepare addresseeview for output 2775 //pending prepare addresseeview for output
2775 //pending detect, if remote file has REV field. if not switch to external sync 2776 //pending detect, if remote file has REV field. if not switch to external sync
2776 mGlobalSyncMode = SYNC_MODE_NORMAL; 2777 mGlobalSyncMode = SYNC_MODE_NORMAL;
2777 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2778 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2778 2779
2779 AddressBook abLocal(filename,"syncContact"); 2780 AddressBook abLocal(filename,"syncContact");
2780 bool syncOK = false; 2781 bool syncOK = false;
2781 if ( abLocal.load() ) { 2782 if ( abLocal.load() ) {
2782 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2783 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2783 bool external = false; 2784 bool external = false;
2784 bool isXML = false; 2785 bool isXML = false;
2785 if ( filename.right(4) == ".xml") { 2786 if ( filename.right(4) == ".xml") {
2786 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2787 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2787 isXML = true; 2788 isXML = true;
2788 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2789 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2789 } else { 2790 } else {
2790 external = !manager->mIsKapiFile; 2791 external = !manager->mIsKapiFile;
2791 if ( external ) { 2792 if ( external ) {
2792 qDebug("Setting vcf mode to external "); 2793 qDebug("Setting vcf mode to external ");
2793 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2794 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2794 AddressBook::Iterator it; 2795 AddressBook::Iterator it;
2795 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2796 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2796 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2797 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2797 (*it).computeCsum( mCurrentSyncDevice ); 2798 (*it).computeCsum( mCurrentSyncDevice );
2798 } 2799 }
2799 } 2800 }
2800 } 2801 }
2801 //AddressBook::Iterator it; 2802 //AddressBook::Iterator it;
2802 //QStringList vcards; 2803 //QStringList vcards;
2803 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2804 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2804 // qDebug("Name %s ", (*it).familyName().latin1()); 2805 // qDebug("Name %s ", (*it).familyName().latin1());
2805 //} 2806 //}
2806 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2807 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2807 if ( syncOK ) { 2808 if ( syncOK ) {
2808 if ( syncManager->mWriteBackFile ) 2809 if ( syncManager->mWriteBackFile )
2809 { 2810 {
2810 if ( external ) 2811 if ( external )
2811 abLocal.removeSyncAddressees( !isXML); 2812 abLocal.removeSyncAddressees( !isXML);
2812 qDebug("Saving remote AB "); 2813 qDebug("Saving remote AB ");
2813 if ( ! abLocal.saveAB()) 2814 if ( ! abLocal.saveAB())
2814 qDebug("Error writing back AB to file "); 2815 qDebug("Error writing back AB to file ");
2815 if ( isXML ) { 2816 if ( external ) {
2816 // afterwrite processing 2817 // afterwrite processing
2817 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2818 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
2818 } 2819 }
2819 } 2820 }
2820 } 2821 }
2821 setModified(); 2822 setModified();
2822 2823
2823 } 2824 }
2824 if ( syncOK ) 2825 if ( syncOK )
2825 mViewManager->refreshView(); 2826 mViewManager->refreshView();
2826 return syncOK; 2827 return syncOK;
2827 2828
2828} 2829}
2829void KABCore::removeSyncInfo( QString syncProfile) 2830void KABCore::removeSyncInfo( QString syncProfile)
2830{ 2831{
2831 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 2832 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
2832 mAddressBook->removeSyncInfo( syncProfile ); 2833 mAddressBook->removeSyncInfo( syncProfile );
2834 setModified();
2833} 2835}
2834 2836
2835 2837
2836//this is a overwritten callbackmethods from the syncinterface 2838//this is a overwritten callbackmethods from the syncinterface
2837bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2839bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2838{ 2840{
2839 if ( resource == "phone" ) 2841 if ( resource == "phone" )
2840 return syncPhone(); 2842 return syncPhone();
2841 disableBR( true ); 2843 disableBR( true );
2842 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2844 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2843 2845
2844 AddressBook abLocal( resource,"syncContact"); 2846 AddressBook abLocal( resource,"syncContact");
2845 bool syncOK = false; 2847 bool syncOK = false;
2846 if ( abLocal.load() ) { 2848 if ( abLocal.load() ) {
2847 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2849 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2848 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2850 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2849 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 2851 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
2850 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2852 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2851 if ( syncOK ) { 2853 if ( syncOK ) {
2852 if ( syncManager->mWriteBackFile ) { 2854 if ( syncManager->mWriteBackFile ) {
2853 abLocal.removeSyncAddressees( false ); 2855 abLocal.removeSyncAddressees( false );
2854 abLocal.saveAB(); 2856 abLocal.saveAB();
2855 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2857 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
2856 } 2858 }
2857 } 2859 }
2858 setModified(); 2860 setModified();
2859 } 2861 }
2860 if ( syncOK ) 2862 if ( syncOK )
2861 mViewManager->refreshView(); 2863 mViewManager->refreshView();
2862 disableBR( false ); 2864 disableBR( false );
2863 return syncOK; 2865 return syncOK;
2864 2866
2865} 2867}
2866void KABCore::message( QString m ) 2868void KABCore::message( QString m )
2867{ 2869{
2868 topLevelWidget()->setCaption( m ); 2870 topLevelWidget()->setCaption( m );
2869 mMessageTimer->start( 15000, true ); 2871 mMessageTimer->start( 15000, true );
2870} 2872}
2871bool KABCore::syncPhone() 2873bool KABCore::syncPhone()
2872{ 2874{
2873 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2875 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2874 QString fileName = getPhoneFile(); 2876 QString fileName = getPhoneFile();
2875 if ( !PhoneAccess::readFromPhone( fileName) ) { 2877 if ( !PhoneAccess::readFromPhone( fileName) ) {
2876 message(i18n("Phone access failed!")); 2878 message(i18n("Phone access failed!"));
2877 return false; 2879 return false;
2878 } 2880 }
2879 AddressBook abLocal( fileName,"syncContact"); 2881 AddressBook abLocal( fileName,"syncContact");
2880 bool syncOK = false; 2882 bool syncOK = false;
2881 { 2883 {
2882 abLocal.importFromFile( fileName ); 2884 abLocal.importFromFile( fileName );
2883 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2885 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2884 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2886 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2885 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2887 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2886 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2888 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2887 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2889 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2888 if ( syncOK ) { 2890 if ( syncOK ) {
2889 if ( syncManager->mWriteBackFile ) { 2891 if ( syncManager->mWriteBackFile ) {
2890 abLocal.removeSyncAddressees( true ); 2892 abLocal.removeSyncAddressees( true );
2891 abLocal.saveABphone( fileName ); 2893 abLocal.saveABphone( fileName );
2892 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 2894 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2893 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2895 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2894 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2896 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
2895 } 2897 }
2896 } 2898 }
2897 setModified(); 2899 setModified();
2898 } 2900 }
2899 if ( syncOK ) 2901 if ( syncOK )
2900 mViewManager->refreshView(); 2902 mViewManager->refreshView();
2901 return syncOK; 2903 return syncOK;
2902} 2904}
2903void KABCore::getFile( bool success ) 2905void KABCore::getFile( bool success )
2904{ 2906{
2905 if ( ! success ) { 2907 if ( ! success ) {
2906 message( i18n("Error receiving file. Nothing changed!") ); 2908 message( i18n("Error receiving file. Nothing changed!") );
2907 return; 2909 return;
2908 } 2910 }
2909 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 2911 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
2910 if ( count ) 2912 if ( count )
2911 setModified( true ); 2913 setModified( true );
2912 message( i18n("Pi-Sync successful!") ); 2914 message( i18n("Pi-Sync successful!") );
2913 mViewManager->refreshView(); 2915 mViewManager->refreshView();
2914} 2916}
2915void KABCore::syncFileRequest() 2917void KABCore::syncFileRequest()
2916{ 2918{
2917 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 2919 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
2918 syncManager->slotSyncMenu( 999 ); 2920 syncManager->slotSyncMenu( 999 );
2919 } 2921 }
2920 mAddressBook->export2File( sentSyncFile() ); 2922 mAddressBook->export2File( sentSyncFile() );
2921} 2923}
2922QString KABCore::sentSyncFile() 2924QString KABCore::sentSyncFile()
2923{ 2925{
2924#ifdef DESKTOP_VERSION 2926#ifdef DESKTOP_VERSION
2925 return locateLocal( "tmp", "copysyncab.vcf" ); 2927 return locateLocal( "tmp", "copysyncab.vcf" );
2926#else 2928#else
2927 return QString( "/tmp/copysyncab.vcf" ); 2929 return QString( "/tmp/copysyncab.vcf" );
2928#endif 2930#endif
2929} 2931}
2930 2932
2931void KABCore::setCaptionBack() 2933void KABCore::setCaptionBack()
2932{ 2934{
2933 mMessageTimer->stop(); 2935 mMessageTimer->stop();
2934 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2936 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2935} 2937}