-rw-r--r-- | korganizer/mainwindow.cpp | 52 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 2 |
2 files changed, 37 insertions, 17 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 460bbdc..f4ac0d6 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1241,1301 +1241,1319 @@ void MainWindow::keyBindings() | |||
1241 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1241 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1242 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1242 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1243 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1243 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1244 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1244 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1245 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1245 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1246 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1246 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1247 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1247 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1248 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1248 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1249 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1249 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1250 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1250 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1251 | displayText( text, cap); | 1251 | displayText( text, cap); |
1252 | 1252 | ||
1253 | } | 1253 | } |
1254 | void MainWindow::aboutAutoSaving() | 1254 | void MainWindow::aboutAutoSaving() |
1255 | { | 1255 | { |
1256 | QMessageBox* msg; | 1256 | QMessageBox* msg; |
1257 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1257 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1258 | 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, | 1258 | 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, |
1259 | QMessageBox::Ok, | 1259 | QMessageBox::Ok, |
1260 | QMessageBox::NoButton, | 1260 | QMessageBox::NoButton, |
1261 | QMessageBox::NoButton); | 1261 | QMessageBox::NoButton); |
1262 | msg->exec(); | 1262 | msg->exec(); |
1263 | delete msg; | 1263 | delete msg; |
1264 | 1264 | ||
1265 | 1265 | ||
1266 | } | 1266 | } |
1267 | void MainWindow::aboutKnownBugs() | 1267 | void MainWindow::aboutKnownBugs() |
1268 | { | 1268 | { |
1269 | QMessageBox* msg; | 1269 | QMessageBox* msg; |
1270 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1270 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1271 | 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")+ | 1271 | 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")+ |
1272 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1272 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1273 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1273 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1274 | i18n("\nor report them in the bugtracker on\n") + | 1274 | i18n("\nor report them in the bugtracker on\n") + |
1275 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1275 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1276 | QMessageBox::NoIcon, | 1276 | QMessageBox::NoIcon, |
1277 | QMessageBox::Ok, | 1277 | QMessageBox::Ok, |
1278 | QMessageBox::NoButton, | 1278 | QMessageBox::NoButton, |
1279 | QMessageBox::NoButton); | 1279 | QMessageBox::NoButton); |
1280 | msg->exec(); | 1280 | msg->exec(); |
1281 | delete msg; | 1281 | delete msg; |
1282 | 1282 | ||
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | QString MainWindow::defaultFileName() | 1285 | QString MainWindow::defaultFileName() |
1286 | { | 1286 | { |
1287 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1287 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1290 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1291 | { | 1291 | { |
1292 | if ( !incidence ) { | 1292 | if ( !incidence ) { |
1293 | enableIncidenceActions( false ); | 1293 | enableIncidenceActions( false ); |
1294 | 1294 | ||
1295 | mNewSubTodoAction->setEnabled( false ); | 1295 | mNewSubTodoAction->setEnabled( false ); |
1296 | setCaptionToDates(); | 1296 | setCaptionToDates(); |
1297 | return; | 1297 | return; |
1298 | 1298 | ||
1299 | } | 1299 | } |
1300 | 1300 | ||
1301 | //KGlobal::locale()->formatDateTime(nextA, true); | 1301 | //KGlobal::locale()->formatDateTime(nextA, true); |
1302 | QString startString = ""; | 1302 | QString startString = ""; |
1303 | if ( incidence->type() != "Todo" ) { | 1303 | if ( incidence->type() != "Todo" ) { |
1304 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1304 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1305 | if ( incidence->doesFloat() ) { | 1305 | if ( incidence->doesFloat() ) { |
1306 | startString += ": "+incidence->dtStartDateStr( true ); | 1306 | startString += ": "+incidence->dtStartDateStr( true ); |
1307 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1307 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1308 | 1308 | ||
1309 | } else { | 1309 | } else { |
1310 | startString = ": "+incidence->dtStartStr(true); | 1310 | startString = ": "+incidence->dtStartStr(true); |
1311 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1311 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1312 | 1312 | ||
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | } else { | 1315 | } else { |
1316 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1316 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1317 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1317 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1318 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1318 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1319 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1319 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | } | 1322 | } |
1323 | else | 1323 | else |
1324 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1324 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1325 | if ( !incidence->location().isEmpty() ) | 1325 | if ( !incidence->location().isEmpty() ) |
1326 | startString += " (" +incidence->location()+")"; | 1326 | startString += " (" +incidence->location()+")"; |
1327 | setCaption( incidence->summary()+startString); | 1327 | setCaption( incidence->summary()+startString); |
1328 | 1328 | ||
1329 | enableIncidenceActions( true ); | 1329 | enableIncidenceActions( true ); |
1330 | 1330 | ||
1331 | if ( incidence->type() == "Event" ) { | 1331 | if ( incidence->type() == "Event" ) { |
1332 | mShowAction->setText( i18n("Show Event...") ); | 1332 | mShowAction->setText( i18n("Show Event...") ); |
1333 | mEditAction->setText( i18n("Edit Event...") ); | 1333 | mEditAction->setText( i18n("Edit Event...") ); |
1334 | mDeleteAction->setText( i18n("Delete Event...") ); | 1334 | mDeleteAction->setText( i18n("Delete Event...") ); |
1335 | 1335 | ||
1336 | mNewSubTodoAction->setEnabled( false ); | 1336 | mNewSubTodoAction->setEnabled( false ); |
1337 | } else if ( incidence->type() == "Todo" ) { | 1337 | } else if ( incidence->type() == "Todo" ) { |
1338 | mShowAction->setText( i18n("Show Todo...") ); | 1338 | mShowAction->setText( i18n("Show Todo...") ); |
1339 | mEditAction->setText( i18n("Edit Todo...") ); | 1339 | mEditAction->setText( i18n("Edit Todo...") ); |
1340 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1340 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1341 | 1341 | ||
1342 | mNewSubTodoAction->setEnabled( true ); | 1342 | mNewSubTodoAction->setEnabled( true ); |
1343 | } else { | 1343 | } else { |
1344 | mShowAction->setText( i18n("Show...") ); | 1344 | mShowAction->setText( i18n("Show...") ); |
1345 | mShowAction->setText( i18n("Edit...") ); | 1345 | mShowAction->setText( i18n("Edit...") ); |
1346 | mShowAction->setText( i18n("Delete...") ); | 1346 | mShowAction->setText( i18n("Delete...") ); |
1347 | 1347 | ||
1348 | mNewSubTodoAction->setEnabled( false ); | 1348 | mNewSubTodoAction->setEnabled( false ); |
1349 | } | 1349 | } |
1350 | } | 1350 | } |
1351 | 1351 | ||
1352 | void MainWindow::enableIncidenceActions( bool enabled ) | 1352 | void MainWindow::enableIncidenceActions( bool enabled ) |
1353 | { | 1353 | { |
1354 | mShowAction->setEnabled( enabled ); | 1354 | mShowAction->setEnabled( enabled ); |
1355 | mEditAction->setEnabled( enabled ); | 1355 | mEditAction->setEnabled( enabled ); |
1356 | mDeleteAction->setEnabled( enabled ); | 1356 | mDeleteAction->setEnabled( enabled ); |
1357 | } | 1357 | } |
1358 | 1358 | ||
1359 | void MainWindow::importOL() | 1359 | void MainWindow::importOL() |
1360 | { | 1360 | { |
1361 | #ifdef _WIN32_ | 1361 | #ifdef _WIN32_ |
1362 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1362 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1363 | id->exec(); | 1363 | id->exec(); |
1364 | delete id; | 1364 | delete id; |
1365 | mView->updateView(); | 1365 | mView->updateView(); |
1366 | #endif | 1366 | #endif |
1367 | } | 1367 | } |
1368 | void MainWindow::importBday() | 1368 | void MainWindow::importBday() |
1369 | { | 1369 | { |
1370 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1370 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1371 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1371 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1372 | i18n("Import!"), i18n("Cancel"), 0, | 1372 | i18n("Import!"), i18n("Cancel"), 0, |
1373 | 0, 1 ); | 1373 | 0, 1 ); |
1374 | if ( result == 0 ) { | 1374 | if ( result == 0 ) { |
1375 | mView->importBday(); | 1375 | mView->importBday(); |
1376 | 1376 | ||
1377 | } | 1377 | } |
1378 | 1378 | ||
1379 | 1379 | ||
1380 | } | 1380 | } |
1381 | void MainWindow::importQtopia() | 1381 | void MainWindow::importQtopia() |
1382 | { | 1382 | { |
1383 | #ifndef DESKTOP_VERSION | 1383 | #ifndef DESKTOP_VERSION |
1384 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1384 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1385 | 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"), | 1385 | 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"), |
1386 | i18n("Import!"), i18n("Cancel"), 0, | 1386 | i18n("Import!"), i18n("Cancel"), 0, |
1387 | 0, 1 ); | 1387 | 0, 1 ); |
1388 | if ( result == 0 ) { | 1388 | if ( result == 0 ) { |
1389 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1389 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1390 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1390 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1391 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1391 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1392 | mView->importQtopia( categories, datebook, todolist ); | 1392 | mView->importQtopia( categories, datebook, todolist ); |
1393 | } | 1393 | } |
1394 | #else | 1394 | #else |
1395 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1395 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1396 | i18n("Not supported \non desktop!\n"), | 1396 | i18n("Not supported \non desktop!\n"), |
1397 | i18n("Ok"), i18n("Cancel"), 0, | 1397 | i18n("Ok"), i18n("Cancel"), 0, |
1398 | 0, 1 ); | 1398 | 0, 1 ); |
1399 | 1399 | ||
1400 | #endif | 1400 | #endif |
1401 | } | 1401 | } |
1402 | 1402 | ||
1403 | void MainWindow::saveOnClose() | 1403 | void MainWindow::saveOnClose() |
1404 | { | 1404 | { |
1405 | KOPrefs *p = KOPrefs::instance(); | 1405 | KOPrefs *p = KOPrefs::instance(); |
1406 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1406 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1407 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1407 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1408 | iconToolBar->y() > height()/2; | 1408 | iconToolBar->y() > height()/2; |
1409 | mView->writeSettings(); | 1409 | mView->writeSettings(); |
1410 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1410 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1411 | save(); | 1411 | save(); |
1412 | } | 1412 | } |
1413 | void MainWindow::slotModifiedChanged( bool changed ) | 1413 | void MainWindow::slotModifiedChanged( bool changed ) |
1414 | { | 1414 | { |
1415 | if ( mBlockAtStartup ) | 1415 | if ( mBlockAtStartup ) |
1416 | return; | 1416 | return; |
1417 | int msec; | 1417 | int msec; |
1418 | // we store the changes after 1 minute, | 1418 | // we store the changes after 1 minute, |
1419 | // and for safety reasons after 10 minutes again | 1419 | // and for safety reasons after 10 minutes again |
1420 | if ( !mBlockSaveFlag ) | 1420 | if ( !mBlockSaveFlag ) |
1421 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1421 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1422 | else | 1422 | else |
1423 | msec = 1000 * 600; | 1423 | msec = 1000 * 600; |
1424 | mSaveTimer.start( msec, true ); // 1 minute | 1424 | mSaveTimer.start( msec, true ); // 1 minute |
1425 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1425 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1426 | mCalendarModifiedFlag = true; | 1426 | mCalendarModifiedFlag = true; |
1427 | } | 1427 | } |
1428 | void MainWindow::save() | 1428 | void MainWindow::save() |
1429 | { | 1429 | { |
1430 | if ( mBlockSaveFlag ) | 1430 | if ( mBlockSaveFlag ) |
1431 | return; | 1431 | return; |
1432 | bool store = mBlockSaveFlag; | 1432 | bool store = mBlockSaveFlag; |
1433 | mBlockSaveFlag = true; | 1433 | mBlockSaveFlag = true; |
1434 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1434 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1435 | 1435 | ||
1436 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1436 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1437 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1437 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1438 | qDebug("KO: Start saving data to file!"); | 1438 | qDebug("KO: Start saving data to file!"); |
1439 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1439 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1440 | mView->saveCalendar( defaultFileName() ); | 1440 | mView->saveCalendar( defaultFileName() ); |
1441 | 1441 | ||
1442 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1442 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1443 | mView->watchSavedFile(); | 1443 | mView->watchSavedFile(); |
1444 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1444 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1445 | QString savemes; | 1445 | QString savemes; |
1446 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1446 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1447 | setCaption(savemes); | 1447 | setCaption(savemes); |
1448 | } else | 1448 | } else |
1449 | setCaption(i18n("Saving cancelled!")); | 1449 | setCaption(i18n("Saving cancelled!")); |
1450 | mCalendarModifiedFlag = false; | 1450 | mCalendarModifiedFlag = false; |
1451 | mBlockSaveFlag = store; | 1451 | mBlockSaveFlag = store; |
1452 | } | 1452 | } |
1453 | 1453 | ||
1454 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1454 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1455 | { | 1455 | { |
1456 | if ( !e->isAutoRepeat() ) { | 1456 | if ( !e->isAutoRepeat() ) { |
1457 | mFlagKeyPressed = false; | 1457 | mFlagKeyPressed = false; |
1458 | } | 1458 | } |
1459 | } | 1459 | } |
1460 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1460 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1461 | { | 1461 | { |
1462 | qApp->processEvents(); | 1462 | qApp->processEvents(); |
1463 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1463 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1464 | e->ignore(); | 1464 | e->ignore(); |
1465 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1465 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1466 | return; | 1466 | return; |
1467 | } | 1467 | } |
1468 | if (! e->isAutoRepeat() ) | 1468 | if (! e->isAutoRepeat() ) |
1469 | mFlagKeyPressed = true; | 1469 | mFlagKeyPressed = true; |
1470 | KOPrefs *p = KOPrefs::instance(); | 1470 | KOPrefs *p = KOPrefs::instance(); |
1471 | bool showSelectedDates = false; | 1471 | bool showSelectedDates = false; |
1472 | int size; | 1472 | int size; |
1473 | int pro = 0; | 1473 | int pro = 0; |
1474 | //qDebug("MainWindow::keyPressEvent "); | 1474 | //qDebug("MainWindow::keyPressEvent "); |
1475 | switch ( e->key() ) { | 1475 | switch ( e->key() ) { |
1476 | case Qt::Key_Right: | 1476 | case Qt::Key_Right: |
1477 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1477 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1478 | mView->goNextMonth(); | 1478 | mView->goNextMonth(); |
1479 | else | 1479 | else |
1480 | mView->goNext(); | 1480 | mView->goNext(); |
1481 | showSelectedDates = true; | 1481 | showSelectedDates = true; |
1482 | break; | 1482 | break; |
1483 | case Qt::Key_Left: | 1483 | case Qt::Key_Left: |
1484 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1484 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1485 | mView->goPreviousMonth(); | 1485 | mView->goPreviousMonth(); |
1486 | else | 1486 | else |
1487 | mView->goPrevious(); | 1487 | mView->goPrevious(); |
1488 | showSelectedDates = true; | 1488 | showSelectedDates = true; |
1489 | break; | 1489 | break; |
1490 | case Qt::Key_Down: | 1490 | case Qt::Key_Down: |
1491 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1491 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1492 | break; | 1492 | break; |
1493 | case Qt::Key_Up: | 1493 | case Qt::Key_Up: |
1494 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1494 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1495 | break; | 1495 | break; |
1496 | case Qt::Key_I: | 1496 | case Qt::Key_I: |
1497 | mView->showIncidence(); | 1497 | mView->showIncidence(); |
1498 | break; | 1498 | break; |
1499 | case Qt::Key_Delete: | 1499 | case Qt::Key_Delete: |
1500 | case Qt::Key_Backspace: | 1500 | case Qt::Key_Backspace: |
1501 | mView->deleteIncidence(); | 1501 | mView->deleteIncidence(); |
1502 | break; | 1502 | break; |
1503 | case Qt::Key_D: | 1503 | case Qt::Key_D: |
1504 | mView->viewManager()->showDayView(); | 1504 | mView->viewManager()->showDayView(); |
1505 | showSelectedDates = true; | 1505 | showSelectedDates = true; |
1506 | break; | 1506 | break; |
1507 | case Qt::Key_O: | 1507 | case Qt::Key_O: |
1508 | mView->toggleFilerEnabled( ); | 1508 | mView->toggleFilerEnabled( ); |
1509 | break; | 1509 | break; |
1510 | case Qt::Key_0: | 1510 | case Qt::Key_0: |
1511 | case Qt::Key_1: | 1511 | case Qt::Key_1: |
1512 | case Qt::Key_2: | 1512 | case Qt::Key_2: |
1513 | case Qt::Key_3: | 1513 | case Qt::Key_3: |
1514 | case Qt::Key_4: | 1514 | case Qt::Key_4: |
1515 | case Qt::Key_5: | 1515 | case Qt::Key_5: |
1516 | case Qt::Key_6: | 1516 | case Qt::Key_6: |
1517 | case Qt::Key_7: | 1517 | case Qt::Key_7: |
1518 | case Qt::Key_8: | 1518 | case Qt::Key_8: |
1519 | case Qt::Key_9: | 1519 | case Qt::Key_9: |
1520 | pro = e->key()-48; | 1520 | pro = e->key()-48; |
1521 | if ( pro == 0 ) | 1521 | if ( pro == 0 ) |
1522 | pro = 10; | 1522 | pro = 10; |
1523 | if ( e->state() == Qt::ControlButton) | 1523 | if ( e->state() == Qt::ControlButton) |
1524 | pro += 10; | 1524 | pro += 10; |
1525 | break; | 1525 | break; |
1526 | case Qt::Key_M: | 1526 | case Qt::Key_M: |
1527 | mView->viewManager()->showMonthView(); | 1527 | mView->viewManager()->showMonthView(); |
1528 | showSelectedDates = true; | 1528 | showSelectedDates = true; |
1529 | break; | 1529 | break; |
1530 | case Qt::Key_Insert: | 1530 | case Qt::Key_Insert: |
1531 | mView->newEvent(); | 1531 | mView->newEvent(); |
1532 | break; | 1532 | break; |
1533 | case Qt::Key_S : | 1533 | case Qt::Key_S : |
1534 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1534 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1535 | mView->newSubTodo(); | 1535 | mView->newSubTodo(); |
1536 | else | 1536 | else |
1537 | mView->dialogManager()->showSearchDialog(); | 1537 | mView->dialogManager()->showSearchDialog(); |
1538 | break; | 1538 | break; |
1539 | case Qt::Key_Y : | 1539 | case Qt::Key_Y : |
1540 | case Qt::Key_Z : | 1540 | case Qt::Key_Z : |
1541 | mView->viewManager()->showWorkWeekView(); | 1541 | mView->viewManager()->showWorkWeekView(); |
1542 | showSelectedDates = true; | 1542 | showSelectedDates = true; |
1543 | break; | 1543 | break; |
1544 | case Qt::Key_U : | 1544 | case Qt::Key_U : |
1545 | mView->viewManager()->showWeekView(); | 1545 | mView->viewManager()->showWeekView(); |
1546 | showSelectedDates = true; | 1546 | showSelectedDates = true; |
1547 | break; | 1547 | break; |
1548 | case Qt::Key_H : | 1548 | case Qt::Key_H : |
1549 | keyBindings(); | 1549 | keyBindings(); |
1550 | break; | 1550 | break; |
1551 | case Qt::Key_W: | 1551 | case Qt::Key_W: |
1552 | mView->viewManager()->showWhatsNextView(); | 1552 | mView->viewManager()->showWhatsNextView(); |
1553 | break; | 1553 | break; |
1554 | case Qt::Key_L: | 1554 | case Qt::Key_L: |
1555 | mView->viewManager()->showListView(); | 1555 | mView->viewManager()->showListView(); |
1556 | break; | 1556 | break; |
1557 | case Qt::Key_N: | 1557 | case Qt::Key_N: |
1558 | mView->viewManager()->showNextXView(); | 1558 | mView->viewManager()->showNextXView(); |
1559 | showSelectedDates = true; | 1559 | showSelectedDates = true; |
1560 | break; | 1560 | break; |
1561 | case Qt::Key_V: | 1561 | case Qt::Key_V: |
1562 | mView->viewManager()->showTodoView(); | 1562 | mView->viewManager()->showTodoView(); |
1563 | break; | 1563 | break; |
1564 | case Qt::Key_C: | 1564 | case Qt::Key_C: |
1565 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1565 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1566 | break; | 1566 | break; |
1567 | case Qt::Key_P: | 1567 | case Qt::Key_P: |
1568 | mView->showDatePicker( ); | 1568 | mView->showDatePicker( ); |
1569 | break; | 1569 | break; |
1570 | case Qt::Key_F: | 1570 | case Qt::Key_F: |
1571 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1571 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1572 | mView->editFilters(); | 1572 | mView->editFilters(); |
1573 | else | 1573 | else |
1574 | mView->toggleFilter(); | 1574 | mView->toggleFilter(); |
1575 | break; | 1575 | break; |
1576 | case Qt::Key_X: | 1576 | case Qt::Key_X: |
1577 | mView->toggleDateNavigatorWidget(); | 1577 | mView->toggleDateNavigatorWidget(); |
1578 | break; | 1578 | break; |
1579 | case Qt::Key_Space: | 1579 | case Qt::Key_Space: |
1580 | mView->toggleExpand(); | 1580 | mView->toggleExpand(); |
1581 | break; | 1581 | break; |
1582 | case Qt::Key_A: | 1582 | case Qt::Key_A: |
1583 | mView->toggleAllDaySize(); | 1583 | mView->toggleAllDaySize(); |
1584 | break; | 1584 | break; |
1585 | case Qt::Key_T: | 1585 | case Qt::Key_T: |
1586 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1586 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1587 | mView->newTodo(); | 1587 | mView->newTodo(); |
1588 | else { | 1588 | else { |
1589 | mView->goToday(); | 1589 | mView->goToday(); |
1590 | showSelectedDates = true; | 1590 | showSelectedDates = true; |
1591 | } | 1591 | } |
1592 | break; | 1592 | break; |
1593 | case Qt::Key_J: | 1593 | case Qt::Key_J: |
1594 | mView->viewManager()->showJournalView(); | 1594 | mView->viewManager()->showJournalView(); |
1595 | break; | 1595 | break; |
1596 | case Qt::Key_B: | 1596 | case Qt::Key_B: |
1597 | mView->editIncidenceDescription();; | 1597 | mView->editIncidenceDescription();; |
1598 | break; | 1598 | break; |
1599 | // case Qt::Key_Return: | 1599 | // case Qt::Key_Return: |
1600 | case Qt::Key_E: | 1600 | case Qt::Key_E: |
1601 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1601 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1602 | mView->newEvent(); | 1602 | mView->newEvent(); |
1603 | else | 1603 | else |
1604 | mView->editIncidence(); | 1604 | mView->editIncidence(); |
1605 | break; | 1605 | break; |
1606 | case Qt::Key_Plus: | 1606 | case Qt::Key_Plus: |
1607 | size = p->mHourSize +2; | 1607 | size = p->mHourSize +2; |
1608 | if ( size <= 18 ) | 1608 | if ( size <= 18 ) |
1609 | configureAgenda( size ); | 1609 | configureAgenda( size ); |
1610 | break; | 1610 | break; |
1611 | case Qt::Key_Minus: | 1611 | case Qt::Key_Minus: |
1612 | size = p->mHourSize - 2; | 1612 | size = p->mHourSize - 2; |
1613 | if ( size >= 4 ) | 1613 | if ( size >= 4 ) |
1614 | configureAgenda( size ); | 1614 | configureAgenda( size ); |
1615 | break; | 1615 | break; |
1616 | 1616 | ||
1617 | 1617 | ||
1618 | default: | 1618 | default: |
1619 | e->ignore(); | 1619 | e->ignore(); |
1620 | } | 1620 | } |
1621 | if ( pro > 0 ) { | 1621 | if ( pro > 0 ) { |
1622 | mView->selectFilter( pro-1 ); | 1622 | mView->selectFilter( pro-1 ); |
1623 | } | 1623 | } |
1624 | if ( showSelectedDates ) { | 1624 | if ( showSelectedDates ) { |
1625 | ;// setCaptionToDates(); | 1625 | ;// setCaptionToDates(); |
1626 | } | 1626 | } |
1627 | 1627 | ||
1628 | } | 1628 | } |
1629 | 1629 | ||
1630 | void MainWindow::fillFilterMenu() | 1630 | void MainWindow::fillFilterMenu() |
1631 | { | 1631 | { |
1632 | selectFilterMenu->clear(); | 1632 | selectFilterMenu->clear(); |
1633 | bool disable = false; | 1633 | bool disable = false; |
1634 | if ( mView->filterView()->filtersEnabled() ) { | 1634 | if ( mView->filterView()->filtersEnabled() ) { |
1635 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1635 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1636 | } | 1636 | } |
1637 | else { | 1637 | else { |
1638 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1638 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1639 | disable = true; | 1639 | disable = true; |
1640 | } | 1640 | } |
1641 | selectFilterMenu->insertSeparator(); | 1641 | selectFilterMenu->insertSeparator(); |
1642 | QPtrList<CalFilter> fili = mView->filters(); | 1642 | QPtrList<CalFilter> fili = mView->filters(); |
1643 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1643 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1644 | CalFilter *filter = fili.first(); | 1644 | CalFilter *filter = fili.first(); |
1645 | int iii = 1; | 1645 | int iii = 1; |
1646 | while(filter) { | 1646 | while(filter) { |
1647 | selectFilterMenu->insertItem( filter->name(), iii ); | 1647 | selectFilterMenu->insertItem( filter->name(), iii ); |
1648 | if ( filter == curfilter) | 1648 | if ( filter == curfilter) |
1649 | selectFilterMenu->setItemChecked( iii, true ); | 1649 | selectFilterMenu->setItemChecked( iii, true ); |
1650 | if ( disable ) | 1650 | if ( disable ) |
1651 | selectFilterMenu->setItemEnabled( iii, false ); | 1651 | selectFilterMenu->setItemEnabled( iii, false ); |
1652 | filter = fili.next(); | 1652 | filter = fili.next(); |
1653 | ++iii; | 1653 | ++iii; |
1654 | } | 1654 | } |
1655 | } | 1655 | } |
1656 | void MainWindow::selectFilter( int fil ) | 1656 | void MainWindow::selectFilter( int fil ) |
1657 | { | 1657 | { |
1658 | if ( fil == 0 ) { | 1658 | if ( fil == 0 ) { |
1659 | mView->toggleFilerEnabled( ); | 1659 | mView->toggleFilerEnabled( ); |
1660 | } else { | 1660 | } else { |
1661 | mView->selectFilter( fil-1 ); | 1661 | mView->selectFilter( fil-1 ); |
1662 | } | 1662 | } |
1663 | } | 1663 | } |
1664 | void MainWindow::configureToolBar( int item ) | 1664 | void MainWindow::configureToolBar( int item ) |
1665 | { | 1665 | { |
1666 | 1666 | ||
1667 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1667 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1668 | KOPrefs *p = KOPrefs::instance(); | 1668 | KOPrefs *p = KOPrefs::instance(); |
1669 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1669 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1670 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1670 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1671 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1671 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1672 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1672 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1673 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1673 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1674 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1674 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1675 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1675 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1676 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1676 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1677 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1677 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1678 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1678 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1679 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1679 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1680 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1680 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1681 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1681 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1682 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1682 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1683 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1683 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1684 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1684 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1685 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1685 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1686 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1686 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1687 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1687 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1688 | // initActions(); | 1688 | // initActions(); |
1689 | } | 1689 | } |
1690 | 1690 | ||
1691 | void MainWindow::setCaptionToDates() | 1691 | void MainWindow::setCaptionToDates() |
1692 | { | 1692 | { |
1693 | QString selDates; | 1693 | QString selDates; |
1694 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1694 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1695 | if (mView->startDate() < mView->endDate() ) | 1695 | if (mView->startDate() < mView->endDate() ) |
1696 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1696 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1697 | setCaption( i18n("Dates: ") + selDates ); | 1697 | setCaption( i18n("Dates: ") + selDates ); |
1698 | 1698 | ||
1699 | } | 1699 | } |
1700 | // parameter item == 0: reinit | 1700 | // parameter item == 0: reinit |
1701 | void MainWindow::configureAgenda( int item ) | 1701 | void MainWindow::configureAgenda( int item ) |
1702 | { | 1702 | { |
1703 | 1703 | ||
1704 | KOPrefs *p = KOPrefs::instance(); | 1704 | KOPrefs *p = KOPrefs::instance(); |
1705 | 1705 | ||
1706 | int i; | 1706 | int i; |
1707 | if ( item == 1 ) { | 1707 | if ( item == 1 ) { |
1708 | mView->toggleAllDaySize(); | 1708 | mView->toggleAllDaySize(); |
1709 | return; | 1709 | return; |
1710 | } | 1710 | } |
1711 | // do not allow 4 for widgets higher than 480 | 1711 | // do not allow 4 for widgets higher than 480 |
1712 | // if ( QApplication::desktop()->height() > 480 ) { | 1712 | // if ( QApplication::desktop()->height() > 480 ) { |
1713 | // if ( item == 4 ) | 1713 | // if ( item == 4 ) |
1714 | // item = 6; | 1714 | // item = 6; |
1715 | // } | 1715 | // } |
1716 | for ( i = 4; i <= 18; i= i+2 ) | 1716 | for ( i = 4; i <= 18; i= i+2 ) |
1717 | configureAgendaMenu->setItemChecked( i, false ); | 1717 | configureAgendaMenu->setItemChecked( i, false ); |
1718 | configureAgendaMenu->setItemChecked( item, true ); | 1718 | configureAgendaMenu->setItemChecked( item, true ); |
1719 | if ( p->mHourSize == item ) | 1719 | if ( p->mHourSize == item ) |
1720 | return; | 1720 | return; |
1721 | p->mHourSize=item; | 1721 | p->mHourSize=item; |
1722 | mView->viewManager()->agendaView()->updateConfig(); | 1722 | mView->viewManager()->agendaView()->updateConfig(); |
1723 | } | 1723 | } |
1724 | 1724 | ||
1725 | void MainWindow::saveCalendar() | 1725 | void MainWindow::saveCalendar() |
1726 | { | 1726 | { |
1727 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1727 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1728 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1728 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1729 | 1729 | ||
1730 | if ( fn == "" ) | 1730 | if ( fn == "" ) |
1731 | return; | 1731 | return; |
1732 | QFileInfo info; | 1732 | QFileInfo info; |
1733 | info.setFile( fn ); | 1733 | info.setFile( fn ); |
1734 | QString mes; | 1734 | QString mes; |
1735 | bool createbup = true; | 1735 | bool createbup = true; |
1736 | if ( info. exists() ) { | 1736 | if ( info. exists() ) { |
1737 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1737 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1738 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1738 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1739 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1739 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1740 | 0, 1 ); | 1740 | 0, 1 ); |
1741 | if ( result != 0 ) { | 1741 | if ( result != 0 ) { |
1742 | createbup = false; | 1742 | createbup = false; |
1743 | } | 1743 | } |
1744 | } | 1744 | } |
1745 | if ( createbup ) { | 1745 | if ( createbup ) { |
1746 | mView->saveCalendar( fn ); | 1746 | mView->saveCalendar( fn ); |
1747 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1747 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1748 | KOPrefs::instance()->mLastSaveFile = fn; | 1748 | KOPrefs::instance()->mLastSaveFile = fn; |
1749 | setCaption(mes); | 1749 | setCaption(mes); |
1750 | } | 1750 | } |
1751 | } | 1751 | } |
1752 | void MainWindow::loadCalendar() | 1752 | void MainWindow::loadCalendar() |
1753 | { | 1753 | { |
1754 | 1754 | ||
1755 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1755 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1756 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1756 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1757 | 1757 | ||
1758 | if ( fn == "" ) | 1758 | if ( fn == "" ) |
1759 | return; | 1759 | return; |
1760 | QFileInfo info; | 1760 | QFileInfo info; |
1761 | info.setFile( fn ); | 1761 | info.setFile( fn ); |
1762 | QString mess; | 1762 | QString mess; |
1763 | bool loadbup = true; | 1763 | bool loadbup = true; |
1764 | if ( info. exists() ) { | 1764 | if ( info. exists() ) { |
1765 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1765 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1766 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1766 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1767 | mess, | 1767 | mess, |
1768 | i18n("Load!"), i18n("Cancel"), 0, | 1768 | i18n("Load!"), i18n("Cancel"), 0, |
1769 | 0, 1 ); | 1769 | 0, 1 ); |
1770 | if ( result != 0 ) { | 1770 | if ( result != 0 ) { |
1771 | loadbup = false; | 1771 | loadbup = false; |
1772 | } | 1772 | } |
1773 | } else { | 1773 | } else { |
1774 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1774 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1775 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1775 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1776 | 0, 1 ); | 1776 | 0, 1 ); |
1777 | 1777 | ||
1778 | return; | 1778 | return; |
1779 | } | 1779 | } |
1780 | if ( loadbup ) { | 1780 | if ( loadbup ) { |
1781 | mView->openCalendar( fn ); | 1781 | mView->openCalendar( fn ); |
1782 | KOPrefs::instance()->mLastLoadFile = fn; | 1782 | KOPrefs::instance()->mLastLoadFile = fn; |
1783 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1783 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1784 | setCaption(mess); | 1784 | setCaption(mess); |
1785 | } | 1785 | } |
1786 | 1786 | ||
1787 | } | 1787 | } |
1788 | void MainWindow::quickImportIcal() | 1788 | void MainWindow::quickImportIcal() |
1789 | { | 1789 | { |
1790 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1790 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1791 | } | 1791 | } |
1792 | void MainWindow::importFile( QString fn, bool quick ) | 1792 | void MainWindow::importFile( QString fn, bool quick ) |
1793 | { | 1793 | { |
1794 | QFileInfo info; | 1794 | QFileInfo info; |
1795 | info.setFile( fn ); | 1795 | info.setFile( fn ); |
1796 | QString mess; | 1796 | QString mess; |
1797 | bool loadbup = true; | 1797 | bool loadbup = true; |
1798 | if ( !info. exists() ) { | 1798 | if ( !info. exists() ) { |
1799 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1799 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1800 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1800 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1801 | mess ); | 1801 | mess ); |
1802 | return; | 1802 | return; |
1803 | } | 1803 | } |
1804 | int result = 0; | 1804 | int result = 0; |
1805 | if ( !quick ) { | 1805 | if ( !quick ) { |
1806 | 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 )); | 1806 | 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 )); |
1807 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1807 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1808 | mess, | 1808 | mess, |
1809 | "Import", "Cancel", 0, | 1809 | "Import", "Cancel", 0, |
1810 | 0, 1 ); | 1810 | 0, 1 ); |
1811 | } | 1811 | } |
1812 | if ( result == 0 ) { | 1812 | if ( result == 0 ) { |
1813 | if ( mView->openCalendar( fn, true )) { | 1813 | if ( mView->openCalendar( fn, true )) { |
1814 | KOPrefs::instance()->mLastImportFile = fn; | 1814 | KOPrefs::instance()->mLastImportFile = fn; |
1815 | setCaption(i18n("Imported file successfully")); | 1815 | setCaption(i18n("Imported file successfully")); |
1816 | } else { | 1816 | } else { |
1817 | setCaption(i18n("Error importing file")); | 1817 | setCaption(i18n("Error importing file")); |
1818 | } | 1818 | } |
1819 | } | 1819 | } |
1820 | } | 1820 | } |
1821 | 1821 | ||
1822 | void MainWindow::importIcal() | 1822 | void MainWindow::importIcal() |
1823 | { | 1823 | { |
1824 | 1824 | ||
1825 | QString fn =KOPrefs::instance()->mLastImportFile; | 1825 | QString fn =KOPrefs::instance()->mLastImportFile; |
1826 | 1826 | ||
1827 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1827 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1828 | if ( fn == "" ) | 1828 | if ( fn == "" ) |
1829 | return; | 1829 | return; |
1830 | importFile( fn, true ); | 1830 | importFile( fn, true ); |
1831 | 1831 | ||
1832 | } | 1832 | } |
1833 | 1833 | ||
1834 | void MainWindow::exportVCalendar() | 1834 | void MainWindow::exportVCalendar() |
1835 | { | 1835 | { |
1836 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1836 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1837 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1837 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1838 | if ( fn == "" ) | 1838 | if ( fn == "" ) |
1839 | return; | 1839 | return; |
1840 | QFileInfo info; | 1840 | QFileInfo info; |
1841 | info.setFile( fn ); | 1841 | info.setFile( fn ); |
1842 | QString mes; | 1842 | QString mes; |
1843 | bool createbup = true; | 1843 | bool createbup = true; |
1844 | if ( info. exists() ) { | 1844 | if ( info. exists() ) { |
1845 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1845 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1846 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1846 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1847 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1847 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1848 | 0, 1 ); | 1848 | 0, 1 ); |
1849 | if ( result != 0 ) { | 1849 | if ( result != 0 ) { |
1850 | createbup = false; | 1850 | createbup = false; |
1851 | } | 1851 | } |
1852 | } | 1852 | } |
1853 | if ( createbup ) { | 1853 | if ( createbup ) { |
1854 | if ( mView->exportVCalendar( fn ) ) { | 1854 | if ( mView->exportVCalendar( fn ) ) { |
1855 | KOPrefs::instance()->mLastVcalFile = fn; | 1855 | KOPrefs::instance()->mLastVcalFile = fn; |
1856 | if ( fn.length() > 20 ) | 1856 | if ( fn.length() > 20 ) |
1857 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1857 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1858 | else | 1858 | else |
1859 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1859 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1860 | setCaption(mes); | 1860 | setCaption(mes); |
1861 | } | 1861 | } |
1862 | } | 1862 | } |
1863 | 1863 | ||
1864 | } | 1864 | } |
1865 | QString MainWindow::getPassword( ) | 1865 | QString MainWindow::getPassword( ) |
1866 | { | 1866 | { |
1867 | QString retfile = ""; | 1867 | QString retfile = ""; |
1868 | QDialog dia ( this, "input-dialog", true ); | 1868 | QDialog dia ( this, "input-dialog", true ); |
1869 | QLineEdit lab ( &dia ); | 1869 | QLineEdit lab ( &dia ); |
1870 | lab.setEchoMode( QLineEdit::Password ); | 1870 | lab.setEchoMode( QLineEdit::Password ); |
1871 | QVBoxLayout lay( &dia ); | 1871 | QVBoxLayout lay( &dia ); |
1872 | lay.setMargin(7); | 1872 | lay.setMargin(7); |
1873 | lay.setSpacing(7); | 1873 | lay.setSpacing(7); |
1874 | lay.addWidget( &lab); | 1874 | lay.addWidget( &lab); |
1875 | dia.setFixedSize( 230,50 ); | 1875 | dia.setFixedSize( 230,50 ); |
1876 | dia.setCaption( i18n("Enter password") ); | 1876 | dia.setCaption( i18n("Enter password") ); |
1877 | QPushButton pb ( "OK", &dia); | 1877 | QPushButton pb ( "OK", &dia); |
1878 | lay.addWidget( &pb ); | 1878 | lay.addWidget( &pb ); |
1879 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1879 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1880 | dia.show(); | 1880 | dia.show(); |
1881 | int res = dia.exec(); | 1881 | int res = dia.exec(); |
1882 | if ( res ) | 1882 | if ( res ) |
1883 | retfile = lab.text(); | 1883 | retfile = lab.text(); |
1884 | dia.hide(); | 1884 | dia.hide(); |
1885 | qApp->processEvents(); | 1885 | qApp->processEvents(); |
1886 | return retfile; | 1886 | return retfile; |
1887 | 1887 | ||
1888 | } | 1888 | } |
1889 | 1889 | ||
1890 | void MainWindow::enableQuick() | 1890 | void MainWindow::enableQuick() |
1891 | { | 1891 | { |
1892 | QString retfile = ""; | 1892 | QString retfile = ""; |
1893 | QDialog dia ( this, "input-dialog", true ); | 1893 | QDialog dia ( this, "input-dialog", true ); |
1894 | QLineEdit lab ( &dia ); | 1894 | QLineEdit lab ( &dia ); |
1895 | QVBoxLayout lay( &dia ); | 1895 | QVBoxLayout lay( &dia ); |
1896 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); | 1896 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); |
1897 | lay.setMargin(7); | 1897 | lay.setMargin(7); |
1898 | lay.setSpacing(7); | 1898 | lay.setSpacing(7); |
1899 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); | 1899 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); |
1900 | lay.addWidget( &label); | 1900 | lay.addWidget( &label); |
1901 | lay.addWidget( &lab); | 1901 | lay.addWidget( &lab); |
1902 | dia.setFixedSize( 230,80 ); | 1902 | dia.setFixedSize( 230,80 ); |
1903 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync") ); | 1903 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync") ); |
1904 | QPushButton pb ( "OK", &dia); | 1904 | QPushButton pb ( "OK", &dia); |
1905 | lay.addWidget( &pb ); | 1905 | lay.addWidget( &pb ); |
1906 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1906 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1907 | dia.show(); | 1907 | dia.show(); |
1908 | int res = dia.exec(); | 1908 | int res = dia.exec(); |
1909 | if ( res ) | 1909 | if ( res ) |
1910 | retfile = lab.text(); | 1910 | retfile = lab.text(); |
1911 | else | 1911 | else |
1912 | return; | 1912 | return; |
1913 | dia.hide(); | 1913 | dia.hide(); |
1914 | qApp->processEvents(); | 1914 | qApp->processEvents(); |
1915 | KOPrefs::instance()->mPassiveSyncPort = retfile; | 1915 | KOPrefs::instance()->mPassiveSyncPort = retfile; |
1916 | bool ok; | 1916 | bool ok; |
1917 | Q_UINT16 port = retfile.toUInt(&ok); | 1917 | Q_UINT16 port = retfile.toUInt(&ok); |
1918 | if ( ! ok ) { | 1918 | if ( ! ok ) { |
1919 | qDebug("no valid port "); | 1919 | qDebug("no valid port "); |
1920 | return; | 1920 | return; |
1921 | } | 1921 | } |
1922 | qDebug("port %d ", port); | 1922 | qDebug("port %d ", port); |
1923 | mServerSocket = new KServerSocket ( port ,1 ); | 1923 | mServerSocket = new KServerSocket ( port ,1 ); |
1924 | qDebug("connected "); | 1924 | qDebug("connected "); |
1925 | if ( !mServerSocket->ok() ) { | 1925 | if ( !mServerSocket->ok() ) { |
1926 | qWarning("Failed to bind to port %d", port); | 1926 | qWarning("Failed to bind to port %d", port); |
1927 | delete mServerSocket; | 1927 | delete mServerSocket; |
1928 | mServerSocket = 0; | 1928 | mServerSocket = 0; |
1929 | return; | 1929 | return; |
1930 | } | 1930 | } |
1931 | connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); | 1931 | connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); |
1932 | connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); | 1932 | connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); |
1933 | } | 1933 | } |
1934 | void MainWindow::sendFile(QSocket* socket) | 1934 | void MainWindow::sendFile(QSocket* socket) |
1935 | { | 1935 | { |
1936 | setCaption( i18n("Received request for file") ); | 1936 | setCaption( i18n("Received request for file") ); |
1937 | qDebug("MainWindow::sendFile(QSocket* s) "); | 1937 | qDebug("MainWindow::sendFile(QSocket* s) "); |
1938 | if ( mSyncActionDialog ) | 1938 | if ( mSyncActionDialog ) |
1939 | delete mSyncActionDialog; | 1939 | delete mSyncActionDialog; |
1940 | mSyncActionDialog = new QDialog ( this, "input-dialog", true ); | 1940 | mSyncActionDialog = new QDialog ( this, "input-dialog", true ); |
1941 | mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING")); | 1941 | mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING")); |
1942 | QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog ); | 1942 | QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog ); |
1943 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1943 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1944 | lay->addWidget( label); | 1944 | lay->addWidget( label); |
1945 | lay->setMargin(7); | 1945 | lay->setMargin(7); |
1946 | lay->setSpacing(7); | 1946 | lay->setSpacing(7); |
1947 | mSyncActionDialog->setFixedSize( 200,100 ); | 1947 | mSyncActionDialog->setFixedSize( 200,100 ); |
1948 | mSyncActionDialog->show(); | 1948 | mSyncActionDialog->show(); |
1949 | qApp->processEvents(); | 1949 | qApp->processEvents(); |
1950 | qDebug("saving ... "); | 1950 | qDebug("saving ... "); |
1951 | save(); | 1951 | save(); |
1952 | QString fileName = defaultFileName(); | 1952 | QString fileName = defaultFileName(); |
1953 | QFile file( fileName ); | 1953 | QFile file( fileName ); |
1954 | if (!file.open( IO_ReadOnly ) ) { | 1954 | if (!file.open( IO_ReadOnly ) ) { |
1955 | setCaption( i18n("Error open file") ); | 1955 | setCaption( i18n("Error open file") ); |
1956 | delete mSyncActionDialog; | 1956 | delete mSyncActionDialog; |
1957 | mSyncActionDialog = 0; | 1957 | mSyncActionDialog = 0; |
1958 | qDebug("error open cal file "); | 1958 | qDebug("error open cal file "); |
1959 | return ; | 1959 | return ; |
1960 | 1960 | ||
1961 | } | 1961 | } |
1962 | setCaption( i18n("Sending file...") ); | 1962 | setCaption( i18n("Sending file...") ); |
1963 | QTextStream ts( &file ); | 1963 | QTextStream ts( &file ); |
1964 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 1964 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
1965 | QTextStream os( socket ); | 1965 | QTextStream os( socket ); |
1966 | os.setCodec( QTextCodec::codecForName("utf8") ); | 1966 | os.setCodec( QTextCodec::codecForName("utf8") ); |
1967 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 1967 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
1968 | while ( ! ts.atEnd() ) { | 1968 | while ( ! ts.atEnd() ) { |
1969 | os << ts.readLine() << "\n"; | 1969 | os << ts.readLine() << "\n"; |
1970 | } | 1970 | } |
1971 | //os << ts.read(); | 1971 | //os << ts.read(); |
1972 | socket->close(); | 1972 | socket->close(); |
1973 | file.close(); | 1973 | file.close(); |
1974 | setCaption( i18n("File sent. Waiting to get back synced file") ); | 1974 | setCaption( i18n("File sent. Waiting to get back synced file") ); |
1975 | qDebug("file sent "); | 1975 | qDebug("file sent "); |
1976 | } | 1976 | } |
1977 | void MainWindow::getFile(QSocket* socket) | 1977 | void MainWindow::getFile(QSocket* socket) |
1978 | { | 1978 | { |
1979 | setCaption( i18n("Receiving synced file...") ); | 1979 | setCaption( i18n("Receiving synced file...") ); |
1980 | 1980 | ||
1981 | QString fileName = defaultFileName(); | 1981 | QString fileName = defaultFileName(); |
1982 | QFile file( fileName ); | 1982 | QFile file( fileName ); |
1983 | if (!file.open( IO_WriteOnly ) ) { | 1983 | if (!file.open( IO_WriteOnly ) ) { |
1984 | setCaption( i18n("Error open file") ); | 1984 | setCaption( i18n("Error open file") ); |
1985 | delete mSyncActionDialog; | 1985 | delete mSyncActionDialog; |
1986 | mSyncActionDialog = 0; | 1986 | mSyncActionDialog = 0; |
1987 | qDebug("error open cal file "); | 1987 | qDebug("error open cal file "); |
1988 | return ; | 1988 | return ; |
1989 | 1989 | ||
1990 | } | 1990 | } |
1991 | 1991 | ||
1992 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1992 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1993 | QTextStream ts( &file ); | 1993 | QTextStream ts( &file ); |
1994 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 1994 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
1995 | bool first = true; | 1995 | bool first = true; |
1996 | while ( socket->canReadLine () || first ) { | 1996 | while ( socket->canReadLine () || first ) { |
1997 | first = false; | 1997 | first = false; |
1998 | while ( socket->canReadLine () ) { | 1998 | while ( socket->canReadLine () ) { |
1999 | qDebug("avail %d ", socket->bytesAvailable () ); | 1999 | qDebug("avail %d ", socket->bytesAvailable () ); |
2000 | ts << socket->readLine (); | 2000 | ts << socket->readLine (); |
2001 | } | 2001 | } |
2002 | QTime ti; | 2002 | QTime ti; |
2003 | ti.start(); | 2003 | ti.start(); |
2004 | while ( ti.elapsed () < 5000 && !socket->canReadLine () ) { | 2004 | while ( ti.elapsed () < 5000 && !socket->canReadLine () ) { |
2005 | qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () ); | 2005 | qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () ); |
2006 | //qApp->processEvents(); | 2006 | //qApp->processEvents(); |
2007 | qDebug("waiting1b %d ",ti.elapsed () ); | 2007 | qDebug("waiting1b %d ",ti.elapsed () ); |
2008 | if ( !socket->canReadLine () ) { | 2008 | if ( !socket->canReadLine () ) { |
2009 | qDebug("waiting1c %d ",ti.elapsed () ); | 2009 | qDebug("waiting1c %d ",ti.elapsed () ); |
2010 | usleep( 100000); | 2010 | usleep( 100000); |
2011 | } | 2011 | } |
2012 | //socket->waitForMore ( 100 ); | 2012 | //socket->waitForMore ( 100 ); |
2013 | } | 2013 | } |
2014 | ts << socket->readLine (); | 2014 | ts << socket->readLine (); |
2015 | #if 0 | 2015 | #if 0 |
2016 | #ifdef DESKTOP_VERSION | 2016 | #ifdef DESKTOP_VERSION |
2017 | socket->waitForMore ( 5000 ); | 2017 | socket->waitForMore ( 5000 ); |
2018 | #else | 2018 | #else |
2019 | // socket->waitForMore ( 5000 ); | 2019 | // socket->waitForMore ( 5000 ); |
2020 | // seems to be broken in qt2 | 2020 | // seems to be broken in qt2 |
2021 | bool stop = false; | 2021 | bool stop = false; |
2022 | QTime ti; | 2022 | QTime ti; |
2023 | ti.start(); | 2023 | ti.start(); |
2024 | while ( ti.elapsed < 5000 && !stop ) { | 2024 | while ( ti.elapsed < 5000 && !stop ) { |
2025 | qApp->processEvents(); | 2025 | qApp->processEvents(); |
2026 | if ( socket->canReadLine () ) | 2026 | if ( socket->canReadLine () ) |
2027 | stop = true ; | 2027 | stop = true ; |
2028 | else { | 2028 | else { |
2029 | usleep( 100000 ); | 2029 | usleep( 100000 ); |
2030 | 2030 | ||
2031 | } | 2031 | } |
2032 | } | 2032 | } |
2033 | #endif | 2033 | #endif |
2034 | #endif | 2034 | #endif |
2035 | } | 2035 | } |
2036 | setCaption( i18n("File received - reloading calendar...") ); | 2036 | setCaption( i18n("File received - reloading calendar...") ); |
2037 | file.close(); | ||
2038 | socket->close(); | 2037 | socket->close(); |
2038 | file.close(); | ||
2039 | mView->watchSavedFile(); | 2039 | mView->watchSavedFile(); |
2040 | mView->openCalendar( defaultFileName() ); | 2040 | mView->openCalendar( defaultFileName() ); |
2041 | setCaption( i18n("Easy-Pi-Sync successful!") ); | 2041 | setCaption( i18n("Easy-Pi-Sync successful!") ); |
2042 | delete mSyncActionDialog; | 2042 | delete mSyncActionDialog; |
2043 | mSyncActionDialog = 0; | 2043 | mSyncActionDialog = 0; |
2044 | 2044 | ||
2045 | 2045 | ||
2046 | } | 2046 | } |
2047 | void MainWindow::endConnect() | 2047 | void MainWindow::endConnect() |
2048 | { | 2048 | { |
2049 | setCaption( i18n("No file received - syncing successful") ); | 2049 | setCaption( i18n("No file received - syncing successful") ); |
2050 | delete mSyncActionDialog; | 2050 | delete mSyncActionDialog; |
2051 | mSyncActionDialog = 0; | 2051 | mSyncActionDialog = 0; |
2052 | } | 2052 | } |
2053 | void MainWindow::performQuick() | 2053 | void MainWindow::performQuick() |
2054 | { | 2054 | { |
2055 | setCaption( i18n("Please input connection settings") ); | 2055 | setCaption( i18n("Please input connection settings") ); |
2056 | QString retfile = ""; | 2056 | QString retfile = ""; |
2057 | QDialog dia ( this, "input-dialog", true ); | 2057 | QDialog dia ( this, "input-dialog", true ); |
2058 | QLineEdit lab ( &dia ); | 2058 | QLineEdit lab ( &dia ); |
2059 | QVBoxLayout lay( &dia ); | 2059 | QVBoxLayout lay( &dia ); |
2060 | QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); | 2060 | QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); |
2061 | lay.addWidget( &label); | 2061 | lay.addWidget( &label); |
2062 | lab.setText( KOPrefs::instance()->mActiveSyncIP ); | 2062 | lab.setText( KOPrefs::instance()->mActiveSyncIP ); |
2063 | lay.setMargin(7); | 2063 | lay.setMargin(7); |
2064 | lay.setSpacing(7); | 2064 | lay.setSpacing(7); |
2065 | lay.addWidget( &lab); | 2065 | lay.addWidget( &lab); |
2066 | QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); | 2066 | QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); |
2067 | lay.addWidget( &label2); | 2067 | lay.addWidget( &label2); |
2068 | QLineEdit lab2 ( &dia ); | 2068 | QLineEdit lab2 ( &dia ); |
2069 | lab2.setText( KOPrefs::instance()->mActiveSyncPort ); | 2069 | lab2.setText( KOPrefs::instance()->mActiveSyncPort ); |
2070 | lay.addWidget( &lab2); | 2070 | lay.addWidget( &lab2); |
2071 | dia.setFixedSize( 230,200 ); | 2071 | dia.setFixedSize( 230,200 ); |
2072 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") ); | 2072 | dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") ); |
2073 | QPushButton pb ( "OK", &dia); | 2073 | QPushButton pb ( "OK", &dia); |
2074 | lay.addWidget( &pb ); | 2074 | lay.addWidget( &pb ); |
2075 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2075 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2076 | dia.show(); | 2076 | dia.show(); |
2077 | int res = dia.exec(); | 2077 | int res = dia.exec(); |
2078 | if ( !res ) { | 2078 | if ( !res ) { |
2079 | setCaption( i18n("Syncing cancelled!") ); | 2079 | setCaption( i18n("Syncing cancelled!") ); |
2080 | return; | 2080 | return; |
2081 | } | 2081 | } |
2082 | dia.hide(); | 2082 | dia.hide(); |
2083 | KOPrefs::instance()->mActiveSyncPort = lab2.text(); | 2083 | KOPrefs::instance()->mActiveSyncPort = lab2.text(); |
2084 | KOPrefs::instance()->mActiveSyncIP = lab.text(); | 2084 | KOPrefs::instance()->mActiveSyncIP = lab.text(); |
2085 | qApp->processEvents(); | 2085 | qApp->processEvents(); |
2086 | performQuickQuick(); | 2086 | performQuickQuick(); |
2087 | } | 2087 | } |
2088 | 2088 | ||
2089 | void MainWindow::performQuickQuick() | 2089 | void MainWindow::performQuickQuick() |
2090 | { | 2090 | { |
2091 | // setCaption( i18n("") ); | 2091 | // setCaption( i18n("") ); |
2092 | 2092 | ||
2093 | bool ok; | 2093 | bool ok; |
2094 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | 2094 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); |
2095 | if ( ! ok ) { | 2095 | if ( ! ok ) { |
2096 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 2096 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
2097 | return; | 2097 | return; |
2098 | } | 2098 | } |
2099 | if ( !mCommandSocket ) { | 2099 | if ( !mCommandSocket ) { |
2100 | mCommandSocket = new QSocket( this ); | 2100 | mCommandSocket = new QSocket( this ); |
2101 | // delete mCommandSocket; | 2101 | // delete mCommandSocket; |
2102 | //mCommandSocket = new QSocket( this ); | 2102 | //mCommandSocket = new QSocket( this ); |
2103 | connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); | 2103 | connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); |
2104 | } | 2104 | } |
2105 | QString host = KOPrefs::instance()->mActiveSyncIP; | 2105 | QString host = KOPrefs::instance()->mActiveSyncIP; |
2106 | mCommandSocket->connectToHost( host, port ); | 2106 | mCommandSocket->connectToHost( host, port ); |
2107 | QTextStream os( mCommandSocket ); | 2107 | QTextStream os( mCommandSocket ); |
2108 | os.setEncoding( QTextStream::UnicodeUTF8 ); | 2108 | os.setEncoding( QTextStream::UnicodeUTF8 ); |
2109 | os << "GET\r\n"; | 2109 | os << "GET\r\n"; |
2110 | setCaption( i18n("Sending request for remote file ...") ); | 2110 | setCaption( i18n("Sending request for remote file ...") ); |
2111 | 2111 | ||
2112 | } | 2112 | } |
2113 | void MainWindow::readFileFromSocket() | 2113 | void MainWindow::readFileFromSocket() |
2114 | { | 2114 | { |
2115 | setCaption( i18n("Receiving remote file ...") ); | 2115 | setCaption( i18n("Receiving remote file ...") ); |
2116 | qDebug("MainWindow::readFileFromSocket() "); | 2116 | qDebug("MainWindow::readFileFromSocket() "); |
2117 | QString fileName; | 2117 | QString fileName; |
2118 | #ifdef _WIN32_ | 2118 | #ifdef _WIN32_ |
2119 | fileName = defaultFileName() +"sync"; | 2119 | fileName = defaultFileName() +"sync"; |
2120 | #else | 2120 | #else |
2121 | fileName = "/tmp/kopitempfile.ics"; | 2121 | fileName = "/tmp/kopitempfile.ics"; |
2122 | #endif | 2122 | #endif |
2123 | QFile file( fileName ); | 2123 | QFile file( fileName ); |
2124 | if (!file.open( IO_WriteOnly ) ) { | 2124 | if (!file.open( IO_WriteOnly ) ) { |
2125 | setCaption( i18n("Error: Cannot open temp file for write.") ); | 2125 | setCaption( i18n("Error: Cannot open temp file for write.") ); |
2126 | qDebug("Error open calender file for writing: %s",fileName.latin1() ); | 2126 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); |
2127 | return ; | 2127 | return ; |
2128 | } | 2128 | } |
2129 | 2129 | ||
2130 | //QTextStream os2( mCommandSocket ); | 2130 | //QTextStream os2( mCommandSocket ); |
2131 | //os2.setEncoding( QTextStream::UnicodeUTF8 ); | 2131 | //os2.setEncoding( QTextStream::UnicodeUTF8 ); |
2132 | 2132 | ||
2133 | QTextStream ts( &file ); | 2133 | QTextStream ts( &file ); |
2134 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2134 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2135 | bool first = true; | 2135 | bool first = true; |
2136 | while ( mCommandSocket->canReadLine () || first) { | 2136 | while ( mCommandSocket->canReadLine () || first) { |
2137 | first = false; | 2137 | first = false; |
2138 | while ( mCommandSocket->canReadLine () ) { | 2138 | while ( mCommandSocket->canReadLine () ) { |
2139 | ts << mCommandSocket->readLine (); | 2139 | ts << mCommandSocket->readLine (); |
2140 | } | 2140 | } |
2141 | QTime ti; | 2141 | QTime ti; |
2142 | ti.start(); | 2142 | ti.start(); |
2143 | while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) { | 2143 | while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) { |
2144 | qApp->processEvents(); | 2144 | qApp->processEvents(); |
2145 | qDebug("waiting2 %d ",ti.elapsed () ); | 2145 | qDebug("waiting2 %d ",ti.elapsed () ); |
2146 | if ( !mCommandSocket->canReadLine () ) | 2146 | if ( !mCommandSocket->canReadLine () ) |
2147 | mCommandSocket->waitForMore ( 100 ); | 2147 | mCommandSocket->waitForMore ( 100 ); |
2148 | } | 2148 | } |
2149 | //mCommandSocket->waitForMore ( 5000 ); | 2149 | //mCommandSocket->waitForMore ( 5000 ); |
2150 | } | 2150 | } |
2151 | file.close(); | 2151 | file.close(); |
2152 | mCommandSocket->close(); | 2152 | mCommandSocket->close(); |
2153 | // pending: deleting after signal SIGNAL(delayedCloseFinished()) | ||
2153 | //delete mCommandSocket; | 2154 | //delete mCommandSocket; |
2154 | setCaption( i18n("Remote file saved to temp file.") ); | 2155 | setCaption( i18n("Remote file saved to temp file.") ); |
2155 | //mCommandSocket = 0; | 2156 | //mCommandSocket = 0; |
2156 | mCurrentSyncProfile = 2 ; // last file | 2157 | mCurrentSyncProfile = 2 ; // last file |
2157 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 2158 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
2158 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 2159 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
2159 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2160 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2160 | KSyncProfile* temp = new KSyncProfile (); | 2161 | KSyncProfile* temp = new KSyncProfile (); |
2161 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2162 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2162 | temp->readConfig(&config); | 2163 | temp->readConfig(&config); |
2163 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2164 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2164 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2165 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2165 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2166 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2166 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2167 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2167 | KOPrefs::instance()->mWriteBackInFuture = 0; | 2168 | KOPrefs::instance()->mWriteBackInFuture = 0; |
2168 | if ( temp->getWriteBackFuture() ) | 2169 | if ( temp->getWriteBackFuture() ) |
2169 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2170 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2170 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2171 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2171 | 2172 | ||
2172 | setCaption( i18n("Remote file saved to temp file.") ); | 2173 | setCaption( i18n("Remote file saved to temp file.") ); |
2173 | if ( ! syncWithFile( fileName , true ) ) { | 2174 | if ( ! syncWithFile( fileName , true ) ) { |
2174 | setCaption( i18n("Syncing failed.") ); | 2175 | setCaption( i18n("Syncing failed.") ); |
2175 | qDebug("Syncing failed "); | 2176 | qDebug("Syncing failed "); |
2176 | return; | 2177 | return; |
2177 | } | 2178 | } |
2178 | 2179 | ||
2179 | if ( !mCommandSocketFinish ) { | 2180 | if ( !mCommandSocketFinish ) { |
2180 | mCommandSocketFinish = new QSocket( this ); | 2181 | mCommandSocketFinish = new QSocket( this ); |
2181 | } | 2182 | } |
2182 | mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); | 2183 | mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); |
2183 | 2184 | ||
2185 | // pending connect signals connected () and error to new slots | ||
2184 | QString host = KOPrefs::instance()->mActiveSyncIP; | 2186 | QString host = KOPrefs::instance()->mActiveSyncIP; |
2185 | QFile file2( fileName ); | 2187 | QFile file2( fileName ); |
2186 | if (!file2.open( IO_ReadOnly ) ) { | 2188 | if (!file2.open( IO_ReadOnly ) ) { |
2187 | setCaption( i18n("Error: Cannot open temp file for read.") ); | 2189 | setCaption( i18n("Error: Cannot open temp file for read.") ); |
2188 | qDebug("error open cal file "); | 2190 | qDebug("error open cal file "); |
2189 | return ; | 2191 | return ; |
2190 | 2192 | ||
2191 | } | 2193 | } |
2192 | setCaption( i18n("Sending back synced file...") ); | 2194 | setCaption( i18n("Sending back synced file...") ); |
2193 | QTextStream ts2( &file2 ); | 2195 | QTextStream ts2( &file2 ); |
2194 | ts2.setCodec( QTextCodec::codecForName("utf8") ); | 2196 | ts2.setCodec( QTextCodec::codecForName("utf8") ); |
2195 | QTextStream os2( mCommandSocketFinish ); | 2197 | QTextStream os2( mCommandSocketFinish ); |
2196 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2198 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2197 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 2199 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
2198 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2200 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2199 | os2 << "PUT\r\n"; | 2201 | os2 << "PUT\r\n"; |
2200 | while ( ! ts2.atEnd() ) { | 2202 | while ( ! ts2.atEnd() ) { |
2201 | os2 << ts2.readLine() << "\n"; | 2203 | os2 << ts2.readLine() << "\n"; |
2202 | } | 2204 | } |
2203 | } else { | 2205 | } else { |
2204 | os2 << "STOP\r\n"; | 2206 | os2 << "STOP\r\n"; |
2205 | } | 2207 | } |
2206 | mCommandSocketFinish->close(); | 2208 | mCommandSocketFinish->close(); |
2207 | file.close(); | 2209 | file.close(); |
2210 | // pending: deleting after signal SIGNAL(delayedCloseFinished()) | ||
2208 | //delete ( mCommandSocket); | 2211 | //delete ( mCommandSocket); |
2209 | //mCommandSocket = 0; | 2212 | //mCommandSocket = 0; |
2210 | qDebug("Syncing succesful! "); | 2213 | qDebug("Syncing succesful! "); |
2211 | setCaption( i18n("Easy-Pi-Sync succesful!") ); | 2214 | setCaption( i18n("Easy-Pi-Sync succesful!") ); |
2212 | 2215 | ||
2213 | 2216 | ||
2214 | } | 2217 | } |
2215 | 2218 | ||
2216 | void MainWindow::syncLocalFile() | 2219 | void MainWindow::syncLocalFile() |
2217 | { | 2220 | { |
2218 | 2221 | ||
2219 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 2222 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; |
2220 | 2223 | ||
2221 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2224 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2222 | if ( fn == "" ) | 2225 | if ( fn == "" ) |
2223 | return; | 2226 | return; |
2224 | //mView->setSyncDevice("local-file" ); | 2227 | //mView->setSyncDevice("local-file" ); |
2225 | if ( syncWithFile( fn, false ) ) { | 2228 | if ( syncWithFile( fn, false ) ) { |
2226 | // Event* e = mView->getLastSyncEvent(); | 2229 | // Event* e = mView->getLastSyncEvent(); |
2227 | // e->setReadOnly( false ); | 2230 | // e->setReadOnly( false ); |
2228 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2231 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2229 | // e->setReadOnly( true ); | 2232 | // e->setReadOnly( true ); |
2230 | } | 2233 | } |
2231 | 2234 | ||
2232 | } | 2235 | } |
2233 | 2236 | ||
2234 | bool MainWindow::syncWithFile( QString fn , bool quick ) | 2237 | bool MainWindow::syncWithFile( QString fn , bool quick ) |
2235 | { | 2238 | { |
2236 | bool ret = false; | 2239 | bool ret = false; |
2237 | QFileInfo info; | 2240 | QFileInfo info; |
2238 | info.setFile( fn ); | 2241 | info.setFile( fn ); |
2239 | QString mess; | 2242 | QString mess; |
2240 | bool loadbup = true; | 2243 | bool loadbup = true; |
2241 | if ( !info. exists() ) { | 2244 | if ( !info. exists() ) { |
2242 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2245 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2243 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2246 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2244 | mess ); | 2247 | mess ); |
2245 | return ret; | 2248 | return ret; |
2246 | } | 2249 | } |
2247 | int result = 0; | 2250 | int result = 0; |
2248 | if ( !quick ) { | 2251 | if ( !quick ) { |
2249 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2252 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2250 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2253 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2251 | mess, | 2254 | mess, |
2252 | i18n("Sync"), i18n("Cancel"), 0, | 2255 | i18n("Sync"), i18n("Cancel"), 0, |
2253 | 0, 1 ); | 2256 | 0, 1 ); |
2254 | if ( result ) | 2257 | if ( result ) |
2255 | return false; | 2258 | return false; |
2256 | } | 2259 | } |
2257 | if ( KOPrefs::instance()->mAskForPreferences ) | 2260 | if ( KOPrefs::instance()->mAskForPreferences ) |
2258 | mView->edit_sync_options(); | 2261 | mView->edit_sync_options(); |
2259 | if ( result == 0 ) { | 2262 | if ( result == 0 ) { |
2260 | //qDebug("Now sycing ... "); | 2263 | //qDebug("Now sycing ... "); |
2261 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) | 2264 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) |
2262 | setCaption( i18n("Synchronization successful") ); | 2265 | setCaption( i18n("Synchronization successful") ); |
2263 | else | 2266 | else |
2264 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 2267 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
2265 | if ( ! quick ) | 2268 | if ( ! quick ) |
2266 | KOPrefs::instance()->mLastSyncedLocalFile = fn; | 2269 | KOPrefs::instance()->mLastSyncedLocalFile = fn; |
2267 | slotModifiedChanged( true ); | 2270 | slotModifiedChanged( true ); |
2268 | } | 2271 | } |
2269 | return ret; | 2272 | return ret; |
2270 | } | 2273 | } |
2271 | void MainWindow::quickSyncLocalFile() | 2274 | void MainWindow::quickSyncLocalFile() |
2272 | { | 2275 | { |
2273 | //mView->setSyncDevice("local-file" ); | 2276 | //mView->setSyncDevice("local-file" ); |
2274 | //qDebug("quickSyncLocalFile() "); | 2277 | //qDebug("quickSyncLocalFile() "); |
2275 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 2278 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
2276 | // Event* e = mView->getLastSyncEvent(); | 2279 | // Event* e = mView->getLastSyncEvent(); |
2277 | // e->setReadOnly( false ); | 2280 | // e->setReadOnly( false ); |
2278 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2281 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2279 | // e->setReadOnly( true ); | 2282 | // e->setReadOnly( true ); |
2280 | 2283 | ||
2281 | } | 2284 | } |
2282 | } | 2285 | } |
2283 | 2286 | ||
2284 | void MainWindow::confSync() | 2287 | void MainWindow::confSync() |
2285 | { | 2288 | { |
2286 | mView->confSync(); | 2289 | mView->confSync(); |
2287 | fillSyncMenu(); | 2290 | fillSyncMenu(); |
2288 | } | 2291 | } |
2289 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) | 2292 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) |
2290 | { | 2293 | { |
2291 | QString question; | 2294 | QString question; |
2292 | if ( ask ) { | 2295 | if ( ask ) { |
2293 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 2296 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
2294 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2297 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2295 | question, | 2298 | question, |
2296 | i18n("Yes"), i18n("No"), | 2299 | i18n("Yes"), i18n("No"), |
2297 | 0, 0 ) != 0 ) | 2300 | 0, 0 ) != 0 ) |
2298 | return; | 2301 | return; |
2299 | } | 2302 | } |
2300 | QString command = prof->getPreSyncCommand(); | 2303 | QString command = prof->getPreSyncCommand(); |
2301 | int fi; | 2304 | int fi; |
2302 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2305 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2303 | QString pwd = getPassword(); | 2306 | QString pwd = getPassword(); |
2304 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2307 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2305 | 2308 | ||
2306 | } | 2309 | } |
2307 | int maxlen = 30; | 2310 | int maxlen = 30; |
2308 | if ( QApplication::desktop()->width() > 320 ) | 2311 | if ( QApplication::desktop()->width() > 320 ) |
2309 | maxlen += 25; | 2312 | maxlen += 25; |
2310 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2313 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2311 | int fileSize = 0; | 2314 | int fileSize = 0; |
2312 | int result = system ( command ); | 2315 | int result = system ( command ); |
2313 | // 0 : okay | 2316 | // 0 : okay |
2314 | // 256: no such file or dir | 2317 | // 256: no such file or dir |
2315 | // | 2318 | // |
2316 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2319 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2317 | if ( result != 0 ) { | 2320 | if ( result != 0 ) { |
2318 | int len = maxlen; | 2321 | int len = maxlen; |
2319 | while ( len < command.length() ) { | 2322 | while ( len < command.length() ) { |
2320 | command.insert( len , "\n" ); | 2323 | command.insert( len , "\n" ); |
2321 | len += maxlen +2; | 2324 | len += maxlen +2; |
2322 | } | 2325 | } |
2323 | 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) ; | 2326 | 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) ; |
2324 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2327 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2325 | question, | 2328 | question, |
2326 | i18n("Okay!")) ; | 2329 | i18n("Okay!")) ; |
2327 | setCaption ("KO/Pi"); | 2330 | setCaption ("KO/Pi"); |
2328 | return; | 2331 | return; |
2329 | } | 2332 | } |
2330 | setCaption ( i18n( "Copying succeed." ) ); | 2333 | setCaption ( i18n( "Copying succeed." ) ); |
2331 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2334 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2332 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { | 2335 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { |
2333 | // Event* e = mView->getLastSyncEvent(); | 2336 | // Event* e = mView->getLastSyncEvent(); |
2334 | // e->setReadOnly( false ); | 2337 | // e->setReadOnly( false ); |
2335 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2338 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2336 | // e->setReadOnly( true ); | 2339 | // e->setReadOnly( true ); |
2337 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2340 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2338 | command = prof->getPostSyncCommand(); | 2341 | command = prof->getPostSyncCommand(); |
2339 | int fi; | 2342 | int fi; |
2340 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2343 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2341 | QString pwd = getPassword(); | 2344 | QString pwd = getPassword(); |
2342 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2345 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2343 | 2346 | ||
2344 | } | 2347 | } |
2345 | setCaption ( i18n( "Writing back file ..." ) ); | 2348 | setCaption ( i18n( "Writing back file ..." ) ); |
2346 | result = system ( command ); | 2349 | result = system ( command ); |
2347 | qDebug("KO: Writing back file result: %d ", result); | 2350 | qDebug("KO: Writing back file result: %d ", result); |
2348 | if ( result != 0 ) { | 2351 | if ( result != 0 ) { |
2349 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2352 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2350 | return; | 2353 | return; |
2351 | } else { | 2354 | } else { |
2352 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2355 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2353 | } | 2356 | } |
2354 | } | 2357 | } |
2355 | } | 2358 | } |
2356 | return; | 2359 | return; |
2357 | } | 2360 | } |
2358 | void MainWindow::syncSSH() | 2361 | void MainWindow::syncSSH() |
2359 | { | 2362 | { |
2360 | // not used anymore | 2363 | // not used anymore |
2361 | QTime timer; | 2364 | QTime timer; |
2362 | timer.start(); | 2365 | timer.start(); |
2363 | //qDebug("MainWindow::syncssh() "); | 2366 | //qDebug("MainWindow::syncssh() "); |
2364 | KOPrefs *p = KOPrefs::instance(); | 2367 | KOPrefs *p = KOPrefs::instance(); |
2365 | QString localFile = p->mLocalTempFile; | 2368 | QString localFile = p->mLocalTempFile; |
2366 | QString remoteIP = p->mRemoteIP; | 2369 | QString remoteIP = p->mRemoteIP; |
2367 | QString remoteUser = p->mRemoteUser; | 2370 | QString remoteUser = p->mRemoteUser; |
2368 | QString remoteFile = p->mRemoteFile; | 2371 | QString remoteFile = p->mRemoteFile; |
2369 | if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) | 2372 | if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) |
2370 | remoteUser += ":" + p->mRemotePassWd; | 2373 | remoteUser += ":" + p->mRemotePassWd; |
2371 | 2374 | ||
2372 | QString question = i18n("Do you really want\nto remote sync?\n \n") + | 2375 | QString question = i18n("Do you really want\nto remote sync?\n \n") + |
2373 | i18n("IP: " ) +remoteIP +"\n" + | 2376 | i18n("IP: " ) +remoteIP +"\n" + |
2374 | i18n("User: " ) + remoteUser +"\n" ; | 2377 | i18n("User: " ) + remoteUser +"\n" ; |
2375 | int maxlen = 30; | 2378 | int maxlen = 30; |
2376 | if ( QApplication::desktop()->width() > 320 ) | 2379 | if ( QApplication::desktop()->width() > 320 ) |
2377 | maxlen += 25; | 2380 | maxlen += 25; |
2378 | if ( remoteFile.length() > maxlen ) | 2381 | if ( remoteFile.length() > maxlen ) |
2379 | question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; | 2382 | question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; |
2380 | else | 2383 | else |
2381 | question += i18n("Remote file:\n " ) + remoteFile +"\n"; | 2384 | question += i18n("Remote file:\n " ) + remoteFile +"\n"; |
2382 | if ( localFile.length() > maxlen ) | 2385 | if ( localFile.length() > maxlen ) |
2383 | question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; | 2386 | question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; |
2384 | else | 2387 | else |
2385 | question += i18n("Local temp file:\n " ) + localFile +"\n"; | 2388 | question += i18n("Local temp file:\n " ) + localFile +"\n"; |
2386 | 2389 | ||
2387 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2390 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2388 | question, | 2391 | question, |
2389 | i18n("Yes"), i18n("No"), | 2392 | i18n("Yes"), i18n("No"), |
2390 | 0, 0 ) != 0 ) | 2393 | 0, 0 ) != 0 ) |
2391 | return; | 2394 | return; |
2392 | // if ( !p->mUsePassWd ) { | 2395 | // if ( !p->mUsePassWd ) { |
2393 | // QString pass = getPassword(); | 2396 | // QString pass = getPassword(); |
2394 | // if ( pass.length() > 0 ) | 2397 | // if ( pass.length() > 0 ) |
2395 | // remoteUser += ":" + pass; | 2398 | // remoteUser += ":" + pass; |
2396 | // } | 2399 | // } |
2397 | QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; | 2400 | QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; |
2398 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2401 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2399 | int fileSize = 0; | 2402 | int fileSize = 0; |
2400 | int result = system ( command ); | 2403 | int result = system ( command ); |
2401 | // 0 : okay | 2404 | // 0 : okay |
2402 | // 256: no such file or dir | 2405 | // 256: no such file or dir |
2403 | // | 2406 | // |
2404 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2407 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2405 | if ( result != 0 ) { | 2408 | if ( result != 0 ) { |
2406 | int len = maxlen; | 2409 | int len = maxlen; |
2407 | while ( len < command.length() ) { | 2410 | while ( len < command.length() ) { |
2408 | command.insert( len , "\n" ); | 2411 | command.insert( len , "\n" ); |
2409 | len += maxlen +2; | 2412 | len += maxlen +2; |
2410 | } | 2413 | } |
2411 | 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) ; | 2414 | 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) ; |
2412 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2415 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2413 | question, | 2416 | question, |
2414 | i18n("Okay!")) ; | 2417 | i18n("Okay!")) ; |
2415 | setCaption ("KO/Pi"); | 2418 | setCaption ("KO/Pi"); |
2416 | return; | 2419 | return; |
2417 | } | 2420 | } |
2418 | 2421 | ||
2419 | 2422 | ||
2420 | setCaption ( i18n( "Copying succeed." ) ); | 2423 | setCaption ( i18n( "Copying succeed." ) ); |
2421 | //mView->setSyncDevice("ssh-scp" ); | 2424 | //mView->setSyncDevice("ssh-scp" ); |
2422 | if ( syncWithFile(localFile , true ) ) { | 2425 | if ( syncWithFile(localFile , true ) ) { |
2423 | // Event* e = mView->getLastSyncEvent(); | 2426 | // Event* e = mView->getLastSyncEvent(); |
2424 | // e->setReadOnly( false ); | 2427 | // e->setReadOnly( false ); |
2425 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2428 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2426 | // e->setReadOnly( true ); | 2429 | // e->setReadOnly( true ); |
2427 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2430 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2428 | command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; | 2431 | command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; |
2429 | setCaption ( i18n( "Writing back file ..." ) ); | 2432 | setCaption ( i18n( "Writing back file ..." ) ); |
2430 | result = system ( command ); | 2433 | result = system ( command ); |
2431 | if ( result != 0 ) { | 2434 | if ( result != 0 ) { |
2432 | int len = maxlen; | 2435 | int len = maxlen; |
2433 | while ( len < command.length() ) { | 2436 | while ( len < command.length() ) { |
2434 | command.insert( len , "\n" ); | 2437 | command.insert( len , "\n" ); |
2435 | len += maxlen +2; | 2438 | len += maxlen +2; |
2436 | } | 2439 | } |
2437 | question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2440 | question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2438 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2441 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2439 | question, | 2442 | question, |
2440 | i18n("Okay!")) ; | 2443 | i18n("Okay!")) ; |
2441 | setCaption ("KO/Pi"); | 2444 | setCaption ("KO/Pi"); |
2442 | return; | 2445 | return; |
2443 | } else { | 2446 | } else { |
2444 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2447 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2445 | } | 2448 | } |
2446 | } | 2449 | } |
2447 | } | 2450 | } |
2448 | return; | 2451 | return; |
2449 | #if 0 | 2452 | #if 0 |
2450 | system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); | 2453 | system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); |
2451 | while ( timer.elapsed() < 5000 ) | 2454 | while ( timer.elapsed() < 5000 ) |
2452 | qApp->processEvents(); | 2455 | qApp->processEvents(); |
2453 | 2456 | ||
2454 | qDebug("MainWindow::merging) "); | 2457 | qDebug("MainWindow::merging) "); |
2455 | mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); | 2458 | mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); |
2456 | while ( mBlockSaveFlag ) | 2459 | while ( mBlockSaveFlag ) |
2457 | qApp->processEvents(); | 2460 | qApp->processEvents(); |
2458 | save(); | 2461 | save(); |
2459 | system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); | 2462 | system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); |
2460 | #endif | 2463 | #endif |
2461 | 2464 | ||
2462 | } | 2465 | } |
2463 | 2466 | ||
2464 | 2467 | ||
2465 | void MainWindow::syncSharp() | 2468 | void MainWindow::syncSharp() |
2466 | { | 2469 | { |
2467 | if ( mCalendarModifiedFlag ) | 2470 | if ( mCalendarModifiedFlag ) |
2468 | save(); | 2471 | save(); |
2469 | mView->syncSharp(); | 2472 | mView->syncSharp(); |
2470 | slotModifiedChanged( true ); | 2473 | slotModifiedChanged( true ); |
2471 | 2474 | ||
2472 | } | 2475 | } |
2473 | void MainWindow::syncPhone() | 2476 | void MainWindow::syncPhone() |
2474 | { | 2477 | { |
2475 | if ( mCalendarModifiedFlag ) | 2478 | if ( mCalendarModifiedFlag ) |
2476 | save(); | 2479 | save(); |
2477 | mView->syncPhone(); | 2480 | mView->syncPhone(); |
2478 | slotModifiedChanged( true ); | 2481 | slotModifiedChanged( true ); |
2479 | 2482 | ||
2480 | } | 2483 | } |
2481 | 2484 | ||
2482 | void MainWindow::printSel( ) | 2485 | void MainWindow::printSel( ) |
2483 | { | 2486 | { |
2484 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2487 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2485 | } | 2488 | } |
2486 | 2489 | ||
2487 | void MainWindow::printCal() | 2490 | void MainWindow::printCal() |
2488 | { | 2491 | { |
2489 | mView->print();//mCp->showDialog(); | 2492 | mView->print();//mCp->showDialog(); |
2490 | } | 2493 | } |
2491 | 2494 | ||
2492 | 2495 | ||
2493 | 2496 | ||
2494 | KServerSocket:: KServerSocket ( Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ){;}; | 2497 | KServerSocket:: KServerSocket ( Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
2498 | { | ||
2499 | |||
2500 | mSocket = 0; | ||
2501 | }; | ||
2495 | 2502 | ||
2496 | void KServerSocket::newConnection ( int socket ) | 2503 | void KServerSocket::newConnection ( int socket ) |
2497 | { | 2504 | { |
2498 | qDebug("KServerSocket:New connection %d ", socket); | 2505 | qDebug("KServerSocket:New connection %d ", socket); |
2499 | QSocket* s = new QSocket( this ); | 2506 | if ( mSocket ) { |
2500 | connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) ); | 2507 | qDebug("KServerSocket::newConnection Socket deleted! "); |
2501 | connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 2508 | delete mSocket; |
2502 | s->setSocket( socket ); | 2509 | mSocket = 0; |
2510 | } | ||
2511 | mSocket = new QSocket( this ); | ||
2512 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | ||
2513 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | ||
2514 | mSocket->setSocket( socket ); | ||
2503 | } | 2515 | } |
2504 | 2516 | ||
2505 | void KServerSocket::discardClient() | 2517 | void KServerSocket::discardClient() |
2506 | { | 2518 | { |
2507 | qDebug(" KServerSocket::discardClient()"); | 2519 | qDebug(" KServerSocket::discardClient()"); |
2508 | QSocket* socket = (QSocket*)sender(); | 2520 | if ( mSocket ) { |
2509 | delete socket; | 2521 | qDebug("delete "); |
2522 | delete mSocket; | ||
2523 | mSocket = 0; | ||
2524 | } | ||
2510 | //emit endConnect(); | 2525 | //emit endConnect(); |
2511 | } | 2526 | } |
2512 | void KServerSocket::readClient() | 2527 | void KServerSocket::readClient() |
2513 | { | 2528 | { |
2529 | if ( mSocket == 0 ) { | ||
2530 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | ||
2531 | return; | ||
2532 | } | ||
2514 | qDebug("KServerSocket readClient()"); | 2533 | qDebug("KServerSocket readClient()"); |
2515 | QSocket* socket = (QSocket*)sender(); | 2534 | if ( mSocket->canReadLine() ) { |
2516 | if ( socket->canReadLine() ) { | 2535 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); |
2517 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() ); | ||
2518 | qDebug("KServerSocket socket->canReadLine()"); | 2536 | qDebug("KServerSocket socket->canReadLine()"); |
2519 | if ( tokens[0] == "GET" ) { | 2537 | if ( tokens[0] == "GET" ) { |
2520 | emit sendFile( socket ); | 2538 | emit sendFile( mSocket ); |
2521 | } | 2539 | } |
2522 | if ( tokens[0] == "PUT" ) { | 2540 | if ( tokens[0] == "PUT" ) { |
2523 | emit getFile( socket ); | 2541 | emit getFile( mSocket ); |
2524 | } | 2542 | } |
2525 | if ( tokens[0] == "STOP" ) { | 2543 | if ( tokens[0] == "STOP" ) { |
2526 | emit endConnect(); | 2544 | emit endConnect(); |
2527 | } | 2545 | } |
2528 | } | 2546 | } |
2529 | } | 2547 | } |
2530 | 2548 | ||
2531 | 2549 | ||
2532 | 2550 | ||
2533 | 2551 | ||
2534 | 2552 | ||
2535 | 2553 | ||
2536 | 2554 | ||
2537 | 2555 | ||
2538 | 2556 | ||
2539 | 2557 | ||
2540 | 2558 | ||
2541 | 2559 | ||
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 7b4fd27..cc656a3 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,159 +1,161 @@ | |||
1 | #ifndef KORGE_MAINWINDOW_H | 1 | #ifndef KORGE_MAINWINDOW_H |
2 | #define KORGE_MAINWINDOW_H | 2 | #define KORGE_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qregexp.h> | 7 | #include <qregexp.h> |
8 | 8 | ||
9 | #include <libkcal/incidence.h> | 9 | #include <libkcal/incidence.h> |
10 | #include "simplealarmclient.h" | 10 | #include "simplealarmclient.h" |
11 | 11 | ||
12 | class QAction; | 12 | class QAction; |
13 | class CalendarView; | 13 | class CalendarView; |
14 | class KSyncProfile; | 14 | class KSyncProfile; |
15 | #ifdef DESKTOP_VERSION | 15 | #ifdef DESKTOP_VERSION |
16 | 16 | ||
17 | #define QPEToolBar QToolBar | 17 | #define QPEToolBar QToolBar |
18 | #define QPEMenuBar QMenuBar | 18 | #define QPEMenuBar QMenuBar |
19 | #endif | 19 | #endif |
20 | class QPEToolBar; | 20 | class QPEToolBar; |
21 | #include <qserversocket.h> | 21 | #include <qserversocket.h> |
22 | #include <qsocket.h> | 22 | #include <qsocket.h> |
23 | #include <qnetworkprotocol.h> | 23 | #include <qnetworkprotocol.h> |
24 | 24 | ||
25 | class KServerSocket : public QServerSocket | 25 | class KServerSocket : public QServerSocket |
26 | { | 26 | { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | 28 | ||
29 | public: | 29 | public: |
30 | KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | 30 | KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
31 | 31 | ||
32 | void newConnection ( int socket ) ; | 32 | void newConnection ( int socket ) ; |
33 | 33 | ||
34 | signals: | 34 | signals: |
35 | void sendFile(QSocket*); | 35 | void sendFile(QSocket*); |
36 | void getFile(QSocket*); | 36 | void getFile(QSocket*); |
37 | void endConnect(); | 37 | void endConnect(); |
38 | private slots: | 38 | private slots: |
39 | void discardClient(); | 39 | void discardClient(); |
40 | void readClient(); | 40 | void readClient(); |
41 | private : | ||
42 | QSocket* mSocket; | ||
41 | }; | 43 | }; |
42 | 44 | ||
43 | 45 | ||
44 | namespace KCal { | 46 | namespace KCal { |
45 | class CalendarLocal; | 47 | class CalendarLocal; |
46 | } | 48 | } |
47 | 49 | ||
48 | using namespace KCal; | 50 | using namespace KCal; |
49 | 51 | ||
50 | class MainWindow : public QMainWindow | 52 | class MainWindow : public QMainWindow |
51 | { | 53 | { |
52 | Q_OBJECT | 54 | Q_OBJECT |
53 | public: | 55 | public: |
54 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 56 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
55 | ~MainWindow(); | 57 | ~MainWindow(); |
56 | public slots: | 58 | public slots: |
57 | virtual void showMaximized (); | 59 | virtual void showMaximized (); |
58 | void configureAgenda( int ); | 60 | void configureAgenda( int ); |
59 | void recieve( const QCString& msg, const QByteArray& data ); | 61 | void recieve( const QCString& msg, const QByteArray& data ); |
60 | static QString defaultFileName(); | 62 | static QString defaultFileName(); |
61 | static QString resourcePath(); | 63 | static QString resourcePath(); |
62 | protected slots: | 64 | protected slots: |
63 | void setCaptionToDates(); | 65 | void setCaptionToDates(); |
64 | int ringSync(); | 66 | int ringSync(); |
65 | void multiSync( bool askforPrefs = false ); | 67 | void multiSync( bool askforPrefs = false ); |
66 | void about(); | 68 | void about(); |
67 | void licence(); | 69 | void licence(); |
68 | void faq(); | 70 | void faq(); |
69 | void usertrans(); | 71 | void usertrans(); |
70 | void features(); | 72 | void features(); |
71 | void synchowto(); | 73 | void synchowto(); |
72 | void whatsNew(); | 74 | void whatsNew(); |
73 | void keyBindings(); | 75 | void keyBindings(); |
74 | void aboutAutoSaving();; | 76 | void aboutAutoSaving();; |
75 | void aboutKnownBugs(); | 77 | void aboutKnownBugs(); |
76 | 78 | ||
77 | void processIncidenceSelection( Incidence * ); | 79 | void processIncidenceSelection( Incidence * ); |
78 | 80 | ||
79 | void importQtopia(); | 81 | void importQtopia(); |
80 | void importBday(); | 82 | void importBday(); |
81 | void importOL(); | 83 | void importOL(); |
82 | void importIcal(); | 84 | void importIcal(); |
83 | void importFile( QString, bool ); | 85 | void importFile( QString, bool ); |
84 | void quickImportIcal(); | 86 | void quickImportIcal(); |
85 | 87 | ||
86 | void slotModifiedChanged( bool ); | 88 | void slotModifiedChanged( bool ); |
87 | 89 | ||
88 | void save(); | 90 | void save(); |
89 | void configureToolBar( int ); | 91 | void configureToolBar( int ); |
90 | void printSel(); | 92 | void printSel(); |
91 | void printCal(); | 93 | void printCal(); |
92 | void saveCalendar(); | 94 | void saveCalendar(); |
93 | void loadCalendar(); | 95 | void loadCalendar(); |
94 | void exportVCalendar(); | 96 | void exportVCalendar(); |
95 | void fillFilterMenu(); | 97 | void fillFilterMenu(); |
96 | void selectFilter( int ); | 98 | void selectFilter( int ); |
97 | 99 | ||
98 | void slotSyncMenu( int ); | 100 | void slotSyncMenu( int ); |
99 | void syncSSH(); | 101 | void syncSSH(); |
100 | void confSync(); | 102 | void confSync(); |
101 | void syncSharp(); | 103 | void syncSharp(); |
102 | void syncPhone(); | 104 | void syncPhone(); |
103 | void syncLocalFile(); | 105 | void syncLocalFile(); |
104 | bool syncWithFile( QString, bool ); | 106 | bool syncWithFile( QString, bool ); |
105 | void quickSyncLocalFile(); | 107 | void quickSyncLocalFile(); |
106 | 108 | ||
107 | 109 | ||
108 | protected: | 110 | protected: |
109 | void displayText( QString, QString); | 111 | void displayText( QString, QString); |
110 | void displayFile( QString, QString); | 112 | void displayFile( QString, QString); |
111 | 113 | ||
112 | void enableIncidenceActions( bool ); | 114 | void enableIncidenceActions( bool ); |
113 | 115 | ||
114 | private slots: | 116 | private slots: |
115 | void fillSyncMenu(); | 117 | void fillSyncMenu(); |
116 | void sendFile(QSocket* s); | 118 | void sendFile(QSocket* s); |
117 | void getFile(QSocket* socket); | 119 | void getFile(QSocket* socket); |
118 | void readFileFromSocket(); | 120 | void readFileFromSocket(); |
119 | void endConnect(); | 121 | void endConnect(); |
120 | private: | 122 | private: |
121 | QSocket* mCommandSocket; | 123 | QSocket* mCommandSocket; |
122 | QSocket* mCommandSocketFinish; | 124 | QSocket* mCommandSocketFinish; |
123 | KServerSocket * mServerSocket; | 125 | KServerSocket * mServerSocket; |
124 | bool mClosed; | 126 | bool mClosed; |
125 | void saveOnClose(); | 127 | void saveOnClose(); |
126 | int mCurrentSyncProfile; | 128 | int mCurrentSyncProfile; |
127 | void enableQuick(); | 129 | void enableQuick(); |
128 | void performQuick(); | 130 | void performQuick(); |
129 | void performQuickQuick(); | 131 | void performQuickQuick(); |
130 | void syncRemote( KSyncProfile* , bool ask = true); | 132 | void syncRemote( KSyncProfile* , bool ask = true); |
131 | bool mFlagKeyPressed; | 133 | bool mFlagKeyPressed; |
132 | bool mBlockAtStartup; | 134 | bool mBlockAtStartup; |
133 | QPEToolBar *iconToolBar; | 135 | QPEToolBar *iconToolBar; |
134 | void initActions(); | 136 | void initActions(); |
135 | void setDefaultPreferences(); | 137 | void setDefaultPreferences(); |
136 | void keyPressEvent ( QKeyEvent * ) ; | 138 | void keyPressEvent ( QKeyEvent * ) ; |
137 | void keyReleaseEvent ( QKeyEvent * ) ; | 139 | void keyReleaseEvent ( QKeyEvent * ) ; |
138 | QPopupMenu *configureToolBarMenu; | 140 | QPopupMenu *configureToolBarMenu; |
139 | QPopupMenu *selectFilterMenu; | 141 | QPopupMenu *selectFilterMenu; |
140 | QPopupMenu *configureAgendaMenu, *syncMenu; | 142 | QPopupMenu *configureAgendaMenu, *syncMenu; |
141 | CalendarLocal *mCalendar; | 143 | CalendarLocal *mCalendar; |
142 | CalendarView *mView; | 144 | CalendarView *mView; |
143 | QString getPassword(); | 145 | QString getPassword(); |
144 | QAction *mNewSubTodoAction; | 146 | QAction *mNewSubTodoAction; |
145 | 147 | ||
146 | QAction *mShowAction; | 148 | QAction *mShowAction; |
147 | QAction *mEditAction; | 149 | QAction *mEditAction; |
148 | QAction *mDeleteAction; | 150 | QAction *mDeleteAction; |
149 | void closeEvent( QCloseEvent* ce ); | 151 | void closeEvent( QCloseEvent* ce ); |
150 | SimpleAlarmClient mAlarmClient; | 152 | SimpleAlarmClient mAlarmClient; |
151 | QTimer mSaveTimer; | 153 | QTimer mSaveTimer; |
152 | bool mBlockSaveFlag; | 154 | bool mBlockSaveFlag; |
153 | bool mCalendarModifiedFlag; | 155 | bool mCalendarModifiedFlag; |
154 | QPixmap loadPixmap( QString ); | 156 | QPixmap loadPixmap( QString ); |
155 | QDialog * mSyncActionDialog; | 157 | QDialog * mSyncActionDialog; |
156 | }; | 158 | }; |
157 | 159 | ||
158 | 160 | ||
159 | #endif | 161 | #endif |