author | zautrix <zautrix> | 2004-10-27 12:27:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-27 12:27:39 (UTC) |
commit | 2f3396d84d2f3c92e1e0e420d677892c1f9c0778 (patch) (unidiff) | |
tree | 1ebab5dc6d00cb09720789897ce2c86df05cc9ab /kaddressbook | |
parent | f73d249579d52d7aeaacde2dcb23abeb42f9ee95 (diff) | |
download | kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.zip kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.tar.gz kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.tar.bz2 |
completed KDE AB sync. but will it work ...?
-rw-r--r-- | kaddressbook/kabcore.cpp | 23 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/viewmanager.h | 1 |
3 files changed, 27 insertions, 2 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 2f00a09..ea87929 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1059,516 +1059,518 @@ void KABCore::contactModified( const KABC::Addressee &addr ) | |||
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | void KABCore::newContact() | 1061 | void KABCore::newContact() |
1062 | { | 1062 | { |
1063 | 1063 | ||
1064 | 1064 | ||
1065 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1065 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1066 | 1066 | ||
1067 | QPtrList<KRES::Resource> kresResources; | 1067 | QPtrList<KRES::Resource> kresResources; |
1068 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1068 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1069 | KABC::Resource *resource; | 1069 | KABC::Resource *resource; |
1070 | while ( ( resource = it.current() ) != 0 ) { | 1070 | while ( ( resource = it.current() ) != 0 ) { |
1071 | ++it; | 1071 | ++it; |
1072 | if ( !resource->readOnly() ) { | 1072 | if ( !resource->readOnly() ) { |
1073 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1073 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1074 | if ( res ) | 1074 | if ( res ) |
1075 | kresResources.append( res ); | 1075 | kresResources.append( res ); |
1076 | } | 1076 | } |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1079 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1080 | resource = static_cast<KABC::Resource*>( res ); | 1080 | resource = static_cast<KABC::Resource*>( res ); |
1081 | 1081 | ||
1082 | if ( resource ) { | 1082 | if ( resource ) { |
1083 | KABC::Addressee addr; | 1083 | KABC::Addressee addr; |
1084 | addr.setResource( resource ); | 1084 | addr.setResource( resource ); |
1085 | mEditorDialog->setAddressee( addr ); | 1085 | mEditorDialog->setAddressee( addr ); |
1086 | KApplication::execDialog ( mEditorDialog ); | 1086 | KApplication::execDialog ( mEditorDialog ); |
1087 | 1087 | ||
1088 | } else | 1088 | } else |
1089 | return; | 1089 | return; |
1090 | 1090 | ||
1091 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1091 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1092 | 1092 | ||
1093 | 1093 | ||
1094 | } | 1094 | } |
1095 | 1095 | ||
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 | mIncSearchWidget->setFocus(); | ||
1315 | } | 1316 | } |
1316 | else { | 1317 | else { |
1317 | mViewManager->show(); | 1318 | mViewManager->show(); |
1318 | mDetails->hide(); | 1319 | mDetails->hide(); |
1320 | mViewManager->setFocusAV(); | ||
1319 | } | 1321 | } |
1320 | setJumpButtonBarVisible( !visible ); | 1322 | setJumpButtonBarVisible( !visible ); |
1321 | } | 1323 | } |
1322 | 1324 | ||
1323 | } | 1325 | } |
1324 | 1326 | ||
1325 | void KABCore::extensionChanged( int id ) | 1327 | void KABCore::extensionChanged( int id ) |
1326 | { | 1328 | { |
1327 | //change the details view only for non desktop systems | 1329 | //change the details view only for non desktop systems |
1328 | #ifndef DESKTOP_VERSION | 1330 | #ifndef DESKTOP_VERSION |
1329 | 1331 | ||
1330 | if (id == 0) | 1332 | if (id == 0) |
1331 | { | 1333 | { |
1332 | //the user disabled the extension. | 1334 | //the user disabled the extension. |
1333 | 1335 | ||
1334 | if (mMultipleViewsAtOnce) | 1336 | if (mMultipleViewsAtOnce) |
1335 | { // enable detailsview again | 1337 | { // enable detailsview again |
1336 | setDetailsVisible( true ); | 1338 | setDetailsVisible( true ); |
1337 | mActionDetails->setChecked( true ); | 1339 | mActionDetails->setChecked( true ); |
1338 | } | 1340 | } |
1339 | else | 1341 | else |
1340 | { //go back to the listview | 1342 | { //go back to the listview |
1341 | setDetailsVisible( false ); | 1343 | setDetailsVisible( false ); |
1342 | mActionDetails->setChecked( false ); | 1344 | mActionDetails->setChecked( false ); |
1343 | mActionDetails->setEnabled(true); | 1345 | mActionDetails->setEnabled(true); |
1344 | } | 1346 | } |
1345 | 1347 | ||
1346 | } | 1348 | } |
1347 | else | 1349 | else |
1348 | { | 1350 | { |
1349 | //the user enabled the extension. | 1351 | //the user enabled the extension. |
1350 | setDetailsVisible( false ); | 1352 | setDetailsVisible( false ); |
1351 | mActionDetails->setChecked( false ); | 1353 | mActionDetails->setChecked( false ); |
1352 | 1354 | ||
1353 | if (!mMultipleViewsAtOnce) | 1355 | if (!mMultipleViewsAtOnce) |
1354 | { | 1356 | { |
1355 | mActionDetails->setEnabled(false); | 1357 | mActionDetails->setEnabled(false); |
1356 | } | 1358 | } |
1357 | 1359 | ||
1358 | mExtensionManager->setSelectionChanged(); | 1360 | mExtensionManager->setSelectionChanged(); |
1359 | 1361 | ||
1360 | } | 1362 | } |
1361 | 1363 | ||
1362 | #endif// DESKTOP_VERSION | 1364 | #endif// DESKTOP_VERSION |
1363 | 1365 | ||
1364 | } | 1366 | } |
1365 | 1367 | ||
1366 | 1368 | ||
1367 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1369 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1368 | { | 1370 | { |
1369 | 1371 | ||
1370 | if ( list.count() != 0 ) { | 1372 | if ( list.count() != 0 ) { |
1371 | KABC::Addressee::List::ConstIterator it; | 1373 | KABC::Addressee::List::ConstIterator it; |
1372 | for ( it = list.begin(); it != list.end(); ++it ) | 1374 | for ( it = list.begin(); it != list.end(); ++it ) |
1373 | mAddressBook->insertAddressee( *it ); | 1375 | mAddressBook->insertAddressee( *it ); |
1374 | if ( list.count() > 1 ) | 1376 | if ( list.count() > 1 ) |
1375 | setModified(); | 1377 | setModified(); |
1376 | else | 1378 | else |
1377 | setModifiedWOrefresh(); | 1379 | setModifiedWOrefresh(); |
1378 | } | 1380 | } |
1379 | if ( list.count() == 0 ) | 1381 | if ( list.count() == 0 ) |
1380 | mViewManager->refreshView(); | 1382 | mViewManager->refreshView(); |
1381 | else | 1383 | else |
1382 | mViewManager->refreshView( list[ 0 ].uid() ); | 1384 | mViewManager->refreshView( list[ 0 ].uid() ); |
1383 | 1385 | ||
1384 | 1386 | ||
1385 | 1387 | ||
1386 | } | 1388 | } |
1387 | 1389 | ||
1388 | QString KABCore::getNameByPhone( const QString &phone ) | 1390 | QString KABCore::getNameByPhone( const QString &phone ) |
1389 | { | 1391 | { |
1390 | #ifndef KAB_EMBEDDED | 1392 | #ifndef KAB_EMBEDDED |
1391 | QRegExp r( "[/*/-/ ]" ); | 1393 | QRegExp r( "[/*/-/ ]" ); |
1392 | QString localPhone( phone ); | 1394 | QString localPhone( phone ); |
1393 | 1395 | ||
1394 | bool found = false; | 1396 | bool found = false; |
1395 | QString ownerName = ""; | 1397 | QString ownerName = ""; |
1396 | KABC::AddressBook::Iterator iter; | 1398 | KABC::AddressBook::Iterator iter; |
1397 | KABC::PhoneNumber::List::Iterator phoneIter; | 1399 | KABC::PhoneNumber::List::Iterator phoneIter; |
1398 | KABC::PhoneNumber::List phoneList; | 1400 | KABC::PhoneNumber::List phoneList; |
1399 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1401 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1400 | phoneList = (*iter).phoneNumbers(); | 1402 | phoneList = (*iter).phoneNumbers(); |
1401 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1403 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1402 | ++phoneIter) { | 1404 | ++phoneIter) { |
1403 | // Get rid of separator chars so just the numbers are compared. | 1405 | // Get rid of separator chars so just the numbers are compared. |
1404 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1406 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1405 | ownerName = (*iter).formattedName(); | 1407 | ownerName = (*iter).formattedName(); |
1406 | found = true; | 1408 | found = true; |
1407 | } | 1409 | } |
1408 | } | 1410 | } |
1409 | } | 1411 | } |
1410 | 1412 | ||
1411 | return ownerName; | 1413 | return ownerName; |
1412 | #else //KAB_EMBEDDED | 1414 | #else //KAB_EMBEDDED |
1413 | qDebug("KABCore::getNameByPhone finsih method"); | 1415 | qDebug("KABCore::getNameByPhone finsih method"); |
1414 | return ""; | 1416 | return ""; |
1415 | #endif //KAB_EMBEDDED | 1417 | #endif //KAB_EMBEDDED |
1416 | 1418 | ||
1417 | } | 1419 | } |
1418 | 1420 | ||
1419 | void KABCore::openConfigDialog() | 1421 | void KABCore::openConfigDialog() |
1420 | { | 1422 | { |
1421 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1423 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1422 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1424 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1423 | ConfigureDialog->addModule(kabcfg ); | 1425 | ConfigureDialog->addModule(kabcfg ); |
1424 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1426 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1425 | ConfigureDialog->addModule(kdelibcfg ); | 1427 | ConfigureDialog->addModule(kdelibcfg ); |
1426 | 1428 | ||
1427 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1429 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1428 | this, SLOT( configurationChanged() ) ); | 1430 | this, SLOT( configurationChanged() ) ); |
1429 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1431 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1430 | this, SLOT( configurationChanged() ) ); | 1432 | this, SLOT( configurationChanged() ) ); |
1431 | saveSettings(); | 1433 | saveSettings(); |
1432 | #ifndef DESKTOP_VERSION | 1434 | #ifndef DESKTOP_VERSION |
1433 | ConfigureDialog->showMaximized(); | 1435 | ConfigureDialog->showMaximized(); |
1434 | #endif | 1436 | #endif |
1435 | if ( ConfigureDialog->exec() ) | 1437 | if ( ConfigureDialog->exec() ) |
1436 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1438 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1437 | delete ConfigureDialog; | 1439 | delete ConfigureDialog; |
1438 | } | 1440 | } |
1439 | 1441 | ||
1440 | void KABCore::openLDAPDialog() | 1442 | void KABCore::openLDAPDialog() |
1441 | { | 1443 | { |
1442 | #ifndef KAB_EMBEDDED | 1444 | #ifndef KAB_EMBEDDED |
1443 | if ( !mLdapSearchDialog ) { | 1445 | if ( !mLdapSearchDialog ) { |
1444 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1446 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1445 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1447 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1446 | SLOT( refreshView() ) ); | 1448 | SLOT( refreshView() ) ); |
1447 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1449 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1448 | SLOT( setModified() ) ); | 1450 | SLOT( setModified() ) ); |
1449 | } else | 1451 | } else |
1450 | mLdapSearchDialog->restoreSettings(); | 1452 | mLdapSearchDialog->restoreSettings(); |
1451 | 1453 | ||
1452 | if ( mLdapSearchDialog->isOK() ) | 1454 | if ( mLdapSearchDialog->isOK() ) |
1453 | mLdapSearchDialog->exec(); | 1455 | mLdapSearchDialog->exec(); |
1454 | #else //KAB_EMBEDDED | 1456 | #else //KAB_EMBEDDED |
1455 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1457 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1456 | #endif //KAB_EMBEDDED | 1458 | #endif //KAB_EMBEDDED |
1457 | } | 1459 | } |
1458 | 1460 | ||
1459 | void KABCore::print() | 1461 | void KABCore::print() |
1460 | { | 1462 | { |
1461 | #ifndef KAB_EMBEDDED | 1463 | #ifndef KAB_EMBEDDED |
1462 | KPrinter printer; | 1464 | KPrinter printer; |
1463 | if ( !printer.setup( this ) ) | 1465 | if ( !printer.setup( this ) ) |
1464 | return; | 1466 | return; |
1465 | 1467 | ||
1466 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1468 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1467 | mViewManager->selectedUids(), this ); | 1469 | mViewManager->selectedUids(), this ); |
1468 | 1470 | ||
1469 | wizard.exec(); | 1471 | wizard.exec(); |
1470 | #else //KAB_EMBEDDED | 1472 | #else //KAB_EMBEDDED |
1471 | qDebug("KABCore::print() finsih method"); | 1473 | qDebug("KABCore::print() finsih method"); |
1472 | #endif //KAB_EMBEDDED | 1474 | #endif //KAB_EMBEDDED |
1473 | 1475 | ||
1474 | } | 1476 | } |
1475 | 1477 | ||
1476 | 1478 | ||
1477 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1479 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1478 | { | 1480 | { |
1479 | if ( mGUIClient ) | 1481 | if ( mGUIClient ) |
1480 | mGUIClient->insertChildClient( client ); | 1482 | mGUIClient->insertChildClient( client ); |
1481 | else | 1483 | else |
1482 | KMessageBox::error( this, "no KXMLGUICLient"); | 1484 | KMessageBox::error( this, "no KXMLGUICLient"); |
1483 | } | 1485 | } |
1484 | 1486 | ||
1485 | 1487 | ||
1486 | void KABCore::configurationChanged() | 1488 | void KABCore::configurationChanged() |
1487 | { | 1489 | { |
1488 | mExtensionManager->reconfigure(); | 1490 | mExtensionManager->reconfigure(); |
1489 | } | 1491 | } |
1490 | 1492 | ||
1491 | void KABCore::addressBookChanged() | 1493 | void KABCore::addressBookChanged() |
1492 | { | 1494 | { |
1493 | /*US | 1495 | /*US |
1494 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1496 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1495 | while ( it.current() ) { | 1497 | while ( it.current() ) { |
1496 | if ( it.current()->dirty() ) { | 1498 | if ( it.current()->dirty() ) { |
1497 | QString text = i18n( "Data has been changed externally. Unsaved " | 1499 | QString text = i18n( "Data has been changed externally. Unsaved " |
1498 | "changes will be lost." ); | 1500 | "changes will be lost." ); |
1499 | KMessageBox::information( this, text ); | 1501 | KMessageBox::information( this, text ); |
1500 | } | 1502 | } |
1501 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1503 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1502 | ++it; | 1504 | ++it; |
1503 | } | 1505 | } |
1504 | */ | 1506 | */ |
1505 | if (mEditorDialog) | 1507 | if (mEditorDialog) |
1506 | { | 1508 | { |
1507 | if (mEditorDialog->dirty()) | 1509 | if (mEditorDialog->dirty()) |
1508 | { | 1510 | { |
1509 | QString text = i18n( "Data has been changed externally. Unsaved " | 1511 | QString text = i18n( "Data has been changed externally. Unsaved " |
1510 | "changes will be lost." ); | 1512 | "changes will be lost." ); |
1511 | KMessageBox::information( this, text ); | 1513 | KMessageBox::information( this, text ); |
1512 | } | 1514 | } |
1513 | QString currentuid = mEditorDialog->addressee().uid(); | 1515 | QString currentuid = mEditorDialog->addressee().uid(); |
1514 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1516 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1515 | } | 1517 | } |
1516 | mViewManager->refreshView(); | 1518 | mViewManager->refreshView(); |
1517 | // mDetails->refreshView(); | 1519 | // mDetails->refreshView(); |
1518 | 1520 | ||
1519 | 1521 | ||
1520 | } | 1522 | } |
1521 | 1523 | ||
1522 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1524 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1523 | const char *name ) | 1525 | const char *name ) |
1524 | { | 1526 | { |
1525 | 1527 | ||
1526 | if ( mEditorDialog == 0 ) { | 1528 | if ( mEditorDialog == 0 ) { |
1527 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1529 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1528 | name ? name : "editorDialog" ); | 1530 | name ? name : "editorDialog" ); |
1529 | 1531 | ||
1530 | 1532 | ||
1531 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1533 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1532 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1534 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1533 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1535 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1534 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1536 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1535 | } | 1537 | } |
1536 | 1538 | ||
1537 | return mEditorDialog; | 1539 | return mEditorDialog; |
1538 | } | 1540 | } |
1539 | 1541 | ||
1540 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1542 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1541 | { | 1543 | { |
1542 | //mEditorDict.remove( uid ); | 1544 | //mEditorDict.remove( uid ); |
1543 | } | 1545 | } |
1544 | 1546 | ||
1545 | void KABCore::initGUI() | 1547 | void KABCore::initGUI() |
1546 | { | 1548 | { |
1547 | #ifndef KAB_EMBEDDED | 1549 | #ifndef KAB_EMBEDDED |
1548 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1550 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1549 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1551 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1550 | 1552 | ||
1551 | mExtensionBarSplitter = new QSplitter( this ); | 1553 | mExtensionBarSplitter = new QSplitter( this ); |
1552 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1554 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1553 | 1555 | ||
1554 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1556 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1555 | 1557 | ||
1556 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1558 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1557 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1559 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1560 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1559 | SLOT( incrementalSearch( const QString& ) ) ); | 1561 | SLOT( incrementalSearch( const QString& ) ) ); |
1560 | 1562 | ||
1561 | mViewManager = new ViewManager( this, viewSpace ); | 1563 | mViewManager = new ViewManager( this, viewSpace ); |
1562 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1564 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1563 | 1565 | ||
1564 | mDetails = new ViewContainer( mDetailsSplitter ); | 1566 | mDetails = new ViewContainer( mDetailsSplitter ); |
1565 | 1567 | ||
1566 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1568 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1567 | 1569 | ||
1568 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1570 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1569 | 1571 | ||
1570 | topLayout->addWidget( mExtensionBarSplitter ); | 1572 | topLayout->addWidget( mExtensionBarSplitter ); |
1571 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1573 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1572 | topLayout->addWidget( mJumpButtonBar ); | 1574 | topLayout->addWidget( mJumpButtonBar ); |
1573 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1575 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1574 | 1576 | ||
@@ -1791,1126 +1793,1143 @@ void KABCore::initActions() | |||
1791 | this, SLOT( redo() ), actionCollection(), | 1793 | this, SLOT( redo() ), actionCollection(), |
1792 | "kaddressbook_redo" ); | 1794 | "kaddressbook_redo" ); |
1793 | } else { | 1795 | } else { |
1794 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1796 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1795 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1797 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1796 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1798 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1797 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1799 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1798 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1800 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1799 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1801 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1800 | } | 1802 | } |
1801 | 1803 | ||
1802 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1804 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1803 | Key_Delete, this, SLOT( deleteContacts() ), | 1805 | Key_Delete, this, SLOT( deleteContacts() ), |
1804 | actionCollection(), "edit_delete" ); | 1806 | actionCollection(), "edit_delete" ); |
1805 | 1807 | ||
1806 | mActionUndo->setEnabled( false ); | 1808 | mActionUndo->setEnabled( false ); |
1807 | mActionRedo->setEnabled( false ); | 1809 | mActionRedo->setEnabled( false ); |
1808 | 1810 | ||
1809 | // settings menu | 1811 | // settings menu |
1810 | #ifdef KAB_EMBEDDED | 1812 | #ifdef KAB_EMBEDDED |
1811 | //US special menuentry to configure the addressbook resources. On KDE | 1813 | //US special menuentry to configure the addressbook resources. On KDE |
1812 | // you do that through the control center !!! | 1814 | // you do that through the control center !!! |
1813 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1815 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1814 | SLOT( configureResources() ), actionCollection(), | 1816 | SLOT( configureResources() ), actionCollection(), |
1815 | "kaddressbook_configure_resources" ); | 1817 | "kaddressbook_configure_resources" ); |
1816 | #endif //KAB_EMBEDDED | 1818 | #endif //KAB_EMBEDDED |
1817 | 1819 | ||
1818 | if ( mIsPart ) { | 1820 | if ( mIsPart ) { |
1819 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1821 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1820 | SLOT( openConfigDialog() ), actionCollection(), | 1822 | SLOT( openConfigDialog() ), actionCollection(), |
1821 | "kaddressbook_configure" ); | 1823 | "kaddressbook_configure" ); |
1822 | 1824 | ||
1823 | //US not implemented yet | 1825 | //US not implemented yet |
1824 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1826 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1825 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1827 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1826 | // "kaddressbook_configure_shortcuts" ); | 1828 | // "kaddressbook_configure_shortcuts" ); |
1827 | #ifdef KAB_EMBEDDED | 1829 | #ifdef KAB_EMBEDDED |
1828 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1830 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1829 | mActionConfigureToolbars->setEnabled( false ); | 1831 | mActionConfigureToolbars->setEnabled( false ); |
1830 | #endif //KAB_EMBEDDED | 1832 | #endif //KAB_EMBEDDED |
1831 | 1833 | ||
1832 | } else { | 1834 | } else { |
1833 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1835 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1834 | 1836 | ||
1835 | //US not implemented yet | 1837 | //US not implemented yet |
1836 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1838 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1837 | } | 1839 | } |
1838 | 1840 | ||
1839 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1841 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1840 | actionCollection(), "options_show_jump_bar" ); | 1842 | actionCollection(), "options_show_jump_bar" ); |
1841 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1843 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1842 | 1844 | ||
1843 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1845 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1844 | actionCollection(), "options_show_details" ); | 1846 | actionCollection(), "options_show_details" ); |
1845 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1847 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1846 | 1848 | ||
1847 | 1849 | ||
1848 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 1850 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
1849 | SLOT( toggleBeamReceive() ), actionCollection(), | 1851 | SLOT( toggleBeamReceive() ), actionCollection(), |
1850 | "kaddressbook_beam_rec" ); | 1852 | "kaddressbook_beam_rec" ); |
1851 | 1853 | ||
1852 | 1854 | ||
1853 | // misc | 1855 | // misc |
1854 | // only enable LDAP lookup if we can handle the protocol | 1856 | // only enable LDAP lookup if we can handle the protocol |
1855 | #ifndef KAB_EMBEDDED | 1857 | #ifndef KAB_EMBEDDED |
1856 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1858 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1857 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1859 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1858 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1860 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1859 | "ldap_lookup" ); | 1861 | "ldap_lookup" ); |
1860 | } | 1862 | } |
1861 | #else //KAB_EMBEDDED | 1863 | #else //KAB_EMBEDDED |
1862 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1864 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1863 | #endif //KAB_EMBEDDED | 1865 | #endif //KAB_EMBEDDED |
1864 | 1866 | ||
1865 | 1867 | ||
1866 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1868 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1867 | SLOT( setWhoAmI() ), actionCollection(), | 1869 | SLOT( setWhoAmI() ), actionCollection(), |
1868 | "set_personal" ); | 1870 | "set_personal" ); |
1869 | 1871 | ||
1870 | 1872 | ||
1871 | 1873 | ||
1872 | 1874 | ||
1873 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1875 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1874 | SLOT( setCategories() ), actionCollection(), | 1876 | SLOT( setCategories() ), actionCollection(), |
1875 | "edit_set_categories" ); | 1877 | "edit_set_categories" ); |
1876 | 1878 | ||
1877 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1879 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1878 | SLOT( removeVoice() ), actionCollection(), | 1880 | SLOT( removeVoice() ), actionCollection(), |
1879 | "remove_voice" ); | 1881 | "remove_voice" ); |
1880 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1882 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1881 | SLOT( importFromOL() ), actionCollection(), | 1883 | SLOT( importFromOL() ), actionCollection(), |
1882 | "import_OL" ); | 1884 | "import_OL" ); |
1883 | #ifdef KAB_EMBEDDED | 1885 | #ifdef KAB_EMBEDDED |
1884 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1886 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1885 | this, SLOT( showLicence() ), actionCollection(), | 1887 | this, SLOT( showLicence() ), actionCollection(), |
1886 | "licence_about_data" ); | 1888 | "licence_about_data" ); |
1887 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1889 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1888 | this, SLOT( faq() ), actionCollection(), | 1890 | this, SLOT( faq() ), actionCollection(), |
1889 | "faq_about_data" ); | 1891 | "faq_about_data" ); |
1890 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 1892 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
1891 | this, SLOT( whatsnew() ), actionCollection(), | 1893 | this, SLOT( whatsnew() ), actionCollection(), |
1892 | "wn" ); | 1894 | "wn" ); |
1893 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 1895 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
1894 | this, SLOT( synchowto() ), actionCollection(), | 1896 | this, SLOT( synchowto() ), actionCollection(), |
1895 | "sync" ); | 1897 | "sync" ); |
1896 | 1898 | ||
1897 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1899 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1898 | this, SLOT( createAboutData() ), actionCollection(), | 1900 | this, SLOT( createAboutData() ), actionCollection(), |
1899 | "kaddressbook_about_data" ); | 1901 | "kaddressbook_about_data" ); |
1900 | #endif //KAB_EMBEDDED | 1902 | #endif //KAB_EMBEDDED |
1901 | 1903 | ||
1902 | clipboardDataChanged(); | 1904 | clipboardDataChanged(); |
1903 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1905 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1904 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1906 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1905 | } | 1907 | } |
1906 | 1908 | ||
1907 | //US we need this function, to plug all actions into the correct menues. | 1909 | //US we need this function, to plug all actions into the correct menues. |
1908 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1910 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1909 | void KABCore::addActionsManually() | 1911 | void KABCore::addActionsManually() |
1910 | { | 1912 | { |
1911 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1913 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1912 | 1914 | ||
1913 | #ifdef KAB_EMBEDDED | 1915 | #ifdef KAB_EMBEDDED |
1914 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1916 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1915 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1917 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1916 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1918 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1917 | 1919 | ||
1918 | KToolBar* tb = mMainWindow->toolBar(); | 1920 | KToolBar* tb = mMainWindow->toolBar(); |
1919 | 1921 | ||
1920 | #ifdef DESKTOP_VERSION | 1922 | #ifdef DESKTOP_VERSION |
1921 | QMenuBar* mb = mMainWindow->menuBar(); | 1923 | QMenuBar* mb = mMainWindow->menuBar(); |
1922 | 1924 | ||
1923 | //US setup menubar. | 1925 | //US setup menubar. |
1924 | //Disable the following block if you do not want to have a menubar. | 1926 | //Disable the following block if you do not want to have a menubar. |
1925 | mb->insertItem( "&File", fileMenu ); | 1927 | mb->insertItem( "&File", fileMenu ); |
1926 | mb->insertItem( "&Edit", editMenu ); | 1928 | mb->insertItem( "&Edit", editMenu ); |
1927 | mb->insertItem( "&View", viewMenu ); | 1929 | mb->insertItem( "&View", viewMenu ); |
1928 | mb->insertItem( "&Settings", settingsMenu ); | 1930 | mb->insertItem( "&Settings", settingsMenu ); |
1929 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1931 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1930 | mb->insertItem( "&Change selected", changeMenu ); | 1932 | mb->insertItem( "&Change selected", changeMenu ); |
1931 | mb->insertItem( "&Help", helpMenu ); | 1933 | mb->insertItem( "&Help", helpMenu ); |
1932 | mIncSearchWidget = new IncSearchWidget( tb ); | 1934 | mIncSearchWidget = new IncSearchWidget( tb ); |
1933 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1935 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1934 | 1936 | ||
1935 | #else | 1937 | #else |
1936 | //US setup toolbar | 1938 | //US setup toolbar |
1937 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1939 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1938 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1940 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1939 | menuBarTB->insertItem( "ME", popupBarTB); | 1941 | menuBarTB->insertItem( "ME", popupBarTB); |
1940 | tb->insertWidget(-1, 0, menuBarTB); | 1942 | tb->insertWidget(-1, 0, menuBarTB); |
1941 | mIncSearchWidget = new IncSearchWidget( tb ); | 1943 | mIncSearchWidget = new IncSearchWidget( tb ); |
1942 | 1944 | ||
1943 | tb->enableMoving(false); | 1945 | tb->enableMoving(false); |
1944 | popupBarTB->insertItem( "&File", fileMenu ); | 1946 | popupBarTB->insertItem( "&File", fileMenu ); |
1945 | popupBarTB->insertItem( "&Edit", editMenu ); | 1947 | popupBarTB->insertItem( "&Edit", editMenu ); |
1946 | popupBarTB->insertItem( "&View", viewMenu ); | 1948 | popupBarTB->insertItem( "&View", viewMenu ); |
1947 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1949 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1948 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1950 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1949 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1951 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1950 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1952 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1951 | popupBarTB->insertItem( "&Help", helpMenu ); | 1953 | popupBarTB->insertItem( "&Help", helpMenu ); |
1952 | if (QApplication::desktop()->width() > 320 ) { | 1954 | if (QApplication::desktop()->width() > 320 ) { |
1953 | // mViewManager->getFilterAction()->plug ( tb); | 1955 | // mViewManager->getFilterAction()->plug ( tb); |
1954 | } | 1956 | } |
1955 | #endif | 1957 | #endif |
1956 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1958 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1957 | 1959 | ||
1958 | 1960 | ||
1959 | 1961 | ||
1960 | //US Now connect the actions with the menue entries. | 1962 | //US Now connect the actions with the menue entries. |
1961 | mActionPrint->plug( fileMenu ); | 1963 | mActionPrint->plug( fileMenu ); |
1962 | mActionMail->plug( fileMenu ); | 1964 | mActionMail->plug( fileMenu ); |
1963 | fileMenu->insertSeparator(); | 1965 | fileMenu->insertSeparator(); |
1964 | 1966 | ||
1965 | mActionNewContact->plug( fileMenu ); | 1967 | mActionNewContact->plug( fileMenu ); |
1966 | mActionNewContact->plug( tb ); | 1968 | mActionNewContact->plug( tb ); |
1967 | 1969 | ||
1968 | mActionEditAddressee->plug( fileMenu ); | 1970 | mActionEditAddressee->plug( fileMenu ); |
1969 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1971 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1970 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1972 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1971 | mActionEditAddressee->plug( tb ); | 1973 | mActionEditAddressee->plug( tb ); |
1972 | 1974 | ||
1973 | fileMenu->insertSeparator(); | 1975 | fileMenu->insertSeparator(); |
1974 | mActionSave->plug( fileMenu ); | 1976 | mActionSave->plug( fileMenu ); |
1975 | fileMenu->insertItem( "&Import", ImportMenu ); | 1977 | fileMenu->insertItem( "&Import", ImportMenu ); |
1976 | fileMenu->insertItem( "&Export", ExportMenu ); | 1978 | fileMenu->insertItem( "&Export", ExportMenu ); |
1977 | fileMenu->insertSeparator(); | 1979 | fileMenu->insertSeparator(); |
1978 | mActionMailVCard->plug( fileMenu ); | 1980 | mActionMailVCard->plug( fileMenu ); |
1979 | #ifndef DESKTOP_VERSION | 1981 | #ifndef DESKTOP_VERSION |
1980 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1982 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1981 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1983 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1982 | #endif | 1984 | #endif |
1983 | fileMenu->insertSeparator(); | 1985 | fileMenu->insertSeparator(); |
1984 | mActionQuit->plug( fileMenu ); | 1986 | mActionQuit->plug( fileMenu ); |
1985 | #ifdef _WIN32_ | 1987 | #ifdef _WIN32_ |
1986 | mActionImportOL->plug( ImportMenu ); | 1988 | mActionImportOL->plug( ImportMenu ); |
1987 | #endif | 1989 | #endif |
1988 | // edit menu | 1990 | // edit menu |
1989 | mActionUndo->plug( editMenu ); | 1991 | mActionUndo->plug( editMenu ); |
1990 | mActionRedo->plug( editMenu ); | 1992 | mActionRedo->plug( editMenu ); |
1991 | editMenu->insertSeparator(); | 1993 | editMenu->insertSeparator(); |
1992 | mActionCut->plug( editMenu ); | 1994 | mActionCut->plug( editMenu ); |
1993 | mActionCopy->plug( editMenu ); | 1995 | mActionCopy->plug( editMenu ); |
1994 | mActionPaste->plug( editMenu ); | 1996 | mActionPaste->plug( editMenu ); |
1995 | mActionDelete->plug( editMenu ); | 1997 | mActionDelete->plug( editMenu ); |
1996 | editMenu->insertSeparator(); | 1998 | editMenu->insertSeparator(); |
1997 | mActionSelectAll->plug( editMenu ); | 1999 | mActionSelectAll->plug( editMenu ); |
1998 | 2000 | ||
1999 | mActionRemoveVoice->plug( changeMenu ); | 2001 | mActionRemoveVoice->plug( changeMenu ); |
2000 | // settings menu | 2002 | // settings menu |
2001 | //US special menuentry to configure the addressbook resources. On KDE | 2003 | //US special menuentry to configure the addressbook resources. On KDE |
2002 | // you do that through the control center !!! | 2004 | // you do that through the control center !!! |
2003 | mActionConfigResources->plug( settingsMenu ); | 2005 | mActionConfigResources->plug( settingsMenu ); |
2004 | settingsMenu->insertSeparator(); | 2006 | settingsMenu->insertSeparator(); |
2005 | 2007 | ||
2006 | mActionConfigKAddressbook->plug( settingsMenu ); | 2008 | mActionConfigKAddressbook->plug( settingsMenu ); |
2007 | 2009 | ||
2008 | if ( mIsPart ) { | 2010 | if ( mIsPart ) { |
2009 | //US not implemented yet | 2011 | //US not implemented yet |
2010 | //mActionConfigShortcuts->plug( settingsMenu ); | 2012 | //mActionConfigShortcuts->plug( settingsMenu ); |
2011 | //mActionConfigureToolbars->plug( settingsMenu ); | 2013 | //mActionConfigureToolbars->plug( settingsMenu ); |
2012 | 2014 | ||
2013 | } else { | 2015 | } else { |
2014 | //US not implemented yet | 2016 | //US not implemented yet |
2015 | //mActionKeyBindings->plug( settingsMenu ); | 2017 | //mActionKeyBindings->plug( settingsMenu ); |
2016 | } | 2018 | } |
2017 | 2019 | ||
2018 | settingsMenu->insertSeparator(); | 2020 | settingsMenu->insertSeparator(); |
2019 | 2021 | ||
2020 | mActionJumpBar->plug( settingsMenu ); | 2022 | mActionJumpBar->plug( settingsMenu ); |
2021 | mActionDetails->plug( settingsMenu ); | 2023 | mActionDetails->plug( settingsMenu ); |
2022 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2024 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2023 | mActionDetails->plug( tb ); | 2025 | mActionDetails->plug( tb ); |
2024 | settingsMenu->insertSeparator(); | 2026 | settingsMenu->insertSeparator(); |
2025 | mActionBR->plug(settingsMenu ); | 2027 | mActionBR->plug(settingsMenu ); |
2026 | settingsMenu->insertSeparator(); | 2028 | settingsMenu->insertSeparator(); |
2027 | 2029 | ||
2028 | mActionWhoAmI->plug( settingsMenu ); | 2030 | mActionWhoAmI->plug( settingsMenu ); |
2029 | mActionCategories->plug( settingsMenu ); | 2031 | mActionCategories->plug( settingsMenu ); |
2030 | 2032 | ||
2031 | 2033 | ||
2032 | mActionWN->plug( helpMenu ); | 2034 | mActionWN->plug( helpMenu ); |
2033 | mActionSyncHowto->plug( helpMenu ); | 2035 | mActionSyncHowto->plug( helpMenu ); |
2034 | mActionLicence->plug( helpMenu ); | 2036 | mActionLicence->plug( helpMenu ); |
2035 | mActionFaq->plug( helpMenu ); | 2037 | mActionFaq->plug( helpMenu ); |
2036 | mActionAboutKAddressbook->plug( helpMenu ); | 2038 | mActionAboutKAddressbook->plug( helpMenu ); |
2037 | 2039 | ||
2038 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2040 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2039 | 2041 | ||
2040 | mActionSave->plug( tb ); | 2042 | mActionSave->plug( tb ); |
2041 | mViewManager->getFilterAction()->plug ( tb); | 2043 | mViewManager->getFilterAction()->plug ( tb); |
2042 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2044 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2043 | mActionUndo->plug( tb ); | 2045 | mActionUndo->plug( tb ); |
2044 | mActionDelete->plug( tb ); | 2046 | mActionDelete->plug( tb ); |
2045 | mActionRedo->plug( tb ); | 2047 | mActionRedo->plug( tb ); |
2046 | } | 2048 | } |
2049 | } else { | ||
2050 | if (KABPrefs::instance()->mMultipleViewsAtOnce ) | ||
2051 | mActionSave->plug( tb ); | ||
2047 | } | 2052 | } |
2048 | //mActionQuit->plug ( tb ); | 2053 | //mActionQuit->plug ( tb ); |
2049 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2054 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2050 | 2055 | ||
2051 | //US link the searchwidget first to this. | 2056 | //US link the searchwidget first to this. |
2052 | // The real linkage to the toolbar happens later. | 2057 | // The real linkage to the toolbar happens later. |
2053 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2058 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2054 | //US tb->insertItem( mIncSearchWidget ); | 2059 | //US tb->insertItem( mIncSearchWidget ); |
2055 | /*US | 2060 | /*US |
2056 | mIncSearchWidget = new IncSearchWidget( tb ); | 2061 | mIncSearchWidget = new IncSearchWidget( tb ); |
2057 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2062 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2058 | SLOT( incrementalSearch( const QString& ) ) ); | 2063 | SLOT( incrementalSearch( const QString& ) ) ); |
2059 | 2064 | ||
2060 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2065 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2061 | 2066 | ||
2062 | //US topLayout->addWidget( mJumpButtonBar ); | 2067 | //US topLayout->addWidget( mJumpButtonBar ); |
2063 | this->layout()->add( mJumpButtonBar ); | 2068 | this->layout()->add( mJumpButtonBar ); |
2064 | */ | 2069 | */ |
2065 | 2070 | ||
2066 | #endif //KAB_EMBEDDED | 2071 | #endif //KAB_EMBEDDED |
2067 | 2072 | ||
2068 | mActionExport2phone->plug( ExportMenu ); | 2073 | mActionExport2phone->plug( ExportMenu ); |
2069 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2074 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2070 | syncManager->fillSyncMenu(); | 2075 | syncManager->fillSyncMenu(); |
2071 | 2076 | ||
2072 | } | 2077 | } |
2073 | void KABCore::showLicence() | 2078 | void KABCore::showLicence() |
2074 | { | 2079 | { |
2075 | KApplication::showLicence(); | 2080 | KApplication::showLicence(); |
2076 | } | 2081 | } |
2077 | void KABCore::removeVoice() | 2082 | void KABCore::removeVoice() |
2078 | { | 2083 | { |
2079 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2084 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2080 | return; | 2085 | return; |
2081 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2086 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2082 | KABC::Addressee::List::Iterator it; | 2087 | KABC::Addressee::List::Iterator it; |
2083 | for ( it = list.begin(); it != list.end(); ++it ) { | 2088 | for ( it = list.begin(); it != list.end(); ++it ) { |
2084 | 2089 | ||
2085 | if ( (*it).removeVoice() ) | 2090 | if ( (*it).removeVoice() ) |
2086 | contactModified((*it) ); | 2091 | contactModified((*it) ); |
2087 | } | 2092 | } |
2088 | } | 2093 | } |
2089 | 2094 | ||
2090 | 2095 | ||
2091 | 2096 | ||
2092 | void KABCore::clipboardDataChanged() | 2097 | void KABCore::clipboardDataChanged() |
2093 | { | 2098 | { |
2094 | 2099 | ||
2095 | if ( mReadWrite ) | 2100 | if ( mReadWrite ) |
2096 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2101 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2097 | 2102 | ||
2098 | } | 2103 | } |
2099 | 2104 | ||
2100 | void KABCore::updateActionMenu() | 2105 | void KABCore::updateActionMenu() |
2101 | { | 2106 | { |
2102 | UndoStack *undo = UndoStack::instance(); | 2107 | UndoStack *undo = UndoStack::instance(); |
2103 | RedoStack *redo = RedoStack::instance(); | 2108 | RedoStack *redo = RedoStack::instance(); |
2104 | 2109 | ||
2105 | if ( undo->isEmpty() ) | 2110 | if ( undo->isEmpty() ) |
2106 | mActionUndo->setText( i18n( "Undo" ) ); | 2111 | mActionUndo->setText( i18n( "Undo" ) ); |
2107 | else | 2112 | else |
2108 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2113 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2109 | 2114 | ||
2110 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2115 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2111 | 2116 | ||
2112 | if ( !redo->top() ) | 2117 | if ( !redo->top() ) |
2113 | mActionRedo->setText( i18n( "Redo" ) ); | 2118 | mActionRedo->setText( i18n( "Redo" ) ); |
2114 | else | 2119 | else |
2115 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2120 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2116 | 2121 | ||
2117 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2122 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2118 | } | 2123 | } |
2119 | 2124 | ||
2120 | void KABCore::configureKeyBindings() | 2125 | void KABCore::configureKeyBindings() |
2121 | { | 2126 | { |
2122 | #ifndef KAB_EMBEDDED | 2127 | #ifndef KAB_EMBEDDED |
2123 | KKeyDialog::configure( actionCollection(), true ); | 2128 | KKeyDialog::configure( actionCollection(), true ); |
2124 | #else //KAB_EMBEDDED | 2129 | #else //KAB_EMBEDDED |
2125 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2130 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2126 | #endif //KAB_EMBEDDED | 2131 | #endif //KAB_EMBEDDED |
2127 | } | 2132 | } |
2128 | 2133 | ||
2129 | #ifdef KAB_EMBEDDED | 2134 | #ifdef KAB_EMBEDDED |
2130 | void KABCore::configureResources() | 2135 | void KABCore::configureResources() |
2131 | { | 2136 | { |
2132 | KRES::KCMKResources dlg( this, "" , 0 ); | 2137 | KRES::KCMKResources dlg( this, "" , 0 ); |
2133 | 2138 | ||
2134 | if ( !dlg.exec() ) | 2139 | if ( !dlg.exec() ) |
2135 | return; | 2140 | return; |
2136 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2141 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2137 | } | 2142 | } |
2138 | #endif //KAB_EMBEDDED | 2143 | #endif //KAB_EMBEDDED |
2139 | 2144 | ||
2140 | 2145 | ||
2141 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2146 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2142 | * for the attendees list of an event. | 2147 | * for the attendees list of an event. |
2143 | */ | 2148 | */ |
2144 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2149 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2145 | { | 2150 | { |
2146 | QStringList nameList; | 2151 | QStringList nameList; |
2147 | QStringList emailList; | 2152 | QStringList emailList; |
2148 | QStringList uidList; | 2153 | QStringList uidList; |
2149 | 2154 | ||
2150 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2155 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2151 | uint i=0; | 2156 | uint i=0; |
2152 | for (i=0; i < list.count(); i++) | 2157 | for (i=0; i < list.count(); i++) |
2153 | { | 2158 | { |
2154 | nameList.append(list[i].realName()); | 2159 | nameList.append(list[i].realName()); |
2155 | emailList.append(list[i].preferredEmail()); | 2160 | emailList.append(list[i].preferredEmail()); |
2156 | uidList.append(list[i].uid()); | 2161 | uidList.append(list[i].uid()); |
2157 | } | 2162 | } |
2158 | 2163 | ||
2159 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2164 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2160 | 2165 | ||
2161 | } | 2166 | } |
2162 | 2167 | ||
2163 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2168 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2164 | * to put them into the calendar. | 2169 | * to put them into the calendar. |
2165 | */ | 2170 | */ |
2166 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2171 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2167 | { | 2172 | { |
2168 | // qDebug("KABCore::requestForBirthdayList"); | 2173 | // qDebug("KABCore::requestForBirthdayList"); |
2169 | QStringList birthdayList; | 2174 | QStringList birthdayList; |
2170 | QStringList anniversaryList; | 2175 | QStringList anniversaryList; |
2171 | QStringList realNameList; | 2176 | QStringList realNameList; |
2172 | QStringList preferredEmailList; | 2177 | QStringList preferredEmailList; |
2173 | QStringList assembledNameList; | 2178 | QStringList assembledNameList; |
2174 | QStringList uidList; | 2179 | QStringList uidList; |
2175 | 2180 | ||
2176 | KABC::AddressBook::Iterator it; | 2181 | KABC::AddressBook::Iterator it; |
2177 | 2182 | ||
2178 | int count = 0; | 2183 | int count = 0; |
2179 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2184 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2180 | ++count; | 2185 | ++count; |
2181 | } | 2186 | } |
2182 | QProgressBar bar(count,0 ); | 2187 | QProgressBar bar(count,0 ); |
2183 | int w = 300; | 2188 | int w = 300; |
2184 | if ( QApplication::desktop()->width() < 320 ) | 2189 | if ( QApplication::desktop()->width() < 320 ) |
2185 | w = 220; | 2190 | w = 220; |
2186 | int h = bar.sizeHint().height() ; | 2191 | int h = bar.sizeHint().height() ; |
2187 | int dw = QApplication::desktop()->width(); | 2192 | int dw = QApplication::desktop()->width(); |
2188 | int dh = QApplication::desktop()->height(); | 2193 | int dh = QApplication::desktop()->height(); |
2189 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2194 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2190 | bar.show(); | 2195 | bar.show(); |
2191 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2196 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2192 | qApp->processEvents(); | 2197 | qApp->processEvents(); |
2193 | 2198 | ||
2194 | QDate bday; | 2199 | QDate bday; |
2195 | QString anni; | 2200 | QString anni; |
2196 | QString formattedbday; | 2201 | QString formattedbday; |
2197 | 2202 | ||
2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2203 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2199 | { | 2204 | { |
2200 | if ( ! bar.isVisible() ) | 2205 | if ( ! bar.isVisible() ) |
2201 | return; | 2206 | return; |
2202 | bar.setProgress( count++ ); | 2207 | bar.setProgress( count++ ); |
2203 | qApp->processEvents(); | 2208 | qApp->processEvents(); |
2204 | bday = (*it).birthday().date(); | 2209 | bday = (*it).birthday().date(); |
2205 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2210 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2206 | 2211 | ||
2207 | if ( bday.isValid() || !anni.isEmpty()) | 2212 | if ( bday.isValid() || !anni.isEmpty()) |
2208 | { | 2213 | { |
2209 | if (bday.isValid()) | 2214 | if (bday.isValid()) |
2210 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2215 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2211 | else | 2216 | else |
2212 | formattedbday = "NOTVALID"; | 2217 | formattedbday = "NOTVALID"; |
2213 | if (anni.isEmpty()) | 2218 | if (anni.isEmpty()) |
2214 | anni = "INVALID"; | 2219 | anni = "INVALID"; |
2215 | 2220 | ||
2216 | birthdayList.append(formattedbday); | 2221 | birthdayList.append(formattedbday); |
2217 | anniversaryList.append(anni); //should be ISODate | 2222 | anniversaryList.append(anni); //should be ISODate |
2218 | realNameList.append((*it).realName()); | 2223 | realNameList.append((*it).realName()); |
2219 | preferredEmailList.append((*it).preferredEmail()); | 2224 | preferredEmailList.append((*it).preferredEmail()); |
2220 | assembledNameList.append((*it).assembledName()); | 2225 | assembledNameList.append((*it).assembledName()); |
2221 | uidList.append((*it).uid()); | 2226 | uidList.append((*it).uid()); |
2222 | 2227 | ||
2223 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2228 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2224 | } | 2229 | } |
2225 | } | 2230 | } |
2226 | 2231 | ||
2227 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2232 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2228 | 2233 | ||
2229 | } | 2234 | } |
2230 | 2235 | ||
2231 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2236 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2232 | */ | 2237 | */ |
2233 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2238 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2234 | { | 2239 | { |
2235 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2240 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2236 | 2241 | ||
2237 | QString foundUid = QString::null; | 2242 | QString foundUid = QString::null; |
2238 | if ( ! uid.isEmpty() ) { | 2243 | if ( ! uid.isEmpty() ) { |
2239 | Addressee adrr = mAddressBook->findByUid( uid ); | 2244 | Addressee adrr = mAddressBook->findByUid( uid ); |
2240 | if ( !adrr.isEmpty() ) { | 2245 | if ( !adrr.isEmpty() ) { |
2241 | foundUid = uid; | 2246 | foundUid = uid; |
2242 | } | 2247 | } |
2243 | if ( email == "sendbacklist" ) { | 2248 | if ( email == "sendbacklist" ) { |
2244 | //qDebug("ssssssssssssssssssssssend "); | 2249 | //qDebug("ssssssssssssssssssssssend "); |
2245 | QStringList nameList; | 2250 | QStringList nameList; |
2246 | QStringList emailList; | 2251 | QStringList emailList; |
2247 | QStringList uidList; | 2252 | QStringList uidList; |
2248 | nameList.append(adrr.realName()); | 2253 | nameList.append(adrr.realName()); |
2249 | emailList = adrr.emails(); | 2254 | emailList = adrr.emails(); |
2250 | uidList.append( adrr.preferredEmail()); | 2255 | uidList.append( adrr.preferredEmail()); |
2251 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2256 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2252 | return; | 2257 | return; |
2253 | } | 2258 | } |
2254 | 2259 | ||
2255 | } | 2260 | } |
2256 | 2261 | ||
2257 | if ( email == "sendbacklist" ) | 2262 | if ( email == "sendbacklist" ) |
2258 | return; | 2263 | return; |
2259 | if (foundUid.isEmpty()) | 2264 | if (foundUid.isEmpty()) |
2260 | { | 2265 | { |
2261 | //find the uid of the person first | 2266 | //find the uid of the person first |
2262 | Addressee::List namelist; | 2267 | Addressee::List namelist; |
2263 | Addressee::List emaillist; | 2268 | Addressee::List emaillist; |
2264 | 2269 | ||
2265 | if (!name.isEmpty()) | 2270 | if (!name.isEmpty()) |
2266 | namelist = mAddressBook->findByName( name ); | 2271 | namelist = mAddressBook->findByName( name ); |
2267 | 2272 | ||
2268 | if (!email.isEmpty()) | 2273 | if (!email.isEmpty()) |
2269 | emaillist = mAddressBook->findByEmail( email ); | 2274 | emaillist = mAddressBook->findByEmail( email ); |
2270 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2275 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2271 | //check if we have a match in Namelist and Emaillist | 2276 | //check if we have a match in Namelist and Emaillist |
2272 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2277 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2273 | foundUid = emaillist[0].uid(); | 2278 | foundUid = emaillist[0].uid(); |
2274 | } | 2279 | } |
2275 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2280 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2276 | foundUid = namelist[0].uid(); | 2281 | foundUid = namelist[0].uid(); |
2277 | else | 2282 | else |
2278 | { | 2283 | { |
2279 | for (int i = 0; i < namelist.count(); i++) | 2284 | for (int i = 0; i < namelist.count(); i++) |
2280 | { | 2285 | { |
2281 | for (int j = 0; j < emaillist.count(); j++) | 2286 | for (int j = 0; j < emaillist.count(); j++) |
2282 | { | 2287 | { |
2283 | if (namelist[i] == emaillist[j]) | 2288 | if (namelist[i] == emaillist[j]) |
2284 | { | 2289 | { |
2285 | foundUid = namelist[i].uid(); | 2290 | foundUid = namelist[i].uid(); |
2286 | } | 2291 | } |
2287 | } | 2292 | } |
2288 | } | 2293 | } |
2289 | } | 2294 | } |
2290 | } | 2295 | } |
2291 | else | 2296 | else |
2292 | { | 2297 | { |
2293 | foundUid = uid; | 2298 | foundUid = uid; |
2294 | } | 2299 | } |
2295 | 2300 | ||
2296 | if (!foundUid.isEmpty()) | 2301 | if (!foundUid.isEmpty()) |
2297 | { | 2302 | { |
2298 | 2303 | ||
2299 | // raise Ka/Pi if it is in the background | 2304 | // raise Ka/Pi if it is in the background |
2300 | #ifndef DESKTOP_VERSION | 2305 | #ifndef DESKTOP_VERSION |
2301 | #ifndef KORG_NODCOP | 2306 | #ifndef KORG_NODCOP |
2302 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2307 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2303 | #endif | 2308 | #endif |
2304 | #endif | 2309 | #endif |
2305 | 2310 | ||
2306 | mMainWindow->showMaximized(); | 2311 | mMainWindow->showMaximized(); |
2307 | mMainWindow-> raise(); | 2312 | mMainWindow-> raise(); |
2308 | 2313 | ||
2309 | mViewManager->setSelected( "", false); | 2314 | mViewManager->setSelected( "", false); |
2310 | mViewManager->refreshView( "" ); | 2315 | mViewManager->refreshView( "" ); |
2311 | mViewManager->setSelected( foundUid, true ); | 2316 | mViewManager->setSelected( foundUid, true ); |
2312 | mViewManager->refreshView( foundUid ); | 2317 | mViewManager->refreshView( foundUid ); |
2313 | 2318 | ||
2314 | if ( !mMultipleViewsAtOnce ) | 2319 | if ( !mMultipleViewsAtOnce ) |
2315 | { | 2320 | { |
2316 | setDetailsVisible( true ); | 2321 | setDetailsVisible( true ); |
2317 | mActionDetails->setChecked(true); | 2322 | mActionDetails->setChecked(true); |
2318 | } | 2323 | } |
2319 | } | 2324 | } |
2320 | } | 2325 | } |
2321 | 2326 | ||
2322 | void KABCore::whatsnew() | 2327 | void KABCore::whatsnew() |
2323 | { | 2328 | { |
2324 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2329 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2325 | } | 2330 | } |
2326 | void KABCore::synchowto() | 2331 | void KABCore::synchowto() |
2327 | { | 2332 | { |
2328 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2333 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2329 | } | 2334 | } |
2330 | 2335 | ||
2331 | void KABCore::faq() | 2336 | void KABCore::faq() |
2332 | { | 2337 | { |
2333 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2338 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2334 | } | 2339 | } |
2335 | 2340 | ||
2336 | #include <libkcal/syncdefines.h> | 2341 | #include <libkcal/syncdefines.h> |
2337 | 2342 | ||
2338 | KABC::Addressee KABCore::getLastSyncAddressee() | 2343 | KABC::Addressee KABCore::getLastSyncAddressee() |
2339 | { | 2344 | { |
2340 | Addressee lse; | 2345 | Addressee lse; |
2341 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2346 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2342 | 2347 | ||
2343 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2348 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2344 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2349 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2345 | if (lse.isEmpty()) { | 2350 | if (lse.isEmpty()) { |
2346 | qDebug("Creating new last-syncAddressee "); | 2351 | qDebug("Creating new last-syncAddressee "); |
2347 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2352 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2348 | QString sum = ""; | 2353 | QString sum = ""; |
2349 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2354 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2350 | sum = "E: "; | 2355 | sum = "E: "; |
2351 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2356 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2352 | lse.setRevision( mLastAddressbookSync ); | 2357 | lse.setRevision( mLastAddressbookSync ); |
2353 | lse.setCategories( i18n("SyncEvent") ); | 2358 | lse.setCategories( i18n("SyncEvent") ); |
2354 | mAddressBook->insertAddressee( lse ); | 2359 | mAddressBook->insertAddressee( lse ); |
2355 | } | 2360 | } |
2356 | return lse; | 2361 | return lse; |
2357 | } | 2362 | } |
2358 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2363 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2359 | { | 2364 | { |
2360 | 2365 | ||
2361 | //void setZaurusId(int id); | 2366 | //void setZaurusId(int id); |
2362 | // int zaurusId() const; | 2367 | // int zaurusId() const; |
2363 | // void setZaurusUid(int id); | 2368 | // void setZaurusUid(int id); |
2364 | // int zaurusUid() const; | 2369 | // int zaurusUid() const; |
2365 | // void setZaurusStat(int id); | 2370 | // void setZaurusStat(int id); |
2366 | // int zaurusStat() const; | 2371 | // int zaurusStat() const; |
2367 | // 0 equal | 2372 | // 0 equal |
2368 | // 1 take local | 2373 | // 1 take local |
2369 | // 2 take remote | 2374 | // 2 take remote |
2370 | // 3 cancel | 2375 | // 3 cancel |
2371 | QDateTime lastSync = mLastAddressbookSync; | 2376 | QDateTime lastSync = mLastAddressbookSync; |
2372 | QDateTime localMod = local->revision(); | 2377 | QDateTime localMod = local->revision(); |
2373 | QDateTime remoteMod = remote->revision(); | 2378 | QDateTime remoteMod = remote->revision(); |
2374 | 2379 | ||
2375 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2380 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2376 | 2381 | ||
2377 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2382 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2378 | bool remCh, locCh; | 2383 | bool remCh, locCh; |
2379 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2384 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2380 | 2385 | ||
2381 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2386 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2382 | locCh = ( localMod > mLastAddressbookSync ); | 2387 | locCh = ( localMod > mLastAddressbookSync ); |
2383 | if ( !remCh && ! locCh ) { | 2388 | if ( !remCh && ! locCh ) { |
2384 | //qDebug("both not changed "); | 2389 | //qDebug("both not changed "); |
2385 | lastSync = localMod.addDays(1); | 2390 | lastSync = localMod.addDays(1); |
2386 | if ( mode <= SYNC_PREF_ASK ) | 2391 | if ( mode <= SYNC_PREF_ASK ) |
2387 | return 0; | 2392 | return 0; |
2388 | } else { | 2393 | } else { |
2389 | if ( locCh ) { | 2394 | if ( locCh ) { |
2390 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2395 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2391 | lastSync = localMod.addDays( -1 ); | 2396 | lastSync = localMod.addDays( -1 ); |
2392 | if ( !remCh ) | 2397 | if ( !remCh ) |
2393 | remoteMod =( lastSync.addDays( -1 ) ); | 2398 | remoteMod =( lastSync.addDays( -1 ) ); |
2394 | } else { | 2399 | } else { |
2395 | //qDebug(" not loc changed "); | 2400 | //qDebug(" not loc changed "); |
2396 | lastSync = localMod.addDays( 1 ); | 2401 | lastSync = localMod.addDays( 1 ); |
2397 | if ( remCh ) | 2402 | if ( remCh ) |
2398 | remoteMod =( lastSync.addDays( 1 ) ); | 2403 | remoteMod =( lastSync.addDays( 1 ) ); |
2399 | 2404 | ||
2400 | } | 2405 | } |
2401 | } | 2406 | } |
2402 | full = true; | 2407 | full = true; |
2403 | if ( mode < SYNC_PREF_ASK ) | 2408 | if ( mode < SYNC_PREF_ASK ) |
2404 | mode = SYNC_PREF_ASK; | 2409 | mode = SYNC_PREF_ASK; |
2405 | } else { | 2410 | } else { |
2406 | if ( localMod == remoteMod ) | 2411 | if ( localMod == remoteMod ) |
2407 | return 0; | 2412 | return 0; |
2408 | 2413 | ||
2409 | } | 2414 | } |
2410 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2415 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2411 | 2416 | ||
2412 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2417 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2413 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2418 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2414 | //full = true; //debug only | 2419 | //full = true; //debug only |
2415 | if ( full ) { | 2420 | if ( full ) { |
2416 | bool equ = ( (*local) == (*remote) ); | 2421 | bool equ = ( (*local) == (*remote) ); |
2417 | if ( equ ) { | 2422 | if ( equ ) { |
2418 | //qDebug("equal "); | 2423 | //qDebug("equal "); |
2419 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2424 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2420 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2425 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2421 | } | 2426 | } |
2422 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2427 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2423 | return 0; | 2428 | return 0; |
2424 | 2429 | ||
2425 | }//else //debug only | 2430 | }//else //debug only |
2426 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2431 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2427 | } | 2432 | } |
2428 | int result; | 2433 | int result; |
2429 | bool localIsNew; | 2434 | bool localIsNew; |
2430 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2435 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2431 | 2436 | ||
2432 | if ( full && mode < SYNC_PREF_NEWEST ) | 2437 | if ( full && mode < SYNC_PREF_NEWEST ) |
2433 | mode = SYNC_PREF_ASK; | 2438 | mode = SYNC_PREF_ASK; |
2434 | 2439 | ||
2435 | switch( mode ) { | 2440 | switch( mode ) { |
2436 | case SYNC_PREF_LOCAL: | 2441 | case SYNC_PREF_LOCAL: |
2437 | if ( lastSync > remoteMod ) | 2442 | if ( lastSync > remoteMod ) |
2438 | return 1; | 2443 | return 1; |
2439 | if ( lastSync > localMod ) | 2444 | if ( lastSync > localMod ) |
2440 | return 2; | 2445 | return 2; |
2441 | return 1; | 2446 | return 1; |
2442 | break; | 2447 | break; |
2443 | case SYNC_PREF_REMOTE: | 2448 | case SYNC_PREF_REMOTE: |
2444 | if ( lastSync > remoteMod ) | 2449 | if ( lastSync > remoteMod ) |
2445 | return 1; | 2450 | return 1; |
2446 | if ( lastSync > localMod ) | 2451 | if ( lastSync > localMod ) |
2447 | return 2; | 2452 | return 2; |
2448 | return 2; | 2453 | return 2; |
2449 | break; | 2454 | break; |
2450 | case SYNC_PREF_NEWEST: | 2455 | case SYNC_PREF_NEWEST: |
2451 | if ( localMod > remoteMod ) | 2456 | if ( localMod > remoteMod ) |
2452 | return 1; | 2457 | return 1; |
2453 | else | 2458 | else |
2454 | return 2; | 2459 | return 2; |
2455 | break; | 2460 | break; |
2456 | case SYNC_PREF_ASK: | 2461 | case SYNC_PREF_ASK: |
2457 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2462 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2458 | if ( lastSync > remoteMod ) | 2463 | if ( lastSync > remoteMod ) |
2459 | return 1; | 2464 | return 1; |
2460 | if ( lastSync > localMod ) | 2465 | if ( lastSync > localMod ) |
2461 | return 2; | 2466 | return 2; |
2462 | localIsNew = localMod >= remoteMod; | 2467 | localIsNew = localMod >= remoteMod; |
2463 | //qDebug("conflict! ************************************** "); | 2468 | //qDebug("conflict! ************************************** "); |
2464 | { | 2469 | { |
2465 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2470 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2466 | result = acd.executeD(localIsNew); | 2471 | result = acd.executeD(localIsNew); |
2467 | return result; | 2472 | return result; |
2468 | } | 2473 | } |
2469 | break; | 2474 | break; |
2470 | case SYNC_PREF_FORCE_LOCAL: | 2475 | case SYNC_PREF_FORCE_LOCAL: |
2471 | return 1; | 2476 | return 1; |
2472 | break; | 2477 | break; |
2473 | case SYNC_PREF_FORCE_REMOTE: | 2478 | case SYNC_PREF_FORCE_REMOTE: |
2474 | return 2; | 2479 | return 2; |
2475 | break; | 2480 | break; |
2476 | 2481 | ||
2477 | default: | 2482 | default: |
2478 | // SYNC_PREF_TAKE_BOTH not implemented | 2483 | // SYNC_PREF_TAKE_BOTH not implemented |
2479 | break; | 2484 | break; |
2480 | } | 2485 | } |
2481 | return 0; | 2486 | return 0; |
2482 | } | 2487 | } |
2483 | 2488 | ||
2484 | 2489 | ||
2485 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2490 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2486 | { | 2491 | { |
2487 | bool syncOK = true; | 2492 | bool syncOK = true; |
2488 | int addedAddressee = 0; | 2493 | int addedAddressee = 0; |
2489 | int addedAddresseeR = 0; | 2494 | int addedAddresseeR = 0; |
2490 | int deletedAddresseeR = 0; | 2495 | int deletedAddresseeR = 0; |
2491 | int deletedAddresseeL = 0; | 2496 | int deletedAddresseeL = 0; |
2492 | int changedLocal = 0; | 2497 | int changedLocal = 0; |
2493 | int changedRemote = 0; | 2498 | int changedRemote = 0; |
2494 | 2499 | ||
2495 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2500 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2496 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2501 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2497 | 2502 | ||
2498 | //QPtrList<Addressee> el = local->rawAddressees(); | 2503 | //QPtrList<Addressee> el = local->rawAddressees(); |
2499 | Addressee addresseeR; | 2504 | Addressee addresseeR; |
2500 | QString uid; | 2505 | QString uid; |
2501 | int take; | 2506 | int take; |
2502 | Addressee addresseeL; | 2507 | Addressee addresseeL; |
2503 | Addressee addresseeRSync; | 2508 | Addressee addresseeRSync; |
2504 | Addressee addresseeLSync; | 2509 | Addressee addresseeLSync; |
2505 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2510 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2506 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2511 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2507 | bool fullDateRange = false; | 2512 | bool fullDateRange = false; |
2508 | local->resetTempSyncStat(); | 2513 | local->resetTempSyncStat(); |
2509 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2514 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2510 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2515 | if ( syncManager->syncWithDesktop() ) { |
2516 | remote->removeSyncInfo( QString());//remove all info | ||
2517 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | ||
2518 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | ||
2519 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | ||
2520 | } else { | ||
2521 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); | ||
2522 | } | ||
2523 | } | ||
2524 | QDateTime modifiedCalendar = mLastAddressbookSync; | ||
2511 | addresseeLSync = getLastSyncAddressee(); | 2525 | addresseeLSync = getLastSyncAddressee(); |
2512 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2526 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2513 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2527 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2514 | if ( !addresseeR.isEmpty() ) { | 2528 | if ( !addresseeR.isEmpty() ) { |
2515 | addresseeRSync = addresseeR; | 2529 | addresseeRSync = addresseeR; |
2516 | remote->removeAddressee(addresseeR ); | 2530 | remote->removeAddressee(addresseeR ); |
2517 | 2531 | ||
2518 | } else { | 2532 | } else { |
2519 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2533 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2520 | addresseeRSync = addresseeLSync ; | 2534 | addresseeRSync = addresseeLSync ; |
2521 | } else { | 2535 | } else { |
2522 | qDebug("FULLDATE 1"); | 2536 | qDebug("FULLDATE 1"); |
2523 | fullDateRange = true; | 2537 | fullDateRange = true; |
2524 | Addressee newAdd; | 2538 | Addressee newAdd; |
2525 | addresseeRSync = newAdd; | 2539 | addresseeRSync = newAdd; |
2526 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2540 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2527 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2541 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2528 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2542 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2529 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2543 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2530 | } | 2544 | } |
2531 | } | 2545 | } |
2532 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2546 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2533 | qDebug("FULLDATE 2"); | 2547 | qDebug("FULLDATE 2"); |
2534 | fullDateRange = true; | 2548 | fullDateRange = true; |
2535 | } | 2549 | } |
2536 | if ( ! fullDateRange ) { | 2550 | if ( ! fullDateRange ) { |
2537 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2551 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2538 | 2552 | ||
2539 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2553 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2540 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2554 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2541 | fullDateRange = true; | 2555 | fullDateRange = true; |
2542 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2556 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2543 | } | 2557 | } |
2544 | } | 2558 | } |
2545 | // fullDateRange = true; // debug only! | 2559 | // fullDateRange = true; // debug only! |
2546 | if ( fullDateRange ) | 2560 | if ( fullDateRange ) |
2547 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2561 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2548 | else | 2562 | else |
2549 | mLastAddressbookSync = addresseeLSync.revision(); | 2563 | mLastAddressbookSync = addresseeLSync.revision(); |
2550 | // for resyncing if own file has changed | 2564 | // for resyncing if own file has changed |
2551 | // PENDING fixme later when implemented | 2565 | // PENDING fixme later when implemented |
2552 | #if 0 | 2566 | #if 0 |
2553 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2567 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2554 | mLastAddressbookSync = loadedFileVersion; | 2568 | mLastAddressbookSync = loadedFileVersion; |
2555 | qDebug("setting mLastAddressbookSync "); | 2569 | qDebug("setting mLastAddressbookSync "); |
2556 | } | 2570 | } |
2557 | #endif | 2571 | #endif |
2558 | 2572 | ||
2559 | //qDebug("*************************** "); | 2573 | //qDebug("*************************** "); |
2560 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2574 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2561 | QStringList er = remote->uidList(); | 2575 | QStringList er = remote->uidList(); |
2562 | Addressee inR ;//= er.first(); | 2576 | Addressee inR ;//= er.first(); |
2563 | Addressee inL; | 2577 | Addressee inL; |
2564 | 2578 | ||
2565 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2579 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2566 | 2580 | ||
2567 | int modulo = (er.count()/10)+1; | 2581 | int modulo = (er.count()/10)+1; |
2568 | int incCounter = 0; | 2582 | int incCounter = 0; |
2569 | while ( incCounter < er.count()) { | 2583 | while ( incCounter < er.count()) { |
2570 | if (syncManager->isProgressBarCanceled()) | 2584 | if (syncManager->isProgressBarCanceled()) |
2571 | return false; | 2585 | return false; |
2572 | if ( incCounter % modulo == 0 ) | 2586 | if ( incCounter % modulo == 0 ) |
2573 | syncManager->showProgressBar(incCounter); | 2587 | syncManager->showProgressBar(incCounter); |
2574 | 2588 | ||
2575 | uid = er[ incCounter ]; | 2589 | uid = er[ incCounter ]; |
2576 | bool skipIncidence = false; | 2590 | bool skipIncidence = false; |
2577 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2591 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2578 | skipIncidence = true; | 2592 | skipIncidence = true; |
2579 | QString idS,OidS; | 2593 | QString idS,OidS; |
2580 | qApp->processEvents(); | 2594 | qApp->processEvents(); |
2581 | if ( !skipIncidence ) { | 2595 | if ( !skipIncidence ) { |
2582 | inL = local->findByUid( uid ); | 2596 | inL = local->findByUid( uid ); |
2583 | inR = remote->findByUid( uid ); | 2597 | inR = remote->findByUid( uid ); |
2584 | //inL.setResource( 0 ); | 2598 | //inL.setResource( 0 ); |
2585 | //inR.setResource( 0 ); | 2599 | //inR.setResource( 0 ); |
2586 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2600 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2587 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2601 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2588 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2602 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2589 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2603 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2590 | if ( take == 3 ) | 2604 | if ( take == 3 ) |
2591 | return false; | 2605 | return false; |
2592 | if ( take == 1 ) {// take local | 2606 | if ( take == 1 ) {// take local |
2593 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2607 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2594 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2608 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2595 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2609 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2596 | local->insertAddressee( inL, false ); | 2610 | local->insertAddressee( inL, false ); |
2597 | idS = inR.externalUID(); | 2611 | idS = inR.externalUID(); |
2598 | OidS = inR.originalExternalUID(); | 2612 | OidS = inR.originalExternalUID(); |
2599 | } | 2613 | } |
2600 | else | 2614 | else |
2601 | idS = inR.IDStr(); | 2615 | idS = inR.IDStr(); |
2602 | remote->removeAddressee( inR ); | 2616 | remote->removeAddressee( inR ); |
2603 | inR = inL; | 2617 | inR = inL; |
2604 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2618 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2605 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2619 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2606 | inR.setOriginalExternalUID( OidS ); | 2620 | inR.setOriginalExternalUID( OidS ); |
2607 | inR.setExternalUID( idS ); | 2621 | inR.setExternalUID( idS ); |
2622 | if ( syncManager->syncWithDesktop() ) | ||
2623 | inR.setIDStr( "changed" ); | ||
2608 | } else { | 2624 | } else { |
2609 | inR.setIDStr( idS ); | 2625 | inR.setIDStr( idS ); |
2610 | } | 2626 | } |
2611 | inR.setResource( 0 ); | 2627 | inR.setResource( 0 ); |
2612 | remote->insertAddressee( inR , false); | 2628 | remote->insertAddressee( inR , false); |
2613 | ++changedRemote; | 2629 | ++changedRemote; |
2614 | } else { // take == 2 take remote | 2630 | } else { // take == 2 take remote |
2615 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2631 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2616 | if ( inR.revision().date().year() < 2004 ) | 2632 | if ( inR.revision().date().year() < 2004 ) |
2617 | inR.setRevision( modifiedCalendar ); | 2633 | inR.setRevision( modifiedCalendar ); |
2618 | } | 2634 | } |
2619 | idS = inL.IDStr(); | 2635 | idS = inL.IDStr(); |
2620 | local->removeAddressee( inL ); | 2636 | local->removeAddressee( inL ); |
2621 | inL = inR; | 2637 | inL = inR; |
2622 | inL.setIDStr( idS ); | 2638 | inL.setIDStr( idS ); |
2623 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2639 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2624 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2640 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2625 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2641 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2626 | } | 2642 | } |
2627 | inL.setResource( 0 ); | 2643 | inL.setResource( 0 ); |
2628 | local->insertAddressee( inL , false ); | 2644 | local->insertAddressee( inL , false ); |
2629 | ++changedLocal; | 2645 | ++changedLocal; |
2630 | } | 2646 | } |
2631 | } | 2647 | } |
2632 | } | 2648 | } |
2633 | } else { // no conflict | 2649 | } else { // no conflict |
2634 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2650 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2635 | QString des = addresseeLSync.note(); | 2651 | QString des = addresseeLSync.note(); |
2636 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2652 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2637 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2653 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2638 | remote->insertAddressee( inR, false ); | 2654 | remote->insertAddressee( inR, false ); |
2639 | ++deletedAddresseeR; | 2655 | ++deletedAddresseeR; |
2640 | } else { | 2656 | } else { |
2641 | inR.setRevision( modifiedCalendar ); | 2657 | inR.setRevision( modifiedCalendar ); |
2642 | remote->insertAddressee( inR, false ); | 2658 | remote->insertAddressee( inR, false ); |
2643 | inL = inR; | 2659 | inL = inR; |
2644 | inL.setResource( 0 ); | 2660 | inL.setResource( 0 ); |
2645 | local->insertAddressee( inL , false); | 2661 | local->insertAddressee( inL , false); |
2646 | ++addedAddressee; | 2662 | ++addedAddressee; |
2647 | } | 2663 | } |
2648 | } else { | 2664 | } else { |
2649 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2665 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2650 | inR.setRevision( modifiedCalendar ); | 2666 | inR.setRevision( modifiedCalendar ); |
2651 | remote->insertAddressee( inR, false ); | 2667 | remote->insertAddressee( inR, false ); |
2652 | inR.setResource( 0 ); | 2668 | inR.setResource( 0 ); |
2653 | local->insertAddressee( inR, false ); | 2669 | local->insertAddressee( inR, false ); |
2654 | ++addedAddressee; | 2670 | ++addedAddressee; |
2655 | } else { | 2671 | } else { |
2656 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2672 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2657 | remote->removeAddressee( inR ); | 2673 | remote->removeAddressee( inR ); |
2658 | ++deletedAddresseeR; | 2674 | ++deletedAddresseeR; |
2659 | } | 2675 | } |
2660 | } | 2676 | } |
2661 | } | 2677 | } |
2662 | } | 2678 | } |
2663 | ++incCounter; | 2679 | ++incCounter; |
2664 | } | 2680 | } |
2665 | er.clear(); | 2681 | er.clear(); |
2666 | QStringList el = local->uidList(); | 2682 | QStringList el = local->uidList(); |
2667 | modulo = (el.count()/10)+1; | 2683 | modulo = (el.count()/10)+1; |
2668 | 2684 | ||
2669 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2685 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2670 | incCounter = 0; | 2686 | incCounter = 0; |
2671 | while ( incCounter < el.count()) { | 2687 | while ( incCounter < el.count()) { |
2672 | qApp->processEvents(); | 2688 | qApp->processEvents(); |
2673 | if (syncManager->isProgressBarCanceled()) | 2689 | if (syncManager->isProgressBarCanceled()) |
2674 | return false; | 2690 | return false; |
2675 | if ( incCounter % modulo == 0 ) | 2691 | if ( incCounter % modulo == 0 ) |
2676 | syncManager->showProgressBar(incCounter); | 2692 | syncManager->showProgressBar(incCounter); |
2677 | uid = el[ incCounter ]; | 2693 | uid = el[ incCounter ]; |
2678 | bool skipIncidence = false; | 2694 | bool skipIncidence = false; |
2679 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2695 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2680 | skipIncidence = true; | 2696 | skipIncidence = true; |
2681 | if ( !skipIncidence ) { | 2697 | if ( !skipIncidence ) { |
2682 | inL = local->findByUid( uid ); | 2698 | inL = local->findByUid( uid ); |
2683 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2699 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2684 | inR = remote->findByUid( uid ); | 2700 | inR = remote->findByUid( uid ); |
2685 | if ( inR.isEmpty() ) { | 2701 | if ( inR.isEmpty() ) { |
2686 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2702 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2687 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2703 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2688 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2704 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2689 | local->removeAddressee( inL ); | 2705 | local->removeAddressee( inL ); |
2690 | ++deletedAddresseeL; | 2706 | ++deletedAddresseeL; |
2691 | } else { | 2707 | } else { |
2692 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2708 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2693 | inL.removeID(mCurrentSyncDevice ); | 2709 | inL.removeID(mCurrentSyncDevice ); |
2694 | ++addedAddresseeR; | 2710 | ++addedAddresseeR; |
2695 | inL.setRevision( modifiedCalendar ); | 2711 | inL.setRevision( modifiedCalendar ); |
2696 | local->insertAddressee( inL, false ); | 2712 | local->insertAddressee( inL, false ); |
2697 | inR = inL; | 2713 | inR = inL; |
2698 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2714 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2699 | inR.setResource( 0 ); | 2715 | inR.setResource( 0 ); |
2700 | remote->insertAddressee( inR, false ); | 2716 | remote->insertAddressee( inR, false ); |
2701 | } | 2717 | } |
2702 | } | 2718 | } |
2703 | } else { | 2719 | } else { |
2704 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2720 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2705 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2721 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2706 | local->removeAddressee( inL ); | 2722 | local->removeAddressee( inL ); |
2707 | ++deletedAddresseeL; | 2723 | ++deletedAddresseeL; |
2708 | } else { | 2724 | } else { |
2709 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2725 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2710 | ++addedAddresseeR; | 2726 | ++addedAddresseeR; |
2711 | inL.setRevision( modifiedCalendar ); | 2727 | inL.setRevision( modifiedCalendar ); |
2712 | local->insertAddressee( inL, false ); | 2728 | local->insertAddressee( inL, false ); |
2713 | inR = inL; | 2729 | inR = inL; |
2714 | inR.setResource( 0 ); | 2730 | inR.setResource( 0 ); |
2715 | remote->insertAddressee( inR, false ); | 2731 | remote->insertAddressee( inR, false ); |
2716 | } | 2732 | } |
2717 | } | 2733 | } |
2718 | } | 2734 | } |
2719 | } | 2735 | } |
2720 | } | 2736 | } |
2721 | } | 2737 | } |
2722 | ++incCounter; | 2738 | ++incCounter; |
2723 | } | 2739 | } |
2724 | el.clear(); | 2740 | el.clear(); |
2725 | syncManager->hideProgressBar(); | 2741 | syncManager->hideProgressBar(); |
2726 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2742 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2727 | // get rid of micro seconds | 2743 | // get rid of micro seconds |
2728 | QTime t = mLastAddressbookSync.time(); | 2744 | QTime t = mLastAddressbookSync.time(); |
2729 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2745 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2730 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2746 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2731 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2747 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2732 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2748 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2733 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2749 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2734 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2750 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2735 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2751 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2736 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2752 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2737 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2753 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2738 | addresseeRSync.setNote( "" ) ; | 2754 | addresseeRSync.setNote( "" ) ; |
2739 | addresseeLSync.setNote( "" ); | 2755 | addresseeLSync.setNote( "" ); |
2740 | 2756 | ||
2741 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2757 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2742 | remote->insertAddressee( addresseeRSync, false ); | 2758 | remote->insertAddressee( addresseeRSync, false ); |
2743 | local->insertAddressee( addresseeLSync, false ); | 2759 | local->insertAddressee( addresseeLSync, false ); |
2744 | QString mes; | 2760 | QString mes; |
2745 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2761 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2746 | if ( syncManager->mShowSyncSummary ) { | 2762 | if ( syncManager->mShowSyncSummary ) { |
2747 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2763 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2748 | } | 2764 | } |
2749 | qDebug( mes ); | 2765 | qDebug( mes ); |
2750 | return syncOK; | 2766 | return syncOK; |
2751 | } | 2767 | } |
2752 | 2768 | ||
2753 | 2769 | ||
2754 | //this is a overwritten callbackmethods from the syncinterface | 2770 | //this is a overwritten callbackmethods from the syncinterface |
2755 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2771 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2756 | { | 2772 | { |
2757 | 2773 | ||
2758 | //pending prepare addresseeview for output | 2774 | //pending prepare addresseeview for output |
2759 | //pending detect, if remote file has REV field. if not switch to external sync | 2775 | //pending detect, if remote file has REV field. if not switch to external sync |
2760 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2776 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2761 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2777 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2762 | 2778 | ||
2763 | AddressBook abLocal(filename,"syncContact"); | 2779 | AddressBook abLocal(filename,"syncContact"); |
2764 | bool syncOK = false; | 2780 | bool syncOK = false; |
2765 | if ( abLocal.load() ) { | 2781 | if ( abLocal.load() ) { |
2766 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2782 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2767 | bool external = false; | 2783 | bool external = false; |
2768 | bool isXML = false; | 2784 | bool isXML = false; |
2769 | if ( filename.right(4) == ".xml") { | 2785 | if ( filename.right(4) == ".xml") { |
2770 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2786 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2771 | isXML = true; | 2787 | isXML = true; |
2772 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2788 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2773 | } else { | 2789 | } else { |
2774 | external = !manager->mIsKapiFile; | 2790 | external = !manager->mIsKapiFile; |
2775 | if ( external ) { | 2791 | if ( external ) { |
2776 | qDebug("Setting vcf mode to external "); | 2792 | qDebug("Setting vcf mode to external "); |
2777 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2793 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2778 | AddressBook::Iterator it; | 2794 | AddressBook::Iterator it; |
2779 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2795 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2780 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2796 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2781 | (*it).computeCsum( mCurrentSyncDevice ); | 2797 | (*it).computeCsum( mCurrentSyncDevice ); |
2782 | } | 2798 | } |
2783 | } | 2799 | } |
2784 | } | 2800 | } |
2785 | //AddressBook::Iterator it; | 2801 | //AddressBook::Iterator it; |
2786 | //QStringList vcards; | 2802 | //QStringList vcards; |
2787 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2803 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2788 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2804 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2789 | //} | 2805 | //} |
2790 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2806 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2791 | if ( syncOK ) { | 2807 | if ( syncOK ) { |
2792 | if ( syncManager->mWriteBackFile ) | 2808 | if ( syncManager->mWriteBackFile ) |
2793 | { | 2809 | { |
2794 | if ( external ) | 2810 | if ( external ) |
2795 | abLocal.removeSyncAddressees( !isXML); | 2811 | abLocal.removeSyncAddressees( !isXML); |
2796 | qDebug("Saving remote AB "); | 2812 | qDebug("Saving remote AB "); |
2797 | if ( ! abLocal.saveAB()) | 2813 | if ( ! abLocal.saveAB()) |
2798 | qDebug("Error writing back AB to file "); | 2814 | qDebug("Error writing back AB to file "); |
2799 | if ( isXML ) { | 2815 | if ( isXML ) { |
2800 | // afterwrite processing | 2816 | // afterwrite processing |
2801 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2817 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2802 | } | 2818 | } |
2803 | } | 2819 | } |
2804 | } | 2820 | } |
2805 | setModified(); | 2821 | setModified(); |
2806 | 2822 | ||
2807 | } | 2823 | } |
2808 | if ( syncOK ) | 2824 | if ( syncOK ) |
2809 | mViewManager->refreshView(); | 2825 | mViewManager->refreshView(); |
2810 | return syncOK; | 2826 | return syncOK; |
2811 | 2827 | ||
2812 | } | 2828 | } |
2813 | void KABCore::removeSyncInfo( QString syncProfile) | 2829 | void KABCore::removeSyncInfo( QString syncProfile) |
2814 | { | 2830 | { |
2815 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 2831 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
2816 | mAddressBook->removeSyncInfo( syncProfile ); | 2832 | mAddressBook->removeSyncInfo( syncProfile ); |
2817 | } | 2833 | } |
2818 | 2834 | ||
2819 | 2835 | ||
2820 | //this is a overwritten callbackmethods from the syncinterface | 2836 | //this is a overwritten callbackmethods from the syncinterface |
2821 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2837 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2822 | { | 2838 | { |
2823 | if ( resource == "phone" ) | 2839 | if ( resource == "phone" ) |
2824 | return syncPhone(); | 2840 | return syncPhone(); |
2825 | disableBR( true ); | 2841 | disableBR( true ); |
2826 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2842 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2827 | 2843 | ||
2828 | AddressBook abLocal( resource,"syncContact"); | 2844 | AddressBook abLocal( resource,"syncContact"); |
2829 | bool syncOK = false; | 2845 | bool syncOK = false; |
2830 | if ( abLocal.load() ) { | 2846 | if ( abLocal.load() ) { |
2831 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2847 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2832 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2848 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2833 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2849 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2834 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2850 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2835 | if ( syncOK ) { | 2851 | if ( syncOK ) { |
2836 | if ( syncManager->mWriteBackFile ) { | 2852 | if ( syncManager->mWriteBackFile ) { |
2837 | abLocal.removeSyncAddressees( false ); | 2853 | abLocal.removeSyncAddressees( false ); |
2838 | abLocal.saveAB(); | 2854 | abLocal.saveAB(); |
2839 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2855 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2840 | } | 2856 | } |
2841 | } | 2857 | } |
2842 | setModified(); | 2858 | setModified(); |
2843 | } | 2859 | } |
2844 | if ( syncOK ) | 2860 | if ( syncOK ) |
2845 | mViewManager->refreshView(); | 2861 | mViewManager->refreshView(); |
2846 | disableBR( false ); | 2862 | disableBR( false ); |
2847 | return syncOK; | 2863 | return syncOK; |
2848 | 2864 | ||
2849 | } | 2865 | } |
2850 | void KABCore::message( QString m ) | 2866 | void KABCore::message( QString m ) |
2851 | { | 2867 | { |
2852 | topLevelWidget()->setCaption( m ); | 2868 | topLevelWidget()->setCaption( m ); |
2853 | mMessageTimer->start( 15000, true ); | 2869 | mMessageTimer->start( 15000, true ); |
2854 | } | 2870 | } |
2855 | bool KABCore::syncPhone() | 2871 | bool KABCore::syncPhone() |
2856 | { | 2872 | { |
2857 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2873 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2858 | QString fileName = getPhoneFile(); | 2874 | QString fileName = getPhoneFile(); |
2859 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2875 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2860 | message(i18n("Phone access failed!")); | 2876 | message(i18n("Phone access failed!")); |
2861 | return false; | 2877 | return false; |
2862 | } | 2878 | } |
2863 | AddressBook abLocal( fileName,"syncContact"); | 2879 | AddressBook abLocal( fileName,"syncContact"); |
2864 | bool syncOK = false; | 2880 | bool syncOK = false; |
2865 | { | 2881 | { |
2866 | abLocal.importFromFile( fileName ); | 2882 | abLocal.importFromFile( fileName ); |
2867 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2883 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2868 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2884 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2869 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2885 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2870 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2886 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2871 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2887 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2872 | if ( syncOK ) { | 2888 | if ( syncOK ) { |
2873 | if ( syncManager->mWriteBackFile ) { | 2889 | if ( syncManager->mWriteBackFile ) { |
2874 | abLocal.removeSyncAddressees( true ); | 2890 | abLocal.removeSyncAddressees( true ); |
2875 | abLocal.saveABphone( fileName ); | 2891 | abLocal.saveABphone( fileName ); |
2876 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2892 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2877 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2893 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2878 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2894 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2879 | } | 2895 | } |
2880 | } | 2896 | } |
2881 | setModified(); | 2897 | setModified(); |
2882 | } | 2898 | } |
2883 | if ( syncOK ) | 2899 | if ( syncOK ) |
2884 | mViewManager->refreshView(); | 2900 | mViewManager->refreshView(); |
2885 | return syncOK; | 2901 | return syncOK; |
2886 | } | 2902 | } |
2887 | void KABCore::getFile( bool success ) | 2903 | void KABCore::getFile( bool success ) |
2888 | { | 2904 | { |
2889 | if ( ! success ) { | 2905 | if ( ! success ) { |
2890 | message( i18n("Error receiving file. Nothing changed!") ); | 2906 | message( i18n("Error receiving file. Nothing changed!") ); |
2891 | return; | 2907 | return; |
2892 | } | 2908 | } |
2893 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2909 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2894 | if ( count ) | 2910 | if ( count ) |
2895 | setModified( true ); | 2911 | setModified( true ); |
2896 | message( i18n("Pi-Sync successful!") ); | 2912 | message( i18n("Pi-Sync successful!") ); |
2897 | mViewManager->refreshView(); | 2913 | mViewManager->refreshView(); |
2898 | } | 2914 | } |
2899 | void KABCore::syncFileRequest() | 2915 | void KABCore::syncFileRequest() |
2900 | { | 2916 | { |
2917 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | ||
2918 | syncManager->slotSyncMenu( 999 ); | ||
2919 | } | ||
2901 | mAddressBook->export2File( sentSyncFile() ); | 2920 | mAddressBook->export2File( sentSyncFile() ); |
2902 | } | 2921 | } |
2903 | QString KABCore::sentSyncFile() | 2922 | QString KABCore::sentSyncFile() |
2904 | { | 2923 | { |
2905 | #ifdef DESKTOP_VERSION | 2924 | #ifdef DESKTOP_VERSION |
2906 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2925 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2907 | #else | 2926 | #else |
2908 | return QString( "/tmp/copysyncab.vcf" ); | 2927 | return QString( "/tmp/copysyncab.vcf" ); |
2909 | #endif | 2928 | #endif |
2910 | } | 2929 | } |
2911 | 2930 | ||
2912 | void KABCore::setCaptionBack() | 2931 | void KABCore::setCaptionBack() |
2913 | { | 2932 | { |
2914 | mMessageTimer->stop(); | 2933 | mMessageTimer->stop(); |
2915 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2934 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2916 | } | 2935 | } |
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index f4fb08b..81e0d99 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -47,512 +47,517 @@ $Id$ | |||
47 | #include "views/kaddressbooktableview.h" | 47 | #include "views/kaddressbooktableview.h" |
48 | #include "views/kaddressbookcardview.h" | 48 | #include "views/kaddressbookcardview.h" |
49 | #include "kaddressbookview.h" | 49 | #include "kaddressbookview.h" |
50 | 50 | ||
51 | #include <qaction.h> | 51 | #include <qaction.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
54 | #include <kconfigbase.h> | 54 | #include <kconfigbase.h> |
55 | 55 | ||
56 | #endif //KAB_EMBEDDED | 56 | #endif //KAB_EMBEDDED |
57 | 57 | ||
58 | 58 | ||
59 | #include <kdebug.h> | 59 | #include <kdebug.h> |
60 | #include <kactionclasses.h> | 60 | #include <kactionclasses.h> |
61 | 61 | ||
62 | #include <qlayout.h> | 62 | #include <qlayout.h> |
63 | #include <qwidgetstack.h> | 63 | #include <qwidgetstack.h> |
64 | 64 | ||
65 | #include <kabc/addressbook.h> | 65 | #include <kabc/addressbook.h> |
66 | #include "filtereditdialog.h" | 66 | #include "filtereditdialog.h" |
67 | #include "addviewdialog.h" | 67 | #include "addviewdialog.h" |
68 | #include "kabcore.h" | 68 | #include "kabcore.h" |
69 | #include "kabprefs.h" | 69 | #include "kabprefs.h" |
70 | #include "viewmanager.h" | 70 | #include "viewmanager.h" |
71 | 71 | ||
72 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) | 72 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) |
73 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) | 73 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) |
74 | { | 74 | { |
75 | initGUI(); | 75 | initGUI(); |
76 | initActions(); | 76 | initActions(); |
77 | 77 | ||
78 | mViewDict.setAutoDelete( true ); | 78 | mViewDict.setAutoDelete( true ); |
79 | 79 | ||
80 | createViewFactories(); | 80 | createViewFactories(); |
81 | } | 81 | } |
82 | 82 | ||
83 | ViewManager::~ViewManager() | 83 | ViewManager::~ViewManager() |
84 | { | 84 | { |
85 | unloadViews(); | 85 | unloadViews(); |
86 | mViewFactoryDict.clear(); | 86 | mViewFactoryDict.clear(); |
87 | } | 87 | } |
88 | void ViewManager::scrollUP() | 88 | void ViewManager::scrollUP() |
89 | { | 89 | { |
90 | if ( mActiveView ) | 90 | if ( mActiveView ) |
91 | mActiveView->scrollUP(); | 91 | mActiveView->scrollUP(); |
92 | } | 92 | } |
93 | void ViewManager::scrollDOWN() | 93 | void ViewManager::scrollDOWN() |
94 | { | 94 | { |
95 | if ( mActiveView ) | 95 | if ( mActiveView ) |
96 | mActiveView->scrollDOWN(); | 96 | mActiveView->scrollDOWN(); |
97 | } | 97 | } |
98 | void ViewManager::restoreSettings() | 98 | void ViewManager::restoreSettings() |
99 | { | 99 | { |
100 | mViewNameList = KABPrefs::instance()->mViewNames; | 100 | mViewNameList = KABPrefs::instance()->mViewNames; |
101 | QString activeViewName = KABPrefs::instance()->mCurrentView; | 101 | QString activeViewName = KABPrefs::instance()->mCurrentView; |
102 | 102 | ||
103 | mActionSelectView->setItems( mViewNameList ); | 103 | mActionSelectView->setItems( mViewNameList ); |
104 | 104 | ||
105 | // Filter | 105 | // Filter |
106 | mFilterList = Filter::restore( mCore->config(), "Filter" ); | 106 | mFilterList = Filter::restore( mCore->config(), "Filter" ); |
107 | mActionSelectFilter->setItems( filterNames() ); | 107 | mActionSelectFilter->setItems( filterNames() ); |
108 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); | 108 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); |
109 | 109 | ||
110 | // Tell the views to reread their config, since they may have | 110 | // Tell the views to reread their config, since they may have |
111 | // been modified by global settings | 111 | // been modified by global settings |
112 | QString _oldgroup = mCore->config()->group(); | 112 | QString _oldgroup = mCore->config()->group(); |
113 | 113 | ||
114 | QDictIterator<KAddressBookView> it( mViewDict ); | 114 | QDictIterator<KAddressBookView> it( mViewDict ); |
115 | for ( it.toFirst(); it.current(); ++it ) { | 115 | for ( it.toFirst(); it.current(); ++it ) { |
116 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 116 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
117 | it.current()->readConfig( mCore->config() ); | 117 | it.current()->readConfig( mCore->config() ); |
118 | } | 118 | } |
119 | setActiveView( activeViewName ); | 119 | setActiveView( activeViewName ); |
120 | 120 | ||
121 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 121 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
122 | } | 122 | } |
123 | 123 | ||
124 | void ViewManager::saveSettings() | 124 | void ViewManager::saveSettings() |
125 | { | 125 | { |
126 | QString _oldgroup = mCore->config()->group(); | 126 | QString _oldgroup = mCore->config()->group(); |
127 | 127 | ||
128 | QDictIterator<KAddressBookView> it( mViewDict ); | 128 | QDictIterator<KAddressBookView> it( mViewDict ); |
129 | for ( it.toFirst(); it.current(); ++it ) { | 129 | for ( it.toFirst(); it.current(); ++it ) { |
130 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 130 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | (*it)->writeConfig( mCore->config() ); | 132 | (*it)->writeConfig( mCore->config() ); |
133 | #else | 133 | #else |
134 | (*it).writeConfig( mCore->config() ); | 134 | (*it).writeConfig( mCore->config() ); |
135 | #endif | 135 | #endif |
136 | } | 136 | } |
137 | 137 | ||
138 | Filter::save( mCore->config(), "Filter", mFilterList ); | 138 | Filter::save( mCore->config(), "Filter", mFilterList ); |
139 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); | 139 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); |
140 | 140 | ||
141 | // write the view name list | 141 | // write the view name list |
142 | KABPrefs::instance()->mViewNames = mViewNameList; | 142 | KABPrefs::instance()->mViewNames = mViewNameList; |
143 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); | 143 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); |
144 | 144 | ||
145 | } | 145 | } |
146 | 146 | ||
147 | QStringList ViewManager::selectedUids() const | 147 | QStringList ViewManager::selectedUids() const |
148 | { | 148 | { |
149 | if ( mActiveView ) | 149 | if ( mActiveView ) |
150 | return mActiveView->selectedUids(); | 150 | return mActiveView->selectedUids(); |
151 | else | 151 | else |
152 | return QStringList(); | 152 | return QStringList(); |
153 | } | 153 | } |
154 | 154 | ||
155 | QStringList ViewManager::selectedEmails() const | 155 | QStringList ViewManager::selectedEmails() const |
156 | { | 156 | { |
157 | if ( mActiveView ) | 157 | if ( mActiveView ) |
158 | return mActiveView->selectedEmails(); | 158 | return mActiveView->selectedEmails(); |
159 | else | 159 | else |
160 | return QStringList(); | 160 | return QStringList(); |
161 | } | 161 | } |
162 | 162 | ||
163 | KABC::Addressee::List ViewManager::selectedAddressees() const | 163 | KABC::Addressee::List ViewManager::selectedAddressees() const |
164 | { | 164 | { |
165 | KABC::Addressee::List list; | 165 | KABC::Addressee::List list; |
166 | if ( mActiveView ) { | 166 | if ( mActiveView ) { |
167 | QStringList uids = mActiveView->selectedUids(); | 167 | QStringList uids = mActiveView->selectedUids(); |
168 | QStringList::Iterator it; | 168 | QStringList::Iterator it; |
169 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 169 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
170 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); | 170 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); |
171 | if ( !addr.isEmpty() ) | 171 | if ( !addr.isEmpty() ) |
172 | list.append( addr ); | 172 | list.append( addr ); |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | return list; | 176 | return list; |
177 | } | 177 | } |
178 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 178 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
179 | void ViewManager::setSelected() | 179 | void ViewManager::setSelected() |
180 | { | 180 | { |
181 | setSelected( QString::null, true ); | 181 | setSelected( QString::null, true ); |
182 | } | 182 | } |
183 | 183 | ||
184 | void ViewManager::setSelected( const QString &uid, bool selected ) | 184 | void ViewManager::setSelected( const QString &uid, bool selected ) |
185 | { | 185 | { |
186 | if ( mActiveView ) | 186 | if ( mActiveView ) |
187 | mActiveView->setSelected( uid, selected ); | 187 | mActiveView->setSelected( uid, selected ); |
188 | } | 188 | } |
189 | 189 | ||
190 | void ViewManager::setListSelected(QStringList list) | 190 | void ViewManager::setListSelected(QStringList list) |
191 | { | 191 | { |
192 | int i, count = list.count(); | 192 | int i, count = list.count(); |
193 | for ( i = 0; i < count;++i ) | 193 | for ( i = 0; i < count;++i ) |
194 | setSelected( list[i], true ); | 194 | setSelected( list[i], true ); |
195 | 195 | ||
196 | } | 196 | } |
197 | void ViewManager::unloadViews() | 197 | void ViewManager::unloadViews() |
198 | { | 198 | { |
199 | mViewDict.clear(); | 199 | mViewDict.clear(); |
200 | mActiveView = 0; | 200 | mActiveView = 0; |
201 | } | 201 | } |
202 | 202 | ||
203 | void ViewManager::setActiveView( const QString &name ) | 203 | void ViewManager::setActiveView( const QString &name ) |
204 | { | 204 | { |
205 | KAddressBookView *view = 0; | 205 | KAddressBookView *view = 0; |
206 | 206 | ||
207 | // Check that this isn't the same as the current active view | 207 | // Check that this isn't the same as the current active view |
208 | if ( mActiveView && ( mActiveView->caption() == name ) ) | 208 | if ( mActiveView && ( mActiveView->caption() == name ) ) |
209 | return; | 209 | return; |
210 | 210 | ||
211 | // At this point we know the view that should be active is not | 211 | // At this point we know the view that should be active is not |
212 | // currently active. We will try to find the new on in the list. If | 212 | // currently active. We will try to find the new on in the list. If |
213 | // we can't find it, it means it hasn't been instantiated, so we will | 213 | // we can't find it, it means it hasn't been instantiated, so we will |
214 | // create it on demand. | 214 | // create it on demand. |
215 | 215 | ||
216 | view = mViewDict.find( name ); | 216 | view = mViewDict.find( name ); |
217 | 217 | ||
218 | // Check if we found the view. If we didn't, then we need to create it | 218 | // Check if we found the view. If we didn't, then we need to create it |
219 | if ( view == 0 ) { | 219 | if ( view == 0 ) { |
220 | KConfig *config = mCore->config(); | 220 | KConfig *config = mCore->config(); |
221 | 221 | ||
222 | KConfigGroupSaver saver( config, name ); | 222 | KConfigGroupSaver saver( config, name ); |
223 | 223 | ||
224 | QString type = config->readEntry( "Type", "Table" ); | 224 | QString type = config->readEntry( "Type", "Table" ); |
225 | 225 | ||
226 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; | 226 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; |
227 | 227 | ||
228 | ViewFactory *factory = mViewFactoryDict.find( type ); | 228 | ViewFactory *factory = mViewFactoryDict.find( type ); |
229 | if ( factory ) | 229 | if ( factory ) |
230 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); | 230 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); |
231 | 231 | ||
232 | if ( view ) { | 232 | if ( view ) { |
233 | view->setCaption( name ); | 233 | view->setCaption( name ); |
234 | mViewDict.insert( name, view ); | 234 | mViewDict.insert( name, view ); |
235 | //US my version needs an int as second parameter to addWidget | 235 | //US my version needs an int as second parameter to addWidget |
236 | mViewWidgetStack->addWidget( view, -1 ); | 236 | mViewWidgetStack->addWidget( view, -1 ); |
237 | view->readConfig( config ); | 237 | view->readConfig( config ); |
238 | 238 | ||
239 | // The manager just relays the signals | 239 | // The manager just relays the signals |
240 | connect( view, SIGNAL( selected( const QString& ) ), | 240 | connect( view, SIGNAL( selected( const QString& ) ), |
241 | SIGNAL( selected( const QString & ) ) ); | 241 | SIGNAL( selected( const QString & ) ) ); |
242 | connect( view, SIGNAL( executed( const QString& ) ), | 242 | connect( view, SIGNAL( executed( const QString& ) ), |
243 | SIGNAL( executed( const QString& ) ) ); | 243 | SIGNAL( executed( const QString& ) ) ); |
244 | 244 | ||
245 | connect( view, SIGNAL( deleteRequest( ) ), | 245 | connect( view, SIGNAL( deleteRequest( ) ), |
246 | SIGNAL( deleteRequest( ) ) ); | 246 | SIGNAL( deleteRequest( ) ) ); |
247 | 247 | ||
248 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); | 248 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); |
249 | connect( view, SIGNAL( dropped( QDropEvent* ) ), | 249 | connect( view, SIGNAL( dropped( QDropEvent* ) ), |
250 | SLOT( dropped( QDropEvent* ) ) ); | 250 | SLOT( dropped( QDropEvent* ) ) ); |
251 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); | 251 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | // If we found or created the view, raise it and refresh it | 255 | // If we found or created the view, raise it and refresh it |
256 | if ( view ) { | 256 | if ( view ) { |
257 | mActiveView = view; | 257 | mActiveView = view; |
258 | mViewWidgetStack->raiseWidget( view ); | 258 | mViewWidgetStack->raiseWidget( view ); |
259 | // Set the proper filter in the view. By setting the combo | 259 | // Set the proper filter in the view. By setting the combo |
260 | // box, the activated slot will be called, which will push | 260 | // box, the activated slot will be called, which will push |
261 | // the filter to the view and refresh it. | 261 | // the filter to the view and refresh it. |
262 | 262 | ||
263 | if ( view->defaultFilterType() == KAddressBookView::None ) { | 263 | if ( view->defaultFilterType() == KAddressBookView::None ) { |
264 | 264 | ||
265 | mActionSelectFilter->setCurrentItem( 0 ); | 265 | mActionSelectFilter->setCurrentItem( 0 ); |
266 | setActiveFilter( 0 ); | 266 | setActiveFilter( 0 ); |
267 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { | 267 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { |
268 | setActiveFilter( mActionSelectFilter->currentItem() ); | 268 | setActiveFilter( mActionSelectFilter->currentItem() ); |
269 | } else { | 269 | } else { |
270 | uint pos = filterPosition( view->defaultFilterName() ); | 270 | uint pos = filterPosition( view->defaultFilterName() ); |
271 | mActionSelectFilter->setCurrentItem( pos ); | 271 | mActionSelectFilter->setCurrentItem( pos ); |
272 | setActiveFilter( pos ); | 272 | setActiveFilter( pos ); |
273 | } | 273 | } |
274 | //US qDebug("ViewManager::setActiveView 6" ); | 274 | //US qDebug("ViewManager::setActiveView 6" ); |
275 | 275 | ||
276 | // Update the inc search widget to show the fields in the new active | 276 | // Update the inc search widget to show the fields in the new active |
277 | // view. | 277 | // view. |
278 | mCore->setSearchFields( mActiveView->fields() ); | 278 | mCore->setSearchFields( mActiveView->fields() ); |
279 | 279 | ||
280 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 280 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
281 | //US mActiveView->refresh(); | 281 | //US mActiveView->refresh(); |
282 | 282 | ||
283 | } | 283 | } |
284 | else | 284 | else |
285 | { | 285 | { |
286 | qDebug("ViewManager::setActiveView: unable to find view" ); | 286 | qDebug("ViewManager::setActiveView: unable to find view" ); |
287 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; | 287 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; |
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||
291 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 291 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
292 | void ViewManager::refreshView() | 292 | void ViewManager::refreshView() |
293 | { | 293 | { |
294 | refreshView( QString::null ); | 294 | refreshView( QString::null ); |
295 | } | 295 | } |
296 | 296 | ||
297 | void ViewManager::refreshView( const QString &uid ) | 297 | void ViewManager::refreshView( const QString &uid ) |
298 | { | 298 | { |
299 | if ( mActiveView ) | 299 | if ( mActiveView ) |
300 | mActiveView->refresh( uid ); | 300 | mActiveView->refresh( uid ); |
301 | } | 301 | } |
302 | 302 | ||
303 | void ViewManager::setFocusAV() | ||
304 | { | ||
305 | if ( mActiveView ) | ||
306 | mActiveView->setFocus(); | ||
307 | } | ||
303 | void ViewManager::editView() | 308 | void ViewManager::editView() |
304 | { | 309 | { |
305 | if ( !mActiveView ) | 310 | if ( !mActiveView ) |
306 | return; | 311 | return; |
307 | 312 | ||
308 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); | 313 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); |
309 | ViewConfigureWidget *wdg = 0; | 314 | ViewConfigureWidget *wdg = 0; |
310 | ViewConfigureDialog* dlg = 0; | 315 | ViewConfigureDialog* dlg = 0; |
311 | if ( factory ) { | 316 | if ( factory ) { |
312 | // Save the filters so the dialog has the latest set | 317 | // Save the filters so the dialog has the latest set |
313 | Filter::save( mCore->config(), "Filter", mFilterList ); | 318 | Filter::save( mCore->config(), "Filter", mFilterList ); |
314 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); | 319 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); |
315 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); | 320 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); |
316 | } else { | 321 | } else { |
317 | qDebug("ViewManager::editView()::cannot find viewfactory "); | 322 | qDebug("ViewManager::editView()::cannot find viewfactory "); |
318 | return; | 323 | return; |
319 | } | 324 | } |
320 | if ( wdg ) { | 325 | if ( wdg ) { |
321 | dlg->setWidget( wdg ); | 326 | dlg->setWidget( wdg ); |
322 | 327 | ||
323 | #ifndef DESKTOP_VERSION | 328 | #ifndef DESKTOP_VERSION |
324 | //dlg.setMaximumSize( 640, 480 ); | 329 | //dlg.setMaximumSize( 640, 480 ); |
325 | //dlg->setGeometry( 40,40, 400, 300); | 330 | //dlg->setGeometry( 40,40, 400, 300); |
326 | dlg->showMaximized(); | 331 | dlg->showMaximized(); |
327 | #endif | 332 | #endif |
328 | 333 | ||
329 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); | 334 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); |
330 | 335 | ||
331 | dlg->restoreSettings( mCore->config() ); | 336 | dlg->restoreSettings( mCore->config() ); |
332 | 337 | ||
333 | if ( dlg->exec() ) { | 338 | if ( dlg->exec() ) { |
334 | dlg->saveSettings( mCore->config() ); | 339 | dlg->saveSettings( mCore->config() ); |
335 | mActiveView->readConfig( mCore->config() ); | 340 | mActiveView->readConfig( mCore->config() ); |
336 | 341 | ||
337 | // Set the proper filter in the view. By setting the combo | 342 | // Set the proper filter in the view. By setting the combo |
338 | // box, the activated slot will be called, which will push | 343 | // box, the activated slot will be called, which will push |
339 | // the filter to the view and refresh it. | 344 | // the filter to the view and refresh it. |
340 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { | 345 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { |
341 | mActionSelectFilter->setCurrentItem( 0 ); | 346 | mActionSelectFilter->setCurrentItem( 0 ); |
342 | setActiveFilter( 0 ); | 347 | setActiveFilter( 0 ); |
343 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { | 348 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { |
344 | setActiveFilter( mActionSelectFilter->currentItem() ); | 349 | setActiveFilter( mActionSelectFilter->currentItem() ); |
345 | } else { | 350 | } else { |
346 | uint pos = filterPosition( mActiveView->defaultFilterName() ); | 351 | uint pos = filterPosition( mActiveView->defaultFilterName() ); |
347 | mActionSelectFilter->setCurrentItem( pos ); | 352 | mActionSelectFilter->setCurrentItem( pos ); |
348 | setActiveFilter( pos ); | 353 | setActiveFilter( pos ); |
349 | } | 354 | } |
350 | mCore->setSearchFields( mActiveView->fields() ); | 355 | mCore->setSearchFields( mActiveView->fields() ); |
351 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 356 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
352 | //US mActiveView->refresh(); | 357 | //US mActiveView->refresh(); |
353 | 358 | ||
354 | 359 | ||
355 | //US this is a bugfix, that we get notified if we change a views configuration | 360 | //US this is a bugfix, that we get notified if we change a views configuration |
356 | emit modified(); | 361 | emit modified(); |
357 | 362 | ||
358 | } | 363 | } |
359 | 364 | ||
360 | } | 365 | } |
361 | delete dlg; | 366 | delete dlg; |
362 | } | 367 | } |
363 | 368 | ||
364 | void ViewManager::deleteView() | 369 | void ViewManager::deleteView() |
365 | { | 370 | { |
366 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) | 371 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) |
367 | .arg( mActiveView->caption() ); | 372 | .arg( mActiveView->caption() ); |
368 | QString caption = i18n( "Confirm Delete" ); | 373 | QString caption = i18n( "Confirm Delete" ); |
369 | 374 | ||
370 | 375 | ||
371 | if (QMessageBox::information( this, caption, | 376 | if (QMessageBox::information( this, caption, |
372 | text, | 377 | text, |
373 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) | 378 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) |
374 | { | 379 | { |
375 | mViewNameList.remove( mActiveView->caption() ); | 380 | mViewNameList.remove( mActiveView->caption() ); |
376 | 381 | ||
377 | // remove the view from the config file | 382 | // remove the view from the config file |
378 | KConfig *config = mCore->config(); | 383 | KConfig *config = mCore->config(); |
379 | config->deleteGroup( mActiveView->caption() ); | 384 | config->deleteGroup( mActiveView->caption() ); |
380 | 385 | ||
381 | mViewDict.remove( mActiveView->caption() ); | 386 | mViewDict.remove( mActiveView->caption() ); |
382 | mActiveView = 0; | 387 | mActiveView = 0; |
383 | 388 | ||
384 | // we are in an invalid state now, but that should be fixed after | 389 | // we are in an invalid state now, but that should be fixed after |
385 | // we emit the signal | 390 | // we emit the signal |
386 | mActionSelectView->setItems( mViewNameList ); | 391 | mActionSelectView->setItems( mViewNameList ); |
387 | if ( mViewNameList.count() > 0 ) { | 392 | if ( mViewNameList.count() > 0 ) { |
388 | mActionSelectView->setCurrentItem( 0 ); | 393 | mActionSelectView->setCurrentItem( 0 ); |
389 | setActiveView( mViewNameList[ 0 ] ); | 394 | setActiveView( mViewNameList[ 0 ] ); |
390 | } | 395 | } |
391 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 396 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
392 | } | 397 | } |
393 | } | 398 | } |
394 | 399 | ||
395 | void ViewManager::addView() | 400 | void ViewManager::addView() |
396 | { | 401 | { |
397 | AddViewDialog dialog( &mViewFactoryDict, this ); | 402 | AddViewDialog dialog( &mViewFactoryDict, this ); |
398 | 403 | ||
399 | if ( dialog.exec() ) { | 404 | if ( dialog.exec() ) { |
400 | QString newName = dialog.viewName(); | 405 | QString newName = dialog.viewName(); |
401 | QString type = dialog.viewType(); | 406 | QString type = dialog.viewType(); |
402 | 407 | ||
403 | // Check for name conflicts | 408 | // Check for name conflicts |
404 | bool firstConflict = true; | 409 | bool firstConflict = true; |
405 | int numTries = 1; | 410 | int numTries = 1; |
406 | while ( mViewNameList.contains( newName ) > 0 ) { | 411 | while ( mViewNameList.contains( newName ) > 0 ) { |
407 | if ( !firstConflict ) { | 412 | if ( !firstConflict ) { |
408 | newName = newName.left( newName.length() - 4 ); | 413 | newName = newName.left( newName.length() - 4 ); |
409 | firstConflict = false; | 414 | firstConflict = false; |
410 | } | 415 | } |
411 | 416 | ||
412 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); | 417 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); |
413 | numTries++; | 418 | numTries++; |
414 | } | 419 | } |
415 | 420 | ||
416 | // Add the new one to the list | 421 | // Add the new one to the list |
417 | mViewNameList.append( newName ); | 422 | mViewNameList.append( newName ); |
418 | 423 | ||
419 | // write the view to the config file, | 424 | // write the view to the config file, |
420 | KConfig *config = mCore->config(); | 425 | KConfig *config = mCore->config(); |
421 | 426 | ||
422 | config->deleteGroup( newName ); | 427 | config->deleteGroup( newName ); |
423 | 428 | ||
424 | KConfigGroupSaver saver( config, newName ); | 429 | KConfigGroupSaver saver( config, newName ); |
425 | 430 | ||
426 | config->writeEntry( "Type", type ); | 431 | config->writeEntry( "Type", type ); |
427 | 432 | ||
428 | // try to set the active view | 433 | // try to set the active view |
429 | mActionSelectView->setItems( mViewNameList ); | 434 | mActionSelectView->setItems( mViewNameList ); |
430 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); | 435 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); |
431 | setActiveView( newName ); | 436 | setActiveView( newName ); |
432 | 437 | ||
433 | editView(); | 438 | editView(); |
434 | 439 | ||
435 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 440 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
436 | } | 441 | } |
437 | } | 442 | } |
438 | 443 | ||
439 | void ViewManager::createViewFactories() | 444 | void ViewManager::createViewFactories() |
440 | { | 445 | { |
441 | #ifndef KAB_EMBEDDED | 446 | #ifndef KAB_EMBEDDED |
442 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); | 447 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); |
443 | KTrader::OfferList::ConstIterator it; | 448 | KTrader::OfferList::ConstIterator it; |
444 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 449 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
445 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) | 450 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) |
446 | continue; | 451 | continue; |
447 | 452 | ||
448 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); | 453 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); |
449 | 454 | ||
450 | if ( !factory ) { | 455 | if ( !factory ) { |
451 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; | 456 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; |
452 | continue; | 457 | continue; |
453 | } | 458 | } |
454 | 459 | ||
455 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); | 460 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); |
456 | 461 | ||
457 | if ( !viewFactory ) { | 462 | if ( !viewFactory ) { |
458 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; | 463 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; |
459 | continue; | 464 | continue; |
460 | } | 465 | } |
461 | 466 | ||
462 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 467 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
463 | } | 468 | } |
464 | 469 | ||
465 | #else //KAB_EMBEDDED | 470 | #else //KAB_EMBEDDED |
466 | ViewFactory* viewFactory = new IconViewFactory(); | 471 | ViewFactory* viewFactory = new IconViewFactory(); |
467 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 472 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
468 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 473 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
469 | 474 | ||
470 | viewFactory = new TableViewFactory(); | 475 | viewFactory = new TableViewFactory(); |
471 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 476 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
472 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 477 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
473 | 478 | ||
474 | viewFactory = new CardViewFactory(); | 479 | viewFactory = new CardViewFactory(); |
475 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 480 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
476 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 481 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
477 | 482 | ||
478 | #endif //KAB_EMBEDDED | 483 | #endif //KAB_EMBEDDED |
479 | 484 | ||
480 | } | 485 | } |
481 | 486 | ||
482 | void ViewManager::dropped( QDropEvent *e ) | 487 | void ViewManager::dropped( QDropEvent *e ) |
483 | { | 488 | { |
484 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; | 489 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; |
485 | 490 | ||
486 | #ifndef KAB_EMBEDDED | 491 | #ifndef KAB_EMBEDDED |
487 | 492 | ||
488 | QString clipText, vcards; | 493 | QString clipText, vcards; |
489 | KURL::List urls; | 494 | KURL::List urls; |
490 | 495 | ||
491 | if ( KURLDrag::decode( e, urls) ) { | 496 | if ( KURLDrag::decode( e, urls) ) { |
492 | KURL::List::Iterator it = urls.begin(); | 497 | KURL::List::Iterator it = urls.begin(); |
493 | int c = urls.count(); | 498 | int c = urls.count(); |
494 | if ( c > 1 ) { | 499 | if ( c > 1 ) { |
495 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); | 500 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); |
496 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { | 501 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { |
497 | for ( ; it != urls.end(); ++it ) | 502 | for ( ; it != urls.end(); ++it ) |
498 | emit urlDropped( *it ); | 503 | emit urlDropped( *it ); |
499 | } | 504 | } |
500 | } else if ( c == 1 ) | 505 | } else if ( c == 1 ) |
501 | emit urlDropped( *it ); | 506 | emit urlDropped( *it ); |
502 | } else if ( KVCardDrag::decode( e, vcards ) ) { | 507 | } else if ( KVCardDrag::decode( e, vcards ) ) { |
503 | KABC::Addressee addr; | 508 | KABC::Addressee addr; |
504 | KABC::VCardConverter converter; | 509 | KABC::VCardConverter converter; |
505 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); | 510 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); |
506 | QStringList::Iterator it; | 511 | QStringList::Iterator it; |
507 | for ( it = list.begin(); it != list.end(); ++it ) { | 512 | for ( it = list.begin(); it != list.end(); ++it ) { |
508 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { | 513 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { |
509 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); | 514 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); |
510 | if ( a.isEmpty() ) { | 515 | if ( a.isEmpty() ) { |
511 | mCore->addressBook()->insertAddressee( addr ); | 516 | mCore->addressBook()->insertAddressee( addr ); |
512 | emit modified(); | 517 | emit modified(); |
513 | } | 518 | } |
514 | } | 519 | } |
515 | } | 520 | } |
516 | 521 | ||
517 | mActiveView->refresh(); | 522 | mActiveView->refresh(); |
518 | } | 523 | } |
519 | #else //KAB_EMBEDDED | 524 | #else //KAB_EMBEDDED |
520 | qDebug("ViewManager::dropped() has to be changed!!" ); | 525 | qDebug("ViewManager::dropped() has to be changed!!" ); |
521 | #endif //KAB_EMBEDDED | 526 | #endif //KAB_EMBEDDED |
522 | 527 | ||
523 | } | 528 | } |
524 | 529 | ||
525 | void ViewManager::startDrag() | 530 | void ViewManager::startDrag() |
526 | { | 531 | { |
527 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; | 532 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; |
528 | 533 | ||
529 | #ifndef KAB_EMBEDDED | 534 | #ifndef KAB_EMBEDDED |
530 | 535 | ||
531 | // Get the list of all the selected addressees | 536 | // Get the list of all the selected addressees |
532 | KABC::Addressee::List addrList; | 537 | KABC::Addressee::List addrList; |
533 | QStringList uidList = selectedUids(); | 538 | QStringList uidList = selectedUids(); |
534 | QStringList::Iterator iter; | 539 | QStringList::Iterator iter; |
535 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) | 540 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) |
536 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); | 541 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); |
537 | 542 | ||
538 | KMultipleDrag *drag = new KMultipleDrag( this ); | 543 | KMultipleDrag *drag = new KMultipleDrag( this ); |
539 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); | 544 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); |
540 | KABC::Addressee::List::Iterator it; | 545 | KABC::Addressee::List::Iterator it; |
541 | QStringList vcards; | 546 | QStringList vcards; |
542 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { | 547 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { |
543 | QString vcard = QString::null; | 548 | QString vcard = QString::null; |
544 | KABC::VCardConverter converter; | 549 | KABC::VCardConverter converter; |
545 | if ( converter.addresseeToVCard( *it, vcard ) ) | 550 | if ( converter.addresseeToVCard( *it, vcard ) ) |
546 | vcards.append( vcard ); | 551 | vcards.append( vcard ); |
547 | } | 552 | } |
548 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); | 553 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); |
549 | 554 | ||
550 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); | 555 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); |
551 | drag->dragCopy(); | 556 | drag->dragCopy(); |
552 | 557 | ||
553 | #else //KAB_EMBEDDED | 558 | #else //KAB_EMBEDDED |
554 | qDebug("ViewManager::startDrag() has to be changed!!" ); | 559 | qDebug("ViewManager::startDrag() has to be changed!!" ); |
555 | #endif //KAB_EMBEDDED | 560 | #endif //KAB_EMBEDDED |
556 | 561 | ||
557 | } | 562 | } |
558 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) | 563 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) |
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h index 585f4e9..a03a83f 100644 --- a/kaddressbook/viewmanager.h +++ b/kaddressbook/viewmanager.h | |||
@@ -1,156 +1,157 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef VIEWMANAGER_H | 24 | #ifndef VIEWMANAGER_H |
25 | #define VIEWMANAGER_H | 25 | #define VIEWMANAGER_H |
26 | 26 | ||
27 | #include <qwidget.h> | 27 | #include <qwidget.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <kaddressbookview.h> | 29 | #include <kaddressbookview.h> |
30 | #include <qdict.h> | 30 | #include <qdict.h> |
31 | 31 | ||
32 | class KAction; | 32 | class KAction; |
33 | class KSelectAction; | 33 | class KSelectAction; |
34 | 34 | ||
35 | class KABCore; | 35 | class KABCore; |
36 | class QWidgetStack; | 36 | class QWidgetStack; |
37 | class QDropEvent; | 37 | class QDropEvent; |
38 | 38 | ||
39 | namespace KABC { class AddressBook; } | 39 | namespace KABC { class AddressBook; } |
40 | 40 | ||
41 | /** | 41 | /** |
42 | The view manager manages the views and everything related to them. The | 42 | The view manager manages the views and everything related to them. The |
43 | manager will load the views at startup and display a view when told to | 43 | manager will load the views at startup and display a view when told to |
44 | make one active. | 44 | make one active. |
45 | 45 | ||
46 | The view manager will also create and manage all dialogs directly related to | 46 | The view manager will also create and manage all dialogs directly related to |
47 | views (ie: AddView, ConfigureView, DeleteView, etc). | 47 | views (ie: AddView, ConfigureView, DeleteView, etc). |
48 | */ | 48 | */ |
49 | class ViewManager : public QWidget | 49 | class ViewManager : public QWidget |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); | 53 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); |
54 | ~ViewManager(); | 54 | ~ViewManager(); |
55 | 55 | ||
56 | void restoreSettings(); | 56 | void restoreSettings(); |
57 | void saveSettings(); | 57 | void saveSettings(); |
58 | void doSearch( const QString& s ,KABC::Field *field ); | 58 | void doSearch( const QString& s ,KABC::Field *field ); |
59 | 59 | ||
60 | void unloadViews(); | 60 | void unloadViews(); |
61 | KSelectAction * getFilterAction() { return mActionSelectFilter; } | 61 | KSelectAction * getFilterAction() { return mActionSelectFilter; } |
62 | 62 | ||
63 | QStringList selectedUids() const; | 63 | QStringList selectedUids() const; |
64 | QStringList selectedEmails() const; | 64 | QStringList selectedEmails() const; |
65 | KABC::Addressee::List selectedAddressees() const; | 65 | KABC::Addressee::List selectedAddressees() const; |
66 | void setListSelected(QStringList); | 66 | void setListSelected(QStringList); |
67 | void setFocusAV(); | ||
67 | 68 | ||
68 | public slots: | 69 | public slots: |
69 | void scrollUP(); | 70 | void scrollUP(); |
70 | void scrollDOWN(); | 71 | void scrollDOWN(); |
71 | 72 | ||
72 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); | 73 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); |
73 | void setSelected( const QString &uid, bool); | 74 | void setSelected( const QString &uid, bool); |
74 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 75 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
75 | void setSelected(); | 76 | void setSelected(); |
76 | 77 | ||
77 | 78 | ||
78 | 79 | ||
79 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 80 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
80 | void refreshView(); | 81 | void refreshView(); |
81 | void refreshView( const QString &uid); | 82 | void refreshView( const QString &uid); |
82 | 83 | ||
83 | void editView(); | 84 | void editView(); |
84 | void deleteView(); | 85 | void deleteView(); |
85 | void addView(); | 86 | void addView(); |
86 | 87 | ||
87 | protected slots: | 88 | protected slots: |
88 | /** | 89 | /** |
89 | Called whenever the user drops something in the active view. | 90 | Called whenever the user drops something in the active view. |
90 | This method will try to decode what was dropped, and if it was | 91 | This method will try to decode what was dropped, and if it was |
91 | a valid addressee, add it to the addressbook. | 92 | a valid addressee, add it to the addressbook. |
92 | */ | 93 | */ |
93 | void dropped( QDropEvent* ); | 94 | void dropped( QDropEvent* ); |
94 | 95 | ||
95 | /** | 96 | /** |
96 | Called whenever the user attempts to start a drag in the view. | 97 | Called whenever the user attempts to start a drag in the view. |
97 | This method will convert all the selected addressees into text (vcard) | 98 | This method will convert all the selected addressees into text (vcard) |
98 | and create a drag object. | 99 | and create a drag object. |
99 | */ | 100 | */ |
100 | void startDrag(); | 101 | void startDrag(); |
101 | 102 | ||
102 | signals: | 103 | signals: |
103 | /** | 104 | /** |
104 | Emitted whenever the user selects an entry in the view. | 105 | Emitted whenever the user selects an entry in the view. |
105 | */ | 106 | */ |
106 | void selected( const QString &uid ); | 107 | void selected( const QString &uid ); |
107 | void deleteRequest( ); | 108 | void deleteRequest( ); |
108 | 109 | ||
109 | /** | 110 | /** |
110 | Emitted whenever the user activates an entry in the view. | 111 | Emitted whenever the user activates an entry in the view. |
111 | */ | 112 | */ |
112 | void executed( const QString &uid ); | 113 | void executed( const QString &uid ); |
113 | 114 | ||
114 | /** | 115 | /** |
115 | Emitted whenever the address book is modified in some way. | 116 | Emitted whenever the address book is modified in some way. |
116 | */ | 117 | */ |
117 | void modified(); | 118 | void modified(); |
118 | 119 | ||
119 | /** | 120 | /** |
120 | Emitted whenever a url is dragged on a view. | 121 | Emitted whenever a url is dragged on a view. |
121 | */ | 122 | */ |
122 | void urlDropped( const KURL& ); | 123 | void urlDropped( const KURL& ); |
123 | 124 | ||
124 | private slots: | 125 | private slots: |
125 | void setActiveView( const QString &name ); | 126 | void setActiveView( const QString &name ); |
126 | void setActiveFilter( int index ); | 127 | void setActiveFilter( int index ); |
127 | void configureFilters(); | 128 | void configureFilters(); |
128 | 129 | ||
129 | private: | 130 | private: |
130 | void createViewFactories(); | 131 | void createViewFactories(); |
131 | QStringList filterNames() const; | 132 | QStringList filterNames() const; |
132 | int filterPosition( const QString &name ) const; | 133 | int filterPosition( const QString &name ) const; |
133 | QStringList viewNames() const; | 134 | QStringList viewNames() const; |
134 | int viewPosition( const QString &name ) const; | 135 | int viewPosition( const QString &name ) const; |
135 | void initActions(); | 136 | void initActions(); |
136 | void initGUI(); | 137 | void initGUI(); |
137 | 138 | ||
138 | KABCore *mCore; | 139 | KABCore *mCore; |
139 | 140 | ||
140 | Filter mCurrentFilter; | 141 | Filter mCurrentFilter; |
141 | Filter::List mFilterList; | 142 | Filter::List mFilterList; |
142 | 143 | ||
143 | QDict<KAddressBookView> mViewDict; | 144 | QDict<KAddressBookView> mViewDict; |
144 | QDict<ViewFactory> mViewFactoryDict; | 145 | QDict<ViewFactory> mViewFactoryDict; |
145 | QStringList mViewNameList; | 146 | QStringList mViewNameList; |
146 | 147 | ||
147 | QWidgetStack *mViewWidgetStack; | 148 | QWidgetStack *mViewWidgetStack; |
148 | KAddressBookView *mActiveView; | 149 | KAddressBookView *mActiveView; |
149 | 150 | ||
150 | KAction *mActionDeleteView; | 151 | KAction *mActionDeleteView; |
151 | KSelectAction *mActionSelectFilter; | 152 | KSelectAction *mActionSelectFilter; |
152 | KSelectAction *mActionSelectView; | 153 | KSelectAction *mActionSelectView; |
153 | 154 | ||
154 | }; | 155 | }; |
155 | 156 | ||
156 | #endif | 157 | #endif |