-rw-r--r-- | kaddressbook/kabcore.cpp | 14 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 14 | ||||
-rw-r--r-- | korganizer/calendarview.h | 2 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 1 | ||||
-rw-r--r-- | libkdepim/kpimprefs.h | 18 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 100 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 20 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 6 |
8 files changed, 79 insertions, 96 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index b014cba..9041e45 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1072,1736 +1072,1736 @@ void KABCore::newContact() | |||
1072 | QPtrList<KRES::Resource> kresResources; | 1072 | QPtrList<KRES::Resource> kresResources; |
1073 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1073 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1074 | KABC::Resource *resource; | 1074 | KABC::Resource *resource; |
1075 | while ( ( resource = it.current() ) != 0 ) { | 1075 | while ( ( resource = it.current() ) != 0 ) { |
1076 | ++it; | 1076 | ++it; |
1077 | if ( !resource->readOnly() ) { | 1077 | if ( !resource->readOnly() ) { |
1078 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1078 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1079 | if ( res ) | 1079 | if ( res ) |
1080 | kresResources.append( res ); | 1080 | kresResources.append( res ); |
1081 | } | 1081 | } |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1084 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1085 | resource = static_cast<KABC::Resource*>( res ); | 1085 | resource = static_cast<KABC::Resource*>( res ); |
1086 | 1086 | ||
1087 | if ( resource ) { | 1087 | if ( resource ) { |
1088 | KABC::Addressee addr; | 1088 | KABC::Addressee addr; |
1089 | addr.setResource( resource ); | 1089 | addr.setResource( resource ); |
1090 | mEditorDialog->setAddressee( addr ); | 1090 | mEditorDialog->setAddressee( addr ); |
1091 | KApplication::execDialog ( mEditorDialog ); | 1091 | KApplication::execDialog ( mEditorDialog ); |
1092 | 1092 | ||
1093 | } else | 1093 | } else |
1094 | return; | 1094 | return; |
1095 | 1095 | ||
1096 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1096 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1097 | 1097 | ||
1098 | 1098 | ||
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | void KABCore::addEmail( QString aStr ) | 1101 | void KABCore::addEmail( QString aStr ) |
1102 | { | 1102 | { |
1103 | #ifndef KAB_EMBEDDED | 1103 | #ifndef KAB_EMBEDDED |
1104 | QString fullName, email; | 1104 | QString fullName, email; |
1105 | 1105 | ||
1106 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1106 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1107 | 1107 | ||
1108 | // Try to lookup the addressee matching the email address | 1108 | // Try to lookup the addressee matching the email address |
1109 | bool found = false; | 1109 | bool found = false; |
1110 | QStringList emailList; | 1110 | QStringList emailList; |
1111 | KABC::AddressBook::Iterator it; | 1111 | KABC::AddressBook::Iterator it; |
1112 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1112 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1113 | emailList = (*it).emails(); | 1113 | emailList = (*it).emails(); |
1114 | if ( emailList.contains( email ) > 0 ) { | 1114 | if ( emailList.contains( email ) > 0 ) { |
1115 | found = true; | 1115 | found = true; |
1116 | (*it).setNameFromString( fullName ); | 1116 | (*it).setNameFromString( fullName ); |
1117 | editContact( (*it).uid() ); | 1117 | editContact( (*it).uid() ); |
1118 | } | 1118 | } |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | if ( !found ) { | 1121 | if ( !found ) { |
1122 | KABC::Addressee addr; | 1122 | KABC::Addressee addr; |
1123 | addr.setNameFromString( fullName ); | 1123 | addr.setNameFromString( fullName ); |
1124 | addr.insertEmail( email, true ); | 1124 | addr.insertEmail( email, true ); |
1125 | 1125 | ||
1126 | mAddressBook->insertAddressee( addr ); | 1126 | mAddressBook->insertAddressee( addr ); |
1127 | mViewManager->refreshView( addr.uid() ); | 1127 | mViewManager->refreshView( addr.uid() ); |
1128 | editContact( addr.uid() ); | 1128 | editContact( addr.uid() ); |
1129 | } | 1129 | } |
1130 | #else //KAB_EMBEDDED | 1130 | #else //KAB_EMBEDDED |
1131 | qDebug("KABCore::addEmail finsih method"); | 1131 | qDebug("KABCore::addEmail finsih method"); |
1132 | #endif //KAB_EMBEDDED | 1132 | #endif //KAB_EMBEDDED |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1135 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1136 | { | 1136 | { |
1137 | mXXPortManager->importVCard( url, showPreview ); | 1137 | mXXPortManager->importVCard( url, showPreview ); |
1138 | } | 1138 | } |
1139 | void KABCore::importFromOL() | 1139 | void KABCore::importFromOL() |
1140 | { | 1140 | { |
1141 | #ifdef _WIN32_ | 1141 | #ifdef _WIN32_ |
1142 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1142 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1143 | idgl->exec(); | 1143 | idgl->exec(); |
1144 | KABC::Addressee::List list = idgl->getAddressList(); | 1144 | KABC::Addressee::List list = idgl->getAddressList(); |
1145 | if ( list.count() > 0 ) { | 1145 | if ( list.count() > 0 ) { |
1146 | KABC::Addressee::List listNew; | 1146 | KABC::Addressee::List listNew; |
1147 | KABC::Addressee::List listExisting; | 1147 | KABC::Addressee::List listExisting; |
1148 | KABC::Addressee::List::Iterator it; | 1148 | KABC::Addressee::List::Iterator it; |
1149 | KABC::AddressBook::Iterator iter; | 1149 | KABC::AddressBook::Iterator iter; |
1150 | for ( it = list.begin(); it != list.end(); ++it ) { | 1150 | for ( it = list.begin(); it != list.end(); ++it ) { |
1151 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1151 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1152 | listNew.append( (*it) ); | 1152 | listNew.append( (*it) ); |
1153 | else | 1153 | else |
1154 | listExisting.append( (*it) ); | 1154 | listExisting.append( (*it) ); |
1155 | } | 1155 | } |
1156 | if ( listExisting.count() > 0 ) | 1156 | if ( listExisting.count() > 0 ) |
1157 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1157 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1158 | if ( listNew.count() > 0 ) { | 1158 | if ( listNew.count() > 0 ) { |
1159 | pasteWithNewUid = false; | 1159 | pasteWithNewUid = false; |
1160 | pasteContacts( listNew ); | 1160 | pasteContacts( listNew ); |
1161 | pasteWithNewUid = true; | 1161 | pasteWithNewUid = true; |
1162 | } | 1162 | } |
1163 | } | 1163 | } |
1164 | delete idgl; | 1164 | delete idgl; |
1165 | #endif | 1165 | #endif |
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1168 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1169 | { | 1169 | { |
1170 | mXXPortManager->importVCard( vCard, showPreview ); | 1170 | mXXPortManager->importVCard( vCard, showPreview ); |
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | //US added a second method without defaultparameter | 1173 | //US added a second method without defaultparameter |
1174 | void KABCore::editContact2() { | 1174 | void KABCore::editContact2() { |
1175 | editContact( QString::null ); | 1175 | editContact( QString::null ); |
1176 | } | 1176 | } |
1177 | 1177 | ||
1178 | void KABCore::editContact( const QString &uid ) | 1178 | void KABCore::editContact( const QString &uid ) |
1179 | { | 1179 | { |
1180 | 1180 | ||
1181 | if ( mExtensionManager->isQuickEditVisible() ) | 1181 | if ( mExtensionManager->isQuickEditVisible() ) |
1182 | return; | 1182 | return; |
1183 | 1183 | ||
1184 | // First, locate the contact entry | 1184 | // First, locate the contact entry |
1185 | QString localUID = uid; | 1185 | QString localUID = uid; |
1186 | if ( localUID.isNull() ) { | 1186 | if ( localUID.isNull() ) { |
1187 | QStringList uidList = mViewManager->selectedUids(); | 1187 | QStringList uidList = mViewManager->selectedUids(); |
1188 | if ( uidList.count() > 0 ) | 1188 | if ( uidList.count() > 0 ) |
1189 | localUID = *( uidList.at( 0 ) ); | 1189 | localUID = *( uidList.at( 0 ) ); |
1190 | } | 1190 | } |
1191 | 1191 | ||
1192 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1192 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1193 | if ( !addr.isEmpty() ) { | 1193 | if ( !addr.isEmpty() ) { |
1194 | mEditorDialog->setAddressee( addr ); | 1194 | mEditorDialog->setAddressee( addr ); |
1195 | KApplication::execDialog ( mEditorDialog ); | 1195 | KApplication::execDialog ( mEditorDialog ); |
1196 | } | 1196 | } |
1197 | } | 1197 | } |
1198 | 1198 | ||
1199 | /** | 1199 | /** |
1200 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1200 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1201 | the method will try to find a selected addressee in the view. | 1201 | the method will try to find a selected addressee in the view. |
1202 | */ | 1202 | */ |
1203 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1203 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1204 | { | 1204 | { |
1205 | if ( mMultipleViewsAtOnce ) | 1205 | if ( mMultipleViewsAtOnce ) |
1206 | { | 1206 | { |
1207 | editContact( uid ); | 1207 | editContact( uid ); |
1208 | } | 1208 | } |
1209 | else | 1209 | else |
1210 | { | 1210 | { |
1211 | setDetailsVisible( true ); | 1211 | setDetailsVisible( true ); |
1212 | mActionDetails->setChecked(true); | 1212 | mActionDetails->setChecked(true); |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | void KABCore::save() | 1217 | void KABCore::save() |
1218 | { | 1218 | { |
1219 | if (syncManager->blockSave()) | 1219 | if (syncManager->blockSave()) |
1220 | return; | 1220 | return; |
1221 | if ( !mModified ) | 1221 | if ( !mModified ) |
1222 | return; | 1222 | return; |
1223 | 1223 | ||
1224 | syncManager->setBlockSave(true); | 1224 | syncManager->setBlockSave(true); |
1225 | QString text = i18n( "There was an error while attempting to save\n the " | 1225 | QString text = i18n( "There was an error while attempting to save\n the " |
1226 | "address book. Please check that some \nother application is " | 1226 | "address book. Please check that some \nother application is " |
1227 | "not using it. " ); | 1227 | "not using it. " ); |
1228 | statusMessage(i18n("Saving addressbook ... ")); | 1228 | statusMessage(i18n("Saving addressbook ... ")); |
1229 | #ifndef KAB_EMBEDDED | 1229 | #ifndef KAB_EMBEDDED |
1230 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1230 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1231 | if ( !b || !b->save() ) { | 1231 | if ( !b || !b->save() ) { |
1232 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1232 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1233 | } | 1233 | } |
1234 | #else //KAB_EMBEDDED | 1234 | #else //KAB_EMBEDDED |
1235 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1235 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1236 | if ( !b || !b->save() ) { | 1236 | if ( !b || !b->save() ) { |
1237 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1237 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1238 | } | 1238 | } |
1239 | #endif //KAB_EMBEDDED | 1239 | #endif //KAB_EMBEDDED |
1240 | 1240 | ||
1241 | statusMessage(i18n("Addressbook saved!")); | 1241 | statusMessage(i18n("Addressbook saved!")); |
1242 | setModified( false ); | 1242 | setModified( false ); |
1243 | syncManager->setBlockSave(false); | 1243 | syncManager->setBlockSave(false); |
1244 | } | 1244 | } |
1245 | 1245 | ||
1246 | void KABCore::statusMessage(QString mess , int time ) | 1246 | void KABCore::statusMessage(QString mess , int time ) |
1247 | { | 1247 | { |
1248 | //topLevelWidget()->setCaption( mess ); | 1248 | //topLevelWidget()->setCaption( mess ); |
1249 | // pending setting timer to revome message | 1249 | // pending setting timer to revome message |
1250 | } | 1250 | } |
1251 | void KABCore::undo() | 1251 | void KABCore::undo() |
1252 | { | 1252 | { |
1253 | UndoStack::instance()->undo(); | 1253 | UndoStack::instance()->undo(); |
1254 | 1254 | ||
1255 | // Refresh the view | 1255 | // Refresh the view |
1256 | mViewManager->refreshView(); | 1256 | mViewManager->refreshView(); |
1257 | } | 1257 | } |
1258 | 1258 | ||
1259 | void KABCore::redo() | 1259 | void KABCore::redo() |
1260 | { | 1260 | { |
1261 | RedoStack::instance()->redo(); | 1261 | RedoStack::instance()->redo(); |
1262 | 1262 | ||
1263 | // Refresh the view | 1263 | // Refresh the view |
1264 | mViewManager->refreshView(); | 1264 | mViewManager->refreshView(); |
1265 | } | 1265 | } |
1266 | 1266 | ||
1267 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1267 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1268 | { | 1268 | { |
1269 | if (mMultipleViewsAtOnce) | 1269 | if (mMultipleViewsAtOnce) |
1270 | { | 1270 | { |
1271 | if ( visible ) | 1271 | if ( visible ) |
1272 | mJumpButtonBar->show(); | 1272 | mJumpButtonBar->show(); |
1273 | else | 1273 | else |
1274 | mJumpButtonBar->hide(); | 1274 | mJumpButtonBar->hide(); |
1275 | } | 1275 | } |
1276 | else | 1276 | else |
1277 | { | 1277 | { |
1278 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1278 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1279 | if (mViewManager->isVisible()) | 1279 | if (mViewManager->isVisible()) |
1280 | { | 1280 | { |
1281 | if ( visible ) | 1281 | if ( visible ) |
1282 | mJumpButtonBar->show(); | 1282 | mJumpButtonBar->show(); |
1283 | else | 1283 | else |
1284 | mJumpButtonBar->hide(); | 1284 | mJumpButtonBar->hide(); |
1285 | } | 1285 | } |
1286 | else | 1286 | else |
1287 | { | 1287 | { |
1288 | mJumpButtonBar->hide(); | 1288 | mJumpButtonBar->hide(); |
1289 | } | 1289 | } |
1290 | } | 1290 | } |
1291 | } | 1291 | } |
1292 | 1292 | ||
1293 | 1293 | ||
1294 | void KABCore::setDetailsToState() | 1294 | void KABCore::setDetailsToState() |
1295 | { | 1295 | { |
1296 | setDetailsVisible( mActionDetails->isChecked() ); | 1296 | setDetailsVisible( mActionDetails->isChecked() ); |
1297 | } | 1297 | } |
1298 | 1298 | ||
1299 | 1299 | ||
1300 | 1300 | ||
1301 | void KABCore::setDetailsVisible( bool visible ) | 1301 | void KABCore::setDetailsVisible( bool visible ) |
1302 | { | 1302 | { |
1303 | if (visible && mDetails->isHidden()) | 1303 | if (visible && mDetails->isHidden()) |
1304 | { | 1304 | { |
1305 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1305 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1306 | if ( addrList.count() > 0 ) | 1306 | if ( addrList.count() > 0 ) |
1307 | mDetails->setAddressee( addrList[ 0 ] ); | 1307 | mDetails->setAddressee( addrList[ 0 ] ); |
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1310 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1311 | // the listview and the detailview. We do that by changing the splitbar size. | 1311 | // the listview and the detailview. We do that by changing the splitbar size. |
1312 | if (mMultipleViewsAtOnce) | 1312 | if (mMultipleViewsAtOnce) |
1313 | { | 1313 | { |
1314 | if ( visible ) | 1314 | if ( visible ) |
1315 | mDetails->show(); | 1315 | mDetails->show(); |
1316 | else | 1316 | else |
1317 | mDetails->hide(); | 1317 | mDetails->hide(); |
1318 | } | 1318 | } |
1319 | else | 1319 | else |
1320 | { | 1320 | { |
1321 | if ( visible ) { | 1321 | if ( visible ) { |
1322 | mViewManager->hide(); | 1322 | mViewManager->hide(); |
1323 | mDetails->show(); | 1323 | mDetails->show(); |
1324 | } | 1324 | } |
1325 | else { | 1325 | else { |
1326 | mViewManager->show(); | 1326 | mViewManager->show(); |
1327 | mDetails->hide(); | 1327 | mDetails->hide(); |
1328 | } | 1328 | } |
1329 | setJumpButtonBarVisible( !visible ); | 1329 | setJumpButtonBarVisible( !visible ); |
1330 | } | 1330 | } |
1331 | 1331 | ||
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | void KABCore::extensionChanged( int id ) | 1334 | void KABCore::extensionChanged( int id ) |
1335 | { | 1335 | { |
1336 | //change the details view only for non desktop systems | 1336 | //change the details view only for non desktop systems |
1337 | #ifndef DESKTOP_VERSION | 1337 | #ifndef DESKTOP_VERSION |
1338 | 1338 | ||
1339 | if (id == 0) | 1339 | if (id == 0) |
1340 | { | 1340 | { |
1341 | //the user disabled the extension. | 1341 | //the user disabled the extension. |
1342 | 1342 | ||
1343 | if (mMultipleViewsAtOnce) | 1343 | if (mMultipleViewsAtOnce) |
1344 | { // enable detailsview again | 1344 | { // enable detailsview again |
1345 | setDetailsVisible( true ); | 1345 | setDetailsVisible( true ); |
1346 | mActionDetails->setChecked( true ); | 1346 | mActionDetails->setChecked( true ); |
1347 | } | 1347 | } |
1348 | else | 1348 | else |
1349 | { //go back to the listview | 1349 | { //go back to the listview |
1350 | setDetailsVisible( false ); | 1350 | setDetailsVisible( false ); |
1351 | mActionDetails->setChecked( false ); | 1351 | mActionDetails->setChecked( false ); |
1352 | mActionDetails->setEnabled(true); | 1352 | mActionDetails->setEnabled(true); |
1353 | } | 1353 | } |
1354 | 1354 | ||
1355 | } | 1355 | } |
1356 | else | 1356 | else |
1357 | { | 1357 | { |
1358 | //the user enabled the extension. | 1358 | //the user enabled the extension. |
1359 | setDetailsVisible( false ); | 1359 | setDetailsVisible( false ); |
1360 | mActionDetails->setChecked( false ); | 1360 | mActionDetails->setChecked( false ); |
1361 | 1361 | ||
1362 | if (!mMultipleViewsAtOnce) | 1362 | if (!mMultipleViewsAtOnce) |
1363 | { | 1363 | { |
1364 | mActionDetails->setEnabled(false); | 1364 | mActionDetails->setEnabled(false); |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | mExtensionManager->setSelectionChanged(); | 1367 | mExtensionManager->setSelectionChanged(); |
1368 | 1368 | ||
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | #endif// DESKTOP_VERSION | 1371 | #endif// DESKTOP_VERSION |
1372 | 1372 | ||
1373 | } | 1373 | } |
1374 | 1374 | ||
1375 | 1375 | ||
1376 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1376 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1377 | { | 1377 | { |
1378 | 1378 | ||
1379 | if ( list.count() != 0 ) { | 1379 | if ( list.count() != 0 ) { |
1380 | KABC::Addressee::List::ConstIterator it; | 1380 | KABC::Addressee::List::ConstIterator it; |
1381 | for ( it = list.begin(); it != list.end(); ++it ) | 1381 | for ( it = list.begin(); it != list.end(); ++it ) |
1382 | mAddressBook->insertAddressee( *it ); | 1382 | mAddressBook->insertAddressee( *it ); |
1383 | if ( list.count() > 1 ) | 1383 | if ( list.count() > 1 ) |
1384 | setModified(); | 1384 | setModified(); |
1385 | else | 1385 | else |
1386 | setModifiedWOrefresh(); | 1386 | setModifiedWOrefresh(); |
1387 | } | 1387 | } |
1388 | if ( list.count() == 0 ) | 1388 | if ( list.count() == 0 ) |
1389 | mViewManager->refreshView(); | 1389 | mViewManager->refreshView(); |
1390 | else | 1390 | else |
1391 | mViewManager->refreshView( list[ 0 ].uid() ); | 1391 | mViewManager->refreshView( list[ 0 ].uid() ); |
1392 | 1392 | ||
1393 | 1393 | ||
1394 | 1394 | ||
1395 | } | 1395 | } |
1396 | 1396 | ||
1397 | QString KABCore::getNameByPhone( const QString &phone ) | 1397 | QString KABCore::getNameByPhone( const QString &phone ) |
1398 | { | 1398 | { |
1399 | #ifndef KAB_EMBEDDED | 1399 | #ifndef KAB_EMBEDDED |
1400 | QRegExp r( "[/*/-/ ]" ); | 1400 | QRegExp r( "[/*/-/ ]" ); |
1401 | QString localPhone( phone ); | 1401 | QString localPhone( phone ); |
1402 | 1402 | ||
1403 | bool found = false; | 1403 | bool found = false; |
1404 | QString ownerName = ""; | 1404 | QString ownerName = ""; |
1405 | KABC::AddressBook::Iterator iter; | 1405 | KABC::AddressBook::Iterator iter; |
1406 | KABC::PhoneNumber::List::Iterator phoneIter; | 1406 | KABC::PhoneNumber::List::Iterator phoneIter; |
1407 | KABC::PhoneNumber::List phoneList; | 1407 | KABC::PhoneNumber::List phoneList; |
1408 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1408 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1409 | phoneList = (*iter).phoneNumbers(); | 1409 | phoneList = (*iter).phoneNumbers(); |
1410 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1410 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1411 | ++phoneIter) { | 1411 | ++phoneIter) { |
1412 | // Get rid of separator chars so just the numbers are compared. | 1412 | // Get rid of separator chars so just the numbers are compared. |
1413 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1413 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1414 | ownerName = (*iter).formattedName(); | 1414 | ownerName = (*iter).formattedName(); |
1415 | found = true; | 1415 | found = true; |
1416 | } | 1416 | } |
1417 | } | 1417 | } |
1418 | } | 1418 | } |
1419 | 1419 | ||
1420 | return ownerName; | 1420 | return ownerName; |
1421 | #else //KAB_EMBEDDED | 1421 | #else //KAB_EMBEDDED |
1422 | qDebug("KABCore::getNameByPhone finsih method"); | 1422 | qDebug("KABCore::getNameByPhone finsih method"); |
1423 | return ""; | 1423 | return ""; |
1424 | #endif //KAB_EMBEDDED | 1424 | #endif //KAB_EMBEDDED |
1425 | 1425 | ||
1426 | } | 1426 | } |
1427 | 1427 | ||
1428 | void KABCore::openConfigDialog() | 1428 | void KABCore::openConfigDialog() |
1429 | { | 1429 | { |
1430 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1430 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1431 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1431 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1432 | ConfigureDialog->addModule(kabcfg ); | 1432 | ConfigureDialog->addModule(kabcfg ); |
1433 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1433 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1434 | ConfigureDialog->addModule(kdelibcfg ); | 1434 | ConfigureDialog->addModule(kdelibcfg ); |
1435 | 1435 | ||
1436 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1436 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1437 | this, SLOT( configurationChanged() ) ); | 1437 | this, SLOT( configurationChanged() ) ); |
1438 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1438 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1439 | this, SLOT( configurationChanged() ) ); | 1439 | this, SLOT( configurationChanged() ) ); |
1440 | saveSettings(); | 1440 | saveSettings(); |
1441 | #ifndef DESKTOP_VERSION | 1441 | #ifndef DESKTOP_VERSION |
1442 | ConfigureDialog->showMaximized(); | 1442 | ConfigureDialog->showMaximized(); |
1443 | #endif | 1443 | #endif |
1444 | if ( ConfigureDialog->exec() ) | 1444 | if ( ConfigureDialog->exec() ) |
1445 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1445 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1446 | delete ConfigureDialog; | 1446 | delete ConfigureDialog; |
1447 | } | 1447 | } |
1448 | 1448 | ||
1449 | void KABCore::openLDAPDialog() | 1449 | void KABCore::openLDAPDialog() |
1450 | { | 1450 | { |
1451 | #ifndef KAB_EMBEDDED | 1451 | #ifndef KAB_EMBEDDED |
1452 | if ( !mLdapSearchDialog ) { | 1452 | if ( !mLdapSearchDialog ) { |
1453 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1453 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1454 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1454 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1455 | SLOT( refreshView() ) ); | 1455 | SLOT( refreshView() ) ); |
1456 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1456 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1457 | SLOT( setModified() ) ); | 1457 | SLOT( setModified() ) ); |
1458 | } else | 1458 | } else |
1459 | mLdapSearchDialog->restoreSettings(); | 1459 | mLdapSearchDialog->restoreSettings(); |
1460 | 1460 | ||
1461 | if ( mLdapSearchDialog->isOK() ) | 1461 | if ( mLdapSearchDialog->isOK() ) |
1462 | mLdapSearchDialog->exec(); | 1462 | mLdapSearchDialog->exec(); |
1463 | #else //KAB_EMBEDDED | 1463 | #else //KAB_EMBEDDED |
1464 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1464 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1465 | #endif //KAB_EMBEDDED | 1465 | #endif //KAB_EMBEDDED |
1466 | } | 1466 | } |
1467 | 1467 | ||
1468 | void KABCore::print() | 1468 | void KABCore::print() |
1469 | { | 1469 | { |
1470 | #ifndef KAB_EMBEDDED | 1470 | #ifndef KAB_EMBEDDED |
1471 | KPrinter printer; | 1471 | KPrinter printer; |
1472 | if ( !printer.setup( this ) ) | 1472 | if ( !printer.setup( this ) ) |
1473 | return; | 1473 | return; |
1474 | 1474 | ||
1475 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1475 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1476 | mViewManager->selectedUids(), this ); | 1476 | mViewManager->selectedUids(), this ); |
1477 | 1477 | ||
1478 | wizard.exec(); | 1478 | wizard.exec(); |
1479 | #else //KAB_EMBEDDED | 1479 | #else //KAB_EMBEDDED |
1480 | qDebug("KABCore::print() finsih method"); | 1480 | qDebug("KABCore::print() finsih method"); |
1481 | #endif //KAB_EMBEDDED | 1481 | #endif //KAB_EMBEDDED |
1482 | 1482 | ||
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | 1485 | ||
1486 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1486 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1487 | { | 1487 | { |
1488 | if ( mGUIClient ) | 1488 | if ( mGUIClient ) |
1489 | mGUIClient->insertChildClient( client ); | 1489 | mGUIClient->insertChildClient( client ); |
1490 | else | 1490 | else |
1491 | KMessageBox::error( this, "no KXMLGUICLient"); | 1491 | KMessageBox::error( this, "no KXMLGUICLient"); |
1492 | } | 1492 | } |
1493 | 1493 | ||
1494 | 1494 | ||
1495 | void KABCore::configurationChanged() | 1495 | void KABCore::configurationChanged() |
1496 | { | 1496 | { |
1497 | mExtensionManager->reconfigure(); | 1497 | mExtensionManager->reconfigure(); |
1498 | } | 1498 | } |
1499 | 1499 | ||
1500 | void KABCore::addressBookChanged() | 1500 | void KABCore::addressBookChanged() |
1501 | { | 1501 | { |
1502 | /*US | 1502 | /*US |
1503 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1503 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1504 | while ( it.current() ) { | 1504 | while ( it.current() ) { |
1505 | if ( it.current()->dirty() ) { | 1505 | if ( it.current()->dirty() ) { |
1506 | QString text = i18n( "Data has been changed externally. Unsaved " | 1506 | QString text = i18n( "Data has been changed externally. Unsaved " |
1507 | "changes will be lost." ); | 1507 | "changes will be lost." ); |
1508 | KMessageBox::information( this, text ); | 1508 | KMessageBox::information( this, text ); |
1509 | } | 1509 | } |
1510 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1510 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1511 | ++it; | 1511 | ++it; |
1512 | } | 1512 | } |
1513 | */ | 1513 | */ |
1514 | if (mEditorDialog) | 1514 | if (mEditorDialog) |
1515 | { | 1515 | { |
1516 | if (mEditorDialog->dirty()) | 1516 | if (mEditorDialog->dirty()) |
1517 | { | 1517 | { |
1518 | QString text = i18n( "Data has been changed externally. Unsaved " | 1518 | QString text = i18n( "Data has been changed externally. Unsaved " |
1519 | "changes will be lost." ); | 1519 | "changes will be lost." ); |
1520 | KMessageBox::information( this, text ); | 1520 | KMessageBox::information( this, text ); |
1521 | } | 1521 | } |
1522 | QString currentuid = mEditorDialog->addressee().uid(); | 1522 | QString currentuid = mEditorDialog->addressee().uid(); |
1523 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1523 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1524 | } | 1524 | } |
1525 | mViewManager->refreshView(); | 1525 | mViewManager->refreshView(); |
1526 | // mDetails->refreshView(); | 1526 | // mDetails->refreshView(); |
1527 | 1527 | ||
1528 | 1528 | ||
1529 | } | 1529 | } |
1530 | 1530 | ||
1531 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1531 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1532 | const char *name ) | 1532 | const char *name ) |
1533 | { | 1533 | { |
1534 | 1534 | ||
1535 | if ( mEditorDialog == 0 ) { | 1535 | if ( mEditorDialog == 0 ) { |
1536 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1536 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1537 | name ? name : "editorDialog" ); | 1537 | name ? name : "editorDialog" ); |
1538 | 1538 | ||
1539 | 1539 | ||
1540 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1540 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1541 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1541 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1542 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1542 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1543 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1543 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1544 | } | 1544 | } |
1545 | 1545 | ||
1546 | return mEditorDialog; | 1546 | return mEditorDialog; |
1547 | } | 1547 | } |
1548 | 1548 | ||
1549 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1549 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1550 | { | 1550 | { |
1551 | //mEditorDict.remove( uid ); | 1551 | //mEditorDict.remove( uid ); |
1552 | } | 1552 | } |
1553 | 1553 | ||
1554 | void KABCore::initGUI() | 1554 | void KABCore::initGUI() |
1555 | { | 1555 | { |
1556 | #ifndef KAB_EMBEDDED | 1556 | #ifndef KAB_EMBEDDED |
1557 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1557 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1558 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1558 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1559 | 1559 | ||
1560 | mExtensionBarSplitter = new QSplitter( this ); | 1560 | mExtensionBarSplitter = new QSplitter( this ); |
1561 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1561 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1562 | 1562 | ||
1563 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1563 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1564 | 1564 | ||
1565 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1565 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1566 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1566 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1567 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1567 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1568 | SLOT( incrementalSearch( const QString& ) ) ); | 1568 | SLOT( incrementalSearch( const QString& ) ) ); |
1569 | 1569 | ||
1570 | mViewManager = new ViewManager( this, viewSpace ); | 1570 | mViewManager = new ViewManager( this, viewSpace ); |
1571 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1571 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1572 | 1572 | ||
1573 | mDetails = new ViewContainer( mDetailsSplitter ); | 1573 | mDetails = new ViewContainer( mDetailsSplitter ); |
1574 | 1574 | ||
1575 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1575 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1576 | 1576 | ||
1577 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1577 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1578 | 1578 | ||
1579 | topLayout->addWidget( mExtensionBarSplitter ); | 1579 | topLayout->addWidget( mExtensionBarSplitter ); |
1580 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1580 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1581 | topLayout->addWidget( mJumpButtonBar ); | 1581 | topLayout->addWidget( mJumpButtonBar ); |
1582 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1582 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1583 | 1583 | ||
1584 | mXXPortManager = new XXPortManager( this, this ); | 1584 | mXXPortManager = new XXPortManager( this, this ); |
1585 | 1585 | ||
1586 | #else //KAB_EMBEDDED | 1586 | #else //KAB_EMBEDDED |
1587 | //US initialize viewMenu before settingup viewmanager. | 1587 | //US initialize viewMenu before settingup viewmanager. |
1588 | // Viewmanager needs this menu to plugin submenues. | 1588 | // Viewmanager needs this menu to plugin submenues. |
1589 | viewMenu = new QPopupMenu( this ); | 1589 | viewMenu = new QPopupMenu( this ); |
1590 | settingsMenu = new QPopupMenu( this ); | 1590 | settingsMenu = new QPopupMenu( this ); |
1591 | //filterMenu = new QPopupMenu( this ); | 1591 | //filterMenu = new QPopupMenu( this ); |
1592 | ImportMenu = new QPopupMenu( this ); | 1592 | ImportMenu = new QPopupMenu( this ); |
1593 | ExportMenu = new QPopupMenu( this ); | 1593 | ExportMenu = new QPopupMenu( this ); |
1594 | syncMenu = new QPopupMenu( this ); | 1594 | syncMenu = new QPopupMenu( this ); |
1595 | changeMenu= new QPopupMenu( this ); | 1595 | changeMenu= new QPopupMenu( this ); |
1596 | 1596 | ||
1597 | //US since we have no splitter for the embedded system, setup | 1597 | //US since we have no splitter for the embedded system, setup |
1598 | // a layout with two frames. One left and one right. | 1598 | // a layout with two frames. One left and one right. |
1599 | 1599 | ||
1600 | QBoxLayout *topLayout; | 1600 | QBoxLayout *topLayout; |
1601 | 1601 | ||
1602 | // = new QHBoxLayout( this ); | 1602 | // = new QHBoxLayout( this ); |
1603 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1603 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1604 | 1604 | ||
1605 | // QWidget *mainBox = new QWidget( this ); | 1605 | // QWidget *mainBox = new QWidget( this ); |
1606 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1606 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1607 | 1607 | ||
1608 | #ifdef DESKTOP_VERSION | 1608 | #ifdef DESKTOP_VERSION |
1609 | topLayout = new QHBoxLayout( this ); | 1609 | topLayout = new QHBoxLayout( this ); |
1610 | 1610 | ||
1611 | 1611 | ||
1612 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1612 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1613 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1613 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1614 | 1614 | ||
1615 | topLayout->addWidget(mMiniSplitter ); | 1615 | topLayout->addWidget(mMiniSplitter ); |
1616 | 1616 | ||
1617 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1617 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1618 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1618 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1619 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1619 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1620 | mDetails = new ViewContainer( mMiniSplitter ); | 1620 | mDetails = new ViewContainer( mMiniSplitter ); |
1621 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1621 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1622 | #else | 1622 | #else |
1623 | if ( QApplication::desktop()->width() > 480 ) { | 1623 | if ( QApplication::desktop()->width() > 480 ) { |
1624 | topLayout = new QHBoxLayout( this ); | 1624 | topLayout = new QHBoxLayout( this ); |
1625 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1625 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1626 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1626 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1627 | } else { | 1627 | } else { |
1628 | 1628 | ||
1629 | topLayout = new QHBoxLayout( this ); | 1629 | topLayout = new QHBoxLayout( this ); |
1630 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1630 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1631 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1631 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1632 | } | 1632 | } |
1633 | 1633 | ||
1634 | topLayout->addWidget(mMiniSplitter ); | 1634 | topLayout->addWidget(mMiniSplitter ); |
1635 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1635 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1636 | mDetails = new ViewContainer( mMiniSplitter ); | 1636 | mDetails = new ViewContainer( mMiniSplitter ); |
1637 | 1637 | ||
1638 | 1638 | ||
1639 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1639 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1640 | #endif | 1640 | #endif |
1641 | //eh->hide(); | 1641 | //eh->hide(); |
1642 | // topLayout->addWidget(mExtensionManager ); | 1642 | // topLayout->addWidget(mExtensionManager ); |
1643 | 1643 | ||
1644 | 1644 | ||
1645 | /*US | 1645 | /*US |
1646 | #ifndef KAB_NOSPLITTER | 1646 | #ifndef KAB_NOSPLITTER |
1647 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1647 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1648 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1648 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1649 | topLayout->setSpacing( 10 ); | 1649 | topLayout->setSpacing( 10 ); |
1650 | 1650 | ||
1651 | mDetailsSplitter = new QSplitter( this ); | 1651 | mDetailsSplitter = new QSplitter( this ); |
1652 | 1652 | ||
1653 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1653 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1654 | 1654 | ||
1655 | mViewManager = new ViewManager( this, viewSpace ); | 1655 | mViewManager = new ViewManager( this, viewSpace ); |
1656 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1656 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1657 | 1657 | ||
1658 | mDetails = new ViewContainer( mDetailsSplitter ); | 1658 | mDetails = new ViewContainer( mDetailsSplitter ); |
1659 | 1659 | ||
1660 | topLayout->addWidget( mDetailsSplitter ); | 1660 | topLayout->addWidget( mDetailsSplitter ); |
1661 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1661 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1662 | #else //KAB_NOSPLITTER | 1662 | #else //KAB_NOSPLITTER |
1663 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1663 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1664 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1664 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1665 | topLayout->setSpacing( 10 ); | 1665 | topLayout->setSpacing( 10 ); |
1666 | 1666 | ||
1667 | // mDetailsSplitter = new QSplitter( this ); | 1667 | // mDetailsSplitter = new QSplitter( this ); |
1668 | 1668 | ||
1669 | QVBox *viewSpace = new QVBox( this ); | 1669 | QVBox *viewSpace = new QVBox( this ); |
1670 | 1670 | ||
1671 | mViewManager = new ViewManager( this, viewSpace ); | 1671 | mViewManager = new ViewManager( this, viewSpace ); |
1672 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1672 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1673 | 1673 | ||
1674 | mDetails = new ViewContainer( this ); | 1674 | mDetails = new ViewContainer( this ); |
1675 | 1675 | ||
1676 | topLayout->addWidget( viewSpace ); | 1676 | topLayout->addWidget( viewSpace ); |
1677 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1677 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1678 | topLayout->addWidget( mDetails ); | 1678 | topLayout->addWidget( mDetails ); |
1679 | #endif //KAB_NOSPLITTER | 1679 | #endif //KAB_NOSPLITTER |
1680 | */ | 1680 | */ |
1681 | 1681 | ||
1682 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1682 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1683 | syncManager->setBlockSave(false); | 1683 | syncManager->setBlockSave(false); |
1684 | 1684 | ||
1685 | 1685 | ||
1686 | #endif //KAB_EMBEDDED | 1686 | #endif //KAB_EMBEDDED |
1687 | initActions(); | 1687 | initActions(); |
1688 | 1688 | ||
1689 | #ifdef KAB_EMBEDDED | 1689 | #ifdef KAB_EMBEDDED |
1690 | addActionsManually(); | 1690 | addActionsManually(); |
1691 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1691 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1692 | mXXPortManager = new XXPortManager( this, this ); | 1692 | mXXPortManager = new XXPortManager( this, this ); |
1693 | 1693 | ||
1694 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1694 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1695 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1695 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1696 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1696 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1697 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1697 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1698 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1698 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1699 | // mIncSearchWidget->hide(); | 1699 | // mIncSearchWidget->hide(); |
1700 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1700 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1701 | SLOT( incrementalSearch( const QString& ) ) ); | 1701 | SLOT( incrementalSearch( const QString& ) ) ); |
1702 | 1702 | ||
1703 | 1703 | ||
1704 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1704 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1705 | 1705 | ||
1706 | topLayout->addWidget( mJumpButtonBar ); | 1706 | topLayout->addWidget( mJumpButtonBar ); |
1707 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1707 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1708 | 1708 | ||
1709 | // mMainWindow->getIconToolBar()->raise(); | 1709 | // mMainWindow->getIconToolBar()->raise(); |
1710 | 1710 | ||
1711 | #endif //KAB_EMBEDDED | 1711 | #endif //KAB_EMBEDDED |
1712 | 1712 | ||
1713 | } | 1713 | } |
1714 | void KABCore::initActions() | 1714 | void KABCore::initActions() |
1715 | { | 1715 | { |
1716 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1716 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1717 | 1717 | ||
1718 | #ifndef KAB_EMBEDDED | 1718 | #ifndef KAB_EMBEDDED |
1719 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1719 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1720 | SLOT( clipboardDataChanged() ) ); | 1720 | SLOT( clipboardDataChanged() ) ); |
1721 | #endif //KAB_EMBEDDED | 1721 | #endif //KAB_EMBEDDED |
1722 | 1722 | ||
1723 | // file menu | 1723 | // file menu |
1724 | if ( mIsPart ) { | 1724 | if ( mIsPart ) { |
1725 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1725 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1726 | SLOT( sendMail() ), actionCollection(), | 1726 | SLOT( sendMail() ), actionCollection(), |
1727 | "kaddressbook_mail" ); | 1727 | "kaddressbook_mail" ); |
1728 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1728 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1729 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1729 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1730 | 1730 | ||
1731 | } else { | 1731 | } else { |
1732 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1732 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1733 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1733 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1734 | } | 1734 | } |
1735 | 1735 | ||
1736 | 1736 | ||
1737 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1737 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1738 | SLOT( save() ), actionCollection(), "file_sync" ); | 1738 | SLOT( save() ), actionCollection(), "file_sync" ); |
1739 | 1739 | ||
1740 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1740 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1741 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1741 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1742 | 1742 | ||
1743 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1743 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1744 | this, SLOT( mailVCard() ), | 1744 | this, SLOT( mailVCard() ), |
1745 | actionCollection(), "file_mail_vcard"); | 1745 | actionCollection(), "file_mail_vcard"); |
1746 | 1746 | ||
1747 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1747 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1748 | SLOT( export2phone() ), actionCollection(), | 1748 | SLOT( export2phone() ), actionCollection(), |
1749 | "kaddressbook_ex2phone" ); | 1749 | "kaddressbook_ex2phone" ); |
1750 | 1750 | ||
1751 | mActionBeamVCard = 0; | 1751 | mActionBeamVCard = 0; |
1752 | mActionBeam = 0; | 1752 | mActionBeam = 0; |
1753 | 1753 | ||
1754 | #ifndef DESKTOP_VERSION | 1754 | #ifndef DESKTOP_VERSION |
1755 | if ( Ir::supported() ) { | 1755 | if ( Ir::supported() ) { |
1756 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1756 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1757 | SLOT( beamVCard() ), actionCollection(), | 1757 | SLOT( beamVCard() ), actionCollection(), |
1758 | "kaddressbook_beam_vcard" ); | 1758 | "kaddressbook_beam_vcard" ); |
1759 | 1759 | ||
1760 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1760 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1761 | SLOT( beamMySelf() ), actionCollection(), | 1761 | SLOT( beamMySelf() ), actionCollection(), |
1762 | "kaddressbook_beam_myself" ); | 1762 | "kaddressbook_beam_myself" ); |
1763 | } | 1763 | } |
1764 | #endif | 1764 | #endif |
1765 | 1765 | ||
1766 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1766 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1767 | this, SLOT( editContact2() ), | 1767 | this, SLOT( editContact2() ), |
1768 | actionCollection(), "file_properties" ); | 1768 | actionCollection(), "file_properties" ); |
1769 | 1769 | ||
1770 | #ifdef KAB_EMBEDDED | 1770 | #ifdef KAB_EMBEDDED |
1771 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1771 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1772 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1772 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1773 | mMainWindow, SLOT( exit() ), | 1773 | mMainWindow, SLOT( exit() ), |
1774 | actionCollection(), "quit" ); | 1774 | actionCollection(), "quit" ); |
1775 | #endif //KAB_EMBEDDED | 1775 | #endif //KAB_EMBEDDED |
1776 | 1776 | ||
1777 | // edit menu | 1777 | // edit menu |
1778 | if ( mIsPart ) { | 1778 | if ( mIsPart ) { |
1779 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1779 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1780 | SLOT( copyContacts() ), actionCollection(), | 1780 | SLOT( copyContacts() ), actionCollection(), |
1781 | "kaddressbook_copy" ); | 1781 | "kaddressbook_copy" ); |
1782 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1782 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1783 | SLOT( cutContacts() ), actionCollection(), | 1783 | SLOT( cutContacts() ), actionCollection(), |
1784 | "kaddressbook_cut" ); | 1784 | "kaddressbook_cut" ); |
1785 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1785 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1786 | SLOT( pasteContacts() ), actionCollection(), | 1786 | SLOT( pasteContacts() ), actionCollection(), |
1787 | "kaddressbook_paste" ); | 1787 | "kaddressbook_paste" ); |
1788 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1788 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1789 | SLOT( selectAllContacts() ), actionCollection(), | 1789 | SLOT( selectAllContacts() ), actionCollection(), |
1790 | "kaddressbook_select_all" ); | 1790 | "kaddressbook_select_all" ); |
1791 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1791 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1792 | SLOT( undo() ), actionCollection(), | 1792 | SLOT( undo() ), actionCollection(), |
1793 | "kaddressbook_undo" ); | 1793 | "kaddressbook_undo" ); |
1794 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1794 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1795 | this, SLOT( redo() ), actionCollection(), | 1795 | this, SLOT( redo() ), actionCollection(), |
1796 | "kaddressbook_redo" ); | 1796 | "kaddressbook_redo" ); |
1797 | } else { | 1797 | } else { |
1798 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1798 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1799 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1799 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1800 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1800 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1801 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1801 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1802 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1802 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1803 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1803 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1804 | } | 1804 | } |
1805 | 1805 | ||
1806 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1806 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1807 | Key_Delete, this, SLOT( deleteContacts() ), | 1807 | Key_Delete, this, SLOT( deleteContacts() ), |
1808 | actionCollection(), "edit_delete" ); | 1808 | actionCollection(), "edit_delete" ); |
1809 | 1809 | ||
1810 | mActionUndo->setEnabled( false ); | 1810 | mActionUndo->setEnabled( false ); |
1811 | mActionRedo->setEnabled( false ); | 1811 | mActionRedo->setEnabled( false ); |
1812 | 1812 | ||
1813 | // settings menu | 1813 | // settings menu |
1814 | #ifdef KAB_EMBEDDED | 1814 | #ifdef KAB_EMBEDDED |
1815 | //US special menuentry to configure the addressbook resources. On KDE | 1815 | //US special menuentry to configure the addressbook resources. On KDE |
1816 | // you do that through the control center !!! | 1816 | // you do that through the control center !!! |
1817 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1817 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1818 | SLOT( configureResources() ), actionCollection(), | 1818 | SLOT( configureResources() ), actionCollection(), |
1819 | "kaddressbook_configure_resources" ); | 1819 | "kaddressbook_configure_resources" ); |
1820 | #endif //KAB_EMBEDDED | 1820 | #endif //KAB_EMBEDDED |
1821 | 1821 | ||
1822 | if ( mIsPart ) { | 1822 | if ( mIsPart ) { |
1823 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1823 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1824 | SLOT( openConfigDialog() ), actionCollection(), | 1824 | SLOT( openConfigDialog() ), actionCollection(), |
1825 | "kaddressbook_configure" ); | 1825 | "kaddressbook_configure" ); |
1826 | 1826 | ||
1827 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1827 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1828 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1828 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1829 | "kaddressbook_configure_shortcuts" ); | 1829 | "kaddressbook_configure_shortcuts" ); |
1830 | #ifdef KAB_EMBEDDED | 1830 | #ifdef KAB_EMBEDDED |
1831 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1831 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1832 | mActionConfigureToolbars->setEnabled( false ); | 1832 | mActionConfigureToolbars->setEnabled( false ); |
1833 | #endif //KAB_EMBEDDED | 1833 | #endif //KAB_EMBEDDED |
1834 | 1834 | ||
1835 | } else { | 1835 | } else { |
1836 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1836 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1837 | 1837 | ||
1838 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1838 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1839 | } | 1839 | } |
1840 | 1840 | ||
1841 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1841 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1842 | actionCollection(), "options_show_jump_bar" ); | 1842 | actionCollection(), "options_show_jump_bar" ); |
1843 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1843 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1844 | 1844 | ||
1845 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1845 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1846 | actionCollection(), "options_show_details" ); | 1846 | actionCollection(), "options_show_details" ); |
1847 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1847 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1848 | 1848 | ||
1849 | // misc | 1849 | // misc |
1850 | // only enable LDAP lookup if we can handle the protocol | 1850 | // only enable LDAP lookup if we can handle the protocol |
1851 | #ifndef KAB_EMBEDDED | 1851 | #ifndef KAB_EMBEDDED |
1852 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1852 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1853 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1853 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1854 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1854 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1855 | "ldap_lookup" ); | 1855 | "ldap_lookup" ); |
1856 | } | 1856 | } |
1857 | #else //KAB_EMBEDDED | 1857 | #else //KAB_EMBEDDED |
1858 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1858 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1859 | #endif //KAB_EMBEDDED | 1859 | #endif //KAB_EMBEDDED |
1860 | 1860 | ||
1861 | 1861 | ||
1862 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1862 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1863 | SLOT( setWhoAmI() ), actionCollection(), | 1863 | SLOT( setWhoAmI() ), actionCollection(), |
1864 | "set_personal" ); | 1864 | "set_personal" ); |
1865 | 1865 | ||
1866 | 1866 | ||
1867 | 1867 | ||
1868 | 1868 | ||
1869 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1869 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1870 | SLOT( setCategories() ), actionCollection(), | 1870 | SLOT( setCategories() ), actionCollection(), |
1871 | "edit_set_categories" ); | 1871 | "edit_set_categories" ); |
1872 | 1872 | ||
1873 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1873 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1874 | SLOT( removeVoice() ), actionCollection(), | 1874 | SLOT( removeVoice() ), actionCollection(), |
1875 | "remove_voice" ); | 1875 | "remove_voice" ); |
1876 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1876 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1877 | SLOT( importFromOL() ), actionCollection(), | 1877 | SLOT( importFromOL() ), actionCollection(), |
1878 | "import_OL" ); | 1878 | "import_OL" ); |
1879 | #ifdef KAB_EMBEDDED | 1879 | #ifdef KAB_EMBEDDED |
1880 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1880 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1881 | this, SLOT( showLicence() ), actionCollection(), | 1881 | this, SLOT( showLicence() ), actionCollection(), |
1882 | "licence_about_data" ); | 1882 | "licence_about_data" ); |
1883 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1883 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1884 | this, SLOT( faq() ), actionCollection(), | 1884 | this, SLOT( faq() ), actionCollection(), |
1885 | "faq_about_data" ); | 1885 | "faq_about_data" ); |
1886 | 1886 | ||
1887 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1887 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1888 | this, SLOT( createAboutData() ), actionCollection(), | 1888 | this, SLOT( createAboutData() ), actionCollection(), |
1889 | "kaddressbook_about_data" ); | 1889 | "kaddressbook_about_data" ); |
1890 | #endif //KAB_EMBEDDED | 1890 | #endif //KAB_EMBEDDED |
1891 | 1891 | ||
1892 | clipboardDataChanged(); | 1892 | clipboardDataChanged(); |
1893 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1893 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1894 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1894 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1895 | } | 1895 | } |
1896 | 1896 | ||
1897 | //US we need this function, to plug all actions into the correct menues. | 1897 | //US we need this function, to plug all actions into the correct menues. |
1898 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1898 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1899 | void KABCore::addActionsManually() | 1899 | void KABCore::addActionsManually() |
1900 | { | 1900 | { |
1901 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1901 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1902 | 1902 | ||
1903 | #ifdef KAB_EMBEDDED | 1903 | #ifdef KAB_EMBEDDED |
1904 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1904 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1905 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1905 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1906 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1906 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1907 | 1907 | ||
1908 | KToolBar* tb = mMainWindow->toolBar(); | 1908 | KToolBar* tb = mMainWindow->toolBar(); |
1909 | 1909 | ||
1910 | #ifdef DESKTOP_VERSION | 1910 | #ifdef DESKTOP_VERSION |
1911 | QMenuBar* mb = mMainWindow->menuBar(); | 1911 | QMenuBar* mb = mMainWindow->menuBar(); |
1912 | 1912 | ||
1913 | //US setup menubar. | 1913 | //US setup menubar. |
1914 | //Disable the following block if you do not want to have a menubar. | 1914 | //Disable the following block if you do not want to have a menubar. |
1915 | mb->insertItem( "&File", fileMenu ); | 1915 | mb->insertItem( "&File", fileMenu ); |
1916 | mb->insertItem( "&Edit", editMenu ); | 1916 | mb->insertItem( "&Edit", editMenu ); |
1917 | mb->insertItem( "&View", viewMenu ); | 1917 | mb->insertItem( "&View", viewMenu ); |
1918 | mb->insertItem( "&Settings", settingsMenu ); | 1918 | mb->insertItem( "&Settings", settingsMenu ); |
1919 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1919 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1920 | mb->insertItem( "&Change selected", changeMenu ); | 1920 | mb->insertItem( "&Change selected", changeMenu ); |
1921 | mb->insertItem( "&Help", helpMenu ); | 1921 | mb->insertItem( "&Help", helpMenu ); |
1922 | mIncSearchWidget = new IncSearchWidget( tb ); | 1922 | mIncSearchWidget = new IncSearchWidget( tb ); |
1923 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1923 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1924 | 1924 | ||
1925 | #else | 1925 | #else |
1926 | //US setup toolbar | 1926 | //US setup toolbar |
1927 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1927 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1928 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1928 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1929 | menuBarTB->insertItem( "ME", popupBarTB); | 1929 | menuBarTB->insertItem( "ME", popupBarTB); |
1930 | tb->insertWidget(-1, 0, menuBarTB); | 1930 | tb->insertWidget(-1, 0, menuBarTB); |
1931 | mIncSearchWidget = new IncSearchWidget( tb ); | 1931 | mIncSearchWidget = new IncSearchWidget( tb ); |
1932 | 1932 | ||
1933 | tb->enableMoving(false); | 1933 | tb->enableMoving(false); |
1934 | popupBarTB->insertItem( "&File", fileMenu ); | 1934 | popupBarTB->insertItem( "&File", fileMenu ); |
1935 | popupBarTB->insertItem( "&Edit", editMenu ); | 1935 | popupBarTB->insertItem( "&Edit", editMenu ); |
1936 | popupBarTB->insertItem( "&View", viewMenu ); | 1936 | popupBarTB->insertItem( "&View", viewMenu ); |
1937 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1937 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1938 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1938 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1939 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1939 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1940 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1940 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1941 | popupBarTB->insertItem( "&Help", helpMenu ); | 1941 | popupBarTB->insertItem( "&Help", helpMenu ); |
1942 | if (QApplication::desktop()->width() > 320 ) { | 1942 | if (QApplication::desktop()->width() > 320 ) { |
1943 | // mViewManager->getFilterAction()->plug ( tb); | 1943 | // mViewManager->getFilterAction()->plug ( tb); |
1944 | } | 1944 | } |
1945 | #endif | 1945 | #endif |
1946 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1946 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1947 | 1947 | ||
1948 | 1948 | ||
1949 | 1949 | ||
1950 | //US Now connect the actions with the menue entries. | 1950 | //US Now connect the actions with the menue entries. |
1951 | mActionPrint->plug( fileMenu ); | 1951 | mActionPrint->plug( fileMenu ); |
1952 | mActionMail->plug( fileMenu ); | 1952 | mActionMail->plug( fileMenu ); |
1953 | fileMenu->insertSeparator(); | 1953 | fileMenu->insertSeparator(); |
1954 | 1954 | ||
1955 | mActionNewContact->plug( fileMenu ); | 1955 | mActionNewContact->plug( fileMenu ); |
1956 | mActionNewContact->plug( tb ); | 1956 | mActionNewContact->plug( tb ); |
1957 | 1957 | ||
1958 | mActionEditAddressee->plug( fileMenu ); | 1958 | mActionEditAddressee->plug( fileMenu ); |
1959 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1959 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1960 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1960 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1961 | mActionEditAddressee->plug( tb ); | 1961 | mActionEditAddressee->plug( tb ); |
1962 | 1962 | ||
1963 | fileMenu->insertSeparator(); | 1963 | fileMenu->insertSeparator(); |
1964 | mActionSave->plug( fileMenu ); | 1964 | mActionSave->plug( fileMenu ); |
1965 | fileMenu->insertItem( "&Import", ImportMenu ); | 1965 | fileMenu->insertItem( "&Import", ImportMenu ); |
1966 | fileMenu->insertItem( "&Export", ExportMenu ); | 1966 | fileMenu->insertItem( "&Export", ExportMenu ); |
1967 | fileMenu->insertSeparator(); | 1967 | fileMenu->insertSeparator(); |
1968 | mActionMailVCard->plug( fileMenu ); | 1968 | mActionMailVCard->plug( fileMenu ); |
1969 | #ifndef DESKTOP_VERSION | 1969 | #ifndef DESKTOP_VERSION |
1970 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1970 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1971 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1971 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1972 | #endif | 1972 | #endif |
1973 | fileMenu->insertSeparator(); | 1973 | fileMenu->insertSeparator(); |
1974 | mActionQuit->plug( fileMenu ); | 1974 | mActionQuit->plug( fileMenu ); |
1975 | #ifdef _WIN32_ | 1975 | #ifdef _WIN32_ |
1976 | mActionImportOL->plug( ImportMenu ); | 1976 | mActionImportOL->plug( ImportMenu ); |
1977 | #endif | 1977 | #endif |
1978 | // edit menu | 1978 | // edit menu |
1979 | mActionUndo->plug( editMenu ); | 1979 | mActionUndo->plug( editMenu ); |
1980 | mActionRedo->plug( editMenu ); | 1980 | mActionRedo->plug( editMenu ); |
1981 | editMenu->insertSeparator(); | 1981 | editMenu->insertSeparator(); |
1982 | mActionCut->plug( editMenu ); | 1982 | mActionCut->plug( editMenu ); |
1983 | mActionCopy->plug( editMenu ); | 1983 | mActionCopy->plug( editMenu ); |
1984 | mActionPaste->plug( editMenu ); | 1984 | mActionPaste->plug( editMenu ); |
1985 | mActionDelete->plug( editMenu ); | 1985 | mActionDelete->plug( editMenu ); |
1986 | editMenu->insertSeparator(); | 1986 | editMenu->insertSeparator(); |
1987 | mActionSelectAll->plug( editMenu ); | 1987 | mActionSelectAll->plug( editMenu ); |
1988 | 1988 | ||
1989 | mActionRemoveVoice->plug( changeMenu ); | 1989 | mActionRemoveVoice->plug( changeMenu ); |
1990 | // settings menu | 1990 | // settings menu |
1991 | //US special menuentry to configure the addressbook resources. On KDE | 1991 | //US special menuentry to configure the addressbook resources. On KDE |
1992 | // you do that through the control center !!! | 1992 | // you do that through the control center !!! |
1993 | mActionConfigResources->plug( settingsMenu ); | 1993 | mActionConfigResources->plug( settingsMenu ); |
1994 | settingsMenu->insertSeparator(); | 1994 | settingsMenu->insertSeparator(); |
1995 | 1995 | ||
1996 | mActionConfigKAddressbook->plug( settingsMenu ); | 1996 | mActionConfigKAddressbook->plug( settingsMenu ); |
1997 | 1997 | ||
1998 | if ( mIsPart ) { | 1998 | if ( mIsPart ) { |
1999 | mActionConfigShortcuts->plug( settingsMenu ); | 1999 | mActionConfigShortcuts->plug( settingsMenu ); |
2000 | mActionConfigureToolbars->plug( settingsMenu ); | 2000 | mActionConfigureToolbars->plug( settingsMenu ); |
2001 | 2001 | ||
2002 | } else { | 2002 | } else { |
2003 | mActionKeyBindings->plug( settingsMenu ); | 2003 | mActionKeyBindings->plug( settingsMenu ); |
2004 | } | 2004 | } |
2005 | 2005 | ||
2006 | settingsMenu->insertSeparator(); | 2006 | settingsMenu->insertSeparator(); |
2007 | 2007 | ||
2008 | mActionJumpBar->plug( settingsMenu ); | 2008 | mActionJumpBar->plug( settingsMenu ); |
2009 | mActionDetails->plug( settingsMenu ); | 2009 | mActionDetails->plug( settingsMenu ); |
2010 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2010 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2011 | mActionDetails->plug( tb ); | 2011 | mActionDetails->plug( tb ); |
2012 | settingsMenu->insertSeparator(); | 2012 | settingsMenu->insertSeparator(); |
2013 | 2013 | ||
2014 | mActionWhoAmI->plug( settingsMenu ); | 2014 | mActionWhoAmI->plug( settingsMenu ); |
2015 | mActionCategories->plug( settingsMenu ); | 2015 | mActionCategories->plug( settingsMenu ); |
2016 | 2016 | ||
2017 | mActionLicence->plug( helpMenu ); | 2017 | mActionLicence->plug( helpMenu ); |
2018 | mActionFaq->plug( helpMenu ); | 2018 | mActionFaq->plug( helpMenu ); |
2019 | mActionAboutKAddressbook->plug( helpMenu ); | 2019 | mActionAboutKAddressbook->plug( helpMenu ); |
2020 | 2020 | ||
2021 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2021 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2022 | 2022 | ||
2023 | mActionSave->plug( tb ); | 2023 | mActionSave->plug( tb ); |
2024 | mViewManager->getFilterAction()->plug ( tb); | 2024 | mViewManager->getFilterAction()->plug ( tb); |
2025 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2025 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2026 | mActionUndo->plug( tb ); | 2026 | mActionUndo->plug( tb ); |
2027 | mActionDelete->plug( tb ); | 2027 | mActionDelete->plug( tb ); |
2028 | mActionRedo->plug( tb ); | 2028 | mActionRedo->plug( tb ); |
2029 | } | 2029 | } |
2030 | } | 2030 | } |
2031 | //mActionQuit->plug ( tb ); | 2031 | //mActionQuit->plug ( tb ); |
2032 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2032 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2033 | 2033 | ||
2034 | //US link the searchwidget first to this. | 2034 | //US link the searchwidget first to this. |
2035 | // The real linkage to the toolbar happens later. | 2035 | // The real linkage to the toolbar happens later. |
2036 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2036 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2037 | //US tb->insertItem( mIncSearchWidget ); | 2037 | //US tb->insertItem( mIncSearchWidget ); |
2038 | /*US | 2038 | /*US |
2039 | mIncSearchWidget = new IncSearchWidget( tb ); | 2039 | mIncSearchWidget = new IncSearchWidget( tb ); |
2040 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2040 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2041 | SLOT( incrementalSearch( const QString& ) ) ); | 2041 | SLOT( incrementalSearch( const QString& ) ) ); |
2042 | 2042 | ||
2043 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2043 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2044 | 2044 | ||
2045 | //US topLayout->addWidget( mJumpButtonBar ); | 2045 | //US topLayout->addWidget( mJumpButtonBar ); |
2046 | this->layout()->add( mJumpButtonBar ); | 2046 | this->layout()->add( mJumpButtonBar ); |
2047 | */ | 2047 | */ |
2048 | 2048 | ||
2049 | #endif //KAB_EMBEDDED | 2049 | #endif //KAB_EMBEDDED |
2050 | 2050 | ||
2051 | mActionExport2phone->plug( ExportMenu ); | 2051 | mActionExport2phone->plug( ExportMenu ); |
2052 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2052 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2053 | syncManager->fillSyncMenu(); | 2053 | syncManager->fillSyncMenu(); |
2054 | 2054 | ||
2055 | } | 2055 | } |
2056 | void KABCore::showLicence() | 2056 | void KABCore::showLicence() |
2057 | { | 2057 | { |
2058 | KApplication::showLicence(); | 2058 | KApplication::showLicence(); |
2059 | } | 2059 | } |
2060 | void KABCore::removeVoice() | 2060 | void KABCore::removeVoice() |
2061 | { | 2061 | { |
2062 | 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 ) | 2062 | 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 ) |
2063 | return; | 2063 | return; |
2064 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2064 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2065 | KABC::Addressee::List::Iterator it; | 2065 | KABC::Addressee::List::Iterator it; |
2066 | for ( it = list.begin(); it != list.end(); ++it ) { | 2066 | for ( it = list.begin(); it != list.end(); ++it ) { |
2067 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 2067 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
2068 | PhoneNumber::List::Iterator phoneIt; | 2068 | PhoneNumber::List::Iterator phoneIt; |
2069 | bool found = false; | 2069 | bool found = false; |
2070 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 2070 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
2071 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 2071 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
2072 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 2072 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
2073 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 2073 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
2074 | (*it).insertPhoneNumber( (*phoneIt) ); | 2074 | (*it).insertPhoneNumber( (*phoneIt) ); |
2075 | found = true; | 2075 | found = true; |
2076 | } | 2076 | } |
2077 | } | 2077 | } |
2078 | 2078 | ||
2079 | } | 2079 | } |
2080 | if ( found ) | 2080 | if ( found ) |
2081 | contactModified((*it) ); | 2081 | contactModified((*it) ); |
2082 | } | 2082 | } |
2083 | } | 2083 | } |
2084 | 2084 | ||
2085 | 2085 | ||
2086 | 2086 | ||
2087 | void KABCore::clipboardDataChanged() | 2087 | void KABCore::clipboardDataChanged() |
2088 | { | 2088 | { |
2089 | 2089 | ||
2090 | if ( mReadWrite ) | 2090 | if ( mReadWrite ) |
2091 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2091 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2092 | 2092 | ||
2093 | } | 2093 | } |
2094 | 2094 | ||
2095 | void KABCore::updateActionMenu() | 2095 | void KABCore::updateActionMenu() |
2096 | { | 2096 | { |
2097 | UndoStack *undo = UndoStack::instance(); | 2097 | UndoStack *undo = UndoStack::instance(); |
2098 | RedoStack *redo = RedoStack::instance(); | 2098 | RedoStack *redo = RedoStack::instance(); |
2099 | 2099 | ||
2100 | if ( undo->isEmpty() ) | 2100 | if ( undo->isEmpty() ) |
2101 | mActionUndo->setText( i18n( "Undo" ) ); | 2101 | mActionUndo->setText( i18n( "Undo" ) ); |
2102 | else | 2102 | else |
2103 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2103 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2104 | 2104 | ||
2105 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2105 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2106 | 2106 | ||
2107 | if ( !redo->top() ) | 2107 | if ( !redo->top() ) |
2108 | mActionRedo->setText( i18n( "Redo" ) ); | 2108 | mActionRedo->setText( i18n( "Redo" ) ); |
2109 | else | 2109 | else |
2110 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2110 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2111 | 2111 | ||
2112 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2112 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2113 | } | 2113 | } |
2114 | 2114 | ||
2115 | void KABCore::configureKeyBindings() | 2115 | void KABCore::configureKeyBindings() |
2116 | { | 2116 | { |
2117 | #ifndef KAB_EMBEDDED | 2117 | #ifndef KAB_EMBEDDED |
2118 | KKeyDialog::configure( actionCollection(), true ); | 2118 | KKeyDialog::configure( actionCollection(), true ); |
2119 | #else //KAB_EMBEDDED | 2119 | #else //KAB_EMBEDDED |
2120 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2120 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2121 | #endif //KAB_EMBEDDED | 2121 | #endif //KAB_EMBEDDED |
2122 | } | 2122 | } |
2123 | 2123 | ||
2124 | #ifdef KAB_EMBEDDED | 2124 | #ifdef KAB_EMBEDDED |
2125 | void KABCore::configureResources() | 2125 | void KABCore::configureResources() |
2126 | { | 2126 | { |
2127 | KRES::KCMKResources dlg( this, "" , 0 ); | 2127 | KRES::KCMKResources dlg( this, "" , 0 ); |
2128 | 2128 | ||
2129 | if ( !dlg.exec() ) | 2129 | if ( !dlg.exec() ) |
2130 | return; | 2130 | return; |
2131 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2131 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2132 | } | 2132 | } |
2133 | #endif //KAB_EMBEDDED | 2133 | #endif //KAB_EMBEDDED |
2134 | 2134 | ||
2135 | 2135 | ||
2136 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2136 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2137 | * for the attendees list of an event. | 2137 | * for the attendees list of an event. |
2138 | */ | 2138 | */ |
2139 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2139 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2140 | { | 2140 | { |
2141 | QStringList nameList; | 2141 | QStringList nameList; |
2142 | QStringList emailList; | 2142 | QStringList emailList; |
2143 | QStringList uidList; | 2143 | QStringList uidList; |
2144 | 2144 | ||
2145 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2145 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2146 | uint i=0; | 2146 | uint i=0; |
2147 | for (i=0; i < list.count(); i++) | 2147 | for (i=0; i < list.count(); i++) |
2148 | { | 2148 | { |
2149 | nameList.append(list[i].realName()); | 2149 | nameList.append(list[i].realName()); |
2150 | emailList.append(list[i].preferredEmail()); | 2150 | emailList.append(list[i].preferredEmail()); |
2151 | uidList.append(list[i].uid()); | 2151 | uidList.append(list[i].uid()); |
2152 | } | 2152 | } |
2153 | 2153 | ||
2154 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2154 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2155 | 2155 | ||
2156 | } | 2156 | } |
2157 | 2157 | ||
2158 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2158 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2159 | */ | 2159 | */ |
2160 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2160 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2161 | { | 2161 | { |
2162 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2162 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2163 | 2163 | ||
2164 | QString foundUid = QString::null; | 2164 | QString foundUid = QString::null; |
2165 | if ( ! uid.isEmpty() ) { | 2165 | if ( ! uid.isEmpty() ) { |
2166 | Addressee adrr = mAddressBook->findByUid( uid ); | 2166 | Addressee adrr = mAddressBook->findByUid( uid ); |
2167 | if ( !adrr.isEmpty() ) { | 2167 | if ( !adrr.isEmpty() ) { |
2168 | foundUid = uid; | 2168 | foundUid = uid; |
2169 | } | 2169 | } |
2170 | if ( email == "sendbacklist" ) { | 2170 | if ( email == "sendbacklist" ) { |
2171 | //qDebug("ssssssssssssssssssssssend "); | 2171 | //qDebug("ssssssssssssssssssssssend "); |
2172 | QStringList nameList; | 2172 | QStringList nameList; |
2173 | QStringList emailList; | 2173 | QStringList emailList; |
2174 | QStringList uidList; | 2174 | QStringList uidList; |
2175 | nameList.append(adrr.realName()); | 2175 | nameList.append(adrr.realName()); |
2176 | emailList = adrr.emails(); | 2176 | emailList = adrr.emails(); |
2177 | uidList.append( adrr.preferredEmail()); | 2177 | uidList.append( adrr.preferredEmail()); |
2178 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2178 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2179 | return; | 2179 | return; |
2180 | } | 2180 | } |
2181 | 2181 | ||
2182 | } | 2182 | } |
2183 | 2183 | ||
2184 | if ( email == "sendbacklist" ) | 2184 | if ( email == "sendbacklist" ) |
2185 | return; | 2185 | return; |
2186 | if (foundUid.isEmpty()) | 2186 | if (foundUid.isEmpty()) |
2187 | { | 2187 | { |
2188 | //find the uid of the person first | 2188 | //find the uid of the person first |
2189 | Addressee::List namelist; | 2189 | Addressee::List namelist; |
2190 | Addressee::List emaillist; | 2190 | Addressee::List emaillist; |
2191 | 2191 | ||
2192 | if (!name.isEmpty()) | 2192 | if (!name.isEmpty()) |
2193 | namelist = mAddressBook->findByName( name ); | 2193 | namelist = mAddressBook->findByName( name ); |
2194 | 2194 | ||
2195 | if (!email.isEmpty()) | 2195 | if (!email.isEmpty()) |
2196 | emaillist = mAddressBook->findByEmail( email ); | 2196 | emaillist = mAddressBook->findByEmail( email ); |
2197 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2197 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2198 | //check if we have a match in Namelist and Emaillist | 2198 | //check if we have a match in Namelist and Emaillist |
2199 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2199 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2200 | foundUid = emaillist[0].uid(); | 2200 | foundUid = emaillist[0].uid(); |
2201 | } | 2201 | } |
2202 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2202 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2203 | foundUid = namelist[0].uid(); | 2203 | foundUid = namelist[0].uid(); |
2204 | else | 2204 | else |
2205 | { | 2205 | { |
2206 | for (int i = 0; i < namelist.count(); i++) | 2206 | for (int i = 0; i < namelist.count(); i++) |
2207 | { | 2207 | { |
2208 | for (int j = 0; j < emaillist.count(); j++) | 2208 | for (int j = 0; j < emaillist.count(); j++) |
2209 | { | 2209 | { |
2210 | if (namelist[i] == emaillist[j]) | 2210 | if (namelist[i] == emaillist[j]) |
2211 | { | 2211 | { |
2212 | foundUid = namelist[i].uid(); | 2212 | foundUid = namelist[i].uid(); |
2213 | } | 2213 | } |
2214 | } | 2214 | } |
2215 | } | 2215 | } |
2216 | } | 2216 | } |
2217 | } | 2217 | } |
2218 | else | 2218 | else |
2219 | { | 2219 | { |
2220 | foundUid = uid; | 2220 | foundUid = uid; |
2221 | } | 2221 | } |
2222 | 2222 | ||
2223 | if (!foundUid.isEmpty()) | 2223 | if (!foundUid.isEmpty()) |
2224 | { | 2224 | { |
2225 | 2225 | ||
2226 | // raise Ka/Pi if it is in the background | 2226 | // raise Ka/Pi if it is in the background |
2227 | #ifndef DESKTOP_VERSION | 2227 | #ifndef DESKTOP_VERSION |
2228 | #ifndef KORG_NODCOP | 2228 | #ifndef KORG_NODCOP |
2229 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2229 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2230 | #endif | 2230 | #endif |
2231 | #endif | 2231 | #endif |
2232 | 2232 | ||
2233 | mMainWindow->showMaximized(); | 2233 | mMainWindow->showMaximized(); |
2234 | mMainWindow-> raise(); | 2234 | mMainWindow-> raise(); |
2235 | 2235 | ||
2236 | mViewManager->setSelected( "", false); | 2236 | mViewManager->setSelected( "", false); |
2237 | mViewManager->refreshView( "" ); | 2237 | mViewManager->refreshView( "" ); |
2238 | mViewManager->setSelected( foundUid, true ); | 2238 | mViewManager->setSelected( foundUid, true ); |
2239 | mViewManager->refreshView( foundUid ); | 2239 | mViewManager->refreshView( foundUid ); |
2240 | 2240 | ||
2241 | if ( !mMultipleViewsAtOnce ) | 2241 | if ( !mMultipleViewsAtOnce ) |
2242 | { | 2242 | { |
2243 | setDetailsVisible( true ); | 2243 | setDetailsVisible( true ); |
2244 | mActionDetails->setChecked(true); | 2244 | mActionDetails->setChecked(true); |
2245 | } | 2245 | } |
2246 | } | 2246 | } |
2247 | } | 2247 | } |
2248 | 2248 | ||
2249 | 2249 | ||
2250 | void KABCore::faq() | 2250 | void KABCore::faq() |
2251 | { | 2251 | { |
2252 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2252 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2253 | } | 2253 | } |
2254 | 2254 | ||
2255 | #include <libkcal/syncdefines.h> | 2255 | #include <libkcal/syncdefines.h> |
2256 | 2256 | ||
2257 | KABC::Addressee KABCore::getLastSyncAddressee() | 2257 | KABC::Addressee KABCore::getLastSyncAddressee() |
2258 | { | 2258 | { |
2259 | Addressee lse; | 2259 | Addressee lse; |
2260 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2260 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2261 | 2261 | ||
2262 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2262 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2263 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2263 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2264 | if (lse.isEmpty()) { | 2264 | if (lse.isEmpty()) { |
2265 | qDebug("Creating new last-syncAddressee "); | 2265 | qDebug("Creating new last-syncAddressee "); |
2266 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2266 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2267 | QString sum = ""; | 2267 | QString sum = ""; |
2268 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2268 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2269 | sum = "E: "; | 2269 | sum = "E: "; |
2270 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2270 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2271 | lse.setRevision( mLastAddressbookSync ); | 2271 | lse.setRevision( mLastAddressbookSync ); |
2272 | lse.setCategories( i18n("SyncEvent") ); | 2272 | lse.setCategories( i18n("SyncEvent") ); |
2273 | mAddressBook->insertAddressee( lse ); | 2273 | mAddressBook->insertAddressee( lse ); |
2274 | } | 2274 | } |
2275 | return lse; | 2275 | return lse; |
2276 | } | 2276 | } |
2277 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2277 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2278 | { | 2278 | { |
2279 | 2279 | ||
2280 | //void setZaurusId(int id); | 2280 | //void setZaurusId(int id); |
2281 | // int zaurusId() const; | 2281 | // int zaurusId() const; |
2282 | // void setZaurusUid(int id); | 2282 | // void setZaurusUid(int id); |
2283 | // int zaurusUid() const; | 2283 | // int zaurusUid() const; |
2284 | // void setZaurusStat(int id); | 2284 | // void setZaurusStat(int id); |
2285 | // int zaurusStat() const; | 2285 | // int zaurusStat() const; |
2286 | // 0 equal | 2286 | // 0 equal |
2287 | // 1 take local | 2287 | // 1 take local |
2288 | // 2 take remote | 2288 | // 2 take remote |
2289 | // 3 cancel | 2289 | // 3 cancel |
2290 | QDateTime lastSync = mLastAddressbookSync; | 2290 | QDateTime lastSync = mLastAddressbookSync; |
2291 | QDateTime localMod = local->revision(); | 2291 | QDateTime localMod = local->revision(); |
2292 | QDateTime remoteMod = remote->revision(); | 2292 | QDateTime remoteMod = remote->revision(); |
2293 | 2293 | ||
2294 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2294 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2295 | 2295 | ||
2296 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2296 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2297 | bool remCh, locCh; | 2297 | bool remCh, locCh; |
2298 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2298 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2299 | 2299 | ||
2300 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2300 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2301 | locCh = ( localMod > mLastAddressbookSync ); | 2301 | locCh = ( localMod > mLastAddressbookSync ); |
2302 | if ( !remCh && ! locCh ) { | 2302 | if ( !remCh && ! locCh ) { |
2303 | //qDebug("both not changed "); | 2303 | //qDebug("both not changed "); |
2304 | lastSync = localMod.addDays(1); | 2304 | lastSync = localMod.addDays(1); |
2305 | if ( mode <= SYNC_PREF_ASK ) | 2305 | if ( mode <= SYNC_PREF_ASK ) |
2306 | return 0; | 2306 | return 0; |
2307 | } else { | 2307 | } else { |
2308 | if ( locCh ) { | 2308 | if ( locCh ) { |
2309 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2309 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2310 | lastSync = localMod.addDays( -1 ); | 2310 | lastSync = localMod.addDays( -1 ); |
2311 | if ( !remCh ) | 2311 | if ( !remCh ) |
2312 | remoteMod =( lastSync.addDays( -1 ) ); | 2312 | remoteMod =( lastSync.addDays( -1 ) ); |
2313 | } else { | 2313 | } else { |
2314 | //qDebug(" not loc changed "); | 2314 | //qDebug(" not loc changed "); |
2315 | lastSync = localMod.addDays( 1 ); | 2315 | lastSync = localMod.addDays( 1 ); |
2316 | if ( remCh ) | 2316 | if ( remCh ) |
2317 | remoteMod =( lastSync.addDays( 1 ) ); | 2317 | remoteMod =( lastSync.addDays( 1 ) ); |
2318 | 2318 | ||
2319 | } | 2319 | } |
2320 | } | 2320 | } |
2321 | full = true; | 2321 | full = true; |
2322 | if ( mode < SYNC_PREF_ASK ) | 2322 | if ( mode < SYNC_PREF_ASK ) |
2323 | mode = SYNC_PREF_ASK; | 2323 | mode = SYNC_PREF_ASK; |
2324 | } else { | 2324 | } else { |
2325 | if ( localMod == remoteMod ) | 2325 | if ( localMod == remoteMod ) |
2326 | return 0; | 2326 | return 0; |
2327 | 2327 | ||
2328 | } | 2328 | } |
2329 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2329 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2330 | 2330 | ||
2331 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2331 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2332 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2332 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2333 | //full = true; //debug only | 2333 | //full = true; //debug only |
2334 | if ( full ) { | 2334 | if ( full ) { |
2335 | bool equ = ( (*local) == (*remote) ); | 2335 | bool equ = ( (*local) == (*remote) ); |
2336 | if ( equ ) { | 2336 | if ( equ ) { |
2337 | //qDebug("equal "); | 2337 | //qDebug("equal "); |
2338 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2338 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2339 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2339 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2340 | } | 2340 | } |
2341 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2341 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2342 | return 0; | 2342 | return 0; |
2343 | 2343 | ||
2344 | }//else //debug only | 2344 | }//else //debug only |
2345 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2345 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2346 | } | 2346 | } |
2347 | int result; | 2347 | int result; |
2348 | bool localIsNew; | 2348 | bool localIsNew; |
2349 | //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() ); | 2349 | //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() ); |
2350 | 2350 | ||
2351 | if ( full && mode < SYNC_PREF_NEWEST ) | 2351 | if ( full && mode < SYNC_PREF_NEWEST ) |
2352 | mode = SYNC_PREF_ASK; | 2352 | mode = SYNC_PREF_ASK; |
2353 | 2353 | ||
2354 | switch( mode ) { | 2354 | switch( mode ) { |
2355 | case SYNC_PREF_LOCAL: | 2355 | case SYNC_PREF_LOCAL: |
2356 | if ( lastSync > remoteMod ) | 2356 | if ( lastSync > remoteMod ) |
2357 | return 1; | 2357 | return 1; |
2358 | if ( lastSync > localMod ) | 2358 | if ( lastSync > localMod ) |
2359 | return 2; | 2359 | return 2; |
2360 | return 1; | 2360 | return 1; |
2361 | break; | 2361 | break; |
2362 | case SYNC_PREF_REMOTE: | 2362 | case SYNC_PREF_REMOTE: |
2363 | if ( lastSync > remoteMod ) | 2363 | if ( lastSync > remoteMod ) |
2364 | return 1; | 2364 | return 1; |
2365 | if ( lastSync > localMod ) | 2365 | if ( lastSync > localMod ) |
2366 | return 2; | 2366 | return 2; |
2367 | return 2; | 2367 | return 2; |
2368 | break; | 2368 | break; |
2369 | case SYNC_PREF_NEWEST: | 2369 | case SYNC_PREF_NEWEST: |
2370 | if ( localMod > remoteMod ) | 2370 | if ( localMod > remoteMod ) |
2371 | return 1; | 2371 | return 1; |
2372 | else | 2372 | else |
2373 | return 2; | 2373 | return 2; |
2374 | break; | 2374 | break; |
2375 | case SYNC_PREF_ASK: | 2375 | case SYNC_PREF_ASK: |
2376 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2376 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2377 | if ( lastSync > remoteMod ) | 2377 | if ( lastSync > remoteMod ) |
2378 | return 1; | 2378 | return 1; |
2379 | if ( lastSync > localMod ) | 2379 | if ( lastSync > localMod ) |
2380 | return 2; | 2380 | return 2; |
2381 | localIsNew = localMod >= remoteMod; | 2381 | localIsNew = localMod >= remoteMod; |
2382 | //qDebug("conflict! ************************************** "); | 2382 | //qDebug("conflict! ************************************** "); |
2383 | { | 2383 | { |
2384 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2384 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2385 | result = acd.executeD(localIsNew); | 2385 | result = acd.executeD(localIsNew); |
2386 | return result; | 2386 | return result; |
2387 | } | 2387 | } |
2388 | break; | 2388 | break; |
2389 | case SYNC_PREF_FORCE_LOCAL: | 2389 | case SYNC_PREF_FORCE_LOCAL: |
2390 | return 1; | 2390 | return 1; |
2391 | break; | 2391 | break; |
2392 | case SYNC_PREF_FORCE_REMOTE: | 2392 | case SYNC_PREF_FORCE_REMOTE: |
2393 | return 2; | 2393 | return 2; |
2394 | break; | 2394 | break; |
2395 | 2395 | ||
2396 | default: | 2396 | default: |
2397 | // SYNC_PREF_TAKE_BOTH not implemented | 2397 | // SYNC_PREF_TAKE_BOTH not implemented |
2398 | break; | 2398 | break; |
2399 | } | 2399 | } |
2400 | return 0; | 2400 | return 0; |
2401 | } | 2401 | } |
2402 | 2402 | ||
2403 | 2403 | ||
2404 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2404 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2405 | { | 2405 | { |
2406 | bool syncOK = true; | 2406 | bool syncOK = true; |
2407 | int addedAddressee = 0; | 2407 | int addedAddressee = 0; |
2408 | int addedAddresseeR = 0; | 2408 | int addedAddresseeR = 0; |
2409 | int deletedAddresseeR = 0; | 2409 | int deletedAddresseeR = 0; |
2410 | int deletedAddresseeL = 0; | 2410 | int deletedAddresseeL = 0; |
2411 | int changedLocal = 0; | 2411 | int changedLocal = 0; |
2412 | int changedRemote = 0; | 2412 | int changedRemote = 0; |
2413 | 2413 | ||
2414 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2414 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2415 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2415 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2416 | 2416 | ||
2417 | //QPtrList<Addressee> el = local->rawAddressees(); | 2417 | //QPtrList<Addressee> el = local->rawAddressees(); |
2418 | Addressee addresseeR; | 2418 | Addressee addresseeR; |
2419 | QString uid; | 2419 | QString uid; |
2420 | int take; | 2420 | int take; |
2421 | Addressee addresseeL; | 2421 | Addressee addresseeL; |
2422 | Addressee addresseeRSync; | 2422 | Addressee addresseeRSync; |
2423 | Addressee addresseeLSync; | 2423 | Addressee addresseeLSync; |
2424 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2424 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2425 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2425 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2426 | bool fullDateRange = false; | 2426 | bool fullDateRange = false; |
2427 | local->resetTempSyncStat(); | 2427 | local->resetTempSyncStat(); |
2428 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2428 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2429 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2429 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2430 | addresseeLSync = getLastSyncAddressee(); | 2430 | addresseeLSync = getLastSyncAddressee(); |
2431 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2431 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2432 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2432 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2433 | if ( !addresseeR.isEmpty() ) { | 2433 | if ( !addresseeR.isEmpty() ) { |
2434 | addresseeRSync = addresseeR; | 2434 | addresseeRSync = addresseeR; |
2435 | remote->removeAddressee(addresseeR ); | 2435 | remote->removeAddressee(addresseeR ); |
2436 | 2436 | ||
2437 | } else { | 2437 | } else { |
2438 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2438 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2439 | addresseeRSync = addresseeLSync ; | 2439 | addresseeRSync = addresseeLSync ; |
2440 | } else { | 2440 | } else { |
2441 | qDebug("FULLDATE 1"); | 2441 | qDebug("FULLDATE 1"); |
2442 | fullDateRange = true; | 2442 | fullDateRange = true; |
2443 | Addressee newAdd; | 2443 | Addressee newAdd; |
2444 | addresseeRSync = newAdd; | 2444 | addresseeRSync = newAdd; |
2445 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2445 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2446 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2446 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2447 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2447 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2448 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2448 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2449 | } | 2449 | } |
2450 | } | 2450 | } |
2451 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2451 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2452 | qDebug("FULLDATE 2"); | 2452 | qDebug("FULLDATE 2"); |
2453 | fullDateRange = true; | 2453 | fullDateRange = true; |
2454 | } | 2454 | } |
2455 | if ( ! fullDateRange ) { | 2455 | if ( ! fullDateRange ) { |
2456 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2456 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2457 | 2457 | ||
2458 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2458 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2459 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2459 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2460 | fullDateRange = true; | 2460 | fullDateRange = true; |
2461 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2461 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2462 | } | 2462 | } |
2463 | } | 2463 | } |
2464 | // fullDateRange = true; // debug only! | 2464 | // fullDateRange = true; // debug only! |
2465 | if ( fullDateRange ) | 2465 | if ( fullDateRange ) |
2466 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2466 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2467 | else | 2467 | else |
2468 | mLastAddressbookSync = addresseeLSync.revision(); | 2468 | mLastAddressbookSync = addresseeLSync.revision(); |
2469 | // for resyncing if own file has changed | 2469 | // for resyncing if own file has changed |
2470 | // PENDING fixme later when implemented | 2470 | // PENDING fixme later when implemented |
2471 | #if 0 | 2471 | #if 0 |
2472 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2472 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2473 | mLastAddressbookSync = loadedFileVersion; | 2473 | mLastAddressbookSync = loadedFileVersion; |
2474 | qDebug("setting mLastAddressbookSync "); | 2474 | qDebug("setting mLastAddressbookSync "); |
2475 | } | 2475 | } |
2476 | #endif | 2476 | #endif |
2477 | 2477 | ||
2478 | //qDebug("*************************** "); | 2478 | //qDebug("*************************** "); |
2479 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2479 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2480 | QStringList er = remote->uidList(); | 2480 | QStringList er = remote->uidList(); |
2481 | Addressee inR ;//= er.first(); | 2481 | Addressee inR ;//= er.first(); |
2482 | Addressee inL; | 2482 | Addressee inL; |
2483 | 2483 | ||
2484 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2484 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2485 | 2485 | ||
2486 | int modulo = (er.count()/10)+1; | 2486 | int modulo = (er.count()/10)+1; |
2487 | int incCounter = 0; | 2487 | int incCounter = 0; |
2488 | while ( incCounter < er.count()) { | 2488 | while ( incCounter < er.count()) { |
2489 | if (syncManager->isProgressBarCanceled()) | 2489 | if (syncManager->isProgressBarCanceled()) |
2490 | return false; | 2490 | return false; |
2491 | if ( incCounter % modulo == 0 ) | 2491 | if ( incCounter % modulo == 0 ) |
2492 | syncManager->showProgressBar(incCounter); | 2492 | syncManager->showProgressBar(incCounter); |
2493 | 2493 | ||
2494 | uid = er[ incCounter ]; | 2494 | uid = er[ incCounter ]; |
2495 | bool skipIncidence = false; | 2495 | bool skipIncidence = false; |
2496 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2496 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2497 | skipIncidence = true; | 2497 | skipIncidence = true; |
2498 | QString idS,OidS; | 2498 | QString idS,OidS; |
2499 | qApp->processEvents(); | 2499 | qApp->processEvents(); |
2500 | if ( !skipIncidence ) { | 2500 | if ( !skipIncidence ) { |
2501 | inL = local->findByUid( uid ); | 2501 | inL = local->findByUid( uid ); |
2502 | inR = remote->findByUid( uid ); | 2502 | inR = remote->findByUid( uid ); |
2503 | //inL.setResource( 0 ); | 2503 | //inL.setResource( 0 ); |
2504 | //inR.setResource( 0 ); | 2504 | //inR.setResource( 0 ); |
2505 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2505 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2506 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2506 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2507 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2507 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2508 | if ( take == 3 ) | 2508 | if ( take == 3 ) |
2509 | return false; | 2509 | return false; |
2510 | if ( take == 1 ) {// take local | 2510 | if ( take == 1 ) {// take local |
2511 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2511 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2512 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2512 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2513 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2513 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2514 | local->insertAddressee( inL, false ); | 2514 | local->insertAddressee( inL, false ); |
2515 | idS = inR.externalUID(); | 2515 | idS = inR.externalUID(); |
2516 | OidS = inR.originalExternalUID(); | 2516 | OidS = inR.originalExternalUID(); |
2517 | } | 2517 | } |
2518 | else | 2518 | else |
2519 | idS = inR.IDStr(); | 2519 | idS = inR.IDStr(); |
2520 | remote->removeAddressee( inR ); | 2520 | remote->removeAddressee( inR ); |
2521 | inR = inL; | 2521 | inR = inL; |
2522 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2522 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2523 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2523 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2524 | inR.setOriginalExternalUID( OidS ); | 2524 | inR.setOriginalExternalUID( OidS ); |
2525 | inR.setExternalUID( idS ); | 2525 | inR.setExternalUID( idS ); |
2526 | } else { | 2526 | } else { |
2527 | inR.setIDStr( idS ); | 2527 | inR.setIDStr( idS ); |
2528 | } | 2528 | } |
2529 | inR.setResource( 0 ); | 2529 | inR.setResource( 0 ); |
2530 | remote->insertAddressee( inR , false); | 2530 | remote->insertAddressee( inR , false); |
2531 | ++changedRemote; | 2531 | ++changedRemote; |
2532 | } else { // take == 2 take remote | 2532 | } else { // take == 2 take remote |
2533 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2533 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2534 | if ( inR.revision().date().year() < 2004 ) | 2534 | if ( inR.revision().date().year() < 2004 ) |
2535 | inR.setRevision( modifiedCalendar ); | 2535 | inR.setRevision( modifiedCalendar ); |
2536 | } | 2536 | } |
2537 | idS = inL.IDStr(); | 2537 | idS = inL.IDStr(); |
2538 | local->removeAddressee( inL ); | 2538 | local->removeAddressee( inL ); |
2539 | inL = inR; | 2539 | inL = inR; |
2540 | inL.setIDStr( idS ); | 2540 | inL.setIDStr( idS ); |
2541 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2541 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2542 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2542 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2543 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2543 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2544 | } | 2544 | } |
2545 | inL.setResource( 0 ); | 2545 | inL.setResource( 0 ); |
2546 | local->insertAddressee( inL , false ); | 2546 | local->insertAddressee( inL , false ); |
2547 | ++changedLocal; | 2547 | ++changedLocal; |
2548 | } | 2548 | } |
2549 | } | 2549 | } |
2550 | } else { // no conflict | 2550 | } else { // no conflict |
2551 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2551 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2552 | QString des = addresseeLSync.note(); | 2552 | QString des = addresseeLSync.note(); |
2553 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2553 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2554 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2554 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2555 | remote->insertAddressee( inR, false ); | 2555 | remote->insertAddressee( inR, false ); |
2556 | ++deletedAddresseeR; | 2556 | ++deletedAddresseeR; |
2557 | } else { | 2557 | } else { |
2558 | inR.setRevision( modifiedCalendar ); | 2558 | inR.setRevision( modifiedCalendar ); |
2559 | remote->insertAddressee( inR, false ); | 2559 | remote->insertAddressee( inR, false ); |
2560 | inL = inR; | 2560 | inL = inR; |
2561 | inL.setResource( 0 ); | 2561 | inL.setResource( 0 ); |
2562 | local->insertAddressee( inL , false); | 2562 | local->insertAddressee( inL , false); |
2563 | ++addedAddressee; | 2563 | ++addedAddressee; |
2564 | } | 2564 | } |
2565 | } else { | 2565 | } else { |
2566 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2566 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2567 | inR.setRevision( modifiedCalendar ); | 2567 | inR.setRevision( modifiedCalendar ); |
2568 | remote->insertAddressee( inR, false ); | 2568 | remote->insertAddressee( inR, false ); |
2569 | inR.setResource( 0 ); | 2569 | inR.setResource( 0 ); |
2570 | local->insertAddressee( inR, false ); | 2570 | local->insertAddressee( inR, false ); |
2571 | ++addedAddressee; | 2571 | ++addedAddressee; |
2572 | } else { | 2572 | } else { |
2573 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2573 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2574 | remote->removeAddressee( inR ); | 2574 | remote->removeAddressee( inR ); |
2575 | ++deletedAddresseeR; | 2575 | ++deletedAddresseeR; |
2576 | } | 2576 | } |
2577 | } | 2577 | } |
2578 | } | 2578 | } |
2579 | } | 2579 | } |
2580 | ++incCounter; | 2580 | ++incCounter; |
2581 | } | 2581 | } |
2582 | er.clear(); | 2582 | er.clear(); |
2583 | QStringList el = local->uidList(); | 2583 | QStringList el = local->uidList(); |
2584 | modulo = (el.count()/10)+1; | 2584 | modulo = (el.count()/10)+1; |
2585 | 2585 | ||
2586 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2586 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2587 | incCounter = 0; | 2587 | incCounter = 0; |
2588 | while ( incCounter < el.count()) { | 2588 | while ( incCounter < el.count()) { |
2589 | qApp->processEvents(); | 2589 | qApp->processEvents(); |
2590 | if (syncManager->isProgressBarCanceled()) | 2590 | if (syncManager->isProgressBarCanceled()) |
2591 | return false; | 2591 | return false; |
2592 | if ( incCounter % modulo == 0 ) | 2592 | if ( incCounter % modulo == 0 ) |
2593 | syncManager->showProgressBar(incCounter); | 2593 | syncManager->showProgressBar(incCounter); |
2594 | uid = el[ incCounter ]; | 2594 | uid = el[ incCounter ]; |
2595 | bool skipIncidence = false; | 2595 | bool skipIncidence = false; |
2596 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2596 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2597 | skipIncidence = true; | 2597 | skipIncidence = true; |
2598 | if ( !skipIncidence ) { | 2598 | if ( !skipIncidence ) { |
2599 | inL = local->findByUid( uid ); | 2599 | inL = local->findByUid( uid ); |
2600 | inR = remote->findByUid( uid ); | 2600 | inR = remote->findByUid( uid ); |
2601 | if ( inR.isEmpty() ) { | 2601 | if ( inR.isEmpty() ) { |
2602 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2602 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2603 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2603 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2604 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2604 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2605 | local->removeAddressee( inL ); | 2605 | local->removeAddressee( inL ); |
2606 | ++deletedAddresseeL; | 2606 | ++deletedAddresseeL; |
2607 | } else { | 2607 | } else { |
2608 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2608 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2609 | inL.removeID(mCurrentSyncDevice ); | 2609 | inL.removeID(mCurrentSyncDevice ); |
2610 | ++addedAddresseeR; | 2610 | ++addedAddresseeR; |
2611 | inL.setRevision( modifiedCalendar ); | 2611 | inL.setRevision( modifiedCalendar ); |
2612 | local->insertAddressee( inL, false ); | 2612 | local->insertAddressee( inL, false ); |
2613 | inR = inL; | 2613 | inR = inL; |
2614 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2614 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2615 | inR.setResource( 0 ); | 2615 | inR.setResource( 0 ); |
2616 | remote->insertAddressee( inR, false ); | 2616 | remote->insertAddressee( inR, false ); |
2617 | } | 2617 | } |
2618 | } | 2618 | } |
2619 | } else { | 2619 | } else { |
2620 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2620 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2621 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2621 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2622 | local->removeAddressee( inL ); | 2622 | local->removeAddressee( inL ); |
2623 | ++deletedAddresseeL; | 2623 | ++deletedAddresseeL; |
2624 | } else { | 2624 | } else { |
2625 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2625 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2626 | ++addedAddresseeR; | 2626 | ++addedAddresseeR; |
2627 | inL.setRevision( modifiedCalendar ); | 2627 | inL.setRevision( modifiedCalendar ); |
2628 | local->insertAddressee( inL, false ); | 2628 | local->insertAddressee( inL, false ); |
2629 | inR = inL; | 2629 | inR = inL; |
2630 | inR.setResource( 0 ); | 2630 | inR.setResource( 0 ); |
2631 | remote->insertAddressee( inR, false ); | 2631 | remote->insertAddressee( inR, false ); |
2632 | } | 2632 | } |
2633 | } | 2633 | } |
2634 | } | 2634 | } |
2635 | } | 2635 | } |
2636 | } | 2636 | } |
2637 | ++incCounter; | 2637 | ++incCounter; |
2638 | } | 2638 | } |
2639 | el.clear(); | 2639 | el.clear(); |
2640 | syncManager->hideProgressBar(); | 2640 | syncManager->hideProgressBar(); |
2641 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2641 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2642 | // get rid of micro seconds | 2642 | // get rid of micro seconds |
2643 | QTime t = mLastAddressbookSync.time(); | 2643 | QTime t = mLastAddressbookSync.time(); |
2644 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2644 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2645 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2645 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2646 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2646 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2647 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2647 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2648 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2648 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2649 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2649 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2650 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2650 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2651 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2651 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2652 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2652 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2653 | addresseeRSync.setNote( "" ) ; | 2653 | addresseeRSync.setNote( "" ) ; |
2654 | addresseeLSync.setNote( "" ); | 2654 | addresseeLSync.setNote( "" ); |
2655 | 2655 | ||
2656 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2656 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2657 | remote->insertAddressee( addresseeRSync, false ); | 2657 | remote->insertAddressee( addresseeRSync, false ); |
2658 | local->insertAddressee( addresseeLSync, false ); | 2658 | local->insertAddressee( addresseeLSync, false ); |
2659 | QString mes; | 2659 | QString mes; |
2660 | 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 ); | 2660 | 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 ); |
2661 | if ( KABPrefs::instance()->mShowSyncSummary ) { | 2661 | if ( syncManager->mShowSyncSummary ) { |
2662 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2662 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2663 | } | 2663 | } |
2664 | qDebug( mes ); | 2664 | qDebug( mes ); |
2665 | return syncOK; | 2665 | return syncOK; |
2666 | } | 2666 | } |
2667 | 2667 | ||
2668 | 2668 | ||
2669 | //this is a overwritten callbackmethods from the syncinterface | 2669 | //this is a overwritten callbackmethods from the syncinterface |
2670 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2670 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2671 | { | 2671 | { |
2672 | 2672 | ||
2673 | //pending prepare addresseeview for output | 2673 | //pending prepare addresseeview for output |
2674 | //pending detect, if remote file has REV field. if not switch to external sync | 2674 | //pending detect, if remote file has REV field. if not switch to external sync |
2675 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2675 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2676 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2676 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2677 | 2677 | ||
2678 | AddressBook abLocal(filename,"syncContact"); | 2678 | AddressBook abLocal(filename,"syncContact"); |
2679 | bool syncOK = false; | 2679 | bool syncOK = false; |
2680 | if ( abLocal.load() ) { | 2680 | if ( abLocal.load() ) { |
2681 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2681 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2682 | bool external = false; | 2682 | bool external = false; |
2683 | bool isXML = false; | 2683 | bool isXML = false; |
2684 | if ( filename.right(4) == ".xml") { | 2684 | if ( filename.right(4) == ".xml") { |
2685 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2685 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2686 | isXML = true; | 2686 | isXML = true; |
2687 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2687 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2688 | } else { | 2688 | } else { |
2689 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2689 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2690 | if ( ! lse.isEmpty() ) { | 2690 | if ( ! lse.isEmpty() ) { |
2691 | if ( lse.familyName().left(4) == "!E: " ) | 2691 | if ( lse.familyName().left(4) == "!E: " ) |
2692 | external = true; | 2692 | external = true; |
2693 | } else { | 2693 | } else { |
2694 | bool found = false; | 2694 | bool found = false; |
2695 | AddressBook::Iterator it; | 2695 | AddressBook::Iterator it; |
2696 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2696 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2697 | if ( (*it).revision().date().year() > 2003 ) { | 2697 | if ( (*it).revision().date().year() > 2003 ) { |
2698 | found = true; | 2698 | found = true; |
2699 | break; | 2699 | break; |
2700 | } | 2700 | } |
2701 | } | 2701 | } |
2702 | external = ! found; | 2702 | external = ! found; |
2703 | } | 2703 | } |
2704 | 2704 | ||
2705 | if ( external ) { | 2705 | if ( external ) { |
2706 | qDebug("Setting vcf mode to external "); | 2706 | qDebug("Setting vcf mode to external "); |
2707 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2707 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2708 | AddressBook::Iterator it; | 2708 | AddressBook::Iterator it; |
2709 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2709 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2710 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2710 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2711 | (*it).computeCsum( mCurrentSyncDevice ); | 2711 | (*it).computeCsum( mCurrentSyncDevice ); |
2712 | } | 2712 | } |
2713 | } | 2713 | } |
2714 | } | 2714 | } |
2715 | //AddressBook::Iterator it; | 2715 | //AddressBook::Iterator it; |
2716 | //QStringList vcards; | 2716 | //QStringList vcards; |
2717 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2717 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2718 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2718 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2719 | //} | 2719 | //} |
2720 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2720 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2721 | if ( syncOK ) { | 2721 | if ( syncOK ) { |
2722 | if ( KABPrefs::instance()->mWriteBackFile ) | 2722 | if ( syncManager->mWriteBackFile ) |
2723 | { | 2723 | { |
2724 | if ( external ) | 2724 | if ( external ) |
2725 | abLocal.removeSyncAddressees( !isXML); | 2725 | abLocal.removeSyncAddressees( !isXML); |
2726 | qDebug("Saving remote AB "); | 2726 | qDebug("Saving remote AB "); |
2727 | abLocal.saveAB(); | 2727 | abLocal.saveAB(); |
2728 | if ( isXML ) { | 2728 | if ( isXML ) { |
2729 | // afterwrite processing | 2729 | // afterwrite processing |
2730 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2730 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2731 | } | 2731 | } |
2732 | } | 2732 | } |
2733 | } | 2733 | } |
2734 | setModified(); | 2734 | setModified(); |
2735 | 2735 | ||
2736 | } | 2736 | } |
2737 | if ( syncOK ) | 2737 | if ( syncOK ) |
2738 | mViewManager->refreshView(); | 2738 | mViewManager->refreshView(); |
2739 | return syncOK; | 2739 | return syncOK; |
2740 | #if 0 | 2740 | #if 0 |
2741 | 2741 | ||
2742 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2742 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2743 | getEventViewerDialog()->setSyncMode( true ); | 2743 | getEventViewerDialog()->setSyncMode( true ); |
2744 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2744 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2745 | getEventViewerDialog()->setSyncMode( false ); | 2745 | getEventViewerDialog()->setSyncMode( false ); |
2746 | if ( syncOK ) { | 2746 | if ( syncOK ) { |
2747 | if ( KOPrefs::instance()->mWriteBackFile ) | 2747 | if ( KOPrefs::instance()->mWriteBackFile ) |
2748 | { | 2748 | { |
2749 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2749 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2750 | storage->save(); | 2750 | storage->save(); |
2751 | } | 2751 | } |
2752 | } | 2752 | } |
2753 | setModified(); | 2753 | setModified(); |
2754 | } | 2754 | } |
2755 | 2755 | ||
2756 | #endif | 2756 | #endif |
2757 | } | 2757 | } |
2758 | 2758 | ||
2759 | 2759 | ||
2760 | //this is a overwritten callbackmethods from the syncinterface | 2760 | //this is a overwritten callbackmethods from the syncinterface |
2761 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2761 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2762 | { | 2762 | { |
2763 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2763 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2764 | 2764 | ||
2765 | AddressBook abLocal( resource,"syncContact"); | 2765 | AddressBook abLocal( resource,"syncContact"); |
2766 | bool syncOK = false; | 2766 | bool syncOK = false; |
2767 | if ( abLocal.load() ) { | 2767 | if ( abLocal.load() ) { |
2768 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2768 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2769 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2769 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2770 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2770 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2771 | qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? "); | 2771 | qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? "); |
2772 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs ); | 2772 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2773 | if ( syncOK ) { | 2773 | if ( syncOK ) { |
2774 | if ( KABPrefs::instance()->mWriteBackFile ) { | 2774 | if ( syncManager->mWriteBackFile ) { |
2775 | abLocal.saveAB(); | 2775 | abLocal.saveAB(); |
2776 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2776 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2777 | } | 2777 | } |
2778 | } | 2778 | } |
2779 | setModified(); | 2779 | setModified(); |
2780 | } | 2780 | } |
2781 | if ( syncOK ) | 2781 | if ( syncOK ) |
2782 | mViewManager->refreshView(); | 2782 | mViewManager->refreshView(); |
2783 | return syncOK; | 2783 | return syncOK; |
2784 | 2784 | ||
2785 | } | 2785 | } |
2786 | 2786 | ||
2787 | //called by the syncmanager to indicate that the work has to marked as dirty. | 2787 | //called by the syncmanager to indicate that the work has to marked as dirty. |
2788 | void KABCore::sync_setModified() | 2788 | void KABCore::sync_setModified() |
2789 | { | 2789 | { |
2790 | setModified(); | 2790 | setModified(); |
2791 | } | 2791 | } |
2792 | 2792 | ||
2793 | //called by the syncmanager to ask if the dirty flag is set. | 2793 | //called by the syncmanager to ask if the dirty flag is set. |
2794 | bool KABCore::sync_isModified() | 2794 | bool KABCore::sync_isModified() |
2795 | { | 2795 | { |
2796 | return mModified; | 2796 | return mModified; |
2797 | } | 2797 | } |
2798 | 2798 | ||
2799 | 2799 | ||
2800 | //called by the syncmanager to indicate that the work has to be saved. | 2800 | //called by the syncmanager to indicate that the work has to be saved. |
2801 | void KABCore::sync_save() | 2801 | void KABCore::sync_save() |
2802 | { | 2802 | { |
2803 | save(); | 2803 | save(); |
2804 | } | 2804 | } |
2805 | 2805 | ||
2806 | 2806 | ||
2807 | 2807 | ||
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 38b55f7..1de2759 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,2430 +1,2416 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #endif | 86 | #endif |
87 | #include <libkcal/phoneformat.h> | 87 | #include <libkcal/phoneformat.h> |
88 | #ifndef KORG_NOMAIL | 88 | #ifndef KORG_NOMAIL |
89 | #include "komailclient.h" | 89 | #include "komailclient.h" |
90 | #endif | 90 | #endif |
91 | #ifndef KORG_NOPRINTER | 91 | #ifndef KORG_NOPRINTER |
92 | #include "calprinter.h" | 92 | #include "calprinter.h" |
93 | #endif | 93 | #endif |
94 | #ifndef KORG_NOPLUGINS | 94 | #ifndef KORG_NOPLUGINS |
95 | #include "kocore.h" | 95 | #include "kocore.h" |
96 | #endif | 96 | #endif |
97 | #include "koeventeditor.h" | 97 | #include "koeventeditor.h" |
98 | #include "kotodoeditor.h" | 98 | #include "kotodoeditor.h" |
99 | #include "koprefs.h" | 99 | #include "koprefs.h" |
100 | #include "koeventviewerdialog.h" | 100 | #include "koeventviewerdialog.h" |
101 | #include "publishdialog.h" | 101 | #include "publishdialog.h" |
102 | #include "kofilterview.h" | 102 | #include "kofilterview.h" |
103 | #include "koglobals.h" | 103 | #include "koglobals.h" |
104 | #include "koviewmanager.h" | 104 | #include "koviewmanager.h" |
105 | #include "koagendaview.h" | 105 | #include "koagendaview.h" |
106 | #include "kodialogmanager.h" | 106 | #include "kodialogmanager.h" |
107 | #include "outgoingdialog.h" | 107 | #include "outgoingdialog.h" |
108 | #include "incomingdialog.h" | 108 | #include "incomingdialog.h" |
109 | #include "statusdialog.h" | 109 | #include "statusdialog.h" |
110 | #include "kdatenavigator.h" | 110 | #include "kdatenavigator.h" |
111 | #include "kotodoview.h" | 111 | #include "kotodoview.h" |
112 | #include "datenavigator.h" | 112 | #include "datenavigator.h" |
113 | #include "resourceview.h" | 113 | #include "resourceview.h" |
114 | #include "navigatorbar.h" | 114 | #include "navigatorbar.h" |
115 | #include "searchdialog.h" | 115 | #include "searchdialog.h" |
116 | #include "mainwindow.h" | 116 | #include "mainwindow.h" |
117 | 117 | ||
118 | #include "calendarview.h" | 118 | #include "calendarview.h" |
119 | #ifndef DESKTOP_VERSION | 119 | #ifndef DESKTOP_VERSION |
120 | #include <qtopia/alarmserver.h> | 120 | #include <qtopia/alarmserver.h> |
121 | #endif | 121 | #endif |
122 | #ifndef _WIN32_ | 122 | #ifndef _WIN32_ |
123 | #include <stdlib.h> | 123 | #include <stdlib.h> |
124 | #include <stdio.h> | 124 | #include <stdio.h> |
125 | #include <unistd.h> | 125 | #include <unistd.h> |
126 | #else | 126 | #else |
127 | #include <qprocess.h> | 127 | #include <qprocess.h> |
128 | #endif | 128 | #endif |
129 | using namespace KOrg; | 129 | using namespace KOrg; |
130 | using namespace KCal; | 130 | using namespace KCal; |
131 | extern int globalFlagBlockAgenda; | 131 | extern int globalFlagBlockAgenda; |
132 | extern int globalFlagBlockStartup; | 132 | extern int globalFlagBlockStartup; |
133 | 133 | ||
134 | 134 | ||
135 | 135 | ||
136 | class KOBeamPrefs : public QDialog | 136 | class KOBeamPrefs : public QDialog |
137 | { | 137 | { |
138 | public: | 138 | public: |
139 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 139 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
140 | QDialog( parent, name, true ) | 140 | QDialog( parent, name, true ) |
141 | { | 141 | { |
142 | setCaption( i18n("Beam Options") ); | 142 | setCaption( i18n("Beam Options") ); |
143 | QVBoxLayout* lay = new QVBoxLayout( this ); | 143 | QVBoxLayout* lay = new QVBoxLayout( this ); |
144 | lay->setSpacing( 3 ); | 144 | lay->setSpacing( 3 ); |
145 | lay->setMargin( 3 ); | 145 | lay->setMargin( 3 ); |
146 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 146 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
147 | lay->addWidget( format ); | 147 | lay->addWidget( format ); |
148 | format->setExclusive ( true ) ; | 148 | format->setExclusive ( true ) ; |
149 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 149 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
150 | lay->addWidget( time ); time->setExclusive ( true ) ; | 150 | lay->addWidget( time ); time->setExclusive ( true ) ; |
151 | vcal = new QRadioButton(" vCalendar ", format ); | 151 | vcal = new QRadioButton(" vCalendar ", format ); |
152 | ical = new QRadioButton(" iCalendar ", format ); | 152 | ical = new QRadioButton(" iCalendar ", format ); |
153 | vcal->setChecked( true ); | 153 | vcal->setChecked( true ); |
154 | tz = new QRadioButton(i18n(" With timezone "), time ); | 154 | tz = new QRadioButton(i18n(" With timezone "), time ); |
155 | local = new QRadioButton(i18n(" Local time "), time ); | 155 | local = new QRadioButton(i18n(" Local time "), time ); |
156 | tz->setChecked( true ); | 156 | tz->setChecked( true ); |
157 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 157 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
158 | lay->addWidget( ok ); | 158 | lay->addWidget( ok ); |
159 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 159 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
160 | lay->addWidget( cancel ); | 160 | lay->addWidget( cancel ); |
161 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 161 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
162 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 162 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
163 | resize( 200, 200 ); | 163 | resize( 200, 200 ); |
164 | } | 164 | } |
165 | 165 | ||
166 | bool beamVcal() { return vcal->isChecked(); } | 166 | bool beamVcal() { return vcal->isChecked(); } |
167 | bool beamLocal() { return local->isChecked(); } | 167 | bool beamLocal() { return local->isChecked(); } |
168 | private: | 168 | private: |
169 | QRadioButton* vcal, *ical, *local, *tz; | 169 | QRadioButton* vcal, *ical, *local, *tz; |
170 | }; | 170 | }; |
171 | class KOCatPrefs : public QDialog | 171 | class KOCatPrefs : public QDialog |
172 | { | 172 | { |
173 | public: | 173 | public: |
174 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 174 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
175 | QDialog( parent, name, true ) | 175 | QDialog( parent, name, true ) |
176 | { | 176 | { |
177 | setCaption( i18n("Manage new Categories") ); | 177 | setCaption( i18n("Manage new Categories") ); |
178 | QVBoxLayout* lay = new QVBoxLayout( this ); | 178 | QVBoxLayout* lay = new QVBoxLayout( this ); |
179 | lay->setSpacing( 3 ); | 179 | lay->setSpacing( 3 ); |
180 | lay->setMargin( 3 ); | 180 | lay->setMargin( 3 ); |
181 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 181 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
182 | lay->addWidget( lab ); | 182 | lay->addWidget( lab ); |
183 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 183 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
184 | lay->addWidget( format ); | 184 | lay->addWidget( format ); |
185 | format->setExclusive ( true ) ; | 185 | format->setExclusive ( true ) ; |
186 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 186 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
187 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 187 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
188 | addCatBut->setChecked( true ); | 188 | addCatBut->setChecked( true ); |
189 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 189 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
190 | lay->addWidget( ok ); | 190 | lay->addWidget( ok ); |
191 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 191 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
192 | lay->addWidget( cancel ); | 192 | lay->addWidget( cancel ); |
193 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 193 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
194 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 194 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
195 | resize( 200, 200 ); | 195 | resize( 200, 200 ); |
196 | } | 196 | } |
197 | 197 | ||
198 | bool addCat() { return addCatBut->isChecked(); } | 198 | bool addCat() { return addCatBut->isChecked(); } |
199 | private: | 199 | private: |
200 | QRadioButton* addCatBut; | 200 | QRadioButton* addCatBut; |
201 | }; | 201 | }; |
202 | 202 | ||
203 | 203 | ||
204 | 204 | ||
205 | CalendarView::CalendarView( CalendarResources *calendar, | 205 | CalendarView::CalendarView( CalendarResources *calendar, |
206 | QWidget *parent, const char *name ) | 206 | QWidget *parent, const char *name ) |
207 | : CalendarViewBase( parent, name ), | 207 | : CalendarViewBase( parent, name ), |
208 | mCalendar( calendar ), | 208 | mCalendar( calendar ), |
209 | mResourceManager( calendar->resourceManager() ) | 209 | mResourceManager( calendar->resourceManager() ) |
210 | { | 210 | { |
211 | 211 | ||
212 | mEventEditor = 0; | 212 | mEventEditor = 0; |
213 | mTodoEditor = 0; | 213 | mTodoEditor = 0; |
214 | 214 | ||
215 | init(); | 215 | init(); |
216 | } | 216 | } |
217 | 217 | ||
218 | CalendarView::CalendarView( Calendar *calendar, | 218 | CalendarView::CalendarView( Calendar *calendar, |
219 | QWidget *parent, const char *name ) | 219 | QWidget *parent, const char *name ) |
220 | : CalendarViewBase( parent, name ), | 220 | : CalendarViewBase( parent, name ), |
221 | mCalendar( calendar ), | 221 | mCalendar( calendar ), |
222 | mResourceManager( 0 ) | 222 | mResourceManager( 0 ) |
223 | { | 223 | { |
224 | 224 | ||
225 | mEventEditor = 0; | 225 | mEventEditor = 0; |
226 | mTodoEditor = 0; | 226 | mTodoEditor = 0; |
227 | init();} | 227 | init();} |
228 | 228 | ||
229 | void CalendarView::init() | 229 | void CalendarView::init() |
230 | { | 230 | { |
231 | beamDialog = new KOBeamPrefs(); | 231 | beamDialog = new KOBeamPrefs(); |
232 | mDatePickerMode = 0; | 232 | mDatePickerMode = 0; |
233 | mCurrentSyncDevice = ""; | 233 | mCurrentSyncDevice = ""; |
234 | writeLocale(); | 234 | writeLocale(); |
235 | mViewManager = new KOViewManager( this ); | 235 | mViewManager = new KOViewManager( this ); |
236 | mDialogManager = new KODialogManager( this ); | 236 | mDialogManager = new KODialogManager( this ); |
237 | mEventViewerDialog = 0; | 237 | mEventViewerDialog = 0; |
238 | mModified = false; | 238 | mModified = false; |
239 | mReadOnly = false; | 239 | mReadOnly = false; |
240 | mSelectedIncidence = 0; | 240 | mSelectedIncidence = 0; |
241 | mCalPrinter = 0; | 241 | mCalPrinter = 0; |
242 | mFilters.setAutoDelete(true); | 242 | mFilters.setAutoDelete(true); |
243 | 243 | ||
244 | mCalendar->registerObserver( this ); | 244 | mCalendar->registerObserver( this ); |
245 | // TODO: Make sure that view is updated, when calendar is changed. | 245 | // TODO: Make sure that view is updated, when calendar is changed. |
246 | 246 | ||
247 | mStorage = new FileStorage( mCalendar ); | 247 | mStorage = new FileStorage( mCalendar ); |
248 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 248 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
249 | 249 | ||
250 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 250 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
251 | #ifndef KORG_NOSPLITTER | 251 | #ifndef KORG_NOSPLITTER |
252 | // create the main layout frames. | 252 | // create the main layout frames. |
253 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 253 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
254 | topLayout->addWidget(mPanner); | 254 | topLayout->addWidget(mPanner); |
255 | 255 | ||
256 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 256 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
257 | "CalendarView::LeftFrame"); | 257 | "CalendarView::LeftFrame"); |
258 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 258 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
259 | 259 | ||
260 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 260 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
261 | "CalendarView::DateNavigator", QDate::currentDate() ); | 261 | "CalendarView::DateNavigator", QDate::currentDate() ); |
262 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 262 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
263 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 263 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
264 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 264 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
265 | 265 | ||
266 | #ifdef KORG_NORESOURCEVIEW | 266 | #ifdef KORG_NORESOURCEVIEW |
267 | mResourceView = 0; | 267 | mResourceView = 0; |
268 | #else | 268 | #else |
269 | if ( mResourceManager ) { | 269 | if ( mResourceManager ) { |
270 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 270 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
271 | mResourceView->updateView(); | 271 | mResourceView->updateView(); |
272 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 272 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
273 | SLOT( updateView() ) ); | 273 | SLOT( updateView() ) ); |
274 | } else { | 274 | } else { |
275 | mResourceView = 0; | 275 | mResourceView = 0; |
276 | } | 276 | } |
277 | #endif | 277 | #endif |
278 | QWidget *rightBox = new QWidget( mPanner ); | 278 | QWidget *rightBox = new QWidget( mPanner ); |
279 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 279 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
280 | 280 | ||
281 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 281 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
282 | rightLayout->addWidget( mNavigatorBar ); | 282 | rightLayout->addWidget( mNavigatorBar ); |
283 | 283 | ||
284 | mRightFrame = new QWidgetStack( rightBox ); | 284 | mRightFrame = new QWidgetStack( rightBox ); |
285 | rightLayout->addWidget( mRightFrame, 1 ); | 285 | rightLayout->addWidget( mRightFrame, 1 ); |
286 | 286 | ||
287 | mLeftFrame = mLeftSplitter; | 287 | mLeftFrame = mLeftSplitter; |
288 | #else | 288 | #else |
289 | QWidget *mainBox = new QWidget( this ); | 289 | QWidget *mainBox = new QWidget( this ); |
290 | QWidget *leftFrame = new QWidget( mainBox ); | 290 | QWidget *leftFrame = new QWidget( mainBox ); |
291 | 291 | ||
292 | QBoxLayout * mainBoxLayout; | 292 | QBoxLayout * mainBoxLayout; |
293 | QBoxLayout * leftFrameLayout; | 293 | QBoxLayout * leftFrameLayout; |
294 | if ( KOPrefs::instance()->mVerticalScreen ) { | 294 | if ( KOPrefs::instance()->mVerticalScreen ) { |
295 | mainBoxLayout = new QVBoxLayout(mainBox); | 295 | mainBoxLayout = new QVBoxLayout(mainBox); |
296 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 296 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
297 | } else { | 297 | } else { |
298 | mainBoxLayout = new QHBoxLayout(mainBox); | 298 | mainBoxLayout = new QHBoxLayout(mainBox); |
299 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 299 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
300 | } | 300 | } |
301 | topLayout->addWidget( mainBox ); | 301 | topLayout->addWidget( mainBox ); |
302 | mainBoxLayout->addWidget (leftFrame); | 302 | mainBoxLayout->addWidget (leftFrame); |
303 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 303 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
304 | "CalendarView::DateNavigator", QDate::currentDate()); | 304 | "CalendarView::DateNavigator", QDate::currentDate()); |
305 | // mDateNavigator->blockSignals( true ); | 305 | // mDateNavigator->blockSignals( true ); |
306 | leftFrameLayout->addWidget( mDateNavigator ); | 306 | leftFrameLayout->addWidget( mDateNavigator ); |
307 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 307 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
308 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); | 308 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); |
309 | 309 | ||
310 | if ( QApplication::desktop()->width() < 480 ) { | 310 | if ( QApplication::desktop()->width() < 480 ) { |
311 | leftFrameLayout->addWidget(mFilterView); | 311 | leftFrameLayout->addWidget(mFilterView); |
312 | leftFrameLayout->addWidget(mTodoList, 2 ); | 312 | leftFrameLayout->addWidget(mTodoList, 2 ); |
313 | 313 | ||
314 | } else { | 314 | } else { |
315 | leftFrameLayout->addWidget(mTodoList,2 ); | 315 | leftFrameLayout->addWidget(mTodoList,2 ); |
316 | leftFrameLayout->addWidget(mFilterView ); | 316 | leftFrameLayout->addWidget(mFilterView ); |
317 | } | 317 | } |
318 | mFilterView->hide(); | 318 | mFilterView->hide(); |
319 | QWidget *rightBox = new QWidget( mainBox ); | 319 | QWidget *rightBox = new QWidget( mainBox ); |
320 | mainBoxLayout->addWidget ( rightBox, 10 ); | 320 | mainBoxLayout->addWidget ( rightBox, 10 ); |
321 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 321 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
322 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 322 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
323 | mRightFrame = new QWidgetStack( rightBox ); | 323 | mRightFrame = new QWidgetStack( rightBox ); |
324 | rightLayout->addWidget( mNavigatorBar ); | 324 | rightLayout->addWidget( mNavigatorBar ); |
325 | rightLayout->addWidget( mRightFrame, 10 ); | 325 | rightLayout->addWidget( mRightFrame, 10 ); |
326 | 326 | ||
327 | mLeftFrame = leftFrame; | 327 | mLeftFrame = leftFrame; |
328 | if ( KOPrefs::instance()->mVerticalScreen ) { | 328 | if ( KOPrefs::instance()->mVerticalScreen ) { |
329 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 329 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
330 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 330 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
331 | } else { | 331 | } else { |
332 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 332 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
333 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 333 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
334 | } | 334 | } |
335 | 335 | ||
336 | //qDebug("Calendarview Size %d %d ", width(), height()); | 336 | //qDebug("Calendarview Size %d %d ", width(), height()); |
337 | #endif | 337 | #endif |
338 | 338 | ||
339 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 339 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
340 | SLOT( showDates( const KCal::DateList & ) ) ); | 340 | SLOT( showDates( const KCal::DateList & ) ) ); |
341 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 341 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
342 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 342 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
343 | 343 | ||
344 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 344 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
345 | mNavigator, SLOT( selectPreviousYear() ) ); | 345 | mNavigator, SLOT( selectPreviousYear() ) ); |
346 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 346 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
347 | mNavigator, SLOT( selectNextYear() ) ); | 347 | mNavigator, SLOT( selectNextYear() ) ); |
348 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 348 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
349 | mNavigator, SLOT( selectPreviousMonth() ) ); | 349 | mNavigator, SLOT( selectPreviousMonth() ) ); |
350 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 350 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
351 | mNavigator, SLOT( selectNextMonth() ) ); | 351 | mNavigator, SLOT( selectNextMonth() ) ); |
352 | 352 | ||
353 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 353 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
354 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 354 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
355 | 355 | ||
356 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 356 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
357 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 357 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
358 | 358 | ||
359 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 359 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
360 | mNavigator, SLOT( selectPreviousYear() ) ); | 360 | mNavigator, SLOT( selectPreviousYear() ) ); |
361 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 361 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
362 | mNavigator, SLOT( selectNextYear() ) ); | 362 | mNavigator, SLOT( selectNextYear() ) ); |
363 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 363 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
364 | mNavigator, SLOT( selectPreviousMonth() ) ); | 364 | mNavigator, SLOT( selectPreviousMonth() ) ); |
365 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 365 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
366 | mNavigator, SLOT( selectNextMonth() ) ); | 366 | mNavigator, SLOT( selectNextMonth() ) ); |
367 | 367 | ||
368 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 368 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
369 | mNavigator, SLOT( selectPrevious() ) ); | 369 | mNavigator, SLOT( selectPrevious() ) ); |
370 | connect( mDateNavigator, SIGNAL( goNext() ), | 370 | connect( mDateNavigator, SIGNAL( goNext() ), |
371 | mNavigator, SLOT( selectNext() ) ); | 371 | mNavigator, SLOT( selectNext() ) ); |
372 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 372 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
373 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 373 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
374 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 374 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
375 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 375 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
376 | 376 | ||
377 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 377 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
378 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 378 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
379 | 379 | ||
380 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 380 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
381 | SLOT( eventAdded( Event *) ) ); | 381 | SLOT( eventAdded( Event *) ) ); |
382 | 382 | ||
383 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 383 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
384 | 384 | ||
385 | connect( this, SIGNAL( configChanged() ), | 385 | connect( this, SIGNAL( configChanged() ), |
386 | mDateNavigator, SLOT( updateConfig() ) ); | 386 | mDateNavigator, SLOT( updateConfig() ) ); |
387 | 387 | ||
388 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 388 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
389 | SLOT( newTodo() ) ); | 389 | SLOT( newTodo() ) ); |
390 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 390 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
391 | SLOT( newSubTodo( Todo * ) ) ); | 391 | SLOT( newSubTodo( Todo * ) ) ); |
392 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 392 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
393 | SLOT( editTodo( Todo * ) ) ); | 393 | SLOT( editTodo( Todo * ) ) ); |
394 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 394 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
395 | SLOT( showTodo( Todo *) ) ); | 395 | SLOT( showTodo( Todo *) ) ); |
396 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 396 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
397 | SLOT( deleteTodo( Todo *) ) ); | 397 | SLOT( deleteTodo( Todo *) ) ); |
398 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 398 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
399 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 399 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
400 | SLOT( purgeCompleted() ) ); | 400 | SLOT( purgeCompleted() ) ); |
401 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 401 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
402 | SIGNAL( todoModified( Todo *, int ) ) ); | 402 | SIGNAL( todoModified( Todo *, int ) ) ); |
403 | 403 | ||
404 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 404 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
405 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 405 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
406 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 406 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
407 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 407 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
408 | 408 | ||
409 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 409 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
410 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 410 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
411 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
412 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 412 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 414 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
415 | this, SLOT ( todo_unsub( Todo * ) ) ); | 415 | this, SLOT ( todo_unsub( Todo * ) ) ); |
416 | 416 | ||
417 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 417 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
418 | SLOT( updateTodo( Todo *, int ) ) ); | 418 | SLOT( updateTodo( Todo *, int ) ) ); |
419 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 419 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
420 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 420 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
421 | 421 | ||
422 | 422 | ||
423 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 423 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
424 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 424 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
425 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 425 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
426 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 426 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
427 | 427 | ||
428 | 428 | ||
429 | 429 | ||
430 | 430 | ||
431 | 431 | ||
432 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 432 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
433 | SLOT(checkClipboard())); | 433 | SLOT(checkClipboard())); |
434 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 434 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
435 | SLOT( processTodoListSelection( Incidence * ) ) ); | 435 | SLOT( processTodoListSelection( Incidence * ) ) ); |
436 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 436 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
437 | 437 | ||
438 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 438 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
439 | 439 | ||
440 | mDateFrame = new QVBox(0,0,WType_Popup); | 440 | mDateFrame = new QVBox(0,0,WType_Popup); |
441 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 441 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
442 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 442 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
443 | mDateFrame->setLineWidth(3); | 443 | mDateFrame->setLineWidth(3); |
444 | mDateFrame->hide(); | 444 | mDateFrame->hide(); |
445 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 445 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
446 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 446 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
447 | 447 | ||
448 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 448 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
449 | 449 | ||
450 | mEventEditor = mDialogManager->getEventEditor(); | 450 | mEventEditor = mDialogManager->getEventEditor(); |
451 | mTodoEditor = mDialogManager->getTodoEditor(); | 451 | mTodoEditor = mDialogManager->getTodoEditor(); |
452 | 452 | ||
453 | mFlagEditDescription = false; | 453 | mFlagEditDescription = false; |
454 | 454 | ||
455 | mSuspendTimer = new QTimer( this ); | 455 | mSuspendTimer = new QTimer( this ); |
456 | mAlarmTimer = new QTimer( this ); | 456 | mAlarmTimer = new QTimer( this ); |
457 | mRecheckAlarmTimer = new QTimer( this ); | 457 | mRecheckAlarmTimer = new QTimer( this ); |
458 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 458 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
459 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 459 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
460 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 460 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
461 | mAlarmDialog = new AlarmDialog( this ); | 461 | mAlarmDialog = new AlarmDialog( this ); |
462 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 462 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
463 | mAlarmDialog->setServerNotification( false ); | 463 | mAlarmDialog->setServerNotification( false ); |
464 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 464 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
465 | } | 465 | } |
466 | 466 | ||
467 | 467 | ||
468 | CalendarView::~CalendarView() | 468 | CalendarView::~CalendarView() |
469 | { | 469 | { |
470 | // kdDebug() << "~CalendarView()" << endl; | 470 | // kdDebug() << "~CalendarView()" << endl; |
471 | //qDebug("CalendarView::~CalendarView() "); | 471 | //qDebug("CalendarView::~CalendarView() "); |
472 | delete mDialogManager; | 472 | delete mDialogManager; |
473 | delete mViewManager; | 473 | delete mViewManager; |
474 | delete mStorage; | 474 | delete mStorage; |
475 | delete mDateFrame ; | 475 | delete mDateFrame ; |
476 | delete beamDialog; | 476 | delete beamDialog; |
477 | //kdDebug() << "~CalendarView() done" << endl; | 477 | //kdDebug() << "~CalendarView() done" << endl; |
478 | } | 478 | } |
479 | void CalendarView::timerAlarm() | 479 | void CalendarView::timerAlarm() |
480 | { | 480 | { |
481 | //qDebug("CalendarView::timerAlarm() "); | 481 | //qDebug("CalendarView::timerAlarm() "); |
482 | computeAlarm(mAlarmNotification ); | 482 | computeAlarm(mAlarmNotification ); |
483 | } | 483 | } |
484 | 484 | ||
485 | void CalendarView::suspendAlarm() | 485 | void CalendarView::suspendAlarm() |
486 | { | 486 | { |
487 | //qDebug(" CalendarView::suspendAlarm() "); | 487 | //qDebug(" CalendarView::suspendAlarm() "); |
488 | computeAlarm(mSuspendAlarmNotification ); | 488 | computeAlarm(mSuspendAlarmNotification ); |
489 | 489 | ||
490 | } | 490 | } |
491 | 491 | ||
492 | void CalendarView::startAlarm( QString mess , QString filename) | 492 | void CalendarView::startAlarm( QString mess , QString filename) |
493 | { | 493 | { |
494 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 494 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
495 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 495 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
496 | 496 | ||
497 | } | 497 | } |
498 | 498 | ||
499 | void CalendarView::checkNextTimerAlarm() | 499 | void CalendarView::checkNextTimerAlarm() |
500 | { | 500 | { |
501 | mCalendar->checkAlarmForIncidence( 0, true ); | 501 | mCalendar->checkAlarmForIncidence( 0, true ); |
502 | } | 502 | } |
503 | 503 | ||
504 | void CalendarView::computeAlarm( QString msg ) | 504 | void CalendarView::computeAlarm( QString msg ) |
505 | { | 505 | { |
506 | 506 | ||
507 | QString mess = msg; | 507 | QString mess = msg; |
508 | QString mAlarmMessage = mess.mid( 9 ); | 508 | QString mAlarmMessage = mess.mid( 9 ); |
509 | QString filename = MainWindow::resourcePath(); | 509 | QString filename = MainWindow::resourcePath(); |
510 | filename += "koalarm.wav"; | 510 | filename += "koalarm.wav"; |
511 | QString tempfilename; | 511 | QString tempfilename; |
512 | if ( mess.left( 13 ) == "suspend_alarm") { | 512 | if ( mess.left( 13 ) == "suspend_alarm") { |
513 | bool error = false; | 513 | bool error = false; |
514 | int len = mess.mid( 13 ).find("+++"); | 514 | int len = mess.mid( 13 ).find("+++"); |
515 | if ( len < 2 ) | 515 | if ( len < 2 ) |
516 | error = true; | 516 | error = true; |
517 | else { | 517 | else { |
518 | tempfilename = mess.mid( 13, len ); | 518 | tempfilename = mess.mid( 13, len ); |
519 | if ( !QFile::exists( tempfilename ) ) | 519 | if ( !QFile::exists( tempfilename ) ) |
520 | error = true; | 520 | error = true; |
521 | } | 521 | } |
522 | if ( ! error ) { | 522 | if ( ! error ) { |
523 | filename = tempfilename; | 523 | filename = tempfilename; |
524 | } | 524 | } |
525 | mAlarmMessage = mess.mid( 13+len+3 ); | 525 | mAlarmMessage = mess.mid( 13+len+3 ); |
526 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 526 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
527 | startAlarm( mAlarmMessage, filename); | 527 | startAlarm( mAlarmMessage, filename); |
528 | return; | 528 | return; |
529 | } | 529 | } |
530 | if ( mess.left( 11 ) == "timer_alarm") { | 530 | if ( mess.left( 11 ) == "timer_alarm") { |
531 | //mTimerTime = 0; | 531 | //mTimerTime = 0; |
532 | startAlarm( mess.mid( 11 ), filename ); | 532 | startAlarm( mess.mid( 11 ), filename ); |
533 | return; | 533 | return; |
534 | } | 534 | } |
535 | if ( mess.left( 10 ) == "proc_alarm") { | 535 | if ( mess.left( 10 ) == "proc_alarm") { |
536 | bool error = false; | 536 | bool error = false; |
537 | int len = mess.mid( 10 ).find("+++"); | 537 | int len = mess.mid( 10 ).find("+++"); |
538 | if ( len < 2 ) | 538 | if ( len < 2 ) |
539 | error = true; | 539 | error = true; |
540 | else { | 540 | else { |
541 | tempfilename = mess.mid( 10, len ); | 541 | tempfilename = mess.mid( 10, len ); |
542 | if ( !QFile::exists( tempfilename ) ) | 542 | if ( !QFile::exists( tempfilename ) ) |
543 | error = true; | 543 | error = true; |
544 | } | 544 | } |
545 | if ( error ) { | 545 | if ( error ) { |
546 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 546 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
547 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 547 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
548 | } else { | 548 | } else { |
549 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 549 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
550 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 550 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
551 | #ifndef _WIN32_ | 551 | #ifndef _WIN32_ |
552 | if ( vfork () == 0 ) { | 552 | if ( vfork () == 0 ) { |
553 | execl ( tempfilename.latin1(), 0 ); | 553 | execl ( tempfilename.latin1(), 0 ); |
554 | return; | 554 | return; |
555 | } | 555 | } |
556 | #else | 556 | #else |
557 | QProcess* p = new QProcess(); | 557 | QProcess* p = new QProcess(); |
558 | p->addArgument( tempfilename.latin1() ); | 558 | p->addArgument( tempfilename.latin1() ); |
559 | p->start(); | 559 | p->start(); |
560 | return; | 560 | return; |
561 | #endif | 561 | #endif |
562 | 562 | ||
563 | return; | 563 | return; |
564 | } | 564 | } |
565 | 565 | ||
566 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 566 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
567 | } | 567 | } |
568 | if ( mess.left( 11 ) == "audio_alarm") { | 568 | if ( mess.left( 11 ) == "audio_alarm") { |
569 | bool error = false; | 569 | bool error = false; |
570 | int len = mess.mid( 11 ).find("+++"); | 570 | int len = mess.mid( 11 ).find("+++"); |
571 | if ( len < 2 ) | 571 | if ( len < 2 ) |
572 | error = true; | 572 | error = true; |
573 | else { | 573 | else { |
574 | tempfilename = mess.mid( 11, len ); | 574 | tempfilename = mess.mid( 11, len ); |
575 | if ( !QFile::exists( tempfilename ) ) | 575 | if ( !QFile::exists( tempfilename ) ) |
576 | error = true; | 576 | error = true; |
577 | } | 577 | } |
578 | if ( ! error ) { | 578 | if ( ! error ) { |
579 | filename = tempfilename; | 579 | filename = tempfilename; |
580 | } | 580 | } |
581 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 581 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
582 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 582 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
583 | } | 583 | } |
584 | if ( mess.left( 9 ) == "cal_alarm") { | 584 | if ( mess.left( 9 ) == "cal_alarm") { |
585 | mAlarmMessage = mess.mid( 9 ) ; | 585 | mAlarmMessage = mess.mid( 9 ) ; |
586 | } | 586 | } |
587 | 587 | ||
588 | startAlarm( mAlarmMessage, filename ); | 588 | startAlarm( mAlarmMessage, filename ); |
589 | 589 | ||
590 | 590 | ||
591 | } | 591 | } |
592 | 592 | ||
593 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 593 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
594 | { | 594 | { |
595 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 595 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
596 | 596 | ||
597 | mSuspendAlarmNotification = noti; | 597 | mSuspendAlarmNotification = noti; |
598 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 598 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
599 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 599 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
600 | mSuspendTimer->start( ms , true ); | 600 | mSuspendTimer->start( ms , true ); |
601 | 601 | ||
602 | } | 602 | } |
603 | 603 | ||
604 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 604 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
605 | { | 605 | { |
606 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 606 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
607 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 607 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
608 | #ifndef DESKTOP_VERSION | 608 | #ifndef DESKTOP_VERSION |
609 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 609 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
610 | #endif | 610 | #endif |
611 | return; | 611 | return; |
612 | } | 612 | } |
613 | int maxSec; | 613 | int maxSec; |
614 | //maxSec = 5; //testing only | 614 | //maxSec = 5; //testing only |
615 | maxSec = 86400+3600; // one day+1hour | 615 | maxSec = 86400+3600; // one day+1hour |
616 | mAlarmNotification = noti; | 616 | mAlarmNotification = noti; |
617 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 617 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
618 | if ( sec > maxSec ) { | 618 | if ( sec > maxSec ) { |
619 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 619 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
620 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 620 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
621 | return; | 621 | return; |
622 | } else { | 622 | } else { |
623 | mRecheckAlarmTimer->stop(); | 623 | mRecheckAlarmTimer->stop(); |
624 | } | 624 | } |
625 | //qDebug("Alarm timer started with secs: %d ", sec); | 625 | //qDebug("Alarm timer started with secs: %d ", sec); |
626 | mAlarmTimer->start( sec *1000 , true ); | 626 | mAlarmTimer->start( sec *1000 , true ); |
627 | 627 | ||
628 | } | 628 | } |
629 | // called by mRecheckAlarmTimer to get next alarm | 629 | // called by mRecheckAlarmTimer to get next alarm |
630 | // we need this, because a QTimer has only a max range of 25 days | 630 | // we need this, because a QTimer has only a max range of 25 days |
631 | void CalendarView::recheckTimerAlarm() | 631 | void CalendarView::recheckTimerAlarm() |
632 | { | 632 | { |
633 | mAlarmTimer->stop(); | 633 | mAlarmTimer->stop(); |
634 | mRecheckAlarmTimer->stop(); | 634 | mRecheckAlarmTimer->stop(); |
635 | mCalendar->checkAlarmForIncidence( 0, true ); | 635 | mCalendar->checkAlarmForIncidence( 0, true ); |
636 | } | 636 | } |
637 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 637 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
638 | { | 638 | { |
639 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 639 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
640 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 640 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
641 | #ifndef DESKTOP_VERSION | 641 | #ifndef DESKTOP_VERSION |
642 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 642 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
643 | #endif | 643 | #endif |
644 | return; | 644 | return; |
645 | } | 645 | } |
646 | mAlarmTimer->stop(); | 646 | mAlarmTimer->stop(); |
647 | } | 647 | } |
648 | void CalendarView::selectWeekNum ( int num ) | 648 | void CalendarView::selectWeekNum ( int num ) |
649 | { | 649 | { |
650 | dateNavigator()->selectWeek( num ); | 650 | dateNavigator()->selectWeek( num ); |
651 | mViewManager->showWeekView(); | 651 | mViewManager->showWeekView(); |
652 | } | 652 | } |
653 | KOViewManager *CalendarView::viewManager() | 653 | KOViewManager *CalendarView::viewManager() |
654 | { | 654 | { |
655 | return mViewManager; | 655 | return mViewManager; |
656 | } | 656 | } |
657 | 657 | ||
658 | KODialogManager *CalendarView::dialogManager() | 658 | KODialogManager *CalendarView::dialogManager() |
659 | { | 659 | { |
660 | return mDialogManager; | 660 | return mDialogManager; |
661 | } | 661 | } |
662 | 662 | ||
663 | QDate CalendarView::startDate() | 663 | QDate CalendarView::startDate() |
664 | { | 664 | { |
665 | DateList dates = mNavigator->selectedDates(); | 665 | DateList dates = mNavigator->selectedDates(); |
666 | 666 | ||
667 | return dates.first(); | 667 | return dates.first(); |
668 | } | 668 | } |
669 | 669 | ||
670 | QDate CalendarView::endDate() | 670 | QDate CalendarView::endDate() |
671 | { | 671 | { |
672 | DateList dates = mNavigator->selectedDates(); | 672 | DateList dates = mNavigator->selectedDates(); |
673 | 673 | ||
674 | return dates.last(); | 674 | return dates.last(); |
675 | } | 675 | } |
676 | 676 | ||
677 | 677 | ||
678 | void CalendarView::createPrinter() | 678 | void CalendarView::createPrinter() |
679 | { | 679 | { |
680 | #ifndef KORG_NOPRINTER | 680 | #ifndef KORG_NOPRINTER |
681 | if (!mCalPrinter) { | 681 | if (!mCalPrinter) { |
682 | mCalPrinter = new CalPrinter(this, mCalendar); | 682 | mCalPrinter = new CalPrinter(this, mCalendar); |
683 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 683 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
684 | } | 684 | } |
685 | #endif | 685 | #endif |
686 | } | 686 | } |
687 | 687 | ||
688 | void CalendarView::confSync() | 688 | void CalendarView::confSync() |
689 | { | 689 | { |
690 | static KSyncPrefsDialog* sp = 0; | 690 | static KSyncPrefsDialog* sp = 0; |
691 | if ( ! sp ) { | 691 | if ( ! sp ) { |
692 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 692 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
693 | } | 693 | } |
694 | sp->usrReadConfig(); | 694 | sp->usrReadConfig(); |
695 | #ifndef DESKTOP_VERSION | 695 | #ifndef DESKTOP_VERSION |
696 | sp->showMaximized(); | 696 | sp->showMaximized(); |
697 | #else | 697 | #else |
698 | sp->show(); | 698 | sp->show(); |
699 | #endif | 699 | #endif |
700 | sp->exec(); | 700 | sp->exec(); |
701 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 701 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
702 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 702 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
703 | } | 703 | } |
704 | 704 | ||
705 | 705 | ||
706 | //KOPrefs::instance()->mWriteBackFile | 706 | //KOPrefs::instance()->mWriteBackFile |
707 | //KOPrefs::instance()->mWriteBackExistingOnly | 707 | //KOPrefs::instance()->mWriteBackExistingOnly |
708 | 708 | ||
709 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 709 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
710 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 710 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
711 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 711 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
712 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 712 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
713 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 713 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
714 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 714 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
715 | 715 | ||
716 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 716 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
717 | { | 717 | { |
718 | 718 | ||
719 | //void setZaurusId(int id); | 719 | //void setZaurusId(int id); |
720 | // int zaurusId() const; | 720 | // int zaurusId() const; |
721 | // void setZaurusUid(int id); | 721 | // void setZaurusUid(int id); |
722 | // int zaurusUid() const; | 722 | // int zaurusUid() const; |
723 | // void setZaurusStat(int id); | 723 | // void setZaurusStat(int id); |
724 | // int zaurusStat() const; | 724 | // int zaurusStat() const; |
725 | // 0 equal | 725 | // 0 equal |
726 | // 1 take local | 726 | // 1 take local |
727 | // 2 take remote | 727 | // 2 take remote |
728 | // 3 cancel | 728 | // 3 cancel |
729 | QDateTime lastSync = mLastCalendarSync; | 729 | QDateTime lastSync = mLastCalendarSync; |
730 | QDateTime localMod = local->lastModified(); | 730 | QDateTime localMod = local->lastModified(); |
731 | QDateTime remoteMod = remote->lastModified(); | 731 | QDateTime remoteMod = remote->lastModified(); |
732 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 732 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
733 | bool remCh, locCh; | 733 | bool remCh, locCh; |
734 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 734 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
735 | //if ( remCh ) | 735 | //if ( remCh ) |
736 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 736 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
737 | locCh = ( localMod > mLastCalendarSync ); | 737 | locCh = ( localMod > mLastCalendarSync ); |
738 | if ( !remCh && ! locCh ) { | 738 | if ( !remCh && ! locCh ) { |
739 | //qDebug("both not changed "); | 739 | //qDebug("both not changed "); |
740 | lastSync = localMod.addDays(1); | 740 | lastSync = localMod.addDays(1); |
741 | if ( mode <= SYNC_PREF_ASK ) | 741 | if ( mode <= SYNC_PREF_ASK ) |
742 | return 0; | 742 | return 0; |
743 | } else { | 743 | } else { |
744 | if ( locCh ) { | 744 | if ( locCh ) { |
745 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 745 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
746 | lastSync = localMod.addDays( -1 ); | 746 | lastSync = localMod.addDays( -1 ); |
747 | if ( !remCh ) | 747 | if ( !remCh ) |
748 | remoteMod = ( lastSync.addDays( -1 ) ); | 748 | remoteMod = ( lastSync.addDays( -1 ) ); |
749 | } else { | 749 | } else { |
750 | //qDebug(" not loc changed "); | 750 | //qDebug(" not loc changed "); |
751 | lastSync = localMod.addDays( 1 ); | 751 | lastSync = localMod.addDays( 1 ); |
752 | if ( remCh ) | 752 | if ( remCh ) |
753 | remoteMod =( lastSync.addDays( 1 ) ); | 753 | remoteMod =( lastSync.addDays( 1 ) ); |
754 | 754 | ||
755 | } | 755 | } |
756 | } | 756 | } |
757 | full = true; | 757 | full = true; |
758 | if ( mode < SYNC_PREF_ASK ) | 758 | if ( mode < SYNC_PREF_ASK ) |
759 | mode = SYNC_PREF_ASK; | 759 | mode = SYNC_PREF_ASK; |
760 | } else { | 760 | } else { |
761 | if ( localMod == remoteMod ) | 761 | if ( localMod == remoteMod ) |
762 | if ( local->revision() == remote->revision() ) | 762 | if ( local->revision() == remote->revision() ) |
763 | return 0; | 763 | return 0; |
764 | 764 | ||
765 | } | 765 | } |
766 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 766 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
767 | 767 | ||
768 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 768 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
769 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 769 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
770 | //full = true; //debug only | 770 | //full = true; //debug only |
771 | if ( full ) { | 771 | if ( full ) { |
772 | bool equ = false; | 772 | bool equ = false; |
773 | if ( local->type() == "Event" ) { | 773 | if ( local->type() == "Event" ) { |
774 | equ = (*((Event*) local) == *((Event*) remote)); | 774 | equ = (*((Event*) local) == *((Event*) remote)); |
775 | } | 775 | } |
776 | else if ( local->type() =="Todo" ) | 776 | else if ( local->type() =="Todo" ) |
777 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 777 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
778 | else if ( local->type() =="Journal" ) | 778 | else if ( local->type() =="Journal" ) |
779 | equ = (*((Journal*) local) == *((Journal*) remote)); | 779 | equ = (*((Journal*) local) == *((Journal*) remote)); |
780 | if ( equ ) { | 780 | if ( equ ) { |
781 | //qDebug("equal "); | 781 | //qDebug("equal "); |
782 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 782 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
783 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 783 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
784 | } | 784 | } |
785 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 785 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
786 | return 0; | 786 | return 0; |
787 | 787 | ||
788 | }//else //debug only | 788 | }//else //debug only |
789 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 789 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
790 | } | 790 | } |
791 | int result; | 791 | int result; |
792 | bool localIsNew; | 792 | bool localIsNew; |
793 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 793 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
794 | 794 | ||
795 | if ( full && mode < SYNC_PREF_NEWEST ) | 795 | if ( full && mode < SYNC_PREF_NEWEST ) |
796 | mode = SYNC_PREF_ASK; | 796 | mode = SYNC_PREF_ASK; |
797 | 797 | ||
798 | switch( mode ) { | 798 | switch( mode ) { |
799 | case SYNC_PREF_LOCAL: | 799 | case SYNC_PREF_LOCAL: |
800 | if ( lastSync > remoteMod ) | 800 | if ( lastSync > remoteMod ) |
801 | return 1; | 801 | return 1; |
802 | if ( lastSync > localMod ) | 802 | if ( lastSync > localMod ) |
803 | return 2; | 803 | return 2; |
804 | return 1; | 804 | return 1; |
805 | break; | 805 | break; |
806 | case SYNC_PREF_REMOTE: | 806 | case SYNC_PREF_REMOTE: |
807 | if ( lastSync > remoteMod ) | 807 | if ( lastSync > remoteMod ) |
808 | return 1; | 808 | return 1; |
809 | if ( lastSync > localMod ) | 809 | if ( lastSync > localMod ) |
810 | return 2; | 810 | return 2; |
811 | return 2; | 811 | return 2; |
812 | break; | 812 | break; |
813 | case SYNC_PREF_NEWEST: | 813 | case SYNC_PREF_NEWEST: |
814 | if ( localMod > remoteMod ) | 814 | if ( localMod > remoteMod ) |
815 | return 1; | 815 | return 1; |
816 | else | 816 | else |
817 | return 2; | 817 | return 2; |
818 | break; | 818 | break; |
819 | case SYNC_PREF_ASK: | 819 | case SYNC_PREF_ASK: |
820 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 820 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
821 | if ( lastSync > remoteMod ) | 821 | if ( lastSync > remoteMod ) |
822 | return 1; | 822 | return 1; |
823 | if ( lastSync > localMod ) | 823 | if ( lastSync > localMod ) |
824 | return 2; | 824 | return 2; |
825 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 825 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
826 | localIsNew = localMod >= remoteMod; | 826 | localIsNew = localMod >= remoteMod; |
827 | if ( localIsNew ) | 827 | if ( localIsNew ) |
828 | getEventViewerDialog()->setColorMode( 1 ); | 828 | getEventViewerDialog()->setColorMode( 1 ); |
829 | else | 829 | else |
830 | getEventViewerDialog()->setColorMode( 2 ); | 830 | getEventViewerDialog()->setColorMode( 2 ); |
831 | getEventViewerDialog()->setIncidence(local); | 831 | getEventViewerDialog()->setIncidence(local); |
832 | if ( localIsNew ) | 832 | if ( localIsNew ) |
833 | getEventViewerDialog()->setColorMode( 2 ); | 833 | getEventViewerDialog()->setColorMode( 2 ); |
834 | else | 834 | else |
835 | getEventViewerDialog()->setColorMode( 1 ); | 835 | getEventViewerDialog()->setColorMode( 1 ); |
836 | getEventViewerDialog()->addIncidence(remote); | 836 | getEventViewerDialog()->addIncidence(remote); |
837 | getEventViewerDialog()->setColorMode( 0 ); | 837 | getEventViewerDialog()->setColorMode( 0 ); |
838 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 838 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
839 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 839 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
840 | getEventViewerDialog()->showMe(); | 840 | getEventViewerDialog()->showMe(); |
841 | result = getEventViewerDialog()->executeS( localIsNew ); | 841 | result = getEventViewerDialog()->executeS( localIsNew ); |
842 | return result; | 842 | return result; |
843 | 843 | ||
844 | break; | 844 | break; |
845 | case SYNC_PREF_FORCE_LOCAL: | 845 | case SYNC_PREF_FORCE_LOCAL: |
846 | return 1; | 846 | return 1; |
847 | break; | 847 | break; |
848 | case SYNC_PREF_FORCE_REMOTE: | 848 | case SYNC_PREF_FORCE_REMOTE: |
849 | return 2; | 849 | return 2; |
850 | break; | 850 | break; |
851 | 851 | ||
852 | default: | 852 | default: |
853 | // SYNC_PREF_TAKE_BOTH not implemented | 853 | // SYNC_PREF_TAKE_BOTH not implemented |
854 | break; | 854 | break; |
855 | } | 855 | } |
856 | return 0; | 856 | return 0; |
857 | } | 857 | } |
858 | Event* CalendarView::getLastSyncEvent() | 858 | Event* CalendarView::getLastSyncEvent() |
859 | { | 859 | { |
860 | Event* lse; | 860 | Event* lse; |
861 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 861 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
862 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 862 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
863 | if (!lse) { | 863 | if (!lse) { |
864 | lse = new Event(); | 864 | lse = new Event(); |
865 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 865 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
866 | QString sum = ""; | 866 | QString sum = ""; |
867 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 867 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
868 | sum = "E: "; | 868 | sum = "E: "; |
869 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 869 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
870 | lse->setDtStart( mLastCalendarSync ); | 870 | lse->setDtStart( mLastCalendarSync ); |
871 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 871 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
872 | lse->setCategories( i18n("SyncEvent") ); | 872 | lse->setCategories( i18n("SyncEvent") ); |
873 | lse->setReadOnly( true ); | 873 | lse->setReadOnly( true ); |
874 | mCalendar->addEvent( lse ); | 874 | mCalendar->addEvent( lse ); |
875 | } | 875 | } |
876 | 876 | ||
877 | return lse; | 877 | return lse; |
878 | 878 | ||
879 | } | 879 | } |
880 | // probaly useless | ||
881 | void CalendarView::setupExternSyncProfiles() | ||
882 | { | ||
883 | Event* lse; | ||
884 | mExternLastSyncEvent.clear(); | ||
885 | int i; | ||
886 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { | ||
887 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); | ||
888 | if ( lse ) | ||
889 | mExternLastSyncEvent.append( lse ); | ||
890 | else | ||
891 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); | ||
892 | } | ||
893 | 880 | ||
894 | } | ||
895 | // we check, if the to delete event has a id for a profile | 881 | // we check, if the to delete event has a id for a profile |
896 | // if yes, we set this id in the profile to delete | 882 | // if yes, we set this id in the profile to delete |
897 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 883 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
898 | { | 884 | { |
899 | if ( lastSync.count() == 0 ) { | 885 | if ( lastSync.count() == 0 ) { |
900 | //qDebug(" lastSync.count() == 0"); | 886 | //qDebug(" lastSync.count() == 0"); |
901 | return; | 887 | return; |
902 | } | 888 | } |
903 | if ( toDelete->type() == "Journal" ) | 889 | if ( toDelete->type() == "Journal" ) |
904 | return; | 890 | return; |
905 | 891 | ||
906 | Event* eve = lastSync.first(); | 892 | Event* eve = lastSync.first(); |
907 | 893 | ||
908 | while ( eve ) { | 894 | while ( eve ) { |
909 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 895 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
910 | if ( !id.isEmpty() ) { | 896 | if ( !id.isEmpty() ) { |
911 | QString des = eve->description(); | 897 | QString des = eve->description(); |
912 | QString pref = "e"; | 898 | QString pref = "e"; |
913 | if ( toDelete->type() == "Todo" ) | 899 | if ( toDelete->type() == "Todo" ) |
914 | pref = "t"; | 900 | pref = "t"; |
915 | des += pref+ id + ","; | 901 | des += pref+ id + ","; |
916 | eve->setReadOnly( false ); | 902 | eve->setReadOnly( false ); |
917 | eve->setDescription( des ); | 903 | eve->setDescription( des ); |
918 | //qDebug("setdes %s ", des.latin1()); | 904 | //qDebug("setdes %s ", des.latin1()); |
919 | eve->setReadOnly( true ); | 905 | eve->setReadOnly( true ); |
920 | } | 906 | } |
921 | eve = lastSync.next(); | 907 | eve = lastSync.next(); |
922 | } | 908 | } |
923 | 909 | ||
924 | } | 910 | } |
925 | void CalendarView::checkExternalId( Incidence * inc ) | 911 | void CalendarView::checkExternalId( Incidence * inc ) |
926 | { | 912 | { |
927 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 913 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
928 | checkExternSyncEvent( lastSync, inc ); | 914 | checkExternSyncEvent( lastSync, inc ); |
929 | 915 | ||
930 | } | 916 | } |
931 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 917 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
932 | { | 918 | { |
933 | bool syncOK = true; | 919 | bool syncOK = true; |
934 | int addedEvent = 0; | 920 | int addedEvent = 0; |
935 | int addedEventR = 0; | 921 | int addedEventR = 0; |
936 | int deletedEventR = 0; | 922 | int deletedEventR = 0; |
937 | int deletedEventL = 0; | 923 | int deletedEventL = 0; |
938 | int changedLocal = 0; | 924 | int changedLocal = 0; |
939 | int changedRemote = 0; | 925 | int changedRemote = 0; |
940 | //QPtrList<Event> el = local->rawEvents(); | 926 | //QPtrList<Event> el = local->rawEvents(); |
941 | Event* eventR; | 927 | Event* eventR; |
942 | QString uid; | 928 | QString uid; |
943 | int take; | 929 | int take; |
944 | Event* eventL; | 930 | Event* eventL; |
945 | Event* eventRSync; | 931 | Event* eventRSync; |
946 | Event* eventLSync; | 932 | Event* eventLSync; |
947 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 933 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
948 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 934 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
949 | bool fullDateRange = false; | 935 | bool fullDateRange = false; |
950 | local->resetTempSyncStat(); | 936 | local->resetTempSyncStat(); |
951 | mLastCalendarSync = QDateTime::currentDateTime(); | 937 | mLastCalendarSync = QDateTime::currentDateTime(); |
952 | QDateTime modifiedCalendar = mLastCalendarSync;; | 938 | QDateTime modifiedCalendar = mLastCalendarSync;; |
953 | eventLSync = getLastSyncEvent(); | 939 | eventLSync = getLastSyncEvent(); |
954 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 940 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
955 | if ( eventR ) { | 941 | if ( eventR ) { |
956 | eventRSync = (Event*) eventR->clone(); | 942 | eventRSync = (Event*) eventR->clone(); |
957 | remote->deleteEvent(eventR ); | 943 | remote->deleteEvent(eventR ); |
958 | 944 | ||
959 | } else { | 945 | } else { |
960 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 946 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
961 | eventRSync = (Event*)eventLSync->clone(); | 947 | eventRSync = (Event*)eventLSync->clone(); |
962 | } else { | 948 | } else { |
963 | fullDateRange = true; | 949 | fullDateRange = true; |
964 | eventRSync = new Event(); | 950 | eventRSync = new Event(); |
965 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 951 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
966 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 952 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
967 | eventRSync->setDtStart( mLastCalendarSync ); | 953 | eventRSync->setDtStart( mLastCalendarSync ); |
968 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 954 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
969 | eventRSync->setCategories( i18n("SyncEvent") ); | 955 | eventRSync->setCategories( i18n("SyncEvent") ); |
970 | } | 956 | } |
971 | } | 957 | } |
972 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 958 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
973 | fullDateRange = true; | 959 | fullDateRange = true; |
974 | 960 | ||
975 | if ( ! fullDateRange ) { | 961 | if ( ! fullDateRange ) { |
976 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 962 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
977 | 963 | ||
978 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 964 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
979 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 965 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
980 | fullDateRange = true; | 966 | fullDateRange = true; |
981 | } | 967 | } |
982 | } | 968 | } |
983 | if ( fullDateRange ) | 969 | if ( fullDateRange ) |
984 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 970 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
985 | else | 971 | else |
986 | mLastCalendarSync = eventLSync->dtStart(); | 972 | mLastCalendarSync = eventLSync->dtStart(); |
987 | // for resyncing if own file has changed | 973 | // for resyncing if own file has changed |
988 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 974 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
989 | mLastCalendarSync = loadedFileVersion; | 975 | mLastCalendarSync = loadedFileVersion; |
990 | qDebug("setting mLastCalendarSync "); | 976 | qDebug("setting mLastCalendarSync "); |
991 | } | 977 | } |
992 | //qDebug("*************************** "); | 978 | //qDebug("*************************** "); |
993 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 979 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
994 | QPtrList<Incidence> er = remote->rawIncidences(); | 980 | QPtrList<Incidence> er = remote->rawIncidences(); |
995 | Incidence* inR = er.first(); | 981 | Incidence* inR = er.first(); |
996 | Incidence* inL; | 982 | Incidence* inL; |
997 | QProgressBar bar( er.count(),0 ); | 983 | QProgressBar bar( er.count(),0 ); |
998 | bar.setCaption (i18n("Syncing - close to abort!") ); | 984 | bar.setCaption (i18n("Syncing - close to abort!") ); |
999 | 985 | ||
1000 | int w = 300; | 986 | int w = 300; |
1001 | if ( QApplication::desktop()->width() < 320 ) | 987 | if ( QApplication::desktop()->width() < 320 ) |
1002 | w = 220; | 988 | w = 220; |
1003 | int h = bar.sizeHint().height() ; | 989 | int h = bar.sizeHint().height() ; |
1004 | int dw = QApplication::desktop()->width(); | 990 | int dw = QApplication::desktop()->width(); |
1005 | int dh = QApplication::desktop()->height(); | 991 | int dh = QApplication::desktop()->height(); |
1006 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 992 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1007 | bar.show(); | 993 | bar.show(); |
1008 | int modulo = (er.count()/10)+1; | 994 | int modulo = (er.count()/10)+1; |
1009 | int incCounter = 0; | 995 | int incCounter = 0; |
1010 | while ( inR ) { | 996 | while ( inR ) { |
1011 | if ( ! bar.isVisible() ) | 997 | if ( ! bar.isVisible() ) |
1012 | return false; | 998 | return false; |
1013 | if ( incCounter % modulo == 0 ) | 999 | if ( incCounter % modulo == 0 ) |
1014 | bar.setProgress( incCounter ); | 1000 | bar.setProgress( incCounter ); |
1015 | ++incCounter; | 1001 | ++incCounter; |
1016 | uid = inR->uid(); | 1002 | uid = inR->uid(); |
1017 | bool skipIncidence = false; | 1003 | bool skipIncidence = false; |
1018 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1004 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1019 | skipIncidence = true; | 1005 | skipIncidence = true; |
1020 | QString idS; | 1006 | QString idS; |
1021 | qApp->processEvents(); | 1007 | qApp->processEvents(); |
1022 | if ( !skipIncidence ) { | 1008 | if ( !skipIncidence ) { |
1023 | inL = local->incidence( uid ); | 1009 | inL = local->incidence( uid ); |
1024 | if ( inL ) { // maybe conflict - same uid in both calendars | 1010 | if ( inL ) { // maybe conflict - same uid in both calendars |
1025 | int maxrev = inL->revision(); | 1011 | int maxrev = inL->revision(); |
1026 | if ( maxrev < inR->revision() ) | 1012 | if ( maxrev < inR->revision() ) |
1027 | maxrev = inR->revision(); | 1013 | maxrev = inR->revision(); |
1028 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1014 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1029 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1015 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1030 | if ( take == 3 ) | 1016 | if ( take == 3 ) |
1031 | return false; | 1017 | return false; |
1032 | if ( take == 1 ) {// take local | 1018 | if ( take == 1 ) {// take local |
1033 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1019 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1034 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1020 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1035 | else | 1021 | else |
1036 | idS = inR->IDStr(); | 1022 | idS = inR->IDStr(); |
1037 | remote->deleteIncidence( inR ); | 1023 | remote->deleteIncidence( inR ); |
1038 | if ( inL->revision() < maxrev ) | 1024 | if ( inL->revision() < maxrev ) |
1039 | inL->setRevision( maxrev ); | 1025 | inL->setRevision( maxrev ); |
1040 | inR = inL->clone(); | 1026 | inR = inL->clone(); |
1041 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1027 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1042 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1028 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1043 | inR->setIDStr( idS ); | 1029 | inR->setIDStr( idS ); |
1044 | remote->addIncidence( inR ); | 1030 | remote->addIncidence( inR ); |
1045 | ++changedRemote; | 1031 | ++changedRemote; |
1046 | } else { | 1032 | } else { |
1047 | if ( inR->revision() < maxrev ) | 1033 | if ( inR->revision() < maxrev ) |
1048 | inR->setRevision( maxrev ); | 1034 | inR->setRevision( maxrev ); |
1049 | idS = inL->IDStr(); | 1035 | idS = inL->IDStr(); |
1050 | local->deleteIncidence( inL ); | 1036 | local->deleteIncidence( inL ); |
1051 | inL = inR->clone(); | 1037 | inL = inR->clone(); |
1052 | inL->setIDStr( idS ); | 1038 | inL->setIDStr( idS ); |
1053 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1039 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1054 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1040 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1055 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1041 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1056 | } | 1042 | } |
1057 | local->addIncidence( inL ); | 1043 | local->addIncidence( inL ); |
1058 | ++changedLocal; | 1044 | ++changedLocal; |
1059 | } | 1045 | } |
1060 | } | 1046 | } |
1061 | } else { // no conflict | 1047 | } else { // no conflict |
1062 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1048 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1063 | QString des = eventLSync->description(); | 1049 | QString des = eventLSync->description(); |
1064 | QString pref = "e"; | 1050 | QString pref = "e"; |
1065 | if ( inR->type() == "Todo" ) | 1051 | if ( inR->type() == "Todo" ) |
1066 | pref = "t"; | 1052 | pref = "t"; |
1067 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1053 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1068 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1054 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1069 | //remote->deleteIncidence( inR ); | 1055 | //remote->deleteIncidence( inR ); |
1070 | ++deletedEventR; | 1056 | ++deletedEventR; |
1071 | } else { | 1057 | } else { |
1072 | inR->setLastModified( modifiedCalendar ); | 1058 | inR->setLastModified( modifiedCalendar ); |
1073 | inL = inR->clone(); | 1059 | inL = inR->clone(); |
1074 | local->addIncidence( inL ); | 1060 | local->addIncidence( inL ); |
1075 | ++addedEvent; | 1061 | ++addedEvent; |
1076 | } | 1062 | } |
1077 | } else { | 1063 | } else { |
1078 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1064 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1079 | inR->setLastModified( modifiedCalendar ); | 1065 | inR->setLastModified( modifiedCalendar ); |
1080 | local->addIncidence( inR->clone() ); | 1066 | local->addIncidence( inR->clone() ); |
1081 | ++addedEvent; | 1067 | ++addedEvent; |
1082 | } else { | 1068 | } else { |
1083 | checkExternSyncEvent(eventRSyncSharp, inR); | 1069 | checkExternSyncEvent(eventRSyncSharp, inR); |
1084 | remote->deleteIncidence( inR ); | 1070 | remote->deleteIncidence( inR ); |
1085 | ++deletedEventR; | 1071 | ++deletedEventR; |
1086 | } | 1072 | } |
1087 | } | 1073 | } |
1088 | } | 1074 | } |
1089 | } | 1075 | } |
1090 | inR = er.next(); | 1076 | inR = er.next(); |
1091 | } | 1077 | } |
1092 | QPtrList<Incidence> el = local->rawIncidences(); | 1078 | QPtrList<Incidence> el = local->rawIncidences(); |
1093 | inL = el.first(); | 1079 | inL = el.first(); |
1094 | modulo = (el.count()/10)+1; | 1080 | modulo = (el.count()/10)+1; |
1095 | bar.setCaption (i18n("Add / remove events") ); | 1081 | bar.setCaption (i18n("Add / remove events") ); |
1096 | bar.setTotalSteps ( el.count() ) ; | 1082 | bar.setTotalSteps ( el.count() ) ; |
1097 | bar.show(); | 1083 | bar.show(); |
1098 | incCounter = 0; | 1084 | incCounter = 0; |
1099 | 1085 | ||
1100 | while ( inL ) { | 1086 | while ( inL ) { |
1101 | 1087 | ||
1102 | qApp->processEvents(); | 1088 | qApp->processEvents(); |
1103 | if ( ! bar.isVisible() ) | 1089 | if ( ! bar.isVisible() ) |
1104 | return false; | 1090 | return false; |
1105 | if ( incCounter % modulo == 0 ) | 1091 | if ( incCounter % modulo == 0 ) |
1106 | bar.setProgress( incCounter ); | 1092 | bar.setProgress( incCounter ); |
1107 | ++incCounter; | 1093 | ++incCounter; |
1108 | uid = inL->uid(); | 1094 | uid = inL->uid(); |
1109 | bool skipIncidence = false; | 1095 | bool skipIncidence = false; |
1110 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1096 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1111 | skipIncidence = true; | 1097 | skipIncidence = true; |
1112 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1098 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1113 | skipIncidence = true; | 1099 | skipIncidence = true; |
1114 | if ( !skipIncidence ) { | 1100 | if ( !skipIncidence ) { |
1115 | inR = remote->incidence( uid ); | 1101 | inR = remote->incidence( uid ); |
1116 | if ( ! inR ) { | 1102 | if ( ! inR ) { |
1117 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1103 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1118 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1104 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1119 | checkExternSyncEvent(eventLSyncSharp, inL); | 1105 | checkExternSyncEvent(eventLSyncSharp, inL); |
1120 | local->deleteIncidence( inL ); | 1106 | local->deleteIncidence( inL ); |
1121 | ++deletedEventL; | 1107 | ++deletedEventL; |
1122 | } else { | 1108 | } else { |
1123 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1109 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1124 | inL->removeID(mCurrentSyncDevice ); | 1110 | inL->removeID(mCurrentSyncDevice ); |
1125 | ++addedEventR; | 1111 | ++addedEventR; |
1126 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1112 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1127 | inL->setLastModified( modifiedCalendar ); | 1113 | inL->setLastModified( modifiedCalendar ); |
1128 | inR = inL->clone(); | 1114 | inR = inL->clone(); |
1129 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1115 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1130 | remote->addIncidence( inR ); | 1116 | remote->addIncidence( inR ); |
1131 | } | 1117 | } |
1132 | } | 1118 | } |
1133 | } else { | 1119 | } else { |
1134 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1120 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1135 | checkExternSyncEvent(eventLSyncSharp, inL); | 1121 | checkExternSyncEvent(eventLSyncSharp, inL); |
1136 | local->deleteIncidence( inL ); | 1122 | local->deleteIncidence( inL ); |
1137 | ++deletedEventL; | 1123 | ++deletedEventL; |
1138 | } else { | 1124 | } else { |
1139 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1125 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1140 | ++addedEventR; | 1126 | ++addedEventR; |
1141 | inL->setLastModified( modifiedCalendar ); | 1127 | inL->setLastModified( modifiedCalendar ); |
1142 | remote->addIncidence( inL->clone() ); | 1128 | remote->addIncidence( inL->clone() ); |
1143 | } | 1129 | } |
1144 | } | 1130 | } |
1145 | } | 1131 | } |
1146 | } | 1132 | } |
1147 | } | 1133 | } |
1148 | inL = el.next(); | 1134 | inL = el.next(); |
1149 | } | 1135 | } |
1150 | int delFut = 0; | 1136 | int delFut = 0; |
1151 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1137 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
1152 | er = remote->rawIncidences(); | 1138 | er = remote->rawIncidences(); |
1153 | inR = er.first(); | 1139 | inR = er.first(); |
1154 | QDateTime dt; | 1140 | QDateTime dt; |
1155 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1141 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1156 | QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); | 1142 | QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); |
1157 | while ( inR ) { | 1143 | while ( inR ) { |
1158 | if ( inR->type() == "Todo" ) { | 1144 | if ( inR->type() == "Todo" ) { |
1159 | Todo * t = (Todo*)inR; | 1145 | Todo * t = (Todo*)inR; |
1160 | if ( t->hasDueDate() ) | 1146 | if ( t->hasDueDate() ) |
1161 | dt = t->dtDue(); | 1147 | dt = t->dtDue(); |
1162 | else | 1148 | else |
1163 | dt = cur.addSecs( 62 ); | 1149 | dt = cur.addSecs( 62 ); |
1164 | } | 1150 | } |
1165 | else if (inR->type() == "Event" ) { | 1151 | else if (inR->type() == "Event" ) { |
1166 | bool ok; | 1152 | bool ok; |
1167 | dt = inR->getNextOccurence( cur, &ok ); | 1153 | dt = inR->getNextOccurence( cur, &ok ); |
1168 | if ( !ok ) | 1154 | if ( !ok ) |
1169 | dt = cur.addSecs( -62 ); | 1155 | dt = cur.addSecs( -62 ); |
1170 | } | 1156 | } |
1171 | else | 1157 | else |
1172 | dt = inR->dtStart(); | 1158 | dt = inR->dtStart(); |
1173 | if ( dt < cur || dt > end ) { | 1159 | if ( dt < cur || dt > end ) { |
1174 | remote->deleteIncidence( inR ); | 1160 | remote->deleteIncidence( inR ); |
1175 | ++delFut; | 1161 | ++delFut; |
1176 | } | 1162 | } |
1177 | inR = er.next(); | 1163 | inR = er.next(); |
1178 | } | 1164 | } |
1179 | } | 1165 | } |
1180 | bar.hide(); | 1166 | bar.hide(); |
1181 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1167 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1182 | eventLSync->setReadOnly( false ); | 1168 | eventLSync->setReadOnly( false ); |
1183 | eventLSync->setDtStart( mLastCalendarSync ); | 1169 | eventLSync->setDtStart( mLastCalendarSync ); |
1184 | eventRSync->setDtStart( mLastCalendarSync ); | 1170 | eventRSync->setDtStart( mLastCalendarSync ); |
1185 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1171 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1186 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1172 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1187 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1173 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1188 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1174 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1189 | eventLSync->setReadOnly( true ); | 1175 | eventLSync->setReadOnly( true ); |
1190 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1176 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1191 | remote->addEvent( eventRSync ); | 1177 | remote->addEvent( eventRSync ); |
1192 | QString mes; | 1178 | QString mes; |
1193 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1179 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1194 | QString delmess; | 1180 | QString delmess; |
1195 | if ( delFut ) { | 1181 | if ( delFut ) { |
1196 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); | 1182 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); |
1197 | mes += delmess; | 1183 | mes += delmess; |
1198 | } | 1184 | } |
1199 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1185 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1200 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1186 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1201 | } | 1187 | } |
1202 | qDebug( mes ); | 1188 | qDebug( mes ); |
1203 | mCalendar->checkAlarmForIncidence( 0, true ); | 1189 | mCalendar->checkAlarmForIncidence( 0, true ); |
1204 | return syncOK; | 1190 | return syncOK; |
1205 | } | 1191 | } |
1206 | 1192 | ||
1207 | void CalendarView::setSyncDevice( QString s ) | 1193 | void CalendarView::setSyncDevice( QString s ) |
1208 | { | 1194 | { |
1209 | mCurrentSyncDevice= s; | 1195 | mCurrentSyncDevice= s; |
1210 | } | 1196 | } |
1211 | void CalendarView::setSyncName( QString s ) | 1197 | void CalendarView::setSyncName( QString s ) |
1212 | { | 1198 | { |
1213 | mCurrentSyncName= s; | 1199 | mCurrentSyncName= s; |
1214 | } | 1200 | } |
1215 | bool CalendarView::syncCalendar(QString filename, int mode) | 1201 | bool CalendarView::syncCalendar(QString filename, int mode) |
1216 | { | 1202 | { |
1217 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1203 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1218 | CalendarLocal* calendar = new CalendarLocal(); | 1204 | CalendarLocal* calendar = new CalendarLocal(); |
1219 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1205 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1220 | FileStorage* storage = new FileStorage( calendar ); | 1206 | FileStorage* storage = new FileStorage( calendar ); |
1221 | bool syncOK = false; | 1207 | bool syncOK = false; |
1222 | storage->setFileName( filename ); | 1208 | storage->setFileName( filename ); |
1223 | // qDebug("loading ... "); | 1209 | // qDebug("loading ... "); |
1224 | if ( storage->load() ) { | 1210 | if ( storage->load() ) { |
1225 | getEventViewerDialog()->setSyncMode( true ); | 1211 | getEventViewerDialog()->setSyncMode( true ); |
1226 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1212 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1227 | getEventViewerDialog()->setSyncMode( false ); | 1213 | getEventViewerDialog()->setSyncMode( false ); |
1228 | if ( syncOK ) { | 1214 | if ( syncOK ) { |
1229 | if ( KOPrefs::instance()->mWriteBackFile ) | 1215 | if ( KOPrefs::instance()->mWriteBackFile ) |
1230 | { | 1216 | { |
1231 | storage->setSaveFormat( new ICalFormat() ); | 1217 | storage->setSaveFormat( new ICalFormat() ); |
1232 | storage->save(); | 1218 | storage->save(); |
1233 | } | 1219 | } |
1234 | } | 1220 | } |
1235 | setModified( true ); | 1221 | setModified( true ); |
1236 | } | 1222 | } |
1237 | delete storage; | 1223 | delete storage; |
1238 | delete calendar; | 1224 | delete calendar; |
1239 | if ( syncOK ) | 1225 | if ( syncOK ) |
1240 | updateView(); | 1226 | updateView(); |
1241 | return syncOK; | 1227 | return syncOK; |
1242 | } | 1228 | } |
1243 | void CalendarView::syncPhone() | 1229 | void CalendarView::syncPhone() |
1244 | { | 1230 | { |
1245 | syncExternal( 1 ); | 1231 | syncExternal( 1 ); |
1246 | } | 1232 | } |
1247 | void CalendarView::syncExternal( int mode ) | 1233 | void CalendarView::syncExternal( int mode ) |
1248 | { | 1234 | { |
1249 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1235 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1250 | //mCurrentSyncDevice = "sharp-DTM"; | 1236 | //mCurrentSyncDevice = "sharp-DTM"; |
1251 | if ( KOPrefs::instance()->mAskForPreferences ) | 1237 | if ( KOPrefs::instance()->mAskForPreferences ) |
1252 | edit_sync_options(); | 1238 | edit_sync_options(); |
1253 | qApp->processEvents(); | 1239 | qApp->processEvents(); |
1254 | CalendarLocal* calendar = new CalendarLocal(); | 1240 | CalendarLocal* calendar = new CalendarLocal(); |
1255 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1241 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1256 | bool syncOK = false; | 1242 | bool syncOK = false; |
1257 | bool loadSuccess = false; | 1243 | bool loadSuccess = false; |
1258 | PhoneFormat* phoneFormat = 0; | 1244 | PhoneFormat* phoneFormat = 0; |
1259 | #ifndef DESKTOP_VERSION | 1245 | #ifndef DESKTOP_VERSION |
1260 | SharpFormat* sharpFormat = 0; | 1246 | SharpFormat* sharpFormat = 0; |
1261 | if ( mode == 0 ) { // sharp | 1247 | if ( mode == 0 ) { // sharp |
1262 | sharpFormat = new SharpFormat () ; | 1248 | sharpFormat = new SharpFormat () ; |
1263 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1249 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1264 | 1250 | ||
1265 | } else | 1251 | } else |
1266 | #endif | 1252 | #endif |
1267 | if ( mode == 1 ) { // phone | 1253 | if ( mode == 1 ) { // phone |
1268 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1254 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1269 | KOPrefs::instance()->mPhoneDevice, | 1255 | KOPrefs::instance()->mPhoneDevice, |
1270 | KOPrefs::instance()->mPhoneConnection, | 1256 | KOPrefs::instance()->mPhoneConnection, |
1271 | KOPrefs::instance()->mPhoneModel); | 1257 | KOPrefs::instance()->mPhoneModel); |
1272 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1258 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1273 | 1259 | ||
1274 | } else | 1260 | } else |
1275 | return; | 1261 | return; |
1276 | if ( loadSuccess ) { | 1262 | if ( loadSuccess ) { |
1277 | getEventViewerDialog()->setSyncMode( true ); | 1263 | getEventViewerDialog()->setSyncMode( true ); |
1278 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1264 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1279 | getEventViewerDialog()->setSyncMode( false ); | 1265 | getEventViewerDialog()->setSyncMode( false ); |
1280 | qApp->processEvents(); | 1266 | qApp->processEvents(); |
1281 | if ( syncOK ) { | 1267 | if ( syncOK ) { |
1282 | if ( KOPrefs::instance()->mWriteBackFile ) | 1268 | if ( KOPrefs::instance()->mWriteBackFile ) |
1283 | { | 1269 | { |
1284 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1270 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1285 | Incidence* inc = iL.first(); | 1271 | Incidence* inc = iL.first(); |
1286 | if ( phoneFormat ) { | 1272 | if ( phoneFormat ) { |
1287 | while ( inc ) { | 1273 | while ( inc ) { |
1288 | inc->removeID(mCurrentSyncDevice); | 1274 | inc->removeID(mCurrentSyncDevice); |
1289 | inc = iL.next(); | 1275 | inc = iL.next(); |
1290 | } | 1276 | } |
1291 | } | 1277 | } |
1292 | #ifndef DESKTOP_VERSION | 1278 | #ifndef DESKTOP_VERSION |
1293 | if ( sharpFormat ) | 1279 | if ( sharpFormat ) |
1294 | sharpFormat->save(calendar); | 1280 | sharpFormat->save(calendar); |
1295 | #endif | 1281 | #endif |
1296 | if ( phoneFormat ) | 1282 | if ( phoneFormat ) |
1297 | phoneFormat->save(calendar); | 1283 | phoneFormat->save(calendar); |
1298 | iL = calendar->rawIncidences(); | 1284 | iL = calendar->rawIncidences(); |
1299 | inc = iL.first(); | 1285 | inc = iL.first(); |
1300 | Incidence* loc; | 1286 | Incidence* loc; |
1301 | while ( inc ) { | 1287 | while ( inc ) { |
1302 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1288 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1303 | loc = mCalendar->incidence(inc->uid() ); | 1289 | loc = mCalendar->incidence(inc->uid() ); |
1304 | if ( loc ) { | 1290 | if ( loc ) { |
1305 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1291 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1306 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1292 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1307 | } | 1293 | } |
1308 | } | 1294 | } |
1309 | inc = iL.next(); | 1295 | inc = iL.next(); |
1310 | } | 1296 | } |
1311 | Incidence* lse = getLastSyncEvent(); | 1297 | Incidence* lse = getLastSyncEvent(); |
1312 | if ( lse ) { | 1298 | if ( lse ) { |
1313 | lse->setReadOnly( false ); | 1299 | lse->setReadOnly( false ); |
1314 | lse->setDescription( "" ); | 1300 | lse->setDescription( "" ); |
1315 | lse->setReadOnly( true ); | 1301 | lse->setReadOnly( true ); |
1316 | } | 1302 | } |
1317 | } | 1303 | } |
1318 | } | 1304 | } |
1319 | setModified( true ); | 1305 | setModified( true ); |
1320 | } else { | 1306 | } else { |
1321 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1307 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1322 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1308 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1323 | question, i18n("Ok")) ; | 1309 | question, i18n("Ok")) ; |
1324 | 1310 | ||
1325 | } | 1311 | } |
1326 | delete calendar; | 1312 | delete calendar; |
1327 | updateView(); | 1313 | updateView(); |
1328 | return ;//syncOK; | 1314 | return ;//syncOK; |
1329 | 1315 | ||
1330 | } | 1316 | } |
1331 | void CalendarView::syncSharp() | 1317 | void CalendarView::syncSharp() |
1332 | { | 1318 | { |
1333 | syncExternal( 0 ); | 1319 | syncExternal( 0 ); |
1334 | 1320 | ||
1335 | } | 1321 | } |
1336 | 1322 | ||
1337 | 1323 | ||
1338 | //#include <kabc/stdaddressbook.h> | 1324 | //#include <kabc/stdaddressbook.h> |
1339 | bool CalendarView::importBday() | 1325 | bool CalendarView::importBday() |
1340 | { | 1326 | { |
1341 | #if 0 | 1327 | #if 0 |
1342 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1328 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1343 | KABC::AddressBook::Iterator it; | 1329 | KABC::AddressBook::Iterator it; |
1344 | int count = 0; | 1330 | int count = 0; |
1345 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1331 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1346 | ++count; | 1332 | ++count; |
1347 | } | 1333 | } |
1348 | QProgressBar bar(count,0 ); | 1334 | QProgressBar bar(count,0 ); |
1349 | int w = 300; | 1335 | int w = 300; |
1350 | if ( QApplication::desktop()->width() < 320 ) | 1336 | if ( QApplication::desktop()->width() < 320 ) |
1351 | w = 220; | 1337 | w = 220; |
1352 | int h = bar.sizeHint().height() ; | 1338 | int h = bar.sizeHint().height() ; |
1353 | int dw = QApplication::desktop()->width(); | 1339 | int dw = QApplication::desktop()->width(); |
1354 | int dh = QApplication::desktop()->height(); | 1340 | int dh = QApplication::desktop()->height(); |
1355 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1341 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1356 | bar.show(); | 1342 | bar.show(); |
1357 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1343 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1358 | qApp->processEvents(); | 1344 | qApp->processEvents(); |
1359 | count = 0; | 1345 | count = 0; |
1360 | int addCount = 0; | 1346 | int addCount = 0; |
1361 | KCal::Attendee* a = 0; | 1347 | KCal::Attendee* a = 0; |
1362 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1348 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1363 | if ( ! bar.isVisible() ) | 1349 | if ( ! bar.isVisible() ) |
1364 | return false; | 1350 | return false; |
1365 | bar.setProgress( count++ ); | 1351 | bar.setProgress( count++ ); |
1366 | qApp->processEvents(); | 1352 | qApp->processEvents(); |
1367 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1353 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1368 | if ( (*it).birthday().date().isValid() ){ | 1354 | if ( (*it).birthday().date().isValid() ){ |
1369 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1355 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1370 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1356 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1371 | ++addCount; | 1357 | ++addCount; |
1372 | } | 1358 | } |
1373 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1359 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1374 | if ( anni.isValid() ){ | 1360 | if ( anni.isValid() ){ |
1375 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1361 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1376 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1362 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1377 | ++addCount; | 1363 | ++addCount; |
1378 | } | 1364 | } |
1379 | } | 1365 | } |
1380 | updateView(); | 1366 | updateView(); |
1381 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1367 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1382 | #endif | 1368 | #endif |
1383 | return true; | 1369 | return true; |
1384 | } | 1370 | } |
1385 | 1371 | ||
1386 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1372 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1387 | { | 1373 | { |
1388 | //qDebug("addAnni "); | 1374 | //qDebug("addAnni "); |
1389 | Event * ev = new Event(); | 1375 | Event * ev = new Event(); |
1390 | if ( a ) { | 1376 | if ( a ) { |
1391 | ev->addAttendee( a ); | 1377 | ev->addAttendee( a ); |
1392 | } | 1378 | } |
1393 | QString kind; | 1379 | QString kind; |
1394 | if ( birthday ) | 1380 | if ( birthday ) |
1395 | kind = i18n( "Birthday" ); | 1381 | kind = i18n( "Birthday" ); |
1396 | else | 1382 | else |
1397 | kind = i18n( "Anniversary" ); | 1383 | kind = i18n( "Anniversary" ); |
1398 | ev->setSummary( name + " - " + kind ); | 1384 | ev->setSummary( name + " - " + kind ); |
1399 | ev->setOrganizer( "nobody@nowhere" ); | 1385 | ev->setOrganizer( "nobody@nowhere" ); |
1400 | ev->setCategories( kind ); | 1386 | ev->setCategories( kind ); |
1401 | ev->setDtStart( QDateTime(date) ); | 1387 | ev->setDtStart( QDateTime(date) ); |
1402 | ev->setDtEnd( QDateTime(date) ); | 1388 | ev->setDtEnd( QDateTime(date) ); |
1403 | ev->setFloats( true ); | 1389 | ev->setFloats( true ); |
1404 | Recurrence * rec = ev->recurrence(); | 1390 | Recurrence * rec = ev->recurrence(); |
1405 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1391 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1406 | rec->addYearlyNum( date.month() ); | 1392 | rec->addYearlyNum( date.month() ); |
1407 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1393 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1408 | delete ev; | 1394 | delete ev; |
1409 | return false; | 1395 | return false; |
1410 | } | 1396 | } |
1411 | return true; | 1397 | return true; |
1412 | 1398 | ||
1413 | } | 1399 | } |
1414 | bool CalendarView::importQtopia( const QString &categories, | 1400 | bool CalendarView::importQtopia( const QString &categories, |
1415 | const QString &datebook, | 1401 | const QString &datebook, |
1416 | const QString &todolist ) | 1402 | const QString &todolist ) |
1417 | { | 1403 | { |
1418 | 1404 | ||
1419 | QtopiaFormat qtopiaFormat; | 1405 | QtopiaFormat qtopiaFormat; |
1420 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1406 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1421 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1407 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1422 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1408 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1423 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1409 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1424 | 1410 | ||
1425 | updateView(); | 1411 | updateView(); |
1426 | return true; | 1412 | return true; |
1427 | 1413 | ||
1428 | #if 0 | 1414 | #if 0 |
1429 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1415 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1430 | mCurrentSyncDevice = "qtopia-XML"; | 1416 | mCurrentSyncDevice = "qtopia-XML"; |
1431 | if ( KOPrefs::instance()->mAskForPreferences ) | 1417 | if ( KOPrefs::instance()->mAskForPreferences ) |
1432 | edit_sync_options(); | 1418 | edit_sync_options(); |
1433 | qApp->processEvents(); | 1419 | qApp->processEvents(); |
1434 | CalendarLocal* calendar = new CalendarLocal(); | 1420 | CalendarLocal* calendar = new CalendarLocal(); |
1435 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1421 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1436 | bool syncOK = false; | 1422 | bool syncOK = false; |
1437 | QtopiaFormat qtopiaFormat; | 1423 | QtopiaFormat qtopiaFormat; |
1438 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1424 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1439 | bool loadOk = true; | 1425 | bool loadOk = true; |
1440 | if ( !categories.isEmpty() ) | 1426 | if ( !categories.isEmpty() ) |
1441 | loadOk = qtopiaFormat.load( calendar, categories ); | 1427 | loadOk = qtopiaFormat.load( calendar, categories ); |
1442 | if ( loadOk && !datebook.isEmpty() ) | 1428 | if ( loadOk && !datebook.isEmpty() ) |
1443 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1429 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1444 | if ( loadOk && !todolist.isEmpty() ) | 1430 | if ( loadOk && !todolist.isEmpty() ) |
1445 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1431 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1446 | 1432 | ||
1447 | if ( loadOk ) { | 1433 | if ( loadOk ) { |
1448 | getEventViewerDialog()->setSyncMode( true ); | 1434 | getEventViewerDialog()->setSyncMode( true ); |
1449 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1435 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1450 | getEventViewerDialog()->setSyncMode( false ); | 1436 | getEventViewerDialog()->setSyncMode( false ); |
1451 | qApp->processEvents(); | 1437 | qApp->processEvents(); |
1452 | if ( syncOK ) { | 1438 | if ( syncOK ) { |
1453 | if ( KOPrefs::instance()->mWriteBackFile ) | 1439 | if ( KOPrefs::instance()->mWriteBackFile ) |
1454 | { | 1440 | { |
1455 | // write back XML file | 1441 | // write back XML file |
1456 | 1442 | ||
1457 | } | 1443 | } |
1458 | setModified( true ); | 1444 | setModified( true ); |
1459 | } | 1445 | } |
1460 | } else { | 1446 | } else { |
1461 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1447 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1462 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1448 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1463 | question, i18n("Ok")) ; | 1449 | question, i18n("Ok")) ; |
1464 | } | 1450 | } |
1465 | delete calendar; | 1451 | delete calendar; |
1466 | updateView(); | 1452 | updateView(); |
1467 | return syncOK; | 1453 | return syncOK; |
1468 | 1454 | ||
1469 | 1455 | ||
1470 | #endif | 1456 | #endif |
1471 | 1457 | ||
1472 | } | 1458 | } |
1473 | 1459 | ||
1474 | void CalendarView::setSyncEventsReadOnly() | 1460 | void CalendarView::setSyncEventsReadOnly() |
1475 | { | 1461 | { |
1476 | Event * ev; | 1462 | Event * ev; |
1477 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1463 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1478 | ev = eL.first(); | 1464 | ev = eL.first(); |
1479 | while ( ev ) { | 1465 | while ( ev ) { |
1480 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1466 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1481 | ev->setReadOnly( true ); | 1467 | ev->setReadOnly( true ); |
1482 | ev = eL.next(); | 1468 | ev = eL.next(); |
1483 | } | 1469 | } |
1484 | } | 1470 | } |
1485 | bool CalendarView::openCalendar(QString filename, bool merge) | 1471 | bool CalendarView::openCalendar(QString filename, bool merge) |
1486 | { | 1472 | { |
1487 | 1473 | ||
1488 | if (filename.isEmpty()) { | 1474 | if (filename.isEmpty()) { |
1489 | return false; | 1475 | return false; |
1490 | } | 1476 | } |
1491 | 1477 | ||
1492 | if (!QFile::exists(filename)) { | 1478 | if (!QFile::exists(filename)) { |
1493 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1479 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1494 | return false; | 1480 | return false; |
1495 | } | 1481 | } |
1496 | 1482 | ||
1497 | globalFlagBlockAgenda = 1; | 1483 | globalFlagBlockAgenda = 1; |
1498 | if (!merge) mCalendar->close(); | 1484 | if (!merge) mCalendar->close(); |
1499 | 1485 | ||
1500 | mStorage->setFileName( filename ); | 1486 | mStorage->setFileName( filename ); |
1501 | 1487 | ||
1502 | if ( mStorage->load() ) { | 1488 | if ( mStorage->load() ) { |
1503 | if ( merge ) ;//setModified( true ); | 1489 | if ( merge ) ;//setModified( true ); |
1504 | else { | 1490 | else { |
1505 | //setModified( true ); | 1491 | //setModified( true ); |
1506 | mViewManager->setDocumentId( filename ); | 1492 | mViewManager->setDocumentId( filename ); |
1507 | mDialogManager->setDocumentId( filename ); | 1493 | mDialogManager->setDocumentId( filename ); |
1508 | mTodoList->setDocumentId( filename ); | 1494 | mTodoList->setDocumentId( filename ); |
1509 | } | 1495 | } |
1510 | globalFlagBlockAgenda = 2; | 1496 | globalFlagBlockAgenda = 2; |
1511 | // if ( getLastSyncEvent() ) | 1497 | // if ( getLastSyncEvent() ) |
1512 | // getLastSyncEvent()->setReadOnly( true ); | 1498 | // getLastSyncEvent()->setReadOnly( true ); |
1513 | mCalendar->reInitAlarmSettings(); | 1499 | mCalendar->reInitAlarmSettings(); |
1514 | setSyncEventsReadOnly(); | 1500 | setSyncEventsReadOnly(); |
1515 | updateUnmanagedViews(); | 1501 | updateUnmanagedViews(); |
1516 | updateView(); | 1502 | updateView(); |
1517 | setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 )); | 1503 | setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 )); |
1518 | if ( filename != MainWindow::defaultFileName() ) { | 1504 | if ( filename != MainWindow::defaultFileName() ) { |
1519 | saveCalendar( MainWindow::defaultFileName() ); | 1505 | saveCalendar( MainWindow::defaultFileName() ); |
1520 | watchSavedFile(); | 1506 | watchSavedFile(); |
1521 | } | 1507 | } |
1522 | return true; | 1508 | return true; |
1523 | } else { | 1509 | } else { |
1524 | // while failing to load, the calendar object could | 1510 | // while failing to load, the calendar object could |
1525 | // have become partially populated. Clear it out. | 1511 | // have become partially populated. Clear it out. |
1526 | if ( !merge ) { | 1512 | if ( !merge ) { |
1527 | mCalendar->close(); | 1513 | mCalendar->close(); |
1528 | mViewManager->setDocumentId( filename ); | 1514 | mViewManager->setDocumentId( filename ); |
1529 | mDialogManager->setDocumentId( filename ); | 1515 | mDialogManager->setDocumentId( filename ); |
1530 | mTodoList->setDocumentId( filename ); | 1516 | mTodoList->setDocumentId( filename ); |
1531 | } | 1517 | } |
1532 | 1518 | ||
1533 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1519 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1534 | 1520 | ||
1535 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1521 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1536 | globalFlagBlockAgenda = 2; | 1522 | globalFlagBlockAgenda = 2; |
1537 | mCalendar->reInitAlarmSettings(); | 1523 | mCalendar->reInitAlarmSettings(); |
1538 | setSyncEventsReadOnly(); | 1524 | setSyncEventsReadOnly(); |
1539 | updateUnmanagedViews(); | 1525 | updateUnmanagedViews(); |
1540 | updateView(); | 1526 | updateView(); |
1541 | } | 1527 | } |
1542 | return false; | 1528 | return false; |
1543 | } | 1529 | } |
1544 | void CalendarView::showOpenError() | 1530 | void CalendarView::showOpenError() |
1545 | { | 1531 | { |
1546 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1532 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1547 | } | 1533 | } |
1548 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1534 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1549 | { | 1535 | { |
1550 | loadedFileVersion = dt; | 1536 | loadedFileVersion = dt; |
1551 | } | 1537 | } |
1552 | bool CalendarView::checkFileChanged(QString fn) | 1538 | bool CalendarView::checkFileChanged(QString fn) |
1553 | { | 1539 | { |
1554 | QFileInfo finf ( fn ); | 1540 | QFileInfo finf ( fn ); |
1555 | if ( !finf.exists() ) | 1541 | if ( !finf.exists() ) |
1556 | return true; | 1542 | return true; |
1557 | QDateTime dt = finf.lastModified (); | 1543 | QDateTime dt = finf.lastModified (); |
1558 | if ( dt <= loadedFileVersion ) | 1544 | if ( dt <= loadedFileVersion ) |
1559 | return false; | 1545 | return false; |
1560 | return true; | 1546 | return true; |
1561 | 1547 | ||
1562 | } | 1548 | } |
1563 | void CalendarView::watchSavedFile() | 1549 | void CalendarView::watchSavedFile() |
1564 | { | 1550 | { |
1565 | QFileInfo finf ( MainWindow::defaultFileName()); | 1551 | QFileInfo finf ( MainWindow::defaultFileName()); |
1566 | if ( !finf.exists() ) | 1552 | if ( !finf.exists() ) |
1567 | return; | 1553 | return; |
1568 | QDateTime dt = finf.lastModified (); | 1554 | QDateTime dt = finf.lastModified (); |
1569 | if ( dt < loadedFileVersion ) { | 1555 | if ( dt < loadedFileVersion ) { |
1570 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1556 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1571 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1557 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1572 | return; | 1558 | return; |
1573 | } | 1559 | } |
1574 | loadedFileVersion = dt; | 1560 | loadedFileVersion = dt; |
1575 | } | 1561 | } |
1576 | 1562 | ||
1577 | bool CalendarView::checkFileVersion(QString fn) | 1563 | bool CalendarView::checkFileVersion(QString fn) |
1578 | { | 1564 | { |
1579 | QFileInfo finf ( fn ); | 1565 | QFileInfo finf ( fn ); |
1580 | if ( !finf.exists() ) | 1566 | if ( !finf.exists() ) |
1581 | return true; | 1567 | return true; |
1582 | QDateTime dt = finf.lastModified (); | 1568 | QDateTime dt = finf.lastModified (); |
1583 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1569 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1584 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1570 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1585 | if ( dt <= loadedFileVersion ) | 1571 | if ( dt <= loadedFileVersion ) |
1586 | return true; | 1572 | return true; |
1587 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1573 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1588 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1574 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1589 | i18n("Sync+save")); | 1575 | i18n("Sync+save")); |
1590 | 1576 | ||
1591 | if ( km == KMessageBox::Cancel ) | 1577 | if ( km == KMessageBox::Cancel ) |
1592 | return false; | 1578 | return false; |
1593 | if ( km == KMessageBox::Yes ) | 1579 | if ( km == KMessageBox::Yes ) |
1594 | return true; | 1580 | return true; |
1595 | 1581 | ||
1596 | setSyncDevice("deleteaftersync" ); | 1582 | setSyncDevice("deleteaftersync" ); |
1597 | KOPrefs::instance()->mAskForPreferences = true; | 1583 | KOPrefs::instance()->mAskForPreferences = true; |
1598 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1584 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1599 | KOPrefs::instance()->mWriteBackFile = false; | 1585 | KOPrefs::instance()->mWriteBackFile = false; |
1600 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1586 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1601 | KOPrefs::instance()->mShowSyncSummary = false; | 1587 | KOPrefs::instance()->mShowSyncSummary = false; |
1602 | syncCalendar( fn, 3 ); | 1588 | syncCalendar( fn, 3 ); |
1603 | Event * e = getLastSyncEvent(); | 1589 | Event * e = getLastSyncEvent(); |
1604 | mCalendar->deleteEvent ( e ); | 1590 | mCalendar->deleteEvent ( e ); |
1605 | updateView(); | 1591 | updateView(); |
1606 | return true; | 1592 | return true; |
1607 | } | 1593 | } |
1608 | 1594 | ||
1609 | bool CalendarView::saveCalendar( QString filename ) | 1595 | bool CalendarView::saveCalendar( QString filename ) |
1610 | { | 1596 | { |
1611 | 1597 | ||
1612 | // Store back all unsaved data into calendar object | 1598 | // Store back all unsaved data into calendar object |
1613 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1599 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1614 | if ( mViewManager->currentView() ) | 1600 | if ( mViewManager->currentView() ) |
1615 | mViewManager->currentView()->flushView(); | 1601 | mViewManager->currentView()->flushView(); |
1616 | 1602 | ||
1617 | //mStorage->setFileName( filename ); | 1603 | //mStorage->setFileName( filename ); |
1618 | 1604 | ||
1619 | mStorage->setSaveFormat( new ICalFormat() ); | 1605 | mStorage->setSaveFormat( new ICalFormat() ); |
1620 | mStorage->setFileName( filename ); | 1606 | mStorage->setFileName( filename ); |
1621 | bool success; | 1607 | bool success; |
1622 | success = mStorage->save(); | 1608 | success = mStorage->save(); |
1623 | if ( !success ) { | 1609 | if ( !success ) { |
1624 | return false; | 1610 | return false; |
1625 | } | 1611 | } |
1626 | 1612 | ||
1627 | return true; | 1613 | return true; |
1628 | } | 1614 | } |
1629 | 1615 | ||
1630 | void CalendarView::closeCalendar() | 1616 | void CalendarView::closeCalendar() |
1631 | { | 1617 | { |
1632 | 1618 | ||
1633 | // child windows no longer valid | 1619 | // child windows no longer valid |
1634 | emit closingDown(); | 1620 | emit closingDown(); |
1635 | 1621 | ||
1636 | mCalendar->close(); | 1622 | mCalendar->close(); |
1637 | setModified(false); | 1623 | setModified(false); |
1638 | updateView(); | 1624 | updateView(); |
1639 | } | 1625 | } |
1640 | 1626 | ||
1641 | void CalendarView::archiveCalendar() | 1627 | void CalendarView::archiveCalendar() |
1642 | { | 1628 | { |
1643 | mDialogManager->showArchiveDialog(); | 1629 | mDialogManager->showArchiveDialog(); |
1644 | } | 1630 | } |
1645 | 1631 | ||
1646 | 1632 | ||
1647 | void CalendarView::readSettings() | 1633 | void CalendarView::readSettings() |
1648 | { | 1634 | { |
1649 | 1635 | ||
1650 | 1636 | ||
1651 | // mViewManager->showAgendaView(); | 1637 | // mViewManager->showAgendaView(); |
1652 | QString str; | 1638 | QString str; |
1653 | //qDebug("CalendarView::readSettings() "); | 1639 | //qDebug("CalendarView::readSettings() "); |
1654 | // read settings from the KConfig, supplying reasonable | 1640 | // read settings from the KConfig, supplying reasonable |
1655 | // defaults where none are to be found | 1641 | // defaults where none are to be found |
1656 | KConfig *config = KOGlobals::config(); | 1642 | KConfig *config = KOGlobals::config(); |
1657 | #ifndef KORG_NOSPLITTER | 1643 | #ifndef KORG_NOSPLITTER |
1658 | config->setGroup("KOrganizer Geometry"); | 1644 | config->setGroup("KOrganizer Geometry"); |
1659 | 1645 | ||
1660 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1646 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1661 | if (sizes.count() != 2) { | 1647 | if (sizes.count() != 2) { |
1662 | sizes << mDateNavigator->minimumSizeHint().width(); | 1648 | sizes << mDateNavigator->minimumSizeHint().width(); |
1663 | sizes << 300; | 1649 | sizes << 300; |
1664 | } | 1650 | } |
1665 | mPanner->setSizes(sizes); | 1651 | mPanner->setSizes(sizes); |
1666 | 1652 | ||
1667 | sizes = config->readIntListEntry("Separator2"); | 1653 | sizes = config->readIntListEntry("Separator2"); |
1668 | if ( ( mResourceView && sizes.count() == 4 ) || | 1654 | if ( ( mResourceView && sizes.count() == 4 ) || |
1669 | ( !mResourceView && sizes.count() == 3 ) ) { | 1655 | ( !mResourceView && sizes.count() == 3 ) ) { |
1670 | mLeftSplitter->setSizes(sizes); | 1656 | mLeftSplitter->setSizes(sizes); |
1671 | } | 1657 | } |
1672 | #endif | 1658 | #endif |
1673 | globalFlagBlockAgenda = 1; | 1659 | globalFlagBlockAgenda = 1; |
1674 | mViewManager->showAgendaView(); | 1660 | mViewManager->showAgendaView(); |
1675 | //mViewManager->readSettings( config ); | 1661 | //mViewManager->readSettings( config ); |
1676 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1662 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1677 | readFilterSettings(config); | 1663 | readFilterSettings(config); |
1678 | config->setGroup( "Views" ); | 1664 | config->setGroup( "Views" ); |
1679 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1665 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1680 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1666 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1681 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1667 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1682 | else mNavigator->selectDates( dateCount ); | 1668 | else mNavigator->selectDates( dateCount ); |
1683 | // mViewManager->readSettings( config ); | 1669 | // mViewManager->readSettings( config ); |
1684 | updateConfig(); | 1670 | updateConfig(); |
1685 | globalFlagBlockAgenda = 2; | 1671 | globalFlagBlockAgenda = 2; |
1686 | mViewManager->readSettings( config ); | 1672 | mViewManager->readSettings( config ); |
1687 | #ifdef DESKTOP_VERSION | 1673 | #ifdef DESKTOP_VERSION |
1688 | config->setGroup("WidgetLayout"); | 1674 | config->setGroup("WidgetLayout"); |
1689 | QStringList list; | 1675 | QStringList list; |
1690 | list = config->readListEntry("MainLayout"); | 1676 | list = config->readListEntry("MainLayout"); |
1691 | int x,y,w,h; | 1677 | int x,y,w,h; |
1692 | if ( ! list.isEmpty() ) { | 1678 | if ( ! list.isEmpty() ) { |
1693 | x = list[0].toInt(); | 1679 | x = list[0].toInt(); |
1694 | y = list[1].toInt(); | 1680 | y = list[1].toInt(); |
1695 | w = list[2].toInt(); | 1681 | w = list[2].toInt(); |
1696 | h = list[3].toInt(); | 1682 | h = list[3].toInt(); |
1697 | topLevelWidget()->setGeometry(x,y,w,h); | 1683 | topLevelWidget()->setGeometry(x,y,w,h); |
1698 | 1684 | ||
1699 | } else { | 1685 | } else { |
1700 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1686 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1701 | } | 1687 | } |
1702 | list = config->readListEntry("EditEventLayout"); | 1688 | list = config->readListEntry("EditEventLayout"); |
1703 | if ( ! list.isEmpty() ) { | 1689 | if ( ! list.isEmpty() ) { |
1704 | x = list[0].toInt(); | 1690 | x = list[0].toInt(); |
1705 | y = list[1].toInt(); | 1691 | y = list[1].toInt(); |
1706 | w = list[2].toInt(); | 1692 | w = list[2].toInt(); |
1707 | h = list[3].toInt(); | 1693 | h = list[3].toInt(); |
1708 | mEventEditor->setGeometry(x,y,w,h); | 1694 | mEventEditor->setGeometry(x,y,w,h); |
1709 | 1695 | ||
1710 | } | 1696 | } |
1711 | list = config->readListEntry("EditTodoLayout"); | 1697 | list = config->readListEntry("EditTodoLayout"); |
1712 | if ( ! list.isEmpty() ) { | 1698 | if ( ! list.isEmpty() ) { |
1713 | x = list[0].toInt(); | 1699 | x = list[0].toInt(); |
1714 | y = list[1].toInt(); | 1700 | y = list[1].toInt(); |
1715 | w = list[2].toInt(); | 1701 | w = list[2].toInt(); |
1716 | h = list[3].toInt(); | 1702 | h = list[3].toInt(); |
1717 | mTodoEditor->setGeometry(x,y,w,h); | 1703 | mTodoEditor->setGeometry(x,y,w,h); |
1718 | 1704 | ||
1719 | } | 1705 | } |
1720 | list = config->readListEntry("ViewerLayout"); | 1706 | list = config->readListEntry("ViewerLayout"); |
1721 | if ( ! list.isEmpty() ) { | 1707 | if ( ! list.isEmpty() ) { |
1722 | x = list[0].toInt(); | 1708 | x = list[0].toInt(); |
1723 | y = list[1].toInt(); | 1709 | y = list[1].toInt(); |
1724 | w = list[2].toInt(); | 1710 | w = list[2].toInt(); |
1725 | h = list[3].toInt(); | 1711 | h = list[3].toInt(); |
1726 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1712 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1727 | } | 1713 | } |
1728 | #endif | 1714 | #endif |
1729 | 1715 | ||
1730 | } | 1716 | } |
1731 | 1717 | ||
1732 | 1718 | ||
1733 | void CalendarView::writeSettings() | 1719 | void CalendarView::writeSettings() |
1734 | { | 1720 | { |
1735 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1721 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1736 | 1722 | ||
1737 | KConfig *config = KOGlobals::config(); | 1723 | KConfig *config = KOGlobals::config(); |
1738 | 1724 | ||
1739 | #ifndef KORG_NOSPLITTER | 1725 | #ifndef KORG_NOSPLITTER |
1740 | config->setGroup("KOrganizer Geometry"); | 1726 | config->setGroup("KOrganizer Geometry"); |
1741 | 1727 | ||
1742 | QValueList<int> list = mPanner->sizes(); | 1728 | QValueList<int> list = mPanner->sizes(); |
1743 | config->writeEntry("Separator1",list); | 1729 | config->writeEntry("Separator1",list); |
1744 | 1730 | ||
1745 | list = mLeftSplitter->sizes(); | 1731 | list = mLeftSplitter->sizes(); |
1746 | config->writeEntry("Separator2",list); | 1732 | config->writeEntry("Separator2",list); |
1747 | #endif | 1733 | #endif |
1748 | 1734 | ||
1749 | mViewManager->writeSettings( config ); | 1735 | mViewManager->writeSettings( config ); |
1750 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1736 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1751 | mDialogManager->writeSettings( config ); | 1737 | mDialogManager->writeSettings( config ); |
1752 | //KOPrefs::instance()->usrWriteConfig(); | 1738 | //KOPrefs::instance()->usrWriteConfig(); |
1753 | KOPrefs::instance()->writeConfig(); | 1739 | KOPrefs::instance()->writeConfig(); |
1754 | 1740 | ||
1755 | writeFilterSettings(config); | 1741 | writeFilterSettings(config); |
1756 | 1742 | ||
1757 | config->setGroup( "Views" ); | 1743 | config->setGroup( "Views" ); |
1758 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1744 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1759 | 1745 | ||
1760 | #ifdef DESKTOP_VERSION | 1746 | #ifdef DESKTOP_VERSION |
1761 | config->setGroup("WidgetLayout"); | 1747 | config->setGroup("WidgetLayout"); |
1762 | QStringList list ;//= config->readListEntry("MainLayout"); | 1748 | QStringList list ;//= config->readListEntry("MainLayout"); |
1763 | int x,y,w,h; | 1749 | int x,y,w,h; |
1764 | QWidget* wid; | 1750 | QWidget* wid; |
1765 | wid = topLevelWidget(); | 1751 | wid = topLevelWidget(); |
1766 | x = wid->geometry().x(); | 1752 | x = wid->geometry().x(); |
1767 | y = wid->geometry().y(); | 1753 | y = wid->geometry().y(); |
1768 | w = wid->width(); | 1754 | w = wid->width(); |
1769 | h = wid->height(); | 1755 | h = wid->height(); |
1770 | list.clear(); | 1756 | list.clear(); |
1771 | list << QString::number( x ); | 1757 | list << QString::number( x ); |
1772 | list << QString::number( y ); | 1758 | list << QString::number( y ); |
1773 | list << QString::number( w ); | 1759 | list << QString::number( w ); |
1774 | list << QString::number( h ); | 1760 | list << QString::number( h ); |
1775 | config->writeEntry("MainLayout",list ); | 1761 | config->writeEntry("MainLayout",list ); |
1776 | 1762 | ||
1777 | wid = mEventEditor; | 1763 | wid = mEventEditor; |
1778 | x = wid->geometry().x(); | 1764 | x = wid->geometry().x(); |
1779 | y = wid->geometry().y(); | 1765 | y = wid->geometry().y(); |
1780 | w = wid->width(); | 1766 | w = wid->width(); |
1781 | h = wid->height(); | 1767 | h = wid->height(); |
1782 | list.clear(); | 1768 | list.clear(); |
1783 | list << QString::number( x ); | 1769 | list << QString::number( x ); |
1784 | list << QString::number( y ); | 1770 | list << QString::number( y ); |
1785 | list << QString::number( w ); | 1771 | list << QString::number( w ); |
1786 | list << QString::number( h ); | 1772 | list << QString::number( h ); |
1787 | config->writeEntry("EditEventLayout",list ); | 1773 | config->writeEntry("EditEventLayout",list ); |
1788 | 1774 | ||
1789 | wid = mTodoEditor; | 1775 | wid = mTodoEditor; |
1790 | x = wid->geometry().x(); | 1776 | x = wid->geometry().x(); |
1791 | y = wid->geometry().y(); | 1777 | y = wid->geometry().y(); |
1792 | w = wid->width(); | 1778 | w = wid->width(); |
1793 | h = wid->height(); | 1779 | h = wid->height(); |
1794 | list.clear(); | 1780 | list.clear(); |
1795 | list << QString::number( x ); | 1781 | list << QString::number( x ); |
1796 | list << QString::number( y ); | 1782 | list << QString::number( y ); |
1797 | list << QString::number( w ); | 1783 | list << QString::number( w ); |
1798 | list << QString::number( h ); | 1784 | list << QString::number( h ); |
1799 | config->writeEntry("EditTodoLayout",list ); | 1785 | config->writeEntry("EditTodoLayout",list ); |
1800 | wid = getEventViewerDialog(); | 1786 | wid = getEventViewerDialog(); |
1801 | x = wid->geometry().x(); | 1787 | x = wid->geometry().x(); |
1802 | y = wid->geometry().y(); | 1788 | y = wid->geometry().y(); |
1803 | w = wid->width(); | 1789 | w = wid->width(); |
1804 | h = wid->height(); | 1790 | h = wid->height(); |
1805 | list.clear(); | 1791 | list.clear(); |
1806 | list << QString::number( x ); | 1792 | list << QString::number( x ); |
1807 | list << QString::number( y ); | 1793 | list << QString::number( y ); |
1808 | list << QString::number( w ); | 1794 | list << QString::number( w ); |
1809 | list << QString::number( h ); | 1795 | list << QString::number( h ); |
1810 | config->writeEntry("ViewerLayout",list ); | 1796 | config->writeEntry("ViewerLayout",list ); |
1811 | wid = mDialogManager->getSearchDialog(); | 1797 | wid = mDialogManager->getSearchDialog(); |
1812 | if ( wid ) { | 1798 | if ( wid ) { |
1813 | x = wid->geometry().x(); | 1799 | x = wid->geometry().x(); |
1814 | y = wid->geometry().y(); | 1800 | y = wid->geometry().y(); |
1815 | w = wid->width(); | 1801 | w = wid->width(); |
1816 | h = wid->height(); | 1802 | h = wid->height(); |
1817 | list.clear(); | 1803 | list.clear(); |
1818 | list << QString::number( x ); | 1804 | list << QString::number( x ); |
1819 | list << QString::number( y ); | 1805 | list << QString::number( y ); |
1820 | list << QString::number( w ); | 1806 | list << QString::number( w ); |
1821 | list << QString::number( h ); | 1807 | list << QString::number( h ); |
1822 | config->writeEntry("SearchLayout",list ); | 1808 | config->writeEntry("SearchLayout",list ); |
1823 | } | 1809 | } |
1824 | #endif | 1810 | #endif |
1825 | 1811 | ||
1826 | 1812 | ||
1827 | config->sync(); | 1813 | config->sync(); |
1828 | } | 1814 | } |
1829 | 1815 | ||
1830 | void CalendarView::readFilterSettings(KConfig *config) | 1816 | void CalendarView::readFilterSettings(KConfig *config) |
1831 | { | 1817 | { |
1832 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1818 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1833 | 1819 | ||
1834 | mFilters.clear(); | 1820 | mFilters.clear(); |
1835 | 1821 | ||
1836 | config->setGroup("General"); | 1822 | config->setGroup("General"); |
1837 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1823 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1838 | 1824 | ||
1839 | QStringList::ConstIterator it = filterList.begin(); | 1825 | QStringList::ConstIterator it = filterList.begin(); |
1840 | QStringList::ConstIterator end = filterList.end(); | 1826 | QStringList::ConstIterator end = filterList.end(); |
1841 | while(it != end) { | 1827 | while(it != end) { |
1842 | // kdDebug() << " filter: " << (*it) << endl; | 1828 | // kdDebug() << " filter: " << (*it) << endl; |
1843 | 1829 | ||
1844 | CalFilter *filter; | 1830 | CalFilter *filter; |
1845 | filter = new CalFilter(*it); | 1831 | filter = new CalFilter(*it); |
1846 | config->setGroup("Filter_" + (*it)); | 1832 | config->setGroup("Filter_" + (*it)); |
1847 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1833 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1848 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1834 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1849 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1835 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1850 | mFilters.append(filter); | 1836 | mFilters.append(filter); |
1851 | 1837 | ||
1852 | ++it; | 1838 | ++it; |
1853 | } | 1839 | } |
1854 | 1840 | ||
1855 | if (mFilters.count() == 0) { | 1841 | if (mFilters.count() == 0) { |
1856 | CalFilter *filter = new CalFilter(i18n("Default")); | 1842 | CalFilter *filter = new CalFilter(i18n("Default")); |
1857 | mFilters.append(filter); | 1843 | mFilters.append(filter); |
1858 | } | 1844 | } |
1859 | mFilterView->updateFilters(); | 1845 | mFilterView->updateFilters(); |
1860 | config->setGroup("FilterView"); | 1846 | config->setGroup("FilterView"); |
1861 | 1847 | ||
1862 | mFilterView->blockSignals(true); | 1848 | mFilterView->blockSignals(true); |
1863 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1849 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1864 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1850 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1865 | mFilterView->blockSignals(false); | 1851 | mFilterView->blockSignals(false); |
1866 | // We do it manually to avoid it being done twice by the above calls | 1852 | // We do it manually to avoid it being done twice by the above calls |
1867 | updateFilter(); | 1853 | updateFilter(); |
1868 | } | 1854 | } |
1869 | 1855 | ||
1870 | void CalendarView::writeFilterSettings(KConfig *config) | 1856 | void CalendarView::writeFilterSettings(KConfig *config) |
1871 | { | 1857 | { |
1872 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1858 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1873 | 1859 | ||
1874 | QStringList filterList; | 1860 | QStringList filterList; |
1875 | 1861 | ||
1876 | CalFilter *filter = mFilters.first(); | 1862 | CalFilter *filter = mFilters.first(); |
1877 | while(filter) { | 1863 | while(filter) { |
1878 | // kdDebug() << " fn: " << filter->name() << endl; | 1864 | // kdDebug() << " fn: " << filter->name() << endl; |
1879 | filterList << filter->name(); | 1865 | filterList << filter->name(); |
1880 | config->setGroup("Filter_" + filter->name()); | 1866 | config->setGroup("Filter_" + filter->name()); |
1881 | config->writeEntry("Criteria",filter->criteria()); | 1867 | config->writeEntry("Criteria",filter->criteria()); |
1882 | config->writeEntry("CategoryList",filter->categoryList()); | 1868 | config->writeEntry("CategoryList",filter->categoryList()); |
1883 | filter = mFilters.next(); | 1869 | filter = mFilters.next(); |
1884 | } | 1870 | } |
1885 | config->setGroup("General"); | 1871 | config->setGroup("General"); |
1886 | config->writeEntry("CalendarFilters",filterList); | 1872 | config->writeEntry("CalendarFilters",filterList); |
1887 | 1873 | ||
1888 | config->setGroup("FilterView"); | 1874 | config->setGroup("FilterView"); |
1889 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1875 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1890 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1876 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1891 | } | 1877 | } |
1892 | 1878 | ||
1893 | 1879 | ||
1894 | void CalendarView::goToday() | 1880 | void CalendarView::goToday() |
1895 | { | 1881 | { |
1896 | mNavigator->selectToday(); | 1882 | mNavigator->selectToday(); |
1897 | } | 1883 | } |
1898 | 1884 | ||
1899 | void CalendarView::goNext() | 1885 | void CalendarView::goNext() |
1900 | { | 1886 | { |
1901 | mNavigator->selectNext(); | 1887 | mNavigator->selectNext(); |
1902 | } | 1888 | } |
1903 | 1889 | ||
1904 | void CalendarView::goPrevious() | 1890 | void CalendarView::goPrevious() |
1905 | { | 1891 | { |
1906 | mNavigator->selectPrevious(); | 1892 | mNavigator->selectPrevious(); |
1907 | } | 1893 | } |
1908 | void CalendarView::goNextMonth() | 1894 | void CalendarView::goNextMonth() |
1909 | { | 1895 | { |
1910 | mNavigator->selectNextMonth(); | 1896 | mNavigator->selectNextMonth(); |
1911 | } | 1897 | } |
1912 | 1898 | ||
1913 | void CalendarView::goPreviousMonth() | 1899 | void CalendarView::goPreviousMonth() |
1914 | { | 1900 | { |
1915 | mNavigator->selectPreviousMonth(); | 1901 | mNavigator->selectPreviousMonth(); |
1916 | } | 1902 | } |
1917 | void CalendarView::writeLocale() | 1903 | void CalendarView::writeLocale() |
1918 | { | 1904 | { |
1919 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 1905 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
1920 | #if 0 | 1906 | #if 0 |
1921 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1907 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1922 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1908 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1923 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1909 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1924 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1910 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1925 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1911 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1926 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1912 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1927 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1913 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1928 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1914 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1929 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1915 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1930 | KOPrefs::instance()->mDaylightsavingStart, | 1916 | KOPrefs::instance()->mDaylightsavingStart, |
1931 | KOPrefs::instance()->mDaylightsavingEnd ); | 1917 | KOPrefs::instance()->mDaylightsavingEnd ); |
1932 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 1918 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
1933 | #endif | 1919 | #endif |
1934 | } | 1920 | } |
1935 | void CalendarView::updateConfig() | 1921 | void CalendarView::updateConfig() |
1936 | { | 1922 | { |
1937 | writeLocale(); | 1923 | writeLocale(); |
1938 | if ( KOPrefs::instance()->mUseAppColors ) | 1924 | if ( KOPrefs::instance()->mUseAppColors ) |
1939 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 1925 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
1940 | emit configChanged(); | 1926 | emit configChanged(); |
1941 | mTodoList->updateConfig(); | 1927 | mTodoList->updateConfig(); |
1942 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 1928 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
1943 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1929 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1944 | // To make the "fill window" configurations work | 1930 | // To make the "fill window" configurations work |
1945 | //mViewManager->raiseCurrentView(); | 1931 | //mViewManager->raiseCurrentView(); |
1946 | } | 1932 | } |
1947 | 1933 | ||
1948 | 1934 | ||
1949 | void CalendarView::eventChanged(Event *event) | 1935 | void CalendarView::eventChanged(Event *event) |
1950 | { | 1936 | { |
1951 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 1937 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
1952 | //updateUnmanagedViews(); | 1938 | //updateUnmanagedViews(); |
1953 | } | 1939 | } |
1954 | 1940 | ||
1955 | void CalendarView::eventAdded(Event *event) | 1941 | void CalendarView::eventAdded(Event *event) |
1956 | { | 1942 | { |
1957 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 1943 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
1958 | } | 1944 | } |
1959 | 1945 | ||
1960 | void CalendarView::eventToBeDeleted(Event *) | 1946 | void CalendarView::eventToBeDeleted(Event *) |
1961 | { | 1947 | { |
1962 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 1948 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
1963 | } | 1949 | } |
1964 | 1950 | ||
1965 | void CalendarView::eventDeleted() | 1951 | void CalendarView::eventDeleted() |
1966 | { | 1952 | { |
1967 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 1953 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
1968 | } | 1954 | } |
1969 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 1955 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
1970 | { | 1956 | { |
1971 | changeIncidenceDisplay((Incidence *)which, action); | 1957 | changeIncidenceDisplay((Incidence *)which, action); |
1972 | mDateNavigator->updateView(); //LR | 1958 | mDateNavigator->updateView(); //LR |
1973 | //mDialogManager->updateSearchDialog(); | 1959 | //mDialogManager->updateSearchDialog(); |
1974 | 1960 | ||
1975 | if (which) { | 1961 | if (which) { |
1976 | mViewManager->updateWNview(); | 1962 | mViewManager->updateWNview(); |
1977 | //mTodoList->updateView(); | 1963 | //mTodoList->updateView(); |
1978 | } | 1964 | } |
1979 | 1965 | ||
1980 | } | 1966 | } |
1981 | 1967 | ||
1982 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 1968 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
1983 | { | 1969 | { |
1984 | updateUnmanagedViews(); | 1970 | updateUnmanagedViews(); |
1985 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 1971 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
1986 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 1972 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
1987 | mCalendar->checkAlarmForIncidence( 0, true ); | 1973 | mCalendar->checkAlarmForIncidence( 0, true ); |
1988 | if ( mEventViewerDialog ) | 1974 | if ( mEventViewerDialog ) |
1989 | mEventViewerDialog->hide(); | 1975 | mEventViewerDialog->hide(); |
1990 | } | 1976 | } |
1991 | else | 1977 | else |
1992 | mCalendar->checkAlarmForIncidence( which , false ); | 1978 | mCalendar->checkAlarmForIncidence( which , false ); |
1993 | } | 1979 | } |
1994 | 1980 | ||
1995 | // most of the changeEventDisplays() right now just call the view's | 1981 | // most of the changeEventDisplays() right now just call the view's |
1996 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 1982 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
1997 | void CalendarView::changeEventDisplay(Event *which, int action) | 1983 | void CalendarView::changeEventDisplay(Event *which, int action) |
1998 | { | 1984 | { |
1999 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 1985 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2000 | changeIncidenceDisplay((Incidence *)which, action); | 1986 | changeIncidenceDisplay((Incidence *)which, action); |
2001 | mDateNavigator->updateView(); | 1987 | mDateNavigator->updateView(); |
2002 | //mDialogManager->updateSearchDialog(); | 1988 | //mDialogManager->updateSearchDialog(); |
2003 | 1989 | ||
2004 | if (which) { | 1990 | if (which) { |
2005 | // If there is an event view visible update the display | 1991 | // If there is an event view visible update the display |
2006 | mViewManager->currentView()->changeEventDisplay(which,action); | 1992 | mViewManager->currentView()->changeEventDisplay(which,action); |
2007 | // TODO: check, if update needed | 1993 | // TODO: check, if update needed |
2008 | // if (which->getTodoStatus()) { | 1994 | // if (which->getTodoStatus()) { |
2009 | mTodoList->updateView(); | 1995 | mTodoList->updateView(); |
2010 | // } | 1996 | // } |
2011 | } else { | 1997 | } else { |
2012 | mViewManager->currentView()->updateView(); | 1998 | mViewManager->currentView()->updateView(); |
2013 | } | 1999 | } |
2014 | } | 2000 | } |
2015 | 2001 | ||
2016 | 2002 | ||
2017 | void CalendarView::updateTodoViews() | 2003 | void CalendarView::updateTodoViews() |
2018 | { | 2004 | { |
2019 | 2005 | ||
2020 | mTodoList->updateView(); | 2006 | mTodoList->updateView(); |
2021 | mViewManager->currentView()->updateView(); | 2007 | mViewManager->currentView()->updateView(); |
2022 | 2008 | ||
2023 | } | 2009 | } |
2024 | 2010 | ||
2025 | 2011 | ||
2026 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2012 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2027 | { | 2013 | { |
2028 | mTodoList->updateView(); | 2014 | mTodoList->updateView(); |
2029 | mViewManager->updateView(start, end); | 2015 | mViewManager->updateView(start, end); |
2030 | //mDateNavigator->updateView(); | 2016 | //mDateNavigator->updateView(); |
2031 | } | 2017 | } |
2032 | 2018 | ||
2033 | void CalendarView::updateView() | 2019 | void CalendarView::updateView() |
2034 | { | 2020 | { |
2035 | DateList tmpList = mNavigator->selectedDates(); | 2021 | DateList tmpList = mNavigator->selectedDates(); |
2036 | 2022 | ||
2037 | // We assume that the navigator only selects consecutive days. | 2023 | // We assume that the navigator only selects consecutive days. |
2038 | updateView( tmpList.first(), tmpList.last() ); | 2024 | updateView( tmpList.first(), tmpList.last() ); |
2039 | } | 2025 | } |
2040 | 2026 | ||
2041 | void CalendarView::updateUnmanagedViews() | 2027 | void CalendarView::updateUnmanagedViews() |
2042 | { | 2028 | { |
2043 | mDateNavigator->updateDayMatrix(); | 2029 | mDateNavigator->updateDayMatrix(); |
2044 | } | 2030 | } |
2045 | 2031 | ||
2046 | int CalendarView::msgItemDelete() | 2032 | int CalendarView::msgItemDelete() |
2047 | { | 2033 | { |
2048 | return KMessageBox::warningContinueCancel(this, | 2034 | return KMessageBox::warningContinueCancel(this, |
2049 | i18n("This item will be\npermanently deleted."), | 2035 | i18n("This item will be\npermanently deleted."), |
2050 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2036 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2051 | } | 2037 | } |
2052 | 2038 | ||
2053 | 2039 | ||
2054 | void CalendarView::edit_cut() | 2040 | void CalendarView::edit_cut() |
2055 | { | 2041 | { |
2056 | Event *anEvent=0; | 2042 | Event *anEvent=0; |
2057 | 2043 | ||
2058 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2044 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2059 | 2045 | ||
2060 | if (mViewManager->currentView()->isEventView()) { | 2046 | if (mViewManager->currentView()->isEventView()) { |
2061 | if ( incidence && incidence->type() == "Event" ) { | 2047 | if ( incidence && incidence->type() == "Event" ) { |
2062 | anEvent = static_cast<Event *>(incidence); | 2048 | anEvent = static_cast<Event *>(incidence); |
2063 | } | 2049 | } |
2064 | } | 2050 | } |
2065 | 2051 | ||
2066 | if (!anEvent) { | 2052 | if (!anEvent) { |
2067 | KNotifyClient::beep(); | 2053 | KNotifyClient::beep(); |
2068 | return; | 2054 | return; |
2069 | } | 2055 | } |
2070 | DndFactory factory( mCalendar ); | 2056 | DndFactory factory( mCalendar ); |
2071 | factory.cutEvent(anEvent); | 2057 | factory.cutEvent(anEvent); |
2072 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2058 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2073 | } | 2059 | } |
2074 | 2060 | ||
2075 | void CalendarView::edit_copy() | 2061 | void CalendarView::edit_copy() |
2076 | { | 2062 | { |
2077 | Event *anEvent=0; | 2063 | Event *anEvent=0; |
2078 | 2064 | ||
2079 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2065 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2080 | 2066 | ||
2081 | if (mViewManager->currentView()->isEventView()) { | 2067 | if (mViewManager->currentView()->isEventView()) { |
2082 | if ( incidence && incidence->type() == "Event" ) { | 2068 | if ( incidence && incidence->type() == "Event" ) { |
2083 | anEvent = static_cast<Event *>(incidence); | 2069 | anEvent = static_cast<Event *>(incidence); |
2084 | } | 2070 | } |
2085 | } | 2071 | } |
2086 | 2072 | ||
2087 | if (!anEvent) { | 2073 | if (!anEvent) { |
2088 | KNotifyClient::beep(); | 2074 | KNotifyClient::beep(); |
2089 | return; | 2075 | return; |
2090 | } | 2076 | } |
2091 | DndFactory factory( mCalendar ); | 2077 | DndFactory factory( mCalendar ); |
2092 | factory.copyEvent(anEvent); | 2078 | factory.copyEvent(anEvent); |
2093 | } | 2079 | } |
2094 | 2080 | ||
2095 | void CalendarView::edit_paste() | 2081 | void CalendarView::edit_paste() |
2096 | { | 2082 | { |
2097 | QDate date = mNavigator->selectedDates().first(); | 2083 | QDate date = mNavigator->selectedDates().first(); |
2098 | 2084 | ||
2099 | DndFactory factory( mCalendar ); | 2085 | DndFactory factory( mCalendar ); |
2100 | Event *pastedEvent = factory.pasteEvent( date ); | 2086 | Event *pastedEvent = factory.pasteEvent( date ); |
2101 | 2087 | ||
2102 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2088 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2103 | } | 2089 | } |
2104 | 2090 | ||
2105 | void CalendarView::edit_options() | 2091 | void CalendarView::edit_options() |
2106 | { | 2092 | { |
2107 | mDialogManager->showOptionsDialog(); | 2093 | mDialogManager->showOptionsDialog(); |
2108 | //writeSettings(); | 2094 | //writeSettings(); |
2109 | } | 2095 | } |
2110 | void CalendarView::edit_sync_options() | 2096 | void CalendarView::edit_sync_options() |
2111 | { | 2097 | { |
2112 | //mDialogManager->showSyncOptions(); | 2098 | //mDialogManager->showSyncOptions(); |
2113 | //KOPrefs::instance()->mSyncAlgoPrefs | 2099 | //KOPrefs::instance()->mSyncAlgoPrefs |
2114 | QDialog dia( this, "dia", true ); | 2100 | QDialog dia( this, "dia", true ); |
2115 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2101 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2116 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2102 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2117 | QVBoxLayout lay ( &dia ); | 2103 | QVBoxLayout lay ( &dia ); |
2118 | lay.setSpacing( 2 ); | 2104 | lay.setSpacing( 2 ); |
2119 | lay.setMargin( 3 ); | 2105 | lay.setMargin( 3 ); |
2120 | lay.addWidget(&gr); | 2106 | lay.addWidget(&gr); |
2121 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2107 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2122 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2108 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2123 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2109 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2124 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2110 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2125 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2111 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2126 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2112 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2127 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2113 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2128 | QPushButton pb ( "OK", &dia); | 2114 | QPushButton pb ( "OK", &dia); |
2129 | lay.addWidget( &pb ); | 2115 | lay.addWidget( &pb ); |
2130 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2116 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2131 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { | 2117 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { |
2132 | case 0: | 2118 | case 0: |
2133 | loc.setChecked( true); | 2119 | loc.setChecked( true); |
2134 | break; | 2120 | break; |
2135 | case 1: | 2121 | case 1: |
2136 | rem.setChecked( true ); | 2122 | rem.setChecked( true ); |
2137 | break; | 2123 | break; |
2138 | case 2: | 2124 | case 2: |
2139 | newest.setChecked( true); | 2125 | newest.setChecked( true); |
2140 | break; | 2126 | break; |
2141 | case 3: | 2127 | case 3: |
2142 | ask.setChecked( true); | 2128 | ask.setChecked( true); |
2143 | break; | 2129 | break; |
2144 | case 4: | 2130 | case 4: |
2145 | f_loc.setChecked( true); | 2131 | f_loc.setChecked( true); |
2146 | break; | 2132 | break; |
2147 | case 5: | 2133 | case 5: |
2148 | f_rem.setChecked( true); | 2134 | f_rem.setChecked( true); |
2149 | break; | 2135 | break; |
2150 | case 6: | 2136 | case 6: |
2151 | // both.setChecked( true); | 2137 | // both.setChecked( true); |
2152 | break; | 2138 | break; |
2153 | default: | 2139 | default: |
2154 | break; | 2140 | break; |
2155 | } | 2141 | } |
2156 | if ( dia.exec() ) { | 2142 | if ( dia.exec() ) { |
2157 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2143 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2158 | } | 2144 | } |
2159 | 2145 | ||
2160 | } | 2146 | } |
2161 | 2147 | ||
2162 | void CalendarView::slotSelectPickerDate( QDate d) | 2148 | void CalendarView::slotSelectPickerDate( QDate d) |
2163 | { | 2149 | { |
2164 | mDateFrame->hide(); | 2150 | mDateFrame->hide(); |
2165 | if ( mDatePickerMode == 1 ) { | 2151 | if ( mDatePickerMode == 1 ) { |
2166 | mNavigator->slotDaySelect( d ); | 2152 | mNavigator->slotDaySelect( d ); |
2167 | } else if ( mDatePickerMode == 2 ) { | 2153 | } else if ( mDatePickerMode == 2 ) { |
2168 | if ( mMoveIncidence->type() == "Todo" ) { | 2154 | if ( mMoveIncidence->type() == "Todo" ) { |
2169 | Todo * to = (Todo *) mMoveIncidence; | 2155 | Todo * to = (Todo *) mMoveIncidence; |
2170 | QTime tim; | 2156 | QTime tim; |
2171 | if ( to->hasDueDate() ) | 2157 | if ( to->hasDueDate() ) |
2172 | tim = to->dtDue().time(); | 2158 | tim = to->dtDue().time(); |
2173 | else { | 2159 | else { |
2174 | tim = QTime ( 0,0,0 ); | 2160 | tim = QTime ( 0,0,0 ); |
2175 | to->setFloats( true ); | 2161 | to->setFloats( true ); |
2176 | to->setHasDueDate( true ); | 2162 | to->setHasDueDate( true ); |
2177 | } | 2163 | } |
2178 | QDateTime dt ( d,tim ); | 2164 | QDateTime dt ( d,tim ); |
2179 | to->setDtDue( dt ); | 2165 | to->setDtDue( dt ); |
2180 | todoChanged( to ); | 2166 | todoChanged( to ); |
2181 | } else { | 2167 | } else { |
2182 | QTime tim = mMoveIncidence->dtStart().time(); | 2168 | QTime tim = mMoveIncidence->dtStart().time(); |
2183 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2169 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2184 | QDateTime dt ( d,tim ); | 2170 | QDateTime dt ( d,tim ); |
2185 | mMoveIncidence->setDtStart( dt ); | 2171 | mMoveIncidence->setDtStart( dt ); |
2186 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2172 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2187 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2173 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2188 | } | 2174 | } |
2189 | 2175 | ||
2190 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2176 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2191 | } | 2177 | } |
2192 | } | 2178 | } |
2193 | 2179 | ||
2194 | void CalendarView::removeCategories() | 2180 | void CalendarView::removeCategories() |
2195 | { | 2181 | { |
2196 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2182 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2197 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2183 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2198 | QStringList catIncList; | 2184 | QStringList catIncList; |
2199 | QStringList newCatList; | 2185 | QStringList newCatList; |
2200 | Incidence* inc = incList.first(); | 2186 | Incidence* inc = incList.first(); |
2201 | int i; | 2187 | int i; |
2202 | int count = 0; | 2188 | int count = 0; |
2203 | while ( inc ) { | 2189 | while ( inc ) { |
2204 | newCatList.clear(); | 2190 | newCatList.clear(); |
2205 | catIncList = inc->categories() ; | 2191 | catIncList = inc->categories() ; |
2206 | for( i = 0; i< catIncList.count(); ++i ) { | 2192 | for( i = 0; i< catIncList.count(); ++i ) { |
2207 | if ( catList.contains (catIncList[i])) | 2193 | if ( catList.contains (catIncList[i])) |
2208 | newCatList.append( catIncList[i] ); | 2194 | newCatList.append( catIncList[i] ); |
2209 | } | 2195 | } |
2210 | newCatList.sort(); | 2196 | newCatList.sort(); |
2211 | inc->setCategories( newCatList.join(",") ); | 2197 | inc->setCategories( newCatList.join(",") ); |
2212 | inc = incList.next(); | 2198 | inc = incList.next(); |
2213 | } | 2199 | } |
2214 | } | 2200 | } |
2215 | 2201 | ||
2216 | int CalendarView::addCategories() | 2202 | int CalendarView::addCategories() |
2217 | { | 2203 | { |
2218 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2204 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2219 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2205 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2220 | QStringList catIncList; | 2206 | QStringList catIncList; |
2221 | Incidence* inc = incList.first(); | 2207 | Incidence* inc = incList.first(); |
2222 | int i; | 2208 | int i; |
2223 | int count = 0; | 2209 | int count = 0; |
2224 | while ( inc ) { | 2210 | while ( inc ) { |
2225 | catIncList = inc->categories() ; | 2211 | catIncList = inc->categories() ; |
2226 | for( i = 0; i< catIncList.count(); ++i ) { | 2212 | for( i = 0; i< catIncList.count(); ++i ) { |
2227 | if ( !catList.contains (catIncList[i])) { | 2213 | if ( !catList.contains (catIncList[i])) { |
2228 | catList.append( catIncList[i] ); | 2214 | catList.append( catIncList[i] ); |
2229 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2215 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2230 | ++count; | 2216 | ++count; |
2231 | } | 2217 | } |
2232 | } | 2218 | } |
2233 | inc = incList.next(); | 2219 | inc = incList.next(); |
2234 | } | 2220 | } |
2235 | catList.sort(); | 2221 | catList.sort(); |
2236 | KOPrefs::instance()->mCustomCategories = catList; | 2222 | KOPrefs::instance()->mCustomCategories = catList; |
2237 | return count; | 2223 | return count; |
2238 | } | 2224 | } |
2239 | 2225 | ||
2240 | void CalendarView::manageCategories() | 2226 | void CalendarView::manageCategories() |
2241 | { | 2227 | { |
2242 | KOCatPrefs* cp = new KOCatPrefs(); | 2228 | KOCatPrefs* cp = new KOCatPrefs(); |
2243 | cp->show(); | 2229 | cp->show(); |
2244 | int w =cp->sizeHint().width() ; | 2230 | int w =cp->sizeHint().width() ; |
2245 | int h = cp->sizeHint().height() ; | 2231 | int h = cp->sizeHint().height() ; |
2246 | int dw = QApplication::desktop()->width(); | 2232 | int dw = QApplication::desktop()->width(); |
2247 | int dh = QApplication::desktop()->height(); | 2233 | int dh = QApplication::desktop()->height(); |
2248 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2234 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2249 | if ( !cp->exec() ) { | 2235 | if ( !cp->exec() ) { |
2250 | delete cp; | 2236 | delete cp; |
2251 | return; | 2237 | return; |
2252 | } | 2238 | } |
2253 | int count = 0; | 2239 | int count = 0; |
2254 | if ( cp->addCat() ) { | 2240 | if ( cp->addCat() ) { |
2255 | count = addCategories(); | 2241 | count = addCategories(); |
2256 | if ( count ) { | 2242 | if ( count ) { |
2257 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2243 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2258 | writeSettings(); | 2244 | writeSettings(); |
2259 | } | 2245 | } |
2260 | } else { | 2246 | } else { |
2261 | removeCategories(); | 2247 | removeCategories(); |
2262 | updateView(); | 2248 | updateView(); |
2263 | } | 2249 | } |
2264 | delete cp; | 2250 | delete cp; |
2265 | } | 2251 | } |
2266 | 2252 | ||
2267 | void CalendarView::beamIncidence(Incidence * Inc) | 2253 | void CalendarView::beamIncidence(Incidence * Inc) |
2268 | { | 2254 | { |
2269 | QPtrList<Incidence> delSel ; | 2255 | QPtrList<Incidence> delSel ; |
2270 | delSel.append(Inc); | 2256 | delSel.append(Inc); |
2271 | beamIncidenceList( delSel ); | 2257 | beamIncidenceList( delSel ); |
2272 | } | 2258 | } |
2273 | void CalendarView::beamCalendar() | 2259 | void CalendarView::beamCalendar() |
2274 | { | 2260 | { |
2275 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2261 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2276 | //qDebug("beamCalendar() "); | 2262 | //qDebug("beamCalendar() "); |
2277 | beamIncidenceList( delSel ); | 2263 | beamIncidenceList( delSel ); |
2278 | } | 2264 | } |
2279 | void CalendarView::beamFilteredCalendar() | 2265 | void CalendarView::beamFilteredCalendar() |
2280 | { | 2266 | { |
2281 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2267 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2282 | //qDebug("beamFilteredCalendar() "); | 2268 | //qDebug("beamFilteredCalendar() "); |
2283 | beamIncidenceList( delSel ); | 2269 | beamIncidenceList( delSel ); |
2284 | } | 2270 | } |
2285 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2271 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2286 | { | 2272 | { |
2287 | if ( beamDialog->exec () == QDialog::Rejected ) | 2273 | if ( beamDialog->exec () == QDialog::Rejected ) |
2288 | return; | 2274 | return; |
2289 | 2275 | ||
2290 | QString fn = "/tmp/kopibeamfile"; | 2276 | QString fn = "/tmp/kopibeamfile"; |
2291 | QString mes; | 2277 | QString mes; |
2292 | bool createbup = true; | 2278 | bool createbup = true; |
2293 | if ( createbup ) { | 2279 | if ( createbup ) { |
2294 | QString description = "\n"; | 2280 | QString description = "\n"; |
2295 | CalendarLocal* cal = new CalendarLocal(); | 2281 | CalendarLocal* cal = new CalendarLocal(); |
2296 | if ( beamDialog->beamLocal() ) | 2282 | if ( beamDialog->beamLocal() ) |
2297 | cal->setLocalTime(); | 2283 | cal->setLocalTime(); |
2298 | else | 2284 | else |
2299 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2285 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2300 | Incidence *incidence = delSel.first(); | 2286 | Incidence *incidence = delSel.first(); |
2301 | bool addText = false; | 2287 | bool addText = false; |
2302 | if ( delSel.count() < 10 ) | 2288 | if ( delSel.count() < 10 ) |
2303 | addText = true; | 2289 | addText = true; |
2304 | else { | 2290 | else { |
2305 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2291 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2306 | } | 2292 | } |
2307 | while ( incidence ) { | 2293 | while ( incidence ) { |
2308 | Incidence *in = incidence->clone(); | 2294 | Incidence *in = incidence->clone(); |
2309 | if ( addText ) | 2295 | if ( addText ) |
2310 | description += in->summary() + "\n"; | 2296 | description += in->summary() + "\n"; |
2311 | cal->addIncidence( in ); | 2297 | cal->addIncidence( in ); |
2312 | incidence = delSel.next(); | 2298 | incidence = delSel.next(); |
2313 | } | 2299 | } |
2314 | if ( beamDialog->beamVcal() ) { | 2300 | if ( beamDialog->beamVcal() ) { |
2315 | fn += ".vcs"; | 2301 | fn += ".vcs"; |
2316 | FileStorage storage( cal, fn, new VCalFormat ); | 2302 | FileStorage storage( cal, fn, new VCalFormat ); |
2317 | storage.save(); | 2303 | storage.save(); |
2318 | } else { | 2304 | } else { |
2319 | fn += ".ics"; | 2305 | fn += ".ics"; |
2320 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2306 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2321 | storage.save(); | 2307 | storage.save(); |
2322 | } | 2308 | } |
2323 | delete cal; | 2309 | delete cal; |
2324 | mes = i18n("KO/Pi: Ready for beaming"); | 2310 | mes = i18n("KO/Pi: Ready for beaming"); |
2325 | setCaption(mes); | 2311 | setCaption(mes); |
2326 | 2312 | ||
2327 | #ifndef DESKTOP_VERSION | 2313 | #ifndef DESKTOP_VERSION |
2328 | Ir *ir = new Ir( this ); | 2314 | Ir *ir = new Ir( this ); |
2329 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2315 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2330 | ir->send( fn, description, "text/x-vCalendar" ); | 2316 | ir->send( fn, description, "text/x-vCalendar" ); |
2331 | #endif | 2317 | #endif |
2332 | } | 2318 | } |
2333 | } | 2319 | } |
2334 | void CalendarView::beamDone( Ir *ir ) | 2320 | void CalendarView::beamDone( Ir *ir ) |
2335 | { | 2321 | { |
2336 | #ifndef DESKTOP_VERSION | 2322 | #ifndef DESKTOP_VERSION |
2337 | delete ir; | 2323 | delete ir; |
2338 | #endif | 2324 | #endif |
2339 | } | 2325 | } |
2340 | 2326 | ||
2341 | void CalendarView::moveIncidence(Incidence * inc ) | 2327 | void CalendarView::moveIncidence(Incidence * inc ) |
2342 | { | 2328 | { |
2343 | if ( !inc ) return; | 2329 | if ( !inc ) return; |
2344 | // qDebug("showDatePickerForIncidence( ) "); | 2330 | // qDebug("showDatePickerForIncidence( ) "); |
2345 | if ( mDateFrame->isVisible() ) | 2331 | if ( mDateFrame->isVisible() ) |
2346 | mDateFrame->hide(); | 2332 | mDateFrame->hide(); |
2347 | else { | 2333 | else { |
2348 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2334 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2349 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2335 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2350 | int dw = QApplication::desktop()->width(); | 2336 | int dw = QApplication::desktop()->width(); |
2351 | int dh = QApplication::desktop()->height(); | 2337 | int dh = QApplication::desktop()->height(); |
2352 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2338 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2353 | mDateFrame->show(); | 2339 | mDateFrame->show(); |
2354 | } | 2340 | } |
2355 | mDatePickerMode = 2; | 2341 | mDatePickerMode = 2; |
2356 | mMoveIncidence = inc ; | 2342 | mMoveIncidence = inc ; |
2357 | QDate da; | 2343 | QDate da; |
2358 | if ( mMoveIncidence->type() == "Todo" ) { | 2344 | if ( mMoveIncidence->type() == "Todo" ) { |
2359 | Todo * to = (Todo *) mMoveIncidence; | 2345 | Todo * to = (Todo *) mMoveIncidence; |
2360 | if ( to->hasDueDate() ) | 2346 | if ( to->hasDueDate() ) |
2361 | da = to->dtDue().date(); | 2347 | da = to->dtDue().date(); |
2362 | else | 2348 | else |
2363 | da = QDate::currentDate(); | 2349 | da = QDate::currentDate(); |
2364 | } else { | 2350 | } else { |
2365 | da = mMoveIncidence->dtStart().date(); | 2351 | da = mMoveIncidence->dtStart().date(); |
2366 | } | 2352 | } |
2367 | mDatePicker->setDate( da ); | 2353 | mDatePicker->setDate( da ); |
2368 | } | 2354 | } |
2369 | void CalendarView::showDatePicker( ) | 2355 | void CalendarView::showDatePicker( ) |
2370 | { | 2356 | { |
2371 | //qDebug("CalendarView::showDatePicker( ) "); | 2357 | //qDebug("CalendarView::showDatePicker( ) "); |
2372 | if ( mDateFrame->isVisible() ) | 2358 | if ( mDateFrame->isVisible() ) |
2373 | mDateFrame->hide(); | 2359 | mDateFrame->hide(); |
2374 | else { | 2360 | else { |
2375 | int w =mDatePicker->sizeHint().width() ; | 2361 | int w =mDatePicker->sizeHint().width() ; |
2376 | int h = mDatePicker->sizeHint().height() ; | 2362 | int h = mDatePicker->sizeHint().height() ; |
2377 | int dw = QApplication::desktop()->width(); | 2363 | int dw = QApplication::desktop()->width(); |
2378 | int dh = QApplication::desktop()->height(); | 2364 | int dh = QApplication::desktop()->height(); |
2379 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2365 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2380 | mDateFrame->show(); | 2366 | mDateFrame->show(); |
2381 | } | 2367 | } |
2382 | mDatePickerMode = 1; | 2368 | mDatePickerMode = 1; |
2383 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2369 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2384 | } | 2370 | } |
2385 | 2371 | ||
2386 | void CalendarView::showEventEditor() | 2372 | void CalendarView::showEventEditor() |
2387 | { | 2373 | { |
2388 | #ifdef DESKTOP_VERSION | 2374 | #ifdef DESKTOP_VERSION |
2389 | mEventEditor->show(); | 2375 | mEventEditor->show(); |
2390 | #else | 2376 | #else |
2391 | mEventEditor->showMaximized(); | 2377 | mEventEditor->showMaximized(); |
2392 | #endif | 2378 | #endif |
2393 | } | 2379 | } |
2394 | void CalendarView::showTodoEditor() | 2380 | void CalendarView::showTodoEditor() |
2395 | { | 2381 | { |
2396 | #ifdef DESKTOP_VERSION | 2382 | #ifdef DESKTOP_VERSION |
2397 | mTodoEditor->show(); | 2383 | mTodoEditor->show(); |
2398 | #else | 2384 | #else |
2399 | mTodoEditor->showMaximized(); | 2385 | mTodoEditor->showMaximized(); |
2400 | #endif | 2386 | #endif |
2401 | } | 2387 | } |
2402 | 2388 | ||
2403 | void CalendarView::cloneIncidence() | 2389 | void CalendarView::cloneIncidence() |
2404 | { | 2390 | { |
2405 | Incidence *incidence = currentSelection(); | 2391 | Incidence *incidence = currentSelection(); |
2406 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2392 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2407 | if ( incidence ) { | 2393 | if ( incidence ) { |
2408 | cloneIncidence(incidence); | 2394 | cloneIncidence(incidence); |
2409 | } | 2395 | } |
2410 | } | 2396 | } |
2411 | void CalendarView::moveIncidence() | 2397 | void CalendarView::moveIncidence() |
2412 | { | 2398 | { |
2413 | Incidence *incidence = currentSelection(); | 2399 | Incidence *incidence = currentSelection(); |
2414 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2400 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2415 | if ( incidence ) { | 2401 | if ( incidence ) { |
2416 | moveIncidence(incidence); | 2402 | moveIncidence(incidence); |
2417 | } | 2403 | } |
2418 | } | 2404 | } |
2419 | void CalendarView::beamIncidence() | 2405 | void CalendarView::beamIncidence() |
2420 | { | 2406 | { |
2421 | Incidence *incidence = currentSelection(); | 2407 | Incidence *incidence = currentSelection(); |
2422 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2408 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2423 | if ( incidence ) { | 2409 | if ( incidence ) { |
2424 | beamIncidence(incidence); | 2410 | beamIncidence(incidence); |
2425 | } | 2411 | } |
2426 | } | 2412 | } |
2427 | void CalendarView::toggleCancelIncidence() | 2413 | void CalendarView::toggleCancelIncidence() |
2428 | { | 2414 | { |
2429 | Incidence *incidence = currentSelection(); | 2415 | Incidence *incidence = currentSelection(); |
2430 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2416 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index a713c91..0f7e696 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,596 +1,594 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/scheduler.h> | 39 | #include <libkcal/scheduler.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | 42 | ||
43 | #include <korganizer/calendarviewbase.h> | 43 | #include <korganizer/calendarviewbase.h> |
44 | 44 | ||
45 | class QWidgetStack; | 45 | class QWidgetStack; |
46 | class QSplitter; | 46 | class QSplitter; |
47 | 47 | ||
48 | class CalPrinter; | 48 | class CalPrinter; |
49 | class KOFilterView; | 49 | class KOFilterView; |
50 | class KOViewManager; | 50 | class KOViewManager; |
51 | class KODialogManager; | 51 | class KODialogManager; |
52 | class KOTodoView; | 52 | class KOTodoView; |
53 | class KDateNavigator; | 53 | class KDateNavigator; |
54 | class DateNavigator; | 54 | class DateNavigator; |
55 | class KOIncidenceEditor; | 55 | class KOIncidenceEditor; |
56 | class KDatePicker; | 56 | class KDatePicker; |
57 | class ResourceView; | 57 | class ResourceView; |
58 | class NavigatorBar; | 58 | class NavigatorBar; |
59 | class KOEventEditor; | 59 | class KOEventEditor; |
60 | class KOTodoEditor ; | 60 | class KOTodoEditor ; |
61 | class KOEventViewerDialog; | 61 | class KOEventViewerDialog; |
62 | class KOBeamPrefs; | 62 | class KOBeamPrefs; |
63 | class KSyncProfile; | 63 | class KSyncProfile; |
64 | class AlarmDialog; | 64 | class AlarmDialog; |
65 | class KCal::Attendee; | 65 | class KCal::Attendee; |
66 | 66 | ||
67 | namespace KCal { class FileStorage; } | 67 | namespace KCal { class FileStorage; } |
68 | 68 | ||
69 | using namespace KCal; | 69 | using namespace KCal; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | This is the main calendar widget. It provides the different vies on t he | 72 | This is the main calendar widget. It provides the different vies on t he |
73 | calendar data as well as the date navigator. It also handles synchronisation | 73 | calendar data as well as the date navigator. It also handles synchronisation |
74 | of the different views and controls the different dialogs like preferences, | 74 | of the different views and controls the different dialogs like preferences, |
75 | event editor, search dialog etc. | 75 | event editor, search dialog etc. |
76 | 76 | ||
77 | @short main calendar view widget | 77 | @short main calendar view widget |
78 | @author Cornelius Schumacher | 78 | @author Cornelius Schumacher |
79 | */ | 79 | */ |
80 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer | 80 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer |
81 | { | 81 | { |
82 | Q_OBJECT | 82 | Q_OBJECT |
83 | public: | 83 | public: |
84 | /** | 84 | /** |
85 | Constructs a new calendar view widget. | 85 | Constructs a new calendar view widget. |
86 | 86 | ||
87 | @param calendar calendar document | 87 | @param calendar calendar document |
88 | @param parent parent window | 88 | @param parent parent window |
89 | @param name Qt internal widget object name | 89 | @param name Qt internal widget object name |
90 | */ | 90 | */ |
91 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 91 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
92 | const char *name = 0 ); | 92 | const char *name = 0 ); |
93 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 93 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
94 | const char *name = 0 ); | 94 | const char *name = 0 ); |
95 | virtual ~CalendarView(); | 95 | virtual ~CalendarView(); |
96 | 96 | ||
97 | Calendar *calendar() { return mCalendar; } | 97 | Calendar *calendar() { return mCalendar; } |
98 | 98 | ||
99 | KOViewManager *viewManager(); | 99 | KOViewManager *viewManager(); |
100 | KODialogManager *dialogManager(); | 100 | KODialogManager *dialogManager(); |
101 | 101 | ||
102 | QDate startDate(); | 102 | QDate startDate(); |
103 | QDate endDate(); | 103 | QDate endDate(); |
104 | 104 | ||
105 | QWidgetStack *viewStack(); | 105 | QWidgetStack *viewStack(); |
106 | QWidget *leftFrame(); | 106 | QWidget *leftFrame(); |
107 | NavigatorBar *navigatorBar(); | 107 | NavigatorBar *navigatorBar(); |
108 | 108 | ||
109 | DateNavigator *dateNavigator(); | 109 | DateNavigator *dateNavigator(); |
110 | KDateNavigator *dateNavigatorWidget(); | 110 | KDateNavigator *dateNavigatorWidget(); |
111 | 111 | ||
112 | void addView(KOrg::BaseView *); | 112 | void addView(KOrg::BaseView *); |
113 | void showView(KOrg::BaseView *); | 113 | void showView(KOrg::BaseView *); |
114 | KOEventViewerDialog* getEventViewerDialog(); | 114 | KOEventViewerDialog* getEventViewerDialog(); |
115 | Incidence *currentSelection(); | 115 | Incidence *currentSelection(); |
116 | void setupExternSyncProfiles(); | ||
117 | 116 | ||
118 | signals: | 117 | signals: |
119 | /** This todo has been modified */ | 118 | /** This todo has been modified */ |
120 | void todoModified(Todo *, int); | 119 | void todoModified(Todo *, int); |
121 | 120 | ||
122 | /** when change is made to options dialog, the topwidget will catch this | 121 | /** when change is made to options dialog, the topwidget will catch this |
123 | * and emit this signal which notifies all widgets which have registered | 122 | * and emit this signal which notifies all widgets which have registered |
124 | * for notification to update their settings. */ | 123 | * for notification to update their settings. */ |
125 | void configChanged(); | 124 | void configChanged(); |
126 | /** emitted when the topwidget is closing down, so that any attached | 125 | /** emitted when the topwidget is closing down, so that any attached |
127 | child windows can also close. */ | 126 | child windows can also close. */ |
128 | void closingDown(); | 127 | void closingDown(); |
129 | /** emitted right before we die */ | 128 | /** emitted right before we die */ |
130 | void closed(QWidget *); | 129 | void closed(QWidget *); |
131 | 130 | ||
132 | /** Emitted when state of modified flag changes */ | 131 | /** Emitted when state of modified flag changes */ |
133 | void modifiedChanged(bool); | 132 | void modifiedChanged(bool); |
134 | void signalmodified(); | 133 | void signalmodified(); |
135 | 134 | ||
136 | /** Emitted when state of read-only flag changes */ | 135 | /** Emitted when state of read-only flag changes */ |
137 | void readOnlyChanged(bool); | 136 | void readOnlyChanged(bool); |
138 | 137 | ||
139 | /** Emitted when the unit of navigation changes */ | 138 | /** Emitted when the unit of navigation changes */ |
140 | void changeNavStringPrev(const QString &); | 139 | void changeNavStringPrev(const QString &); |
141 | void changeNavStringNext(const QString &); | 140 | void changeNavStringNext(const QString &); |
142 | 141 | ||
143 | /** Emitted when state of events selection has changed and user is organizer*/ | 142 | /** Emitted when state of events selection has changed and user is organizer*/ |
144 | void organizerEventsSelected(bool); | 143 | void organizerEventsSelected(bool); |
145 | /** Emitted when state of events selection has changed and user is attendee*/ | 144 | /** Emitted when state of events selection has changed and user is attendee*/ |
146 | void groupEventsSelected(bool); | 145 | void groupEventsSelected(bool); |
147 | /** | 146 | /** |
148 | Emitted when an incidence gets selected. If the selection is cleared the | 147 | Emitted when an incidence gets selected. If the selection is cleared the |
149 | signal is emitted with 0 as argument. | 148 | signal is emitted with 0 as argument. |
150 | */ | 149 | */ |
151 | void incidenceSelected( Incidence * ); | 150 | void incidenceSelected( Incidence * ); |
152 | /** Emitted, when a todoitem is selected or deselected. */ | 151 | /** Emitted, when a todoitem is selected or deselected. */ |
153 | void todoSelected( bool ); | 152 | void todoSelected( bool ); |
154 | 153 | ||
155 | /** | 154 | /** |
156 | Emitted, when clipboard content changes. Parameter indicates if paste | 155 | Emitted, when clipboard content changes. Parameter indicates if paste |
157 | is possible or not. | 156 | is possible or not. |
158 | */ | 157 | */ |
159 | void pasteEnabled(bool); | 158 | void pasteEnabled(bool); |
160 | 159 | ||
161 | /** Emitted, when the number of incoming messages has changed. */ | 160 | /** Emitted, when the number of incoming messages has changed. */ |
162 | void numIncomingChanged(int); | 161 | void numIncomingChanged(int); |
163 | 162 | ||
164 | /** Emitted, when the number of outgoing messages has changed. */ | 163 | /** Emitted, when the number of outgoing messages has changed. */ |
165 | void numOutgoingChanged(int); | 164 | void numOutgoingChanged(int); |
166 | 165 | ||
167 | /** Send status message, which can e.g. be displayed in the status bar. */ | 166 | /** Send status message, which can e.g. be displayed in the status bar. */ |
168 | void statusMessage(const QString &); | 167 | void statusMessage(const QString &); |
169 | 168 | ||
170 | void calendarViewExpanded( bool ); | 169 | void calendarViewExpanded( bool ); |
171 | void updateSearchDialog(); | 170 | void updateSearchDialog(); |
172 | 171 | ||
173 | 172 | ||
174 | public slots: | 173 | public slots: |
175 | void showOpenError(); | 174 | void showOpenError(); |
176 | void watchSavedFile(); | 175 | void watchSavedFile(); |
177 | void recheckTimerAlarm(); | 176 | void recheckTimerAlarm(); |
178 | void checkNextTimerAlarm(); | 177 | void checkNextTimerAlarm(); |
179 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 178 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
180 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 179 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
181 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 180 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
182 | 181 | ||
183 | /** options dialog made a changed to the configuration. we catch this | 182 | /** options dialog made a changed to the configuration. we catch this |
184 | * and notify all widgets which need to update their configuration. */ | 183 | * and notify all widgets which need to update their configuration. */ |
185 | void updateConfig(); | 184 | void updateConfig(); |
186 | 185 | ||
187 | /** | 186 | /** |
188 | Load calendar from file \a filename. If \a merge is true, load | 187 | Load calendar from file \a filename. If \a merge is true, load |
189 | calendar into existing one, if it is false, clear calendar, before | 188 | calendar into existing one, if it is false, clear calendar, before |
190 | loading. Return true, if calendar could be successfully loaded. | 189 | loading. Return true, if calendar could be successfully loaded. |
191 | */ | 190 | */ |
192 | bool openCalendar(QString filename, bool merge=false); | 191 | bool openCalendar(QString filename, bool merge=false); |
193 | bool syncCalendar(QString filename,int mode = 0 ); | 192 | bool syncCalendar(QString filename,int mode = 0 ); |
194 | 193 | ||
195 | /** | 194 | /** |
196 | Save calendar data to file. Return true if calendar could be | 195 | Save calendar data to file. Return true if calendar could be |
197 | successfully saved. | 196 | successfully saved. |
198 | */ | 197 | */ |
199 | bool saveCalendar(QString filename); | 198 | bool saveCalendar(QString filename); |
200 | 199 | ||
201 | /** | 200 | /** |
202 | Close calendar. Clear calendar data and reset views to display an empty | 201 | Close calendar. Clear calendar data and reset views to display an empty |
203 | calendar. | 202 | calendar. |
204 | */ | 203 | */ |
205 | void closeCalendar(); | 204 | void closeCalendar(); |
206 | 205 | ||
207 | /** Archive old events of calendar */ | 206 | /** Archive old events of calendar */ |
208 | void archiveCalendar(); | 207 | void archiveCalendar(); |
209 | 208 | ||
210 | void showIncidence(); | 209 | void showIncidence(); |
211 | void editIncidence(); | 210 | void editIncidence(); |
212 | void editIncidenceDescription(); | 211 | void editIncidenceDescription(); |
213 | void deleteIncidence(); | 212 | void deleteIncidence(); |
214 | void cloneIncidence(); | 213 | void cloneIncidence(); |
215 | void moveIncidence(); | 214 | void moveIncidence(); |
216 | void beamIncidence(); | 215 | void beamIncidence(); |
217 | void toggleCancelIncidence(); | 216 | void toggleCancelIncidence(); |
218 | 217 | ||
219 | /** create an editeventwin with supplied date/time, and if bool is true, | 218 | /** create an editeventwin with supplied date/time, and if bool is true, |
220 | * make the event take all day. */ | 219 | * make the event take all day. */ |
221 | void newEvent(QDateTime, QDateTime, bool allDay = false); | 220 | void newEvent(QDateTime, QDateTime, bool allDay = false); |
222 | void newEvent(QDateTime fh); | 221 | void newEvent(QDateTime fh); |
223 | void newEvent(QDate dt); | 222 | void newEvent(QDate dt); |
224 | /** create new event without having a date hint. Takes current date as | 223 | /** create new event without having a date hint. Takes current date as |
225 | default hint. */ | 224 | default hint. */ |
226 | void newEvent(); | 225 | void newEvent(); |
227 | void newFloatingEvent(); | 226 | void newFloatingEvent(); |
228 | 227 | ||
229 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 228 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
230 | void showIncidence(Incidence *); | 229 | void showIncidence(Incidence *); |
231 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 230 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
232 | void editIncidence(Incidence *); | 231 | void editIncidence(Incidence *); |
233 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 232 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
234 | void deleteIncidence(Incidence *); | 233 | void deleteIncidence(Incidence *); |
235 | void cloneIncidence(Incidence *); | 234 | void cloneIncidence(Incidence *); |
236 | void cancelIncidence(Incidence *); | 235 | void cancelIncidence(Incidence *); |
237 | /** Create an editor for the supplied event. */ | 236 | /** Create an editor for the supplied event. */ |
238 | void editEvent(Event *); | 237 | void editEvent(Event *); |
239 | /** Delete the supplied event. */ | 238 | /** Delete the supplied event. */ |
240 | void deleteEvent(Event *); | 239 | void deleteEvent(Event *); |
241 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 240 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
242 | found. */ | 241 | found. */ |
243 | bool deleteEvent(const QString &uid); | 242 | bool deleteEvent(const QString &uid); |
244 | /** Create a read-only viewer dialog for the supplied event. */ | 243 | /** Create a read-only viewer dialog for the supplied event. */ |
245 | void showEvent(Event *); | 244 | void showEvent(Event *); |
246 | 245 | ||
247 | void editJournal(Journal *); | 246 | void editJournal(Journal *); |
248 | void showJournal(Journal *); | 247 | void showJournal(Journal *); |
249 | void deleteJournal(Journal *); | 248 | void deleteJournal(Journal *); |
250 | /** Create an editor dialog for a todo */ | 249 | /** Create an editor dialog for a todo */ |
251 | void editTodo(Todo *); | 250 | void editTodo(Todo *); |
252 | /** Create a read-only viewer dialog for the supplied todo */ | 251 | /** Create a read-only viewer dialog for the supplied todo */ |
253 | void showTodo(Todo *); | 252 | void showTodo(Todo *); |
254 | /** create new todo */ | 253 | /** create new todo */ |
255 | void newTodo(); | 254 | void newTodo(); |
256 | /** create new todo with a parent todo */ | 255 | /** create new todo with a parent todo */ |
257 | void newSubTodo(); | 256 | void newSubTodo(); |
258 | /** create new todo with a parent todo */ | 257 | /** create new todo with a parent todo */ |
259 | void newSubTodo(Todo *); | 258 | void newSubTodo(Todo *); |
260 | /** Delete todo */ | 259 | /** Delete todo */ |
261 | void deleteTodo(Todo *); | 260 | void deleteTodo(Todo *); |
262 | 261 | ||
263 | 262 | ||
264 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 263 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
265 | * emitted as result. */ | 264 | * emitted as result. */ |
266 | void checkClipboard(); | 265 | void checkClipboard(); |
267 | 266 | ||
268 | /** using the KConfig associated with the kapp variable, read in the | 267 | /** using the KConfig associated with the kapp variable, read in the |
269 | * settings from the config file. | 268 | * settings from the config file. |
270 | */ | 269 | */ |
271 | void readSettings(); | 270 | void readSettings(); |
272 | 271 | ||
273 | /** write current state to config file. */ | 272 | /** write current state to config file. */ |
274 | void writeSettings(); | 273 | void writeSettings(); |
275 | 274 | ||
276 | /** read settings for calendar filters */ | 275 | /** read settings for calendar filters */ |
277 | void readFilterSettings(KConfig *config); | 276 | void readFilterSettings(KConfig *config); |
278 | 277 | ||
279 | /** write settings for calendar filters */ | 278 | /** write settings for calendar filters */ |
280 | void writeFilterSettings(KConfig *config); | 279 | void writeFilterSettings(KConfig *config); |
281 | 280 | ||
282 | /** passes on the message that an event has changed to the currently | 281 | /** passes on the message that an event has changed to the currently |
283 | * activated view so that it can make appropriate display changes. */ | 282 | * activated view so that it can make appropriate display changes. */ |
284 | void changeEventDisplay(Event *, int); | 283 | void changeEventDisplay(Event *, int); |
285 | void changeIncidenceDisplay(Incidence *, int); | 284 | void changeIncidenceDisplay(Incidence *, int); |
286 | void changeTodoDisplay(Todo *, int); | 285 | void changeTodoDisplay(Todo *, int); |
287 | 286 | ||
288 | void eventAdded(Event *); | 287 | void eventAdded(Event *); |
289 | void eventChanged(Event *); | 288 | void eventChanged(Event *); |
290 | void eventToBeDeleted(Event *); | 289 | void eventToBeDeleted(Event *); |
291 | void eventDeleted(); | 290 | void eventDeleted(); |
292 | 291 | ||
293 | void todoAdded(Todo *); | 292 | void todoAdded(Todo *); |
294 | void todoChanged(Todo *); | 293 | void todoChanged(Todo *); |
295 | void todoToBeDeleted(Todo *); | 294 | void todoToBeDeleted(Todo *); |
296 | void todoDeleted(); | 295 | void todoDeleted(); |
297 | 296 | ||
298 | void updateView(const QDate &start, const QDate &end); | 297 | void updateView(const QDate &start, const QDate &end); |
299 | void updateView(); | 298 | void updateView(); |
300 | 299 | ||
301 | /** Full update of visible todo views */ | 300 | /** Full update of visible todo views */ |
302 | void updateTodoViews(); | 301 | void updateTodoViews(); |
303 | 302 | ||
304 | void updateUnmanagedViews(); | 303 | void updateUnmanagedViews(); |
305 | 304 | ||
306 | /** cut the current appointment to the clipboard */ | 305 | /** cut the current appointment to the clipboard */ |
307 | void edit_cut(); | 306 | void edit_cut(); |
308 | 307 | ||
309 | /** copy the current appointment(s) to the clipboard */ | 308 | /** copy the current appointment(s) to the clipboard */ |
310 | void edit_copy(); | 309 | void edit_copy(); |
311 | 310 | ||
312 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 311 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
313 | void edit_paste(); | 312 | void edit_paste(); |
314 | 313 | ||
315 | /** edit viewing and configuration options. */ | 314 | /** edit viewing and configuration options. */ |
316 | void edit_options(); | 315 | void edit_options(); |
317 | void edit_sync_options(); | 316 | void edit_sync_options(); |
318 | /** | 317 | /** |
319 | Functions for printing, previewing a print, and setting up printing | 318 | Functions for printing, previewing a print, and setting up printing |
320 | parameters. | 319 | parameters. |
321 | */ | 320 | */ |
322 | void print(); | 321 | void print(); |
323 | void printSetup(); | 322 | void printSetup(); |
324 | void printPreview(); | 323 | void printPreview(); |
325 | 324 | ||
326 | /** Export as iCalendar file */ | 325 | /** Export as iCalendar file */ |
327 | void exportICalendar(); | 326 | void exportICalendar(); |
328 | 327 | ||
329 | /** Export as vCalendar file */ | 328 | /** Export as vCalendar file */ |
330 | bool exportVCalendar( QString fn); | 329 | bool exportVCalendar( QString fn); |
331 | 330 | ||
332 | /** pop up a dialog to show an existing appointment. */ | 331 | /** pop up a dialog to show an existing appointment. */ |
333 | void appointment_show(); | 332 | void appointment_show(); |
334 | /** | 333 | /** |
335 | * pop up an Appointment Dialog to edit an existing appointment.Get | 334 | * pop up an Appointment Dialog to edit an existing appointment.Get |
336 | * information on the appointment from the list of unique IDs that is | 335 | * information on the appointment from the list of unique IDs that is |
337 | * currently in the View, called currIds. | 336 | * currently in the View, called currIds. |
338 | */ | 337 | */ |
339 | void appointment_edit(); | 338 | void appointment_edit(); |
340 | /** | 339 | /** |
341 | * pop up dialog confirming deletion of currently selected event in the | 340 | * pop up dialog confirming deletion of currently selected event in the |
342 | * View. | 341 | * View. |
343 | */ | 342 | */ |
344 | void appointment_delete(); | 343 | void appointment_delete(); |
345 | 344 | ||
346 | /** mails the currently selected event to a particular user as a vCalendar | 345 | /** mails the currently selected event to a particular user as a vCalendar |
347 | attachment. */ | 346 | attachment. */ |
348 | void action_mail(); | 347 | void action_mail(); |
349 | 348 | ||
350 | /* frees a subtodo from it's relation */ | 349 | /* frees a subtodo from it's relation */ |
351 | void todo_unsub( Todo * ); | 350 | void todo_unsub( Todo * ); |
352 | 351 | ||
353 | /** Take ownership of selected event. */ | 352 | /** Take ownership of selected event. */ |
354 | void takeOverEvent(); | 353 | void takeOverEvent(); |
355 | 354 | ||
356 | /** Take ownership of all events in calendar. */ | 355 | /** Take ownership of all events in calendar. */ |
357 | void takeOverCalendar(); | 356 | void takeOverCalendar(); |
358 | 357 | ||
359 | /** query whether or not the calendar is "dirty". */ | 358 | /** query whether or not the calendar is "dirty". */ |
360 | bool isModified(); | 359 | bool isModified(); |
361 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 360 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
362 | void setModified(bool modified=true); | 361 | void setModified(bool modified=true); |
363 | 362 | ||
364 | /** query if the calendar is read-only. */ | 363 | /** query if the calendar is read-only. */ |
365 | bool isReadOnly(); | 364 | bool isReadOnly(); |
366 | /** set state of calendar to read-only */ | 365 | /** set state of calendar to read-only */ |
367 | void setReadOnly(bool readOnly=true); | 366 | void setReadOnly(bool readOnly=true); |
368 | 367 | ||
369 | void eventUpdated(Incidence *); | 368 | void eventUpdated(Incidence *); |
370 | 369 | ||
371 | /* iTIP scheduling actions */ | 370 | /* iTIP scheduling actions */ |
372 | void schedule_publish(Incidence *incidence = 0); | 371 | void schedule_publish(Incidence *incidence = 0); |
373 | void schedule_request(Incidence *incidence = 0); | 372 | void schedule_request(Incidence *incidence = 0); |
374 | void schedule_refresh(Incidence *incidence = 0); | 373 | void schedule_refresh(Incidence *incidence = 0); |
375 | void schedule_cancel(Incidence *incidence = 0); | 374 | void schedule_cancel(Incidence *incidence = 0); |
376 | void schedule_add(Incidence *incidence = 0); | 375 | void schedule_add(Incidence *incidence = 0); |
377 | void schedule_reply(Incidence *incidence = 0); | 376 | void schedule_reply(Incidence *incidence = 0); |
378 | void schedule_counter(Incidence *incidence = 0); | 377 | void schedule_counter(Incidence *incidence = 0); |
379 | void schedule_declinecounter(Incidence *incidence = 0); | 378 | void schedule_declinecounter(Incidence *incidence = 0); |
380 | void schedule_publish_freebusy(int daysToPublish = 30); | 379 | void schedule_publish_freebusy(int daysToPublish = 30); |
381 | 380 | ||
382 | void openAddressbook(); | 381 | void openAddressbook(); |
383 | 382 | ||
384 | void editFilters(); | 383 | void editFilters(); |
385 | void toggleFilerEnabled(); | 384 | void toggleFilerEnabled(); |
386 | QPtrList<CalFilter> filters(); | 385 | QPtrList<CalFilter> filters(); |
387 | void toggleFilter(); | 386 | void toggleFilter(); |
388 | void showFilter(bool visible); | 387 | void showFilter(bool visible); |
389 | void updateFilter(); | 388 | void updateFilter(); |
390 | void filterEdited(); | 389 | void filterEdited(); |
391 | void selectFilter( int ); | 390 | void selectFilter( int ); |
392 | KOFilterView *filterView(); | 391 | KOFilterView *filterView(); |
393 | 392 | ||
394 | void showIntro(); | 393 | void showIntro(); |
395 | 394 | ||
396 | /** Move the curdatepient view date to today */ | 395 | /** Move the curdatepient view date to today */ |
397 | void goToday(); | 396 | void goToday(); |
398 | 397 | ||
399 | /** Move to the next date(s) in the current view */ | 398 | /** Move to the next date(s) in the current view */ |
400 | void goNext(); | 399 | void goNext(); |
401 | 400 | ||
402 | /** Move to the previous date(s) in the current view */ | 401 | /** Move to the previous date(s) in the current view */ |
403 | void goPrevious(); | 402 | void goPrevious(); |
404 | /** Move to the next date(s) in the current view */ | 403 | /** Move to the next date(s) in the current view */ |
405 | void goNextMonth(); | 404 | void goNextMonth(); |
406 | 405 | ||
407 | /** Move to the previous date(s) in the current view */ | 406 | /** Move to the previous date(s) in the current view */ |
408 | void goPreviousMonth(); | 407 | void goPreviousMonth(); |
409 | 408 | ||
410 | void toggleExpand(); | 409 | void toggleExpand(); |
411 | void toggleDateNavigatorWidget(); | 410 | void toggleDateNavigatorWidget(); |
412 | void toggleAllDaySize(); | 411 | void toggleAllDaySize(); |
413 | void dialogClosing(Incidence *); | 412 | void dialogClosing(Incidence *); |
414 | 413 | ||
415 | /** Look for new messages in the inbox */ | 414 | /** Look for new messages in the inbox */ |
416 | void lookForIncomingMessages(); | 415 | void lookForIncomingMessages(); |
417 | /** Look for new messages in the outbox */ | 416 | /** Look for new messages in the outbox */ |
418 | void lookForOutgoingMessages(); | 417 | void lookForOutgoingMessages(); |
419 | 418 | ||
420 | void processMainViewSelection( Incidence * ); | 419 | void processMainViewSelection( Incidence * ); |
421 | void processTodoListSelection( Incidence * ); | 420 | void processTodoListSelection( Incidence * ); |
422 | 421 | ||
423 | void processIncidenceSelection( Incidence * ); | 422 | void processIncidenceSelection( Incidence * ); |
424 | 423 | ||
425 | void purgeCompleted(); | 424 | void purgeCompleted(); |
426 | bool removeCompletedSubTodos( Todo* ); | 425 | bool removeCompletedSubTodos( Todo* ); |
427 | void slotCalendarChanged(); | 426 | void slotCalendarChanged(); |
428 | bool importBday(); | 427 | bool importBday(); |
429 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 428 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
430 | bool importQtopia( const QString &categoriesFile, | 429 | bool importQtopia( const QString &categoriesFile, |
431 | const QString &datebookFile, | 430 | const QString &datebookFile, |
432 | const QString &tasklistFile ); | 431 | const QString &tasklistFile ); |
433 | void syncSharp( ); | 432 | void syncSharp( ); |
434 | void syncPhone( ); | 433 | void syncPhone( ); |
435 | void syncExternal( int mode ); | 434 | void syncExternal( int mode ); |
436 | void slotSelectPickerDate( QDate ) ; | 435 | void slotSelectPickerDate( QDate ) ; |
437 | void showDatePicker( ) ; | 436 | void showDatePicker( ) ; |
438 | void moveIncidence(Incidence *) ; | 437 | void moveIncidence(Incidence *) ; |
439 | void beamIncidence(Incidence *) ; | 438 | void beamIncidence(Incidence *) ; |
440 | void beamCalendar() ; | 439 | void beamCalendar() ; |
441 | void beamFilteredCalendar() ; | 440 | void beamFilteredCalendar() ; |
442 | void beamIncidenceList(QPtrList<Incidence>) ; | 441 | void beamIncidenceList(QPtrList<Incidence>) ; |
443 | void manageCategories(); | 442 | void manageCategories(); |
444 | int addCategories(); | 443 | int addCategories(); |
445 | void removeCategories(); | 444 | void removeCategories(); |
446 | void setSyncDevice( QString ); | 445 | void setSyncDevice( QString ); |
447 | void setSyncName( QString ); | 446 | void setSyncName( QString ); |
448 | protected slots: | 447 | protected slots: |
449 | void timerAlarm(); | 448 | void timerAlarm(); |
450 | void suspendAlarm(); | 449 | void suspendAlarm(); |
451 | void beamDone( Ir *ir ); | 450 | void beamDone( Ir *ir ); |
452 | /** Select a view or adapt the current view to display the specified dates. */ | 451 | /** Select a view or adapt the current view to display the specified dates. */ |
453 | void showDates( const KCal::DateList & ); | 452 | void showDates( const KCal::DateList & ); |
454 | void selectWeekNum ( int ); | 453 | void selectWeekNum ( int ); |
455 | 454 | ||
456 | public: | 455 | public: |
457 | // show a standard warning | 456 | // show a standard warning |
458 | // returns KMsgBox::yesNoCancel() | 457 | // returns KMsgBox::yesNoCancel() |
459 | int msgCalModified(); | 458 | int msgCalModified(); |
460 | void confSync(); | 459 | void confSync(); |
461 | void setLoadedFileVersion(QDateTime); | 460 | void setLoadedFileVersion(QDateTime); |
462 | bool checkFileVersion(QString fn); | 461 | bool checkFileVersion(QString fn); |
463 | bool checkFileChanged(QString fn); | 462 | bool checkFileChanged(QString fn); |
464 | Event* getLastSyncEvent(); | 463 | Event* getLastSyncEvent(); |
465 | /** Adapt navigation units correpsonding to step size of navigation of the | 464 | /** Adapt navigation units correpsonding to step size of navigation of the |
466 | * current view. | 465 | * current view. |
467 | */ | 466 | */ |
468 | void adaptNavigationUnits(); | 467 | void adaptNavigationUnits(); |
469 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 468 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
470 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 469 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
471 | //Attendee* getYourAttendee(Event *event); | 470 | //Attendee* getYourAttendee(Event *event); |
472 | protected: | 471 | protected: |
473 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 472 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
474 | 473 | ||
475 | // returns KMsgBox::OKCandel() | 474 | // returns KMsgBox::OKCandel() |
476 | int msgItemDelete(); | 475 | int msgItemDelete(); |
477 | void showEventEditor(); | 476 | void showEventEditor(); |
478 | void showTodoEditor(); | 477 | void showTodoEditor(); |
479 | void writeLocale(); | 478 | void writeLocale(); |
480 | Todo *selectedTodo(); | 479 | Todo *selectedTodo(); |
481 | 480 | ||
482 | private: | 481 | private: |
483 | AlarmDialog * mAlarmDialog; | 482 | AlarmDialog * mAlarmDialog; |
484 | QString mAlarmNotification; | 483 | QString mAlarmNotification; |
485 | QString mSuspendAlarmNotification; | 484 | QString mSuspendAlarmNotification; |
486 | QTimer* mSuspendTimer; | 485 | QTimer* mSuspendTimer; |
487 | QTimer* mAlarmTimer; | 486 | QTimer* mAlarmTimer; |
488 | QTimer* mRecheckAlarmTimer; | 487 | QTimer* mRecheckAlarmTimer; |
489 | void computeAlarm( QString ); | 488 | void computeAlarm( QString ); |
490 | void startAlarm( QString, QString ); | 489 | void startAlarm( QString, QString ); |
491 | void setSyncEventsReadOnly(); | 490 | void setSyncEventsReadOnly(); |
492 | 491 | ||
493 | QDateTime loadedFileVersion; | 492 | QDateTime loadedFileVersion; |
494 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 493 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
495 | void checkExternalId( Incidence * inc ); | 494 | void checkExternalId( Incidence * inc ); |
496 | int mGlobalSyncMode; | 495 | int mGlobalSyncMode; |
497 | QString mCurrentSyncDevice; | 496 | QString mCurrentSyncDevice; |
498 | QString mCurrentSyncName; | 497 | QString mCurrentSyncName; |
499 | KOBeamPrefs* beamDialog; | 498 | KOBeamPrefs* beamDialog; |
500 | void init(); | 499 | void init(); |
501 | int mDatePickerMode; | 500 | int mDatePickerMode; |
502 | bool mFlagEditDescription; | 501 | bool mFlagEditDescription; |
503 | QDateTime mLastCalendarSync; | 502 | QDateTime mLastCalendarSync; |
504 | void createPrinter(); | 503 | void createPrinter(); |
505 | 504 | ||
506 | void calendarModified( bool, Calendar * ); | 505 | void calendarModified( bool, Calendar * ); |
507 | 506 | ||
508 | CalPrinter *mCalPrinter; | 507 | CalPrinter *mCalPrinter; |
509 | 508 | ||
510 | QSplitter *mPanner; | 509 | QSplitter *mPanner; |
511 | QSplitter *mLeftSplitter; | 510 | QSplitter *mLeftSplitter; |
512 | QWidget *mLeftFrame; | 511 | QWidget *mLeftFrame; |
513 | QWidgetStack *mRightFrame; | 512 | QWidgetStack *mRightFrame; |
514 | 513 | ||
515 | KDatePicker* mDatePicker; | 514 | KDatePicker* mDatePicker; |
516 | QVBox* mDateFrame; | 515 | QVBox* mDateFrame; |
517 | NavigatorBar *mNavigatorBar; | 516 | NavigatorBar *mNavigatorBar; |
518 | 517 | ||
519 | KDateNavigator *mDateNavigator; // widget showing small month view. | 518 | KDateNavigator *mDateNavigator; // widget showing small month view. |
520 | 519 | ||
521 | KOFilterView *mFilterView; | 520 | KOFilterView *mFilterView; |
522 | 521 | ||
523 | ResourceView *mResourceView; | 522 | ResourceView *mResourceView; |
524 | 523 | ||
525 | // calendar object for this viewing instance | 524 | // calendar object for this viewing instance |
526 | Calendar *mCalendar; | 525 | Calendar *mCalendar; |
527 | 526 | ||
528 | CalendarResourceManager *mResourceManager; | 527 | CalendarResourceManager *mResourceManager; |
529 | 528 | ||
530 | FileStorage *mStorage; | 529 | FileStorage *mStorage; |
531 | 530 | ||
532 | DateNavigator *mNavigator; | 531 | DateNavigator *mNavigator; |
533 | 532 | ||
534 | KOViewManager *mViewManager; | 533 | KOViewManager *mViewManager; |
535 | KODialogManager *mDialogManager; | 534 | KODialogManager *mDialogManager; |
536 | 535 | ||
537 | // Calendar filters | 536 | // Calendar filters |
538 | QPtrList<CalFilter> mFilters; | 537 | QPtrList<CalFilter> mFilters; |
539 | 538 | ||
540 | // various housekeeping variables. | 539 | // various housekeeping variables. |
541 | bool mModified; // flag indicating if calendar is modified | 540 | bool mModified; // flag indicating if calendar is modified |
542 | bool mReadOnly; // flag indicating if calendar is read-only | 541 | bool mReadOnly; // flag indicating if calendar is read-only |
543 | QDate mSaveSingleDate; | 542 | QDate mSaveSingleDate; |
544 | 543 | ||
545 | Incidence *mSelectedIncidence; | 544 | Incidence *mSelectedIncidence; |
546 | Incidence *mMoveIncidence; | 545 | Incidence *mMoveIncidence; |
547 | QPtrList<Event> mExternLastSyncEvent; | ||
548 | KOTodoView *mTodoList; | 546 | KOTodoView *mTodoList; |
549 | KOEventEditor * mEventEditor; | 547 | KOEventEditor * mEventEditor; |
550 | KOTodoEditor * mTodoEditor; | 548 | KOTodoEditor * mTodoEditor; |
551 | KOEventViewerDialog * mEventViewerDialog; | 549 | KOEventViewerDialog * mEventViewerDialog; |
552 | void keyPressEvent ( QKeyEvent *e) ; | 550 | void keyPressEvent ( QKeyEvent *e) ; |
553 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 551 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
554 | }; | 552 | }; |
555 | 553 | ||
556 | 554 | ||
557 | class CalendarViewVisitor : public Incidence::Visitor | 555 | class CalendarViewVisitor : public Incidence::Visitor |
558 | { | 556 | { |
559 | public: | 557 | public: |
560 | CalendarViewVisitor() : mView( 0 ) {} | 558 | CalendarViewVisitor() : mView( 0 ) {} |
561 | 559 | ||
562 | bool act( Incidence *incidence, CalendarView *view ) | 560 | bool act( Incidence *incidence, CalendarView *view ) |
563 | { | 561 | { |
564 | mView = view; | 562 | mView = view; |
565 | return incidence->accept( *this ); | 563 | return incidence->accept( *this ); |
566 | } | 564 | } |
567 | 565 | ||
568 | protected: | 566 | protected: |
569 | CalendarView *mView; | 567 | CalendarView *mView; |
570 | }; | 568 | }; |
571 | 569 | ||
572 | class ShowIncidenceVisitor : public CalendarViewVisitor | 570 | class ShowIncidenceVisitor : public CalendarViewVisitor |
573 | { | 571 | { |
574 | protected: | 572 | protected: |
575 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 573 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
576 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 574 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
577 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 575 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
578 | }; | 576 | }; |
579 | 577 | ||
580 | class EditIncidenceVisitor : public CalendarViewVisitor | 578 | class EditIncidenceVisitor : public CalendarViewVisitor |
581 | { | 579 | { |
582 | protected: | 580 | protected: |
583 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 581 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
584 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 582 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
585 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 583 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
586 | }; | 584 | }; |
587 | 585 | ||
588 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 586 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
589 | { | 587 | { |
590 | protected: | 588 | protected: |
591 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 589 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
592 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 590 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
593 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 591 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
594 | }; | 592 | }; |
595 | 593 | ||
596 | #endif | 594 | #endif |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index ec69b11..9104347 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,2529 +1,2528 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qtopia/alarmserver.h> | 28 | #include <qtopia/alarmserver.h> |
29 | #include <qtopia/qcopenvelope_qws.h> | 29 | #include <qtopia/qcopenvelope_qws.h> |
30 | #include <unistd.h> // for sleep | 30 | #include <unistd.h> // for sleep |
31 | #else | 31 | #else |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | //#include <resource.h> | 35 | //#include <resource.h> |
36 | 36 | ||
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendarlocal.h> | 38 | #include <libkcal/calendarlocal.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | #include <libkcal/phoneformat.h> | 40 | #include <libkcal/phoneformat.h> |
41 | #include <libkdepim/ksyncprofile.h> | 41 | #include <libkdepim/ksyncprofile.h> |
42 | #include <libkdepim/phoneaccess.h> | 42 | #include <libkdepim/phoneaccess.h> |
43 | #include <libkcal/kincidenceformatter.h> | 43 | #include <libkcal/kincidenceformatter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "calendarview.h" | 46 | #include "calendarview.h" |
47 | #include "koviewmanager.h" | 47 | #include "koviewmanager.h" |
48 | #include "datenavigator.h" | 48 | #include "datenavigator.h" |
49 | #include "koagendaview.h" | 49 | #include "koagendaview.h" |
50 | #include "koagenda.h" | 50 | #include "koagenda.h" |
51 | #include "kodialogmanager.h" | 51 | #include "kodialogmanager.h" |
52 | #include "kdialogbase.h" | 52 | #include "kdialogbase.h" |
53 | #include "kapplication.h" | 53 | #include "kapplication.h" |
54 | #include "kofilterview.h" | 54 | #include "kofilterview.h" |
55 | #include "kstandarddirs.h" | 55 | #include "kstandarddirs.h" |
56 | #include "koprefs.h" | 56 | #include "koprefs.h" |
57 | #include "kfiledialog.h" | 57 | #include "kfiledialog.h" |
58 | #include "koglobals.h" | 58 | #include "koglobals.h" |
59 | #include "kglobal.h" | 59 | #include "kglobal.h" |
60 | #include "klocale.h" | 60 | #include "klocale.h" |
61 | #include "kconfig.h" | 61 | #include "kconfig.h" |
62 | #include "simplealarmclient.h" | 62 | #include "simplealarmclient.h" |
63 | #include "externalapphandler.h" | 63 | #include "externalapphandler.h" |
64 | 64 | ||
65 | using namespace KCal; | 65 | using namespace KCal; |
66 | #ifndef _WIN32_ | 66 | #ifndef _WIN32_ |
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #else | 68 | #else |
69 | #include "koimportoldialog.h" | 69 | #include "koimportoldialog.h" |
70 | #endif | 70 | #endif |
71 | #include "mainwindow.h" | 71 | #include "mainwindow.h" |
72 | 72 | ||
73 | class KOex2phonePrefs : public QDialog | 73 | class KOex2phonePrefs : public QDialog |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 76 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
77 | QDialog( parent, name, true ) | 77 | QDialog( parent, name, true ) |
78 | { | 78 | { |
79 | setCaption( i18n("Export to phone options") ); | 79 | setCaption( i18n("Export to phone options") ); |
80 | QVBoxLayout* lay = new QVBoxLayout( this ); | 80 | QVBoxLayout* lay = new QVBoxLayout( this ); |
81 | lay->setSpacing( 3 ); | 81 | lay->setSpacing( 3 ); |
82 | lay->setMargin( 3 ); | 82 | lay->setMargin( 3 ); |
83 | QLabel *lab; | 83 | QLabel *lab; |
84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 84 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
85 | lab->setAlignment (AlignHCenter ); | 85 | lab->setAlignment (AlignHCenter ); |
86 | QHBox* temphb; | 86 | QHBox* temphb; |
87 | temphb = new QHBox( this ); | 87 | temphb = new QHBox( this ); |
88 | new QLabel( i18n("I/O device: "), temphb ); | 88 | new QLabel( i18n("I/O device: "), temphb ); |
89 | mPhoneDevice = new QLineEdit( temphb); | 89 | mPhoneDevice = new QLineEdit( temphb); |
90 | lay->addWidget( temphb ); | 90 | lay->addWidget( temphb ); |
91 | temphb = new QHBox( this ); | 91 | temphb = new QHBox( this ); |
92 | new QLabel( i18n("Connection: "), temphb ); | 92 | new QLabel( i18n("Connection: "), temphb ); |
93 | mPhoneConnection = new QLineEdit( temphb); | 93 | mPhoneConnection = new QLineEdit( temphb); |
94 | lay->addWidget( temphb ); | 94 | lay->addWidget( temphb ); |
95 | temphb = new QHBox( this ); | 95 | temphb = new QHBox( this ); |
96 | new QLabel( i18n("Model(opt.): "), temphb ); | 96 | new QLabel( i18n("Model(opt.): "), temphb ); |
97 | mPhoneModel = new QLineEdit( temphb); | 97 | mPhoneModel = new QLineEdit( temphb); |
98 | lay->addWidget( temphb ); | 98 | lay->addWidget( temphb ); |
99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 99 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
100 | mWriteBackFuture->setChecked( true ); | 100 | mWriteBackFuture->setChecked( true ); |
101 | lay->addWidget( mWriteBackFuture ); | 101 | lay->addWidget( mWriteBackFuture ); |
102 | temphb = new QHBox( this ); | 102 | temphb = new QHBox( this ); |
103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 103 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 104 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
105 | mWriteBackFutureWeeks->setValue( 8 ); | 105 | mWriteBackFutureWeeks->setValue( 8 ); |
106 | lay->addWidget( temphb ); | 106 | lay->addWidget( temphb ); |
107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); | 107 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); |
108 | lab->setAlignment (AlignHCenter ); | 108 | lab->setAlignment (AlignHCenter ); |
109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 109 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
110 | lay->addWidget( ok ); | 110 | lay->addWidget( ok ); |
111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 111 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
112 | lay->addWidget( cancel ); | 112 | lay->addWidget( cancel ); |
113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 113 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 114 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
115 | resize( 220, 240 ); | 115 | resize( 220, 240 ); |
116 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | public: | 119 | public: |
120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 120 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
121 | QCheckBox* mWriteBackFuture; | 121 | QCheckBox* mWriteBackFuture; |
122 | QSpinBox* mWriteBackFutureWeeks; | 122 | QSpinBox* mWriteBackFutureWeeks; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | int globalFlagBlockStartup; | 125 | int globalFlagBlockStartup; |
126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 126 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
127 | QMainWindow( parent, name ) | 127 | QMainWindow( parent, name ) |
128 | { | 128 | { |
129 | mPassWordPiSync = "abc"; | 129 | mPassWordPiSync = "abc"; |
130 | #ifdef DESKTOP_VERSION | 130 | #ifdef DESKTOP_VERSION |
131 | setFont( QFont("Arial"), 14 ); | 131 | setFont( QFont("Arial"), 14 ); |
132 | #endif | 132 | #endif |
133 | mSyncActionDialog = 0; | 133 | mSyncActionDialog = 0; |
134 | mServerSocket = 0; | 134 | mServerSocket = 0; |
135 | mClosed = false; | 135 | mClosed = false; |
136 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 136 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
137 | QString confFile = locateLocal("config","korganizerrc"); | 137 | QString confFile = locateLocal("config","korganizerrc"); |
138 | QFileInfo finf ( confFile ); | 138 | QFileInfo finf ( confFile ); |
139 | bool showWarning = !finf.exists(); | 139 | bool showWarning = !finf.exists(); |
140 | setIcon(SmallIcon( "ko24" ) ); | 140 | setIcon(SmallIcon( "ko24" ) ); |
141 | mBlockAtStartup = true; | 141 | mBlockAtStartup = true; |
142 | mFlagKeyPressed = false; | 142 | mFlagKeyPressed = false; |
143 | setCaption("KOrganizer/Pi"); | 143 | setCaption("KOrganizer/Pi"); |
144 | KOPrefs *p = KOPrefs::instance(); | 144 | KOPrefs *p = KOPrefs::instance(); |
145 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 145 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
146 | // if ( QApplication::desktop()->height() > 480 ) { | 146 | // if ( QApplication::desktop()->height() > 480 ) { |
147 | // if ( p->mHourSize == 4 ) | 147 | // if ( p->mHourSize == 4 ) |
148 | // p->mHourSize = 6; | 148 | // p->mHourSize = 6; |
149 | // } | 149 | // } |
150 | if ( p->mHourSize > 18 ) | 150 | if ( p->mHourSize > 18 ) |
151 | p->mHourSize = 18; | 151 | p->mHourSize = 18; |
152 | QMainWindow::ToolBarDock tbd; | 152 | QMainWindow::ToolBarDock tbd; |
153 | if ( p->mToolBarHor ) { | 153 | if ( p->mToolBarHor ) { |
154 | if ( p->mToolBarUp ) | 154 | if ( p->mToolBarUp ) |
155 | tbd = Bottom; | 155 | tbd = Bottom; |
156 | else | 156 | else |
157 | tbd = Top; | 157 | tbd = Top; |
158 | } | 158 | } |
159 | else { | 159 | else { |
160 | if ( p->mToolBarUp ) | 160 | if ( p->mToolBarUp ) |
161 | tbd = Right; | 161 | tbd = Right; |
162 | else | 162 | else |
163 | tbd = Left; | 163 | tbd = Left; |
164 | } | 164 | } |
165 | if ( KOPrefs::instance()->mUseAppColors ) | 165 | if ( KOPrefs::instance()->mUseAppColors ) |
166 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 166 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
167 | globalFlagBlockStartup = 1; | 167 | globalFlagBlockStartup = 1; |
168 | iconToolBar = new QPEToolBar( this ); | 168 | iconToolBar = new QPEToolBar( this ); |
169 | addToolBar (iconToolBar , tbd ); | 169 | addToolBar (iconToolBar , tbd ); |
170 | mBlockSaveFlag = false; | 170 | mBlockSaveFlag = false; |
171 | mCalendarModifiedFlag = false; | 171 | mCalendarModifiedFlag = false; |
172 | 172 | ||
173 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 173 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
174 | splash->setAlignment ( AlignCenter ); | 174 | splash->setAlignment ( AlignCenter ); |
175 | setCentralWidget( splash ); | 175 | setCentralWidget( splash ); |
176 | #ifndef DESKTOP_VERSION | 176 | #ifndef DESKTOP_VERSION |
177 | showMaximized(); | 177 | showMaximized(); |
178 | #endif | 178 | #endif |
179 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 179 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
180 | setDefaultPreferences(); | 180 | setDefaultPreferences(); |
181 | mCalendar = new CalendarLocal(); | 181 | mCalendar = new CalendarLocal(); |
182 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 182 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
183 | mView->hide(); | 183 | mView->hide(); |
184 | //mView->resize(splash->size() ); | 184 | //mView->resize(splash->size() ); |
185 | initActions(); | 185 | initActions(); |
186 | #ifndef DESKTOP_VERSION | 186 | #ifndef DESKTOP_VERSION |
187 | iconToolBar->show(); | 187 | iconToolBar->show(); |
188 | qApp->processEvents(); | 188 | qApp->processEvents(); |
189 | #endif | 189 | #endif |
190 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 190 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
191 | int vh = height() ; | 191 | int vh = height() ; |
192 | int vw = width(); | 192 | int vw = width(); |
193 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 193 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
194 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 194 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
195 | vh -= iconToolBar->height(); | 195 | vh -= iconToolBar->height(); |
196 | } else { | 196 | } else { |
197 | vw -= iconToolBar->height(); | 197 | vw -= iconToolBar->height(); |
198 | } | 198 | } |
199 | //mView->setMaximumSize( splash->size() ); | 199 | //mView->setMaximumSize( splash->size() ); |
200 | //mView->resize( splash->size() ); | 200 | //mView->resize( splash->size() ); |
201 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 201 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
202 | mView->readSettings(); | 202 | mView->readSettings(); |
203 | bool newFile = false; | 203 | bool newFile = false; |
204 | if( !QFile::exists( defaultFileName() ) ) { | 204 | if( !QFile::exists( defaultFileName() ) ) { |
205 | QFileInfo finfo ( defaultFileName() ); | 205 | QFileInfo finfo ( defaultFileName() ); |
206 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 206 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
207 | qDebug("oldfile %s ", oldFile.latin1()); | 207 | qDebug("oldfile %s ", oldFile.latin1()); |
208 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 208 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
209 | finfo.setFile( oldFile ); | 209 | finfo.setFile( oldFile ); |
210 | if (finfo.exists() ) { | 210 | if (finfo.exists() ) { |
211 | KMessageBox::information( this, message); | 211 | KMessageBox::information( this, message); |
212 | mView->openCalendar( oldFile ); | 212 | mView->openCalendar( oldFile ); |
213 | qApp->processEvents(); | 213 | qApp->processEvents(); |
214 | } else { | 214 | } else { |
215 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 215 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
216 | finfo.setFile( oldFile ); | 216 | finfo.setFile( oldFile ); |
217 | if (finfo.exists() ) { | 217 | if (finfo.exists() ) { |
218 | KMessageBox::information( this, message); | 218 | KMessageBox::information( this, message); |
219 | mView->openCalendar( oldFile ); | 219 | mView->openCalendar( oldFile ); |
220 | qApp->processEvents(); | 220 | qApp->processEvents(); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | mView->saveCalendar( defaultFileName() ); | 223 | mView->saveCalendar( defaultFileName() ); |
224 | newFile = true; | 224 | newFile = true; |
225 | } | 225 | } |
226 | 226 | ||
227 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 227 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
228 | mView->openCalendar( defaultFileName() ); | 228 | mView->openCalendar( defaultFileName() ); |
229 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 229 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
230 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 230 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
231 | 231 | ||
232 | if ( KOPrefs::instance()->mLanguageChanged ) { | 232 | if ( KOPrefs::instance()->mLanguageChanged ) { |
233 | KOPrefs::instance()->setCategoryDefaults(); | 233 | KOPrefs::instance()->setCategoryDefaults(); |
234 | int count = mView->addCategories(); | 234 | int count = mView->addCategories(); |
235 | KOPrefs::instance()->mLanguageChanged = false; | 235 | KOPrefs::instance()->mLanguageChanged = false; |
236 | } | 236 | } |
237 | processIncidenceSelection( 0 ); | 237 | processIncidenceSelection( 0 ); |
238 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 238 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
239 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 239 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
240 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 240 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
241 | SLOT( slotModifiedChanged( bool ) ) ); | 241 | SLOT( slotModifiedChanged( bool ) ) ); |
242 | 242 | ||
243 | 243 | ||
244 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 244 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
245 | mView->setModified( false ); | 245 | mView->setModified( false ); |
246 | mBlockAtStartup = false; | 246 | mBlockAtStartup = false; |
247 | mView->setModified( false ); | 247 | mView->setModified( false ); |
248 | setCentralWidget( mView ); | 248 | setCentralWidget( mView ); |
249 | globalFlagBlockStartup = 0; | 249 | globalFlagBlockStartup = 0; |
250 | mView->show(); | 250 | mView->show(); |
251 | delete splash; | 251 | delete splash; |
252 | if ( newFile ) | 252 | if ( newFile ) |
253 | mView->updateConfig(); | 253 | mView->updateConfig(); |
254 | // qApp->processEvents(); | 254 | // qApp->processEvents(); |
255 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 255 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
256 | fillSyncMenu(); | 256 | fillSyncMenu(); |
257 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 257 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
258 | if ( showWarning ) { | 258 | if ( showWarning ) { |
259 | KMessageBox::information( this, | 259 | KMessageBox::information( this, |
260 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 260 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
261 | qApp->processEvents(); | 261 | qApp->processEvents(); |
262 | mView->dialogManager()->showSyncOptions(); | 262 | mView->dialogManager()->showSyncOptions(); |
263 | } | 263 | } |
264 | 264 | ||
265 | //US listen for result adressed from Ka/Pi | 265 | //US listen for result adressed from Ka/Pi |
266 | #ifndef DESKTOP_VERSION | 266 | #ifndef DESKTOP_VERSION |
267 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 267 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
268 | #endif | 268 | #endif |
269 | } | 269 | } |
270 | MainWindow::~MainWindow() | 270 | MainWindow::~MainWindow() |
271 | { | 271 | { |
272 | //qDebug("MainWindow::~MainWindow() "); | 272 | //qDebug("MainWindow::~MainWindow() "); |
273 | //save toolbar location | 273 | //save toolbar location |
274 | delete mServerSocket; | 274 | delete mServerSocket; |
275 | delete mCalendar; | 275 | delete mCalendar; |
276 | delete KOPrefs::instance(); | 276 | delete KOPrefs::instance(); |
277 | delete KIncidenceFormatter::instance(); | 277 | delete KIncidenceFormatter::instance(); |
278 | 278 | ||
279 | 279 | ||
280 | } | 280 | } |
281 | void MainWindow::showMaximized () | 281 | void MainWindow::showMaximized () |
282 | { | 282 | { |
283 | #ifndef DESKTOP_VERSION | 283 | #ifndef DESKTOP_VERSION |
284 | if ( ! globalFlagBlockStartup ) | 284 | if ( ! globalFlagBlockStartup ) |
285 | if ( mClosed ) | 285 | if ( mClosed ) |
286 | mView->goToday(); | 286 | mView->goToday(); |
287 | #endif | 287 | #endif |
288 | QWidget::showMaximized () ; | 288 | QWidget::showMaximized () ; |
289 | mClosed = false; | 289 | mClosed = false; |
290 | } | 290 | } |
291 | void MainWindow::closeEvent( QCloseEvent* ce ) | 291 | void MainWindow::closeEvent( QCloseEvent* ce ) |
292 | { | 292 | { |
293 | 293 | ||
294 | 294 | ||
295 | 295 | ||
296 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 296 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
297 | saveOnClose(); | 297 | saveOnClose(); |
298 | mClosed = true; | 298 | mClosed = true; |
299 | ce->accept(); | 299 | ce->accept(); |
300 | return; | 300 | return; |
301 | 301 | ||
302 | } | 302 | } |
303 | 303 | ||
304 | switch( QMessageBox::information( this, "KO/Pi", | 304 | switch( QMessageBox::information( this, "KO/Pi", |
305 | i18n("Do you really want\nto close KO/Pi?"), | 305 | i18n("Do you really want\nto close KO/Pi?"), |
306 | i18n("Close"), i18n("No"), | 306 | i18n("Close"), i18n("No"), |
307 | 0, 0 ) ) { | 307 | 0, 0 ) ) { |
308 | case 0: | 308 | case 0: |
309 | saveOnClose(); | 309 | saveOnClose(); |
310 | mClosed = true; | 310 | mClosed = true; |
311 | ce->accept(); | 311 | ce->accept(); |
312 | break; | 312 | break; |
313 | case 1: | 313 | case 1: |
314 | ce->ignore(); | 314 | ce->ignore(); |
315 | break; | 315 | break; |
316 | case 2: | 316 | case 2: |
317 | 317 | ||
318 | default: | 318 | default: |
319 | break; | 319 | break; |
320 | } | 320 | } |
321 | 321 | ||
322 | 322 | ||
323 | } | 323 | } |
324 | 324 | ||
325 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 325 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
326 | { | 326 | { |
327 | QDataStream stream( data, IO_ReadOnly ); | 327 | QDataStream stream( data, IO_ReadOnly ); |
328 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 328 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
329 | //QString datamess; | 329 | //QString datamess; |
330 | //qDebug("message "); | 330 | //qDebug("message "); |
331 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 331 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
332 | 332 | ||
333 | if ( cmsg == "-writeFile" ) { | 333 | if ( cmsg == "-writeFile" ) { |
334 | // I made from the "-writeFile" an "-writeAlarm" | 334 | // I made from the "-writeFile" an "-writeAlarm" |
335 | mView->viewManager()->showWhatsNextView(); | 335 | mView->viewManager()->showWhatsNextView(); |
336 | mCalendar->checkAlarmForIncidence( 0, true); | 336 | mCalendar->checkAlarmForIncidence( 0, true); |
337 | showMaximized(); | 337 | showMaximized(); |
338 | raise(); | 338 | raise(); |
339 | return; | 339 | return; |
340 | } | 340 | } |
341 | 341 | ||
342 | if ( cmsg == "-writeFile" ) { | 342 | if ( cmsg == "-writeFile" ) { |
343 | // I made from the "-writeFile" an "-writeAlarm" | 343 | // I made from the "-writeFile" an "-writeAlarm" |
344 | mView->viewManager()->showWhatsNextView(); | 344 | mView->viewManager()->showWhatsNextView(); |
345 | mCalendar->checkAlarmForIncidence( 0, true); | 345 | mCalendar->checkAlarmForIncidence( 0, true); |
346 | showMaximized(); | 346 | showMaximized(); |
347 | raise(); | 347 | raise(); |
348 | return; | 348 | return; |
349 | 349 | ||
350 | } | 350 | } |
351 | if ( cmsg == "-writeFileSilent" ) { | 351 | if ( cmsg == "-writeFileSilent" ) { |
352 | // I made from the "-writeFile" an "-writeAlarm" | 352 | // I made from the "-writeFile" an "-writeAlarm" |
353 | // mView->viewManager()->showWhatsNextView(); | 353 | // mView->viewManager()->showWhatsNextView(); |
354 | mCalendar->checkAlarmForIncidence( 0, true); | 354 | mCalendar->checkAlarmForIncidence( 0, true); |
355 | //showMaximized(); | 355 | //showMaximized(); |
356 | //raise(); | 356 | //raise(); |
357 | hide(); | 357 | hide(); |
358 | return; | 358 | return; |
359 | } | 359 | } |
360 | if ( cmsg == "-newCountdown" ) { | 360 | if ( cmsg == "-newCountdown" ) { |
361 | qDebug("newCountdown "); | 361 | qDebug("newCountdown "); |
362 | 362 | ||
363 | } | 363 | } |
364 | QString msg ; | 364 | QString msg ; |
365 | QString allmsg = cmsg; | 365 | QString allmsg = cmsg; |
366 | while ( allmsg.length() > 0 ) { | 366 | while ( allmsg.length() > 0 ) { |
367 | int nextC = allmsg.find( "-", 1 ); | 367 | int nextC = allmsg.find( "-", 1 ); |
368 | if ( nextC == -1 ) { | 368 | if ( nextC == -1 ) { |
369 | msg = allmsg; | 369 | msg = allmsg; |
370 | allmsg = ""; | 370 | allmsg = ""; |
371 | } else{ | 371 | } else{ |
372 | msg = allmsg.left( nextC ); | 372 | msg = allmsg.left( nextC ); |
373 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 373 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
374 | } | 374 | } |
375 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 375 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
376 | if ( msg == "-newEvent" ) { | 376 | if ( msg == "-newEvent" ) { |
377 | mView->newEvent(); | 377 | mView->newEvent(); |
378 | } | 378 | } |
379 | if ( msg == "-newTodo" ) { | 379 | if ( msg == "-newTodo" ) { |
380 | mView->newTodo(); | 380 | mView->newTodo(); |
381 | 381 | ||
382 | } | 382 | } |
383 | if ( msg == "-showWN" ) { | 383 | if ( msg == "-showWN" ) { |
384 | mView->viewManager()->showWhatsNextView(); | 384 | mView->viewManager()->showWhatsNextView(); |
385 | } | 385 | } |
386 | if ( msg == "-showTodo" ) { | 386 | if ( msg == "-showTodo" ) { |
387 | mView->viewManager()->showTodoView(); | 387 | mView->viewManager()->showTodoView(); |
388 | } | 388 | } |
389 | if ( msg == "-showList" ) { | 389 | if ( msg == "-showList" ) { |
390 | mView->viewManager()->showListView(); | 390 | mView->viewManager()->showListView(); |
391 | } | 391 | } |
392 | else if ( msg == "-showDay" ) { | 392 | else if ( msg == "-showDay" ) { |
393 | mView->viewManager()->showDayView(); | 393 | mView->viewManager()->showDayView(); |
394 | } | 394 | } |
395 | else if ( msg == "-showWWeek" ) { | 395 | else if ( msg == "-showWWeek" ) { |
396 | mView->viewManager()->showWorkWeekView(); | 396 | mView->viewManager()->showWorkWeekView(); |
397 | } | 397 | } |
398 | else if ( msg == "-ringSync" ) { | 398 | else if ( msg == "-ringSync" ) { |
399 | multiSync( false ); | 399 | multiSync( false ); |
400 | } | 400 | } |
401 | else if ( msg == "-showWeek" ) { | 401 | else if ( msg == "-showWeek" ) { |
402 | mView->viewManager()->showWeekView(); | 402 | mView->viewManager()->showWeekView(); |
403 | } | 403 | } |
404 | else if ( msg == "-showTodo" ) { | 404 | else if ( msg == "-showTodo" ) { |
405 | mView->viewManager()->showTodoView(); | 405 | mView->viewManager()->showTodoView(); |
406 | } | 406 | } |
407 | else if ( msg == "-showJournal" ) { | 407 | else if ( msg == "-showJournal" ) { |
408 | mView->dateNavigator()->selectDates( 1 ); | 408 | mView->dateNavigator()->selectDates( 1 ); |
409 | mView->dateNavigator()->selectToday(); | 409 | mView->dateNavigator()->selectToday(); |
410 | mView->viewManager()->showJournalView(); | 410 | mView->viewManager()->showJournalView(); |
411 | } | 411 | } |
412 | else if ( msg == "-showKO" ) { | 412 | else if ( msg == "-showKO" ) { |
413 | mView->viewManager()->showNextXView(); | 413 | mView->viewManager()->showNextXView(); |
414 | } | 414 | } |
415 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 415 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
416 | mView->viewManager()->showWhatsNextView(); | 416 | mView->viewManager()->showWhatsNextView(); |
417 | } | 417 | } |
418 | else if ( msg == "-showNextXView" ) { | 418 | else if ( msg == "-showNextXView" ) { |
419 | mView->viewManager()->showNextXView(); | 419 | mView->viewManager()->showNextXView(); |
420 | } | 420 | } |
421 | 421 | ||
422 | 422 | ||
423 | } | 423 | } |
424 | 424 | ||
425 | showMaximized(); | 425 | showMaximized(); |
426 | raise(); | 426 | raise(); |
427 | } | 427 | } |
428 | 428 | ||
429 | QPixmap MainWindow::loadPixmap( QString name ) | 429 | QPixmap MainWindow::loadPixmap( QString name ) |
430 | { | 430 | { |
431 | return SmallIcon( name ); | 431 | return SmallIcon( name ); |
432 | 432 | ||
433 | } | 433 | } |
434 | void MainWindow::initActions() | 434 | void MainWindow::initActions() |
435 | { | 435 | { |
436 | //KOPrefs::instance()->mShowFullMenu | 436 | //KOPrefs::instance()->mShowFullMenu |
437 | iconToolBar->clear(); | 437 | iconToolBar->clear(); |
438 | KOPrefs *p = KOPrefs::instance(); | 438 | KOPrefs *p = KOPrefs::instance(); |
439 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 439 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
440 | 440 | ||
441 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 441 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
442 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 442 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
443 | QPopupMenu *importMenu = new QPopupMenu( this ); | 443 | QPopupMenu *importMenu = new QPopupMenu( this ); |
444 | selectFilterMenu = new QPopupMenu( this ); | 444 | selectFilterMenu = new QPopupMenu( this ); |
445 | selectFilterMenu->setCheckable( true ); | 445 | selectFilterMenu->setCheckable( true ); |
446 | syncMenu = new QPopupMenu( this ); | 446 | syncMenu = new QPopupMenu( this ); |
447 | configureAgendaMenu = new QPopupMenu( this ); | 447 | configureAgendaMenu = new QPopupMenu( this ); |
448 | configureToolBarMenu = new QPopupMenu( this ); | 448 | configureToolBarMenu = new QPopupMenu( this ); |
449 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 449 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
450 | if ( KOPrefs::instance()->mShowFullMenu ) { | 450 | if ( KOPrefs::instance()->mShowFullMenu ) { |
451 | QMenuBar *menuBar1; | 451 | QMenuBar *menuBar1; |
452 | menuBar1 = menuBar(); | 452 | menuBar1 = menuBar(); |
453 | menuBar1->insertItem( i18n("File"), importMenu ); | 453 | menuBar1->insertItem( i18n("File"), importMenu ); |
454 | menuBar1->insertItem( i18n("View"), viewMenu ); | 454 | menuBar1->insertItem( i18n("View"), viewMenu ); |
455 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 455 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
456 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 456 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
457 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 457 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
458 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 458 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
459 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 459 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
460 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 460 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
461 | } else { | 461 | } else { |
462 | QPEMenuBar *menuBar1; | 462 | QPEMenuBar *menuBar1; |
463 | menuBar1 = new QPEMenuBar( iconToolBar ); | 463 | menuBar1 = new QPEMenuBar( iconToolBar ); |
464 | QPopupMenu *menuBar = new QPopupMenu( this ); | 464 | QPopupMenu *menuBar = new QPopupMenu( this ); |
465 | menuBar1->insertItem( i18n("ME"), menuBar); | 465 | menuBar1->insertItem( i18n("ME"), menuBar); |
466 | menuBar->insertItem( i18n("File"), importMenu ); | 466 | menuBar->insertItem( i18n("File"), importMenu ); |
467 | menuBar->insertItem( i18n("View"), viewMenu ); | 467 | menuBar->insertItem( i18n("View"), viewMenu ); |
468 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 468 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
469 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 469 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
470 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 470 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
471 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 471 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
472 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 472 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
473 | menuBar->insertItem( i18n("Help"), helpMenu ); | 473 | menuBar->insertItem( i18n("Help"), helpMenu ); |
474 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 474 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
475 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 475 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
476 | } | 476 | } |
477 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 477 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); |
478 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 478 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
479 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); | 479 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); |
480 | 480 | ||
481 | // ****************** | 481 | // ****************** |
482 | QAction *action; | 482 | QAction *action; |
483 | QIconSet icon; | 483 | QIconSet icon; |
484 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 484 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
485 | configureToolBarMenu->setCheckable( true ); | 485 | configureToolBarMenu->setCheckable( true ); |
486 | 486 | ||
487 | QString pathString = ""; | 487 | QString pathString = ""; |
488 | if ( !p->mToolBarMiniIcons ) { | 488 | if ( !p->mToolBarMiniIcons ) { |
489 | if ( QApplication::desktop()->width() < 480 ) | 489 | if ( QApplication::desktop()->width() < 480 ) |
490 | pathString += "icons16/"; | 490 | pathString += "icons16/"; |
491 | } else | 491 | } else |
492 | pathString += "iconsmini/"; | 492 | pathString += "iconsmini/"; |
493 | configureAgendaMenu->setCheckable( true ); | 493 | configureAgendaMenu->setCheckable( true ); |
494 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); | 494 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); |
495 | configureAgendaMenu->insertSeparator(); | 495 | configureAgendaMenu->insertSeparator(); |
496 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); | 496 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); |
497 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); | 497 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); |
498 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); | 498 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); |
499 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); | 499 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); |
500 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); | 500 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); |
501 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); | 501 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); |
502 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); | 502 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); |
503 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); | 503 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); |
504 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 504 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
505 | 505 | ||
506 | icon = loadPixmap( pathString + "configure" ); | 506 | icon = loadPixmap( pathString + "configure" ); |
507 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 507 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
508 | action->addTo( actionMenu ); | 508 | action->addTo( actionMenu ); |
509 | connect( action, SIGNAL( activated() ), | 509 | connect( action, SIGNAL( activated() ), |
510 | mView, SLOT( edit_options() ) ); | 510 | mView, SLOT( edit_options() ) ); |
511 | actionMenu->insertSeparator(); | 511 | actionMenu->insertSeparator(); |
512 | icon = loadPixmap( pathString + "newevent" ); | 512 | icon = loadPixmap( pathString + "newevent" ); |
513 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 513 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
514 | configureToolBarMenu->insertSeparator(); | 514 | configureToolBarMenu->insertSeparator(); |
515 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 515 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
516 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 516 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
517 | ne_action->addTo( actionMenu ); | 517 | ne_action->addTo( actionMenu ); |
518 | connect( ne_action, SIGNAL( activated() ), | 518 | connect( ne_action, SIGNAL( activated() ), |
519 | mView, SLOT( newEvent() ) ); | 519 | mView, SLOT( newEvent() ) ); |
520 | icon = loadPixmap( pathString + "newtodo" ); | 520 | icon = loadPixmap( pathString + "newtodo" ); |
521 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 521 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
522 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 522 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
523 | nt_action->addTo( actionMenu ); | 523 | nt_action->addTo( actionMenu ); |
524 | connect( nt_action, SIGNAL( activated() ), | 524 | connect( nt_action, SIGNAL( activated() ), |
525 | mView, SLOT( newTodo() ) ); | 525 | mView, SLOT( newTodo() ) ); |
526 | icon = loadPixmap( pathString + "navi" ); | 526 | icon = loadPixmap( pathString + "navi" ); |
527 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 527 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
528 | action->addTo( viewMenu ); | 528 | action->addTo( viewMenu ); |
529 | connect( action, SIGNAL( activated() ), | 529 | connect( action, SIGNAL( activated() ), |
530 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 530 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
531 | icon = loadPixmap( pathString + "filter" ); | 531 | icon = loadPixmap( pathString + "filter" ); |
532 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 532 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
533 | action->addTo( viewMenu ); | 533 | action->addTo( viewMenu ); |
534 | connect( action, SIGNAL( activated() ), | 534 | connect( action, SIGNAL( activated() ), |
535 | mView, SLOT( toggleFilter() ) ); | 535 | mView, SLOT( toggleFilter() ) ); |
536 | 536 | ||
537 | 537 | ||
538 | viewMenu->insertSeparator(); | 538 | viewMenu->insertSeparator(); |
539 | icon = loadPixmap( pathString + "picker" ); | 539 | icon = loadPixmap( pathString + "picker" ); |
540 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 540 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
541 | action->addTo( viewMenu ); | 541 | action->addTo( viewMenu ); |
542 | connect( action, SIGNAL( activated() ), | 542 | connect( action, SIGNAL( activated() ), |
543 | mView, SLOT( showDatePicker() ) ); | 543 | mView, SLOT( showDatePicker() ) ); |
544 | action->addTo( iconToolBar ); | 544 | action->addTo( iconToolBar ); |
545 | viewMenu->insertSeparator(); | 545 | viewMenu->insertSeparator(); |
546 | icon = loadPixmap( pathString + "list" ); | 546 | icon = loadPixmap( pathString + "list" ); |
547 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 547 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
548 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 548 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
549 | showlist_action->addTo( viewMenu ); | 549 | showlist_action->addTo( viewMenu ); |
550 | connect( showlist_action, SIGNAL( activated() ), | 550 | connect( showlist_action, SIGNAL( activated() ), |
551 | mView->viewManager(), SLOT( showListView() ) ); | 551 | mView->viewManager(), SLOT( showListView() ) ); |
552 | 552 | ||
553 | 553 | ||
554 | icon = loadPixmap( pathString + "day" ); | 554 | icon = loadPixmap( pathString + "day" ); |
555 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 555 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
556 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 556 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
557 | day1_action->addTo( viewMenu ); | 557 | day1_action->addTo( viewMenu ); |
558 | // action->addTo( toolBar ); | 558 | // action->addTo( toolBar ); |
559 | connect( day1_action, SIGNAL( activated() ), | 559 | connect( day1_action, SIGNAL( activated() ), |
560 | mView->viewManager(), SLOT( showDayView() ) ); | 560 | mView->viewManager(), SLOT( showDayView() ) ); |
561 | 561 | ||
562 | icon = loadPixmap( pathString + "workweek" ); | 562 | icon = loadPixmap( pathString + "workweek" ); |
563 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 563 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
564 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 564 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
565 | day5_action->addTo( viewMenu ); | 565 | day5_action->addTo( viewMenu ); |
566 | connect( day5_action, SIGNAL( activated() ), | 566 | connect( day5_action, SIGNAL( activated() ), |
567 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 567 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
568 | 568 | ||
569 | icon = loadPixmap( pathString + "week" ); | 569 | icon = loadPixmap( pathString + "week" ); |
570 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 570 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
571 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 571 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
572 | day7_action->addTo( viewMenu ); | 572 | day7_action->addTo( viewMenu ); |
573 | connect( day7_action, SIGNAL( activated() ), | 573 | connect( day7_action, SIGNAL( activated() ), |
574 | mView->viewManager(), SLOT( showWeekView() ) ); | 574 | mView->viewManager(), SLOT( showWeekView() ) ); |
575 | 575 | ||
576 | icon = loadPixmap( pathString + "month" ); | 576 | icon = loadPixmap( pathString + "month" ); |
577 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 577 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
578 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 578 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
579 | month_action->addTo( viewMenu ); | 579 | month_action->addTo( viewMenu ); |
580 | connect( month_action, SIGNAL( activated() ), | 580 | connect( month_action, SIGNAL( activated() ), |
581 | mView->viewManager(), SLOT( showMonthView() ) ); | 581 | mView->viewManager(), SLOT( showMonthView() ) ); |
582 | 582 | ||
583 | icon = loadPixmap( pathString + "todo" ); | 583 | icon = loadPixmap( pathString + "todo" ); |
584 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 584 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
585 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 585 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
586 | todoview_action->addTo( viewMenu ); | 586 | todoview_action->addTo( viewMenu ); |
587 | connect( todoview_action, SIGNAL( activated() ), | 587 | connect( todoview_action, SIGNAL( activated() ), |
588 | mView->viewManager(), SLOT( showTodoView() ) ); | 588 | mView->viewManager(), SLOT( showTodoView() ) ); |
589 | 589 | ||
590 | icon = loadPixmap( pathString + "journal" ); | 590 | icon = loadPixmap( pathString + "journal" ); |
591 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 591 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
592 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 592 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
593 | viewjournal_action->addTo( viewMenu ); | 593 | viewjournal_action->addTo( viewMenu ); |
594 | connect( viewjournal_action, SIGNAL( activated() ), | 594 | connect( viewjournal_action, SIGNAL( activated() ), |
595 | mView->viewManager(), SLOT( showJournalView() ) ); | 595 | mView->viewManager(), SLOT( showJournalView() ) ); |
596 | 596 | ||
597 | icon = loadPixmap( pathString + "xdays" ); | 597 | icon = loadPixmap( pathString + "xdays" ); |
598 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | 598 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); |
599 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 599 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
600 | xdays_action->addTo( viewMenu ); | 600 | xdays_action->addTo( viewMenu ); |
601 | connect( xdays_action, SIGNAL( activated() ), | 601 | connect( xdays_action, SIGNAL( activated() ), |
602 | mView->viewManager(), SLOT( showNextXView() ) ); | 602 | mView->viewManager(), SLOT( showNextXView() ) ); |
603 | 603 | ||
604 | icon = loadPixmap( pathString + "whatsnext" ); | 604 | icon = loadPixmap( pathString + "whatsnext" ); |
605 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | 605 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); |
606 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 606 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
607 | whatsnext_action->addTo( viewMenu ); | 607 | whatsnext_action->addTo( viewMenu ); |
608 | connect( whatsnext_action, SIGNAL( activated() ), | 608 | connect( whatsnext_action, SIGNAL( activated() ), |
609 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 609 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
610 | 610 | ||
611 | #if 0 | 611 | #if 0 |
612 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 612 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
613 | action->addTo( viewMenu ); | 613 | action->addTo( viewMenu ); |
614 | connect( action, SIGNAL( activated() ), | 614 | connect( action, SIGNAL( activated() ), |
615 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 615 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
616 | #endif | 616 | #endif |
617 | 617 | ||
618 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 618 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
619 | this ); | 619 | this ); |
620 | mNewSubTodoAction->addTo( actionMenu ); | 620 | mNewSubTodoAction->addTo( actionMenu ); |
621 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 621 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
622 | mView, SLOT( newSubTodo() ) ); | 622 | mView, SLOT( newSubTodo() ) ); |
623 | 623 | ||
624 | actionMenu->insertSeparator(); | 624 | actionMenu->insertSeparator(); |
625 | 625 | ||
626 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 626 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
627 | mShowAction->addTo( actionMenu ); | 627 | mShowAction->addTo( actionMenu ); |
628 | connect( mShowAction, SIGNAL( activated() ), | 628 | connect( mShowAction, SIGNAL( activated() ), |
629 | mView, SLOT( showIncidence() ) ); | 629 | mView, SLOT( showIncidence() ) ); |
630 | 630 | ||
631 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 631 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
632 | mEditAction->addTo( actionMenu ); | 632 | mEditAction->addTo( actionMenu ); |
633 | connect( mEditAction, SIGNAL( activated() ), | 633 | connect( mEditAction, SIGNAL( activated() ), |
634 | mView, SLOT( editIncidence() ) ); | 634 | mView, SLOT( editIncidence() ) ); |
635 | 635 | ||
636 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 636 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
637 | mDeleteAction->addTo( actionMenu ); | 637 | mDeleteAction->addTo( actionMenu ); |
638 | connect( mDeleteAction, SIGNAL( activated() ), | 638 | connect( mDeleteAction, SIGNAL( activated() ), |
639 | mView, SLOT( deleteIncidence() ) ); | 639 | mView, SLOT( deleteIncidence() ) ); |
640 | 640 | ||
641 | 641 | ||
642 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | 642 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); |
643 | mCloneAction->addTo( actionMenu ); | 643 | mCloneAction->addTo( actionMenu ); |
644 | connect( mCloneAction, SIGNAL( activated() ), | 644 | connect( mCloneAction, SIGNAL( activated() ), |
645 | mView, SLOT( cloneIncidence() ) ); | 645 | mView, SLOT( cloneIncidence() ) ); |
646 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | 646 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); |
647 | mMoveAction->addTo( actionMenu ); | 647 | mMoveAction->addTo( actionMenu ); |
648 | connect( mMoveAction, SIGNAL( activated() ), | 648 | connect( mMoveAction, SIGNAL( activated() ), |
649 | mView, SLOT( moveIncidence() ) ); | 649 | mView, SLOT( moveIncidence() ) ); |
650 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | 650 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); |
651 | mBeamAction->addTo( actionMenu ); | 651 | mBeamAction->addTo( actionMenu ); |
652 | connect( mBeamAction, SIGNAL( activated() ), | 652 | connect( mBeamAction, SIGNAL( activated() ), |
653 | mView, SLOT( beamIncidence() ) ); | 653 | mView, SLOT( beamIncidence() ) ); |
654 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | 654 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); |
655 | mCancelAction->addTo( actionMenu ); | 655 | mCancelAction->addTo( actionMenu ); |
656 | connect( mCancelAction, SIGNAL( activated() ), | 656 | connect( mCancelAction, SIGNAL( activated() ), |
657 | mView, SLOT( toggleCancelIncidence() ) ); | 657 | mView, SLOT( toggleCancelIncidence() ) ); |
658 | 658 | ||
659 | actionMenu->insertSeparator(); | 659 | actionMenu->insertSeparator(); |
660 | 660 | ||
661 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 661 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
662 | this ); | 662 | this ); |
663 | action->addTo( actionMenu ); | 663 | action->addTo( actionMenu ); |
664 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 664 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
665 | 665 | ||
666 | icon = loadPixmap( pathString + "search" ); | 666 | icon = loadPixmap( pathString + "search" ); |
667 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 667 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
668 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | 668 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); |
669 | search_action->addTo( actionMenu ); | 669 | search_action->addTo( actionMenu ); |
670 | connect( search_action, SIGNAL( activated() ), | 670 | connect( search_action, SIGNAL( activated() ), |
671 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 671 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
672 | 672 | ||
673 | icon = loadPixmap( pathString + "today" ); | 673 | icon = loadPixmap( pathString + "today" ); |
674 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 674 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
675 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 675 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
676 | today_action->addTo( actionMenu ); | 676 | today_action->addTo( actionMenu ); |
677 | connect( today_action, SIGNAL( activated() ), | 677 | connect( today_action, SIGNAL( activated() ), |
678 | mView, SLOT( goToday() ) ); | 678 | mView, SLOT( goToday() ) ); |
679 | 679 | ||
680 | if ( KOPrefs::instance()->mShowFullMenu ) { | 680 | if ( KOPrefs::instance()->mShowFullMenu ) { |
681 | actionMenu->insertSeparator(); | 681 | actionMenu->insertSeparator(); |
682 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 682 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
683 | 683 | ||
684 | } | 684 | } |
685 | // actionMenu->insertSeparator(); | 685 | // actionMenu->insertSeparator(); |
686 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 686 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
687 | this ); | 687 | this ); |
688 | action->addTo( importMenu ); | 688 | action->addTo( importMenu ); |
689 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 689 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
690 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 690 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
691 | this ); | 691 | this ); |
692 | action->addTo( importMenu ); | 692 | action->addTo( importMenu ); |
693 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 693 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
694 | importMenu->insertSeparator(); | 694 | importMenu->insertSeparator(); |
695 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 695 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
696 | this ); | 696 | this ); |
697 | action->addTo( importMenu ); | 697 | action->addTo( importMenu ); |
698 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 698 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
699 | #ifndef DESKTOP_VERSION | 699 | #ifndef DESKTOP_VERSION |
700 | importMenu->insertSeparator(); | 700 | importMenu->insertSeparator(); |
701 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 701 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
702 | this ); | 702 | this ); |
703 | action->addTo( importMenu ); | 703 | action->addTo( importMenu ); |
704 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 704 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
705 | #else | 705 | #else |
706 | #ifdef _WIN32_ | 706 | #ifdef _WIN32_ |
707 | importMenu->insertSeparator(); | 707 | importMenu->insertSeparator(); |
708 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 708 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
709 | this ); | 709 | this ); |
710 | action->addTo( importMenu ); | 710 | action->addTo( importMenu ); |
711 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 711 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
712 | #endif | 712 | #endif |
713 | #endif | 713 | #endif |
714 | 714 | ||
715 | importMenu->insertSeparator(); | 715 | importMenu->insertSeparator(); |
716 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 716 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
717 | this ); | 717 | this ); |
718 | action->addTo( importMenu ); | 718 | action->addTo( importMenu ); |
719 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 719 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
720 | 720 | ||
721 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 721 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
722 | this ); | 722 | this ); |
723 | action->addTo( importMenu ); | 723 | action->addTo( importMenu ); |
724 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 724 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
725 | 725 | ||
726 | importMenu->insertSeparator(); | 726 | importMenu->insertSeparator(); |
727 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 727 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
728 | this ); | 728 | this ); |
729 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 729 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
730 | 730 | ||
731 | 731 | ||
732 | //LR | 732 | //LR |
733 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 733 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
734 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 734 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
735 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 735 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
736 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 736 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
737 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); | 737 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); |
738 | 738 | ||
739 | importMenu->insertSeparator(); | 739 | importMenu->insertSeparator(); |
740 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 740 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
741 | this ); | 741 | this ); |
742 | action->addTo( importMenu ); | 742 | action->addTo( importMenu ); |
743 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 743 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
744 | #ifndef DESKTOP_VERSION | 744 | #ifndef DESKTOP_VERSION |
745 | importMenu->insertSeparator(); | 745 | importMenu->insertSeparator(); |
746 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 746 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
747 | this ); | 747 | this ); |
748 | action->addTo( importMenu ); | 748 | action->addTo( importMenu ); |
749 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 749 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
750 | 750 | ||
751 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 751 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
752 | this ); | 752 | this ); |
753 | action->addTo( importMenu ); | 753 | action->addTo( importMenu ); |
754 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 754 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
755 | #else | 755 | #else |
756 | importMenu->insertSeparator(); | 756 | importMenu->insertSeparator(); |
757 | icon = loadPixmap( pathString + "print" ); | 757 | icon = loadPixmap( pathString + "print" ); |
758 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 758 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
759 | action->addTo( importMenu ); | 759 | action->addTo( importMenu ); |
760 | connect( action, SIGNAL( activated() ), | 760 | connect( action, SIGNAL( activated() ), |
761 | this, SLOT( printCal() ) ); | 761 | this, SLOT( printCal() ) ); |
762 | 762 | ||
763 | icon = loadPixmap( pathString + "print" ); | 763 | icon = loadPixmap( pathString + "print" ); |
764 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 764 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
765 | action->addTo( importMenu ); | 765 | action->addTo( importMenu ); |
766 | connect( action, SIGNAL( activated() ), | 766 | connect( action, SIGNAL( activated() ), |
767 | this, SLOT( printSel() ) ); | 767 | this, SLOT( printSel() ) ); |
768 | #endif | 768 | #endif |
769 | importMenu->insertSeparator(); | 769 | importMenu->insertSeparator(); |
770 | action = new QAction( "beam all", i18n("Save"), 0, | 770 | action = new QAction( "beam all", i18n("Save"), 0, |
771 | this ); | 771 | this ); |
772 | action->addTo( importMenu ); | 772 | action->addTo( importMenu ); |
773 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 773 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
774 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 774 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
775 | this ); | 775 | this ); |
776 | action->addTo( importMenu ); | 776 | action->addTo( importMenu ); |
777 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 777 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
778 | 778 | ||
779 | //menuBar->insertItem( "Configure",configureMenu ); | 779 | //menuBar->insertItem( "Configure",configureMenu ); |
780 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 780 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
781 | icon = loadPixmap( "korganizer/korganizer" ); | 781 | icon = loadPixmap( "korganizer/korganizer" ); |
782 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 782 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
783 | action->addTo( helpMenu ); | 783 | action->addTo( helpMenu ); |
784 | connect( action, SIGNAL( activated() ), | 784 | connect( action, SIGNAL( activated() ), |
785 | SLOT( keyBindings() ) ); | 785 | SLOT( keyBindings() ) ); |
786 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 786 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
787 | action->addTo( helpMenu ); | 787 | action->addTo( helpMenu ); |
788 | connect( action, SIGNAL( activated() ), | 788 | connect( action, SIGNAL( activated() ), |
789 | SLOT( features() ) ); | 789 | SLOT( features() ) ); |
790 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 790 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
791 | action->addTo( helpMenu ); | 791 | action->addTo( helpMenu ); |
792 | connect( action, SIGNAL( activated() ), | 792 | connect( action, SIGNAL( activated() ), |
793 | SLOT( aboutAutoSaving() ) ); | 793 | SLOT( aboutAutoSaving() ) ); |
794 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 794 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
795 | action->addTo( helpMenu ); | 795 | action->addTo( helpMenu ); |
796 | connect( action, SIGNAL( activated() ), | 796 | connect( action, SIGNAL( activated() ), |
797 | SLOT( aboutKnownBugs() ) ); | 797 | SLOT( aboutKnownBugs() ) ); |
798 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 798 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
799 | action->addTo( helpMenu ); | 799 | action->addTo( helpMenu ); |
800 | connect( action, SIGNAL( activated() ), | 800 | connect( action, SIGNAL( activated() ), |
801 | SLOT( usertrans() ) ); | 801 | SLOT( usertrans() ) ); |
802 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 802 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
803 | action->addTo( helpMenu ); | 803 | action->addTo( helpMenu ); |
804 | connect( action, SIGNAL( activated() ), | 804 | connect( action, SIGNAL( activated() ), |
805 | SLOT( synchowto() ) ); | 805 | SLOT( synchowto() ) ); |
806 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 806 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
807 | action->addTo( helpMenu ); | 807 | action->addTo( helpMenu ); |
808 | connect( action, SIGNAL( activated() ), | 808 | connect( action, SIGNAL( activated() ), |
809 | SLOT( whatsNew() ) ); | 809 | SLOT( whatsNew() ) ); |
810 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 810 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
811 | action->addTo( helpMenu ); | 811 | action->addTo( helpMenu ); |
812 | connect( action, SIGNAL( activated() ), | 812 | connect( action, SIGNAL( activated() ), |
813 | SLOT( faq() ) ); | 813 | SLOT( faq() ) ); |
814 | 814 | ||
815 | 815 | ||
816 | action = new QAction( "about", i18n("About..."), 0, this ); | 816 | action = new QAction( "about", i18n("About..."), 0, this ); |
817 | action->addTo( helpMenu ); | 817 | action->addTo( helpMenu ); |
818 | connect( action, SIGNAL( activated() ), | 818 | connect( action, SIGNAL( activated() ), |
819 | SLOT( about() ) ); | 819 | SLOT( about() ) ); |
820 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 820 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
821 | action->addTo( helpMenu ); | 821 | action->addTo( helpMenu ); |
822 | connect( action, SIGNAL( activated() ), | 822 | connect( action, SIGNAL( activated() ), |
823 | SLOT( licence() ) ); | 823 | SLOT( licence() ) ); |
824 | //menuBar->insertSeparator(); | 824 | //menuBar->insertSeparator(); |
825 | 825 | ||
826 | // ****************************************************** | 826 | // ****************************************************** |
827 | // menubar icons | 827 | // menubar icons |
828 | 828 | ||
829 | 829 | ||
830 | iconToolBar->setHorizontalStretchable (true ); | 830 | iconToolBar->setHorizontalStretchable (true ); |
831 | //menuBar->insertItem( iconToolBar ); | 831 | //menuBar->insertItem( iconToolBar ); |
832 | //xdays_action | 832 | //xdays_action |
833 | if (p-> mShowIconNewEvent) | 833 | if (p-> mShowIconNewEvent) |
834 | ne_action->addTo( iconToolBar ); | 834 | ne_action->addTo( iconToolBar ); |
835 | if (p->mShowIconNewTodo ) | 835 | if (p->mShowIconNewTodo ) |
836 | nt_action->addTo( iconToolBar ); | 836 | nt_action->addTo( iconToolBar ); |
837 | if (p-> mShowIconSearch) | 837 | if (p-> mShowIconSearch) |
838 | search_action->addTo( iconToolBar ); | 838 | search_action->addTo( iconToolBar ); |
839 | if (p-> mShowIconNext) | 839 | if (p-> mShowIconNext) |
840 | whatsnext_action->addTo( iconToolBar ); | 840 | whatsnext_action->addTo( iconToolBar ); |
841 | if (p-> mShowIconNextDays) | 841 | if (p-> mShowIconNextDays) |
842 | xdays_action->addTo( iconToolBar ); | 842 | xdays_action->addTo( iconToolBar ); |
843 | if (p-> mShowIconList) | 843 | if (p-> mShowIconList) |
844 | showlist_action->addTo( iconToolBar ); | 844 | showlist_action->addTo( iconToolBar ); |
845 | if (p-> mShowIconDay1) | 845 | if (p-> mShowIconDay1) |
846 | day1_action->addTo( iconToolBar ); | 846 | day1_action->addTo( iconToolBar ); |
847 | if (p-> mShowIconDay5) | 847 | if (p-> mShowIconDay5) |
848 | day5_action->addTo( iconToolBar ); | 848 | day5_action->addTo( iconToolBar ); |
849 | if (p-> mShowIconDay7) | 849 | if (p-> mShowIconDay7) |
850 | day7_action->addTo( iconToolBar ); | 850 | day7_action->addTo( iconToolBar ); |
851 | if (p-> mShowIconMonth) | 851 | if (p-> mShowIconMonth) |
852 | month_action->addTo( iconToolBar ); | 852 | month_action->addTo( iconToolBar ); |
853 | if (p-> mShowIconTodoview) | 853 | if (p-> mShowIconTodoview) |
854 | todoview_action->addTo( iconToolBar ); | 854 | todoview_action->addTo( iconToolBar ); |
855 | if (p-> mShowIconJournal) | 855 | if (p-> mShowIconJournal) |
856 | viewjournal_action->addTo( iconToolBar ); | 856 | viewjournal_action->addTo( iconToolBar ); |
857 | icon = loadPixmap( pathString + "2leftarrowB" ); | 857 | icon = loadPixmap( pathString + "2leftarrowB" ); |
858 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 858 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
859 | if (p-> mShowIconBackFast) { | 859 | if (p-> mShowIconBackFast) { |
860 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 860 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
861 | connect( action, SIGNAL( activated() ), | 861 | connect( action, SIGNAL( activated() ), |
862 | mView, SLOT( goPreviousMonth() ) ); | 862 | mView, SLOT( goPreviousMonth() ) ); |
863 | action->addTo( iconToolBar ); | 863 | action->addTo( iconToolBar ); |
864 | } | 864 | } |
865 | icon = loadPixmap( pathString + "1leftarrowB" ); | 865 | icon = loadPixmap( pathString + "1leftarrowB" ); |
866 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 866 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
867 | if (p-> mShowIconBack) { | 867 | if (p-> mShowIconBack) { |
868 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 868 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
869 | connect( action, SIGNAL( activated() ), | 869 | connect( action, SIGNAL( activated() ), |
870 | mView, SLOT( goPrevious() ) ); | 870 | mView, SLOT( goPrevious() ) ); |
871 | action->addTo( iconToolBar ); | 871 | action->addTo( iconToolBar ); |
872 | } | 872 | } |
873 | if (p-> mShowIconToday) | 873 | if (p-> mShowIconToday) |
874 | today_action->addTo( iconToolBar ); | 874 | today_action->addTo( iconToolBar ); |
875 | icon = loadPixmap( pathString + "1rightarrowB" ); | 875 | icon = loadPixmap( pathString + "1rightarrowB" ); |
876 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 876 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
877 | if (p-> mShowIconForward) { | 877 | if (p-> mShowIconForward) { |
878 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 878 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
879 | connect( action, SIGNAL( activated() ), | 879 | connect( action, SIGNAL( activated() ), |
880 | mView, SLOT( goNext() ) ); | 880 | mView, SLOT( goNext() ) ); |
881 | action->addTo( iconToolBar ); | 881 | action->addTo( iconToolBar ); |
882 | } | 882 | } |
883 | icon = loadPixmap( pathString + "2rightarrowB" ); | 883 | icon = loadPixmap( pathString + "2rightarrowB" ); |
884 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 884 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
885 | if (p-> mShowIconForwardFast) { | 885 | if (p-> mShowIconForwardFast) { |
886 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 886 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
887 | connect( action, SIGNAL( activated() ), | 887 | connect( action, SIGNAL( activated() ), |
888 | mView, SLOT( goNextMonth() ) ); | 888 | mView, SLOT( goNextMonth() ) ); |
889 | action->addTo( iconToolBar ); | 889 | action->addTo( iconToolBar ); |
890 | } | 890 | } |
891 | 891 | ||
892 | 892 | ||
893 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 893 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
894 | 894 | ||
895 | if (p-> mShowIconNewEvent) | 895 | if (p-> mShowIconNewEvent) |
896 | configureToolBarMenu->setItemChecked( 10, true ); | 896 | configureToolBarMenu->setItemChecked( 10, true ); |
897 | if (p->mShowIconNewTodo ) | 897 | if (p->mShowIconNewTodo ) |
898 | configureToolBarMenu->setItemChecked( 20, true ); | 898 | configureToolBarMenu->setItemChecked( 20, true ); |
899 | if (p-> mShowIconSearch) | 899 | if (p-> mShowIconSearch) |
900 | configureToolBarMenu->setItemChecked( 120, true ); | 900 | configureToolBarMenu->setItemChecked( 120, true ); |
901 | if (p-> mShowIconList) | 901 | if (p-> mShowIconList) |
902 | configureToolBarMenu->setItemChecked( 30, true ); | 902 | configureToolBarMenu->setItemChecked( 30, true ); |
903 | if (p-> mShowIconDay1) | 903 | if (p-> mShowIconDay1) |
904 | configureToolBarMenu->setItemChecked( 40, true ); | 904 | configureToolBarMenu->setItemChecked( 40, true ); |
905 | if (p-> mShowIconDay5) | 905 | if (p-> mShowIconDay5) |
906 | configureToolBarMenu->setItemChecked( 50, true ); | 906 | configureToolBarMenu->setItemChecked( 50, true ); |
907 | if (p-> mShowIconDay7) | 907 | if (p-> mShowIconDay7) |
908 | configureToolBarMenu->setItemChecked( 60, true ); | 908 | configureToolBarMenu->setItemChecked( 60, true ); |
909 | if (p-> mShowIconMonth) | 909 | if (p-> mShowIconMonth) |
910 | configureToolBarMenu->setItemChecked( 70, true ); | 910 | configureToolBarMenu->setItemChecked( 70, true ); |
911 | if (p-> mShowIconTodoview) | 911 | if (p-> mShowIconTodoview) |
912 | configureToolBarMenu->setItemChecked( 80, true ); | 912 | configureToolBarMenu->setItemChecked( 80, true ); |
913 | if (p-> mShowIconBackFast) | 913 | if (p-> mShowIconBackFast) |
914 | configureToolBarMenu->setItemChecked( 200, true ); | 914 | configureToolBarMenu->setItemChecked( 200, true ); |
915 | if (p-> mShowIconBack) | 915 | if (p-> mShowIconBack) |
916 | configureToolBarMenu->setItemChecked( 210, true ); | 916 | configureToolBarMenu->setItemChecked( 210, true ); |
917 | if (p-> mShowIconToday) | 917 | if (p-> mShowIconToday) |
918 | configureToolBarMenu->setItemChecked( 130, true ); | 918 | configureToolBarMenu->setItemChecked( 130, true ); |
919 | if (p-> mShowIconForward) | 919 | if (p-> mShowIconForward) |
920 | configureToolBarMenu->setItemChecked( 220, true ); | 920 | configureToolBarMenu->setItemChecked( 220, true ); |
921 | if (p-> mShowIconForwardFast) | 921 | if (p-> mShowIconForwardFast) |
922 | configureToolBarMenu->setItemChecked( 230, true ); | 922 | configureToolBarMenu->setItemChecked( 230, true ); |
923 | if (p-> mShowIconNextDays) | 923 | if (p-> mShowIconNextDays) |
924 | configureToolBarMenu->setItemChecked( 100, true ); | 924 | configureToolBarMenu->setItemChecked( 100, true ); |
925 | if (p-> mShowIconNext) | 925 | if (p-> mShowIconNext) |
926 | configureToolBarMenu->setItemChecked( 110, true ); | 926 | configureToolBarMenu->setItemChecked( 110, true ); |
927 | if (p-> mShowIconJournal) | 927 | if (p-> mShowIconJournal) |
928 | configureToolBarMenu->setItemChecked( 90, true ); | 928 | configureToolBarMenu->setItemChecked( 90, true ); |
929 | if (p-> mShowIconWhatsThis) | 929 | if (p-> mShowIconWhatsThis) |
930 | configureToolBarMenu->setItemChecked( 300, true ); | 930 | configureToolBarMenu->setItemChecked( 300, true ); |
931 | 931 | ||
932 | QLabel* dummy = new QLabel( iconToolBar ); | 932 | QLabel* dummy = new QLabel( iconToolBar ); |
933 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 933 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
934 | if (!p-> mShowIconStretch) | 934 | if (!p-> mShowIconStretch) |
935 | iconToolBar->setStretchableWidget ( dummy ) ; | 935 | iconToolBar->setStretchableWidget ( dummy ) ; |
936 | else | 936 | else |
937 | configureToolBarMenu->setItemChecked( 5, true ); | 937 | configureToolBarMenu->setItemChecked( 5, true ); |
938 | if (p-> mShowIconWhatsThis) | 938 | if (p-> mShowIconWhatsThis) |
939 | QWhatsThis::whatsThisButton ( iconToolBar ); | 939 | QWhatsThis::whatsThisButton ( iconToolBar ); |
940 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 940 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
941 | configureAgenda( p->mHourSize ); | 941 | configureAgenda( p->mHourSize ); |
942 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 942 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
943 | } | 943 | } |
944 | void MainWindow::fillSyncMenu() | 944 | void MainWindow::fillSyncMenu() |
945 | { | 945 | { |
946 | if ( syncMenu->count() ) | 946 | if ( syncMenu->count() ) |
947 | syncMenu->clear(); | 947 | syncMenu->clear(); |
948 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 948 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
949 | syncMenu->insertSeparator(); | 949 | syncMenu->insertSeparator(); |
950 | if ( mServerSocket == 0 ) { | 950 | if ( mServerSocket == 0 ) { |
951 | syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 951 | syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
952 | } else { | 952 | } else { |
953 | syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 953 | syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
954 | } | 954 | } |
955 | syncMenu->insertSeparator(); | 955 | syncMenu->insertSeparator(); |
956 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 956 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
957 | syncMenu->insertSeparator(); | 957 | syncMenu->insertSeparator(); |
958 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 958 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
959 | config.setGroup("General"); | 959 | config.setGroup("General"); |
960 | QStringList prof = config.readListEntry("SyncProfileNames"); | 960 | QStringList prof = config.readListEntry("SyncProfileNames"); |
961 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 961 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
962 | if ( prof.count() < 3 ) { | 962 | if ( prof.count() < 3 ) { |
963 | prof.clear(); | 963 | prof.clear(); |
964 | prof << i18n("Sharp_DTM"); | 964 | prof << i18n("Sharp_DTM"); |
965 | prof << i18n("Local_file"); | 965 | prof << i18n("Local_file"); |
966 | prof << i18n("Last_file"); | 966 | prof << i18n("Last_file"); |
967 | KSyncProfile* temp = new KSyncProfile (); | 967 | KSyncProfile* temp = new KSyncProfile (); |
968 | temp->setName( prof[0] ); | 968 | temp->setName( prof[0] ); |
969 | temp->writeConfig(&config); | 969 | temp->writeConfig(&config); |
970 | temp->setName( prof[1] ); | 970 | temp->setName( prof[1] ); |
971 | temp->writeConfig(&config); | 971 | temp->writeConfig(&config); |
972 | temp->setName( prof[2] ); | 972 | temp->setName( prof[2] ); |
973 | temp->writeConfig(&config); | 973 | temp->writeConfig(&config); |
974 | config.setGroup("General"); | 974 | config.setGroup("General"); |
975 | config.writeEntry("SyncProfileNames",prof); | 975 | config.writeEntry("SyncProfileNames",prof); |
976 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 976 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
977 | config.sync(); | 977 | config.sync(); |
978 | delete temp; | 978 | delete temp; |
979 | } | 979 | } |
980 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 980 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
981 | KOPrefs::instance()->mSyncProfileNames = prof; | 981 | KOPrefs::instance()->mSyncProfileNames = prof; |
982 | int i; | 982 | int i; |
983 | for ( i = 0; i < prof.count(); ++i ) { | 983 | for ( i = 0; i < prof.count(); ++i ) { |
984 | 984 | ||
985 | syncMenu->insertItem( prof[i], 1000+i ); | 985 | syncMenu->insertItem( prof[i], 1000+i ); |
986 | if ( i == 2 ) | 986 | if ( i == 2 ) |
987 | syncMenu->insertSeparator(); | 987 | syncMenu->insertSeparator(); |
988 | } | 988 | } |
989 | QDir app_dir; | 989 | QDir app_dir; |
990 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 990 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
991 | syncMenu->setItemEnabled( false , 1000 ); | 991 | syncMenu->setItemEnabled( false , 1000 ); |
992 | } | 992 | } |
993 | mView->setupExternSyncProfiles(); | ||
994 | } | 993 | } |
995 | 994 | ||
996 | int MainWindow::ringSync() | 995 | int MainWindow::ringSync() |
997 | { | 996 | { |
998 | int syncedProfiles = 0; | 997 | int syncedProfiles = 0; |
999 | int i; | 998 | int i; |
1000 | QTime timer; | 999 | QTime timer; |
1001 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 1000 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
1002 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | 1001 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; |
1003 | KSyncProfile* temp = new KSyncProfile (); | 1002 | KSyncProfile* temp = new KSyncProfile (); |
1004 | KOPrefs::instance()->mAskForPreferences = false; | 1003 | KOPrefs::instance()->mAskForPreferences = false; |
1005 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 1004 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
1006 | mCurrentSyncProfile = i; | 1005 | mCurrentSyncProfile = i; |
1007 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 1006 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
1008 | temp->readConfig(&config); | 1007 | temp->readConfig(&config); |
1009 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | 1008 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { |
1010 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 1009 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
1011 | ++syncedProfiles; | 1010 | ++syncedProfiles; |
1012 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1011 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
1013 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1012 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1014 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1013 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1015 | KOPrefs::instance()->mWriteBackInFuture = 0; | 1014 | KOPrefs::instance()->mWriteBackInFuture = 0; |
1016 | if ( temp->getWriteBackFuture() ) | 1015 | if ( temp->getWriteBackFuture() ) |
1017 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 1016 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
1018 | KOPrefs::instance()->mShowSyncSummary = false; | 1017 | KOPrefs::instance()->mShowSyncSummary = false; |
1019 | mView->setSyncDevice(syncProfileNames[i] ); | 1018 | mView->setSyncDevice(syncProfileNames[i] ); |
1020 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 1019 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
1021 | if ( i == 0 ) { | 1020 | if ( i == 0 ) { |
1022 | syncSharp(); | 1021 | syncSharp(); |
1023 | } else { | 1022 | } else { |
1024 | if ( temp->getIsLocalFileSync() ) { | 1023 | if ( temp->getIsLocalFileSync() ) { |
1025 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | 1024 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) |
1026 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1025 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1027 | } else { | 1026 | } else { |
1028 | if ( temp->getIsPhoneSync() ) { | 1027 | if ( temp->getIsPhoneSync() ) { |
1029 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1028 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1030 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1029 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1031 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1030 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1032 | syncPhone(); | 1031 | syncPhone(); |
1033 | } else if ( temp->getIsPiSync() ) { | 1032 | } else if ( temp->getIsPiSync() ) { |
1034 | mPassWordPiSync = temp->getRemotePw(); | 1033 | mPassWordPiSync = temp->getRemotePw(); |
1035 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | 1034 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); |
1036 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | 1035 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); |
1037 | syncPi(); | 1036 | syncPi(); |
1038 | } else | 1037 | } else |
1039 | syncRemote( temp, false ); | 1038 | syncRemote( temp, false ); |
1040 | 1039 | ||
1041 | } | 1040 | } |
1042 | } | 1041 | } |
1043 | timer.start(); | 1042 | timer.start(); |
1044 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 1043 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
1045 | while ( timer.elapsed () < 2000 ) { | 1044 | while ( timer.elapsed () < 2000 ) { |
1046 | qApp->processEvents(); | 1045 | qApp->processEvents(); |
1047 | #ifndef _WIN32_ | 1046 | #ifndef _WIN32_ |
1048 | sleep (1); | 1047 | sleep (1); |
1049 | #endif | 1048 | #endif |
1050 | } | 1049 | } |
1051 | 1050 | ||
1052 | } | 1051 | } |
1053 | 1052 | ||
1054 | } | 1053 | } |
1055 | delete temp; | 1054 | delete temp; |
1056 | return syncedProfiles; | 1055 | return syncedProfiles; |
1057 | } | 1056 | } |
1058 | 1057 | ||
1059 | void MainWindow::multiSync( bool askforPrefs ) | 1058 | void MainWindow::multiSync( bool askforPrefs ) |
1060 | { | 1059 | { |
1061 | if (mBlockSaveFlag) | 1060 | if (mBlockSaveFlag) |
1062 | return; | 1061 | return; |
1063 | mBlockSaveFlag = true; | 1062 | mBlockSaveFlag = true; |
1064 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 1063 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
1065 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 1064 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
1066 | question, | 1065 | question, |
1067 | i18n("Yes"), i18n("No"), | 1066 | i18n("Yes"), i18n("No"), |
1068 | 0, 0 ) != 0 ) { | 1067 | 0, 0 ) != 0 ) { |
1069 | mBlockSaveFlag = false; | 1068 | mBlockSaveFlag = false; |
1070 | setCaption(i18n("Aborted! Nothing synced!")); | 1069 | setCaption(i18n("Aborted! Nothing synced!")); |
1071 | return; | 1070 | return; |
1072 | } | 1071 | } |
1073 | mView->setSyncDevice(i18n("Multiple profiles") ); | 1072 | mView->setSyncDevice(i18n("Multiple profiles") ); |
1074 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; | 1073 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; |
1075 | if ( askforPrefs ) { | 1074 | if ( askforPrefs ) { |
1076 | mView->edit_sync_options(); | 1075 | mView->edit_sync_options(); |
1077 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; | 1076 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; |
1078 | } | 1077 | } |
1079 | setCaption(i18n("Multiple sync started.") ); | 1078 | setCaption(i18n("Multiple sync started.") ); |
1080 | qApp->processEvents(); | 1079 | qApp->processEvents(); |
1081 | int num = ringSync() ; | 1080 | int num = ringSync() ; |
1082 | if ( num > 1 ) | 1081 | if ( num > 1 ) |
1083 | ringSync(); | 1082 | ringSync(); |
1084 | mBlockSaveFlag = false; | 1083 | mBlockSaveFlag = false; |
1085 | if ( num ) | 1084 | if ( num ) |
1086 | save(); | 1085 | save(); |
1087 | if ( num ) | 1086 | if ( num ) |
1088 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 1087 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
1089 | else | 1088 | else |
1090 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 1089 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
1091 | return; | 1090 | return; |
1092 | } | 1091 | } |
1093 | void MainWindow::slotSyncMenu( int action ) | 1092 | void MainWindow::slotSyncMenu( int action ) |
1094 | { | 1093 | { |
1095 | qDebug("syncaction %d ", action); | 1094 | qDebug("syncaction %d ", action); |
1096 | if ( action == 0 ) { | 1095 | if ( action == 0 ) { |
1097 | 1096 | ||
1098 | // seems to be a Qt2 event handling bug | 1097 | // seems to be a Qt2 event handling bug |
1099 | // syncmenu.clear causes a segfault at first time | 1098 | // syncmenu.clear causes a segfault at first time |
1100 | // when we call it after the main event loop, it is ok | 1099 | // when we call it after the main event loop, it is ok |
1101 | // same behaviour when calling OM/Pi via QCOP for the first time | 1100 | // same behaviour when calling OM/Pi via QCOP for the first time |
1102 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 1101 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
1103 | //confSync(); | 1102 | //confSync(); |
1104 | 1103 | ||
1105 | return; | 1104 | return; |
1106 | } | 1105 | } |
1107 | if ( action == 1 ) { | 1106 | if ( action == 1 ) { |
1108 | multiSync( true ); | 1107 | multiSync( true ); |
1109 | return; | 1108 | return; |
1110 | } | 1109 | } |
1111 | if ( action == 2 ) { | 1110 | if ( action == 2 ) { |
1112 | enableQuick(); | 1111 | enableQuick(); |
1113 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 1112 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
1114 | return; | 1113 | return; |
1115 | } | 1114 | } |
1116 | if ( action == 3 ) { | 1115 | if ( action == 3 ) { |
1117 | delete mServerSocket; | 1116 | delete mServerSocket; |
1118 | mServerSocket = 0; | 1117 | mServerSocket = 0; |
1119 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 1118 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
1120 | return; | 1119 | return; |
1121 | } | 1120 | } |
1122 | 1121 | ||
1123 | if (mBlockSaveFlag) | 1122 | if (mBlockSaveFlag) |
1124 | return; | 1123 | return; |
1125 | mBlockSaveFlag = true; | 1124 | mBlockSaveFlag = true; |
1126 | mCurrentSyncProfile = action - 1000 ; | 1125 | mCurrentSyncProfile = action - 1000 ; |
1127 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 1126 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
1128 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 1127 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
1129 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 1128 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
1130 | KSyncProfile* temp = new KSyncProfile (); | 1129 | KSyncProfile* temp = new KSyncProfile (); |
1131 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 1130 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
1132 | temp->readConfig(&config); | 1131 | temp->readConfig(&config); |
1133 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1132 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
1134 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 1133 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
1135 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1134 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1136 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1135 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1137 | KOPrefs::instance()->mWriteBackInFuture = 0; | 1136 | KOPrefs::instance()->mWriteBackInFuture = 0; |
1138 | if ( temp->getWriteBackFuture() ) | 1137 | if ( temp->getWriteBackFuture() ) |
1139 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 1138 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
1140 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 1139 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
1141 | if ( action == 1000 ) { | 1140 | if ( action == 1000 ) { |
1142 | syncSharp(); | 1141 | syncSharp(); |
1143 | 1142 | ||
1144 | } else if ( action == 1001 ) { | 1143 | } else if ( action == 1001 ) { |
1145 | syncLocalFile(); | 1144 | syncLocalFile(); |
1146 | 1145 | ||
1147 | } else if ( action == 1002 ) { | 1146 | } else if ( action == 1002 ) { |
1148 | quickSyncLocalFile(); | 1147 | quickSyncLocalFile(); |
1149 | 1148 | ||
1150 | } else if ( action >= 1003 ) { | 1149 | } else if ( action >= 1003 ) { |
1151 | if ( temp->getIsLocalFileSync() ) { | 1150 | if ( temp->getIsLocalFileSync() ) { |
1152 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 1151 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
1153 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1152 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1154 | } else { | 1153 | } else { |
1155 | if ( temp->getIsPhoneSync() ) { | 1154 | if ( temp->getIsPhoneSync() ) { |
1156 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1155 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1157 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1156 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1158 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1157 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1159 | syncPhone(); | 1158 | syncPhone(); |
1160 | } else if ( temp->getIsPiSync() ) { | 1159 | } else if ( temp->getIsPiSync() ) { |
1161 | mPassWordPiSync = temp->getRemotePw(); | 1160 | mPassWordPiSync = temp->getRemotePw(); |
1162 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | 1161 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); |
1163 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | 1162 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); |
1164 | syncPi(); | 1163 | syncPi(); |
1165 | } else | 1164 | } else |
1166 | syncRemote( temp ); | 1165 | syncRemote( temp ); |
1167 | 1166 | ||
1168 | } | 1167 | } |
1169 | } | 1168 | } |
1170 | delete temp; | 1169 | delete temp; |
1171 | mBlockSaveFlag = false; | 1170 | mBlockSaveFlag = false; |
1172 | } | 1171 | } |
1173 | void MainWindow::exportToPhone( int mode ) | 1172 | void MainWindow::exportToPhone( int mode ) |
1174 | { | 1173 | { |
1175 | 1174 | ||
1176 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1175 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1177 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1176 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1178 | KOex2phonePrefs ex2phone; | 1177 | KOex2phonePrefs ex2phone; |
1179 | 1178 | ||
1180 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 1179 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
1181 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 1180 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
1182 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1181 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1183 | if ( mode == 1 ) | 1182 | if ( mode == 1 ) |
1184 | ex2phone.setCaption(i18n("Export complete calendar")); | 1183 | ex2phone.setCaption(i18n("Export complete calendar")); |
1185 | if ( mode == 2 ) | 1184 | if ( mode == 2 ) |
1186 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1185 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1187 | 1186 | ||
1188 | if ( !ex2phone.exec() ) { | 1187 | if ( !ex2phone.exec() ) { |
1189 | return; | 1188 | return; |
1190 | } | 1189 | } |
1191 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1190 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1192 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1191 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1193 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1192 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1194 | 1193 | ||
1195 | int inFuture = 0; | 1194 | int inFuture = 0; |
1196 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1195 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1197 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1196 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1198 | QPtrList<Incidence> delSel; | 1197 | QPtrList<Incidence> delSel; |
1199 | if ( mode == 1 ) | 1198 | if ( mode == 1 ) |
1200 | delSel = mCalendar->rawIncidences(); | 1199 | delSel = mCalendar->rawIncidences(); |
1201 | if ( mode == 2 ) | 1200 | if ( mode == 2 ) |
1202 | delSel = mCalendar->incidences(); | 1201 | delSel = mCalendar->incidences(); |
1203 | CalendarLocal* cal = new CalendarLocal(); | 1202 | CalendarLocal* cal = new CalendarLocal(); |
1204 | cal->setLocalTime(); | 1203 | cal->setLocalTime(); |
1205 | Incidence *incidence = delSel.first(); | 1204 | Incidence *incidence = delSel.first(); |
1206 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1205 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1207 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1206 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1208 | while ( incidence ) { | 1207 | while ( incidence ) { |
1209 | if ( incidence->type() != "Journal" ) { | 1208 | if ( incidence->type() != "Journal" ) { |
1210 | bool add = true; | 1209 | bool add = true; |
1211 | if ( inFuture ) { | 1210 | if ( inFuture ) { |
1212 | QDateTime dt; | 1211 | QDateTime dt; |
1213 | if ( incidence->type() == "Todo" ) { | 1212 | if ( incidence->type() == "Todo" ) { |
1214 | Todo * t = (Todo*)incidence; | 1213 | Todo * t = (Todo*)incidence; |
1215 | if ( t->hasDueDate() ) | 1214 | if ( t->hasDueDate() ) |
1216 | dt = t->dtDue(); | 1215 | dt = t->dtDue(); |
1217 | else | 1216 | else |
1218 | dt = cur.addSecs( 62 ); | 1217 | dt = cur.addSecs( 62 ); |
1219 | } | 1218 | } |
1220 | else { | 1219 | else { |
1221 | bool ok; | 1220 | bool ok; |
1222 | dt = incidence->getNextOccurence( cur, &ok ); | 1221 | dt = incidence->getNextOccurence( cur, &ok ); |
1223 | if ( !ok ) | 1222 | if ( !ok ) |
1224 | dt = cur.addSecs( -62 ); | 1223 | dt = cur.addSecs( -62 ); |
1225 | } | 1224 | } |
1226 | if ( dt < cur || dt > end ) { | 1225 | if ( dt < cur || dt > end ) { |
1227 | add = false; | 1226 | add = false; |
1228 | } | 1227 | } |
1229 | } | 1228 | } |
1230 | if ( add ) { | 1229 | if ( add ) { |
1231 | Incidence *in = incidence->clone(); | 1230 | Incidence *in = incidence->clone(); |
1232 | cal->addIncidence( in ); | 1231 | cal->addIncidence( in ); |
1233 | } | 1232 | } |
1234 | } | 1233 | } |
1235 | incidence = delSel.next(); | 1234 | incidence = delSel.next(); |
1236 | } | 1235 | } |
1237 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1236 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1238 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1237 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1239 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1238 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1240 | 1239 | ||
1241 | setCaption( i18n("Writing to phone...")); | 1240 | setCaption( i18n("Writing to phone...")); |
1242 | if ( PhoneFormat::writeToPhone( cal ) ) | 1241 | if ( PhoneFormat::writeToPhone( cal ) ) |
1243 | setCaption( i18n("Export to phone successful!")); | 1242 | setCaption( i18n("Export to phone successful!")); |
1244 | else | 1243 | else |
1245 | setCaption( i18n("Error exporting to phone!")); | 1244 | setCaption( i18n("Error exporting to phone!")); |
1246 | delete cal; | 1245 | delete cal; |
1247 | } | 1246 | } |
1248 | 1247 | ||
1249 | 1248 | ||
1250 | void MainWindow::setDefaultPreferences() | 1249 | void MainWindow::setDefaultPreferences() |
1251 | { | 1250 | { |
1252 | KOPrefs *p = KOPrefs::instance(); | 1251 | KOPrefs *p = KOPrefs::instance(); |
1253 | 1252 | ||
1254 | p->mCompactDialogs = true; | 1253 | p->mCompactDialogs = true; |
1255 | p->mConfirm = true; | 1254 | p->mConfirm = true; |
1256 | // p->mEnableQuickTodo = false; | 1255 | // p->mEnableQuickTodo = false; |
1257 | 1256 | ||
1258 | } | 1257 | } |
1259 | 1258 | ||
1260 | QString MainWindow::resourcePath() | 1259 | QString MainWindow::resourcePath() |
1261 | { | 1260 | { |
1262 | return KGlobal::iconLoader()->iconPath(); | 1261 | return KGlobal::iconLoader()->iconPath(); |
1263 | } | 1262 | } |
1264 | 1263 | ||
1265 | void MainWindow::displayText( QString text ,QString cap ) | 1264 | void MainWindow::displayText( QString text ,QString cap ) |
1266 | { | 1265 | { |
1267 | QDialog dia( this, "name", true ); ; | 1266 | QDialog dia( this, "name", true ); ; |
1268 | dia.setCaption( cap ); | 1267 | dia.setCaption( cap ); |
1269 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1268 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1270 | lay->setSpacing( 3 ); | 1269 | lay->setSpacing( 3 ); |
1271 | lay->setMargin( 3 ); | 1270 | lay->setMargin( 3 ); |
1272 | QTextBrowser tb ( &dia ); | 1271 | QTextBrowser tb ( &dia ); |
1273 | lay->addWidget( &tb ); | 1272 | lay->addWidget( &tb ); |
1274 | tb.setText( text ); | 1273 | tb.setText( text ); |
1275 | #ifdef DESKTOP_VERSION | 1274 | #ifdef DESKTOP_VERSION |
1276 | dia.resize( 640, 480); | 1275 | dia.resize( 640, 480); |
1277 | #else | 1276 | #else |
1278 | dia.showMaximized(); | 1277 | dia.showMaximized(); |
1279 | #endif | 1278 | #endif |
1280 | dia.exec(); | 1279 | dia.exec(); |
1281 | } | 1280 | } |
1282 | void MainWindow::displayFile( QString fn, QString cap ) | 1281 | void MainWindow::displayFile( QString fn, QString cap ) |
1283 | { | 1282 | { |
1284 | QString fileName = resourcePath() + fn; | 1283 | QString fileName = resourcePath() + fn; |
1285 | QString text; | 1284 | QString text; |
1286 | QFile file( fileName ); | 1285 | QFile file( fileName ); |
1287 | if (!file.open( IO_ReadOnly ) ) { | 1286 | if (!file.open( IO_ReadOnly ) ) { |
1288 | return ; | 1287 | return ; |
1289 | 1288 | ||
1290 | } | 1289 | } |
1291 | QTextStream ts( &file ); | 1290 | QTextStream ts( &file ); |
1292 | text = ts.read(); | 1291 | text = ts.read(); |
1293 | file.close(); | 1292 | file.close(); |
1294 | displayText( text, cap); | 1293 | displayText( text, cap); |
1295 | } | 1294 | } |
1296 | void MainWindow::features() | 1295 | void MainWindow::features() |
1297 | { | 1296 | { |
1298 | 1297 | ||
1299 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1298 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1300 | } | 1299 | } |
1301 | 1300 | ||
1302 | void MainWindow::usertrans() | 1301 | void MainWindow::usertrans() |
1303 | { | 1302 | { |
1304 | 1303 | ||
1305 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1304 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1306 | } | 1305 | } |
1307 | 1306 | ||
1308 | void MainWindow::synchowto() | 1307 | void MainWindow::synchowto() |
1309 | { | 1308 | { |
1310 | #if 0 | 1309 | #if 0 |
1311 | QPtrList<Incidence> er = mCalendar->rawIncidences(); | 1310 | QPtrList<Incidence> er = mCalendar->rawIncidences(); |
1312 | Incidence* inR = er.first(); | 1311 | Incidence* inR = er.first(); |
1313 | VCalFormat vf; | 1312 | VCalFormat vf; |
1314 | QString strout; | 1313 | QString strout; |
1315 | while ( inR ) { | 1314 | while ( inR ) { |
1316 | if ( inR->type() == "Todo" ) | 1315 | if ( inR->type() == "Todo" ) |
1317 | strout = vf.todoToString( (Todo *) inR ); | 1316 | strout = vf.todoToString( (Todo *) inR ); |
1318 | if ( inR->type() == "Event" ) | 1317 | if ( inR->type() == "Event" ) |
1319 | strout = vf.eventToString( (Event *) inR ); | 1318 | strout = vf.eventToString( (Event *) inR ); |
1320 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); | 1319 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); |
1321 | inR = er.next(); | 1320 | inR = er.next(); |
1322 | } | 1321 | } |
1323 | #endif | 1322 | #endif |
1324 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); | 1323 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); |
1325 | } | 1324 | } |
1326 | void MainWindow::faq() | 1325 | void MainWindow::faq() |
1327 | { | 1326 | { |
1328 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1327 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1329 | 1328 | ||
1330 | } | 1329 | } |
1331 | void MainWindow::whatsNew() | 1330 | void MainWindow::whatsNew() |
1332 | { | 1331 | { |
1333 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); | 1332 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); |
1334 | 1333 | ||
1335 | } | 1334 | } |
1336 | void MainWindow::licence() | 1335 | void MainWindow::licence() |
1337 | { | 1336 | { |
1338 | KApplication::showLicence(); | 1337 | KApplication::showLicence(); |
1339 | 1338 | ||
1340 | } | 1339 | } |
1341 | void MainWindow::about() | 1340 | void MainWindow::about() |
1342 | { | 1341 | { |
1343 | QString version; | 1342 | QString version; |
1344 | #include <../version> | 1343 | #include <../version> |
1345 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1344 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1346 | i18n("KOrganizer/Platform-independent\n") + | 1345 | i18n("KOrganizer/Platform-independent\n") + |
1347 | "(KO/Pi) " + version + " - " + | 1346 | "(KO/Pi) " + version + " - " + |
1348 | 1347 | ||
1349 | #ifdef DESKTOP_VERSION | 1348 | #ifdef DESKTOP_VERSION |
1350 | i18n("Desktop Edition\n") + | 1349 | i18n("Desktop Edition\n") + |
1351 | #else | 1350 | #else |
1352 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1351 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1353 | #endif | 1352 | #endif |
1354 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); | 1353 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); |
1355 | } | 1354 | } |
1356 | void MainWindow::keyBindings() | 1355 | void MainWindow::keyBindings() |
1357 | { | 1356 | { |
1358 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1357 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1359 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1358 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1360 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1359 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1361 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1360 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1362 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1361 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1363 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1362 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1364 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1363 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1365 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1364 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1366 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1365 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1367 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1366 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1368 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1367 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1369 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1368 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1370 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1369 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1371 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1370 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1372 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1371 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1373 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1372 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1374 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1373 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1375 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1374 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1376 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1375 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1377 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1376 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1378 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1377 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1379 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1378 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1380 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1379 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1381 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1380 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1382 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1381 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1383 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1382 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1384 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1383 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1385 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1384 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1386 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1385 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1387 | i18n("<p><h3>In list view:</h3></p>\n") + | 1386 | i18n("<p><h3>In list view:</h3></p>\n") + |
1388 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1387 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1389 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1388 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1390 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1389 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1391 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1390 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1392 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1391 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1393 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1392 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1394 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1393 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1395 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1394 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1396 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1395 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1397 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1396 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1398 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1397 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1399 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1398 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1400 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1399 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1401 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1400 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1402 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1401 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1403 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1402 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1404 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1403 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1405 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1404 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1406 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1405 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1407 | displayText( text, cap); | 1406 | displayText( text, cap); |
1408 | 1407 | ||
1409 | } | 1408 | } |
1410 | void MainWindow::aboutAutoSaving() | 1409 | void MainWindow::aboutAutoSaving() |
1411 | { | 1410 | { |
1412 | QMessageBox* msg; | 1411 | QMessageBox* msg; |
1413 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1412 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1414 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, | 1413 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, |
1415 | QMessageBox::Ok, | 1414 | QMessageBox::Ok, |
1416 | QMessageBox::NoButton, | 1415 | QMessageBox::NoButton, |
1417 | QMessageBox::NoButton); | 1416 | QMessageBox::NoButton); |
1418 | msg->exec(); | 1417 | msg->exec(); |
1419 | delete msg; | 1418 | delete msg; |
1420 | 1419 | ||
1421 | 1420 | ||
1422 | } | 1421 | } |
1423 | void MainWindow::aboutKnownBugs() | 1422 | void MainWindow::aboutKnownBugs() |
1424 | { | 1423 | { |
1425 | QMessageBox* msg; | 1424 | QMessageBox* msg; |
1426 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1425 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1427 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1426 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1428 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1427 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1429 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1428 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1430 | i18n("\nor report them in the bugtracker on\n") + | 1429 | i18n("\nor report them in the bugtracker on\n") + |
1431 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1430 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1432 | QMessageBox::NoIcon, | 1431 | QMessageBox::NoIcon, |
1433 | QMessageBox::Ok, | 1432 | QMessageBox::Ok, |
1434 | QMessageBox::NoButton, | 1433 | QMessageBox::NoButton, |
1435 | QMessageBox::NoButton); | 1434 | QMessageBox::NoButton); |
1436 | msg->exec(); | 1435 | msg->exec(); |
1437 | delete msg; | 1436 | delete msg; |
1438 | 1437 | ||
1439 | } | 1438 | } |
1440 | 1439 | ||
1441 | QString MainWindow::defaultFileName() | 1440 | QString MainWindow::defaultFileName() |
1442 | { | 1441 | { |
1443 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1442 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1444 | } | 1443 | } |
1445 | QString MainWindow::syncFileName() | 1444 | QString MainWindow::syncFileName() |
1446 | { | 1445 | { |
1447 | #ifdef _WIN32_ | 1446 | #ifdef _WIN32_ |
1448 | return locateLocal( "tmp", "synccalendar.ics" ); | 1447 | return locateLocal( "tmp", "synccalendar.ics" ); |
1449 | #else | 1448 | #else |
1450 | return QString( "/tmp/kopitempfile.ics" ); | 1449 | return QString( "/tmp/kopitempfile.ics" ); |
1451 | #endif | 1450 | #endif |
1452 | } | 1451 | } |
1453 | 1452 | ||
1454 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1453 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1455 | { | 1454 | { |
1456 | if ( !incidence ) { | 1455 | if ( !incidence ) { |
1457 | enableIncidenceActions( false ); | 1456 | enableIncidenceActions( false ); |
1458 | 1457 | ||
1459 | mNewSubTodoAction->setEnabled( false ); | 1458 | mNewSubTodoAction->setEnabled( false ); |
1460 | setCaptionToDates(); | 1459 | setCaptionToDates(); |
1461 | return; | 1460 | return; |
1462 | 1461 | ||
1463 | } | 1462 | } |
1464 | 1463 | ||
1465 | //KGlobal::locale()->formatDateTime(nextA, true); | 1464 | //KGlobal::locale()->formatDateTime(nextA, true); |
1466 | QString startString = ""; | 1465 | QString startString = ""; |
1467 | if ( incidence->type() != "Todo" ) { | 1466 | if ( incidence->type() != "Todo" ) { |
1468 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1467 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1469 | if ( incidence->doesFloat() ) { | 1468 | if ( incidence->doesFloat() ) { |
1470 | startString += ": "+incidence->dtStartDateStr( true ); | 1469 | startString += ": "+incidence->dtStartDateStr( true ); |
1471 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1470 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1472 | 1471 | ||
1473 | } else { | 1472 | } else { |
1474 | startString = ": "+incidence->dtStartStr(true); | 1473 | startString = ": "+incidence->dtStartStr(true); |
1475 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1474 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1476 | 1475 | ||
1477 | } | 1476 | } |
1478 | 1477 | ||
1479 | } else { | 1478 | } else { |
1480 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1479 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1481 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1480 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1482 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1481 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1483 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1482 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1484 | } | 1483 | } |
1485 | 1484 | ||
1486 | } | 1485 | } |
1487 | else | 1486 | else |
1488 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1487 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1489 | if ( !incidence->location().isEmpty() ) | 1488 | if ( !incidence->location().isEmpty() ) |
1490 | startString += " (" +incidence->location()+")"; | 1489 | startString += " (" +incidence->location()+")"; |
1491 | setCaption( incidence->summary()+startString); | 1490 | setCaption( incidence->summary()+startString); |
1492 | 1491 | ||
1493 | enableIncidenceActions( true ); | 1492 | enableIncidenceActions( true ); |
1494 | 1493 | ||
1495 | if ( incidence->type() == "Event" ) { | 1494 | if ( incidence->type() == "Event" ) { |
1496 | mShowAction->setText( i18n("Show Event...") ); | 1495 | mShowAction->setText( i18n("Show Event...") ); |
1497 | mEditAction->setText( i18n("Edit Event...") ); | 1496 | mEditAction->setText( i18n("Edit Event...") ); |
1498 | mDeleteAction->setText( i18n("Delete Event...") ); | 1497 | mDeleteAction->setText( i18n("Delete Event...") ); |
1499 | 1498 | ||
1500 | mNewSubTodoAction->setEnabled( false ); | 1499 | mNewSubTodoAction->setEnabled( false ); |
1501 | } else if ( incidence->type() == "Todo" ) { | 1500 | } else if ( incidence->type() == "Todo" ) { |
1502 | mShowAction->setText( i18n("Show Todo...") ); | 1501 | mShowAction->setText( i18n("Show Todo...") ); |
1503 | mEditAction->setText( i18n("Edit Todo...") ); | 1502 | mEditAction->setText( i18n("Edit Todo...") ); |
1504 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1503 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1505 | 1504 | ||
1506 | mNewSubTodoAction->setEnabled( true ); | 1505 | mNewSubTodoAction->setEnabled( true ); |
1507 | } else { | 1506 | } else { |
1508 | mShowAction->setText( i18n("Show...") ); | 1507 | mShowAction->setText( i18n("Show...") ); |
1509 | mShowAction->setText( i18n("Edit...") ); | 1508 | mShowAction->setText( i18n("Edit...") ); |
1510 | mShowAction->setText( i18n("Delete...") ); | 1509 | mShowAction->setText( i18n("Delete...") ); |
1511 | 1510 | ||
1512 | mNewSubTodoAction->setEnabled( false ); | 1511 | mNewSubTodoAction->setEnabled( false ); |
1513 | } | 1512 | } |
1514 | } | 1513 | } |
1515 | 1514 | ||
1516 | void MainWindow::enableIncidenceActions( bool enabled ) | 1515 | void MainWindow::enableIncidenceActions( bool enabled ) |
1517 | { | 1516 | { |
1518 | mShowAction->setEnabled( enabled ); | 1517 | mShowAction->setEnabled( enabled ); |
1519 | mEditAction->setEnabled( enabled ); | 1518 | mEditAction->setEnabled( enabled ); |
1520 | mDeleteAction->setEnabled( enabled ); | 1519 | mDeleteAction->setEnabled( enabled ); |
1521 | 1520 | ||
1522 | mCloneAction->setEnabled( enabled ); | 1521 | mCloneAction->setEnabled( enabled ); |
1523 | mMoveAction->setEnabled( enabled ); | 1522 | mMoveAction->setEnabled( enabled ); |
1524 | mBeamAction->setEnabled( enabled ); | 1523 | mBeamAction->setEnabled( enabled ); |
1525 | mCancelAction->setEnabled( enabled ); | 1524 | mCancelAction->setEnabled( enabled ); |
1526 | } | 1525 | } |
1527 | 1526 | ||
1528 | void MainWindow::importOL() | 1527 | void MainWindow::importOL() |
1529 | { | 1528 | { |
1530 | #ifdef _WIN32_ | 1529 | #ifdef _WIN32_ |
1531 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1530 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1532 | id->exec(); | 1531 | id->exec(); |
1533 | delete id; | 1532 | delete id; |
1534 | mView->updateView(); | 1533 | mView->updateView(); |
1535 | #endif | 1534 | #endif |
1536 | } | 1535 | } |
1537 | void MainWindow::importBday() | 1536 | void MainWindow::importBday() |
1538 | { | 1537 | { |
1539 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1538 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1540 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1539 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1541 | i18n("Import!"), i18n("Cancel"), 0, | 1540 | i18n("Import!"), i18n("Cancel"), 0, |
1542 | 0, 1 ); | 1541 | 0, 1 ); |
1543 | if ( result == 0 ) { | 1542 | if ( result == 0 ) { |
1544 | mView->importBday(); | 1543 | mView->importBday(); |
1545 | 1544 | ||
1546 | } | 1545 | } |
1547 | 1546 | ||
1548 | 1547 | ||
1549 | } | 1548 | } |
1550 | void MainWindow::importQtopia() | 1549 | void MainWindow::importQtopia() |
1551 | { | 1550 | { |
1552 | #ifndef DESKTOP_VERSION | 1551 | #ifndef DESKTOP_VERSION |
1553 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1552 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1554 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1553 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1555 | i18n("Import!"), i18n("Cancel"), 0, | 1554 | i18n("Import!"), i18n("Cancel"), 0, |
1556 | 0, 1 ); | 1555 | 0, 1 ); |
1557 | if ( result == 0 ) { | 1556 | if ( result == 0 ) { |
1558 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1557 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1559 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1558 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1560 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1559 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1561 | mView->importQtopia( categories, datebook, todolist ); | 1560 | mView->importQtopia( categories, datebook, todolist ); |
1562 | } | 1561 | } |
1563 | #else | 1562 | #else |
1564 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1563 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1565 | i18n("Not supported \non desktop!\n"), | 1564 | i18n("Not supported \non desktop!\n"), |
1566 | i18n("Ok"), i18n("Cancel"), 0, | 1565 | i18n("Ok"), i18n("Cancel"), 0, |
1567 | 0, 1 ); | 1566 | 0, 1 ); |
1568 | 1567 | ||
1569 | #endif | 1568 | #endif |
1570 | } | 1569 | } |
1571 | 1570 | ||
1572 | void MainWindow::saveOnClose() | 1571 | void MainWindow::saveOnClose() |
1573 | { | 1572 | { |
1574 | KOPrefs *p = KOPrefs::instance(); | 1573 | KOPrefs *p = KOPrefs::instance(); |
1575 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1574 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1576 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1575 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1577 | iconToolBar->y() > height()/2; | 1576 | iconToolBar->y() > height()/2; |
1578 | mView->writeSettings(); | 1577 | mView->writeSettings(); |
1579 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1578 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1580 | save(); | 1579 | save(); |
1581 | } | 1580 | } |
1582 | void MainWindow::slotModifiedChanged( bool changed ) | 1581 | void MainWindow::slotModifiedChanged( bool changed ) |
1583 | { | 1582 | { |
1584 | if ( mBlockAtStartup ) | 1583 | if ( mBlockAtStartup ) |
1585 | return; | 1584 | return; |
1586 | int msec; | 1585 | int msec; |
1587 | // we store the changes after 1 minute, | 1586 | // we store the changes after 1 minute, |
1588 | // and for safety reasons after 10 minutes again | 1587 | // and for safety reasons after 10 minutes again |
1589 | if ( !mBlockSaveFlag ) | 1588 | if ( !mBlockSaveFlag ) |
1590 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1589 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1591 | else | 1590 | else |
1592 | msec = 1000 * 600; | 1591 | msec = 1000 * 600; |
1593 | mSaveTimer.start( msec, true ); // 1 minute | 1592 | mSaveTimer.start( msec, true ); // 1 minute |
1594 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1593 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1595 | mCalendarModifiedFlag = true; | 1594 | mCalendarModifiedFlag = true; |
1596 | } | 1595 | } |
1597 | void MainWindow::save() | 1596 | void MainWindow::save() |
1598 | { | 1597 | { |
1599 | if ( mBlockSaveFlag ) | 1598 | if ( mBlockSaveFlag ) |
1600 | return; | 1599 | return; |
1601 | bool store = mBlockSaveFlag; | 1600 | bool store = mBlockSaveFlag; |
1602 | mBlockSaveFlag = true; | 1601 | mBlockSaveFlag = true; |
1603 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1602 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1604 | 1603 | ||
1605 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1604 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1606 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1605 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1607 | qDebug("KO: Start saving data to file!"); | 1606 | qDebug("KO: Start saving data to file!"); |
1608 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1607 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1609 | mView->saveCalendar( defaultFileName() ); | 1608 | mView->saveCalendar( defaultFileName() ); |
1610 | 1609 | ||
1611 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1610 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1612 | mView->watchSavedFile(); | 1611 | mView->watchSavedFile(); |
1613 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1612 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1614 | QString savemes; | 1613 | QString savemes; |
1615 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1614 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1616 | setCaption(savemes); | 1615 | setCaption(savemes); |
1617 | } else | 1616 | } else |
1618 | setCaption(i18n("Saving cancelled!")); | 1617 | setCaption(i18n("Saving cancelled!")); |
1619 | mCalendarModifiedFlag = false; | 1618 | mCalendarModifiedFlag = false; |
1620 | mBlockSaveFlag = store; | 1619 | mBlockSaveFlag = store; |
1621 | } | 1620 | } |
1622 | 1621 | ||
1623 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1622 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1624 | { | 1623 | { |
1625 | if ( !e->isAutoRepeat() ) { | 1624 | if ( !e->isAutoRepeat() ) { |
1626 | mFlagKeyPressed = false; | 1625 | mFlagKeyPressed = false; |
1627 | } | 1626 | } |
1628 | } | 1627 | } |
1629 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1628 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1630 | { | 1629 | { |
1631 | qApp->processEvents(); | 1630 | qApp->processEvents(); |
1632 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1631 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1633 | e->ignore(); | 1632 | e->ignore(); |
1634 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1633 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1635 | return; | 1634 | return; |
1636 | } | 1635 | } |
1637 | if (! e->isAutoRepeat() ) | 1636 | if (! e->isAutoRepeat() ) |
1638 | mFlagKeyPressed = true; | 1637 | mFlagKeyPressed = true; |
1639 | KOPrefs *p = KOPrefs::instance(); | 1638 | KOPrefs *p = KOPrefs::instance(); |
1640 | bool showSelectedDates = false; | 1639 | bool showSelectedDates = false; |
1641 | int size; | 1640 | int size; |
1642 | int pro = 0; | 1641 | int pro = 0; |
1643 | //qDebug("MainWindow::keyPressEvent "); | 1642 | //qDebug("MainWindow::keyPressEvent "); |
1644 | switch ( e->key() ) { | 1643 | switch ( e->key() ) { |
1645 | case Qt::Key_Right: | 1644 | case Qt::Key_Right: |
1646 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1645 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1647 | mView->goNextMonth(); | 1646 | mView->goNextMonth(); |
1648 | else | 1647 | else |
1649 | mView->goNext(); | 1648 | mView->goNext(); |
1650 | showSelectedDates = true; | 1649 | showSelectedDates = true; |
1651 | break; | 1650 | break; |
1652 | case Qt::Key_Left: | 1651 | case Qt::Key_Left: |
1653 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1652 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1654 | mView->goPreviousMonth(); | 1653 | mView->goPreviousMonth(); |
1655 | else | 1654 | else |
1656 | mView->goPrevious(); | 1655 | mView->goPrevious(); |
1657 | showSelectedDates = true; | 1656 | showSelectedDates = true; |
1658 | break; | 1657 | break; |
1659 | case Qt::Key_Down: | 1658 | case Qt::Key_Down: |
1660 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1659 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1661 | break; | 1660 | break; |
1662 | case Qt::Key_Up: | 1661 | case Qt::Key_Up: |
1663 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1662 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1664 | break; | 1663 | break; |
1665 | case Qt::Key_I: | 1664 | case Qt::Key_I: |
1666 | mView->showIncidence(); | 1665 | mView->showIncidence(); |
1667 | break; | 1666 | break; |
1668 | case Qt::Key_Delete: | 1667 | case Qt::Key_Delete: |
1669 | case Qt::Key_Backspace: | 1668 | case Qt::Key_Backspace: |
1670 | mView->deleteIncidence(); | 1669 | mView->deleteIncidence(); |
1671 | break; | 1670 | break; |
1672 | case Qt::Key_D: | 1671 | case Qt::Key_D: |
1673 | mView->viewManager()->showDayView(); | 1672 | mView->viewManager()->showDayView(); |
1674 | showSelectedDates = true; | 1673 | showSelectedDates = true; |
1675 | break; | 1674 | break; |
1676 | case Qt::Key_O: | 1675 | case Qt::Key_O: |
1677 | mView->toggleFilerEnabled( ); | 1676 | mView->toggleFilerEnabled( ); |
1678 | break; | 1677 | break; |
1679 | case Qt::Key_0: | 1678 | case Qt::Key_0: |
1680 | case Qt::Key_1: | 1679 | case Qt::Key_1: |
1681 | case Qt::Key_2: | 1680 | case Qt::Key_2: |
1682 | case Qt::Key_3: | 1681 | case Qt::Key_3: |
1683 | case Qt::Key_4: | 1682 | case Qt::Key_4: |
1684 | case Qt::Key_5: | 1683 | case Qt::Key_5: |
1685 | case Qt::Key_6: | 1684 | case Qt::Key_6: |
1686 | case Qt::Key_7: | 1685 | case Qt::Key_7: |
1687 | case Qt::Key_8: | 1686 | case Qt::Key_8: |
1688 | case Qt::Key_9: | 1687 | case Qt::Key_9: |
1689 | pro = e->key()-48; | 1688 | pro = e->key()-48; |
1690 | if ( pro == 0 ) | 1689 | if ( pro == 0 ) |
1691 | pro = 10; | 1690 | pro = 10; |
1692 | if ( e->state() == Qt::ControlButton) | 1691 | if ( e->state() == Qt::ControlButton) |
1693 | pro += 10; | 1692 | pro += 10; |
1694 | break; | 1693 | break; |
1695 | case Qt::Key_M: | 1694 | case Qt::Key_M: |
1696 | mView->viewManager()->showMonthView(); | 1695 | mView->viewManager()->showMonthView(); |
1697 | showSelectedDates = true; | 1696 | showSelectedDates = true; |
1698 | break; | 1697 | break; |
1699 | case Qt::Key_Insert: | 1698 | case Qt::Key_Insert: |
1700 | mView->newEvent(); | 1699 | mView->newEvent(); |
1701 | break; | 1700 | break; |
1702 | case Qt::Key_S : | 1701 | case Qt::Key_S : |
1703 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1702 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1704 | mView->newSubTodo(); | 1703 | mView->newSubTodo(); |
1705 | else | 1704 | else |
1706 | mView->dialogManager()->showSearchDialog(); | 1705 | mView->dialogManager()->showSearchDialog(); |
1707 | break; | 1706 | break; |
1708 | case Qt::Key_Y : | 1707 | case Qt::Key_Y : |
1709 | case Qt::Key_Z : | 1708 | case Qt::Key_Z : |
1710 | mView->viewManager()->showWorkWeekView(); | 1709 | mView->viewManager()->showWorkWeekView(); |
1711 | showSelectedDates = true; | 1710 | showSelectedDates = true; |
1712 | break; | 1711 | break; |
1713 | case Qt::Key_U : | 1712 | case Qt::Key_U : |
1714 | mView->viewManager()->showWeekView(); | 1713 | mView->viewManager()->showWeekView(); |
1715 | showSelectedDates = true; | 1714 | showSelectedDates = true; |
1716 | break; | 1715 | break; |
1717 | case Qt::Key_H : | 1716 | case Qt::Key_H : |
1718 | keyBindings(); | 1717 | keyBindings(); |
1719 | break; | 1718 | break; |
1720 | case Qt::Key_W: | 1719 | case Qt::Key_W: |
1721 | mView->viewManager()->showWhatsNextView(); | 1720 | mView->viewManager()->showWhatsNextView(); |
1722 | break; | 1721 | break; |
1723 | case Qt::Key_L: | 1722 | case Qt::Key_L: |
1724 | mView->viewManager()->showListView(); | 1723 | mView->viewManager()->showListView(); |
1725 | break; | 1724 | break; |
1726 | case Qt::Key_N: | 1725 | case Qt::Key_N: |
1727 | mView->viewManager()->showNextXView(); | 1726 | mView->viewManager()->showNextXView(); |
1728 | showSelectedDates = true; | 1727 | showSelectedDates = true; |
1729 | break; | 1728 | break; |
1730 | case Qt::Key_V: | 1729 | case Qt::Key_V: |
1731 | mView->viewManager()->showTodoView(); | 1730 | mView->viewManager()->showTodoView(); |
1732 | break; | 1731 | break; |
1733 | case Qt::Key_C: | 1732 | case Qt::Key_C: |
1734 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1733 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1735 | break; | 1734 | break; |
1736 | case Qt::Key_P: | 1735 | case Qt::Key_P: |
1737 | mView->showDatePicker( ); | 1736 | mView->showDatePicker( ); |
1738 | break; | 1737 | break; |
1739 | case Qt::Key_F: | 1738 | case Qt::Key_F: |
1740 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1739 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1741 | mView->editFilters(); | 1740 | mView->editFilters(); |
1742 | else | 1741 | else |
1743 | mView->toggleFilter(); | 1742 | mView->toggleFilter(); |
1744 | break; | 1743 | break; |
1745 | case Qt::Key_X: | 1744 | case Qt::Key_X: |
1746 | mView->toggleDateNavigatorWidget(); | 1745 | mView->toggleDateNavigatorWidget(); |
1747 | break; | 1746 | break; |
1748 | case Qt::Key_Space: | 1747 | case Qt::Key_Space: |
1749 | mView->toggleExpand(); | 1748 | mView->toggleExpand(); |
1750 | break; | 1749 | break; |
1751 | case Qt::Key_A: | 1750 | case Qt::Key_A: |
1752 | mView->toggleAllDaySize(); | 1751 | mView->toggleAllDaySize(); |
1753 | break; | 1752 | break; |
1754 | case Qt::Key_T: | 1753 | case Qt::Key_T: |
1755 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1754 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1756 | mView->newTodo(); | 1755 | mView->newTodo(); |
1757 | else { | 1756 | else { |
1758 | mView->goToday(); | 1757 | mView->goToday(); |
1759 | showSelectedDates = true; | 1758 | showSelectedDates = true; |
1760 | } | 1759 | } |
1761 | break; | 1760 | break; |
1762 | case Qt::Key_J: | 1761 | case Qt::Key_J: |
1763 | mView->viewManager()->showJournalView(); | 1762 | mView->viewManager()->showJournalView(); |
1764 | break; | 1763 | break; |
1765 | case Qt::Key_B: | 1764 | case Qt::Key_B: |
1766 | mView->editIncidenceDescription();; | 1765 | mView->editIncidenceDescription();; |
1767 | break; | 1766 | break; |
1768 | // case Qt::Key_Return: | 1767 | // case Qt::Key_Return: |
1769 | case Qt::Key_E: | 1768 | case Qt::Key_E: |
1770 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1769 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1771 | mView->newEvent(); | 1770 | mView->newEvent(); |
1772 | else | 1771 | else |
1773 | mView->editIncidence(); | 1772 | mView->editIncidence(); |
1774 | break; | 1773 | break; |
1775 | case Qt::Key_Plus: | 1774 | case Qt::Key_Plus: |
1776 | size = p->mHourSize +2; | 1775 | size = p->mHourSize +2; |
1777 | if ( size <= 18 ) | 1776 | if ( size <= 18 ) |
1778 | configureAgenda( size ); | 1777 | configureAgenda( size ); |
1779 | break; | 1778 | break; |
1780 | case Qt::Key_Minus: | 1779 | case Qt::Key_Minus: |
1781 | size = p->mHourSize - 2; | 1780 | size = p->mHourSize - 2; |
1782 | if ( size >= 4 ) | 1781 | if ( size >= 4 ) |
1783 | configureAgenda( size ); | 1782 | configureAgenda( size ); |
1784 | break; | 1783 | break; |
1785 | 1784 | ||
1786 | 1785 | ||
1787 | default: | 1786 | default: |
1788 | e->ignore(); | 1787 | e->ignore(); |
1789 | } | 1788 | } |
1790 | if ( pro > 0 ) { | 1789 | if ( pro > 0 ) { |
1791 | mView->selectFilter( pro-1 ); | 1790 | mView->selectFilter( pro-1 ); |
1792 | } | 1791 | } |
1793 | if ( showSelectedDates ) { | 1792 | if ( showSelectedDates ) { |
1794 | ;// setCaptionToDates(); | 1793 | ;// setCaptionToDates(); |
1795 | } | 1794 | } |
1796 | 1795 | ||
1797 | } | 1796 | } |
1798 | 1797 | ||
1799 | void MainWindow::fillFilterMenu() | 1798 | void MainWindow::fillFilterMenu() |
1800 | { | 1799 | { |
1801 | selectFilterMenu->clear(); | 1800 | selectFilterMenu->clear(); |
1802 | bool disable = false; | 1801 | bool disable = false; |
1803 | if ( mView->filterView()->filtersEnabled() ) { | 1802 | if ( mView->filterView()->filtersEnabled() ) { |
1804 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1803 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1805 | } | 1804 | } |
1806 | else { | 1805 | else { |
1807 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1806 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1808 | disable = true; | 1807 | disable = true; |
1809 | } | 1808 | } |
1810 | selectFilterMenu->insertSeparator(); | 1809 | selectFilterMenu->insertSeparator(); |
1811 | QPtrList<CalFilter> fili = mView->filters(); | 1810 | QPtrList<CalFilter> fili = mView->filters(); |
1812 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1811 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1813 | CalFilter *filter = fili.first(); | 1812 | CalFilter *filter = fili.first(); |
1814 | int iii = 1; | 1813 | int iii = 1; |
1815 | while(filter) { | 1814 | while(filter) { |
1816 | selectFilterMenu->insertItem( filter->name(), iii ); | 1815 | selectFilterMenu->insertItem( filter->name(), iii ); |
1817 | if ( filter == curfilter) | 1816 | if ( filter == curfilter) |
1818 | selectFilterMenu->setItemChecked( iii, true ); | 1817 | selectFilterMenu->setItemChecked( iii, true ); |
1819 | if ( disable ) | 1818 | if ( disable ) |
1820 | selectFilterMenu->setItemEnabled( iii, false ); | 1819 | selectFilterMenu->setItemEnabled( iii, false ); |
1821 | filter = fili.next(); | 1820 | filter = fili.next(); |
1822 | ++iii; | 1821 | ++iii; |
1823 | } | 1822 | } |
1824 | } | 1823 | } |
1825 | void MainWindow::selectFilter( int fil ) | 1824 | void MainWindow::selectFilter( int fil ) |
1826 | { | 1825 | { |
1827 | if ( fil == 0 ) { | 1826 | if ( fil == 0 ) { |
1828 | mView->toggleFilerEnabled( ); | 1827 | mView->toggleFilerEnabled( ); |
1829 | } else { | 1828 | } else { |
1830 | mView->selectFilter( fil-1 ); | 1829 | mView->selectFilter( fil-1 ); |
1831 | } | 1830 | } |
1832 | } | 1831 | } |
1833 | void MainWindow::configureToolBar( int item ) | 1832 | void MainWindow::configureToolBar( int item ) |
1834 | { | 1833 | { |
1835 | 1834 | ||
1836 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1835 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1837 | KOPrefs *p = KOPrefs::instance(); | 1836 | KOPrefs *p = KOPrefs::instance(); |
1838 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1837 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1839 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1838 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1840 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1839 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1841 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1840 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1842 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1841 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1843 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1842 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1844 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1843 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1845 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1844 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1846 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1845 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1847 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1846 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1848 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1847 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1849 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1848 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1850 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1849 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1851 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1850 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1852 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1851 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1853 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1852 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1854 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1853 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1855 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1854 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1856 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1855 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1857 | // initActions(); | 1856 | // initActions(); |
1858 | } | 1857 | } |
1859 | 1858 | ||
1860 | void MainWindow::setCaptionToDates() | 1859 | void MainWindow::setCaptionToDates() |
1861 | { | 1860 | { |
1862 | QString selDates; | 1861 | QString selDates; |
1863 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1862 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1864 | if (mView->startDate() < mView->endDate() ) | 1863 | if (mView->startDate() < mView->endDate() ) |
1865 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1864 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1866 | setCaption( i18n("Dates: ") + selDates ); | 1865 | setCaption( i18n("Dates: ") + selDates ); |
1867 | 1866 | ||
1868 | } | 1867 | } |
1869 | // parameter item == 0: reinit | 1868 | // parameter item == 0: reinit |
1870 | void MainWindow::configureAgenda( int item ) | 1869 | void MainWindow::configureAgenda( int item ) |
1871 | { | 1870 | { |
1872 | 1871 | ||
1873 | KOPrefs *p = KOPrefs::instance(); | 1872 | KOPrefs *p = KOPrefs::instance(); |
1874 | 1873 | ||
1875 | int i; | 1874 | int i; |
1876 | if ( item == 1 ) { | 1875 | if ( item == 1 ) { |
1877 | mView->toggleAllDaySize(); | 1876 | mView->toggleAllDaySize(); |
1878 | return; | 1877 | return; |
1879 | } | 1878 | } |
1880 | // do not allow 4 for widgets higher than 480 | 1879 | // do not allow 4 for widgets higher than 480 |
1881 | // if ( QApplication::desktop()->height() > 480 ) { | 1880 | // if ( QApplication::desktop()->height() > 480 ) { |
1882 | // if ( item == 4 ) | 1881 | // if ( item == 4 ) |
1883 | // item = 6; | 1882 | // item = 6; |
1884 | // } | 1883 | // } |
1885 | for ( i = 4; i <= 18; i= i+2 ) | 1884 | for ( i = 4; i <= 18; i= i+2 ) |
1886 | configureAgendaMenu->setItemChecked( i, false ); | 1885 | configureAgendaMenu->setItemChecked( i, false ); |
1887 | configureAgendaMenu->setItemChecked( item, true ); | 1886 | configureAgendaMenu->setItemChecked( item, true ); |
1888 | if ( p->mHourSize == item ) | 1887 | if ( p->mHourSize == item ) |
1889 | return; | 1888 | return; |
1890 | p->mHourSize=item; | 1889 | p->mHourSize=item; |
1891 | mView->viewManager()->agendaView()->updateConfig(); | 1890 | mView->viewManager()->agendaView()->updateConfig(); |
1892 | } | 1891 | } |
1893 | 1892 | ||
1894 | void MainWindow::saveCalendar() | 1893 | void MainWindow::saveCalendar() |
1895 | { | 1894 | { |
1896 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1895 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1897 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1896 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1898 | 1897 | ||
1899 | if ( fn == "" ) | 1898 | if ( fn == "" ) |
1900 | return; | 1899 | return; |
1901 | QFileInfo info; | 1900 | QFileInfo info; |
1902 | info.setFile( fn ); | 1901 | info.setFile( fn ); |
1903 | QString mes; | 1902 | QString mes; |
1904 | bool createbup = true; | 1903 | bool createbup = true; |
1905 | if ( info. exists() ) { | 1904 | if ( info. exists() ) { |
1906 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1905 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1907 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1906 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1908 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1907 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1909 | 0, 1 ); | 1908 | 0, 1 ); |
1910 | if ( result != 0 ) { | 1909 | if ( result != 0 ) { |
1911 | createbup = false; | 1910 | createbup = false; |
1912 | } | 1911 | } |
1913 | } | 1912 | } |
1914 | if ( createbup ) { | 1913 | if ( createbup ) { |
1915 | mView->saveCalendar( fn ); | 1914 | mView->saveCalendar( fn ); |
1916 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1915 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1917 | KOPrefs::instance()->mLastSaveFile = fn; | 1916 | KOPrefs::instance()->mLastSaveFile = fn; |
1918 | setCaption(mes); | 1917 | setCaption(mes); |
1919 | } | 1918 | } |
1920 | } | 1919 | } |
1921 | void MainWindow::loadCalendar() | 1920 | void MainWindow::loadCalendar() |
1922 | { | 1921 | { |
1923 | 1922 | ||
1924 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1923 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1925 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1924 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1926 | 1925 | ||
1927 | if ( fn == "" ) | 1926 | if ( fn == "" ) |
1928 | return; | 1927 | return; |
1929 | QFileInfo info; | 1928 | QFileInfo info; |
1930 | info.setFile( fn ); | 1929 | info.setFile( fn ); |
1931 | QString mess; | 1930 | QString mess; |
1932 | bool loadbup = true; | 1931 | bool loadbup = true; |
1933 | if ( info. exists() ) { | 1932 | if ( info. exists() ) { |
1934 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1933 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1935 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1934 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1936 | mess, | 1935 | mess, |
1937 | i18n("Load!"), i18n("Cancel"), 0, | 1936 | i18n("Load!"), i18n("Cancel"), 0, |
1938 | 0, 1 ); | 1937 | 0, 1 ); |
1939 | if ( result != 0 ) { | 1938 | if ( result != 0 ) { |
1940 | loadbup = false; | 1939 | loadbup = false; |
1941 | } | 1940 | } |
1942 | } else { | 1941 | } else { |
1943 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1942 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1944 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1943 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1945 | 0, 1 ); | 1944 | 0, 1 ); |
1946 | 1945 | ||
1947 | return; | 1946 | return; |
1948 | } | 1947 | } |
1949 | if ( loadbup ) { | 1948 | if ( loadbup ) { |
1950 | mView->openCalendar( fn ); | 1949 | mView->openCalendar( fn ); |
1951 | KOPrefs::instance()->mLastLoadFile = fn; | 1950 | KOPrefs::instance()->mLastLoadFile = fn; |
1952 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1951 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1953 | setCaption(mess); | 1952 | setCaption(mess); |
1954 | } | 1953 | } |
1955 | 1954 | ||
1956 | } | 1955 | } |
1957 | void MainWindow::quickImportIcal() | 1956 | void MainWindow::quickImportIcal() |
1958 | { | 1957 | { |
1959 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1958 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1960 | } | 1959 | } |
1961 | void MainWindow::importFile( QString fn, bool quick ) | 1960 | void MainWindow::importFile( QString fn, bool quick ) |
1962 | { | 1961 | { |
1963 | QFileInfo info; | 1962 | QFileInfo info; |
1964 | info.setFile( fn ); | 1963 | info.setFile( fn ); |
1965 | QString mess; | 1964 | QString mess; |
1966 | bool loadbup = true; | 1965 | bool loadbup = true; |
1967 | if ( !info. exists() ) { | 1966 | if ( !info. exists() ) { |
1968 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1967 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1969 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1968 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1970 | mess ); | 1969 | mess ); |
1971 | return; | 1970 | return; |
1972 | } | 1971 | } |
1973 | int result = 0; | 1972 | int result = 0; |
1974 | if ( !quick ) { | 1973 | if ( !quick ) { |
1975 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1974 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1976 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1975 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1977 | mess, | 1976 | mess, |
1978 | "Import", "Cancel", 0, | 1977 | "Import", "Cancel", 0, |
1979 | 0, 1 ); | 1978 | 0, 1 ); |
1980 | } | 1979 | } |
1981 | if ( result == 0 ) { | 1980 | if ( result == 0 ) { |
1982 | if ( mView->openCalendar( fn, true )) { | 1981 | if ( mView->openCalendar( fn, true )) { |
1983 | KOPrefs::instance()->mLastImportFile = fn; | 1982 | KOPrefs::instance()->mLastImportFile = fn; |
1984 | setCaption(i18n("Imported file successfully")); | 1983 | setCaption(i18n("Imported file successfully")); |
1985 | } else { | 1984 | } else { |
1986 | setCaption(i18n("Error importing file")); | 1985 | setCaption(i18n("Error importing file")); |
1987 | } | 1986 | } |
1988 | } | 1987 | } |
1989 | } | 1988 | } |
1990 | 1989 | ||
1991 | void MainWindow::importIcal() | 1990 | void MainWindow::importIcal() |
1992 | { | 1991 | { |
1993 | 1992 | ||
1994 | QString fn =KOPrefs::instance()->mLastImportFile; | 1993 | QString fn =KOPrefs::instance()->mLastImportFile; |
1995 | 1994 | ||
1996 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1995 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1997 | if ( fn == "" ) | 1996 | if ( fn == "" ) |
1998 | return; | 1997 | return; |
1999 | importFile( fn, true ); | 1998 | importFile( fn, true ); |
2000 | 1999 | ||
2001 | } | 2000 | } |
2002 | 2001 | ||
2003 | void MainWindow::exportVCalendar() | 2002 | void MainWindow::exportVCalendar() |
2004 | { | 2003 | { |
2005 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2004 | QString fn = KOPrefs::instance()->mLastVcalFile; |
2006 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2005 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
2007 | if ( fn == "" ) | 2006 | if ( fn == "" ) |
2008 | return; | 2007 | return; |
2009 | QFileInfo info; | 2008 | QFileInfo info; |
2010 | info.setFile( fn ); | 2009 | info.setFile( fn ); |
2011 | QString mes; | 2010 | QString mes; |
2012 | bool createbup = true; | 2011 | bool createbup = true; |
2013 | if ( info. exists() ) { | 2012 | if ( info. exists() ) { |
2014 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2013 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2015 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2014 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2016 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2015 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2017 | 0, 1 ); | 2016 | 0, 1 ); |
2018 | if ( result != 0 ) { | 2017 | if ( result != 0 ) { |
2019 | createbup = false; | 2018 | createbup = false; |
2020 | } | 2019 | } |
2021 | } | 2020 | } |
2022 | if ( createbup ) { | 2021 | if ( createbup ) { |
2023 | if ( mView->exportVCalendar( fn ) ) { | 2022 | if ( mView->exportVCalendar( fn ) ) { |
2024 | KOPrefs::instance()->mLastVcalFile = fn; | 2023 | KOPrefs::instance()->mLastVcalFile = fn; |
2025 | if ( fn.length() > 20 ) | 2024 | if ( fn.length() > 20 ) |
2026 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2025 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2027 | else | 2026 | else |
2028 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2027 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2029 | setCaption(mes); | 2028 | setCaption(mes); |
2030 | } | 2029 | } |
2031 | } | 2030 | } |
2032 | 2031 | ||
2033 | } | 2032 | } |
2034 | QString MainWindow::getPassword( ) | 2033 | QString MainWindow::getPassword( ) |
2035 | { | 2034 | { |
2036 | QString retfile = ""; | 2035 | QString retfile = ""; |
2037 | QDialog dia ( this, "input-dialog", true ); | 2036 | QDialog dia ( this, "input-dialog", true ); |
2038 | QLineEdit lab ( &dia ); | 2037 | QLineEdit lab ( &dia ); |
2039 | lab.setEchoMode( QLineEdit::Password ); | 2038 | lab.setEchoMode( QLineEdit::Password ); |
2040 | QVBoxLayout lay( &dia ); | 2039 | QVBoxLayout lay( &dia ); |
2041 | lay.setMargin(7); | 2040 | lay.setMargin(7); |
2042 | lay.setSpacing(7); | 2041 | lay.setSpacing(7); |
2043 | lay.addWidget( &lab); | 2042 | lay.addWidget( &lab); |
2044 | dia.setFixedSize( 230,50 ); | 2043 | dia.setFixedSize( 230,50 ); |
2045 | dia.setCaption( i18n("Enter password") ); | 2044 | dia.setCaption( i18n("Enter password") ); |
2046 | QPushButton pb ( "OK", &dia); | 2045 | QPushButton pb ( "OK", &dia); |
2047 | lay.addWidget( &pb ); | 2046 | lay.addWidget( &pb ); |
2048 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2047 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2049 | dia.show(); | 2048 | dia.show(); |
2050 | int res = dia.exec(); | 2049 | int res = dia.exec(); |
2051 | if ( res ) | 2050 | if ( res ) |
2052 | retfile = lab.text(); | 2051 | retfile = lab.text(); |
2053 | dia.hide(); | 2052 | dia.hide(); |
2054 | qApp->processEvents(); | 2053 | qApp->processEvents(); |
2055 | return retfile; | 2054 | return retfile; |
2056 | 2055 | ||
2057 | } | 2056 | } |
2058 | 2057 | ||
2059 | void MainWindow::enableQuick() | 2058 | void MainWindow::enableQuick() |
2060 | { | 2059 | { |
2061 | QDialog dia ( this, "input-dialog", true ); | 2060 | QDialog dia ( this, "input-dialog", true ); |
2062 | QLineEdit lab ( &dia ); | 2061 | QLineEdit lab ( &dia ); |
2063 | QVBoxLayout lay( &dia ); | 2062 | QVBoxLayout lay( &dia ); |
2064 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); | 2063 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); |
2065 | lay.setMargin(7); | 2064 | lay.setMargin(7); |
2066 | lay.setSpacing(7); | 2065 | lay.setSpacing(7); |
2067 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); | 2066 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); |
2068 | lay.addWidget( &label); | 2067 | lay.addWidget( &label); |
2069 | lay.addWidget( &lab); | 2068 | lay.addWidget( &lab); |
2070 | 2069 | ||
2071 | QLineEdit lepw ( &dia ); | 2070 | QLineEdit lepw ( &dia ); |
2072 | lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); | 2071 | lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); |
2073 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 2072 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
2074 | lay.addWidget( &label2); | 2073 | lay.addWidget( &label2); |
2075 | lay.addWidget( &lepw); | 2074 | lay.addWidget( &lepw); |
2076 | dia.setFixedSize( 230,80 ); | 2075 | dia.setFixedSize( 230,80 ); |
2077 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 2076 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
2078 | QPushButton pb ( "OK", &dia); | 2077 | QPushButton pb ( "OK", &dia); |
2079 | lay.addWidget( &pb ); | 2078 | lay.addWidget( &pb ); |
2080 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2079 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2081 | dia.show(); | 2080 | dia.show(); |
2082 | if ( ! dia.exec() ) | 2081 | if ( ! dia.exec() ) |
2083 | return; | 2082 | return; |
2084 | dia.hide(); | 2083 | dia.hide(); |
2085 | qApp->processEvents(); | 2084 | qApp->processEvents(); |
2086 | KOPrefs::instance()->mPassiveSyncPw = lepw.text(); | 2085 | KOPrefs::instance()->mPassiveSyncPw = lepw.text(); |
2087 | KOPrefs::instance()->mPassiveSyncPort = lab.text(); | 2086 | KOPrefs::instance()->mPassiveSyncPort = lab.text(); |
2088 | bool ok; | 2087 | bool ok; |
2089 | Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); | 2088 | Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); |
2090 | if ( ! ok ) { | 2089 | if ( ! ok ) { |
2091 | KMessageBox::information( this, i18n("No valid port")); | 2090 | KMessageBox::information( this, i18n("No valid port")); |
2092 | return; | 2091 | return; |
2093 | } | 2092 | } |
2094 | //qDebug("port %d ", port); | 2093 | //qDebug("port %d ", port); |
2095 | mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); | 2094 | mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); |
2096 | mServerSocket->setFileName( defaultFileName() ); | 2095 | mServerSocket->setFileName( defaultFileName() ); |
2097 | //qDebug("connected "); | 2096 | //qDebug("connected "); |
2098 | if ( !mServerSocket->ok() ) { | 2097 | if ( !mServerSocket->ok() ) { |
2099 | KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); | 2098 | KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); |
2100 | delete mServerSocket; | 2099 | delete mServerSocket; |
2101 | mServerSocket = 0; | 2100 | mServerSocket = 0; |
2102 | return; | 2101 | return; |
2103 | } | 2102 | } |
2104 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); | 2103 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); |
2105 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); | 2104 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); |
2106 | } | 2105 | } |
2107 | 2106 | ||
2108 | void MainWindow::getFile( bool success ) | 2107 | void MainWindow::getFile( bool success ) |
2109 | { | 2108 | { |
2110 | if ( ! success ) { | 2109 | if ( ! success ) { |
2111 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2110 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2112 | return; | 2111 | return; |
2113 | } | 2112 | } |
2114 | mView->watchSavedFile(); | 2113 | mView->watchSavedFile(); |
2115 | mView->openCalendar( defaultFileName() ); | 2114 | mView->openCalendar( defaultFileName() ); |
2116 | setCaption( i18n("Pi-Sync successful!") ); | 2115 | setCaption( i18n("Pi-Sync successful!") ); |
2117 | 2116 | ||
2118 | } | 2117 | } |
2119 | 2118 | ||
2120 | 2119 | ||
2121 | void MainWindow::syncPi() | 2120 | void MainWindow::syncPi() |
2122 | { | 2121 | { |
2123 | qApp->processEvents(); | 2122 | qApp->processEvents(); |
2124 | bool ok; | 2123 | bool ok; |
2125 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | 2124 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); |
2126 | if ( ! ok ) { | 2125 | if ( ! ok ) { |
2127 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 2126 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
2128 | return; | 2127 | return; |
2129 | } | 2128 | } |
2130 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); | 2129 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); |
2131 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 2130 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
2132 | setCaption( i18n("Sending request for remote file ...") ); | 2131 | setCaption( i18n("Sending request for remote file ...") ); |
2133 | commandSocket->readFile( syncFileName() ); | 2132 | commandSocket->readFile( syncFileName() ); |
2134 | } | 2133 | } |
2135 | 2134 | ||
2136 | void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) | 2135 | void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) |
2137 | { | 2136 | { |
2138 | qDebug("MainWindow::deleteCommandSocket %d", state); | 2137 | qDebug("MainWindow::deleteCommandSocket %d", state); |
2139 | 2138 | ||
2140 | //enum { success, errorW, errorR, quiet }; | 2139 | //enum { success, errorW, errorR, quiet }; |
2141 | if ( state == KCommandSocket::errorR ) { | 2140 | if ( state == KCommandSocket::errorR ) { |
2142 | setCaption( i18n("ERROR: Receiving remote file failed.") ); | 2141 | setCaption( i18n("ERROR: Receiving remote file failed.") ); |
2143 | delete s; | 2142 | delete s; |
2144 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | 2143 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); |
2145 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 2144 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
2146 | commandSocket->sendStop(); | 2145 | commandSocket->sendStop(); |
2147 | return; | 2146 | return; |
2148 | 2147 | ||
2149 | } else if ( state == KCommandSocket::errorW ) { | 2148 | } else if ( state == KCommandSocket::errorW ) { |
2150 | setCaption( i18n("ERROR:Writing back file failed.") ); | 2149 | setCaption( i18n("ERROR:Writing back file failed.") ); |
2151 | 2150 | ||
2152 | } else if ( state == KCommandSocket::successR ) { | 2151 | } else if ( state == KCommandSocket::successR ) { |
2153 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 2152 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
2154 | 2153 | ||
2155 | } else if ( state == KCommandSocket::successW ) { | 2154 | } else if ( state == KCommandSocket::successW ) { |
2156 | setCaption( i18n("Pi-Sync succesful!") ); | 2155 | setCaption( i18n("Pi-Sync succesful!") ); |
2157 | } | 2156 | } |
2158 | 2157 | ||
2159 | delete s; | 2158 | delete s; |
2160 | } | 2159 | } |
2161 | 2160 | ||
2162 | void MainWindow::readFileFromSocket() | 2161 | void MainWindow::readFileFromSocket() |
2163 | { | 2162 | { |
2164 | QString fileName = syncFileName(); | 2163 | QString fileName = syncFileName(); |
2165 | setCaption( i18n("Remote file saved to temp file.") ); | 2164 | setCaption( i18n("Remote file saved to temp file.") ); |
2166 | if ( ! syncWithFile( fileName , true ) ) { | 2165 | if ( ! syncWithFile( fileName , true ) ) { |
2167 | setCaption( i18n("Syncing failed.") ); | 2166 | setCaption( i18n("Syncing failed.") ); |
2168 | qDebug("Syncing failed "); | 2167 | qDebug("Syncing failed "); |
2169 | return; | 2168 | return; |
2170 | } | 2169 | } |
2171 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | 2170 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); |
2172 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 2171 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
2173 | if ( KOPrefs::instance()->mWriteBackFile ) | 2172 | if ( KOPrefs::instance()->mWriteBackFile ) |
2174 | commandSocket->writeFile( fileName ); | 2173 | commandSocket->writeFile( fileName ); |
2175 | else { | 2174 | else { |
2176 | commandSocket->sendStop(); | 2175 | commandSocket->sendStop(); |
2177 | setCaption( i18n("Pi-Sync succesful!") ); | 2176 | setCaption( i18n("Pi-Sync succesful!") ); |
2178 | } | 2177 | } |
2179 | } | 2178 | } |
2180 | 2179 | ||
2181 | void MainWindow::syncLocalFile() | 2180 | void MainWindow::syncLocalFile() |
2182 | { | 2181 | { |
2183 | 2182 | ||
2184 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 2183 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; |
2185 | 2184 | ||
2186 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2185 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2187 | if ( fn == "" ) | 2186 | if ( fn == "" ) |
2188 | return; | 2187 | return; |
2189 | //mView->setSyncDevice("local-file" ); | 2188 | //mView->setSyncDevice("local-file" ); |
2190 | if ( syncWithFile( fn, false ) ) { | 2189 | if ( syncWithFile( fn, false ) ) { |
2191 | // Event* e = mView->getLastSyncEvent(); | 2190 | // Event* e = mView->getLastSyncEvent(); |
2192 | // e->setReadOnly( false ); | 2191 | // e->setReadOnly( false ); |
2193 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2192 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2194 | // e->setReadOnly( true ); | 2193 | // e->setReadOnly( true ); |
2195 | } | 2194 | } |
2196 | 2195 | ||
2197 | } | 2196 | } |
2198 | 2197 | ||
2199 | bool MainWindow::syncWithFile( QString fn , bool quick ) | 2198 | bool MainWindow::syncWithFile( QString fn , bool quick ) |
2200 | { | 2199 | { |
2201 | bool ret = false; | 2200 | bool ret = false; |
2202 | QFileInfo info; | 2201 | QFileInfo info; |
2203 | info.setFile( fn ); | 2202 | info.setFile( fn ); |
2204 | QString mess; | 2203 | QString mess; |
2205 | bool loadbup = true; | 2204 | bool loadbup = true; |
2206 | if ( !info. exists() ) { | 2205 | if ( !info. exists() ) { |
2207 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2206 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2208 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2207 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2209 | mess ); | 2208 | mess ); |
2210 | return ret; | 2209 | return ret; |
2211 | } | 2210 | } |
2212 | int result = 0; | 2211 | int result = 0; |
2213 | if ( !quick ) { | 2212 | if ( !quick ) { |
2214 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2213 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2215 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2214 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2216 | mess, | 2215 | mess, |
2217 | i18n("Sync"), i18n("Cancel"), 0, | 2216 | i18n("Sync"), i18n("Cancel"), 0, |
2218 | 0, 1 ); | 2217 | 0, 1 ); |
2219 | if ( result ) | 2218 | if ( result ) |
2220 | return false; | 2219 | return false; |
2221 | } | 2220 | } |
2222 | if ( KOPrefs::instance()->mAskForPreferences ) | 2221 | if ( KOPrefs::instance()->mAskForPreferences ) |
2223 | mView->edit_sync_options(); | 2222 | mView->edit_sync_options(); |
2224 | if ( result == 0 ) { | 2223 | if ( result == 0 ) { |
2225 | //qDebug("Now sycing ... "); | 2224 | //qDebug("Now sycing ... "); |
2226 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) | 2225 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) |
2227 | setCaption( i18n("Synchronization successful") ); | 2226 | setCaption( i18n("Synchronization successful") ); |
2228 | else | 2227 | else |
2229 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 2228 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
2230 | if ( ! quick ) | 2229 | if ( ! quick ) |
2231 | KOPrefs::instance()->mLastSyncedLocalFile = fn; | 2230 | KOPrefs::instance()->mLastSyncedLocalFile = fn; |
2232 | slotModifiedChanged( true ); | 2231 | slotModifiedChanged( true ); |
2233 | } | 2232 | } |
2234 | return ret; | 2233 | return ret; |
2235 | } | 2234 | } |
2236 | void MainWindow::quickSyncLocalFile() | 2235 | void MainWindow::quickSyncLocalFile() |
2237 | { | 2236 | { |
2238 | //mView->setSyncDevice("local-file" ); | 2237 | //mView->setSyncDevice("local-file" ); |
2239 | //qDebug("quickSyncLocalFile() "); | 2238 | //qDebug("quickSyncLocalFile() "); |
2240 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 2239 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
2241 | // Event* e = mView->getLastSyncEvent(); | 2240 | // Event* e = mView->getLastSyncEvent(); |
2242 | // e->setReadOnly( false ); | 2241 | // e->setReadOnly( false ); |
2243 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2242 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2244 | // e->setReadOnly( true ); | 2243 | // e->setReadOnly( true ); |
2245 | 2244 | ||
2246 | } | 2245 | } |
2247 | } | 2246 | } |
2248 | 2247 | ||
2249 | void MainWindow::confSync() | 2248 | void MainWindow::confSync() |
2250 | { | 2249 | { |
2251 | mView->confSync(); | 2250 | mView->confSync(); |
2252 | fillSyncMenu(); | 2251 | fillSyncMenu(); |
2253 | } | 2252 | } |
2254 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) | 2253 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) |
2255 | { | 2254 | { |
2256 | QString question; | 2255 | QString question; |
2257 | if ( ask ) { | 2256 | if ( ask ) { |
2258 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 2257 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
2259 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2258 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2260 | question, | 2259 | question, |
2261 | i18n("Yes"), i18n("No"), | 2260 | i18n("Yes"), i18n("No"), |
2262 | 0, 0 ) != 0 ) | 2261 | 0, 0 ) != 0 ) |
2263 | return; | 2262 | return; |
2264 | } | 2263 | } |
2265 | QString command = prof->getPreSyncCommand(); | 2264 | QString command = prof->getPreSyncCommand(); |
2266 | int fi; | 2265 | int fi; |
2267 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2266 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2268 | QString pwd = getPassword(); | 2267 | QString pwd = getPassword(); |
2269 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2268 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2270 | 2269 | ||
2271 | } | 2270 | } |
2272 | int maxlen = 30; | 2271 | int maxlen = 30; |
2273 | if ( QApplication::desktop()->width() > 320 ) | 2272 | if ( QApplication::desktop()->width() > 320 ) |
2274 | maxlen += 25; | 2273 | maxlen += 25; |
2275 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2274 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2276 | int fileSize = 0; | 2275 | int fileSize = 0; |
2277 | int result = system ( command ); | 2276 | int result = system ( command ); |
2278 | // 0 : okay | 2277 | // 0 : okay |
2279 | // 256: no such file or dir | 2278 | // 256: no such file or dir |
2280 | // | 2279 | // |
2281 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2280 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2282 | if ( result != 0 ) { | 2281 | if ( result != 0 ) { |
2283 | int len = maxlen; | 2282 | int len = maxlen; |
2284 | while ( len < command.length() ) { | 2283 | while ( len < command.length() ) { |
2285 | command.insert( len , "\n" ); | 2284 | command.insert( len , "\n" ); |
2286 | len += maxlen +2; | 2285 | len += maxlen +2; |
2287 | } | 2286 | } |
2288 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2287 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2289 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2288 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2290 | question, | 2289 | question, |
2291 | i18n("Okay!")) ; | 2290 | i18n("Okay!")) ; |
2292 | setCaption ("KO/Pi"); | 2291 | setCaption ("KO/Pi"); |
2293 | return; | 2292 | return; |
2294 | } | 2293 | } |
2295 | setCaption ( i18n( "Copying succeed." ) ); | 2294 | setCaption ( i18n( "Copying succeed." ) ); |
2296 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2295 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2297 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { | 2296 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { |
2298 | // Event* e = mView->getLastSyncEvent(); | 2297 | // Event* e = mView->getLastSyncEvent(); |
2299 | // e->setReadOnly( false ); | 2298 | // e->setReadOnly( false ); |
2300 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2299 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2301 | // e->setReadOnly( true ); | 2300 | // e->setReadOnly( true ); |
2302 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2301 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2303 | command = prof->getPostSyncCommand(); | 2302 | command = prof->getPostSyncCommand(); |
2304 | int fi; | 2303 | int fi; |
2305 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2304 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2306 | QString pwd = getPassword(); | 2305 | QString pwd = getPassword(); |
2307 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2306 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2308 | 2307 | ||
2309 | } | 2308 | } |
2310 | setCaption ( i18n( "Writing back file ..." ) ); | 2309 | setCaption ( i18n( "Writing back file ..." ) ); |
2311 | result = system ( command ); | 2310 | result = system ( command ); |
2312 | qDebug("KO: Writing back file result: %d ", result); | 2311 | qDebug("KO: Writing back file result: %d ", result); |
2313 | if ( result != 0 ) { | 2312 | if ( result != 0 ) { |
2314 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2313 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2315 | return; | 2314 | return; |
2316 | } else { | 2315 | } else { |
2317 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2316 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2318 | } | 2317 | } |
2319 | } | 2318 | } |
2320 | } | 2319 | } |
2321 | return; | 2320 | return; |
2322 | } | 2321 | } |
2323 | 2322 | ||
2324 | void MainWindow::syncSharp() | 2323 | void MainWindow::syncSharp() |
2325 | { | 2324 | { |
2326 | if ( mCalendarModifiedFlag ) | 2325 | if ( mCalendarModifiedFlag ) |
2327 | save(); | 2326 | save(); |
2328 | mView->syncSharp(); | 2327 | mView->syncSharp(); |
2329 | slotModifiedChanged( true ); | 2328 | slotModifiedChanged( true ); |
2330 | 2329 | ||
2331 | } | 2330 | } |
2332 | void MainWindow::syncPhone() | 2331 | void MainWindow::syncPhone() |
2333 | { | 2332 | { |
2334 | if ( mCalendarModifiedFlag ) | 2333 | if ( mCalendarModifiedFlag ) |
2335 | save(); | 2334 | save(); |
2336 | mView->syncPhone(); | 2335 | mView->syncPhone(); |
2337 | slotModifiedChanged( true ); | 2336 | slotModifiedChanged( true ); |
2338 | 2337 | ||
2339 | } | 2338 | } |
2340 | 2339 | ||
2341 | void MainWindow::printSel( ) | 2340 | void MainWindow::printSel( ) |
2342 | { | 2341 | { |
2343 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2342 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2344 | } | 2343 | } |
2345 | 2344 | ||
2346 | void MainWindow::printCal() | 2345 | void MainWindow::printCal() |
2347 | { | 2346 | { |
2348 | mView->print();//mCp->showDialog(); | 2347 | mView->print();//mCp->showDialog(); |
2349 | } | 2348 | } |
2350 | 2349 | ||
2351 | 2350 | ||
2352 | 2351 | ||
2353 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 2352 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
2354 | { | 2353 | { |
2355 | mPassWord = pw; | 2354 | mPassWord = pw; |
2356 | mSocket = 0; | 2355 | mSocket = 0; |
2357 | mSyncActionDialog = 0; | 2356 | mSyncActionDialog = 0; |
2358 | blockRC = false; | 2357 | blockRC = false; |
2359 | }; | 2358 | }; |
2360 | 2359 | ||
2361 | void KServerSocket::newConnection ( int socket ) | 2360 | void KServerSocket::newConnection ( int socket ) |
2362 | { | 2361 | { |
2363 | // qDebug("KServerSocket:New connection %d ", socket); | 2362 | // qDebug("KServerSocket:New connection %d ", socket); |
2364 | if ( mSocket ) { | 2363 | if ( mSocket ) { |
2365 | qDebug("KServerSocket::newConnection Socket deleted! "); | 2364 | qDebug("KServerSocket::newConnection Socket deleted! "); |
2366 | delete mSocket; | 2365 | delete mSocket; |
2367 | mSocket = 0; | 2366 | mSocket = 0; |
2368 | } | 2367 | } |
2369 | mSocket = new QSocket( this ); | 2368 | mSocket = new QSocket( this ); |
2370 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 2369 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
2371 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 2370 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
2372 | mSocket->setSocket( socket ); | 2371 | mSocket->setSocket( socket ); |
2373 | } | 2372 | } |
2374 | 2373 | ||
2375 | void KServerSocket::discardClient() | 2374 | void KServerSocket::discardClient() |
2376 | { | 2375 | { |
2377 | //qDebug(" KServerSocket::discardClient()"); | 2376 | //qDebug(" KServerSocket::discardClient()"); |
2378 | if ( mSocket ) { | 2377 | if ( mSocket ) { |
2379 | delete mSocket; | 2378 | delete mSocket; |
2380 | mSocket = 0; | 2379 | mSocket = 0; |
2381 | } | 2380 | } |
2382 | //emit endConnect(); | 2381 | //emit endConnect(); |
2383 | } | 2382 | } |
2384 | void KServerSocket::readClient() | 2383 | void KServerSocket::readClient() |
2385 | { | 2384 | { |
2386 | if ( blockRC ) | 2385 | if ( blockRC ) |
2387 | return; | 2386 | return; |
2388 | if ( mSocket == 0 ) { | 2387 | if ( mSocket == 0 ) { |
2389 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 2388 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
2390 | return; | 2389 | return; |
2391 | } | 2390 | } |
2392 | qDebug("KServerSocket readClient()"); | 2391 | qDebug("KServerSocket readClient()"); |
2393 | if ( mSocket->canReadLine() ) { | 2392 | if ( mSocket->canReadLine() ) { |
2394 | QString line = mSocket->readLine(); | 2393 | QString line = mSocket->readLine(); |
2395 | qDebug("KServerSocket readline: %s ", line.latin1()); | 2394 | qDebug("KServerSocket readline: %s ", line.latin1()); |
2396 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 2395 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
2397 | if ( tokens[0] == "GET" ) { | 2396 | if ( tokens[0] == "GET" ) { |
2398 | if ( tokens[1] == mPassWord ) | 2397 | if ( tokens[1] == mPassWord ) |
2399 | //emit sendFile( mSocket ); | 2398 | //emit sendFile( mSocket ); |
2400 | send_file(); | 2399 | send_file(); |
2401 | else { | 2400 | else { |
2402 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); | 2401 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); |
2403 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 2402 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
2404 | } | 2403 | } |
2405 | } | 2404 | } |
2406 | if ( tokens[0] == "PUT" ) { | 2405 | if ( tokens[0] == "PUT" ) { |
2407 | if ( tokens[1] == mPassWord ) { | 2406 | if ( tokens[1] == mPassWord ) { |
2408 | //emit getFile( mSocket ); | 2407 | //emit getFile( mSocket ); |
2409 | blockRC = true; | 2408 | blockRC = true; |
2410 | get_file(); | 2409 | get_file(); |
2411 | } | 2410 | } |
2412 | else { | 2411 | else { |
2413 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); | 2412 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); |
2414 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 2413 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
2415 | } | 2414 | } |
2416 | } | 2415 | } |
2417 | if ( tokens[0] == "STOP" ) { | 2416 | if ( tokens[0] == "STOP" ) { |
2418 | //emit endConnect(); | 2417 | //emit endConnect(); |
2419 | end_connect(); | 2418 | end_connect(); |
2420 | } | 2419 | } |
2421 | } | 2420 | } |
2422 | } | 2421 | } |
2423 | void KServerSocket::end_connect() | 2422 | void KServerSocket::end_connect() |
2424 | { | 2423 | { |
2425 | delete mSyncActionDialog; | 2424 | delete mSyncActionDialog; |
2426 | mSyncActionDialog = 0; | 2425 | mSyncActionDialog = 0; |
2427 | } | 2426 | } |
2428 | void KServerSocket::send_file() | 2427 | void KServerSocket::send_file() |
2429 | { | 2428 | { |
2430 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 2429 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
2431 | if ( mSyncActionDialog ) | 2430 | if ( mSyncActionDialog ) |
2432 | delete mSyncActionDialog; | 2431 | delete mSyncActionDialog; |
2433 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 2432 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
2434 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 2433 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
2435 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 2434 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
2436 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 2435 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
2437 | lay->addWidget( label); | 2436 | lay->addWidget( label); |
2438 | lay->setMargin(7); | 2437 | lay->setMargin(7); |
2439 | lay->setSpacing(7); | 2438 | lay->setSpacing(7); |
2440 | mSyncActionDialog->setFixedSize( 230, 120); | 2439 | mSyncActionDialog->setFixedSize( 230, 120); |
2441 | mSyncActionDialog->show(); | 2440 | mSyncActionDialog->show(); |
2442 | qDebug("KSS::saving ... "); | 2441 | qDebug("KSS::saving ... "); |
2443 | emit saveFile(); | 2442 | emit saveFile(); |
2444 | qApp->processEvents(); | 2443 | qApp->processEvents(); |
2445 | QString fileName = mFileName; | 2444 | QString fileName = mFileName; |
2446 | QFile file( fileName ); | 2445 | QFile file( fileName ); |
2447 | if (!file.open( IO_ReadOnly ) ) { | 2446 | if (!file.open( IO_ReadOnly ) ) { |
2448 | delete mSyncActionDialog; | 2447 | delete mSyncActionDialog; |
2449 | mSyncActionDialog = 0; | 2448 | mSyncActionDialog = 0; |
2450 | qDebug("KSS::error open file "); | 2449 | qDebug("KSS::error open file "); |
2451 | mSocket->close(); | 2450 | mSocket->close(); |
2452 | if ( mSocket->state() == QSocket::Idle ) | 2451 | if ( mSocket->state() == QSocket::Idle ) |
2453 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 2452 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
2454 | return ; | 2453 | return ; |
2455 | 2454 | ||
2456 | } | 2455 | } |
2457 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 2456 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
2458 | QTextStream ts( &file ); | 2457 | QTextStream ts( &file ); |
2459 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2458 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2460 | QTextStream os( mSocket ); | 2459 | QTextStream os( mSocket ); |
2461 | os.setCodec( QTextCodec::codecForName("utf8") ); | 2460 | os.setCodec( QTextCodec::codecForName("utf8") ); |
2462 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 2461 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
2463 | while ( ! ts.atEnd() ) { | 2462 | while ( ! ts.atEnd() ) { |
2464 | os << ts.readLine() << "\n"; | 2463 | os << ts.readLine() << "\n"; |
2465 | } | 2464 | } |
2466 | //os << ts.read(); | 2465 | //os << ts.read(); |
2467 | file.close(); | 2466 | file.close(); |
2468 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 2467 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
2469 | mSocket->close(); | 2468 | mSocket->close(); |
2470 | if ( mSocket->state() == QSocket::Idle ) | 2469 | if ( mSocket->state() == QSocket::Idle ) |
2471 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 2470 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
2472 | } | 2471 | } |
2473 | void KServerSocket::get_file() | 2472 | void KServerSocket::get_file() |
2474 | { | 2473 | { |
2475 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 2474 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
2476 | 2475 | ||
2477 | piTime.start(); | 2476 | piTime.start(); |
2478 | piFileString = ""; | 2477 | piFileString = ""; |
2479 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 2478 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
2480 | } | 2479 | } |
2481 | 2480 | ||
2482 | 2481 | ||
2483 | void KServerSocket::readBackFileFromSocket() | 2482 | void KServerSocket::readBackFileFromSocket() |
2484 | { | 2483 | { |
2485 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 2484 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
2486 | while ( mSocket->canReadLine () ) { | 2485 | while ( mSocket->canReadLine () ) { |
2487 | piTime.restart(); | 2486 | piTime.restart(); |
2488 | QString line = mSocket->readLine (); | 2487 | QString line = mSocket->readLine (); |
2489 | piFileString += line; | 2488 | piFileString += line; |
2490 | //qDebug("readline: %s ", line.latin1()); | 2489 | //qDebug("readline: %s ", line.latin1()); |
2491 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 2490 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
2492 | 2491 | ||
2493 | } | 2492 | } |
2494 | if ( piTime.elapsed () < 3000 ) { | 2493 | if ( piTime.elapsed () < 3000 ) { |
2495 | // wait for more | 2494 | // wait for more |
2496 | //qDebug("waitformore "); | 2495 | //qDebug("waitformore "); |
2497 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 2496 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
2498 | return; | 2497 | return; |
2499 | } | 2498 | } |
2500 | QString fileName = mFileName; | 2499 | QString fileName = mFileName; |
2501 | QFile file ( fileName ); | 2500 | QFile file ( fileName ); |
2502 | if (!file.open( IO_WriteOnly ) ) { | 2501 | if (!file.open( IO_WriteOnly ) ) { |
2503 | delete mSyncActionDialog; | 2502 | delete mSyncActionDialog; |
2504 | mSyncActionDialog = 0; | 2503 | mSyncActionDialog = 0; |
2505 | qDebug("error open cal file "); | 2504 | qDebug("error open cal file "); |
2506 | piFileString = ""; | 2505 | piFileString = ""; |
2507 | emit file_received( false ); | 2506 | emit file_received( false ); |
2508 | blockRC = false; | 2507 | blockRC = false; |
2509 | return ; | 2508 | return ; |
2510 | 2509 | ||
2511 | } | 2510 | } |
2512 | 2511 | ||
2513 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 2512 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
2514 | QTextStream ts ( &file ); | 2513 | QTextStream ts ( &file ); |
2515 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2514 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2516 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 2515 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
2517 | ts << piFileString; | 2516 | ts << piFileString; |
2518 | mSocket->close(); | 2517 | mSocket->close(); |
2519 | if ( mSocket->state() == QSocket::Idle ) | 2518 | if ( mSocket->state() == QSocket::Idle ) |
2520 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 2519 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
2521 | file.close(); | 2520 | file.close(); |
2522 | delete mSyncActionDialog; | 2521 | delete mSyncActionDialog; |
2523 | mSyncActionDialog = 0; | 2522 | mSyncActionDialog = 0; |
2524 | piFileString = ""; | 2523 | piFileString = ""; |
2525 | blockRC = false; | 2524 | blockRC = false; |
2526 | emit file_received( true ); | 2525 | emit file_received( true ); |
2527 | 2526 | ||
2528 | } | 2527 | } |
2529 | 2528 | ||
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h index 01c57a3..6f92919 100644 --- a/libkdepim/kpimprefs.h +++ b/libkdepim/kpimprefs.h | |||
@@ -1,85 +1,69 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
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 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef KPIMPREFS_H | 31 | #ifndef KPIMPREFS_H |
32 | #define KPIMPREFS_H | 32 | #define KPIMPREFS_H |
33 | 33 | ||
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | 35 | ||
36 | #include "kprefs.h" | 36 | #include "kprefs.h" |
37 | 37 | ||
38 | class KPimPrefs : public KPrefs | 38 | class KPimPrefs : public KPrefs |
39 | { | 39 | { |
40 | public: | 40 | public: |
41 | 41 | ||
42 | KPimPrefs( const QString &name = QString::null ); | 42 | KPimPrefs( const QString &name = QString::null ); |
43 | 43 | ||
44 | virtual ~KPimPrefs(); | 44 | virtual ~KPimPrefs(); |
45 | 45 | ||
46 | /** Set preferences to default values */ | 46 | /** Set preferences to default values */ |
47 | void usrSetDefaults(); | 47 | void usrSetDefaults(); |
48 | 48 | ||
49 | /** Read preferences from config file */ | 49 | /** Read preferences from config file */ |
50 | void usrReadConfig(); | 50 | void usrReadConfig(); |
51 | 51 | ||
52 | /** Write preferences to config file */ | 52 | /** Write preferences to config file */ |
53 | void usrWriteConfig(); | 53 | void usrWriteConfig(); |
54 | 54 | ||
55 | 55 | ||
56 | public: | 56 | public: |
57 | QStringList mCustomCategories; | 57 | QStringList mCustomCategories; |
58 | 58 | ||
59 | // sync stuff | 59 | |
60 | QString mLocalMachineName; | ||
61 | QStringList mExternSyncProfiles; | ||
62 | QStringList mSyncProfileNames; | ||
63 | bool mAskForPreferences; | ||
64 | bool mShowSyncSummary; | ||
65 | bool mShowSyncEvents; | ||
66 | bool mShowTodoInAgenda; | ||
67 | bool mWriteBackExistingOnly; | ||
68 | int mSyncAlgoPrefs; | ||
69 | int mRingSyncAlgoPrefs; | ||
70 | bool mWriteBackFile; | ||
71 | int mWriteBackInFuture; | ||
72 | QString mPhoneDevice; | ||
73 | QString mPhoneConnection; | ||
74 | QString mPhoneModel; | ||
75 | QString mLastSyncedLocalFile; // save! | ||
76 | 60 | ||
77 | 61 | ||
78 | protected: | 62 | protected: |
79 | virtual void setCategoryDefaults(); | 63 | virtual void setCategoryDefaults(); |
80 | 64 | ||
81 | 65 | ||
82 | 66 | ||
83 | }; | 67 | }; |
84 | 68 | ||
85 | #endif | 69 | #endif |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 07e6761..c0cc840 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,665 +1,663 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | 35 | ||
36 | #include <qdir.h> | 36 | #include <qdir.h> |
37 | #include <qprogressbar.h> | 37 | #include <qprogressbar.h> |
38 | #include <qpopupmenu.h> | 38 | #include <qpopupmenu.h> |
39 | #include <qpushbutton.h> | 39 | #include <qpushbutton.h> |
40 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
41 | #include <qbuttongroup.h> | 41 | #include <qbuttongroup.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qapplication.h> | 44 | #include <qapplication.h> |
45 | #include <qlineedit.h> | 45 | #include <qlineedit.h> |
46 | #include <qdialog.h> | 46 | #include <qdialog.h> |
47 | #include <qlayout.h> | 47 | #include <qlayout.h> |
48 | 48 | ||
49 | #include <klocale.h> | 49 | #include <klocale.h> |
50 | #include <kglobal.h> | 50 | #include <kglobal.h> |
51 | #include <kconfig.h> | 51 | #include <kconfig.h> |
52 | #include <kfiledialog.h> | 52 | #include <kfiledialog.h> |
53 | 53 | ||
54 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 54 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
55 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs), mSyncMenu(syncmenu) | 55 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) |
56 | { | 56 | { |
57 | bar = new QProgressBar ( 1, 0 ); | 57 | bar = new QProgressBar ( 1, 0 ); |
58 | bar->setCaption (""); | 58 | bar->setCaption (""); |
59 | 59 | ||
60 | int w = 300; | 60 | int w = 300; |
61 | if ( QApplication::desktop()->width() < 320 ) | 61 | if ( QApplication::desktop()->width() < 320 ) |
62 | w = 220; | 62 | w = 220; |
63 | int h = bar->sizeHint().height() ; | 63 | int h = bar->sizeHint().height() ; |
64 | int dw = QApplication::desktop()->width(); | 64 | int dw = QApplication::desktop()->width(); |
65 | int dh = QApplication::desktop()->height(); | 65 | int dh = QApplication::desktop()->height(); |
66 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 66 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
67 | 67 | ||
68 | } | 68 | } |
69 | 69 | ||
70 | KSyncManager::~KSyncManager() | 70 | KSyncManager::~KSyncManager() |
71 | { | 71 | { |
72 | delete bar; | 72 | delete bar; |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | void KSyncManager::fillSyncMenu() | 76 | void KSyncManager::fillSyncMenu() |
77 | { | 77 | { |
78 | if ( mSyncMenu->count() ) | 78 | if ( mSyncMenu->count() ) |
79 | mSyncMenu->clear(); | 79 | mSyncMenu->clear(); |
80 | 80 | ||
81 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 81 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
82 | mSyncMenu->insertSeparator(); | 82 | mSyncMenu->insertSeparator(); |
83 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 83 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
84 | mSyncMenu->insertSeparator(); | 84 | mSyncMenu->insertSeparator(); |
85 | 85 | ||
86 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 86 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
87 | config.setGroup("General"); | 87 | config.setGroup("General"); |
88 | QStringList prof = config.readListEntry("SyncProfileNames"); | 88 | QStringList prof = config.readListEntry("SyncProfileNames"); |
89 | mPrefs->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 89 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
90 | if ( prof.count() < 3 ) { | 90 | if ( prof.count() < 3 ) { |
91 | prof.clear(); | 91 | prof.clear(); |
92 | prof << i18n("Sharp_DTM"); | 92 | prof << i18n("Sharp_DTM"); |
93 | prof << i18n("Local_file"); | 93 | prof << i18n("Local_file"); |
94 | prof << i18n("Last_file"); | 94 | prof << i18n("Last_file"); |
95 | KSyncProfile* temp = new KSyncProfile (); | 95 | KSyncProfile* temp = new KSyncProfile (); |
96 | temp->setName( prof[0] ); | 96 | temp->setName( prof[0] ); |
97 | temp->writeConfig(&config); | 97 | temp->writeConfig(&config); |
98 | temp->setName( prof[1] ); | 98 | temp->setName( prof[1] ); |
99 | temp->writeConfig(&config); | 99 | temp->writeConfig(&config); |
100 | temp->setName( prof[2] ); | 100 | temp->setName( prof[2] ); |
101 | temp->writeConfig(&config); | 101 | temp->writeConfig(&config); |
102 | config.setGroup("General"); | 102 | config.setGroup("General"); |
103 | config.writeEntry("SyncProfileNames",prof); | 103 | config.writeEntry("SyncProfileNames",prof); |
104 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 104 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
105 | config.sync(); | 105 | config.sync(); |
106 | delete temp; | 106 | delete temp; |
107 | } | 107 | } |
108 | mPrefs->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 108 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
109 | mPrefs->mSyncProfileNames = prof; | 109 | mSyncProfileNames = prof; |
110 | unsigned int i; | 110 | unsigned int i; |
111 | for ( i = 0; i < prof.count(); ++i ) { | 111 | for ( i = 0; i < prof.count(); ++i ) { |
112 | mSyncMenu->insertItem( prof[i], 1000+i ); | 112 | mSyncMenu->insertItem( prof[i], 1000+i ); |
113 | if ( i == 2 ) | 113 | if ( i == 2 ) |
114 | mSyncMenu->insertSeparator(); | 114 | mSyncMenu->insertSeparator(); |
115 | } | 115 | } |
116 | QDir app_dir; | 116 | QDir app_dir; |
117 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 117 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
118 | if ( mTargetApp == PWMPI) { | 118 | if ( mTargetApp == PWMPI) { |
119 | mSyncMenu->removeItem( 1000 ); | 119 | mSyncMenu->removeItem( 1000 ); |
120 | } | 120 | } |
121 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 121 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
122 | mSyncMenu->setItemEnabled( 1000, false ); | 122 | mSyncMenu->setItemEnabled( 1000, false ); |
123 | } | 123 | } |
124 | //probaly useless | ||
125 | //mView->setupExternSyncProfiles(); | ||
126 | } | 124 | } |
127 | 125 | ||
128 | void KSyncManager::slotSyncMenu( int action ) | 126 | void KSyncManager::slotSyncMenu( int action ) |
129 | { | 127 | { |
130 | //qDebug("syncaction %d ", action); | 128 | //qDebug("syncaction %d ", action); |
131 | if ( action == 0 ) { | 129 | if ( action == 0 ) { |
132 | 130 | ||
133 | // seems to be a Qt2 event handling bug | 131 | // seems to be a Qt2 event handling bug |
134 | // syncmenu.clear causes a segfault at first time | 132 | // syncmenu.clear causes a segfault at first time |
135 | // when we call it after the main event loop, it is ok | 133 | // when we call it after the main event loop, it is ok |
136 | // same behaviour when calling OM/Pi via QCOP for the first time | 134 | // same behaviour when calling OM/Pi via QCOP for the first time |
137 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 135 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
138 | //confSync(); | 136 | //confSync(); |
139 | 137 | ||
140 | return; | 138 | return; |
141 | } | 139 | } |
142 | if ( action == 1 ) { | 140 | if ( action == 1 ) { |
143 | multiSync( true ); | 141 | multiSync( true ); |
144 | return; | 142 | return; |
145 | } | 143 | } |
146 | 144 | ||
147 | if (blockSave()) | 145 | if (blockSave()) |
148 | return; | 146 | return; |
149 | 147 | ||
150 | setBlockSave(true); | 148 | setBlockSave(true); |
151 | 149 | ||
152 | mCurrentSyncProfile = action - 1000 ; | 150 | mCurrentSyncProfile = action - 1000 ; |
153 | mCurrentSyncDevice = mPrefs->mSyncProfileNames[mCurrentSyncProfile] ; | 151 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
154 | mCurrentSyncName = mPrefs->mLocalMachineName ; | 152 | mCurrentSyncName = mLocalMachineName ; |
155 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 153 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
156 | KSyncProfile* temp = new KSyncProfile (); | 154 | KSyncProfile* temp = new KSyncProfile (); |
157 | temp->setName(mPrefs->mSyncProfileNames[mCurrentSyncProfile]); | 155 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
158 | temp->readConfig(&config); | 156 | temp->readConfig(&config); |
159 | mPrefs->mAskForPreferences = temp->getAskForPreferences(); | 157 | mAskForPreferences = temp->getAskForPreferences(); |
160 | mPrefs->mSyncAlgoPrefs = temp->getSyncPrefs(); | 158 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
161 | mPrefs->mWriteBackFile = temp->getWriteBackFile(); | 159 | mWriteBackFile = temp->getWriteBackFile(); |
162 | mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 160 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
163 | mPrefs->mWriteBackInFuture = 0; | 161 | mWriteBackInFuture = 0; |
164 | if ( temp->getWriteBackFuture() ) | 162 | if ( temp->getWriteBackFuture() ) |
165 | mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 163 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
166 | mPrefs->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 164 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
167 | if ( action == 1000 ) { | 165 | if ( action == 1000 ) { |
168 | syncSharp(); | 166 | syncSharp(); |
169 | 167 | ||
170 | } else if ( action == 1001 ) { | 168 | } else if ( action == 1001 ) { |
171 | syncLocalFile(); | 169 | syncLocalFile(); |
172 | 170 | ||
173 | } else if ( action == 1002 ) { | 171 | } else if ( action == 1002 ) { |
174 | quickSyncLocalFile(); | 172 | quickSyncLocalFile(); |
175 | 173 | ||
176 | } else if ( action >= 1003 ) { | 174 | } else if ( action >= 1003 ) { |
177 | if ( temp->getIsLocalFileSync() ) { | 175 | if ( temp->getIsLocalFileSync() ) { |
178 | switch(mTargetApp) | 176 | switch(mTargetApp) |
179 | { | 177 | { |
180 | case (KAPI): | 178 | case (KAPI): |
181 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 179 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
182 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 180 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
183 | break; | 181 | break; |
184 | case (KOPI): | 182 | case (KOPI): |
185 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 183 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
186 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 184 | mLastSyncedLocalFile = temp->getRemoteFileName(); |
187 | break; | 185 | break; |
188 | case (PWMPI): | 186 | case (PWMPI): |
189 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 187 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
190 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 188 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
191 | break; | 189 | break; |
192 | default: | 190 | default: |
193 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 191 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
194 | break; | 192 | break; |
195 | 193 | ||
196 | } | 194 | } |
197 | } else { | 195 | } else { |
198 | if ( temp->getIsPhoneSync() ) { | 196 | if ( temp->getIsPhoneSync() ) { |
199 | mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ; | 197 | mPhoneDevice = temp->getPhoneDevice( ) ; |
200 | mPrefs->mPhoneConnection = temp->getPhoneConnection( ); | 198 | mPhoneConnection = temp->getPhoneConnection( ); |
201 | mPrefs->mPhoneModel = temp->getPhoneModel( ); | 199 | mPhoneModel = temp->getPhoneModel( ); |
202 | syncPhone(); | 200 | syncPhone(); |
203 | } else | 201 | } else |
204 | syncRemote( temp ); | 202 | syncRemote( temp ); |
205 | 203 | ||
206 | } | 204 | } |
207 | } | 205 | } |
208 | delete temp; | 206 | delete temp; |
209 | setBlockSave(false); | 207 | setBlockSave(false); |
210 | } | 208 | } |
211 | 209 | ||
212 | void KSyncManager::syncLocalFile() | 210 | void KSyncManager::syncLocalFile() |
213 | { | 211 | { |
214 | 212 | ||
215 | QString fn =mPrefs->mLastSyncedLocalFile; | 213 | QString fn =mLastSyncedLocalFile; |
216 | QString ext; | 214 | QString ext; |
217 | 215 | ||
218 | switch(mTargetApp) | 216 | switch(mTargetApp) |
219 | { | 217 | { |
220 | case (KAPI): | 218 | case (KAPI): |
221 | ext = "(*.vcf)"; | 219 | ext = "(*.vcf)"; |
222 | break; | 220 | break; |
223 | case (KOPI): | 221 | case (KOPI): |
224 | ext = "(*.ics/*.vcs)"; | 222 | ext = "(*.ics/*.vcs)"; |
225 | break; | 223 | break; |
226 | case (PWMPI): | 224 | case (PWMPI): |
227 | ext = "(*.pwm)"; | 225 | ext = "(*.pwm)"; |
228 | break; | 226 | break; |
229 | default: | 227 | default: |
230 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 228 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
231 | break; | 229 | break; |
232 | 230 | ||
233 | } | 231 | } |
234 | 232 | ||
235 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 233 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
236 | if ( fn == "" ) | 234 | if ( fn == "" ) |
237 | return; | 235 | return; |
238 | if ( syncWithFile( fn, false ) ) { | 236 | if ( syncWithFile( fn, false ) ) { |
239 | qDebug("syncLocalFile() successful "); | 237 | qDebug("syncLocalFile() successful "); |
240 | } | 238 | } |
241 | 239 | ||
242 | } | 240 | } |
243 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 241 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
244 | { | 242 | { |
245 | bool ret = false; | 243 | bool ret = false; |
246 | QFileInfo info; | 244 | QFileInfo info; |
247 | info.setFile( fn ); | 245 | info.setFile( fn ); |
248 | QString mess; | 246 | QString mess; |
249 | bool loadbup = true; | 247 | bool loadbup = true; |
250 | if ( !info. exists() ) { | 248 | if ( !info. exists() ) { |
251 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 249 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
252 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 250 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
253 | mess ); | 251 | mess ); |
254 | return ret; | 252 | return ret; |
255 | } | 253 | } |
256 | int result = 0; | 254 | int result = 0; |
257 | if ( !quick ) { | 255 | if ( !quick ) { |
258 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 256 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
259 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 257 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
260 | mess, | 258 | mess, |
261 | i18n("Sync"), i18n("Cancel"), 0, | 259 | i18n("Sync"), i18n("Cancel"), 0, |
262 | 0, 1 ); | 260 | 0, 1 ); |
263 | if ( result ) | 261 | if ( result ) |
264 | return false; | 262 | return false; |
265 | } | 263 | } |
266 | if ( mPrefs->mAskForPreferences ) | 264 | if ( mAskForPreferences ) |
267 | edit_sync_options(); | 265 | edit_sync_options(); |
268 | if ( result == 0 ) { | 266 | if ( result == 0 ) { |
269 | //qDebug("Now sycing ... "); | 267 | //qDebug("Now sycing ... "); |
270 | if ( ret = mImplementation->sync( this, fn, mPrefs->mSyncAlgoPrefs ) ) | 268 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
271 | mParent->setCaption( i18n("Synchronization successful") ); | 269 | mParent->setCaption( i18n("Synchronization successful") ); |
272 | else | 270 | else |
273 | mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 271 | mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
274 | if ( ! quick ) | 272 | if ( ! quick ) |
275 | mPrefs->mLastSyncedLocalFile = fn; | 273 | mLastSyncedLocalFile = fn; |
276 | mImplementation->sync_setModified(); | 274 | mImplementation->sync_setModified(); |
277 | } | 275 | } |
278 | return ret; | 276 | return ret; |
279 | } | 277 | } |
280 | void KSyncManager::quickSyncLocalFile() | 278 | void KSyncManager::quickSyncLocalFile() |
281 | { | 279 | { |
282 | 280 | ||
283 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) { | 281 | if ( syncWithFile( mLastSyncedLocalFile, false ) ) { |
284 | qDebug("quick syncLocalFile() successful "); | 282 | qDebug("quick syncLocalFile() successful "); |
285 | 283 | ||
286 | } | 284 | } |
287 | } | 285 | } |
288 | void KSyncManager::multiSync( bool askforPrefs ) | 286 | void KSyncManager::multiSync( bool askforPrefs ) |
289 | { | 287 | { |
290 | if (blockSave()) | 288 | if (blockSave()) |
291 | return; | 289 | return; |
292 | setBlockSave(true); | 290 | setBlockSave(true); |
293 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 291 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
294 | if ( QMessageBox::information( mParent, i18n("Sync"), | 292 | if ( QMessageBox::information( mParent, i18n("Sync"), |
295 | question, | 293 | question, |
296 | i18n("Yes"), i18n("No"), | 294 | i18n("Yes"), i18n("No"), |
297 | 0, 0 ) != 0 ) { | 295 | 0, 0 ) != 0 ) { |
298 | setBlockSave(false); | 296 | setBlockSave(false); |
299 | mParent->setCaption(i18n("Aborted! Nothing synced!")); | 297 | mParent->setCaption(i18n("Aborted! Nothing synced!")); |
300 | return; | 298 | return; |
301 | } | 299 | } |
302 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 300 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
303 | mPrefs->mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 301 | mSyncAlgoPrefs = mRingSyncAlgoPrefs; |
304 | if ( askforPrefs ) { | 302 | if ( askforPrefs ) { |
305 | edit_sync_options(); | 303 | edit_sync_options(); |
306 | mPrefs->mRingSyncAlgoPrefs = mPrefs->mSyncAlgoPrefs; | 304 | mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
307 | } | 305 | } |
308 | mParent->setCaption(i18n("Multiple sync started.") ); | 306 | mParent->setCaption(i18n("Multiple sync started.") ); |
309 | qApp->processEvents(); | 307 | qApp->processEvents(); |
310 | int num = ringSync() ; | 308 | int num = ringSync() ; |
311 | if ( num > 1 ) | 309 | if ( num > 1 ) |
312 | ringSync(); | 310 | ringSync(); |
313 | setBlockSave(false); | 311 | setBlockSave(false); |
314 | if ( num ) | 312 | if ( num ) |
315 | mImplementation->sync_save(); | 313 | mImplementation->sync_save(); |
316 | if ( num ) | 314 | if ( num ) |
317 | mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 315 | mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
318 | else | 316 | else |
319 | mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 317 | mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
320 | return; | 318 | return; |
321 | } | 319 | } |
322 | int KSyncManager::ringSync() | 320 | int KSyncManager::ringSync() |
323 | { | 321 | { |
324 | int syncedProfiles = 0; | 322 | int syncedProfiles = 0; |
325 | unsigned int i; | 323 | unsigned int i; |
326 | QTime timer; | 324 | QTime timer; |
327 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 325 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
328 | QStringList syncProfileNames = mPrefs->mSyncProfileNames; | 326 | QStringList syncProfileNames = mSyncProfileNames; |
329 | KSyncProfile* temp = new KSyncProfile (); | 327 | KSyncProfile* temp = new KSyncProfile (); |
330 | mPrefs->mAskForPreferences = false; | 328 | mAskForPreferences = false; |
331 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 329 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
332 | mCurrentSyncProfile = i; | 330 | mCurrentSyncProfile = i; |
333 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 331 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
334 | temp->readConfig(&config); | 332 | temp->readConfig(&config); |
335 | 333 | ||
336 | QString includeInRingSync; | 334 | QString includeInRingSync; |
337 | switch(mTargetApp) | 335 | switch(mTargetApp) |
338 | { | 336 | { |
339 | case (KAPI): | 337 | case (KAPI): |
340 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 338 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
341 | break; | 339 | break; |
342 | case (KOPI): | 340 | case (KOPI): |
343 | includeInRingSync = temp->getIncludeInRingSync(); | 341 | includeInRingSync = temp->getIncludeInRingSync(); |
344 | break; | 342 | break; |
345 | case (PWMPI): | 343 | case (PWMPI): |
346 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 344 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
347 | break; | 345 | break; |
348 | default: | 346 | default: |
349 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 347 | qDebug("KSyncManager::ringSync: invalid apptype selected"); |
350 | break; | 348 | break; |
351 | 349 | ||
352 | } | 350 | } |
353 | 351 | ||
354 | 352 | ||
355 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 353 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
356 | mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 354 | mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
357 | ++syncedProfiles; | 355 | ++syncedProfiles; |
358 | // mPrefs->mAskForPreferences = temp->getAskForPreferences(); | 356 | // mAskForPreferences = temp->getAskForPreferences(); |
359 | mPrefs->mWriteBackFile = temp->getWriteBackFile(); | 357 | mWriteBackFile = temp->getWriteBackFile(); |
360 | mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 358 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
361 | mPrefs->mWriteBackInFuture = 0; | 359 | mWriteBackInFuture = 0; |
362 | if ( temp->getWriteBackFuture() ) | 360 | if ( temp->getWriteBackFuture() ) |
363 | mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 361 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
364 | mPrefs->mShowSyncSummary = false; | 362 | mShowSyncSummary = false; |
365 | mCurrentSyncDevice = syncProfileNames[i] ; | 363 | mCurrentSyncDevice = syncProfileNames[i] ; |
366 | mCurrentSyncName = mPrefs->mLocalMachineName; | 364 | mCurrentSyncName = mLocalMachineName; |
367 | if ( i == 0 ) { | 365 | if ( i == 0 ) { |
368 | syncSharp(); | 366 | syncSharp(); |
369 | } else { | 367 | } else { |
370 | if ( temp->getIsLocalFileSync() ) { | 368 | if ( temp->getIsLocalFileSync() ) { |
371 | switch(mTargetApp) | 369 | switch(mTargetApp) |
372 | { | 370 | { |
373 | case (KAPI): | 371 | case (KAPI): |
374 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 372 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
375 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 373 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
376 | break; | 374 | break; |
377 | case (KOPI): | 375 | case (KOPI): |
378 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 376 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
379 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 377 | mLastSyncedLocalFile = temp->getRemoteFileName(); |
380 | break; | 378 | break; |
381 | case (PWMPI): | 379 | case (PWMPI): |
382 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 380 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
383 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 381 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
384 | break; | 382 | break; |
385 | default: | 383 | default: |
386 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 384 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
387 | break; | 385 | break; |
388 | } | 386 | } |
389 | } else { | 387 | } else { |
390 | if ( temp->getIsPhoneSync() ) { | 388 | if ( temp->getIsPhoneSync() ) { |
391 | mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ; | 389 | mPhoneDevice = temp->getPhoneDevice( ) ; |
392 | mPrefs->mPhoneConnection = temp->getPhoneConnection( ); | 390 | mPhoneConnection = temp->getPhoneConnection( ); |
393 | mPrefs->mPhoneModel = temp->getPhoneModel( ); | 391 | mPhoneModel = temp->getPhoneModel( ); |
394 | syncPhone(); | 392 | syncPhone(); |
395 | } else | 393 | } else |
396 | syncRemote( temp, false ); | 394 | syncRemote( temp, false ); |
397 | 395 | ||
398 | } | 396 | } |
399 | } | 397 | } |
400 | timer.start(); | 398 | timer.start(); |
401 | mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 399 | mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
402 | while ( timer.elapsed () < 2000 ) { | 400 | while ( timer.elapsed () < 2000 ) { |
403 | qApp->processEvents(); | 401 | qApp->processEvents(); |
404 | #ifndef _WIN32_ | 402 | #ifndef _WIN32_ |
405 | sleep (1); | 403 | sleep (1); |
406 | #endif | 404 | #endif |
407 | } | 405 | } |
408 | 406 | ||
409 | } | 407 | } |
410 | 408 | ||
411 | } | 409 | } |
412 | delete temp; | 410 | delete temp; |
413 | return syncedProfiles; | 411 | return syncedProfiles; |
414 | } | 412 | } |
415 | 413 | ||
416 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 414 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
417 | { | 415 | { |
418 | QString question; | 416 | QString question; |
419 | if ( ask ) { | 417 | if ( ask ) { |
420 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 418 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
421 | if ( QMessageBox::information( mParent, i18n("Sync"), | 419 | if ( QMessageBox::information( mParent, i18n("Sync"), |
422 | question, | 420 | question, |
423 | i18n("Yes"), i18n("No"), | 421 | i18n("Yes"), i18n("No"), |
424 | 0, 0 ) != 0 ) | 422 | 0, 0 ) != 0 ) |
425 | return; | 423 | return; |
426 | } | 424 | } |
427 | 425 | ||
428 | QString preCommand; | 426 | QString preCommand; |
429 | QString localTempFile; | 427 | QString localTempFile; |
430 | QString postCommand; | 428 | QString postCommand; |
431 | 429 | ||
432 | switch(mTargetApp) | 430 | switch(mTargetApp) |
433 | { | 431 | { |
434 | case (KAPI): | 432 | case (KAPI): |
435 | preCommand = prof->getPreSyncCommandAB(); | 433 | preCommand = prof->getPreSyncCommandAB(); |
436 | postCommand = prof->getPostSyncCommandAB(); | 434 | postCommand = prof->getPostSyncCommandAB(); |
437 | localTempFile = prof->getLocalTempFileAB(); | 435 | localTempFile = prof->getLocalTempFileAB(); |
438 | break; | 436 | break; |
439 | case (KOPI): | 437 | case (KOPI): |
440 | preCommand = prof->getPreSyncCommand(); | 438 | preCommand = prof->getPreSyncCommand(); |
441 | postCommand = prof->getPostSyncCommand(); | 439 | postCommand = prof->getPostSyncCommand(); |
442 | localTempFile = prof->getLocalTempFile(); | 440 | localTempFile = prof->getLocalTempFile(); |
443 | break; | 441 | break; |
444 | case (PWMPI): | 442 | case (PWMPI): |
445 | preCommand = prof->getPreSyncCommandPWM(); | 443 | preCommand = prof->getPreSyncCommandPWM(); |
446 | postCommand = prof->getPostSyncCommandPWM(); | 444 | postCommand = prof->getPostSyncCommandPWM(); |
447 | localTempFile = prof->getLocalTempFilePWM(); | 445 | localTempFile = prof->getLocalTempFilePWM(); |
448 | break; | 446 | break; |
449 | default: | 447 | default: |
450 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); | 448 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); |
451 | break; | 449 | break; |
452 | } | 450 | } |
453 | 451 | ||
454 | 452 | ||
455 | int fi; | 453 | int fi; |
456 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 454 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
457 | QString pwd = getPassword(); | 455 | QString pwd = getPassword(); |
458 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 456 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
459 | 457 | ||
460 | } | 458 | } |
461 | int maxlen = 30; | 459 | int maxlen = 30; |
462 | if ( QApplication::desktop()->width() > 320 ) | 460 | if ( QApplication::desktop()->width() > 320 ) |
463 | maxlen += 25; | 461 | maxlen += 25; |
464 | mParent->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 462 | mParent->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
465 | int fileSize = 0; | 463 | int fileSize = 0; |
466 | int result = system ( preCommand ); | 464 | int result = system ( preCommand ); |
467 | // 0 : okay | 465 | // 0 : okay |
468 | // 256: no such file or dir | 466 | // 256: no such file or dir |
469 | // | 467 | // |
470 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 468 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
471 | if ( result != 0 ) { | 469 | if ( result != 0 ) { |
472 | unsigned int len = maxlen; | 470 | unsigned int len = maxlen; |
473 | while ( len < preCommand.length() ) { | 471 | while ( len < preCommand.length() ) { |
474 | preCommand.insert( len , "\n" ); | 472 | preCommand.insert( len , "\n" ); |
475 | len += maxlen +2; | 473 | len += maxlen +2; |
476 | } | 474 | } |
477 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; | 475 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; |
478 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 476 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
479 | question, | 477 | question, |
480 | i18n("Okay!")) ; | 478 | i18n("Okay!")) ; |
481 | mParent->setCaption (""); | 479 | mParent->setCaption (""); |
482 | return; | 480 | return; |
483 | } | 481 | } |
484 | mParent->setCaption ( i18n( "Copying succeed." ) ); | 482 | mParent->setCaption ( i18n( "Copying succeed." ) ); |
485 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 483 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
486 | 484 | ||
487 | 485 | ||
488 | 486 | ||
489 | if ( syncWithFile( localTempFile, true ) ) { | 487 | if ( syncWithFile( localTempFile, true ) ) { |
490 | // Event* e = mView->getLastSyncEvent(); | 488 | // Event* e = mView->getLastSyncEvent(); |
491 | // e->setReadOnly( false ); | 489 | // e->setReadOnly( false ); |
492 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 490 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
493 | // e->setReadOnly( true ); | 491 | // e->setReadOnly( true ); |
494 | if ( mPrefs->mWriteBackFile ) { | 492 | if ( mWriteBackFile ) { |
495 | int fi; | 493 | int fi; |
496 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 494 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
497 | QString pwd = getPassword(); | 495 | QString pwd = getPassword(); |
498 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 496 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
499 | 497 | ||
500 | } | 498 | } |
501 | mParent->setCaption ( i18n( "Writing back file ..." ) ); | 499 | mParent->setCaption ( i18n( "Writing back file ..." ) ); |
502 | result = system ( postCommand ); | 500 | result = system ( postCommand ); |
503 | qDebug("Writing back file result: %d ", result); | 501 | qDebug("Writing back file result: %d ", result); |
504 | if ( result != 0 ) { | 502 | if ( result != 0 ) { |
505 | mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 503 | mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
506 | return; | 504 | return; |
507 | } else { | 505 | } else { |
508 | mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 506 | mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
509 | } | 507 | } |
510 | } | 508 | } |
511 | } | 509 | } |
512 | return; | 510 | return; |
513 | } | 511 | } |
514 | 512 | ||
515 | void KSyncManager::edit_sync_options() | 513 | void KSyncManager::edit_sync_options() |
516 | { | 514 | { |
517 | //mDialogManager->showSyncOptions(); | 515 | //mDialogManager->showSyncOptions(); |
518 | //mPrefs->mSyncAlgoPrefs | 516 | //mSyncAlgoPrefs |
519 | QDialog dia( mParent, "dia", true ); | 517 | QDialog dia( mParent, "dia", true ); |
520 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 518 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
521 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 519 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
522 | QVBoxLayout lay ( &dia ); | 520 | QVBoxLayout lay ( &dia ); |
523 | lay.setSpacing( 2 ); | 521 | lay.setSpacing( 2 ); |
524 | lay.setMargin( 3 ); | 522 | lay.setMargin( 3 ); |
525 | lay.addWidget(&gr); | 523 | lay.addWidget(&gr); |
526 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 524 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
527 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 525 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
528 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 526 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
529 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 527 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
530 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 528 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
531 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 529 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
532 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 530 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
533 | QPushButton pb ( "OK", &dia); | 531 | QPushButton pb ( "OK", &dia); |
534 | lay.addWidget( &pb ); | 532 | lay.addWidget( &pb ); |
535 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 533 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
536 | switch ( mPrefs->mSyncAlgoPrefs ) { | 534 | switch ( mSyncAlgoPrefs ) { |
537 | case 0: | 535 | case 0: |
538 | loc.setChecked( true); | 536 | loc.setChecked( true); |
539 | break; | 537 | break; |
540 | case 1: | 538 | case 1: |
541 | rem.setChecked( true ); | 539 | rem.setChecked( true ); |
542 | break; | 540 | break; |
543 | case 2: | 541 | case 2: |
544 | newest.setChecked( true); | 542 | newest.setChecked( true); |
545 | break; | 543 | break; |
546 | case 3: | 544 | case 3: |
547 | ask.setChecked( true); | 545 | ask.setChecked( true); |
548 | break; | 546 | break; |
549 | case 4: | 547 | case 4: |
550 | f_loc.setChecked( true); | 548 | f_loc.setChecked( true); |
551 | break; | 549 | break; |
552 | case 5: | 550 | case 5: |
553 | f_rem.setChecked( true); | 551 | f_rem.setChecked( true); |
554 | break; | 552 | break; |
555 | case 6: | 553 | case 6: |
556 | // both.setChecked( true); | 554 | // both.setChecked( true); |
557 | break; | 555 | break; |
558 | default: | 556 | default: |
559 | break; | 557 | break; |
560 | } | 558 | } |
561 | if ( dia.exec() ) { | 559 | if ( dia.exec() ) { |
562 | mPrefs->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 560 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
563 | } | 561 | } |
564 | 562 | ||
565 | 563 | ||
566 | } | 564 | } |
567 | QString KSyncManager::getPassword( ) | 565 | QString KSyncManager::getPassword( ) |
568 | { | 566 | { |
569 | QString retfile = ""; | 567 | QString retfile = ""; |
570 | QDialog dia ( mParent, "input-dialog", true ); | 568 | QDialog dia ( mParent, "input-dialog", true ); |
571 | QLineEdit lab ( &dia ); | 569 | QLineEdit lab ( &dia ); |
572 | lab.setEchoMode( QLineEdit::Password ); | 570 | lab.setEchoMode( QLineEdit::Password ); |
573 | QVBoxLayout lay( &dia ); | 571 | QVBoxLayout lay( &dia ); |
574 | lay.setMargin(7); | 572 | lay.setMargin(7); |
575 | lay.setSpacing(7); | 573 | lay.setSpacing(7); |
576 | lay.addWidget( &lab); | 574 | lay.addWidget( &lab); |
577 | dia.setFixedSize( 230,50 ); | 575 | dia.setFixedSize( 230,50 ); |
578 | dia.setCaption( i18n("Enter password") ); | 576 | dia.setCaption( i18n("Enter password") ); |
579 | QPushButton pb ( "OK", &dia); | 577 | QPushButton pb ( "OK", &dia); |
580 | lay.addWidget( &pb ); | 578 | lay.addWidget( &pb ); |
581 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 579 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
582 | dia.show(); | 580 | dia.show(); |
583 | int res = dia.exec(); | 581 | int res = dia.exec(); |
584 | if ( res ) | 582 | if ( res ) |
585 | retfile = lab.text(); | 583 | retfile = lab.text(); |
586 | dia.hide(); | 584 | dia.hide(); |
587 | qApp->processEvents(); | 585 | qApp->processEvents(); |
588 | return retfile; | 586 | return retfile; |
589 | 587 | ||
590 | } | 588 | } |
591 | 589 | ||
592 | 590 | ||
593 | void KSyncManager::confSync() | 591 | void KSyncManager::confSync() |
594 | { | 592 | { |
595 | static KSyncPrefsDialog* sp = 0; | 593 | static KSyncPrefsDialog* sp = 0; |
596 | if ( ! sp ) { | 594 | if ( ! sp ) { |
597 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 595 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
598 | } | 596 | } |
599 | sp->usrReadConfig(); | 597 | sp->usrReadConfig(); |
600 | #ifndef DESKTOP_VERSION | 598 | #ifndef DESKTOP_VERSION |
601 | sp->showMaximized(); | 599 | sp->showMaximized(); |
602 | #else | 600 | #else |
603 | sp->show(); | 601 | sp->show(); |
604 | #endif | 602 | #endif |
605 | sp->exec(); | 603 | sp->exec(); |
606 | mPrefs->mSyncProfileNames = sp->getSyncProfileNames(); | 604 | mSyncProfileNames = sp->getSyncProfileNames(); |
607 | mPrefs->mLocalMachineName = sp->getLocalMachineName (); | 605 | mLocalMachineName = sp->getLocalMachineName (); |
608 | fillSyncMenu(); | 606 | fillSyncMenu(); |
609 | } | 607 | } |
610 | 608 | ||
611 | void KSyncManager::syncSharp() | 609 | void KSyncManager::syncSharp() |
612 | { | 610 | { |
613 | if ( ! syncExternalApplication("sharp") ) | 611 | if ( ! syncExternalApplication("sharp") ) |
614 | qDebug("ERROR sync sharp ");; | 612 | qDebug("ERROR sync sharp ");; |
615 | } | 613 | } |
616 | 614 | ||
617 | bool KSyncManager::syncExternalApplication(QString resource) | 615 | bool KSyncManager::syncExternalApplication(QString resource) |
618 | { | 616 | { |
619 | if ( mImplementation->sync_isModified() ) | 617 | if ( mImplementation->sync_isModified() ) |
620 | mImplementation->sync_save(); | 618 | mImplementation->sync_save(); |
621 | 619 | ||
622 | if ( mPrefs->mAskForPreferences ) | 620 | if ( mAskForPreferences ) |
623 | edit_sync_options(); | 621 | edit_sync_options(); |
624 | 622 | ||
625 | qDebug("sync %s", resource.latin1()); | 623 | qDebug("sync %s", resource.latin1()); |
626 | 624 | ||
627 | bool syncOK = mImplementation->syncExternal(this, resource); | 625 | bool syncOK = mImplementation->syncExternal(this, resource); |
628 | 626 | ||
629 | return syncOK; | 627 | return syncOK; |
630 | 628 | ||
631 | } | 629 | } |
632 | 630 | ||
633 | void KSyncManager::syncPhone() | 631 | void KSyncManager::syncPhone() |
634 | { | 632 | { |
635 | if ( mImplementation->sync_isModified() ) | 633 | if ( mImplementation->sync_isModified() ) |
636 | mImplementation->sync_save(); | 634 | mImplementation->sync_save(); |
637 | 635 | ||
638 | qDebug("pending syncPhone(); "); | 636 | qDebug("pending syncPhone(); "); |
639 | //mView->syncPhone(); | 637 | //mView->syncPhone(); |
640 | mImplementation->sync_setModified(); | 638 | mImplementation->sync_setModified(); |
641 | 639 | ||
642 | } | 640 | } |
643 | 641 | ||
644 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 642 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
645 | { | 643 | { |
646 | if (!bar->isVisible()) | 644 | if (!bar->isVisible()) |
647 | { | 645 | { |
648 | bar->setCaption (caption); | 646 | bar->setCaption (caption); |
649 | bar->setTotalSteps ( total ) ; | 647 | bar->setTotalSteps ( total ) ; |
650 | 648 | ||
651 | bar->show(); | 649 | bar->show(); |
652 | } | 650 | } |
653 | 651 | ||
654 | bar->setProgress( percentage ); | 652 | bar->setProgress( percentage ); |
655 | } | 653 | } |
656 | 654 | ||
657 | void KSyncManager::hideProgressBar() | 655 | void KSyncManager::hideProgressBar() |
658 | { | 656 | { |
659 | bar->hide(); | 657 | bar->hide(); |
660 | } | 658 | } |
661 | 659 | ||
662 | bool KSyncManager::isProgressBarCanceled() | 660 | bool KSyncManager::isProgressBarCanceled() |
663 | { | 661 | { |
664 | return !bar->isVisible(); | 662 | return !bar->isVisible(); |
665 | } | 663 | } |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 9761107..6b10016 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -1,129 +1,147 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | $Id$ | 20 | $Id$ |
21 | */ | 21 | */ |
22 | #ifndef _KSYNCMANAGER_H | 22 | #ifndef _KSYNCMANAGER_H |
23 | #define _KSYNCMANAGER_H | 23 | #define _KSYNCMANAGER_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | 27 | ||
28 | class QPopupMenu; | 28 | class QPopupMenu; |
29 | class KSyncProfile; | 29 | class KSyncProfile; |
30 | class KPimPrefs; | 30 | class KPimPrefs; |
31 | class QWidget; | 31 | class QWidget; |
32 | class KSyncManager; | 32 | class KSyncManager; |
33 | class KSyncInterface; | 33 | class KSyncInterface; |
34 | class QProgressBar; | 34 | class QProgressBar; |
35 | 35 | ||
36 | class KSyncManager : public QObject | 36 | class KSyncManager : public QObject |
37 | { | 37 | { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | 39 | ||
40 | public: | 40 | public: |
41 | enum TargetApp { | 41 | enum TargetApp { |
42 | KOPI = 0, | 42 | KOPI = 0, |
43 | KAPI = 1, | 43 | KAPI = 1, |
44 | PWMPI = 2 }; | 44 | PWMPI = 2 }; |
45 | 45 | ||
46 | 46 | ||
47 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 47 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
48 | ~KSyncManager() ; | 48 | ~KSyncManager() ; |
49 | 49 | ||
50 | bool blockSave() { return mBlockSaveFlag; } | 50 | bool blockSave() { return mBlockSaveFlag; } |
51 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 51 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
52 | 52 | ||
53 | void fillSyncMenu(); | 53 | void fillSyncMenu(); |
54 | 54 | ||
55 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 55 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
56 | QString getCurrentSyncName() { return mCurrentSyncName; } | 56 | QString getCurrentSyncName() { return mCurrentSyncName; } |
57 | 57 | ||
58 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 58 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
59 | void hideProgressBar(); | 59 | void hideProgressBar(); |
60 | bool isProgressBarCanceled(); | 60 | bool isProgressBarCanceled(); |
61 | 61 | ||
62 | // sync stuff | ||
63 | QString mLocalMachineName; | ||
64 | QStringList mExternSyncProfiles; | ||
65 | QStringList mSyncProfileNames; | ||
66 | bool mAskForPreferences; | ||
67 | bool mShowSyncSummary; | ||
68 | bool mShowSyncEvents; | ||
69 | bool mShowTodoInAgenda; | ||
70 | bool mWriteBackExistingOnly; | ||
71 | int mSyncAlgoPrefs; | ||
72 | int mRingSyncAlgoPrefs; | ||
73 | bool mWriteBackFile; | ||
74 | int mWriteBackInFuture; | ||
75 | QString mPhoneDevice; | ||
76 | QString mPhoneConnection; | ||
77 | QString mPhoneModel; | ||
78 | QString mLastSyncedLocalFile; // save! | ||
79 | |||
80 | |||
62 | 81 | ||
63 | public slots: | 82 | public slots: |
64 | void slotSyncMenu( int ); | 83 | void slotSyncMenu( int ); |
65 | 84 | ||
66 | private: | 85 | private: |
67 | // LR ******************************* | 86 | // LR ******************************* |
68 | // sync stuff! | 87 | // sync stuff! |
69 | QString mCurrentSyncDevice; | 88 | QString mCurrentSyncDevice; |
70 | QString mCurrentSyncName; | 89 | QString mCurrentSyncName; |
71 | void quickSyncLocalFile(); | 90 | void quickSyncLocalFile(); |
72 | bool syncWithFile( QString fn , bool quick ); | 91 | bool syncWithFile( QString fn , bool quick ); |
73 | void syncLocalFile(); | 92 | void syncLocalFile(); |
74 | void syncPhone(); | 93 | void syncPhone(); |
75 | void syncSharp(); | 94 | void syncSharp(); |
76 | bool syncExternalApplication(QString); | 95 | bool syncExternalApplication(QString); |
77 | void multiSync( bool askforPrefs ); | 96 | void multiSync( bool askforPrefs ); |
78 | int mCurrentSyncProfile ; | 97 | int mCurrentSyncProfile ; |
79 | void syncRemote( KSyncProfile* prof, bool ask = true); | 98 | void syncRemote( KSyncProfile* prof, bool ask = true); |
80 | void edit_sync_options(); | 99 | void edit_sync_options(); |
81 | int ringSync(); | 100 | int ringSync(); |
82 | QString getPassword( ); | 101 | QString getPassword( ); |
83 | 102 | ||
84 | private slots: | 103 | private slots: |
85 | void confSync(); | 104 | void confSync(); |
86 | // ********************* | 105 | // ********************* |
87 | 106 | ||
88 | private: | 107 | private: |
89 | bool mBlockSaveFlag; | 108 | bool mBlockSaveFlag; |
90 | 109 | ||
91 | 110 | ||
92 | QWidget* mParent; | 111 | QWidget* mParent; |
93 | KSyncInterface* mImplementation; | 112 | KSyncInterface* mImplementation; |
94 | TargetApp mTargetApp; | 113 | TargetApp mTargetApp; |
95 | KPimPrefs* mPrefs; | ||
96 | QPopupMenu* mSyncMenu; | 114 | QPopupMenu* mSyncMenu; |
97 | 115 | ||
98 | QProgressBar* bar; | 116 | QProgressBar* bar; |
99 | 117 | ||
100 | 118 | ||
101 | 119 | ||
102 | 120 | ||
103 | 121 | ||
104 | }; | 122 | }; |
105 | 123 | ||
106 | 124 | ||
107 | class KSyncInterface | 125 | class KSyncInterface |
108 | { | 126 | { |
109 | public: | 127 | public: |
110 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 128 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
111 | 129 | ||
112 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 130 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
113 | { | 131 | { |
114 | // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. | 132 | // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. |
115 | return false; | 133 | return false; |
116 | } | 134 | } |
117 | 135 | ||
118 | //called by the syncmanager to indicate that the work has to be marked as dirty. | 136 | //called by the syncmanager to indicate that the work has to be marked as dirty. |
119 | virtual void sync_setModified() = 0; | 137 | virtual void sync_setModified() = 0; |
120 | 138 | ||
121 | //called by the syncmanager to ask if the dirty flag is set. | 139 | //called by the syncmanager to ask if the dirty flag is set. |
122 | virtual bool sync_isModified() = 0; | 140 | virtual bool sync_isModified() = 0; |
123 | 141 | ||
124 | //called by the syncmanager to indicate that the work has to be saved. | 142 | //called by the syncmanager to indicate that the work has to be saved. |
125 | virtual void sync_save() = 0; | 143 | virtual void sync_save() = 0; |
126 | }; | 144 | }; |
127 | 145 | ||
128 | 146 | ||
129 | #endif | 147 | #endif |
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp index 6c1a9c0..76a45f4 100644 --- a/pwmanager/pwmanager/pwmdoc.cpp +++ b/pwmanager/pwmanager/pwmdoc.cpp | |||
@@ -1427,1874 +1427,1874 @@ PwMerror PwMDoc::decrypt(string *d, unsigned int pos, const QString *pw, | |||
1427 | #else | 1427 | #else |
1428 | d->assign((const char *)(decrypted), | 1428 | d->assign((const char *)(decrypted), |
1429 | (string::size_type)(cryptLen)); | 1429 | (string::size_type)(cryptLen)); |
1430 | #endif | 1430 | #endif |
1431 | delete [] decrypted; | 1431 | delete [] decrypted; |
1432 | if (algo == PWM_CRYPT_BLOWFISH) { | 1432 | if (algo == PWM_CRYPT_BLOWFISH) { |
1433 | if (!Blowfish::unpadNull(d)) { | 1433 | if (!Blowfish::unpadNull(d)) { |
1434 | BUG(); | 1434 | BUG(); |
1435 | return e_readFile; | 1435 | return e_readFile; |
1436 | } | 1436 | } |
1437 | } | 1437 | } |
1438 | return e_success; | 1438 | return e_success; |
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | PwMerror PwMDoc::checkDataHash(char dataHashType, const string *dataHash, | 1441 | PwMerror PwMDoc::checkDataHash(char dataHashType, const string *dataHash, |
1442 | const string *dataStream) | 1442 | const string *dataStream) |
1443 | { | 1443 | { |
1444 | PWM_ASSERT(dataHash); | 1444 | PWM_ASSERT(dataHash); |
1445 | PWM_ASSERT(dataStream); | 1445 | PWM_ASSERT(dataStream); |
1446 | switch(dataHashType) { | 1446 | switch(dataHashType) { |
1447 | case PWM_HASH_SHA1: { | 1447 | case PWM_HASH_SHA1: { |
1448 | Sha1 hash; | 1448 | Sha1 hash; |
1449 | hash.sha1_write((byte*)dataStream->c_str(), dataStream->length()); | 1449 | hash.sha1_write((byte*)dataStream->c_str(), dataStream->length()); |
1450 | string ret = hash.sha1_read(); | 1450 | string ret = hash.sha1_read(); |
1451 | if (ret != *dataHash) | 1451 | if (ret != *dataHash) |
1452 | return e_fileCorrupt; | 1452 | return e_fileCorrupt; |
1453 | break; | 1453 | break; |
1454 | } | 1454 | } |
1455 | #ifndef PWM_EMBEDDED | 1455 | #ifndef PWM_EMBEDDED |
1456 | case PWM_HASH_SHA256: | 1456 | case PWM_HASH_SHA256: |
1457 | /*... fall through */ | 1457 | /*... fall through */ |
1458 | case PWM_HASH_SHA384: | 1458 | case PWM_HASH_SHA384: |
1459 | case PWM_HASH_SHA512: | 1459 | case PWM_HASH_SHA512: |
1460 | case PWM_HASH_MD5: | 1460 | case PWM_HASH_MD5: |
1461 | case PWM_HASH_RMD160: | 1461 | case PWM_HASH_RMD160: |
1462 | case PWM_HASH_TIGER: { | 1462 | case PWM_HASH_TIGER: { |
1463 | if (!LibGCryptIf::available()) | 1463 | if (!LibGCryptIf::available()) |
1464 | return e_hashNotImpl; | 1464 | return e_hashNotImpl; |
1465 | LibGCryptIf gc; | 1465 | LibGCryptIf gc; |
1466 | PwMerror err; | 1466 | PwMerror err; |
1467 | unsigned char *buf; | 1467 | unsigned char *buf; |
1468 | size_t hashLen; | 1468 | size_t hashLen; |
1469 | err = gc.hash(&buf, | 1469 | err = gc.hash(&buf, |
1470 | &hashLen, | 1470 | &hashLen, |
1471 | reinterpret_cast<const unsigned char *>(dataStream->c_str()), | 1471 | reinterpret_cast<const unsigned char *>(dataStream->c_str()), |
1472 | dataStream->length(), | 1472 | dataStream->length(), |
1473 | dataHashType); | 1473 | dataHashType); |
1474 | if (err != e_success) | 1474 | if (err != e_success) |
1475 | return e_hashNotImpl; | 1475 | return e_hashNotImpl; |
1476 | string calcHash(reinterpret_cast<const char *>(buf), | 1476 | string calcHash(reinterpret_cast<const char *>(buf), |
1477 | static_cast<string::size_type>(hashLen)); | 1477 | static_cast<string::size_type>(hashLen)); |
1478 | delete [] buf; | 1478 | delete [] buf; |
1479 | if (calcHash != *dataHash) | 1479 | if (calcHash != *dataHash) |
1480 | return e_fileCorrupt; | 1480 | return e_fileCorrupt; |
1481 | break; | 1481 | break; |
1482 | } | 1482 | } |
1483 | #endif | 1483 | #endif |
1484 | default: | 1484 | default: |
1485 | return e_hashNotImpl; | 1485 | return e_hashNotImpl; |
1486 | } | 1486 | } |
1487 | return e_success; | 1487 | return e_success; |
1488 | } | 1488 | } |
1489 | 1489 | ||
1490 | bool PwMDoc::lockAt(unsigned int category, unsigned int index, | 1490 | bool PwMDoc::lockAt(unsigned int category, unsigned int index, |
1491 | bool lock) | 1491 | bool lock) |
1492 | { | 1492 | { |
1493 | if (index >= numEntries(category)) { | 1493 | if (index >= numEntries(category)) { |
1494 | BUG(); | 1494 | BUG(); |
1495 | return false; | 1495 | return false; |
1496 | } | 1496 | } |
1497 | if (lock == dti.dta[category].d[index].lockStat) | 1497 | if (lock == dti.dta[category].d[index].lockStat) |
1498 | return true; | 1498 | return true; |
1499 | 1499 | ||
1500 | if (!lock && currentPw != "") { | 1500 | if (!lock && currentPw != "") { |
1501 | // "unlocking" and "password is already set" | 1501 | // "unlocking" and "password is already set" |
1502 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW)) { | 1502 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW)) { |
1503 | // unlocking without pw not allowed | 1503 | // unlocking without pw not allowed |
1504 | QString pw; | 1504 | QString pw; |
1505 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1505 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1506 | if (pw != "") { | 1506 | if (pw != "") { |
1507 | if (pw != currentPw) { | 1507 | if (pw != currentPw) { |
1508 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1508 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1509 | return false; | 1509 | return false; |
1510 | } else { | 1510 | } else { |
1511 | timer()->start(DocTimer::id_mpwTimer); | 1511 | timer()->start(DocTimer::id_mpwTimer); |
1512 | } | 1512 | } |
1513 | } else { | 1513 | } else { |
1514 | return false; | 1514 | return false; |
1515 | } | 1515 | } |
1516 | } else { | 1516 | } else { |
1517 | timer()->start(DocTimer::id_mpwTimer); | 1517 | timer()->start(DocTimer::id_mpwTimer); |
1518 | } | 1518 | } |
1519 | } | 1519 | } |
1520 | 1520 | ||
1521 | dti.dta[category].d[index].lockStat = lock; | 1521 | dti.dta[category].d[index].lockStat = lock; |
1522 | dti.dta[category].d[index].rev++; // increment revision counter. | 1522 | dti.dta[category].d[index].rev++; // increment revision counter. |
1523 | 1523 | ||
1524 | emitDataChanged(this); | 1524 | emitDataChanged(this); |
1525 | if (!lock) | 1525 | if (!lock) |
1526 | timer()->start(DocTimer::id_autoLockTimer); | 1526 | timer()->start(DocTimer::id_autoLockTimer); |
1527 | 1527 | ||
1528 | return true; | 1528 | return true; |
1529 | 1529 | ||
1530 | } | 1530 | } |
1531 | 1531 | ||
1532 | bool PwMDoc::lockAt(const QString &category,unsigned int index, | 1532 | bool PwMDoc::lockAt(const QString &category,unsigned int index, |
1533 | bool lock) | 1533 | bool lock) |
1534 | { | 1534 | { |
1535 | unsigned int cat = 0; | 1535 | unsigned int cat = 0; |
1536 | 1536 | ||
1537 | if (!findCategory(category, &cat)) { | 1537 | if (!findCategory(category, &cat)) { |
1538 | BUG(); | 1538 | BUG(); |
1539 | return false; | 1539 | return false; |
1540 | } | 1540 | } |
1541 | 1541 | ||
1542 | return lockAt(cat, index, lock); | 1542 | return lockAt(cat, index, lock); |
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | bool PwMDoc::lockAll(bool lock) | 1545 | bool PwMDoc::lockAll(bool lock) |
1546 | { | 1546 | { |
1547 | if (!lock && isDeepLocked()) { | 1547 | if (!lock && isDeepLocked()) { |
1548 | PwMerror ret; | 1548 | PwMerror ret; |
1549 | ret = deepLock(false); | 1549 | ret = deepLock(false); |
1550 | if (ret != e_success) | 1550 | if (ret != e_success) |
1551 | return false; | 1551 | return false; |
1552 | return true; | 1552 | return true; |
1553 | } | 1553 | } |
1554 | if (isDocEmpty()) { | 1554 | if (isDocEmpty()) { |
1555 | return true; | 1555 | return true; |
1556 | } | 1556 | } |
1557 | if (!lock && currentPw != "") { | 1557 | if (!lock && currentPw != "") { |
1558 | // unlocking and password is already set | 1558 | // unlocking and password is already set |
1559 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW)) { | 1559 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW)) { |
1560 | // unlocking without pw not allowed | 1560 | // unlocking without pw not allowed |
1561 | QString pw; | 1561 | QString pw; |
1562 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1562 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1563 | if (pw != "") { | 1563 | if (pw != "") { |
1564 | if (pw != currentPw) { | 1564 | if (pw != currentPw) { |
1565 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1565 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1566 | return false; | 1566 | return false; |
1567 | } else { | 1567 | } else { |
1568 | timer()->start(DocTimer::id_mpwTimer); | 1568 | timer()->start(DocTimer::id_mpwTimer); |
1569 | } | 1569 | } |
1570 | } else { | 1570 | } else { |
1571 | return false; | 1571 | return false; |
1572 | } | 1572 | } |
1573 | } else { | 1573 | } else { |
1574 | timer()->start(DocTimer::id_mpwTimer); | 1574 | timer()->start(DocTimer::id_mpwTimer); |
1575 | } | 1575 | } |
1576 | } | 1576 | } |
1577 | 1577 | ||
1578 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), | 1578 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), |
1579 | catEnd = dti.dta.end(), | 1579 | catEnd = dti.dta.end(), |
1580 | catI = catBegin; | 1580 | catI = catBegin; |
1581 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 1581 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
1582 | while (catI != catEnd) { | 1582 | while (catI != catEnd) { |
1583 | entrBegin = catI->d.begin(); | 1583 | entrBegin = catI->d.begin(); |
1584 | entrEnd = catI->d.end(); | 1584 | entrEnd = catI->d.end(); |
1585 | entrI = entrBegin; | 1585 | entrI = entrBegin; |
1586 | while (entrI != entrEnd) { | 1586 | while (entrI != entrEnd) { |
1587 | entrI->lockStat = lock; | 1587 | entrI->lockStat = lock; |
1588 | entrI->rev++; // increment revision counter. | 1588 | entrI->rev++; // increment revision counter. |
1589 | ++entrI; | 1589 | ++entrI; |
1590 | } | 1590 | } |
1591 | ++catI; | 1591 | ++catI; |
1592 | } | 1592 | } |
1593 | 1593 | ||
1594 | emitDataChanged(this); | 1594 | emitDataChanged(this); |
1595 | if (lock) | 1595 | if (lock) |
1596 | timer()->stop(DocTimer::id_autoLockTimer); | 1596 | timer()->stop(DocTimer::id_autoLockTimer); |
1597 | else | 1597 | else |
1598 | timer()->start(DocTimer::id_autoLockTimer); | 1598 | timer()->start(DocTimer::id_autoLockTimer); |
1599 | 1599 | ||
1600 | return true; | 1600 | return true; |
1601 | } | 1601 | } |
1602 | 1602 | ||
1603 | bool PwMDoc::isLocked(const QString &category, unsigned int index) | 1603 | bool PwMDoc::isLocked(const QString &category, unsigned int index) |
1604 | { | 1604 | { |
1605 | unsigned int cat = 0; | 1605 | unsigned int cat = 0; |
1606 | 1606 | ||
1607 | if (!findCategory(category, &cat)) { | 1607 | if (!findCategory(category, &cat)) { |
1608 | BUG(); | 1608 | BUG(); |
1609 | return false; | 1609 | return false; |
1610 | } | 1610 | } |
1611 | 1611 | ||
1612 | return isLocked(cat, index); | 1612 | return isLocked(cat, index); |
1613 | } | 1613 | } |
1614 | 1614 | ||
1615 | bool PwMDoc::unlockAll_tempoary(bool revert) | 1615 | bool PwMDoc::unlockAll_tempoary(bool revert) |
1616 | { | 1616 | { |
1617 | static vector< vector<bool> > *oldLockStates = 0; | 1617 | static vector< vector<bool> > *oldLockStates = 0; |
1618 | static bool wasDeepLocked; | 1618 | static bool wasDeepLocked; |
1619 | 1619 | ||
1620 | if (revert) {// revert the unlocking | 1620 | if (revert) {// revert the unlocking |
1621 | if (oldLockStates) { | 1621 | if (oldLockStates) { |
1622 | /* we actually _have_ unlocked something, because | 1622 | /* we actually _have_ unlocked something, because |
1623 | * we have allocated space for the oldLockStates. | 1623 | * we have allocated space for the oldLockStates. |
1624 | * So, go on and revert them! | 1624 | * So, go on and revert them! |
1625 | */ | 1625 | */ |
1626 | if (wasDeepLocked) { | 1626 | if (wasDeepLocked) { |
1627 | PwMerror ret = deepLock(true); | 1627 | PwMerror ret = deepLock(true); |
1628 | if (ret == e_success) { | 1628 | if (ret == e_success) { |
1629 | /* deep-lock succeed. We are save. | 1629 | /* deep-lock succeed. We are save. |
1630 | * (but if it failed, just go on | 1630 | * (but if it failed, just go on |
1631 | * lock them normally) | 1631 | * lock them normally) |
1632 | */ | 1632 | */ |
1633 | delete_and_null(oldLockStates); | 1633 | delete_and_null(oldLockStates); |
1634 | timer()->start(DocTimer::id_autoLockTimer); | 1634 | timer()->start(DocTimer::id_autoLockTimer); |
1635 | printDebug("tempoary unlocking of dta " | 1635 | printDebug("tempoary unlocking of dta " |
1636 | "reverted by deep-locking."); | 1636 | "reverted by deep-locking."); |
1637 | return true; | 1637 | return true; |
1638 | } | 1638 | } |
1639 | printDebug("deep-lock failed while reverting! " | 1639 | printDebug("deep-lock failed while reverting! " |
1640 | "Falling back to normal-lock."); | 1640 | "Falling back to normal-lock."); |
1641 | } | 1641 | } |
1642 | if (unlikely(!wasDeepLocked && | 1642 | if (unlikely(!wasDeepLocked && |
1643 | numCategories() != oldLockStates->size())) { | 1643 | numCategories() != oldLockStates->size())) { |
1644 | /* DOH! We have modified "dta" while | 1644 | /* DOH! We have modified "dta" while |
1645 | * it was unlocked tempoary. DON'T DO THIS! | 1645 | * it was unlocked tempoary. DON'T DO THIS! |
1646 | */ | 1646 | */ |
1647 | BUG(); | 1647 | BUG(); |
1648 | delete_and_null(oldLockStates); | 1648 | delete_and_null(oldLockStates); |
1649 | timer()->start(DocTimer::id_autoLockTimer); | 1649 | timer()->start(DocTimer::id_autoLockTimer); |
1650 | return false; | 1650 | return false; |
1651 | } | 1651 | } |
1652 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), | 1652 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), |
1653 | catEnd = dti.dta.end(), | 1653 | catEnd = dti.dta.end(), |
1654 | catI = catBegin; | 1654 | catI = catBegin; |
1655 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 1655 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
1656 | vector< vector<bool> >::iterator oldCatStatI = oldLockStates->begin(); | 1656 | vector< vector<bool> >::iterator oldCatStatI = oldLockStates->begin(); |
1657 | vector<bool>::iterator oldEntrStatBegin, | 1657 | vector<bool>::iterator oldEntrStatBegin, |
1658 | oldEntrStatEnd, | 1658 | oldEntrStatEnd, |
1659 | oldEntrStatI; | 1659 | oldEntrStatI; |
1660 | while (catI != catEnd) { | 1660 | while (catI != catEnd) { |
1661 | entrBegin = catI->d.begin(); | 1661 | entrBegin = catI->d.begin(); |
1662 | entrEnd = catI->d.end(); | 1662 | entrEnd = catI->d.end(); |
1663 | entrI = entrBegin; | 1663 | entrI = entrBegin; |
1664 | if (likely(!wasDeepLocked)) { | 1664 | if (likely(!wasDeepLocked)) { |
1665 | oldEntrStatBegin = oldCatStatI->begin(); | 1665 | oldEntrStatBegin = oldCatStatI->begin(); |
1666 | oldEntrStatEnd = oldCatStatI->end(); | 1666 | oldEntrStatEnd = oldCatStatI->end(); |
1667 | oldEntrStatI = oldEntrStatBegin; | 1667 | oldEntrStatI = oldEntrStatBegin; |
1668 | if (unlikely(catI->d.size() != oldCatStatI->size())) { | 1668 | if (unlikely(catI->d.size() != oldCatStatI->size())) { |
1669 | /* DOH! We have modified "dta" while | 1669 | /* DOH! We have modified "dta" while |
1670 | * it was unlocked tempoary. DON'T DO THIS! | 1670 | * it was unlocked tempoary. DON'T DO THIS! |
1671 | */ | 1671 | */ |
1672 | BUG(); | 1672 | BUG(); |
1673 | delete_and_null(oldLockStates); | 1673 | delete_and_null(oldLockStates); |
1674 | timer()->start(DocTimer::id_autoLockTimer); | 1674 | timer()->start(DocTimer::id_autoLockTimer); |
1675 | return false; | 1675 | return false; |
1676 | } | 1676 | } |
1677 | } | 1677 | } |
1678 | while (entrI != entrEnd) { | 1678 | while (entrI != entrEnd) { |
1679 | if (wasDeepLocked) { | 1679 | if (wasDeepLocked) { |
1680 | /* this is an error-fallback if | 1680 | /* this is an error-fallback if |
1681 | * deeplock didn't succeed | 1681 | * deeplock didn't succeed |
1682 | */ | 1682 | */ |
1683 | entrI->lockStat = true; | 1683 | entrI->lockStat = true; |
1684 | } else { | 1684 | } else { |
1685 | entrI->lockStat = *oldEntrStatI; | 1685 | entrI->lockStat = *oldEntrStatI; |
1686 | } | 1686 | } |
1687 | ++entrI; | 1687 | ++entrI; |
1688 | if (likely(!wasDeepLocked)) | 1688 | if (likely(!wasDeepLocked)) |
1689 | ++oldEntrStatI; | 1689 | ++oldEntrStatI; |
1690 | } | 1690 | } |
1691 | ++catI; | 1691 | ++catI; |
1692 | if (likely(!wasDeepLocked)) | 1692 | if (likely(!wasDeepLocked)) |
1693 | ++oldCatStatI; | 1693 | ++oldCatStatI; |
1694 | } | 1694 | } |
1695 | delete_and_null(oldLockStates); | 1695 | delete_and_null(oldLockStates); |
1696 | if (unlikely(wasDeepLocked)) { | 1696 | if (unlikely(wasDeepLocked)) { |
1697 | /* error fallback... */ | 1697 | /* error fallback... */ |
1698 | unsetDocStatFlag(DOC_STAT_DEEPLOCKED); | 1698 | unsetDocStatFlag(DOC_STAT_DEEPLOCKED); |
1699 | emitDataChanged(this); | 1699 | emitDataChanged(this); |
1700 | printDebug("WARNING: unlockAll_tempoary(true) " | 1700 | printDebug("WARNING: unlockAll_tempoary(true) " |
1701 | "deeplock fallback!"); | 1701 | "deeplock fallback!"); |
1702 | } | 1702 | } |
1703 | printDebug("tempoary unlocking of dta reverted."); | 1703 | printDebug("tempoary unlocking of dta reverted."); |
1704 | } else { | 1704 | } else { |
1705 | printDebug("unlockAll_tempoary(true): nothing to do."); | 1705 | printDebug("unlockAll_tempoary(true): nothing to do."); |
1706 | } | 1706 | } |
1707 | timer()->start(DocTimer::id_autoLockTimer); | 1707 | timer()->start(DocTimer::id_autoLockTimer); |
1708 | } else {// unlock all data tempoary | 1708 | } else {// unlock all data tempoary |
1709 | if (unlikely(oldLockStates != 0)) { | 1709 | if (unlikely(oldLockStates != 0)) { |
1710 | /* DOH! We have already unlocked the data tempoarly. | 1710 | /* DOH! We have already unlocked the data tempoarly. |
1711 | * No need to do it twice. ;) | 1711 | * No need to do it twice. ;) |
1712 | */ | 1712 | */ |
1713 | BUG(); | 1713 | BUG(); |
1714 | return false; | 1714 | return false; |
1715 | } | 1715 | } |
1716 | wasDeepLocked = false; | 1716 | wasDeepLocked = false; |
1717 | bool mustUnlock = false; | 1717 | bool mustUnlock = false; |
1718 | if (isDeepLocked()) { | 1718 | if (isDeepLocked()) { |
1719 | PwMerror ret; | 1719 | PwMerror ret; |
1720 | while (1) { | 1720 | while (1) { |
1721 | ret = deepLock(false); | 1721 | ret = deepLock(false); |
1722 | if (ret == e_success) { | 1722 | if (ret == e_success) { |
1723 | break; | 1723 | break; |
1724 | } else if (ret == e_wrongPw) { | 1724 | } else if (ret == e_wrongPw) { |
1725 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1725 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1726 | } else { | 1726 | } else { |
1727 | printDebug("deep-unlocking failed while " | 1727 | printDebug("deep-unlocking failed while " |
1728 | "tempoary unlocking!"); | 1728 | "tempoary unlocking!"); |
1729 | return false; | 1729 | return false; |
1730 | } | 1730 | } |
1731 | } | 1731 | } |
1732 | wasDeepLocked = true; | 1732 | wasDeepLocked = true; |
1733 | mustUnlock = true; | 1733 | mustUnlock = true; |
1734 | } else { | 1734 | } else { |
1735 | // first check if it's needed to unlock some entries | 1735 | // first check if it's needed to unlock some entries |
1736 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), | 1736 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), |
1737 | catEnd = dti.dta.end(), | 1737 | catEnd = dti.dta.end(), |
1738 | catI = catBegin; | 1738 | catI = catBegin; |
1739 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 1739 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
1740 | while (catI != catEnd) { | 1740 | while (catI != catEnd) { |
1741 | entrBegin = catI->d.begin(); | 1741 | entrBegin = catI->d.begin(); |
1742 | entrEnd = catI->d.end(); | 1742 | entrEnd = catI->d.end(); |
1743 | entrI = entrBegin; | 1743 | entrI = entrBegin; |
1744 | while (entrI != entrEnd) { | 1744 | while (entrI != entrEnd) { |
1745 | if (entrI->lockStat == true) { | 1745 | if (entrI->lockStat == true) { |
1746 | mustUnlock = true; | 1746 | mustUnlock = true; |
1747 | break; | 1747 | break; |
1748 | } | 1748 | } |
1749 | ++entrI; | 1749 | ++entrI; |
1750 | } | 1750 | } |
1751 | if (mustUnlock) | 1751 | if (mustUnlock) |
1752 | break; | 1752 | break; |
1753 | ++catI; | 1753 | ++catI; |
1754 | } | 1754 | } |
1755 | } | 1755 | } |
1756 | if (!mustUnlock) { | 1756 | if (!mustUnlock) { |
1757 | // nothing to do. | 1757 | // nothing to do. |
1758 | timer()->stop(DocTimer::id_autoLockTimer); | 1758 | timer()->stop(DocTimer::id_autoLockTimer); |
1759 | printDebug("unlockAll_tempoary(): nothing to do."); | 1759 | printDebug("unlockAll_tempoary(): nothing to do."); |
1760 | return true; | 1760 | return true; |
1761 | } else if (!wasDeepLocked) { | 1761 | } else if (!wasDeepLocked) { |
1762 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW) && | 1762 | if (!getDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW) && |
1763 | currentPw != "") { | 1763 | currentPw != "") { |
1764 | /* we can't unlock without mpw, so | 1764 | /* we can't unlock without mpw, so |
1765 | * we need to ask for it. | 1765 | * we need to ask for it. |
1766 | */ | 1766 | */ |
1767 | QString pw; | 1767 | QString pw; |
1768 | while (1) { | 1768 | while (1) { |
1769 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1769 | pw = requestMpw(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1770 | if (pw == "") { | 1770 | if (pw == "") { |
1771 | return false; | 1771 | return false; |
1772 | } else if (pw == currentPw) { | 1772 | } else if (pw == currentPw) { |
1773 | break; | 1773 | break; |
1774 | } | 1774 | } |
1775 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); | 1775 | wrongMpwMsgBox(getDocStatFlag(DOC_STAT_USE_CHIPCARD)); |
1776 | } | 1776 | } |
1777 | } | 1777 | } |
1778 | } | 1778 | } |
1779 | timer()->stop(DocTimer::id_autoLockTimer); | 1779 | timer()->stop(DocTimer::id_autoLockTimer); |
1780 | oldLockStates = new vector< vector<bool> >; | 1780 | oldLockStates = new vector< vector<bool> >; |
1781 | vector<bool> tmp_vec; | 1781 | vector<bool> tmp_vec; |
1782 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), | 1782 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), |
1783 | catEnd = dti.dta.end(), | 1783 | catEnd = dti.dta.end(), |
1784 | catI = catBegin; | 1784 | catI = catBegin; |
1785 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 1785 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
1786 | while (catI != catEnd) { | 1786 | while (catI != catEnd) { |
1787 | entrBegin = catI->d.begin(); | 1787 | entrBegin = catI->d.begin(); |
1788 | entrEnd = catI->d.end(); | 1788 | entrEnd = catI->d.end(); |
1789 | entrI = entrBegin; | 1789 | entrI = entrBegin; |
1790 | while (entrI != entrEnd) { | 1790 | while (entrI != entrEnd) { |
1791 | if (!wasDeepLocked) { | 1791 | if (!wasDeepLocked) { |
1792 | tmp_vec.push_back(entrI->lockStat); | 1792 | tmp_vec.push_back(entrI->lockStat); |
1793 | } | 1793 | } |
1794 | entrI->lockStat = false; | 1794 | entrI->lockStat = false; |
1795 | ++entrI; | 1795 | ++entrI; |
1796 | } | 1796 | } |
1797 | if (!wasDeepLocked) { | 1797 | if (!wasDeepLocked) { |
1798 | oldLockStates->push_back(tmp_vec); | 1798 | oldLockStates->push_back(tmp_vec); |
1799 | tmp_vec.clear(); | 1799 | tmp_vec.clear(); |
1800 | } | 1800 | } |
1801 | ++catI; | 1801 | ++catI; |
1802 | } | 1802 | } |
1803 | printDebug("tempoary unlocked dta."); | 1803 | printDebug("tempoary unlocked dta."); |
1804 | } | 1804 | } |
1805 | 1805 | ||
1806 | return true; | 1806 | return true; |
1807 | } | 1807 | } |
1808 | 1808 | ||
1809 | PwMerror PwMDoc::deepLock(bool lock, bool saveToFile) | 1809 | PwMerror PwMDoc::deepLock(bool lock, bool saveToFile) |
1810 | { | 1810 | { |
1811 | PwMerror ret; | 1811 | PwMerror ret; |
1812 | 1812 | ||
1813 | if (lock) { | 1813 | if (lock) { |
1814 | if (isDeepLocked()) | 1814 | if (isDeepLocked()) |
1815 | return e_lock; | 1815 | return e_lock; |
1816 | if (saveToFile) { | 1816 | if (saveToFile) { |
1817 | if (isDocEmpty()) | 1817 | if (isDocEmpty()) |
1818 | return e_docIsEmpty; | 1818 | return e_docIsEmpty; |
1819 | ret = saveDoc(conf()->confGlobCompression()); | 1819 | ret = saveDoc(conf()->confGlobCompression()); |
1820 | if (ret == e_filename) { | 1820 | if (ret == e_filename) { |
1821 | /* the doc wasn't saved to a file | 1821 | /* the doc wasn't saved to a file |
1822 | * by the user, yet. | 1822 | * by the user, yet. |
1823 | */ | 1823 | */ |
1824 | cantDeeplock_notSavedMsgBox(); | 1824 | cantDeeplock_notSavedMsgBox(); |
1825 | return e_docNotSaved; | 1825 | return e_docNotSaved; |
1826 | } else if (ret != e_success) { | 1826 | } else if (ret != e_success) { |
1827 | return e_lock; | 1827 | return e_lock; |
1828 | } | 1828 | } |
1829 | } | 1829 | } |
1830 | timer()->stop(DocTimer::id_autoLockTimer); | 1830 | timer()->stop(DocTimer::id_autoLockTimer); |
1831 | clearDoc(); | 1831 | clearDoc(); |
1832 | PwMDataItem d; | 1832 | PwMDataItem d; |
1833 | d.desc = IS_DEEPLOCKED_SHORTMSG.latin1(); | 1833 | d.desc = IS_DEEPLOCKED_SHORTMSG.latin1(); |
1834 | d.comment = IS_DEEPLOCKED_MSG.latin1(); | 1834 | d.comment = IS_DEEPLOCKED_MSG.latin1(); |
1835 | d.listViewPos = 0; | 1835 | d.listViewPos = 0; |
1836 | addEntry(DEFAULT_CATEGORY, &d, true); | 1836 | addEntry(DEFAULT_CATEGORY, &d, true); |
1837 | lockAt(DEFAULT_CATEGORY, 0, true); | 1837 | lockAt(DEFAULT_CATEGORY, 0, true); |
1838 | unsetDocStatFlag(DOC_STAT_DISK_DIRTY); | 1838 | unsetDocStatFlag(DOC_STAT_DISK_DIRTY); |
1839 | setDocStatFlag(DOC_STAT_DEEPLOCKED); | 1839 | setDocStatFlag(DOC_STAT_DEEPLOCKED); |
1840 | } else { | 1840 | } else { |
1841 | if (!isDeepLocked()) | 1841 | if (!isDeepLocked()) |
1842 | return e_lock; | 1842 | return e_lock; |
1843 | ret = openDoc(&filename, (conf()->confGlobUnlockOnOpen()) | 1843 | ret = openDoc(&filename, (conf()->confGlobUnlockOnOpen()) |
1844 | ? 0 : 1); | 1844 | ? 0 : 1); |
1845 | if (ret == e_wrongPw) { | 1845 | if (ret == e_wrongPw) { |
1846 | return e_wrongPw; | 1846 | return e_wrongPw; |
1847 | } else if (ret != e_success) { | 1847 | } else if (ret != e_success) { |
1848 | printDebug(string("PwMDoc::deepLock(false): ERR! openDoc() == ") | 1848 | printDebug(string("PwMDoc::deepLock(false): ERR! openDoc() == ") |
1849 | + tostr(static_cast<int>(ret))); | 1849 | + tostr(static_cast<int>(ret))); |
1850 | return e_lock; | 1850 | return e_lock; |
1851 | } | 1851 | } |
1852 | unsetDocStatFlag(DOC_STAT_DEEPLOCKED); | 1852 | unsetDocStatFlag(DOC_STAT_DEEPLOCKED); |
1853 | timer()->start(DocTimer::id_autoLockTimer); | 1853 | timer()->start(DocTimer::id_autoLockTimer); |
1854 | } | 1854 | } |
1855 | 1855 | ||
1856 | emitDataChanged(this); | 1856 | emitDataChanged(this); |
1857 | return e_success; | 1857 | return e_success; |
1858 | } | 1858 | } |
1859 | 1859 | ||
1860 | void PwMDoc::_deepUnlock() | 1860 | void PwMDoc::_deepUnlock() |
1861 | { | 1861 | { |
1862 | deepLock(false); | 1862 | deepLock(false); |
1863 | } | 1863 | } |
1864 | 1864 | ||
1865 | void PwMDoc::clearDoc() | 1865 | void PwMDoc::clearDoc() |
1866 | { | 1866 | { |
1867 | dti.clear(); | 1867 | dti.clear(); |
1868 | PwMCategoryItem d; | 1868 | PwMCategoryItem d; |
1869 | d.name = DEFAULT_CATEGORY.latin1(); | 1869 | d.name = DEFAULT_CATEGORY.latin1(); |
1870 | dti.dta.push_back(d); | 1870 | dti.dta.push_back(d); |
1871 | currentPw = ""; | 1871 | currentPw = ""; |
1872 | unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); | 1872 | unsetDocStatFlag(DOC_STAT_UNLOCK_WITHOUT_PW); |
1873 | } | 1873 | } |
1874 | 1874 | ||
1875 | void PwMDoc::changeCurrentPw() | 1875 | void PwMDoc::changeCurrentPw() |
1876 | { | 1876 | { |
1877 | if (currentPw == "") | 1877 | if (currentPw == "") |
1878 | return; // doc hasn't been saved. No mpw available. | 1878 | return; // doc hasn't been saved. No mpw available. |
1879 | bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD); | 1879 | bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD); |
1880 | QString pw = requestMpwChange(¤tPw, &useChipcard); | 1880 | QString pw = requestMpwChange(¤tPw, &useChipcard); |
1881 | if (pw == "") | 1881 | if (pw == "") |
1882 | return; | 1882 | return; |
1883 | if (useChipcard) | 1883 | if (useChipcard) |
1884 | setDocStatFlag(DOC_STAT_USE_CHIPCARD); | 1884 | setDocStatFlag(DOC_STAT_USE_CHIPCARD); |
1885 | else | 1885 | else |
1886 | unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); | 1886 | unsetDocStatFlag(DOC_STAT_USE_CHIPCARD); |
1887 | setCurrentPw(pw); | 1887 | setCurrentPw(pw); |
1888 | } | 1888 | } |
1889 | 1889 | ||
1890 | void PwMDoc::setListViewPos(const QString &category, unsigned int index, | 1890 | void PwMDoc::setListViewPos(const QString &category, unsigned int index, |
1891 | int pos) | 1891 | int pos) |
1892 | { | 1892 | { |
1893 | unsigned int cat = 0; | 1893 | unsigned int cat = 0; |
1894 | 1894 | ||
1895 | if (!findCategory(category, &cat)) { | 1895 | if (!findCategory(category, &cat)) { |
1896 | BUG(); | 1896 | BUG(); |
1897 | return; | 1897 | return; |
1898 | } | 1898 | } |
1899 | setListViewPos(cat, index, pos); | 1899 | setListViewPos(cat, index, pos); |
1900 | } | 1900 | } |
1901 | 1901 | ||
1902 | void PwMDoc::setListViewPos(unsigned int category, unsigned int index, | 1902 | void PwMDoc::setListViewPos(unsigned int category, unsigned int index, |
1903 | int pos) | 1903 | int pos) |
1904 | { | 1904 | { |
1905 | dti.dta[category].d[index].listViewPos = pos; | 1905 | dti.dta[category].d[index].listViewPos = pos; |
1906 | 1906 | ||
1907 | /* FIXME workaround: don't flag dirty, because this function sometimes | 1907 | /* FIXME workaround: don't flag dirty, because this function sometimes |
1908 | * get's called when it shouldn't. It's because PwMView assumes | 1908 | * get's called when it shouldn't. It's because PwMView assumes |
1909 | * the user resorted the UI on behalf of signal layoutChanged(). | 1909 | * the user resorted the UI on behalf of signal layoutChanged(). |
1910 | * This is somewhat broken and incorrect, but I've no other | 1910 | * This is somewhat broken and incorrect, but I've no other |
1911 | * solution for now. | 1911 | * solution for now. |
1912 | */ | 1912 | */ |
1913 | //setDocStatFlag(DOC_STAT_DISK_DIRTY); | 1913 | //setDocStatFlag(DOC_STAT_DISK_DIRTY); |
1914 | } | 1914 | } |
1915 | 1915 | ||
1916 | int PwMDoc::getListViewPos(const QString &category, unsigned int index) | 1916 | int PwMDoc::getListViewPos(const QString &category, unsigned int index) |
1917 | { | 1917 | { |
1918 | unsigned int cat = 0; | 1918 | unsigned int cat = 0; |
1919 | 1919 | ||
1920 | if (!findCategory(category, &cat)) { | 1920 | if (!findCategory(category, &cat)) { |
1921 | BUG(); | 1921 | BUG(); |
1922 | return -1; | 1922 | return -1; |
1923 | } | 1923 | } |
1924 | 1924 | ||
1925 | return dti.dta[cat].d[index].listViewPos; | 1925 | return dti.dta[cat].d[index].listViewPos; |
1926 | } | 1926 | } |
1927 | 1927 | ||
1928 | void PwMDoc::findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, | 1928 | void PwMDoc::findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn, |
1929 | vector<unsigned int> *foundPositions, bool breakAfterFound, | 1929 | vector<unsigned int> *foundPositions, bool breakAfterFound, |
1930 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) | 1930 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) |
1931 | { | 1931 | { |
1932 | PWM_ASSERT(foundPositions); | 1932 | PWM_ASSERT(foundPositions); |
1933 | PWM_ASSERT(searchIn); | 1933 | PWM_ASSERT(searchIn); |
1934 | foundPositions->clear(); | 1934 | foundPositions->clear(); |
1935 | 1935 | ||
1936 | unsigned int i, entries = numEntries(category); | 1936 | unsigned int i, entries = numEntries(category); |
1937 | for (i = 0; i < entries; ++i) { | 1937 | for (i = 0; i < entries; ++i) { |
1938 | if (searchIn & SEARCH_IN_DESC) { | 1938 | if (searchIn & SEARCH_IN_DESC) { |
1939 | if (!compareString(find.desc, dti.dta[category].d[i].desc, | 1939 | if (!compareString(find.desc, dti.dta[category].d[i].desc, |
1940 | caseSensitive, exactWordMatch)) { | 1940 | caseSensitive, exactWordMatch)) { |
1941 | continue; | 1941 | continue; |
1942 | } | 1942 | } |
1943 | } | 1943 | } |
1944 | if (searchIn & SEARCH_IN_NAME) { | 1944 | if (searchIn & SEARCH_IN_NAME) { |
1945 | if (!compareString(find.name, dti.dta[category].d[i].name, | 1945 | if (!compareString(find.name, dti.dta[category].d[i].name, |
1946 | caseSensitive, exactWordMatch)) { | 1946 | caseSensitive, exactWordMatch)) { |
1947 | continue; | 1947 | continue; |
1948 | } | 1948 | } |
1949 | } | 1949 | } |
1950 | if (searchIn & SEARCH_IN_PW) { | 1950 | if (searchIn & SEARCH_IN_PW) { |
1951 | bool wasLocked = isLocked(category, i); | 1951 | bool wasLocked = isLocked(category, i); |
1952 | getDataChangedLock(); | 1952 | getDataChangedLock(); |
1953 | lockAt(category, i, false); | 1953 | lockAt(category, i, false); |
1954 | if (!compareString(find.pw, dti.dta[category].d[i].pw, | 1954 | if (!compareString(find.pw, dti.dta[category].d[i].pw, |
1955 | caseSensitive, exactWordMatch)) { | 1955 | caseSensitive, exactWordMatch)) { |
1956 | lockAt(category, i, wasLocked); | 1956 | lockAt(category, i, wasLocked); |
1957 | putDataChangedLock(); | 1957 | putDataChangedLock(); |
1958 | continue; | 1958 | continue; |
1959 | } | 1959 | } |
1960 | lockAt(category, i, wasLocked); | 1960 | lockAt(category, i, wasLocked); |
1961 | putDataChangedLock(); | 1961 | putDataChangedLock(); |
1962 | } | 1962 | } |
1963 | if (searchIn & SEARCH_IN_COMMENT) { | 1963 | if (searchIn & SEARCH_IN_COMMENT) { |
1964 | if (!compareString(find.comment, dti.dta[category].d[i].comment, | 1964 | if (!compareString(find.comment, dti.dta[category].d[i].comment, |
1965 | caseSensitive, exactWordMatch)) { | 1965 | caseSensitive, exactWordMatch)) { |
1966 | continue; | 1966 | continue; |
1967 | } | 1967 | } |
1968 | } | 1968 | } |
1969 | if (searchIn & SEARCH_IN_URL) { | 1969 | if (searchIn & SEARCH_IN_URL) { |
1970 | if (!compareString(find.url, dti.dta[category].d[i].url, | 1970 | if (!compareString(find.url, dti.dta[category].d[i].url, |
1971 | caseSensitive, exactWordMatch)) { | 1971 | caseSensitive, exactWordMatch)) { |
1972 | continue; | 1972 | continue; |
1973 | } | 1973 | } |
1974 | } | 1974 | } |
1975 | if (searchIn & SEARCH_IN_LAUNCHER) { | 1975 | if (searchIn & SEARCH_IN_LAUNCHER) { |
1976 | if (!compareString(find.launcher, dti.dta[category].d[i].launcher, | 1976 | if (!compareString(find.launcher, dti.dta[category].d[i].launcher, |
1977 | caseSensitive, exactWordMatch)) { | 1977 | caseSensitive, exactWordMatch)) { |
1978 | continue; | 1978 | continue; |
1979 | } | 1979 | } |
1980 | } | 1980 | } |
1981 | 1981 | ||
1982 | // all selected "searchIn" matched. | 1982 | // all selected "searchIn" matched. |
1983 | foundPositions->push_back(i); | 1983 | foundPositions->push_back(i); |
1984 | if (breakAfterFound) | 1984 | if (breakAfterFound) |
1985 | break; | 1985 | break; |
1986 | } | 1986 | } |
1987 | 1987 | ||
1988 | if (sortByLvp && foundPositions->size() > 1) { | 1988 | if (sortByLvp && foundPositions->size() > 1) { |
1989 | vector< pair<unsigned int /* foundPosition (real doc pos) */, | 1989 | vector< pair<unsigned int /* foundPosition (real doc pos) */, |
1990 | unsigned int /* lvp-pos */> > tmp_vec; | 1990 | unsigned int /* lvp-pos */> > tmp_vec; |
1991 | 1991 | ||
1992 | unsigned int i, items = foundPositions->size(); | 1992 | unsigned int i, items = foundPositions->size(); |
1993 | pair<unsigned int, unsigned int> tmp_pair; | 1993 | pair<unsigned int, unsigned int> tmp_pair; |
1994 | for (i = 0; i < items; ++i) { | 1994 | for (i = 0; i < items; ++i) { |
1995 | tmp_pair.first = (*foundPositions)[i]; | 1995 | tmp_pair.first = (*foundPositions)[i]; |
1996 | tmp_pair.second = dti.dta[category].d[(*foundPositions)[i]].listViewPos; | 1996 | tmp_pair.second = dti.dta[category].d[(*foundPositions)[i]].listViewPos; |
1997 | tmp_vec.push_back(tmp_pair); | 1997 | tmp_vec.push_back(tmp_pair); |
1998 | } | 1998 | } |
1999 | sort(tmp_vec.begin(), tmp_vec.end(), dta_lvp_greater()); | 1999 | sort(tmp_vec.begin(), tmp_vec.end(), dta_lvp_greater()); |
2000 | foundPositions->clear(); | 2000 | foundPositions->clear(); |
2001 | for (i = 0; i < items; ++i) { | 2001 | for (i = 0; i < items; ++i) { |
2002 | foundPositions->push_back(tmp_vec[i].first); | 2002 | foundPositions->push_back(tmp_vec[i].first); |
2003 | } | 2003 | } |
2004 | } | 2004 | } |
2005 | } | 2005 | } |
2006 | 2006 | ||
2007 | void PwMDoc::findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, | 2007 | void PwMDoc::findEntry(const QString &category, PwMDataItem find, unsigned int searchIn, |
2008 | vector<unsigned int> *foundPositions, bool breakAfterFound, | 2008 | vector<unsigned int> *foundPositions, bool breakAfterFound, |
2009 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) | 2009 | bool caseSensitive, bool exactWordMatch, bool sortByLvp) |
2010 | { | 2010 | { |
2011 | PWM_ASSERT(foundPositions); | 2011 | PWM_ASSERT(foundPositions); |
2012 | unsigned int cat = 0; | 2012 | unsigned int cat = 0; |
2013 | 2013 | ||
2014 | if (!findCategory(category, &cat)) { | 2014 | if (!findCategory(category, &cat)) { |
2015 | foundPositions->clear(); | 2015 | foundPositions->clear(); |
2016 | return; | 2016 | return; |
2017 | } | 2017 | } |
2018 | 2018 | ||
2019 | findEntry(cat, find, searchIn, foundPositions, breakAfterFound, | 2019 | findEntry(cat, find, searchIn, foundPositions, breakAfterFound, |
2020 | caseSensitive, exactWordMatch, sortByLvp); | 2020 | caseSensitive, exactWordMatch, sortByLvp); |
2021 | } | 2021 | } |
2022 | 2022 | ||
2023 | bool PwMDoc::compareString(const string &s1, const string &s2, bool caseSensitive, | 2023 | bool PwMDoc::compareString(const string &s1, const string &s2, bool caseSensitive, |
2024 | bool exactWordMatch) | 2024 | bool exactWordMatch) |
2025 | { | 2025 | { |
2026 | QString _s1(s1.c_str()); | 2026 | QString _s1(s1.c_str()); |
2027 | QString _s2(s2.c_str()); | 2027 | QString _s2(s2.c_str()); |
2028 | if (!caseSensitive) { | 2028 | if (!caseSensitive) { |
2029 | _s1 = _s1.lower(); | 2029 | _s1 = _s1.lower(); |
2030 | _s2 = _s2.lower(); | 2030 | _s2 = _s2.lower(); |
2031 | } | 2031 | } |
2032 | if (exactWordMatch ? (_s1 == _s2) : (_s2.find(_s1) != -1)) | 2032 | if (exactWordMatch ? (_s1 == _s2) : (_s2.find(_s1) != -1)) |
2033 | return true; | 2033 | return true; |
2034 | return false; | 2034 | return false; |
2035 | } | 2035 | } |
2036 | 2036 | ||
2037 | bool PwMDoc::findCategory(const QString &name, unsigned int *index) | 2037 | bool PwMDoc::findCategory(const QString &name, unsigned int *index) |
2038 | { | 2038 | { |
2039 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), | 2039 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), |
2040 | end = dti.dta.end(); | 2040 | end = dti.dta.end(); |
2041 | while (i != end) { | 2041 | while (i != end) { |
2042 | if ((*i).name == name.latin1()) { | 2042 | if ((*i).name == name.latin1()) { |
2043 | if (index) { | 2043 | if (index) { |
2044 | *index = i - dti.dta.begin(); | 2044 | *index = i - dti.dta.begin(); |
2045 | } | 2045 | } |
2046 | return true; | 2046 | return true; |
2047 | } | 2047 | } |
2048 | ++i; | 2048 | ++i; |
2049 | } | 2049 | } |
2050 | return false; | 2050 | return false; |
2051 | } | 2051 | } |
2052 | 2052 | ||
2053 | bool PwMDoc::renameCategory(const QString &category, const QString &newName) | 2053 | bool PwMDoc::renameCategory(const QString &category, const QString &newName) |
2054 | { | 2054 | { |
2055 | unsigned int cat = 0; | 2055 | unsigned int cat = 0; |
2056 | 2056 | ||
2057 | if (!findCategory(category, &cat)) | 2057 | if (!findCategory(category, &cat)) |
2058 | return false; | 2058 | return false; |
2059 | 2059 | ||
2060 | return renameCategory(cat, newName); | 2060 | return renameCategory(cat, newName); |
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | bool PwMDoc::renameCategory(unsigned int category, const QString &newName, | 2063 | bool PwMDoc::renameCategory(unsigned int category, const QString &newName, |
2064 | bool dontFlagDirty) | 2064 | bool dontFlagDirty) |
2065 | { | 2065 | { |
2066 | if (category > numCategories() - 1) | 2066 | if (category > numCategories() - 1) |
2067 | return false; | 2067 | return false; |
2068 | 2068 | ||
2069 | dti.dta[category].name = newName.latin1(); | 2069 | dti.dta[category].name = newName.latin1(); |
2070 | if (!dontFlagDirty) | 2070 | if (!dontFlagDirty) |
2071 | flagDirty(); | 2071 | flagDirty(); |
2072 | 2072 | ||
2073 | return true; | 2073 | return true; |
2074 | } | 2074 | } |
2075 | 2075 | ||
2076 | bool PwMDoc::delCategory(const QString &category) | 2076 | bool PwMDoc::delCategory(const QString &category) |
2077 | { | 2077 | { |
2078 | unsigned int cat = 0; | 2078 | unsigned int cat = 0; |
2079 | 2079 | ||
2080 | if (!findCategory(category, &cat)) | 2080 | if (!findCategory(category, &cat)) |
2081 | return false; | 2081 | return false; |
2082 | 2082 | ||
2083 | return delCategory(cat); | 2083 | return delCategory(cat); |
2084 | } | 2084 | } |
2085 | 2085 | ||
2086 | bool PwMDoc::delCategory(unsigned int category, bool dontFlagDirty) | 2086 | bool PwMDoc::delCategory(unsigned int category, bool dontFlagDirty) |
2087 | { | 2087 | { |
2088 | if (category > numCategories() - 1) | 2088 | if (category > numCategories() - 1) |
2089 | return false; | 2089 | return false; |
2090 | 2090 | ||
2091 | // We don't delete it, if it is the last existing | 2091 | // We don't delete it, if it is the last existing |
2092 | // category! Instead we rename it to "Default". | 2092 | // category! Instead we rename it to "Default". |
2093 | if (numCategories() > 1) { | 2093 | if (numCategories() > 1) { |
2094 | dti.dta.erase(dti.dta.begin() + category); | 2094 | dti.dta.erase(dti.dta.begin() + category); |
2095 | } else { | 2095 | } else { |
2096 | renameCategory(category, DEFAULT_CATEGORY, dontFlagDirty); | 2096 | renameCategory(category, DEFAULT_CATEGORY, dontFlagDirty); |
2097 | return true; | 2097 | return true; |
2098 | } | 2098 | } |
2099 | if (!dontFlagDirty) | 2099 | if (!dontFlagDirty) |
2100 | flagDirty(); | 2100 | flagDirty(); |
2101 | 2101 | ||
2102 | return true; | 2102 | return true; |
2103 | } | 2103 | } |
2104 | 2104 | ||
2105 | void PwMDoc::delAllEmptyCat(bool dontFlagDirty) | 2105 | void PwMDoc::delAllEmptyCat(bool dontFlagDirty) |
2106 | { | 2106 | { |
2107 | vector<PwMCategoryItem>::iterator begin = dti.dta.begin(), | 2107 | vector<PwMCategoryItem>::iterator begin = dti.dta.begin(), |
2108 | end = dti.dta.end(), | 2108 | end = dti.dta.end(), |
2109 | i = begin; | 2109 | i = begin; |
2110 | while (i != end) { | 2110 | while (i != end) { |
2111 | if (i->d.empty()) { | 2111 | if (i->d.empty()) { |
2112 | delCategory(begin - i, dontFlagDirty); | 2112 | delCategory(begin - i, dontFlagDirty); |
2113 | } | 2113 | } |
2114 | ++i; | 2114 | ++i; |
2115 | } | 2115 | } |
2116 | } | 2116 | } |
2117 | 2117 | ||
2118 | void PwMDoc::getCategoryList(vector<string> *list) | 2118 | void PwMDoc::getCategoryList(vector<string> *list) |
2119 | { | 2119 | { |
2120 | PWM_ASSERT(list); | 2120 | PWM_ASSERT(list); |
2121 | list->clear(); | 2121 | list->clear(); |
2122 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), | 2122 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), |
2123 | end = dti.dta.end(); | 2123 | end = dti.dta.end(); |
2124 | while (i != end) { | 2124 | while (i != end) { |
2125 | list->push_back(i->name); | 2125 | list->push_back(i->name); |
2126 | ++i; | 2126 | ++i; |
2127 | } | 2127 | } |
2128 | } | 2128 | } |
2129 | 2129 | ||
2130 | void PwMDoc::getCategoryList(QStringList *list) | 2130 | void PwMDoc::getCategoryList(QStringList *list) |
2131 | { | 2131 | { |
2132 | PWM_ASSERT(list); | 2132 | PWM_ASSERT(list); |
2133 | list->clear(); | 2133 | list->clear(); |
2134 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), | 2134 | vector<PwMCategoryItem>::iterator i = dti.dta.begin(), |
2135 | end = dti.dta.end(); | 2135 | end = dti.dta.end(); |
2136 | while (i != end) { | 2136 | while (i != end) { |
2137 | #ifndef PWM_EMBEDDED | 2137 | #ifndef PWM_EMBEDDED |
2138 | list->push_back(i->name.c_str()); | 2138 | list->push_back(i->name.c_str()); |
2139 | #else | 2139 | #else |
2140 | list->append(i->name.c_str()); | 2140 | list->append(i->name.c_str()); |
2141 | #endif | 2141 | #endif |
2142 | ++i; | 2142 | ++i; |
2143 | } | 2143 | } |
2144 | } | 2144 | } |
2145 | 2145 | ||
2146 | void PwMDoc::getEntryList(const QString &category, QStringList *list) | 2146 | void PwMDoc::getEntryList(const QString &category, QStringList *list) |
2147 | { | 2147 | { |
2148 | PWM_ASSERT(list); | 2148 | PWM_ASSERT(list); |
2149 | unsigned int cat = 0; | 2149 | unsigned int cat = 0; |
2150 | if (!findCategory(category, &cat)) { | 2150 | if (!findCategory(category, &cat)) { |
2151 | list->clear(); | 2151 | list->clear(); |
2152 | return; | 2152 | return; |
2153 | } | 2153 | } |
2154 | getEntryList(cat, list); | 2154 | getEntryList(cat, list); |
2155 | } | 2155 | } |
2156 | 2156 | ||
2157 | void PwMDoc::getEntryList(const QString &category, vector<string> *list) | 2157 | void PwMDoc::getEntryList(const QString &category, vector<string> *list) |
2158 | { | 2158 | { |
2159 | PWM_ASSERT(list); | 2159 | PWM_ASSERT(list); |
2160 | unsigned int cat = 0; | 2160 | unsigned int cat = 0; |
2161 | if (!findCategory(category, &cat)) { | 2161 | if (!findCategory(category, &cat)) { |
2162 | list->clear(); | 2162 | list->clear(); |
2163 | return; | 2163 | return; |
2164 | } | 2164 | } |
2165 | getEntryList(cat, list); | 2165 | getEntryList(cat, list); |
2166 | } | 2166 | } |
2167 | 2167 | ||
2168 | void PwMDoc::getEntryList(unsigned int category, vector<string> *list) | 2168 | void PwMDoc::getEntryList(unsigned int category, vector<string> *list) |
2169 | { | 2169 | { |
2170 | PWM_ASSERT(list); | 2170 | PWM_ASSERT(list); |
2171 | list->clear(); | 2171 | list->clear(); |
2172 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), | 2172 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), |
2173 | end = dti.dta[category].d.end(), | 2173 | end = dti.dta[category].d.end(), |
2174 | i = begin; | 2174 | i = begin; |
2175 | while (i != end) { | 2175 | while (i != end) { |
2176 | list->push_back(i->desc); | 2176 | list->push_back(i->desc); |
2177 | ++i; | 2177 | ++i; |
2178 | } | 2178 | } |
2179 | } | 2179 | } |
2180 | 2180 | ||
2181 | void PwMDoc::getEntryList(unsigned int category, QStringList *list) | 2181 | void PwMDoc::getEntryList(unsigned int category, QStringList *list) |
2182 | { | 2182 | { |
2183 | PWM_ASSERT(list); | 2183 | PWM_ASSERT(list); |
2184 | list->clear(); | 2184 | list->clear(); |
2185 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), | 2185 | vector<PwMDataItem>::iterator begin = dti.dta[category].d.begin(), |
2186 | end = dti.dta[category].d.end(), | 2186 | end = dti.dta[category].d.end(), |
2187 | i = begin; | 2187 | i = begin; |
2188 | while (i != end) { | 2188 | while (i != end) { |
2189 | #ifndef PWM_EMBEDDED | 2189 | #ifndef PWM_EMBEDDED |
2190 | list->push_back(i->desc.c_str()); | 2190 | list->push_back(i->desc.c_str()); |
2191 | #else | 2191 | #else |
2192 | list->append(i->desc.c_str()); | 2192 | list->append(i->desc.c_str()); |
2193 | #endif | 2193 | #endif |
2194 | ++i; | 2194 | ++i; |
2195 | } | 2195 | } |
2196 | } | 2196 | } |
2197 | 2197 | ||
2198 | bool PwMDoc::execLauncher(const QString &category, unsigned int entryIndex) | 2198 | bool PwMDoc::execLauncher(const QString &category, unsigned int entryIndex) |
2199 | { | 2199 | { |
2200 | unsigned int cat = 0; | 2200 | unsigned int cat = 0; |
2201 | 2201 | ||
2202 | if (!findCategory(category, &cat)) | 2202 | if (!findCategory(category, &cat)) |
2203 | return false; | 2203 | return false; |
2204 | 2204 | ||
2205 | return execLauncher(cat, entryIndex); | 2205 | return execLauncher(cat, entryIndex); |
2206 | } | 2206 | } |
2207 | 2207 | ||
2208 | bool PwMDoc::execLauncher(unsigned int category, unsigned int entryIndex) | 2208 | bool PwMDoc::execLauncher(unsigned int category, unsigned int entryIndex) |
2209 | { | 2209 | { |
2210 | if (geteuid() == 0) { | 2210 | if (geteuid() == 0) { |
2211 | rootAlertMsgBox(); | 2211 | rootAlertMsgBox(); |
2212 | return false; | 2212 | return false; |
2213 | } | 2213 | } |
2214 | QString command(dti.dta[category].d[entryIndex].launcher.c_str()); | 2214 | QString command(dti.dta[category].d[entryIndex].launcher.c_str()); |
2215 | bool wasLocked = isLocked(category, entryIndex); | 2215 | bool wasLocked = isLocked(category, entryIndex); |
2216 | 2216 | ||
2217 | if (command.find("$p") != -1) { | 2217 | if (command.find("$p") != -1) { |
2218 | /* the user requested the password to be included | 2218 | /* the user requested the password to be included |
2219 | * into the command. We have to ask for the password, | 2219 | * into the command. We have to ask for the password, |
2220 | * if it's locked. We do that by unlocking the entry | 2220 | * if it's locked. We do that by unlocking the entry |
2221 | */ | 2221 | */ |
2222 | if (!lockAt(category, entryIndex, false)) | 2222 | if (!lockAt(category, entryIndex, false)) |
2223 | return false; | 2223 | return false; |
2224 | } | 2224 | } |
2225 | #ifndef PWM_EMBEDDED | 2225 | #ifndef PWM_EMBEDDED |
2226 | command.replace("$d", dti.dta[category].d[entryIndex].desc.c_str()); | 2226 | command.replace("$d", dti.dta[category].d[entryIndex].desc.c_str()); |
2227 | command.replace("$n", dti.dta[category].d[entryIndex].name.c_str()); | 2227 | command.replace("$n", dti.dta[category].d[entryIndex].name.c_str()); |
2228 | command.replace("$p", dti.dta[category].d[entryIndex].pw.c_str()); | 2228 | command.replace("$p", dti.dta[category].d[entryIndex].pw.c_str()); |
2229 | command.replace("$u", dti.dta[category].d[entryIndex].url.c_str()); | 2229 | command.replace("$u", dti.dta[category].d[entryIndex].url.c_str()); |
2230 | command.replace("$c", dti.dta[category].d[entryIndex].comment.c_str()); | 2230 | command.replace("$c", dti.dta[category].d[entryIndex].comment.c_str()); |
2231 | #else | 2231 | #else |
2232 | command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str()); | 2232 | command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str()); |
2233 | command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str()); | 2233 | command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str()); |
2234 | command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str()); | 2234 | command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str()); |
2235 | command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str()); | 2235 | command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str()); |
2236 | command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str()); | 2236 | command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str()); |
2237 | #endif | 2237 | #endif |
2238 | command.append(" &"); | 2238 | command.append(" &"); |
2239 | 2239 | ||
2240 | QString customXterm(conf()->confGlobXtermCommand()); | 2240 | QString customXterm(conf()->confGlobXtermCommand()); |
2241 | if (!customXterm.isEmpty()) | 2241 | if (!customXterm.isEmpty()) |
2242 | command = customXterm + " " + command; | 2242 | command = customXterm + " " + command; |
2243 | 2243 | ||
2244 | system(command.latin1()); | 2244 | system(command.latin1()); |
2245 | 2245 | ||
2246 | lockAt(category, entryIndex, wasLocked); | 2246 | lockAt(category, entryIndex, wasLocked); |
2247 | return true; | 2247 | return true; |
2248 | } | 2248 | } |
2249 | 2249 | ||
2250 | bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex) | 2250 | bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex) |
2251 | { | 2251 | { |
2252 | unsigned int cat = 0; | 2252 | unsigned int cat = 0; |
2253 | 2253 | ||
2254 | if (!findCategory(category, &cat)) | 2254 | if (!findCategory(category, &cat)) |
2255 | return false; | 2255 | return false; |
2256 | 2256 | ||
2257 | return goToURL(cat, entryIndex); | 2257 | return goToURL(cat, entryIndex); |
2258 | } | 2258 | } |
2259 | 2259 | ||
2260 | bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex) | 2260 | bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex) |
2261 | { | 2261 | { |
2262 | if (geteuid() == 0) { | 2262 | if (geteuid() == 0) { |
2263 | rootAlertMsgBox(); | 2263 | rootAlertMsgBox(); |
2264 | return false; | 2264 | return false; |
2265 | } | 2265 | } |
2266 | QString url(dti.dta[category].d[entryIndex].url.c_str()); | 2266 | QString url(dti.dta[category].d[entryIndex].url.c_str()); |
2267 | if (url.isEmpty()) | 2267 | if (url.isEmpty()) |
2268 | return false; | 2268 | return false; |
2269 | 2269 | ||
2270 | QString customBrowser(conf()->confGlobBrowserCommand()); | 2270 | QString customBrowser(conf()->confGlobBrowserCommand()); |
2271 | if (!customBrowser.isEmpty()) { | 2271 | if (!customBrowser.isEmpty()) { |
2272 | browserProc.clearArguments(); | 2272 | browserProc.clearArguments(); |
2273 | browserProc << customBrowser << url; | 2273 | browserProc << customBrowser << url; |
2274 | if (browserProc.start(KProcess::DontCare)) | 2274 | if (browserProc.start(KProcess::DontCare)) |
2275 | return true; | 2275 | return true; |
2276 | } | 2276 | } |
2277 | 2277 | ||
2278 | browserProc.clearArguments(); | 2278 | browserProc.clearArguments(); |
2279 | browserProc << "konqueror" << url; | 2279 | browserProc << "konqueror" << url; |
2280 | if (browserProc.start(KProcess::DontCare)) | 2280 | if (browserProc.start(KProcess::DontCare)) |
2281 | return true; | 2281 | return true; |
2282 | 2282 | ||
2283 | browserProc.clearArguments(); | 2283 | browserProc.clearArguments(); |
2284 | browserProc << "mozilla" << url; | 2284 | browserProc << "mozilla" << url; |
2285 | if (browserProc.start(KProcess::DontCare)) | 2285 | if (browserProc.start(KProcess::DontCare)) |
2286 | return true; | 2286 | return true; |
2287 | 2287 | ||
2288 | browserProc.clearArguments(); | 2288 | browserProc.clearArguments(); |
2289 | browserProc << "opera" << url; | 2289 | browserProc << "opera" << url; |
2290 | if (browserProc.start(KProcess::DontCare)) | 2290 | if (browserProc.start(KProcess::DontCare)) |
2291 | return true; | 2291 | return true; |
2292 | return false; | 2292 | return false; |
2293 | } | 2293 | } |
2294 | 2294 | ||
2295 | PwMerror PwMDoc::exportToText(const QString *file) | 2295 | PwMerror PwMDoc::exportToText(const QString *file) |
2296 | { | 2296 | { |
2297 | PWM_ASSERT(file); | 2297 | PWM_ASSERT(file); |
2298 | if (QFile::exists(*file)) { | 2298 | if (QFile::exists(*file)) { |
2299 | if (!QFile::remove(*file)) | 2299 | if (!QFile::remove(*file)) |
2300 | return e_accessFile; | 2300 | return e_accessFile; |
2301 | } | 2301 | } |
2302 | QFile f(*file); | 2302 | QFile f(*file); |
2303 | if (!f.open(IO_ReadWrite)) | 2303 | if (!f.open(IO_ReadWrite)) |
2304 | return e_openFile; | 2304 | return e_openFile; |
2305 | 2305 | ||
2306 | if (!unlockAll_tempoary()) { | 2306 | if (!unlockAll_tempoary()) { |
2307 | f.close(); | 2307 | f.close(); |
2308 | return e_lock; | 2308 | return e_lock; |
2309 | } | 2309 | } |
2310 | 2310 | ||
2311 | // write header | 2311 | // write header |
2312 | string header = i18n("Password table generated by\nPwM v").latin1(); | 2312 | string header = i18n("Password table generated by\nPwM v").latin1(); |
2313 | header += PACKAGE_VER; | 2313 | header += PACKAGE_VER; |
2314 | header += i18n("\non ").latin1(); | 2314 | header += i18n("\non ").latin1(); |
2315 | QDate currDate = QDate::currentDate(); | 2315 | QDate currDate = QDate::currentDate(); |
2316 | QTime currTime = QTime::currentTime(); | 2316 | QTime currTime = QTime::currentTime(); |
2317 | 2317 | ||
2318 | #ifndef PWM_EMBEDDED | 2318 | #ifndef PWM_EMBEDDED |
2319 | header += currDate.toString("ddd MMMM d ").latin1(); | 2319 | header += currDate.toString("ddd MMMM d ").latin1(); |
2320 | header += currTime.toString("hh:mm:ss ").latin1(); | 2320 | header += currTime.toString("hh:mm:ss ").latin1(); |
2321 | #else | 2321 | #else |
2322 | QString dfs = KGlobal::locale()->dateFormatShort(); | 2322 | QString dfs = KGlobal::locale()->dateFormatShort(); |
2323 | bool ampm = KGlobal::locale()->use12Clock(); | 2323 | bool ampm = KGlobal::locale()->use12Clock(); |
2324 | KGlobal::locale()->setDateFormatShort("%A %B %d"); | 2324 | KGlobal::locale()->setDateFormatShort("%A %B %d"); |
2325 | KGlobal::locale()->setHore24Format(true); | 2325 | KGlobal::locale()->setHore24Format(true); |
2326 | 2326 | ||
2327 | header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined); | 2327 | header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined); |
2328 | header += KGlobal::locale()->formatTime(currTime, true); | 2328 | header += KGlobal::locale()->formatTime(currTime, true); |
2329 | KGlobal::locale()->setDateFormatShort(dfs); | 2329 | KGlobal::locale()->setDateFormatShort(dfs); |
2330 | KGlobal::locale()->setHore24Format(!ampm); | 2330 | KGlobal::locale()->setHore24Format(!ampm); |
2331 | 2331 | ||
2332 | #endif | 2332 | #endif |
2333 | header += tostr(currDate.year()); | 2333 | header += tostr(currDate.year()); |
2334 | header += "\n==============================\n\n"; | 2334 | header += "\n==============================\n\n"; |
2335 | 2335 | ||
2336 | 2336 | ||
2337 | #ifndef PWM_EMBEDDED | 2337 | #ifndef PWM_EMBEDDED |
2338 | if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) { | 2338 | if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) { |
2339 | unlockAll_tempoary(true); | 2339 | unlockAll_tempoary(true); |
2340 | f.close(); | 2340 | f.close(); |
2341 | return e_writeFile; | 2341 | return e_writeFile; |
2342 | } | 2342 | } |
2343 | #else | 2343 | #else |
2344 | if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) { | 2344 | if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) { |
2345 | unlockAll_tempoary(true); | 2345 | unlockAll_tempoary(true); |
2346 | f.close(); | 2346 | f.close(); |
2347 | return e_writeFile; | 2347 | return e_writeFile; |
2348 | } | 2348 | } |
2349 | #endif | 2349 | #endif |
2350 | unsigned int i, numCat = numCategories(); | 2350 | unsigned int i, numCat = numCategories(); |
2351 | unsigned int j, numEnt; | 2351 | unsigned int j, numEnt; |
2352 | string exp; | 2352 | string exp; |
2353 | for (i = 0; i < numCat; ++i) { | 2353 | for (i = 0; i < numCat; ++i) { |
2354 | numEnt = numEntries(i); | 2354 | numEnt = numEntries(i); |
2355 | 2355 | ||
2356 | exp = "\n== Category: "; | 2356 | exp = "\n== Category: "; |
2357 | exp += dti.dta[i].name; | 2357 | exp += dti.dta[i].name; |
2358 | exp += " ==\n"; | 2358 | exp += " ==\n"; |
2359 | #ifndef PWM_EMBEDDED | 2359 | #ifndef PWM_EMBEDDED |
2360 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { | 2360 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { |
2361 | unlockAll_tempoary(true); | 2361 | unlockAll_tempoary(true); |
2362 | f.close(); | 2362 | f.close(); |
2363 | return e_writeFile; | 2363 | return e_writeFile; |
2364 | } | 2364 | } |
2365 | #else | 2365 | #else |
2366 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { | 2366 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { |
2367 | unlockAll_tempoary(true); | 2367 | unlockAll_tempoary(true); |
2368 | f.close(); | 2368 | f.close(); |
2369 | return e_writeFile; | 2369 | return e_writeFile; |
2370 | } | 2370 | } |
2371 | #endif | 2371 | #endif |
2372 | for (j = 0; j < numEnt; ++j) { | 2372 | for (j = 0; j < numEnt; ++j) { |
2373 | exp = "\n-- "; | 2373 | exp = "\n-- "; |
2374 | exp += dti.dta[i].d[j].desc; | 2374 | exp += dti.dta[i].d[j].desc; |
2375 | exp += " --\n"; | 2375 | exp += " --\n"; |
2376 | 2376 | ||
2377 | exp += i18n("Username: ").latin1(); | 2377 | exp += i18n("Username: ").latin1(); |
2378 | exp += dti.dta[i].d[j].name; | 2378 | exp += dti.dta[i].d[j].name; |
2379 | exp += "\n"; | 2379 | exp += "\n"; |
2380 | 2380 | ||
2381 | exp += i18n("Password: ").latin1(); | 2381 | exp += i18n("Password: ").latin1(); |
2382 | exp += dti.dta[i].d[j].pw; | 2382 | exp += dti.dta[i].d[j].pw; |
2383 | exp += "\n"; | 2383 | exp += "\n"; |
2384 | 2384 | ||
2385 | exp += i18n("Comment: ").latin1(); | 2385 | exp += i18n("Comment: ").latin1(); |
2386 | exp += dti.dta[i].d[j].comment; | 2386 | exp += dti.dta[i].d[j].comment; |
2387 | exp += "\n"; | 2387 | exp += "\n"; |
2388 | 2388 | ||
2389 | exp += i18n("URL: ").latin1(); | 2389 | exp += i18n("URL: ").latin1(); |
2390 | exp += dti.dta[i].d[j].url; | 2390 | exp += dti.dta[i].d[j].url; |
2391 | exp += "\n"; | 2391 | exp += "\n"; |
2392 | 2392 | ||
2393 | exp += i18n("Launcher: ").latin1(); | 2393 | exp += i18n("Launcher: ").latin1(); |
2394 | exp += dti.dta[i].d[j].launcher; | 2394 | exp += dti.dta[i].d[j].launcher; |
2395 | exp += "\n"; | 2395 | exp += "\n"; |
2396 | 2396 | ||
2397 | #ifndef PWM_EMBEDDED | 2397 | #ifndef PWM_EMBEDDED |
2398 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { | 2398 | if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { |
2399 | unlockAll_tempoary(true); | 2399 | unlockAll_tempoary(true); |
2400 | f.close(); | 2400 | f.close(); |
2401 | return e_writeFile; | 2401 | return e_writeFile; |
2402 | } | 2402 | } |
2403 | #else | 2403 | #else |
2404 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { | 2404 | if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { |
2405 | unlockAll_tempoary(true); | 2405 | unlockAll_tempoary(true); |
2406 | f.close(); | 2406 | f.close(); |
2407 | return e_writeFile; | 2407 | return e_writeFile; |
2408 | } | 2408 | } |
2409 | #endif | 2409 | #endif |
2410 | } | 2410 | } |
2411 | } | 2411 | } |
2412 | unlockAll_tempoary(true); | 2412 | unlockAll_tempoary(true); |
2413 | f.close(); | 2413 | f.close(); |
2414 | 2414 | ||
2415 | return e_success; | 2415 | return e_success; |
2416 | } | 2416 | } |
2417 | 2417 | ||
2418 | PwMerror PwMDoc::importFromText(const QString *file, int format) | 2418 | PwMerror PwMDoc::importFromText(const QString *file, int format) |
2419 | { | 2419 | { |
2420 | PWM_ASSERT(file); | 2420 | PWM_ASSERT(file); |
2421 | if (format == 0) | 2421 | if (format == 0) |
2422 | return importText_PwM(file); | 2422 | return importText_PwM(file); |
2423 | else if (format == -1) { | 2423 | else if (format == -1) { |
2424 | // probe for all formats | 2424 | // probe for all formats |
2425 | if (importText_PwM(file) == e_success) | 2425 | if (importText_PwM(file) == e_success) |
2426 | return e_success; | 2426 | return e_success; |
2427 | dti.clear(); | 2427 | dti.clear(); |
2428 | emitDataChanged(this); | 2428 | emitDataChanged(this); |
2429 | // add next format here... | 2429 | // add next format here... |
2430 | return e_fileFormat; | 2430 | return e_fileFormat; |
2431 | } | 2431 | } |
2432 | return e_invalidArg; | 2432 | return e_invalidArg; |
2433 | } | 2433 | } |
2434 | 2434 | ||
2435 | PwMerror PwMDoc::importText_PwM(const QString *file) | 2435 | PwMerror PwMDoc::importText_PwM(const QString *file) |
2436 | { | 2436 | { |
2437 | PWM_ASSERT(file); | 2437 | PWM_ASSERT(file); |
2438 | FILE *f; | 2438 | FILE *f; |
2439 | int tmp; | 2439 | int tmp; |
2440 | ssize_t ret; | 2440 | ssize_t ret; |
2441 | string curCat; | 2441 | string curCat; |
2442 | unsigned int entriesRead = 0; | 2442 | unsigned int entriesRead = 0; |
2443 | PwMDataItem currItem; | 2443 | PwMDataItem currItem; |
2444 | f = fopen(file->latin1(), "r"); | 2444 | f = fopen(file->latin1(), "r"); |
2445 | if (!f) | 2445 | if (!f) |
2446 | return e_openFile; | 2446 | return e_openFile; |
2447 | size_t ch_tmp_size = 1024; | 2447 | size_t ch_tmp_size = 1024; |
2448 | char *ch_tmp = (char*)malloc(ch_tmp_size); | 2448 | char *ch_tmp = (char*)malloc(ch_tmp_size); |
2449 | if (!ch_tmp) { | 2449 | if (!ch_tmp) { |
2450 | fclose(f); | 2450 | fclose(f); |
2451 | return e_outOfMem; | 2451 | return e_outOfMem; |
2452 | } | 2452 | } |
2453 | 2453 | ||
2454 | // - check header | 2454 | // - check header |
2455 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) // skip first line. | 2455 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) // skip first line. |
2456 | goto formatError; | 2456 | goto formatError; |
2457 | // check version-string and return version in "ch_tmp". | 2457 | // check version-string and return version in "ch_tmp". |
2458 | if (fscanf(f, "PwM v%s", ch_tmp) != 1) { | 2458 | if (fscanf(f, "PwM v%s", ch_tmp) != 1) { |
2459 | // header not recognized as PwM generated header | 2459 | // header not recognized as PwM generated header |
2460 | goto formatError; | 2460 | goto formatError; |
2461 | } | 2461 | } |
2462 | // set filepointer behind version-string-line previously checked | 2462 | // set filepointer behind version-string-line previously checked |
2463 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2463 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2464 | goto formatError; | 2464 | goto formatError; |
2465 | // skip next line containing the build-date | 2465 | // skip next line containing the build-date |
2466 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2466 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2467 | goto formatError; | 2467 | goto formatError; |
2468 | // read header termination line | 2468 | // read header termination line |
2469 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2469 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2470 | goto formatError; | 2470 | goto formatError; |
2471 | if (strcmp(ch_tmp, "==============================\n")) | 2471 | if (strcmp(ch_tmp, "==============================\n")) |
2472 | goto formatError; | 2472 | goto formatError; |
2473 | 2473 | ||
2474 | // - read entries | 2474 | // - read entries |
2475 | do { | 2475 | do { |
2476 | // find beginning of next category | 2476 | // find beginning of next category |
2477 | do { | 2477 | do { |
2478 | tmp = fgetc(f); | 2478 | tmp = fgetc(f); |
2479 | } while (tmp == '\n' && tmp != EOF); | 2479 | } while (tmp == '\n' && tmp != EOF); |
2480 | if (tmp == EOF) | 2480 | if (tmp == EOF) |
2481 | break; | 2481 | break; |
2482 | 2482 | ||
2483 | // decrement filepos by one | 2483 | // decrement filepos by one |
2484 | fseek(f, -1, SEEK_CUR); | 2484 | fseek(f, -1, SEEK_CUR); |
2485 | // read cat-name | 2485 | // read cat-name |
2486 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2486 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2487 | goto formatError; | 2487 | goto formatError; |
2488 | // check cat-name format | 2488 | // check cat-name format |
2489 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) | 2489 | if (memcmp(ch_tmp, "== Category: ", 13) != 0) |
2490 | goto formatError; | 2490 | goto formatError; |
2491 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) | 2491 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) |
2492 | goto formatError; | 2492 | goto formatError; |
2493 | // copy cat-name | 2493 | // copy cat-name |
2494 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); | 2494 | curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); |
2495 | 2495 | ||
2496 | do { | 2496 | do { |
2497 | // find beginning of next entry | 2497 | // find beginning of next entry |
2498 | do { | 2498 | do { |
2499 | tmp = fgetc(f); | 2499 | tmp = fgetc(f); |
2500 | } while (tmp == '\n' && tmp != EOF && tmp != '='); | 2500 | } while (tmp == '\n' && tmp != EOF && tmp != '='); |
2501 | if (tmp == EOF) | 2501 | if (tmp == EOF) |
2502 | break; | 2502 | break; |
2503 | if (tmp == '=') { | 2503 | if (tmp == '=') { |
2504 | fseek(f, -1, SEEK_CUR); | 2504 | fseek(f, -1, SEEK_CUR); |
2505 | break; | 2505 | break; |
2506 | } | 2506 | } |
2507 | // decrement filepos by one | 2507 | // decrement filepos by one |
2508 | fseek(f, -1, SEEK_CUR); | 2508 | fseek(f, -1, SEEK_CUR); |
2509 | // read desc-line | 2509 | // read desc-line |
2510 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) | 2510 | if (getline(&ch_tmp, &ch_tmp_size, f) == -1) |
2511 | goto formatError; | 2511 | goto formatError; |
2512 | // check desc-line format | 2512 | // check desc-line format |
2513 | if (memcmp(ch_tmp, "-- ", 3) != 0) | 2513 | if (memcmp(ch_tmp, "-- ", 3) != 0) |
2514 | goto formatError; | 2514 | goto formatError; |
2515 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) | 2515 | if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) |
2516 | goto formatError; | 2516 | goto formatError; |
2517 | // add desc-line | 2517 | // add desc-line |
2518 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); | 2518 | currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); |
2519 | 2519 | ||
2520 | // read username-line | 2520 | // read username-line |
2521 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2521 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2522 | goto formatError; | 2522 | goto formatError; |
2523 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) | 2523 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) |
2524 | goto formatError; | 2524 | goto formatError; |
2525 | 2525 | ||
2526 | // read pw-line | 2526 | // read pw-line |
2527 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2527 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2528 | goto formatError; | 2528 | goto formatError; |
2529 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) | 2529 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) |
2530 | goto formatError; | 2530 | goto formatError; |
2531 | 2531 | ||
2532 | // read comment-line | 2532 | // read comment-line |
2533 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2533 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2534 | goto formatError; | 2534 | goto formatError; |
2535 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) | 2535 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) |
2536 | goto formatError; | 2536 | goto formatError; |
2537 | 2537 | ||
2538 | // read URL-line | 2538 | // read URL-line |
2539 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2539 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2540 | goto formatError; | 2540 | goto formatError; |
2541 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) | 2541 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) |
2542 | goto formatError; | 2542 | goto formatError; |
2543 | 2543 | ||
2544 | // read launcher-line | 2544 | // read launcher-line |
2545 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) | 2545 | if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) |
2546 | goto formatError; | 2546 | goto formatError; |
2547 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) | 2547 | if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) |
2548 | goto formatError; | 2548 | goto formatError; |
2549 | 2549 | ||
2550 | currItem.lockStat = true; | 2550 | currItem.lockStat = true; |
2551 | currItem.listViewPos = -1; | 2551 | currItem.listViewPos = -1; |
2552 | addEntry(curCat.c_str(), &currItem, true); | 2552 | addEntry(curCat.c_str(), &currItem, true); |
2553 | ++entriesRead; | 2553 | ++entriesRead; |
2554 | } while (1); | 2554 | } while (1); |
2555 | } while (1); | 2555 | } while (1); |
2556 | if (!entriesRead) | 2556 | if (!entriesRead) |
2557 | goto formatError; | 2557 | goto formatError; |
2558 | 2558 | ||
2559 | free(ch_tmp); | 2559 | free(ch_tmp); |
2560 | fclose(f); | 2560 | fclose(f); |
2561 | flagDirty(); | 2561 | flagDirty(); |
2562 | return e_success; | 2562 | return e_success; |
2563 | 2563 | ||
2564 | formatError: | 2564 | formatError: |
2565 | free(ch_tmp); | 2565 | free(ch_tmp); |
2566 | fclose(f); | 2566 | fclose(f); |
2567 | return e_fileFormat; | 2567 | return e_fileFormat; |
2568 | } | 2568 | } |
2569 | 2569 | ||
2570 | bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out) | 2570 | bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out) |
2571 | { | 2571 | { |
2572 | PWM_ASSERT(in && out); | 2572 | PWM_ASSERT(in && out); |
2573 | ssize_t i = 0, len = in_size - 1; | 2573 | ssize_t i = 0, len = in_size - 1; |
2574 | while (i < len) { | 2574 | while (i < len) { |
2575 | if (in[i] == ':') | 2575 | if (in[i] == ':') |
2576 | break; | 2576 | break; |
2577 | ++i; | 2577 | ++i; |
2578 | } | 2578 | } |
2579 | i += 2; | 2579 | i += 2; |
2580 | *out = ""; | 2580 | *out = ""; |
2581 | out->append(in + i, in_size - i - 1); | 2581 | out->append(in + i, in_size - i - 1); |
2582 | return true; | 2582 | return true; |
2583 | } | 2583 | } |
2584 | 2584 | ||
2585 | PwMerror PwMDoc::exportToGpasman(const QString *file) | 2585 | PwMerror PwMDoc::exportToGpasman(const QString *file) |
2586 | { | 2586 | { |
2587 | PWM_ASSERT(file); | 2587 | PWM_ASSERT(file); |
2588 | GpasmanFile gp; | 2588 | GpasmanFile gp; |
2589 | int ret; | 2589 | int ret; |
2590 | 2590 | ||
2591 | if (!unlockAll_tempoary()) | 2591 | if (!unlockAll_tempoary()) |
2592 | return e_lock; | 2592 | return e_lock; |
2593 | 2593 | ||
2594 | QString gpmPassword; | 2594 | QString gpmPassword; |
2595 | while (1) { | 2595 | while (1) { |
2596 | gpmPassword = requestNewMpw(0); | 2596 | gpmPassword = requestNewMpw(0); |
2597 | if (gpmPassword == "") { | 2597 | if (gpmPassword == "") { |
2598 | unlockAll_tempoary(true); | 2598 | unlockAll_tempoary(true); |
2599 | return e_noPw; | 2599 | return e_noPw; |
2600 | } | 2600 | } |
2601 | if (gpmPassword.length() < 4) { | 2601 | if (gpmPassword.length() < 4) { |
2602 | gpmPwLenErrMsgBox(); | 2602 | gpmPwLenErrMsgBox(); |
2603 | } else { | 2603 | } else { |
2604 | break; | 2604 | break; |
2605 | } | 2605 | } |
2606 | } | 2606 | } |
2607 | 2607 | ||
2608 | ret = gp.save_init(file->latin1(), gpmPassword.latin1()); | 2608 | ret = gp.save_init(file->latin1(), gpmPassword.latin1()); |
2609 | if (ret != 1) { | 2609 | if (ret != 1) { |
2610 | unlockAll_tempoary(true); | 2610 | unlockAll_tempoary(true); |
2611 | return e_accessFile; | 2611 | return e_accessFile; |
2612 | } | 2612 | } |
2613 | 2613 | ||
2614 | char *entry[4]; | 2614 | char *entry[4]; |
2615 | unsigned int numCat = numCategories(), i; | 2615 | unsigned int numCat = numCategories(), i; |
2616 | unsigned int numEntr, j; | 2616 | unsigned int numEntr, j; |
2617 | int descLen, nameLen, pwLen, commentLen; | 2617 | int descLen, nameLen, pwLen, commentLen; |
2618 | for (i = 0; i < numCat; ++i) { | 2618 | for (i = 0; i < numCat; ++i) { |
2619 | numEntr = numEntries(i); | 2619 | numEntr = numEntries(i); |
2620 | for (j = 0; j < numEntr; ++j) { | 2620 | for (j = 0; j < numEntr; ++j) { |
2621 | descLen = dti.dta[i].d[j].desc.length(); | 2621 | descLen = dti.dta[i].d[j].desc.length(); |
2622 | nameLen = dti.dta[i].d[j].name.length(); | 2622 | nameLen = dti.dta[i].d[j].name.length(); |
2623 | pwLen = dti.dta[i].d[j].pw.length(); | 2623 | pwLen = dti.dta[i].d[j].pw.length(); |
2624 | commentLen = dti.dta[i].d[j].comment.length(); | 2624 | commentLen = dti.dta[i].d[j].comment.length(); |
2625 | entry[0] = new char[descLen + 1]; | 2625 | entry[0] = new char[descLen + 1]; |
2626 | entry[1] = new char[nameLen + 1]; | 2626 | entry[1] = new char[nameLen + 1]; |
2627 | entry[2] = new char[pwLen + 1]; | 2627 | entry[2] = new char[pwLen + 1]; |
2628 | entry[3] = new char[commentLen + 1]; | 2628 | entry[3] = new char[commentLen + 1]; |
2629 | strcpy(entry[0], descLen == 0 ? " " : dti.dta[i].d[j].desc.c_str()); | 2629 | strcpy(entry[0], descLen == 0 ? " " : dti.dta[i].d[j].desc.c_str()); |
2630 | strcpy(entry[1], nameLen == 0 ? " " : dti.dta[i].d[j].name.c_str()); | 2630 | strcpy(entry[1], nameLen == 0 ? " " : dti.dta[i].d[j].name.c_str()); |
2631 | strcpy(entry[2], pwLen == 0 ? " " : dti.dta[i].d[j].pw.c_str()); | 2631 | strcpy(entry[2], pwLen == 0 ? " " : dti.dta[i].d[j].pw.c_str()); |
2632 | strcpy(entry[3], commentLen == 0 ? " " : dti.dta[i].d[j].comment.c_str()); | 2632 | strcpy(entry[3], commentLen == 0 ? " " : dti.dta[i].d[j].comment.c_str()); |
2633 | entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0'; | 2633 | entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0'; |
2634 | entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0'; | 2634 | entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0'; |
2635 | entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0'; | 2635 | entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0'; |
2636 | entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0'; | 2636 | entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0'; |
2637 | 2637 | ||
2638 | ret = gp.save_entry(entry); | 2638 | ret = gp.save_entry(entry); |
2639 | if (ret == -1){ | 2639 | if (ret == -1){ |
2640 | delete [] entry[0]; | 2640 | delete [] entry[0]; |
2641 | delete [] entry[1]; | 2641 | delete [] entry[1]; |
2642 | delete [] entry[2]; | 2642 | delete [] entry[2]; |
2643 | delete [] entry[3]; | 2643 | delete [] entry[3]; |
2644 | gp.save_finalize(); | 2644 | gp.save_finalize(); |
2645 | unlockAll_tempoary(true); | 2645 | unlockAll_tempoary(true); |
2646 | return e_writeFile; | 2646 | return e_writeFile; |
2647 | } | 2647 | } |
2648 | 2648 | ||
2649 | delete [] entry[0]; | 2649 | delete [] entry[0]; |
2650 | delete [] entry[1]; | 2650 | delete [] entry[1]; |
2651 | delete [] entry[2]; | 2651 | delete [] entry[2]; |
2652 | delete [] entry[3]; | 2652 | delete [] entry[3]; |
2653 | } | 2653 | } |
2654 | } | 2654 | } |
2655 | unlockAll_tempoary(true); | 2655 | unlockAll_tempoary(true); |
2656 | if (gp.save_finalize() == -1) | 2656 | if (gp.save_finalize() == -1) |
2657 | return e_writeFile; | 2657 | return e_writeFile; |
2658 | 2658 | ||
2659 | return e_success; | 2659 | return e_success; |
2660 | } | 2660 | } |
2661 | 2661 | ||
2662 | PwMerror PwMDoc::importFromGpasman(const QString *file) | 2662 | PwMerror PwMDoc::importFromGpasman(const QString *file) |
2663 | { | 2663 | { |
2664 | PWM_ASSERT(file); | 2664 | PWM_ASSERT(file); |
2665 | QString pw = requestMpw(false); | 2665 | QString pw = requestMpw(false); |
2666 | if (pw == "") | 2666 | if (pw == "") |
2667 | return e_noPw; | 2667 | return e_noPw; |
2668 | GpasmanFile gp; | 2668 | GpasmanFile gp; |
2669 | int ret, i; | 2669 | int ret, i; |
2670 | PwMerror ret2; | 2670 | PwMerror ret2; |
2671 | char *entry[4]; | 2671 | char *entry[4]; |
2672 | PwMDataItem tmpData; | 2672 | PwMDataItem tmpData; |
2673 | ret = gp.load_init(file->latin1(), pw.latin1()); | 2673 | ret = gp.load_init(file->latin1(), pw.latin1()); |
2674 | if (ret != 1) | 2674 | if (ret != 1) |
2675 | return e_accessFile; | 2675 | return e_accessFile; |
2676 | 2676 | ||
2677 | do { | 2677 | do { |
2678 | ret = gp.load_entry(entry); | 2678 | ret = gp.load_entry(entry); |
2679 | if(ret != 1) | 2679 | if(ret != 1) |
2680 | break; | 2680 | break; |
2681 | tmpData.desc = entry[0]; | 2681 | tmpData.desc = entry[0]; |
2682 | tmpData.name = entry[1]; | 2682 | tmpData.name = entry[1]; |
2683 | tmpData.pw = entry[2]; | 2683 | tmpData.pw = entry[2]; |
2684 | tmpData.comment = entry[3]; | 2684 | tmpData.comment = entry[3]; |
2685 | tmpData.lockStat = true; | 2685 | tmpData.lockStat = true; |
2686 | tmpData.listViewPos = -1; | 2686 | tmpData.listViewPos = -1; |
2687 | ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true); | 2687 | ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true); |
2688 | for (i = 0; i < 4; ++i) | 2688 | for (i = 0; i < 4; ++i) |
2689 | free(entry[i]); | 2689 | free(entry[i]); |
2690 | if (ret2 == e_maxAllowedEntr) { | 2690 | if (ret2 == e_maxAllowedEntr) { |
2691 | gp.load_finalize(); | 2691 | gp.load_finalize(); |
2692 | return e_maxAllowedEntr; | 2692 | return e_maxAllowedEntr; |
2693 | } | 2693 | } |
2694 | } while (1); | 2694 | } while (1); |
2695 | gp.load_finalize(); | 2695 | gp.load_finalize(); |
2696 | if (isDocEmpty()) | 2696 | if (isDocEmpty()) |
2697 | return e_wrongPw; // we assume this. | 2697 | return e_wrongPw; // we assume this. |
2698 | 2698 | ||
2699 | flagDirty(); | 2699 | flagDirty(); |
2700 | return e_success; | 2700 | return e_success; |
2701 | } | 2701 | } |
2702 | 2702 | ||
2703 | void PwMDoc::ensureLvp() | 2703 | void PwMDoc::ensureLvp() |
2704 | { | 2704 | { |
2705 | if (isDocEmpty()) | 2705 | if (isDocEmpty()) |
2706 | return; | 2706 | return; |
2707 | 2707 | ||
2708 | vector< vector<PwMDataItem>::iterator > undefined; | 2708 | vector< vector<PwMDataItem>::iterator > undefined; |
2709 | vector< vector<PwMDataItem>::iterator >::iterator undefBegin, | 2709 | vector< vector<PwMDataItem>::iterator >::iterator undefBegin, |
2710 | undefEnd, | 2710 | undefEnd, |
2711 | undefI; | 2711 | undefI; |
2712 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), | 2712 | vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), |
2713 | catEnd = dti.dta.end(), | 2713 | catEnd = dti.dta.end(), |
2714 | catI = catBegin; | 2714 | catI = catBegin; |
2715 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 2715 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
2716 | int lvpTop, tmpLvp; | 2716 | int lvpTop, tmpLvp; |
2717 | 2717 | ||
2718 | while (catI != catEnd) { | 2718 | while (catI != catEnd) { |
2719 | lvpTop = -1; | 2719 | lvpTop = -1; |
2720 | undefined.clear(); | 2720 | undefined.clear(); |
2721 | 2721 | ||
2722 | entrBegin = catI->d.begin(); | 2722 | entrBegin = catI->d.begin(); |
2723 | entrEnd = catI->d.end(); | 2723 | entrEnd = catI->d.end(); |
2724 | entrI = entrBegin; | 2724 | entrI = entrBegin; |
2725 | 2725 | ||
2726 | while (entrI != entrEnd) { | 2726 | while (entrI != entrEnd) { |
2727 | tmpLvp = entrI->listViewPos; | 2727 | tmpLvp = entrI->listViewPos; |
2728 | if (tmpLvp == -1) | 2728 | if (tmpLvp == -1) |
2729 | undefined.push_back(entrI); | 2729 | undefined.push_back(entrI); |
2730 | else if (tmpLvp > lvpTop) | 2730 | else if (tmpLvp > lvpTop) |
2731 | lvpTop = tmpLvp; | 2731 | lvpTop = tmpLvp; |
2732 | ++entrI; | 2732 | ++entrI; |
2733 | } | 2733 | } |
2734 | undefBegin = undefined.begin(); | 2734 | undefBegin = undefined.begin(); |
2735 | undefEnd = undefined.end(); | 2735 | undefEnd = undefined.end(); |
2736 | undefI = undefBegin; | 2736 | undefI = undefBegin; |
2737 | while (undefI != undefEnd) { | 2737 | while (undefI != undefEnd) { |
2738 | (*undefI)->listViewPos = ++lvpTop; | 2738 | (*undefI)->listViewPos = ++lvpTop; |
2739 | ++undefI; | 2739 | ++undefI; |
2740 | } | 2740 | } |
2741 | ++catI; | 2741 | ++catI; |
2742 | } | 2742 | } |
2743 | } | 2743 | } |
2744 | 2744 | ||
2745 | QString PwMDoc::getTitle() | 2745 | QString PwMDoc::getTitle() |
2746 | { | 2746 | { |
2747 | /* NOTE: We have to ensure, that the returned title | 2747 | /* NOTE: We have to ensure, that the returned title |
2748 | * is unique and not reused somewhere else while | 2748 | * is unique and not reused somewhere else while |
2749 | * this document is valid (open). | 2749 | * this document is valid (open). |
2750 | */ | 2750 | */ |
2751 | QString title(getFilename()); | 2751 | QString title(getFilename()); |
2752 | if (title.isEmpty()) { | 2752 | if (title.isEmpty()) { |
2753 | if (unnamedNum == 0) { | 2753 | if (unnamedNum == 0) { |
2754 | unnamedNum = PwMDocList::getNewUnnamedNumber(); | 2754 | unnamedNum = PwMDocList::getNewUnnamedNumber(); |
2755 | PWM_ASSERT(unnamedNum != 0); | 2755 | PWM_ASSERT(unnamedNum != 0); |
2756 | } | 2756 | } |
2757 | title = DEFAULT_TITLE; | 2757 | title = DEFAULT_TITLE; |
2758 | title += " "; | 2758 | title += " "; |
2759 | title += tostr(unnamedNum).c_str(); | 2759 | title += tostr(unnamedNum).c_str(); |
2760 | } | 2760 | } |
2761 | return title; | 2761 | return title; |
2762 | } | 2762 | } |
2763 | 2763 | ||
2764 | bool PwMDoc::tryDelete() | 2764 | bool PwMDoc::tryDelete() |
2765 | { | 2765 | { |
2766 | if (deleted) | 2766 | if (deleted) |
2767 | return true; | 2767 | return true; |
2768 | int ret; | 2768 | int ret; |
2769 | if (isDirty()) { | 2769 | if (isDirty()) { |
2770 | ret = dirtyAskSave(getTitle()); | 2770 | ret = dirtyAskSave(getTitle()); |
2771 | if (ret == 0) { // save to disk | 2771 | if (ret == 0) { // save to disk |
2772 | if (!saveDocUi(this)) | 2772 | if (!saveDocUi(this)) |
2773 | goto out_ignore; | 2773 | goto out_ignore; |
2774 | } else if (ret == 1) { // don't save and delete | 2774 | } else if (ret == 1) { // don't save and delete |
2775 | goto out_accept; | 2775 | goto out_accept; |
2776 | } else { // cancel operation | 2776 | } else { // cancel operation |
2777 | goto out_ignore; | 2777 | goto out_ignore; |
2778 | } | 2778 | } |
2779 | } | 2779 | } |
2780 | out_accept: | 2780 | out_accept: |
2781 | deleted = true; | 2781 | deleted = true; |
2782 | delete this; | 2782 | delete this; |
2783 | return true; | 2783 | return true; |
2784 | out_ignore: | 2784 | out_ignore: |
2785 | return false; | 2785 | return false; |
2786 | } | 2786 | } |
2787 | 2787 | ||
2788 | 2788 | ||
2789 | 2789 | ||
2790 | #ifdef PWM_EMBEDDED | 2790 | #ifdef PWM_EMBEDDED |
2791 | //US ENH: this is the magic function that syncronizes the this doc with the remote doc | 2791 | //US ENH: this is the magic function that syncronizes the this doc with the remote doc |
2792 | //US it could have been defined as static, but I did not want to. | 2792 | //US it could have been defined as static, but I did not want to. |
2793 | PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) | 2793 | PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) |
2794 | { | 2794 | { |
2795 | int addedPasswordsLocal = 0; | 2795 | int addedPasswordsLocal = 0; |
2796 | int addedPasswordsRemote = 0; | 2796 | int addedPasswordsRemote = 0; |
2797 | int deletedPasswordsRemote = 0; | 2797 | int deletedPasswordsRemote = 0; |
2798 | int deletedPasswordsLocal = 0; | 2798 | int deletedPasswordsLocal = 0; |
2799 | int changedLocal = 0; | 2799 | int changedLocal = 0; |
2800 | int changedRemote = 0; | 2800 | int changedRemote = 0; |
2801 | 2801 | ||
2802 | PwMSyncItem* syncItemLocal; | 2802 | PwMSyncItem* syncItemLocal; |
2803 | PwMSyncItem* syncItemRemote; | 2803 | PwMSyncItem* syncItemRemote; |
2804 | 2804 | ||
2805 | QString mCurrentSyncName = manager->getCurrentSyncName(); | 2805 | QString mCurrentSyncName = manager->getCurrentSyncName(); |
2806 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2806 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2807 | 2807 | ||
2808 | bool fullDateRange = false; | 2808 | bool fullDateRange = false; |
2809 | int take; | 2809 | int take; |
2810 | // local->resetTempSyncStat(); | 2810 | // local->resetTempSyncStat(); |
2811 | QDateTime mLastSync = QDateTime::currentDateTime(); | 2811 | QDateTime mLastSync = QDateTime::currentDateTime(); |
2812 | QDateTime modifiedSync = mLastSync; | 2812 | QDateTime modifiedSync = mLastSync; |
2813 | 2813 | ||
2814 | unsigned int index; | 2814 | unsigned int index; |
2815 | //Step 1. Find syncinfo in Local file and create if not existent. | 2815 | //Step 1. Find syncinfo in Local file and create if not existent. |
2816 | bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); | 2816 | bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); |
2817 | if (found == false) | 2817 | if (found == false) |
2818 | { | 2818 | { |
2819 | PwMSyncItem newSyncItemLocal; | 2819 | PwMSyncItem newSyncItemLocal; |
2820 | newSyncItemLocal.syncName = mCurrentSyncDevice; | 2820 | newSyncItemLocal.syncName = mCurrentSyncDevice; |
2821 | newSyncItemLocal.lastSyncDate = mLastSync; | 2821 | newSyncItemLocal.lastSyncDate = mLastSync; |
2822 | syncLocal->addSyncDataEntry(&newSyncItemLocal, true); | 2822 | syncLocal->addSyncDataEntry(&newSyncItemLocal, true); |
2823 | found = syncLocal->findSyncData(mCurrentSyncDevice, &index); | 2823 | found = syncLocal->findSyncData(mCurrentSyncDevice, &index); |
2824 | if (found == false) { | 2824 | if (found == false) { |
2825 | qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); | 2825 | qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); |
2826 | return e_syncError; | 2826 | return e_syncError; |
2827 | } | 2827 | } |
2828 | } | 2828 | } |
2829 | 2829 | ||
2830 | syncItemLocal = syncLocal->getSyncDataEntry(index); | 2830 | syncItemLocal = syncLocal->getSyncDataEntry(index); |
2831 | qDebug("Last Sync %s ", syncItemLocal->lastSyncDate.toString().latin1()); | 2831 | qDebug("Last Sync %s ", syncItemLocal->lastSyncDate.toString().latin1()); |
2832 | 2832 | ||
2833 | //Step 2. Find syncinfo in remote file and create if not existent. | 2833 | //Step 2. Find syncinfo in remote file and create if not existent. |
2834 | found = syncRemote->findSyncData(mCurrentSyncName, &index); | 2834 | found = syncRemote->findSyncData(mCurrentSyncName, &index); |
2835 | if (found == false) | 2835 | if (found == false) |
2836 | { | 2836 | { |
2837 | qDebug("FULLDATE 1"); | 2837 | qDebug("FULLDATE 1"); |
2838 | fullDateRange = true; | 2838 | fullDateRange = true; |
2839 | PwMSyncItem newSyncItemRemote; | 2839 | PwMSyncItem newSyncItemRemote; |
2840 | newSyncItemRemote.syncName = mCurrentSyncName; | 2840 | newSyncItemRemote.syncName = mCurrentSyncName; |
2841 | newSyncItemRemote.lastSyncDate = mLastSync; | 2841 | newSyncItemRemote.lastSyncDate = mLastSync; |
2842 | syncRemote->addSyncDataEntry(&newSyncItemRemote, true); | 2842 | syncRemote->addSyncDataEntry(&newSyncItemRemote, true); |
2843 | found = syncRemote->findSyncData(mCurrentSyncName, &index); | 2843 | found = syncRemote->findSyncData(mCurrentSyncName, &index); |
2844 | if (found == false) { | 2844 | if (found == false) { |
2845 | qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); | 2845 | qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); |
2846 | return e_syncError; | 2846 | return e_syncError; |
2847 | } | 2847 | } |
2848 | } | 2848 | } |
2849 | 2849 | ||
2850 | syncItemRemote = syncRemote->getSyncDataEntry(index); | 2850 | syncItemRemote = syncRemote->getSyncDataEntry(index); |
2851 | //and remove the found entry here. We will reenter it later again. | 2851 | //and remove the found entry here. We will reenter it later again. |
2852 | syncRemote->delSyncDataEntry(index, true); | 2852 | syncRemote->delSyncDataEntry(index, true); |
2853 | 2853 | ||
2854 | 2854 | ||
2855 | if ( syncItemLocal->lastSyncDate == mLastSync ) { | 2855 | if ( syncItemLocal->lastSyncDate == mLastSync ) { |
2856 | qDebug("FULLDATE 2"); | 2856 | qDebug("FULLDATE 2"); |
2857 | fullDateRange = true; | 2857 | fullDateRange = true; |
2858 | } | 2858 | } |
2859 | 2859 | ||
2860 | if ( ! fullDateRange ) { | 2860 | if ( ! fullDateRange ) { |
2861 | if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { | 2861 | if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { |
2862 | 2862 | ||
2863 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2863 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2864 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2864 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2865 | fullDateRange = true; | 2865 | fullDateRange = true; |
2866 | qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); | 2866 | qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); |
2867 | } | 2867 | } |
2868 | } | 2868 | } |
2869 | // fullDateRange = true; // debug only! | 2869 | // fullDateRange = true; // debug only! |
2870 | if ( fullDateRange ) | 2870 | if ( fullDateRange ) |
2871 | mLastSync = QDateTime::currentDateTime().addDays( -100*365); | 2871 | mLastSync = QDateTime::currentDateTime().addDays( -100*365); |
2872 | else | 2872 | else |
2873 | mLastSync = syncItemLocal->lastSyncDate; | 2873 | mLastSync = syncItemLocal->lastSyncDate; |
2874 | 2874 | ||
2875 | 2875 | ||
2876 | qDebug("*************************** "); | 2876 | qDebug("*************************** "); |
2877 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2877 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2878 | QStringList er = syncRemote->getIDEntryList(); | 2878 | QStringList er = syncRemote->getIDEntryList(); |
2879 | PwMDataItem* inRemote ;//= er.first(); | 2879 | PwMDataItem* inRemote ;//= er.first(); |
2880 | PwMDataItem* inLocal; | 2880 | PwMDataItem* inLocal; |
2881 | unsigned int catLocal, indexLocal; | 2881 | unsigned int catLocal, indexLocal; |
2882 | unsigned int catRemote, indexRemote; | 2882 | unsigned int catRemote, indexRemote; |
2883 | 2883 | ||
2884 | QString uid; | 2884 | QString uid; |
2885 | manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2885 | manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2886 | 2886 | ||
2887 | int modulo = (er.count()/10)+1; | 2887 | int modulo = (er.count()/10)+1; |
2888 | unsigned int incCounter = 0; | 2888 | unsigned int incCounter = 0; |
2889 | while ( incCounter < er.count()) { | 2889 | while ( incCounter < er.count()) { |
2890 | if (manager->isProgressBarCanceled()) | 2890 | if (manager->isProgressBarCanceled()) |
2891 | return e_syncError; | 2891 | return e_syncError; |
2892 | if ( incCounter % modulo == 0 ) | 2892 | if ( incCounter % modulo == 0 ) |
2893 | manager->showProgressBar(incCounter); | 2893 | manager->showProgressBar(incCounter); |
2894 | 2894 | ||
2895 | uid = er[ incCounter ]; | 2895 | uid = er[ incCounter ]; |
2896 | qDebug("sync uid %s from remote file", uid.latin1()); | 2896 | qDebug("sync uid %s from remote file", uid.latin1()); |
2897 | 2897 | ||
2898 | qApp->processEvents(); | 2898 | qApp->processEvents(); |
2899 | 2899 | ||
2900 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); | 2900 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); |
2901 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); | 2901 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); |
2902 | PWM_ASSERT(inRemote); | 2902 | PWM_ASSERT(inRemote); |
2903 | if ( inLocal != 0 ) { // maybe conflict - same uid in both files | 2903 | if ( inLocal != 0 ) { // maybe conflict - same uid in both files |
2904 | if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { | 2904 | if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { |
2905 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2905 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2906 | if ( take == 3 ) | 2906 | if ( take == 3 ) |
2907 | return e_syncError; | 2907 | return e_syncError; |
2908 | if ( take == 1 ) {// take local | 2908 | if ( take == 1 ) {// take local |
2909 | //US syncRemote->removeAddressee( inRemote ); | 2909 | //US syncRemote->removeAddressee( inRemote ); |
2910 | (*inRemote) = (*inLocal); | 2910 | (*inRemote) = (*inLocal); |
2911 | //US syncRemote->insertAddressee( inRemote , false); | 2911 | //US syncRemote->insertAddressee( inRemote , false); |
2912 | ++changedRemote; | 2912 | ++changedRemote; |
2913 | } else { // take == 2 take remote | 2913 | } else { // take == 2 take remote |
2914 | //US syncLocal->removeAddressee( inLocal ); | 2914 | //US syncLocal->removeAddressee( inLocal ); |
2915 | (*inLocal) = (*inRemote); | 2915 | (*inLocal) = (*inRemote); |
2916 | //US syncLocal->insertAddressee( inLocal , false ); | 2916 | //US syncLocal->insertAddressee( inLocal , false ); |
2917 | ++changedLocal; | 2917 | ++changedLocal; |
2918 | } | 2918 | } |
2919 | } | 2919 | } |
2920 | } else { // no conflict | 2920 | } else { // no conflict |
2921 | if ( inRemote->meta.update > mLastSync || mode == 5 ) { | 2921 | if ( inRemote->meta.update > mLastSync || mode == 5 ) { |
2922 | inRemote->meta.update = modifiedSync; | 2922 | inRemote->meta.update = modifiedSync; |
2923 | //US syncRemote->insertAddressee( inRemote, false ); | 2923 | //US syncRemote->insertAddressee( inRemote, false ); |
2924 | //US syncLocal->insertAddressee( inRemote, false ); | 2924 | //US syncLocal->insertAddressee( inRemote, false ); |
2925 | syncLocal->addEntry("newcategory", inRemote, true, false); | 2925 | syncLocal->addEntry("newcategory", inRemote, true, false); |
2926 | 2926 | ||
2927 | ++addedPasswordsLocal; | 2927 | ++addedPasswordsLocal; |
2928 | } else { | 2928 | } else { |
2929 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2929 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2930 | syncRemote->delEntry(catRemote, indexRemote, true); | 2930 | syncRemote->delEntry(catRemote, indexRemote, true); |
2931 | //USsyncRemote->removeAddressee( inRemote ); | 2931 | //USsyncRemote->removeAddressee( inRemote ); |
2932 | ++deletedPasswordsRemote; | 2932 | ++deletedPasswordsRemote; |
2933 | } | 2933 | } |
2934 | } | 2934 | } |
2935 | 2935 | ||
2936 | ++incCounter; | 2936 | ++incCounter; |
2937 | } | 2937 | } |
2938 | 2938 | ||
2939 | 2939 | ||
2940 | er.clear(); | 2940 | er.clear(); |
2941 | QStringList el = syncLocal->getIDEntryList(); | 2941 | QStringList el = syncLocal->getIDEntryList(); |
2942 | modulo = (el.count()/10)+1; | 2942 | modulo = (el.count()/10)+1; |
2943 | 2943 | ||
2944 | manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2944 | manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2945 | incCounter = 0; | 2945 | incCounter = 0; |
2946 | while ( incCounter < el.count()) { | 2946 | while ( incCounter < el.count()) { |
2947 | qApp->processEvents(); | 2947 | qApp->processEvents(); |
2948 | if (manager->isProgressBarCanceled()) | 2948 | if (manager->isProgressBarCanceled()) |
2949 | return e_syncError; | 2949 | return e_syncError; |
2950 | if ( incCounter % modulo == 0 ) | 2950 | if ( incCounter % modulo == 0 ) |
2951 | manager->showProgressBar(incCounter); | 2951 | manager->showProgressBar(incCounter); |
2952 | uid = el[ incCounter ]; | 2952 | uid = el[ incCounter ]; |
2953 | 2953 | ||
2954 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); | 2954 | inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); |
2955 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); | 2955 | inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); |
2956 | if ( inRemote == 0 ) { | 2956 | if ( inRemote == 0 ) { |
2957 | if ( inLocal->meta.update < mLastSync && mode != 4 ) { | 2957 | if ( inLocal->meta.update < mLastSync && mode != 4 ) { |
2958 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2958 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2959 | syncLocal->delEntry(catLocal, indexLocal, true); | 2959 | syncLocal->delEntry(catLocal, indexLocal, true); |
2960 | //USsyncLocal->removeAddressee( inLocal ); | 2960 | //USsyncLocal->removeAddressee( inLocal ); |
2961 | ++deletedPasswordsLocal; | 2961 | ++deletedPasswordsLocal; |
2962 | } else { | 2962 | } else { |
2963 | if ( ! PWMPrefs::instance()->mWriteBackExistingOnly ) { | 2963 | if ( ! manager->mWriteBackExistingOnly ) { |
2964 | ++addedPasswordsRemote; | 2964 | ++addedPasswordsRemote; |
2965 | inLocal->meta.update = modifiedSync; | 2965 | inLocal->meta.update = modifiedSync; |
2966 | //USsyncLocal->insertAddressee( inLocal, false ); | 2966 | //USsyncLocal->insertAddressee( inLocal, false ); |
2967 | (*inRemote) = (*inLocal); | 2967 | (*inRemote) = (*inLocal); |
2968 | //USsyncRemote->insertAddressee( inRemote, false ); | 2968 | //USsyncRemote->insertAddressee( inRemote, false ); |
2969 | syncRemote->addEntry("newcategory", inRemote, true, false); | 2969 | syncRemote->addEntry("newcategory", inRemote, true, false); |
2970 | 2970 | ||
2971 | } | 2971 | } |
2972 | } | 2972 | } |
2973 | 2973 | ||
2974 | } | 2974 | } |
2975 | ++incCounter; | 2975 | ++incCounter; |
2976 | } | 2976 | } |
2977 | el.clear(); | 2977 | el.clear(); |
2978 | manager->hideProgressBar(); | 2978 | manager->hideProgressBar(); |
2979 | 2979 | ||
2980 | // Now write the info back into the sync data space of the files | 2980 | // Now write the info back into the sync data space of the files |
2981 | 2981 | ||
2982 | mLastSync = QDateTime::currentDateTime().addSecs( 1 ); | 2982 | mLastSync = QDateTime::currentDateTime().addSecs( 1 ); |
2983 | // get rid of micro seconds | 2983 | // get rid of micro seconds |
2984 | QTime t = mLastSync.time(); | 2984 | QTime t = mLastSync.time(); |
2985 | mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2985 | mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2986 | 2986 | ||
2987 | 2987 | ||
2988 | syncItemLocal->lastSyncDate = mLastSync; | 2988 | syncItemLocal->lastSyncDate = mLastSync; |
2989 | syncItemRemote->lastSyncDate = mLastSync; | 2989 | syncItemRemote->lastSyncDate = mLastSync; |
2990 | 2990 | ||
2991 | // addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2991 | // addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2992 | // addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2992 | // addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2993 | 2993 | ||
2994 | syncRemote->addSyncDataEntry( syncItemRemote, false ); | 2994 | syncRemote->addSyncDataEntry( syncItemRemote, false ); |
2995 | syncLocal->addSyncDataEntry( syncItemLocal, false ); | 2995 | syncLocal->addSyncDataEntry( syncItemLocal, false ); |
2996 | QString mes; | 2996 | QString mes; |
2997 | 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"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote ); | 2997 | 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"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote ); |
2998 | if ( PWMPrefs::instance()->mShowSyncSummary ) { | 2998 | if ( manager->mShowSyncSummary ) { |
2999 | KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); | 2999 | KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); |
3000 | } | 3000 | } |
3001 | qDebug( mes ); | 3001 | qDebug( mes ); |
3002 | return e_success; | 3002 | return e_success; |
3003 | } | 3003 | } |
3004 | 3004 | ||
3005 | 3005 | ||
3006 | int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) | 3006 | int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) |
3007 | { | 3007 | { |
3008 | // 0 equal | 3008 | // 0 equal |
3009 | // 1 take local | 3009 | // 1 take local |
3010 | // 2 take remote | 3010 | // 2 take remote |
3011 | // 3 cancel | 3011 | // 3 cancel |
3012 | QDateTime localMod = local->meta.update; | 3012 | QDateTime localMod = local->meta.update; |
3013 | QDateTime remoteMod = remote->meta.update; | 3013 | QDateTime remoteMod = remote->meta.update; |
3014 | 3014 | ||
3015 | //US QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3015 | //US QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3016 | 3016 | ||
3017 | if ( localMod == remoteMod ) | 3017 | if ( localMod == remoteMod ) |
3018 | return 0; | 3018 | return 0; |
3019 | 3019 | ||
3020 | qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); | 3020 | qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); |
3021 | 3021 | ||
3022 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 3022 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
3023 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 3023 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
3024 | //full = true; //debug only | 3024 | //full = true; //debug only |
3025 | if ( full ) { | 3025 | if ( full ) { |
3026 | bool equ = true;//US ( (*local) == (*remote) ); | 3026 | bool equ = true;//US ( (*local) == (*remote) ); |
3027 | if ( equ ) { | 3027 | if ( equ ) { |
3028 | //qDebug("equal "); | 3028 | //qDebug("equal "); |
3029 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 3029 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
3030 | return 0; | 3030 | return 0; |
3031 | 3031 | ||
3032 | }//else //debug only | 3032 | }//else //debug only |
3033 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 3033 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
3034 | } | 3034 | } |
3035 | 3035 | ||
3036 | int result; | 3036 | int result; |
3037 | bool localIsNew; | 3037 | bool localIsNew; |
3038 | //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() ); | 3038 | //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() ); |
3039 | 3039 | ||
3040 | if ( full && mode < SYNC_PREF_NEWEST ) | 3040 | if ( full && mode < SYNC_PREF_NEWEST ) |
3041 | mode = SYNC_PREF_ASK; | 3041 | mode = SYNC_PREF_ASK; |
3042 | 3042 | ||
3043 | switch( mode ) { | 3043 | switch( mode ) { |
3044 | case SYNC_PREF_LOCAL: | 3044 | case SYNC_PREF_LOCAL: |
3045 | if ( lastSync > remoteMod ) | 3045 | if ( lastSync > remoteMod ) |
3046 | return 1; | 3046 | return 1; |
3047 | if ( lastSync > localMod ) | 3047 | if ( lastSync > localMod ) |
3048 | return 2; | 3048 | return 2; |
3049 | return 1; | 3049 | return 1; |
3050 | break; | 3050 | break; |
3051 | case SYNC_PREF_REMOTE: | 3051 | case SYNC_PREF_REMOTE: |
3052 | if ( lastSync > remoteMod ) | 3052 | if ( lastSync > remoteMod ) |
3053 | return 1; | 3053 | return 1; |
3054 | if ( lastSync > localMod ) | 3054 | if ( lastSync > localMod ) |
3055 | return 2; | 3055 | return 2; |
3056 | return 2; | 3056 | return 2; |
3057 | break; | 3057 | break; |
3058 | case SYNC_PREF_NEWEST: | 3058 | case SYNC_PREF_NEWEST: |
3059 | if ( localMod > remoteMod ) | 3059 | if ( localMod > remoteMod ) |
3060 | return 1; | 3060 | return 1; |
3061 | else | 3061 | else |
3062 | return 2; | 3062 | return 2; |
3063 | break; | 3063 | break; |
3064 | case SYNC_PREF_ASK: | 3064 | case SYNC_PREF_ASK: |
3065 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 3065 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
3066 | if ( lastSync > remoteMod ) | 3066 | if ( lastSync > remoteMod ) |
3067 | return 1; | 3067 | return 1; |
3068 | if ( lastSync > localMod ) | 3068 | if ( lastSync > localMod ) |
3069 | return 2; | 3069 | return 2; |
3070 | localIsNew = localMod >= remoteMod; | 3070 | localIsNew = localMod >= remoteMod; |
3071 | //qDebug("conflict! ************************************** "); | 3071 | //qDebug("conflict! ************************************** "); |
3072 | { | 3072 | { |
3073 | PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ ); | 3073 | PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ ); |
3074 | result = acd.executeD(localIsNew); | 3074 | result = acd.executeD(localIsNew); |
3075 | return result; | 3075 | return result; |
3076 | } | 3076 | } |
3077 | break; | 3077 | break; |
3078 | case SYNC_PREF_FORCE_LOCAL: | 3078 | case SYNC_PREF_FORCE_LOCAL: |
3079 | return 1; | 3079 | return 1; |
3080 | break; | 3080 | break; |
3081 | case SYNC_PREF_FORCE_REMOTE: | 3081 | case SYNC_PREF_FORCE_REMOTE: |
3082 | return 2; | 3082 | return 2; |
3083 | break; | 3083 | break; |
3084 | 3084 | ||
3085 | default: | 3085 | default: |
3086 | // SYNC_PREF_TAKE_BOTH not implemented | 3086 | // SYNC_PREF_TAKE_BOTH not implemented |
3087 | break; | 3087 | break; |
3088 | } | 3088 | } |
3089 | return 0; | 3089 | return 0; |
3090 | } | 3090 | } |
3091 | 3091 | ||
3092 | 3092 | ||
3093 | 3093 | ||
3094 | 3094 | ||
3095 | //this are the overwritten callbackmethods from the syncinterface | 3095 | //this are the overwritten callbackmethods from the syncinterface |
3096 | bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) | 3096 | bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) |
3097 | { | 3097 | { |
3098 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3098 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3099 | 3099 | ||
3100 | //1) unlock local file first if necessary (ask for password) | 3100 | //1) unlock local file first if necessary (ask for password) |
3101 | if (this->isDeepLocked()) { | 3101 | if (this->isDeepLocked()) { |
3102 | PwMerror ret = this->deepLock(false); | 3102 | PwMerror ret = this->deepLock(false); |
3103 | if (ret != e_success) | 3103 | if (ret != e_success) |
3104 | return false; | 3104 | return false; |
3105 | } | 3105 | } |
3106 | 3106 | ||
3107 | //2) construct and open a new doc on the stack(automatic cleanup) for remote file. | 3107 | //2) construct and open a new doc on the stack(automatic cleanup) for remote file. |
3108 | PwMDoc syncTarget(this, "synctarget"); | 3108 | PwMDoc syncTarget(this, "synctarget"); |
3109 | PwMDoc* pSyncTarget = &syncTarget; | 3109 | PwMDoc* pSyncTarget = &syncTarget; |
3110 | 3110 | ||
3111 | 3111 | ||
3112 | PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); | 3112 | PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); |
3113 | 3113 | ||
3114 | if (err == e_alreadyOpen) { | 3114 | if (err == e_alreadyOpen) { |
3115 | PwMDocList::listItem li; | 3115 | PwMDocList::listItem li; |
3116 | if (getOpenDocList()->find(filename.latin1(), &li)) | 3116 | if (getOpenDocList()->find(filename.latin1(), &li)) |
3117 | pSyncTarget = li.doc; | 3117 | pSyncTarget = li.doc; |
3118 | else { | 3118 | else { |
3119 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); | 3119 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); |
3120 | return false; | 3120 | return false; |
3121 | } | 3121 | } |
3122 | } | 3122 | } |
3123 | else if (err != e_success) { | 3123 | else if (err != e_success) { |
3124 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); | 3124 | qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); |
3125 | return false; | 3125 | return false; |
3126 | } | 3126 | } |
3127 | 3127 | ||
3128 | qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); | 3128 | qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); |
3129 | 3129 | ||
3130 | 3130 | ||
3131 | //3) unlock remote file first if necessary (ask for password) | 3131 | //3) unlock remote file first if necessary (ask for password) |
3132 | if (pSyncTarget->isDeepLocked()) { | 3132 | if (pSyncTarget->isDeepLocked()) { |
3133 | PwMerror ret = pSyncTarget->deepLock(false); | 3133 | PwMerror ret = pSyncTarget->deepLock(false); |
3134 | if (ret != e_success) | 3134 | if (ret != e_success) |
3135 | return false; | 3135 | return false; |
3136 | } | 3136 | } |
3137 | 3137 | ||
3138 | 3138 | ||
3139 | err = syncronize(manager, this, pSyncTarget, mode ); | 3139 | err = syncronize(manager, this, pSyncTarget, mode ); |
3140 | 3140 | ||
3141 | if (err == e_success) { | 3141 | if (err == e_success) { |
3142 | if ( PWMPrefs::instance()->mWriteBackFile ){ | 3142 | if ( manager->mWriteBackFile ){ |
3143 | qDebug("Saving remote PWManager file"); | 3143 | qDebug("Saving remote PWManager file"); |
3144 | err = pSyncTarget->saveDoc(conf()->confGlobCompression()); | 3144 | err = pSyncTarget->saveDoc(conf()->confGlobCompression()); |
3145 | if (err != e_success) { | 3145 | if (err != e_success) { |
3146 | qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); | 3146 | qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); |
3147 | return false; | 3147 | return false; |
3148 | } | 3148 | } |
3149 | } | 3149 | } |
3150 | 3150 | ||
3151 | flagDirty(); | 3151 | flagDirty(); |
3152 | return true; | 3152 | return true; |
3153 | } | 3153 | } |
3154 | else { | 3154 | else { |
3155 | return false; | 3155 | return false; |
3156 | } | 3156 | } |
3157 | } | 3157 | } |
3158 | 3158 | ||
3159 | //called by the syncmanager to indicate that the work has to marked as dirty. | 3159 | //called by the syncmanager to indicate that the work has to marked as dirty. |
3160 | void PwMDoc::sync_setModified() | 3160 | void PwMDoc::sync_setModified() |
3161 | { | 3161 | { |
3162 | flagDirty(); | 3162 | flagDirty(); |
3163 | } | 3163 | } |
3164 | 3164 | ||
3165 | //called by the syncmanager to ask if the dirty flag is set. | 3165 | //called by the syncmanager to ask if the dirty flag is set. |
3166 | bool PwMDoc::sync_isModified() | 3166 | bool PwMDoc::sync_isModified() |
3167 | { | 3167 | { |
3168 | return isDirty(); | 3168 | return isDirty(); |
3169 | } | 3169 | } |
3170 | 3170 | ||
3171 | //called by the syncmanager to indicate that the work has to be saved. | 3171 | //called by the syncmanager to indicate that the work has to be saved. |
3172 | void PwMDoc::sync_save() | 3172 | void PwMDoc::sync_save() |
3173 | { | 3173 | { |
3174 | saveDoc(conf()->confGlobCompression()); | 3174 | saveDoc(conf()->confGlobCompression()); |
3175 | } | 3175 | } |
3176 | #endif | 3176 | #endif |
3177 | 3177 | ||
3178 | 3178 | ||
3179 | bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index) | 3179 | bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index) |
3180 | { | 3180 | { |
3181 | vector<PwMSyncItem>::iterator i = dti.syncDta.begin(), | 3181 | vector<PwMSyncItem>::iterator i = dti.syncDta.begin(), |
3182 | end = dti.syncDta.end(); | 3182 | end = dti.syncDta.end(); |
3183 | 3183 | ||
3184 | while (i != end) { | 3184 | while (i != end) { |
3185 | if ((*i).syncName == syncname.latin1()) { | 3185 | if ((*i).syncName == syncname.latin1()) { |
3186 | if (index) { | 3186 | if (index) { |
3187 | *index = i - dti.syncDta.begin(); | 3187 | *index = i - dti.syncDta.begin(); |
3188 | } | 3188 | } |
3189 | return true; | 3189 | return true; |
3190 | } | 3190 | } |
3191 | ++i; | 3191 | ++i; |
3192 | } | 3192 | } |
3193 | return false; | 3193 | return false; |
3194 | }; | 3194 | }; |
3195 | 3195 | ||
3196 | /** add new syncdataentry */ | 3196 | /** add new syncdataentry */ |
3197 | PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty) | 3197 | PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty) |
3198 | { | 3198 | { |
3199 | PWM_ASSERT(d); | 3199 | PWM_ASSERT(d); |
3200 | 3200 | ||
3201 | if (isDeepLocked()) { | 3201 | if (isDeepLocked()) { |
3202 | PwMerror ret; | 3202 | PwMerror ret; |
3203 | ret = deepLock(false); | 3203 | ret = deepLock(false); |
3204 | if (ret != e_success) | 3204 | if (ret != e_success) |
3205 | return e_lock; | 3205 | return e_lock; |
3206 | } | 3206 | } |
3207 | unsigned int index; | 3207 | unsigned int index; |
3208 | 3208 | ||
3209 | const QString tmp = d->syncName.c_str(); | 3209 | const QString tmp = d->syncName.c_str(); |
3210 | bool exists = findSyncData(d->syncName.c_str(), &index); | 3210 | bool exists = findSyncData(d->syncName.c_str(), &index); |
3211 | 3211 | ||
3212 | if (exists == true) { | 3212 | if (exists == true) { |
3213 | // DOH! We found this entry. | 3213 | // DOH! We found this entry. |
3214 | return e_entryExists; | 3214 | return e_entryExists; |
3215 | } | 3215 | } |
3216 | 3216 | ||
3217 | dti.syncDta.push_back(*d); | 3217 | dti.syncDta.push_back(*d); |
3218 | 3218 | ||
3219 | if (!dontFlagDirty) | 3219 | if (!dontFlagDirty) |
3220 | flagDirty(); | 3220 | flagDirty(); |
3221 | return e_success; | 3221 | return e_success; |
3222 | } | 3222 | } |
3223 | 3223 | ||
3224 | 3224 | ||
3225 | 3225 | ||
3226 | /** delete syncdata entry */ | 3226 | /** delete syncdata entry */ |
3227 | bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty) | 3227 | bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty) |
3228 | { | 3228 | { |
3229 | if (isDeepLocked()) | 3229 | if (isDeepLocked()) |
3230 | return false; | 3230 | return false; |
3231 | if (index > dti.syncDta.size() - 1) | 3231 | if (index > dti.syncDta.size() - 1) |
3232 | return false; | 3232 | return false; |
3233 | 3233 | ||
3234 | // delete entry | 3234 | // delete entry |
3235 | dti.syncDta.erase(dti.syncDta.begin() + index); | 3235 | dti.syncDta.erase(dti.syncDta.begin() + index); |
3236 | 3236 | ||
3237 | if (!dontFlagDirty) | 3237 | if (!dontFlagDirty) |
3238 | flagDirty(); | 3238 | flagDirty(); |
3239 | return true; | 3239 | return true; |
3240 | } | 3240 | } |
3241 | 3241 | ||
3242 | 3242 | ||
3243 | PwMDataItem* PwMDoc::findEntryByID(const QString &uid, unsigned int *category, unsigned int *index) | 3243 | PwMDataItem* PwMDoc::findEntryByID(const QString &uid, unsigned int *category, unsigned int *index) |
3244 | { | 3244 | { |
3245 | vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), | 3245 | vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), |
3246 | catend = dti.dta.end(); | 3246 | catend = dti.dta.end(); |
3247 | 3247 | ||
3248 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 3248 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
3249 | 3249 | ||
3250 | while (catcounter != catend) { | 3250 | while (catcounter != catend) { |
3251 | entrBegin = catcounter->d.begin(); | 3251 | entrBegin = catcounter->d.begin(); |
3252 | entrEnd = catcounter->d.end(); | 3252 | entrEnd = catcounter->d.end(); |
3253 | entrI = entrBegin; | 3253 | entrI = entrBegin; |
3254 | while (entrI != entrEnd) { | 3254 | while (entrI != entrEnd) { |
3255 | if ((*entrI).meta.uniqueid == uid.latin1()) { | 3255 | if ((*entrI).meta.uniqueid == uid.latin1()) { |
3256 | if (category) | 3256 | if (category) |
3257 | *category = catcounter - dti.dta.begin(); | 3257 | *category = catcounter - dti.dta.begin(); |
3258 | if (index) | 3258 | if (index) |
3259 | *index = entrI - entrBegin; | 3259 | *index = entrI - entrBegin; |
3260 | 3260 | ||
3261 | return &(*entrI); | 3261 | return &(*entrI); |
3262 | } | 3262 | } |
3263 | ++entrI; | 3263 | ++entrI; |
3264 | } | 3264 | } |
3265 | ++catcounter; | 3265 | ++catcounter; |
3266 | } | 3266 | } |
3267 | 3267 | ||
3268 | return 0; | 3268 | return 0; |
3269 | } | 3269 | } |
3270 | 3270 | ||
3271 | QStringList PwMDoc::getIDEntryList() | 3271 | QStringList PwMDoc::getIDEntryList() |
3272 | { | 3272 | { |
3273 | QStringList results; | 3273 | QStringList results; |
3274 | 3274 | ||
3275 | vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), | 3275 | vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), |
3276 | catend = dti.dta.end(); | 3276 | catend = dti.dta.end(); |
3277 | 3277 | ||
3278 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; | 3278 | vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; |
3279 | 3279 | ||
3280 | while (catcounter != catend) { | 3280 | while (catcounter != catend) { |
3281 | entrBegin = catcounter->d.begin(); | 3281 | entrBegin = catcounter->d.begin(); |
3282 | entrEnd = catcounter->d.end(); | 3282 | entrEnd = catcounter->d.end(); |
3283 | entrI = entrBegin; | 3283 | entrI = entrBegin; |
3284 | while (entrI != entrEnd) { | 3284 | while (entrI != entrEnd) { |
3285 | results.append( (*entrI).meta.uniqueid ); | 3285 | results.append( (*entrI).meta.uniqueid ); |
3286 | ++entrI; | 3286 | ++entrI; |
3287 | } | 3287 | } |
3288 | ++catcounter; | 3288 | ++catcounter; |
3289 | } | 3289 | } |
3290 | 3290 | ||
3291 | return results; | 3291 | return results; |
3292 | } | 3292 | } |
3293 | 3293 | ||
3294 | 3294 | ||
3295 | 3295 | ||
3296 | 3296 | ||
3297 | 3297 | ||
3298 | #ifndef PWM_EMBEDDED | 3298 | #ifndef PWM_EMBEDDED |
3299 | #include "pwmdoc.moc" | 3299 | #include "pwmdoc.moc" |
3300 | #endif | 3300 | #endif |