author | ulf69 <ulf69> | 2004-10-22 22:32:19 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-22 22:32:19 (UTC) |
commit | 6b99c0feac04963f814a32586268ecac966f3d51 (patch) (unidiff) | |
tree | ca8bf4e29d082360b1e6e64ce9ec4630324e01f4 /kaddressbook | |
parent | b8da6435b8e5941eb1824873e68d8a6a728fae5e (diff) | |
download | kdepimpi-6b99c0feac04963f814a32586268ecac966f3d51.zip kdepimpi-6b99c0feac04963f814a32586268ecac966f3d51.tar.gz kdepimpi-6b99c0feac04963f814a32586268ecac966f3d51.tar.bz2 |
removed typos "beam received"
-rw-r--r-- | kaddressbook/kabcore.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index c4382d6..4c1d5da 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1078,1537 +1078,1537 @@ void KABCore::newContact() | |||
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 | ||
1096 | void KABCore::addEmail( QString aStr ) | 1096 | void 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 | ||
1130 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1130 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1131 | { | 1131 | { |
1132 | mXXPortManager->importVCard( url, showPreview ); | 1132 | mXXPortManager->importVCard( url, showPreview ); |
1133 | } | 1133 | } |
1134 | void KABCore::importFromOL() | 1134 | void 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 | ||
1163 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1163 | void 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 |
1169 | void KABCore::editContact2() { | 1169 | void KABCore::editContact2() { |
1170 | editContact( QString::null ); | 1170 | editContact( QString::null ); |
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | void KABCore::editContact( const QString &uid ) | 1173 | void 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 | */ |
1198 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1198 | void 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 | ||
1212 | void KABCore::save() | 1212 | void 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 | ||
1242 | void KABCore::undo() | 1242 | void 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 | ||
1250 | void KABCore::redo() | 1250 | void 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 | ||
1258 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1258 | void 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 | ||
1285 | void KABCore::setDetailsToState() | 1285 | void KABCore::setDetailsToState() |
1286 | { | 1286 | { |
1287 | setDetailsVisible( mActionDetails->isChecked() ); | 1287 | setDetailsVisible( mActionDetails->isChecked() ); |
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | 1290 | ||
1291 | 1291 | ||
1292 | void KABCore::setDetailsVisible( bool visible ) | 1292 | void 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 | } | 1315 | } |
1316 | else { | 1316 | else { |
1317 | mViewManager->show(); | 1317 | mViewManager->show(); |
1318 | mDetails->hide(); | 1318 | mDetails->hide(); |
1319 | } | 1319 | } |
1320 | setJumpButtonBarVisible( !visible ); | 1320 | setJumpButtonBarVisible( !visible ); |
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | } | 1323 | } |
1324 | 1324 | ||
1325 | void KABCore::extensionChanged( int id ) | 1325 | void KABCore::extensionChanged( int id ) |
1326 | { | 1326 | { |
1327 | //change the details view only for non desktop systems | 1327 | //change the details view only for non desktop systems |
1328 | #ifndef DESKTOP_VERSION | 1328 | #ifndef DESKTOP_VERSION |
1329 | 1329 | ||
1330 | if (id == 0) | 1330 | if (id == 0) |
1331 | { | 1331 | { |
1332 | //the user disabled the extension. | 1332 | //the user disabled the extension. |
1333 | 1333 | ||
1334 | if (mMultipleViewsAtOnce) | 1334 | if (mMultipleViewsAtOnce) |
1335 | { // enable detailsview again | 1335 | { // enable detailsview again |
1336 | setDetailsVisible( true ); | 1336 | setDetailsVisible( true ); |
1337 | mActionDetails->setChecked( true ); | 1337 | mActionDetails->setChecked( true ); |
1338 | } | 1338 | } |
1339 | else | 1339 | else |
1340 | { //go back to the listview | 1340 | { //go back to the listview |
1341 | setDetailsVisible( false ); | 1341 | setDetailsVisible( false ); |
1342 | mActionDetails->setChecked( false ); | 1342 | mActionDetails->setChecked( false ); |
1343 | mActionDetails->setEnabled(true); | 1343 | mActionDetails->setEnabled(true); |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | } | 1346 | } |
1347 | else | 1347 | else |
1348 | { | 1348 | { |
1349 | //the user enabled the extension. | 1349 | //the user enabled the extension. |
1350 | setDetailsVisible( false ); | 1350 | setDetailsVisible( false ); |
1351 | mActionDetails->setChecked( false ); | 1351 | mActionDetails->setChecked( false ); |
1352 | 1352 | ||
1353 | if (!mMultipleViewsAtOnce) | 1353 | if (!mMultipleViewsAtOnce) |
1354 | { | 1354 | { |
1355 | mActionDetails->setEnabled(false); | 1355 | mActionDetails->setEnabled(false); |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | mExtensionManager->setSelectionChanged(); | 1358 | mExtensionManager->setSelectionChanged(); |
1359 | 1359 | ||
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | #endif// DESKTOP_VERSION | 1362 | #endif// DESKTOP_VERSION |
1363 | 1363 | ||
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | 1366 | ||
1367 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1367 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1368 | { | 1368 | { |
1369 | 1369 | ||
1370 | if ( list.count() != 0 ) { | 1370 | if ( list.count() != 0 ) { |
1371 | KABC::Addressee::List::ConstIterator it; | 1371 | KABC::Addressee::List::ConstIterator it; |
1372 | for ( it = list.begin(); it != list.end(); ++it ) | 1372 | for ( it = list.begin(); it != list.end(); ++it ) |
1373 | mAddressBook->insertAddressee( *it ); | 1373 | mAddressBook->insertAddressee( *it ); |
1374 | if ( list.count() > 1 ) | 1374 | if ( list.count() > 1 ) |
1375 | setModified(); | 1375 | setModified(); |
1376 | else | 1376 | else |
1377 | setModifiedWOrefresh(); | 1377 | setModifiedWOrefresh(); |
1378 | } | 1378 | } |
1379 | if ( list.count() == 0 ) | 1379 | if ( list.count() == 0 ) |
1380 | mViewManager->refreshView(); | 1380 | mViewManager->refreshView(); |
1381 | else | 1381 | else |
1382 | mViewManager->refreshView( list[ 0 ].uid() ); | 1382 | mViewManager->refreshView( list[ 0 ].uid() ); |
1383 | 1383 | ||
1384 | 1384 | ||
1385 | 1385 | ||
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | QString KABCore::getNameByPhone( const QString &phone ) | 1388 | QString KABCore::getNameByPhone( const QString &phone ) |
1389 | { | 1389 | { |
1390 | #ifndef KAB_EMBEDDED | 1390 | #ifndef KAB_EMBEDDED |
1391 | QRegExp r( "[/*/-/ ]" ); | 1391 | QRegExp r( "[/*/-/ ]" ); |
1392 | QString localPhone( phone ); | 1392 | QString localPhone( phone ); |
1393 | 1393 | ||
1394 | bool found = false; | 1394 | bool found = false; |
1395 | QString ownerName = ""; | 1395 | QString ownerName = ""; |
1396 | KABC::AddressBook::Iterator iter; | 1396 | KABC::AddressBook::Iterator iter; |
1397 | KABC::PhoneNumber::List::Iterator phoneIter; | 1397 | KABC::PhoneNumber::List::Iterator phoneIter; |
1398 | KABC::PhoneNumber::List phoneList; | 1398 | KABC::PhoneNumber::List phoneList; |
1399 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1399 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1400 | phoneList = (*iter).phoneNumbers(); | 1400 | phoneList = (*iter).phoneNumbers(); |
1401 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1401 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1402 | ++phoneIter) { | 1402 | ++phoneIter) { |
1403 | // Get rid of separator chars so just the numbers are compared. | 1403 | // Get rid of separator chars so just the numbers are compared. |
1404 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1404 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1405 | ownerName = (*iter).formattedName(); | 1405 | ownerName = (*iter).formattedName(); |
1406 | found = true; | 1406 | found = true; |
1407 | } | 1407 | } |
1408 | } | 1408 | } |
1409 | } | 1409 | } |
1410 | 1410 | ||
1411 | return ownerName; | 1411 | return ownerName; |
1412 | #else //KAB_EMBEDDED | 1412 | #else //KAB_EMBEDDED |
1413 | qDebug("KABCore::getNameByPhone finsih method"); | 1413 | qDebug("KABCore::getNameByPhone finsih method"); |
1414 | return ""; | 1414 | return ""; |
1415 | #endif //KAB_EMBEDDED | 1415 | #endif //KAB_EMBEDDED |
1416 | 1416 | ||
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | void KABCore::openConfigDialog() | 1419 | void KABCore::openConfigDialog() |
1420 | { | 1420 | { |
1421 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1421 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1422 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1422 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1423 | ConfigureDialog->addModule(kabcfg ); | 1423 | ConfigureDialog->addModule(kabcfg ); |
1424 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1424 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1425 | ConfigureDialog->addModule(kdelibcfg ); | 1425 | ConfigureDialog->addModule(kdelibcfg ); |
1426 | 1426 | ||
1427 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1427 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1428 | this, SLOT( configurationChanged() ) ); | 1428 | this, SLOT( configurationChanged() ) ); |
1429 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1429 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1430 | this, SLOT( configurationChanged() ) ); | 1430 | this, SLOT( configurationChanged() ) ); |
1431 | saveSettings(); | 1431 | saveSettings(); |
1432 | #ifndef DESKTOP_VERSION | 1432 | #ifndef DESKTOP_VERSION |
1433 | ConfigureDialog->showMaximized(); | 1433 | ConfigureDialog->showMaximized(); |
1434 | #endif | 1434 | #endif |
1435 | if ( ConfigureDialog->exec() ) | 1435 | if ( ConfigureDialog->exec() ) |
1436 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1436 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1437 | delete ConfigureDialog; | 1437 | delete ConfigureDialog; |
1438 | } | 1438 | } |
1439 | 1439 | ||
1440 | void KABCore::openLDAPDialog() | 1440 | void KABCore::openLDAPDialog() |
1441 | { | 1441 | { |
1442 | #ifndef KAB_EMBEDDED | 1442 | #ifndef KAB_EMBEDDED |
1443 | if ( !mLdapSearchDialog ) { | 1443 | if ( !mLdapSearchDialog ) { |
1444 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1444 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1445 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1445 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1446 | SLOT( refreshView() ) ); | 1446 | SLOT( refreshView() ) ); |
1447 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1447 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1448 | SLOT( setModified() ) ); | 1448 | SLOT( setModified() ) ); |
1449 | } else | 1449 | } else |
1450 | mLdapSearchDialog->restoreSettings(); | 1450 | mLdapSearchDialog->restoreSettings(); |
1451 | 1451 | ||
1452 | if ( mLdapSearchDialog->isOK() ) | 1452 | if ( mLdapSearchDialog->isOK() ) |
1453 | mLdapSearchDialog->exec(); | 1453 | mLdapSearchDialog->exec(); |
1454 | #else //KAB_EMBEDDED | 1454 | #else //KAB_EMBEDDED |
1455 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1455 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1456 | #endif //KAB_EMBEDDED | 1456 | #endif //KAB_EMBEDDED |
1457 | } | 1457 | } |
1458 | 1458 | ||
1459 | void KABCore::print() | 1459 | void KABCore::print() |
1460 | { | 1460 | { |
1461 | #ifndef KAB_EMBEDDED | 1461 | #ifndef KAB_EMBEDDED |
1462 | KPrinter printer; | 1462 | KPrinter printer; |
1463 | if ( !printer.setup( this ) ) | 1463 | if ( !printer.setup( this ) ) |
1464 | return; | 1464 | return; |
1465 | 1465 | ||
1466 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1466 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1467 | mViewManager->selectedUids(), this ); | 1467 | mViewManager->selectedUids(), this ); |
1468 | 1468 | ||
1469 | wizard.exec(); | 1469 | wizard.exec(); |
1470 | #else //KAB_EMBEDDED | 1470 | #else //KAB_EMBEDDED |
1471 | qDebug("KABCore::print() finsih method"); | 1471 | qDebug("KABCore::print() finsih method"); |
1472 | #endif //KAB_EMBEDDED | 1472 | #endif //KAB_EMBEDDED |
1473 | 1473 | ||
1474 | } | 1474 | } |
1475 | 1475 | ||
1476 | 1476 | ||
1477 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1477 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1478 | { | 1478 | { |
1479 | if ( mGUIClient ) | 1479 | if ( mGUIClient ) |
1480 | mGUIClient->insertChildClient( client ); | 1480 | mGUIClient->insertChildClient( client ); |
1481 | else | 1481 | else |
1482 | KMessageBox::error( this, "no KXMLGUICLient"); | 1482 | KMessageBox::error( this, "no KXMLGUICLient"); |
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | 1485 | ||
1486 | void KABCore::configurationChanged() | 1486 | void KABCore::configurationChanged() |
1487 | { | 1487 | { |
1488 | mExtensionManager->reconfigure(); | 1488 | mExtensionManager->reconfigure(); |
1489 | } | 1489 | } |
1490 | 1490 | ||
1491 | void KABCore::addressBookChanged() | 1491 | void KABCore::addressBookChanged() |
1492 | { | 1492 | { |
1493 | /*US | 1493 | /*US |
1494 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1494 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1495 | while ( it.current() ) { | 1495 | while ( it.current() ) { |
1496 | if ( it.current()->dirty() ) { | 1496 | if ( it.current()->dirty() ) { |
1497 | QString text = i18n( "Data has been changed externally. Unsaved " | 1497 | QString text = i18n( "Data has been changed externally. Unsaved " |
1498 | "changes will be lost." ); | 1498 | "changes will be lost." ); |
1499 | KMessageBox::information( this, text ); | 1499 | KMessageBox::information( this, text ); |
1500 | } | 1500 | } |
1501 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1501 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1502 | ++it; | 1502 | ++it; |
1503 | } | 1503 | } |
1504 | */ | 1504 | */ |
1505 | if (mEditorDialog) | 1505 | if (mEditorDialog) |
1506 | { | 1506 | { |
1507 | if (mEditorDialog->dirty()) | 1507 | if (mEditorDialog->dirty()) |
1508 | { | 1508 | { |
1509 | QString text = i18n( "Data has been changed externally. Unsaved " | 1509 | QString text = i18n( "Data has been changed externally. Unsaved " |
1510 | "changes will be lost." ); | 1510 | "changes will be lost." ); |
1511 | KMessageBox::information( this, text ); | 1511 | KMessageBox::information( this, text ); |
1512 | } | 1512 | } |
1513 | QString currentuid = mEditorDialog->addressee().uid(); | 1513 | QString currentuid = mEditorDialog->addressee().uid(); |
1514 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1514 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1515 | } | 1515 | } |
1516 | mViewManager->refreshView(); | 1516 | mViewManager->refreshView(); |
1517 | // mDetails->refreshView(); | 1517 | // mDetails->refreshView(); |
1518 | 1518 | ||
1519 | 1519 | ||
1520 | } | 1520 | } |
1521 | 1521 | ||
1522 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1522 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1523 | const char *name ) | 1523 | const char *name ) |
1524 | { | 1524 | { |
1525 | 1525 | ||
1526 | if ( mEditorDialog == 0 ) { | 1526 | if ( mEditorDialog == 0 ) { |
1527 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1527 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1528 | name ? name : "editorDialog" ); | 1528 | name ? name : "editorDialog" ); |
1529 | 1529 | ||
1530 | 1530 | ||
1531 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1531 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1532 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1532 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1533 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1533 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1534 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1534 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1535 | } | 1535 | } |
1536 | 1536 | ||
1537 | return mEditorDialog; | 1537 | return mEditorDialog; |
1538 | } | 1538 | } |
1539 | 1539 | ||
1540 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1540 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1541 | { | 1541 | { |
1542 | //mEditorDict.remove( uid ); | 1542 | //mEditorDict.remove( uid ); |
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | void KABCore::initGUI() | 1545 | void KABCore::initGUI() |
1546 | { | 1546 | { |
1547 | #ifndef KAB_EMBEDDED | 1547 | #ifndef KAB_EMBEDDED |
1548 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1548 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1549 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1549 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1550 | 1550 | ||
1551 | mExtensionBarSplitter = new QSplitter( this ); | 1551 | mExtensionBarSplitter = new QSplitter( this ); |
1552 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1552 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1553 | 1553 | ||
1554 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1554 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1555 | 1555 | ||
1556 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1556 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1557 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1557 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1559 | SLOT( incrementalSearch( const QString& ) ) ); | 1559 | SLOT( incrementalSearch( const QString& ) ) ); |
1560 | 1560 | ||
1561 | mViewManager = new ViewManager( this, viewSpace ); | 1561 | mViewManager = new ViewManager( this, viewSpace ); |
1562 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1562 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1563 | 1563 | ||
1564 | mDetails = new ViewContainer( mDetailsSplitter ); | 1564 | mDetails = new ViewContainer( mDetailsSplitter ); |
1565 | 1565 | ||
1566 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1566 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1567 | 1567 | ||
1568 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1568 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1569 | 1569 | ||
1570 | topLayout->addWidget( mExtensionBarSplitter ); | 1570 | topLayout->addWidget( mExtensionBarSplitter ); |
1571 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1571 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1572 | topLayout->addWidget( mJumpButtonBar ); | 1572 | topLayout->addWidget( mJumpButtonBar ); |
1573 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1573 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1574 | 1574 | ||
1575 | mXXPortManager = new XXPortManager( this, this ); | 1575 | mXXPortManager = new XXPortManager( this, this ); |
1576 | 1576 | ||
1577 | #else //KAB_EMBEDDED | 1577 | #else //KAB_EMBEDDED |
1578 | //US initialize viewMenu before settingup viewmanager. | 1578 | //US initialize viewMenu before settingup viewmanager. |
1579 | // Viewmanager needs this menu to plugin submenues. | 1579 | // Viewmanager needs this menu to plugin submenues. |
1580 | viewMenu = new QPopupMenu( this ); | 1580 | viewMenu = new QPopupMenu( this ); |
1581 | settingsMenu = new QPopupMenu( this ); | 1581 | settingsMenu = new QPopupMenu( this ); |
1582 | //filterMenu = new QPopupMenu( this ); | 1582 | //filterMenu = new QPopupMenu( this ); |
1583 | ImportMenu = new QPopupMenu( this ); | 1583 | ImportMenu = new QPopupMenu( this ); |
1584 | ExportMenu = new QPopupMenu( this ); | 1584 | ExportMenu = new QPopupMenu( this ); |
1585 | syncMenu = new QPopupMenu( this ); | 1585 | syncMenu = new QPopupMenu( this ); |
1586 | changeMenu= new QPopupMenu( this ); | 1586 | changeMenu= new QPopupMenu( this ); |
1587 | 1587 | ||
1588 | //US since we have no splitter for the embedded system, setup | 1588 | //US since we have no splitter for the embedded system, setup |
1589 | // a layout with two frames. One left and one right. | 1589 | // a layout with two frames. One left and one right. |
1590 | 1590 | ||
1591 | QBoxLayout *topLayout; | 1591 | QBoxLayout *topLayout; |
1592 | 1592 | ||
1593 | // = new QHBoxLayout( this ); | 1593 | // = new QHBoxLayout( this ); |
1594 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1594 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1595 | 1595 | ||
1596 | // QWidget *mainBox = new QWidget( this ); | 1596 | // QWidget *mainBox = new QWidget( this ); |
1597 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1597 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1598 | 1598 | ||
1599 | #ifdef DESKTOP_VERSION | 1599 | #ifdef DESKTOP_VERSION |
1600 | topLayout = new QHBoxLayout( this ); | 1600 | topLayout = new QHBoxLayout( this ); |
1601 | 1601 | ||
1602 | 1602 | ||
1603 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1603 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1604 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1604 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1605 | 1605 | ||
1606 | topLayout->addWidget(mMiniSplitter ); | 1606 | topLayout->addWidget(mMiniSplitter ); |
1607 | 1607 | ||
1608 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1608 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1609 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1609 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1610 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1610 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1611 | mDetails = new ViewContainer( mMiniSplitter ); | 1611 | mDetails = new ViewContainer( mMiniSplitter ); |
1612 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1612 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1613 | #else | 1613 | #else |
1614 | if ( QApplication::desktop()->width() > 480 ) { | 1614 | if ( QApplication::desktop()->width() > 480 ) { |
1615 | topLayout = new QHBoxLayout( this ); | 1615 | topLayout = new QHBoxLayout( this ); |
1616 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1616 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1617 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1617 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1618 | } else { | 1618 | } else { |
1619 | 1619 | ||
1620 | topLayout = new QHBoxLayout( this ); | 1620 | topLayout = new QHBoxLayout( this ); |
1621 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1621 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1622 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1622 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1623 | } | 1623 | } |
1624 | 1624 | ||
1625 | topLayout->addWidget(mMiniSplitter ); | 1625 | topLayout->addWidget(mMiniSplitter ); |
1626 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1626 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1627 | mDetails = new ViewContainer( mMiniSplitter ); | 1627 | mDetails = new ViewContainer( mMiniSplitter ); |
1628 | 1628 | ||
1629 | 1629 | ||
1630 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1630 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1631 | #endif | 1631 | #endif |
1632 | //eh->hide(); | 1632 | //eh->hide(); |
1633 | // topLayout->addWidget(mExtensionManager ); | 1633 | // topLayout->addWidget(mExtensionManager ); |
1634 | 1634 | ||
1635 | 1635 | ||
1636 | /*US | 1636 | /*US |
1637 | #ifndef KAB_NOSPLITTER | 1637 | #ifndef KAB_NOSPLITTER |
1638 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1638 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1639 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1639 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1640 | topLayout->setSpacing( 10 ); | 1640 | topLayout->setSpacing( 10 ); |
1641 | 1641 | ||
1642 | mDetailsSplitter = new QSplitter( this ); | 1642 | mDetailsSplitter = new QSplitter( this ); |
1643 | 1643 | ||
1644 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1644 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1645 | 1645 | ||
1646 | mViewManager = new ViewManager( this, viewSpace ); | 1646 | mViewManager = new ViewManager( this, viewSpace ); |
1647 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1647 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1648 | 1648 | ||
1649 | mDetails = new ViewContainer( mDetailsSplitter ); | 1649 | mDetails = new ViewContainer( mDetailsSplitter ); |
1650 | 1650 | ||
1651 | topLayout->addWidget( mDetailsSplitter ); | 1651 | topLayout->addWidget( mDetailsSplitter ); |
1652 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1652 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1653 | #else //KAB_NOSPLITTER | 1653 | #else //KAB_NOSPLITTER |
1654 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1654 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1655 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1655 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1656 | topLayout->setSpacing( 10 ); | 1656 | topLayout->setSpacing( 10 ); |
1657 | 1657 | ||
1658 | // mDetailsSplitter = new QSplitter( this ); | 1658 | // mDetailsSplitter = new QSplitter( this ); |
1659 | 1659 | ||
1660 | QVBox *viewSpace = new QVBox( this ); | 1660 | QVBox *viewSpace = new QVBox( this ); |
1661 | 1661 | ||
1662 | mViewManager = new ViewManager( this, viewSpace ); | 1662 | mViewManager = new ViewManager( this, viewSpace ); |
1663 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1663 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1664 | 1664 | ||
1665 | mDetails = new ViewContainer( this ); | 1665 | mDetails = new ViewContainer( this ); |
1666 | 1666 | ||
1667 | topLayout->addWidget( viewSpace ); | 1667 | topLayout->addWidget( viewSpace ); |
1668 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1668 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1669 | topLayout->addWidget( mDetails ); | 1669 | topLayout->addWidget( mDetails ); |
1670 | #endif //KAB_NOSPLITTER | 1670 | #endif //KAB_NOSPLITTER |
1671 | */ | 1671 | */ |
1672 | 1672 | ||
1673 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1673 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1674 | syncManager->setBlockSave(false); | 1674 | syncManager->setBlockSave(false); |
1675 | 1675 | ||
1676 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1676 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1677 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1677 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1678 | syncManager->setDefaultFileName( sentSyncFile()); | 1678 | syncManager->setDefaultFileName( sentSyncFile()); |
1679 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1679 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1680 | 1680 | ||
1681 | #endif //KAB_EMBEDDED | 1681 | #endif //KAB_EMBEDDED |
1682 | initActions(); | 1682 | initActions(); |
1683 | 1683 | ||
1684 | #ifdef KAB_EMBEDDED | 1684 | #ifdef KAB_EMBEDDED |
1685 | addActionsManually(); | 1685 | addActionsManually(); |
1686 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1686 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1687 | mXXPortManager = new XXPortManager( this, this ); | 1687 | mXXPortManager = new XXPortManager( this, this ); |
1688 | 1688 | ||
1689 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1689 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1690 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1690 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1691 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1691 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1692 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1692 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1693 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1693 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1694 | // mIncSearchWidget->hide(); | 1694 | // mIncSearchWidget->hide(); |
1695 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1695 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1696 | SLOT( incrementalSearch( const QString& ) ) ); | 1696 | SLOT( incrementalSearch( const QString& ) ) ); |
1697 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1697 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1698 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1698 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1699 | 1699 | ||
1700 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1700 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1701 | 1701 | ||
1702 | topLayout->addWidget( mJumpButtonBar ); | 1702 | topLayout->addWidget( mJumpButtonBar ); |
1703 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1703 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1704 | 1704 | ||
1705 | // mMainWindow->getIconToolBar()->raise(); | 1705 | // mMainWindow->getIconToolBar()->raise(); |
1706 | 1706 | ||
1707 | #endif //KAB_EMBEDDED | 1707 | #endif //KAB_EMBEDDED |
1708 | 1708 | ||
1709 | } | 1709 | } |
1710 | void KABCore::initActions() | 1710 | void KABCore::initActions() |
1711 | { | 1711 | { |
1712 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1712 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1713 | 1713 | ||
1714 | #ifndef KAB_EMBEDDED | 1714 | #ifndef KAB_EMBEDDED |
1715 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1715 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1716 | SLOT( clipboardDataChanged() ) ); | 1716 | SLOT( clipboardDataChanged() ) ); |
1717 | #endif //KAB_EMBEDDED | 1717 | #endif //KAB_EMBEDDED |
1718 | 1718 | ||
1719 | // file menu | 1719 | // file menu |
1720 | if ( mIsPart ) { | 1720 | if ( mIsPart ) { |
1721 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1721 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1722 | SLOT( sendMail() ), actionCollection(), | 1722 | SLOT( sendMail() ), actionCollection(), |
1723 | "kaddressbook_mail" ); | 1723 | "kaddressbook_mail" ); |
1724 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1724 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1725 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1725 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1726 | 1726 | ||
1727 | } else { | 1727 | } else { |
1728 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1728 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1729 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1729 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1730 | } | 1730 | } |
1731 | 1731 | ||
1732 | 1732 | ||
1733 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1733 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1734 | SLOT( save() ), actionCollection(), "file_sync" ); | 1734 | SLOT( save() ), actionCollection(), "file_sync" ); |
1735 | 1735 | ||
1736 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1736 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1737 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1737 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1738 | 1738 | ||
1739 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1739 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1740 | this, SLOT( mailVCard() ), | 1740 | this, SLOT( mailVCard() ), |
1741 | actionCollection(), "file_mail_vcard"); | 1741 | actionCollection(), "file_mail_vcard"); |
1742 | 1742 | ||
1743 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1743 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1744 | SLOT( export2phone() ), actionCollection(), | 1744 | SLOT( export2phone() ), actionCollection(), |
1745 | "kaddressbook_ex2phone" ); | 1745 | "kaddressbook_ex2phone" ); |
1746 | 1746 | ||
1747 | mActionBeamVCard = 0; | 1747 | mActionBeamVCard = 0; |
1748 | mActionBeam = 0; | 1748 | mActionBeam = 0; |
1749 | 1749 | ||
1750 | #ifndef DESKTOP_VERSION | 1750 | #ifndef DESKTOP_VERSION |
1751 | if ( Ir::supported() ) { | 1751 | if ( Ir::supported() ) { |
1752 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1752 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1753 | SLOT( beamVCard() ), actionCollection(), | 1753 | SLOT( beamVCard() ), actionCollection(), |
1754 | "kaddressbook_beam_vcard" ); | 1754 | "kaddressbook_beam_vcard" ); |
1755 | 1755 | ||
1756 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1756 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1757 | SLOT( beamMySelf() ), actionCollection(), | 1757 | SLOT( beamMySelf() ), actionCollection(), |
1758 | "kaddressbook_beam_myself" ); | 1758 | "kaddressbook_beam_myself" ); |
1759 | } | 1759 | } |
1760 | #endif | 1760 | #endif |
1761 | 1761 | ||
1762 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1762 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1763 | this, SLOT( editContact2() ), | 1763 | this, SLOT( editContact2() ), |
1764 | actionCollection(), "file_properties" ); | 1764 | actionCollection(), "file_properties" ); |
1765 | 1765 | ||
1766 | #ifdef KAB_EMBEDDED | 1766 | #ifdef KAB_EMBEDDED |
1767 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1767 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1768 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1768 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1769 | mMainWindow, SLOT( exit() ), | 1769 | mMainWindow, SLOT( exit() ), |
1770 | actionCollection(), "quit" ); | 1770 | actionCollection(), "quit" ); |
1771 | #endif //KAB_EMBEDDED | 1771 | #endif //KAB_EMBEDDED |
1772 | 1772 | ||
1773 | // edit menu | 1773 | // edit menu |
1774 | if ( mIsPart ) { | 1774 | if ( mIsPart ) { |
1775 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1775 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1776 | SLOT( copyContacts() ), actionCollection(), | 1776 | SLOT( copyContacts() ), actionCollection(), |
1777 | "kaddressbook_copy" ); | 1777 | "kaddressbook_copy" ); |
1778 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1778 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1779 | SLOT( cutContacts() ), actionCollection(), | 1779 | SLOT( cutContacts() ), actionCollection(), |
1780 | "kaddressbook_cut" ); | 1780 | "kaddressbook_cut" ); |
1781 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1781 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1782 | SLOT( pasteContacts() ), actionCollection(), | 1782 | SLOT( pasteContacts() ), actionCollection(), |
1783 | "kaddressbook_paste" ); | 1783 | "kaddressbook_paste" ); |
1784 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1784 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1785 | SLOT( selectAllContacts() ), actionCollection(), | 1785 | SLOT( selectAllContacts() ), actionCollection(), |
1786 | "kaddressbook_select_all" ); | 1786 | "kaddressbook_select_all" ); |
1787 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1787 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1788 | SLOT( undo() ), actionCollection(), | 1788 | SLOT( undo() ), actionCollection(), |
1789 | "kaddressbook_undo" ); | 1789 | "kaddressbook_undo" ); |
1790 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1790 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1791 | this, SLOT( redo() ), actionCollection(), | 1791 | this, SLOT( redo() ), actionCollection(), |
1792 | "kaddressbook_redo" ); | 1792 | "kaddressbook_redo" ); |
1793 | } else { | 1793 | } else { |
1794 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1794 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1795 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1795 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1796 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1796 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1797 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1797 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1798 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1798 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1799 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1799 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1800 | } | 1800 | } |
1801 | 1801 | ||
1802 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1802 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1803 | Key_Delete, this, SLOT( deleteContacts() ), | 1803 | Key_Delete, this, SLOT( deleteContacts() ), |
1804 | actionCollection(), "edit_delete" ); | 1804 | actionCollection(), "edit_delete" ); |
1805 | 1805 | ||
1806 | mActionUndo->setEnabled( false ); | 1806 | mActionUndo->setEnabled( false ); |
1807 | mActionRedo->setEnabled( false ); | 1807 | mActionRedo->setEnabled( false ); |
1808 | 1808 | ||
1809 | // settings menu | 1809 | // settings menu |
1810 | #ifdef KAB_EMBEDDED | 1810 | #ifdef KAB_EMBEDDED |
1811 | //US special menuentry to configure the addressbook resources. On KDE | 1811 | //US special menuentry to configure the addressbook resources. On KDE |
1812 | // you do that through the control center !!! | 1812 | // you do that through the control center !!! |
1813 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1813 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1814 | SLOT( configureResources() ), actionCollection(), | 1814 | SLOT( configureResources() ), actionCollection(), |
1815 | "kaddressbook_configure_resources" ); | 1815 | "kaddressbook_configure_resources" ); |
1816 | #endif //KAB_EMBEDDED | 1816 | #endif //KAB_EMBEDDED |
1817 | 1817 | ||
1818 | if ( mIsPart ) { | 1818 | if ( mIsPart ) { |
1819 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1819 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1820 | SLOT( openConfigDialog() ), actionCollection(), | 1820 | SLOT( openConfigDialog() ), actionCollection(), |
1821 | "kaddressbook_configure" ); | 1821 | "kaddressbook_configure" ); |
1822 | 1822 | ||
1823 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1823 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1824 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1824 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1825 | "kaddressbook_configure_shortcuts" ); | 1825 | "kaddressbook_configure_shortcuts" ); |
1826 | #ifdef KAB_EMBEDDED | 1826 | #ifdef KAB_EMBEDDED |
1827 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1827 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1828 | mActionConfigureToolbars->setEnabled( false ); | 1828 | mActionConfigureToolbars->setEnabled( false ); |
1829 | #endif //KAB_EMBEDDED | 1829 | #endif //KAB_EMBEDDED |
1830 | 1830 | ||
1831 | } else { | 1831 | } else { |
1832 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1832 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1833 | 1833 | ||
1834 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1834 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1835 | } | 1835 | } |
1836 | 1836 | ||
1837 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1837 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1838 | actionCollection(), "options_show_jump_bar" ); | 1838 | actionCollection(), "options_show_jump_bar" ); |
1839 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1839 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1840 | 1840 | ||
1841 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1841 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1842 | actionCollection(), "options_show_details" ); | 1842 | actionCollection(), "options_show_details" ); |
1843 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1843 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1844 | 1844 | ||
1845 | 1845 | ||
1846 | mActionBR = new KToggleAction( i18n( "Beam receice enabled" ), "beam", 0, this, | 1846 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
1847 | SLOT( toggleBeamReceive() ), actionCollection(), | 1847 | SLOT( toggleBeamReceive() ), actionCollection(), |
1848 | "kaddressbook_beam_rec" ); | 1848 | "kaddressbook_beam_rec" ); |
1849 | 1849 | ||
1850 | 1850 | ||
1851 | // misc | 1851 | // misc |
1852 | // only enable LDAP lookup if we can handle the protocol | 1852 | // only enable LDAP lookup if we can handle the protocol |
1853 | #ifndef KAB_EMBEDDED | 1853 | #ifndef KAB_EMBEDDED |
1854 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1854 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1855 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1855 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1856 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1856 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1857 | "ldap_lookup" ); | 1857 | "ldap_lookup" ); |
1858 | } | 1858 | } |
1859 | #else //KAB_EMBEDDED | 1859 | #else //KAB_EMBEDDED |
1860 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1860 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1861 | #endif //KAB_EMBEDDED | 1861 | #endif //KAB_EMBEDDED |
1862 | 1862 | ||
1863 | 1863 | ||
1864 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1864 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1865 | SLOT( setWhoAmI() ), actionCollection(), | 1865 | SLOT( setWhoAmI() ), actionCollection(), |
1866 | "set_personal" ); | 1866 | "set_personal" ); |
1867 | 1867 | ||
1868 | 1868 | ||
1869 | 1869 | ||
1870 | 1870 | ||
1871 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1871 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1872 | SLOT( setCategories() ), actionCollection(), | 1872 | SLOT( setCategories() ), actionCollection(), |
1873 | "edit_set_categories" ); | 1873 | "edit_set_categories" ); |
1874 | 1874 | ||
1875 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1875 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1876 | SLOT( removeVoice() ), actionCollection(), | 1876 | SLOT( removeVoice() ), actionCollection(), |
1877 | "remove_voice" ); | 1877 | "remove_voice" ); |
1878 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1878 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1879 | SLOT( importFromOL() ), actionCollection(), | 1879 | SLOT( importFromOL() ), actionCollection(), |
1880 | "import_OL" ); | 1880 | "import_OL" ); |
1881 | #ifdef KAB_EMBEDDED | 1881 | #ifdef KAB_EMBEDDED |
1882 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1882 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1883 | this, SLOT( showLicence() ), actionCollection(), | 1883 | this, SLOT( showLicence() ), actionCollection(), |
1884 | "licence_about_data" ); | 1884 | "licence_about_data" ); |
1885 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1885 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1886 | this, SLOT( faq() ), actionCollection(), | 1886 | this, SLOT( faq() ), actionCollection(), |
1887 | "faq_about_data" ); | 1887 | "faq_about_data" ); |
1888 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 1888 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
1889 | this, SLOT( whatsnew() ), actionCollection(), | 1889 | this, SLOT( whatsnew() ), actionCollection(), |
1890 | "wn" ); | 1890 | "wn" ); |
1891 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 1891 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
1892 | this, SLOT( synchowto() ), actionCollection(), | 1892 | this, SLOT( synchowto() ), actionCollection(), |
1893 | "sync" ); | 1893 | "sync" ); |
1894 | 1894 | ||
1895 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1895 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1896 | this, SLOT( createAboutData() ), actionCollection(), | 1896 | this, SLOT( createAboutData() ), actionCollection(), |
1897 | "kaddressbook_about_data" ); | 1897 | "kaddressbook_about_data" ); |
1898 | #endif //KAB_EMBEDDED | 1898 | #endif //KAB_EMBEDDED |
1899 | 1899 | ||
1900 | clipboardDataChanged(); | 1900 | clipboardDataChanged(); |
1901 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1901 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1902 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1902 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1903 | } | 1903 | } |
1904 | 1904 | ||
1905 | //US we need this function, to plug all actions into the correct menues. | 1905 | //US we need this function, to plug all actions into the correct menues. |
1906 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1906 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1907 | void KABCore::addActionsManually() | 1907 | void KABCore::addActionsManually() |
1908 | { | 1908 | { |
1909 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1909 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1910 | 1910 | ||
1911 | #ifdef KAB_EMBEDDED | 1911 | #ifdef KAB_EMBEDDED |
1912 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1912 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1913 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1913 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1914 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1914 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1915 | 1915 | ||
1916 | KToolBar* tb = mMainWindow->toolBar(); | 1916 | KToolBar* tb = mMainWindow->toolBar(); |
1917 | 1917 | ||
1918 | #ifdef DESKTOP_VERSION | 1918 | #ifdef DESKTOP_VERSION |
1919 | QMenuBar* mb = mMainWindow->menuBar(); | 1919 | QMenuBar* mb = mMainWindow->menuBar(); |
1920 | 1920 | ||
1921 | //US setup menubar. | 1921 | //US setup menubar. |
1922 | //Disable the following block if you do not want to have a menubar. | 1922 | //Disable the following block if you do not want to have a menubar. |
1923 | mb->insertItem( "&File", fileMenu ); | 1923 | mb->insertItem( "&File", fileMenu ); |
1924 | mb->insertItem( "&Edit", editMenu ); | 1924 | mb->insertItem( "&Edit", editMenu ); |
1925 | mb->insertItem( "&View", viewMenu ); | 1925 | mb->insertItem( "&View", viewMenu ); |
1926 | mb->insertItem( "&Settings", settingsMenu ); | 1926 | mb->insertItem( "&Settings", settingsMenu ); |
1927 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1927 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1928 | mb->insertItem( "&Change selected", changeMenu ); | 1928 | mb->insertItem( "&Change selected", changeMenu ); |
1929 | mb->insertItem( "&Help", helpMenu ); | 1929 | mb->insertItem( "&Help", helpMenu ); |
1930 | mIncSearchWidget = new IncSearchWidget( tb ); | 1930 | mIncSearchWidget = new IncSearchWidget( tb ); |
1931 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1931 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1932 | 1932 | ||
1933 | #else | 1933 | #else |
1934 | //US setup toolbar | 1934 | //US setup toolbar |
1935 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1935 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1936 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1936 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1937 | menuBarTB->insertItem( "ME", popupBarTB); | 1937 | menuBarTB->insertItem( "ME", popupBarTB); |
1938 | tb->insertWidget(-1, 0, menuBarTB); | 1938 | tb->insertWidget(-1, 0, menuBarTB); |
1939 | mIncSearchWidget = new IncSearchWidget( tb ); | 1939 | mIncSearchWidget = new IncSearchWidget( tb ); |
1940 | 1940 | ||
1941 | tb->enableMoving(false); | 1941 | tb->enableMoving(false); |
1942 | popupBarTB->insertItem( "&File", fileMenu ); | 1942 | popupBarTB->insertItem( "&File", fileMenu ); |
1943 | popupBarTB->insertItem( "&Edit", editMenu ); | 1943 | popupBarTB->insertItem( "&Edit", editMenu ); |
1944 | popupBarTB->insertItem( "&View", viewMenu ); | 1944 | popupBarTB->insertItem( "&View", viewMenu ); |
1945 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1945 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1946 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1946 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1947 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1947 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1948 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1948 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1949 | popupBarTB->insertItem( "&Help", helpMenu ); | 1949 | popupBarTB->insertItem( "&Help", helpMenu ); |
1950 | if (QApplication::desktop()->width() > 320 ) { | 1950 | if (QApplication::desktop()->width() > 320 ) { |
1951 | // mViewManager->getFilterAction()->plug ( tb); | 1951 | // mViewManager->getFilterAction()->plug ( tb); |
1952 | } | 1952 | } |
1953 | #endif | 1953 | #endif |
1954 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1954 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1955 | 1955 | ||
1956 | 1956 | ||
1957 | 1957 | ||
1958 | //US Now connect the actions with the menue entries. | 1958 | //US Now connect the actions with the menue entries. |
1959 | mActionPrint->plug( fileMenu ); | 1959 | mActionPrint->plug( fileMenu ); |
1960 | mActionMail->plug( fileMenu ); | 1960 | mActionMail->plug( fileMenu ); |
1961 | fileMenu->insertSeparator(); | 1961 | fileMenu->insertSeparator(); |
1962 | 1962 | ||
1963 | mActionNewContact->plug( fileMenu ); | 1963 | mActionNewContact->plug( fileMenu ); |
1964 | mActionNewContact->plug( tb ); | 1964 | mActionNewContact->plug( tb ); |
1965 | 1965 | ||
1966 | mActionEditAddressee->plug( fileMenu ); | 1966 | mActionEditAddressee->plug( fileMenu ); |
1967 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1967 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1968 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1968 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1969 | mActionEditAddressee->plug( tb ); | 1969 | mActionEditAddressee->plug( tb ); |
1970 | 1970 | ||
1971 | fileMenu->insertSeparator(); | 1971 | fileMenu->insertSeparator(); |
1972 | mActionSave->plug( fileMenu ); | 1972 | mActionSave->plug( fileMenu ); |
1973 | fileMenu->insertItem( "&Import", ImportMenu ); | 1973 | fileMenu->insertItem( "&Import", ImportMenu ); |
1974 | fileMenu->insertItem( "&Export", ExportMenu ); | 1974 | fileMenu->insertItem( "&Export", ExportMenu ); |
1975 | fileMenu->insertSeparator(); | 1975 | fileMenu->insertSeparator(); |
1976 | mActionMailVCard->plug( fileMenu ); | 1976 | mActionMailVCard->plug( fileMenu ); |
1977 | #ifndef DESKTOP_VERSION | 1977 | #ifndef DESKTOP_VERSION |
1978 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1978 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1979 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1979 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1980 | #endif | 1980 | #endif |
1981 | fileMenu->insertSeparator(); | 1981 | fileMenu->insertSeparator(); |
1982 | mActionQuit->plug( fileMenu ); | 1982 | mActionQuit->plug( fileMenu ); |
1983 | #ifdef _WIN32_ | 1983 | #ifdef _WIN32_ |
1984 | mActionImportOL->plug( ImportMenu ); | 1984 | mActionImportOL->plug( ImportMenu ); |
1985 | #endif | 1985 | #endif |
1986 | // edit menu | 1986 | // edit menu |
1987 | mActionUndo->plug( editMenu ); | 1987 | mActionUndo->plug( editMenu ); |
1988 | mActionRedo->plug( editMenu ); | 1988 | mActionRedo->plug( editMenu ); |
1989 | editMenu->insertSeparator(); | 1989 | editMenu->insertSeparator(); |
1990 | mActionCut->plug( editMenu ); | 1990 | mActionCut->plug( editMenu ); |
1991 | mActionCopy->plug( editMenu ); | 1991 | mActionCopy->plug( editMenu ); |
1992 | mActionPaste->plug( editMenu ); | 1992 | mActionPaste->plug( editMenu ); |
1993 | mActionDelete->plug( editMenu ); | 1993 | mActionDelete->plug( editMenu ); |
1994 | editMenu->insertSeparator(); | 1994 | editMenu->insertSeparator(); |
1995 | mActionSelectAll->plug( editMenu ); | 1995 | mActionSelectAll->plug( editMenu ); |
1996 | 1996 | ||
1997 | mActionRemoveVoice->plug( changeMenu ); | 1997 | mActionRemoveVoice->plug( changeMenu ); |
1998 | // settings menu | 1998 | // settings menu |
1999 | //US special menuentry to configure the addressbook resources. On KDE | 1999 | //US special menuentry to configure the addressbook resources. On KDE |
2000 | // you do that through the control center !!! | 2000 | // you do that through the control center !!! |
2001 | mActionConfigResources->plug( settingsMenu ); | 2001 | mActionConfigResources->plug( settingsMenu ); |
2002 | settingsMenu->insertSeparator(); | 2002 | settingsMenu->insertSeparator(); |
2003 | 2003 | ||
2004 | mActionConfigKAddressbook->plug( settingsMenu ); | 2004 | mActionConfigKAddressbook->plug( settingsMenu ); |
2005 | 2005 | ||
2006 | if ( mIsPart ) { | 2006 | if ( mIsPart ) { |
2007 | mActionConfigShortcuts->plug( settingsMenu ); | 2007 | mActionConfigShortcuts->plug( settingsMenu ); |
2008 | mActionConfigureToolbars->plug( settingsMenu ); | 2008 | mActionConfigureToolbars->plug( settingsMenu ); |
2009 | 2009 | ||
2010 | } else { | 2010 | } else { |
2011 | mActionKeyBindings->plug( settingsMenu ); | 2011 | mActionKeyBindings->plug( settingsMenu ); |
2012 | } | 2012 | } |
2013 | 2013 | ||
2014 | settingsMenu->insertSeparator(); | 2014 | settingsMenu->insertSeparator(); |
2015 | 2015 | ||
2016 | mActionJumpBar->plug( settingsMenu ); | 2016 | mActionJumpBar->plug( settingsMenu ); |
2017 | mActionDetails->plug( settingsMenu ); | 2017 | mActionDetails->plug( settingsMenu ); |
2018 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2018 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2019 | mActionDetails->plug( tb ); | 2019 | mActionDetails->plug( tb ); |
2020 | settingsMenu->insertSeparator(); | 2020 | settingsMenu->insertSeparator(); |
2021 | mActionBR->plug(settingsMenu ); | 2021 | mActionBR->plug(settingsMenu ); |
2022 | settingsMenu->insertSeparator(); | 2022 | settingsMenu->insertSeparator(); |
2023 | 2023 | ||
2024 | mActionWhoAmI->plug( settingsMenu ); | 2024 | mActionWhoAmI->plug( settingsMenu ); |
2025 | mActionCategories->plug( settingsMenu ); | 2025 | mActionCategories->plug( settingsMenu ); |
2026 | 2026 | ||
2027 | 2027 | ||
2028 | mActionWN->plug( helpMenu ); | 2028 | mActionWN->plug( helpMenu ); |
2029 | mActionSyncHowto->plug( helpMenu ); | 2029 | mActionSyncHowto->plug( helpMenu ); |
2030 | mActionLicence->plug( helpMenu ); | 2030 | mActionLicence->plug( helpMenu ); |
2031 | mActionFaq->plug( helpMenu ); | 2031 | mActionFaq->plug( helpMenu ); |
2032 | mActionAboutKAddressbook->plug( helpMenu ); | 2032 | mActionAboutKAddressbook->plug( helpMenu ); |
2033 | 2033 | ||
2034 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2034 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2035 | 2035 | ||
2036 | mActionSave->plug( tb ); | 2036 | mActionSave->plug( tb ); |
2037 | mViewManager->getFilterAction()->plug ( tb); | 2037 | mViewManager->getFilterAction()->plug ( tb); |
2038 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2038 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2039 | mActionUndo->plug( tb ); | 2039 | mActionUndo->plug( tb ); |
2040 | mActionDelete->plug( tb ); | 2040 | mActionDelete->plug( tb ); |
2041 | mActionRedo->plug( tb ); | 2041 | mActionRedo->plug( tb ); |
2042 | } | 2042 | } |
2043 | } | 2043 | } |
2044 | //mActionQuit->plug ( tb ); | 2044 | //mActionQuit->plug ( tb ); |
2045 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2045 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2046 | 2046 | ||
2047 | //US link the searchwidget first to this. | 2047 | //US link the searchwidget first to this. |
2048 | // The real linkage to the toolbar happens later. | 2048 | // The real linkage to the toolbar happens later. |
2049 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2049 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2050 | //US tb->insertItem( mIncSearchWidget ); | 2050 | //US tb->insertItem( mIncSearchWidget ); |
2051 | /*US | 2051 | /*US |
2052 | mIncSearchWidget = new IncSearchWidget( tb ); | 2052 | mIncSearchWidget = new IncSearchWidget( tb ); |
2053 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2053 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2054 | SLOT( incrementalSearch( const QString& ) ) ); | 2054 | SLOT( incrementalSearch( const QString& ) ) ); |
2055 | 2055 | ||
2056 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2056 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2057 | 2057 | ||
2058 | //US topLayout->addWidget( mJumpButtonBar ); | 2058 | //US topLayout->addWidget( mJumpButtonBar ); |
2059 | this->layout()->add( mJumpButtonBar ); | 2059 | this->layout()->add( mJumpButtonBar ); |
2060 | */ | 2060 | */ |
2061 | 2061 | ||
2062 | #endif //KAB_EMBEDDED | 2062 | #endif //KAB_EMBEDDED |
2063 | 2063 | ||
2064 | mActionExport2phone->plug( ExportMenu ); | 2064 | mActionExport2phone->plug( ExportMenu ); |
2065 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2065 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2066 | syncManager->fillSyncMenu(); | 2066 | syncManager->fillSyncMenu(); |
2067 | 2067 | ||
2068 | } | 2068 | } |
2069 | void KABCore::showLicence() | 2069 | void KABCore::showLicence() |
2070 | { | 2070 | { |
2071 | KApplication::showLicence(); | 2071 | KApplication::showLicence(); |
2072 | } | 2072 | } |
2073 | void KABCore::removeVoice() | 2073 | void KABCore::removeVoice() |
2074 | { | 2074 | { |
2075 | 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 ) | 2075 | 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 ) |
2076 | return; | 2076 | return; |
2077 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2077 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2078 | KABC::Addressee::List::Iterator it; | 2078 | KABC::Addressee::List::Iterator it; |
2079 | for ( it = list.begin(); it != list.end(); ++it ) { | 2079 | for ( it = list.begin(); it != list.end(); ++it ) { |
2080 | 2080 | ||
2081 | if ( (*it).removeVoice() ) | 2081 | if ( (*it).removeVoice() ) |
2082 | contactModified((*it) ); | 2082 | contactModified((*it) ); |
2083 | } | 2083 | } |
2084 | } | 2084 | } |
2085 | 2085 | ||
2086 | 2086 | ||
2087 | 2087 | ||
2088 | void KABCore::clipboardDataChanged() | 2088 | void KABCore::clipboardDataChanged() |
2089 | { | 2089 | { |
2090 | 2090 | ||
2091 | if ( mReadWrite ) | 2091 | if ( mReadWrite ) |
2092 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2092 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2093 | 2093 | ||
2094 | } | 2094 | } |
2095 | 2095 | ||
2096 | void KABCore::updateActionMenu() | 2096 | void KABCore::updateActionMenu() |
2097 | { | 2097 | { |
2098 | UndoStack *undo = UndoStack::instance(); | 2098 | UndoStack *undo = UndoStack::instance(); |
2099 | RedoStack *redo = RedoStack::instance(); | 2099 | RedoStack *redo = RedoStack::instance(); |
2100 | 2100 | ||
2101 | if ( undo->isEmpty() ) | 2101 | if ( undo->isEmpty() ) |
2102 | mActionUndo->setText( i18n( "Undo" ) ); | 2102 | mActionUndo->setText( i18n( "Undo" ) ); |
2103 | else | 2103 | else |
2104 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2104 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2105 | 2105 | ||
2106 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2106 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2107 | 2107 | ||
2108 | if ( !redo->top() ) | 2108 | if ( !redo->top() ) |
2109 | mActionRedo->setText( i18n( "Redo" ) ); | 2109 | mActionRedo->setText( i18n( "Redo" ) ); |
2110 | else | 2110 | else |
2111 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2111 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2112 | 2112 | ||
2113 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2113 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2114 | } | 2114 | } |
2115 | 2115 | ||
2116 | void KABCore::configureKeyBindings() | 2116 | void KABCore::configureKeyBindings() |
2117 | { | 2117 | { |
2118 | #ifndef KAB_EMBEDDED | 2118 | #ifndef KAB_EMBEDDED |
2119 | KKeyDialog::configure( actionCollection(), true ); | 2119 | KKeyDialog::configure( actionCollection(), true ); |
2120 | #else //KAB_EMBEDDED | 2120 | #else //KAB_EMBEDDED |
2121 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2121 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2122 | #endif //KAB_EMBEDDED | 2122 | #endif //KAB_EMBEDDED |
2123 | } | 2123 | } |
2124 | 2124 | ||
2125 | #ifdef KAB_EMBEDDED | 2125 | #ifdef KAB_EMBEDDED |
2126 | void KABCore::configureResources() | 2126 | void KABCore::configureResources() |
2127 | { | 2127 | { |
2128 | KRES::KCMKResources dlg( this, "" , 0 ); | 2128 | KRES::KCMKResources dlg( this, "" , 0 ); |
2129 | 2129 | ||
2130 | if ( !dlg.exec() ) | 2130 | if ( !dlg.exec() ) |
2131 | return; | 2131 | return; |
2132 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2132 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2133 | } | 2133 | } |
2134 | #endif //KAB_EMBEDDED | 2134 | #endif //KAB_EMBEDDED |
2135 | 2135 | ||
2136 | 2136 | ||
2137 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2137 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2138 | * for the attendees list of an event. | 2138 | * for the attendees list of an event. |
2139 | */ | 2139 | */ |
2140 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2140 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2141 | { | 2141 | { |
2142 | QStringList nameList; | 2142 | QStringList nameList; |
2143 | QStringList emailList; | 2143 | QStringList emailList; |
2144 | QStringList uidList; | 2144 | QStringList uidList; |
2145 | 2145 | ||
2146 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2146 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2147 | uint i=0; | 2147 | uint i=0; |
2148 | for (i=0; i < list.count(); i++) | 2148 | for (i=0; i < list.count(); i++) |
2149 | { | 2149 | { |
2150 | nameList.append(list[i].realName()); | 2150 | nameList.append(list[i].realName()); |
2151 | emailList.append(list[i].preferredEmail()); | 2151 | emailList.append(list[i].preferredEmail()); |
2152 | uidList.append(list[i].uid()); | 2152 | uidList.append(list[i].uid()); |
2153 | } | 2153 | } |
2154 | 2154 | ||
2155 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2155 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2156 | 2156 | ||
2157 | } | 2157 | } |
2158 | 2158 | ||
2159 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2159 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2160 | * to put them into the calendar. | 2160 | * to put them into the calendar. |
2161 | */ | 2161 | */ |
2162 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2162 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2163 | { | 2163 | { |
2164 | // qDebug("KABCore::requestForBirthdayList"); | 2164 | // qDebug("KABCore::requestForBirthdayList"); |
2165 | QStringList birthdayList; | 2165 | QStringList birthdayList; |
2166 | QStringList anniversaryList; | 2166 | QStringList anniversaryList; |
2167 | QStringList realNameList; | 2167 | QStringList realNameList; |
2168 | QStringList preferredEmailList; | 2168 | QStringList preferredEmailList; |
2169 | QStringList assembledNameList; | 2169 | QStringList assembledNameList; |
2170 | QStringList uidList; | 2170 | QStringList uidList; |
2171 | 2171 | ||
2172 | KABC::AddressBook::Iterator it; | 2172 | KABC::AddressBook::Iterator it; |
2173 | 2173 | ||
2174 | int count = 0; | 2174 | int count = 0; |
2175 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2175 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2176 | ++count; | 2176 | ++count; |
2177 | } | 2177 | } |
2178 | QProgressBar bar(count,0 ); | 2178 | QProgressBar bar(count,0 ); |
2179 | int w = 300; | 2179 | int w = 300; |
2180 | if ( QApplication::desktop()->width() < 320 ) | 2180 | if ( QApplication::desktop()->width() < 320 ) |
2181 | w = 220; | 2181 | w = 220; |
2182 | int h = bar.sizeHint().height() ; | 2182 | int h = bar.sizeHint().height() ; |
2183 | int dw = QApplication::desktop()->width(); | 2183 | int dw = QApplication::desktop()->width(); |
2184 | int dh = QApplication::desktop()->height(); | 2184 | int dh = QApplication::desktop()->height(); |
2185 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2185 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2186 | bar.show(); | 2186 | bar.show(); |
2187 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2187 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2188 | qApp->processEvents(); | 2188 | qApp->processEvents(); |
2189 | 2189 | ||
2190 | QDate bday; | 2190 | QDate bday; |
2191 | QString anni; | 2191 | QString anni; |
2192 | QString formattedbday; | 2192 | QString formattedbday; |
2193 | 2193 | ||
2194 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2194 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2195 | { | 2195 | { |
2196 | if ( ! bar.isVisible() ) | 2196 | if ( ! bar.isVisible() ) |
2197 | return; | 2197 | return; |
2198 | bar.setProgress( count++ ); | 2198 | bar.setProgress( count++ ); |
2199 | qApp->processEvents(); | 2199 | qApp->processEvents(); |
2200 | bday = (*it).birthday().date(); | 2200 | bday = (*it).birthday().date(); |
2201 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2201 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2202 | 2202 | ||
2203 | if ( bday.isValid() || !anni.isEmpty()) | 2203 | if ( bday.isValid() || !anni.isEmpty()) |
2204 | { | 2204 | { |
2205 | if (bday.isValid()) | 2205 | if (bday.isValid()) |
2206 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2206 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2207 | else | 2207 | else |
2208 | formattedbday = "NOTVALID"; | 2208 | formattedbday = "NOTVALID"; |
2209 | if (anni.isEmpty()) | 2209 | if (anni.isEmpty()) |
2210 | anni = "INVALID"; | 2210 | anni = "INVALID"; |
2211 | 2211 | ||
2212 | birthdayList.append(formattedbday); | 2212 | birthdayList.append(formattedbday); |
2213 | anniversaryList.append(anni); //should be ISODate | 2213 | anniversaryList.append(anni); //should be ISODate |
2214 | realNameList.append((*it).realName()); | 2214 | realNameList.append((*it).realName()); |
2215 | preferredEmailList.append((*it).preferredEmail()); | 2215 | preferredEmailList.append((*it).preferredEmail()); |
2216 | assembledNameList.append((*it).assembledName()); | 2216 | assembledNameList.append((*it).assembledName()); |
2217 | uidList.append((*it).uid()); | 2217 | uidList.append((*it).uid()); |
2218 | 2218 | ||
2219 | 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() ); | 2219 | 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() ); |
2220 | } | 2220 | } |
2221 | } | 2221 | } |
2222 | 2222 | ||
2223 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2223 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2224 | 2224 | ||
2225 | } | 2225 | } |
2226 | 2226 | ||
2227 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2227 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2228 | */ | 2228 | */ |
2229 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2229 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2230 | { | 2230 | { |
2231 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2231 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2232 | 2232 | ||
2233 | QString foundUid = QString::null; | 2233 | QString foundUid = QString::null; |
2234 | if ( ! uid.isEmpty() ) { | 2234 | if ( ! uid.isEmpty() ) { |
2235 | Addressee adrr = mAddressBook->findByUid( uid ); | 2235 | Addressee adrr = mAddressBook->findByUid( uid ); |
2236 | if ( !adrr.isEmpty() ) { | 2236 | if ( !adrr.isEmpty() ) { |
2237 | foundUid = uid; | 2237 | foundUid = uid; |
2238 | } | 2238 | } |
2239 | if ( email == "sendbacklist" ) { | 2239 | if ( email == "sendbacklist" ) { |
2240 | //qDebug("ssssssssssssssssssssssend "); | 2240 | //qDebug("ssssssssssssssssssssssend "); |
2241 | QStringList nameList; | 2241 | QStringList nameList; |
2242 | QStringList emailList; | 2242 | QStringList emailList; |
2243 | QStringList uidList; | 2243 | QStringList uidList; |
2244 | nameList.append(adrr.realName()); | 2244 | nameList.append(adrr.realName()); |
2245 | emailList = adrr.emails(); | 2245 | emailList = adrr.emails(); |
2246 | uidList.append( adrr.preferredEmail()); | 2246 | uidList.append( adrr.preferredEmail()); |
2247 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2247 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2248 | return; | 2248 | return; |
2249 | } | 2249 | } |
2250 | 2250 | ||
2251 | } | 2251 | } |
2252 | 2252 | ||
2253 | if ( email == "sendbacklist" ) | 2253 | if ( email == "sendbacklist" ) |
2254 | return; | 2254 | return; |
2255 | if (foundUid.isEmpty()) | 2255 | if (foundUid.isEmpty()) |
2256 | { | 2256 | { |
2257 | //find the uid of the person first | 2257 | //find the uid of the person first |
2258 | Addressee::List namelist; | 2258 | Addressee::List namelist; |
2259 | Addressee::List emaillist; | 2259 | Addressee::List emaillist; |
2260 | 2260 | ||
2261 | if (!name.isEmpty()) | 2261 | if (!name.isEmpty()) |
2262 | namelist = mAddressBook->findByName( name ); | 2262 | namelist = mAddressBook->findByName( name ); |
2263 | 2263 | ||
2264 | if (!email.isEmpty()) | 2264 | if (!email.isEmpty()) |
2265 | emaillist = mAddressBook->findByEmail( email ); | 2265 | emaillist = mAddressBook->findByEmail( email ); |
2266 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2266 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2267 | //check if we have a match in Namelist and Emaillist | 2267 | //check if we have a match in Namelist and Emaillist |
2268 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2268 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2269 | foundUid = emaillist[0].uid(); | 2269 | foundUid = emaillist[0].uid(); |
2270 | } | 2270 | } |
2271 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2271 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2272 | foundUid = namelist[0].uid(); | 2272 | foundUid = namelist[0].uid(); |
2273 | else | 2273 | else |
2274 | { | 2274 | { |
2275 | for (int i = 0; i < namelist.count(); i++) | 2275 | for (int i = 0; i < namelist.count(); i++) |
2276 | { | 2276 | { |
2277 | for (int j = 0; j < emaillist.count(); j++) | 2277 | for (int j = 0; j < emaillist.count(); j++) |
2278 | { | 2278 | { |
2279 | if (namelist[i] == emaillist[j]) | 2279 | if (namelist[i] == emaillist[j]) |
2280 | { | 2280 | { |
2281 | foundUid = namelist[i].uid(); | 2281 | foundUid = namelist[i].uid(); |
2282 | } | 2282 | } |
2283 | } | 2283 | } |
2284 | } | 2284 | } |
2285 | } | 2285 | } |
2286 | } | 2286 | } |
2287 | else | 2287 | else |
2288 | { | 2288 | { |
2289 | foundUid = uid; | 2289 | foundUid = uid; |
2290 | } | 2290 | } |
2291 | 2291 | ||
2292 | if (!foundUid.isEmpty()) | 2292 | if (!foundUid.isEmpty()) |
2293 | { | 2293 | { |
2294 | 2294 | ||
2295 | // raise Ka/Pi if it is in the background | 2295 | // raise Ka/Pi if it is in the background |
2296 | #ifndef DESKTOP_VERSION | 2296 | #ifndef DESKTOP_VERSION |
2297 | #ifndef KORG_NODCOP | 2297 | #ifndef KORG_NODCOP |
2298 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2298 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2299 | #endif | 2299 | #endif |
2300 | #endif | 2300 | #endif |
2301 | 2301 | ||
2302 | mMainWindow->showMaximized(); | 2302 | mMainWindow->showMaximized(); |
2303 | mMainWindow-> raise(); | 2303 | mMainWindow-> raise(); |
2304 | 2304 | ||
2305 | mViewManager->setSelected( "", false); | 2305 | mViewManager->setSelected( "", false); |
2306 | mViewManager->refreshView( "" ); | 2306 | mViewManager->refreshView( "" ); |
2307 | mViewManager->setSelected( foundUid, true ); | 2307 | mViewManager->setSelected( foundUid, true ); |
2308 | mViewManager->refreshView( foundUid ); | 2308 | mViewManager->refreshView( foundUid ); |
2309 | 2309 | ||
2310 | if ( !mMultipleViewsAtOnce ) | 2310 | if ( !mMultipleViewsAtOnce ) |
2311 | { | 2311 | { |
2312 | setDetailsVisible( true ); | 2312 | setDetailsVisible( true ); |
2313 | mActionDetails->setChecked(true); | 2313 | mActionDetails->setChecked(true); |
2314 | } | 2314 | } |
2315 | } | 2315 | } |
2316 | } | 2316 | } |
2317 | 2317 | ||
2318 | void KABCore::whatsnew() | 2318 | void KABCore::whatsnew() |
2319 | { | 2319 | { |
2320 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2320 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2321 | } | 2321 | } |
2322 | void KABCore::synchowto() | 2322 | void KABCore::synchowto() |
2323 | { | 2323 | { |
2324 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2324 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2325 | } | 2325 | } |
2326 | 2326 | ||
2327 | void KABCore::faq() | 2327 | void KABCore::faq() |
2328 | { | 2328 | { |
2329 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2329 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2330 | } | 2330 | } |
2331 | 2331 | ||
2332 | #include <libkcal/syncdefines.h> | 2332 | #include <libkcal/syncdefines.h> |
2333 | 2333 | ||
2334 | KABC::Addressee KABCore::getLastSyncAddressee() | 2334 | KABC::Addressee KABCore::getLastSyncAddressee() |
2335 | { | 2335 | { |
2336 | Addressee lse; | 2336 | Addressee lse; |
2337 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2337 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2338 | 2338 | ||
2339 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2339 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2340 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2340 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2341 | if (lse.isEmpty()) { | 2341 | if (lse.isEmpty()) { |
2342 | qDebug("Creating new last-syncAddressee "); | 2342 | qDebug("Creating new last-syncAddressee "); |
2343 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2343 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2344 | QString sum = ""; | 2344 | QString sum = ""; |
2345 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2345 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2346 | sum = "E: "; | 2346 | sum = "E: "; |
2347 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2347 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2348 | lse.setRevision( mLastAddressbookSync ); | 2348 | lse.setRevision( mLastAddressbookSync ); |
2349 | lse.setCategories( i18n("SyncEvent") ); | 2349 | lse.setCategories( i18n("SyncEvent") ); |
2350 | mAddressBook->insertAddressee( lse ); | 2350 | mAddressBook->insertAddressee( lse ); |
2351 | } | 2351 | } |
2352 | return lse; | 2352 | return lse; |
2353 | } | 2353 | } |
2354 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2354 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2355 | { | 2355 | { |
2356 | 2356 | ||
2357 | //void setZaurusId(int id); | 2357 | //void setZaurusId(int id); |
2358 | // int zaurusId() const; | 2358 | // int zaurusId() const; |
2359 | // void setZaurusUid(int id); | 2359 | // void setZaurusUid(int id); |
2360 | // int zaurusUid() const; | 2360 | // int zaurusUid() const; |
2361 | // void setZaurusStat(int id); | 2361 | // void setZaurusStat(int id); |
2362 | // int zaurusStat() const; | 2362 | // int zaurusStat() const; |
2363 | // 0 equal | 2363 | // 0 equal |
2364 | // 1 take local | 2364 | // 1 take local |
2365 | // 2 take remote | 2365 | // 2 take remote |
2366 | // 3 cancel | 2366 | // 3 cancel |
2367 | QDateTime lastSync = mLastAddressbookSync; | 2367 | QDateTime lastSync = mLastAddressbookSync; |
2368 | QDateTime localMod = local->revision(); | 2368 | QDateTime localMod = local->revision(); |
2369 | QDateTime remoteMod = remote->revision(); | 2369 | QDateTime remoteMod = remote->revision(); |
2370 | 2370 | ||
2371 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2371 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2372 | 2372 | ||
2373 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2373 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2374 | bool remCh, locCh; | 2374 | bool remCh, locCh; |
2375 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2375 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2376 | 2376 | ||
2377 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2377 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2378 | locCh = ( localMod > mLastAddressbookSync ); | 2378 | locCh = ( localMod > mLastAddressbookSync ); |
2379 | if ( !remCh && ! locCh ) { | 2379 | if ( !remCh && ! locCh ) { |
2380 | //qDebug("both not changed "); | 2380 | //qDebug("both not changed "); |
2381 | lastSync = localMod.addDays(1); | 2381 | lastSync = localMod.addDays(1); |
2382 | if ( mode <= SYNC_PREF_ASK ) | 2382 | if ( mode <= SYNC_PREF_ASK ) |
2383 | return 0; | 2383 | return 0; |
2384 | } else { | 2384 | } else { |
2385 | if ( locCh ) { | 2385 | if ( locCh ) { |
2386 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2386 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2387 | lastSync = localMod.addDays( -1 ); | 2387 | lastSync = localMod.addDays( -1 ); |
2388 | if ( !remCh ) | 2388 | if ( !remCh ) |
2389 | remoteMod =( lastSync.addDays( -1 ) ); | 2389 | remoteMod =( lastSync.addDays( -1 ) ); |
2390 | } else { | 2390 | } else { |
2391 | //qDebug(" not loc changed "); | 2391 | //qDebug(" not loc changed "); |
2392 | lastSync = localMod.addDays( 1 ); | 2392 | lastSync = localMod.addDays( 1 ); |
2393 | if ( remCh ) | 2393 | if ( remCh ) |
2394 | remoteMod =( lastSync.addDays( 1 ) ); | 2394 | remoteMod =( lastSync.addDays( 1 ) ); |
2395 | 2395 | ||
2396 | } | 2396 | } |
2397 | } | 2397 | } |
2398 | full = true; | 2398 | full = true; |
2399 | if ( mode < SYNC_PREF_ASK ) | 2399 | if ( mode < SYNC_PREF_ASK ) |
2400 | mode = SYNC_PREF_ASK; | 2400 | mode = SYNC_PREF_ASK; |
2401 | } else { | 2401 | } else { |
2402 | if ( localMod == remoteMod ) | 2402 | if ( localMod == remoteMod ) |
2403 | return 0; | 2403 | return 0; |
2404 | 2404 | ||
2405 | } | 2405 | } |
2406 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2406 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2407 | 2407 | ||
2408 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2408 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2409 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2409 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2410 | //full = true; //debug only | 2410 | //full = true; //debug only |
2411 | if ( full ) { | 2411 | if ( full ) { |
2412 | bool equ = ( (*local) == (*remote) ); | 2412 | bool equ = ( (*local) == (*remote) ); |
2413 | if ( equ ) { | 2413 | if ( equ ) { |
2414 | //qDebug("equal "); | 2414 | //qDebug("equal "); |
2415 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2415 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2416 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2416 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2417 | } | 2417 | } |
2418 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2418 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2419 | return 0; | 2419 | return 0; |
2420 | 2420 | ||
2421 | }//else //debug only | 2421 | }//else //debug only |
2422 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2422 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2423 | } | 2423 | } |
2424 | int result; | 2424 | int result; |
2425 | bool localIsNew; | 2425 | bool localIsNew; |
2426 | //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() ); | 2426 | //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() ); |
2427 | 2427 | ||
2428 | if ( full && mode < SYNC_PREF_NEWEST ) | 2428 | if ( full && mode < SYNC_PREF_NEWEST ) |
2429 | mode = SYNC_PREF_ASK; | 2429 | mode = SYNC_PREF_ASK; |
2430 | 2430 | ||
2431 | switch( mode ) { | 2431 | switch( mode ) { |
2432 | case SYNC_PREF_LOCAL: | 2432 | case SYNC_PREF_LOCAL: |
2433 | if ( lastSync > remoteMod ) | 2433 | if ( lastSync > remoteMod ) |
2434 | return 1; | 2434 | return 1; |
2435 | if ( lastSync > localMod ) | 2435 | if ( lastSync > localMod ) |
2436 | return 2; | 2436 | return 2; |
2437 | return 1; | 2437 | return 1; |
2438 | break; | 2438 | break; |
2439 | case SYNC_PREF_REMOTE: | 2439 | case SYNC_PREF_REMOTE: |
2440 | if ( lastSync > remoteMod ) | 2440 | if ( lastSync > remoteMod ) |
2441 | return 1; | 2441 | return 1; |
2442 | if ( lastSync > localMod ) | 2442 | if ( lastSync > localMod ) |
2443 | return 2; | 2443 | return 2; |
2444 | return 2; | 2444 | return 2; |
2445 | break; | 2445 | break; |
2446 | case SYNC_PREF_NEWEST: | 2446 | case SYNC_PREF_NEWEST: |
2447 | if ( localMod > remoteMod ) | 2447 | if ( localMod > remoteMod ) |
2448 | return 1; | 2448 | return 1; |
2449 | else | 2449 | else |
2450 | return 2; | 2450 | return 2; |
2451 | break; | 2451 | break; |
2452 | case SYNC_PREF_ASK: | 2452 | case SYNC_PREF_ASK: |
2453 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2453 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2454 | if ( lastSync > remoteMod ) | 2454 | if ( lastSync > remoteMod ) |
2455 | return 1; | 2455 | return 1; |
2456 | if ( lastSync > localMod ) | 2456 | if ( lastSync > localMod ) |
2457 | return 2; | 2457 | return 2; |
2458 | localIsNew = localMod >= remoteMod; | 2458 | localIsNew = localMod >= remoteMod; |
2459 | //qDebug("conflict! ************************************** "); | 2459 | //qDebug("conflict! ************************************** "); |
2460 | { | 2460 | { |
2461 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2461 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2462 | result = acd.executeD(localIsNew); | 2462 | result = acd.executeD(localIsNew); |
2463 | return result; | 2463 | return result; |
2464 | } | 2464 | } |
2465 | break; | 2465 | break; |
2466 | case SYNC_PREF_FORCE_LOCAL: | 2466 | case SYNC_PREF_FORCE_LOCAL: |
2467 | return 1; | 2467 | return 1; |
2468 | break; | 2468 | break; |
2469 | case SYNC_PREF_FORCE_REMOTE: | 2469 | case SYNC_PREF_FORCE_REMOTE: |
2470 | return 2; | 2470 | return 2; |
2471 | break; | 2471 | break; |
2472 | 2472 | ||
2473 | default: | 2473 | default: |
2474 | // SYNC_PREF_TAKE_BOTH not implemented | 2474 | // SYNC_PREF_TAKE_BOTH not implemented |
2475 | break; | 2475 | break; |
2476 | } | 2476 | } |
2477 | return 0; | 2477 | return 0; |
2478 | } | 2478 | } |
2479 | 2479 | ||
2480 | 2480 | ||
2481 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2481 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2482 | { | 2482 | { |
2483 | bool syncOK = true; | 2483 | bool syncOK = true; |
2484 | int addedAddressee = 0; | 2484 | int addedAddressee = 0; |
2485 | int addedAddresseeR = 0; | 2485 | int addedAddresseeR = 0; |
2486 | int deletedAddresseeR = 0; | 2486 | int deletedAddresseeR = 0; |
2487 | int deletedAddresseeL = 0; | 2487 | int deletedAddresseeL = 0; |
2488 | int changedLocal = 0; | 2488 | int changedLocal = 0; |
2489 | int changedRemote = 0; | 2489 | int changedRemote = 0; |
2490 | 2490 | ||
2491 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2491 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2492 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2492 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2493 | 2493 | ||
2494 | //QPtrList<Addressee> el = local->rawAddressees(); | 2494 | //QPtrList<Addressee> el = local->rawAddressees(); |
2495 | Addressee addresseeR; | 2495 | Addressee addresseeR; |
2496 | QString uid; | 2496 | QString uid; |
2497 | int take; | 2497 | int take; |
2498 | Addressee addresseeL; | 2498 | Addressee addresseeL; |
2499 | Addressee addresseeRSync; | 2499 | Addressee addresseeRSync; |
2500 | Addressee addresseeLSync; | 2500 | Addressee addresseeLSync; |
2501 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2501 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2502 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2502 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2503 | bool fullDateRange = false; | 2503 | bool fullDateRange = false; |
2504 | local->resetTempSyncStat(); | 2504 | local->resetTempSyncStat(); |
2505 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2505 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2506 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2506 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2507 | addresseeLSync = getLastSyncAddressee(); | 2507 | addresseeLSync = getLastSyncAddressee(); |
2508 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2508 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2509 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2509 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2510 | if ( !addresseeR.isEmpty() ) { | 2510 | if ( !addresseeR.isEmpty() ) { |
2511 | addresseeRSync = addresseeR; | 2511 | addresseeRSync = addresseeR; |
2512 | remote->removeAddressee(addresseeR ); | 2512 | remote->removeAddressee(addresseeR ); |
2513 | 2513 | ||
2514 | } else { | 2514 | } else { |
2515 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2515 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2516 | addresseeRSync = addresseeLSync ; | 2516 | addresseeRSync = addresseeLSync ; |
2517 | } else { | 2517 | } else { |
2518 | qDebug("FULLDATE 1"); | 2518 | qDebug("FULLDATE 1"); |
2519 | fullDateRange = true; | 2519 | fullDateRange = true; |
2520 | Addressee newAdd; | 2520 | Addressee newAdd; |
2521 | addresseeRSync = newAdd; | 2521 | addresseeRSync = newAdd; |
2522 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2522 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2523 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2523 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2524 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2524 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2525 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2525 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2526 | } | 2526 | } |
2527 | } | 2527 | } |
2528 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2528 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2529 | qDebug("FULLDATE 2"); | 2529 | qDebug("FULLDATE 2"); |
2530 | fullDateRange = true; | 2530 | fullDateRange = true; |
2531 | } | 2531 | } |
2532 | if ( ! fullDateRange ) { | 2532 | if ( ! fullDateRange ) { |
2533 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2533 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2534 | 2534 | ||
2535 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2535 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2536 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2536 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2537 | fullDateRange = true; | 2537 | fullDateRange = true; |
2538 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2538 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2539 | } | 2539 | } |
2540 | } | 2540 | } |
2541 | // fullDateRange = true; // debug only! | 2541 | // fullDateRange = true; // debug only! |
2542 | if ( fullDateRange ) | 2542 | if ( fullDateRange ) |
2543 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2543 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2544 | else | 2544 | else |
2545 | mLastAddressbookSync = addresseeLSync.revision(); | 2545 | mLastAddressbookSync = addresseeLSync.revision(); |
2546 | // for resyncing if own file has changed | 2546 | // for resyncing if own file has changed |
2547 | // PENDING fixme later when implemented | 2547 | // PENDING fixme later when implemented |
2548 | #if 0 | 2548 | #if 0 |
2549 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2549 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2550 | mLastAddressbookSync = loadedFileVersion; | 2550 | mLastAddressbookSync = loadedFileVersion; |
2551 | qDebug("setting mLastAddressbookSync "); | 2551 | qDebug("setting mLastAddressbookSync "); |
2552 | } | 2552 | } |
2553 | #endif | 2553 | #endif |
2554 | 2554 | ||
2555 | //qDebug("*************************** "); | 2555 | //qDebug("*************************** "); |
2556 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2556 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2557 | QStringList er = remote->uidList(); | 2557 | QStringList er = remote->uidList(); |
2558 | Addressee inR ;//= er.first(); | 2558 | Addressee inR ;//= er.first(); |
2559 | Addressee inL; | 2559 | Addressee inL; |
2560 | 2560 | ||
2561 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2561 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2562 | 2562 | ||
2563 | int modulo = (er.count()/10)+1; | 2563 | int modulo = (er.count()/10)+1; |
2564 | int incCounter = 0; | 2564 | int incCounter = 0; |
2565 | while ( incCounter < er.count()) { | 2565 | while ( incCounter < er.count()) { |
2566 | if (syncManager->isProgressBarCanceled()) | 2566 | if (syncManager->isProgressBarCanceled()) |
2567 | return false; | 2567 | return false; |
2568 | if ( incCounter % modulo == 0 ) | 2568 | if ( incCounter % modulo == 0 ) |
2569 | syncManager->showProgressBar(incCounter); | 2569 | syncManager->showProgressBar(incCounter); |
2570 | 2570 | ||
2571 | uid = er[ incCounter ]; | 2571 | uid = er[ incCounter ]; |
2572 | bool skipIncidence = false; | 2572 | bool skipIncidence = false; |
2573 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2573 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2574 | skipIncidence = true; | 2574 | skipIncidence = true; |
2575 | QString idS,OidS; | 2575 | QString idS,OidS; |
2576 | qApp->processEvents(); | 2576 | qApp->processEvents(); |
2577 | if ( !skipIncidence ) { | 2577 | if ( !skipIncidence ) { |
2578 | inL = local->findByUid( uid ); | 2578 | inL = local->findByUid( uid ); |
2579 | inR = remote->findByUid( uid ); | 2579 | inR = remote->findByUid( uid ); |
2580 | //inL.setResource( 0 ); | 2580 | //inL.setResource( 0 ); |
2581 | //inR.setResource( 0 ); | 2581 | //inR.setResource( 0 ); |
2582 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2582 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2583 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2583 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2584 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2584 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2585 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2585 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2586 | if ( take == 3 ) | 2586 | if ( take == 3 ) |
2587 | return false; | 2587 | return false; |
2588 | if ( take == 1 ) {// take local | 2588 | if ( take == 1 ) {// take local |
2589 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2589 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2590 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2590 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2591 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2591 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2592 | local->insertAddressee( inL, false ); | 2592 | local->insertAddressee( inL, false ); |
2593 | idS = inR.externalUID(); | 2593 | idS = inR.externalUID(); |
2594 | OidS = inR.originalExternalUID(); | 2594 | OidS = inR.originalExternalUID(); |
2595 | } | 2595 | } |
2596 | else | 2596 | else |
2597 | idS = inR.IDStr(); | 2597 | idS = inR.IDStr(); |
2598 | remote->removeAddressee( inR ); | 2598 | remote->removeAddressee( inR ); |
2599 | inR = inL; | 2599 | inR = inL; |
2600 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2600 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2601 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2601 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2602 | inR.setOriginalExternalUID( OidS ); | 2602 | inR.setOriginalExternalUID( OidS ); |
2603 | inR.setExternalUID( idS ); | 2603 | inR.setExternalUID( idS ); |
2604 | } else { | 2604 | } else { |
2605 | inR.setIDStr( idS ); | 2605 | inR.setIDStr( idS ); |
2606 | } | 2606 | } |
2607 | inR.setResource( 0 ); | 2607 | inR.setResource( 0 ); |
2608 | remote->insertAddressee( inR , false); | 2608 | remote->insertAddressee( inR , false); |
2609 | ++changedRemote; | 2609 | ++changedRemote; |
2610 | } else { // take == 2 take remote | 2610 | } else { // take == 2 take remote |
2611 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2611 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2612 | if ( inR.revision().date().year() < 2004 ) | 2612 | if ( inR.revision().date().year() < 2004 ) |
2613 | inR.setRevision( modifiedCalendar ); | 2613 | inR.setRevision( modifiedCalendar ); |
2614 | } | 2614 | } |