summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-28 15:16:46 (UTC)
committer zautrix <zautrix>2005-03-28 15:16:46 (UTC)
commit435d67be852dc98b460bd3123a2164131db82334 (patch) (unidiff)
tree5d031d970da9214e111079061ccae271752c33c0
parente4e6bda3a6b0a82e3f64db0fa5f7d60cab9f0e48 (diff)
downloadkdepimpi-435d67be852dc98b460bd3123a2164131db82334.zip
kdepimpi-435d67be852dc98b460bd3123a2164131db82334.tar.gz
kdepimpi-435d67be852dc98b460bd3123a2164131db82334.tar.bz2
more fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index ad1c0cd..2da592b 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1470,405 +1470,437 @@ QString MainWindow::defaultFileName()
1470{ 1470{
1471 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1471 return locateLocal( "data", "korganizer/mycalendar.ics" );
1472} 1472}
1473QString MainWindow::syncFileName() 1473QString MainWindow::syncFileName()
1474{ 1474{
1475#ifdef DESKTOP_VERSION 1475#ifdef DESKTOP_VERSION
1476 return locateLocal( "tmp", "synccalendar.ics" ); 1476 return locateLocal( "tmp", "synccalendar.ics" );
1477#else 1477#else
1478 return QString( "/tmp/synccalendar.ics" ); 1478 return QString( "/tmp/synccalendar.ics" );
1479#endif 1479#endif
1480} 1480}
1481void MainWindow::updateWeek(QDate seda) 1481void MainWindow::updateWeek(QDate seda)
1482{ 1482{
1483 int weekNum = 0; 1483 int weekNum = 0;
1484 QDate d = QDate ( seda.year(), 1,1); 1484 QDate d = QDate ( seda.year(), 1,1);
1485 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday 1485 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday
1486 if ( seda.addDays(6).year() != seda.year() ) { 1486 if ( seda.addDays(6).year() != seda.year() ) {
1487 if ( seda.year() != d.year() ) { 1487 if ( seda.year() != d.year() ) {
1488 if ( d.dayOfWeek() > 4 ) 1488 if ( d.dayOfWeek() > 4 )
1489 d = QDate ( seda.year(), 1,1); 1489 d = QDate ( seda.year(), 1,1);
1490 else 1490 else
1491 weekNum = 1; 1491 weekNum = 1;
1492 } else { 1492 } else {
1493 QDate dd( seda.year()+1, 1,1); 1493 QDate dd( seda.year()+1, 1,1);
1494 if ( dd.dayOfWeek() <= 4 ) 1494 if ( dd.dayOfWeek() <= 4 )
1495 weekNum = 1; 1495 weekNum = 1;
1496 } 1496 }
1497 } 1497 }
1498 if ( weekNum == 0 ){ 1498 if ( weekNum == 0 ){
1499 int dow = d.dayOfWeek(); 1499 int dow = d.dayOfWeek();
1500 if ( dow <= 4 ) 1500 if ( dow <= 4 )
1501 d = d.addDays( 1-dow ); 1501 d = d.addDays( 1-dow );
1502 else // 5,6,7 1502 else // 5,6,7
1503 d = d.addDays( 8-dow ); 1503 d = d.addDays( 8-dow );
1504 // we have the first week of the year.we are on monday 1504 // we have the first week of the year.we are on monday
1505 weekNum = d.daysTo( seda ) / 7 +1; 1505 weekNum = d.daysTo( seda ) / 7 +1;
1506 } 1506 }
1507 1507
1508 mWeekPixmap.fill( mWeekBgColor ); 1508 mWeekPixmap.fill( mWeekBgColor );
1509 QPainter p ( &mWeekPixmap ); 1509 QPainter p ( &mWeekPixmap );
1510 p.setFont( mWeekFont ); 1510 p.setFont( mWeekFont );
1511 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1511 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1512 p.end(); 1512 p.end();
1513 QIconSet icon3 ( mWeekPixmap ); 1513 QIconSet icon3 ( mWeekPixmap );
1514 mWeekAction->setIconSet ( icon3 ); 1514 mWeekAction->setIconSet ( icon3 );
1515 1515
1516} 1516}
1517void MainWindow::updateWeekNum(const DateList &selectedDates) 1517void MainWindow::updateWeekNum(const DateList &selectedDates)
1518{ 1518{
1519 updateWeek( selectedDates.first() ); 1519 updateWeek( selectedDates.first() );
1520} 1520}
1521void MainWindow::processIncidenceSelection( Incidence *incidence ) 1521void MainWindow::processIncidenceSelection( Incidence *incidence )
1522{ 1522{
1523 1523
1524 if ( !incidence ) { 1524 if ( !incidence ) {
1525 enableIncidenceActions( false ); 1525 enableIncidenceActions( false );
1526 1526
1527 mNewSubTodoAction->setEnabled( false ); 1527 mNewSubTodoAction->setEnabled( false );
1528 setCaptionToDates(); 1528 setCaptionToDates();
1529 return; 1529 return;
1530 1530
1531 } 1531 }
1532 1532
1533 //KGlobal::locale()->formatDateTime(nextA, true); 1533 //KGlobal::locale()->formatDateTime(nextA, true);
1534 QString startString = ""; 1534 QString startString = "";
1535 if ( incidence->type() != "Todo" ) { 1535 if ( incidence->type() != "Todo" ) {
1536 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1536 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1537 if ( incidence->doesFloat() ) { 1537 if ( incidence->doesFloat() ) {
1538 startString += ": "+incidence->dtStartDateStr( true ); 1538 startString += ": "+incidence->dtStartDateStr( true );
1539 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1539 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1540 1540
1541 } else { 1541 } else {
1542 startString = ": "+incidence->dtStartStr(true); 1542 startString = ": "+incidence->dtStartStr(true);
1543 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1543 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1544 1544
1545 } 1545 }
1546 1546
1547 } else { 1547 } else {
1548 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1548 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1549 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1549 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1550 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1550 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1551 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { 1551 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) {
1552 bool ok; 1552 bool ok;
1553 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1553 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1554 if ( ok ) { 1554 if ( ok ) {
1555 int years = noc.date().year() - incidence->dtStart().date().year(); 1555 int years = noc.date().year() - incidence->dtStart().date().year();
1556 startString += i18n(" (%1 y.)"). arg( years ); 1556 startString += i18n(" (%1 y.)"). arg( years );
1557 } 1557 }
1558 } 1558 }
1559 else 1559 else
1560 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1560 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1561 } 1561 }
1562 1562
1563 } 1563 }
1564 else 1564 else
1565 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1565 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1566 if ( !incidence->location().isEmpty() ) 1566 if ( !incidence->location().isEmpty() )
1567 startString += " (" +incidence->location()+")"; 1567 startString += " (" +incidence->location()+")";
1568 setCaption( incidence->summary()+startString); 1568 setCaption( incidence->summary()+startString);
1569 1569
1570 enableIncidenceActions( true ); 1570 enableIncidenceActions( true );
1571 1571
1572 if ( incidence->type() == "Event" ) { 1572 if ( incidence->type() == "Event" ) {
1573 mShowAction->setText( i18n("Show Event...") ); 1573 mShowAction->setText( i18n("Show Event...") );
1574 mEditAction->setText( i18n("Edit Event...") ); 1574 mEditAction->setText( i18n("Edit Event...") );
1575 mDeleteAction->setText( i18n("Delete Event...") ); 1575 mDeleteAction->setText( i18n("Delete Event...") );
1576 1576
1577 mNewSubTodoAction->setEnabled( false ); 1577 mNewSubTodoAction->setEnabled( false );
1578 } else if ( incidence->type() == "Todo" ) { 1578 } else if ( incidence->type() == "Todo" ) {
1579 mShowAction->setText( i18n("Show Todo...") ); 1579 mShowAction->setText( i18n("Show Todo...") );
1580 mEditAction->setText( i18n("Edit Todo...") ); 1580 mEditAction->setText( i18n("Edit Todo...") );
1581 mDeleteAction->setText( i18n("Delete Todo...") ); 1581 mDeleteAction->setText( i18n("Delete Todo...") );
1582 1582
1583 mNewSubTodoAction->setEnabled( true ); 1583 mNewSubTodoAction->setEnabled( true );
1584 } else { 1584 } else {
1585 mShowAction->setText( i18n("Show...") ); 1585 mShowAction->setText( i18n("Show...") );
1586 mShowAction->setText( i18n("Edit...") ); 1586 mShowAction->setText( i18n("Edit...") );
1587 mShowAction->setText( i18n("Delete...") ); 1587 mShowAction->setText( i18n("Delete...") );
1588 1588
1589 mNewSubTodoAction->setEnabled( false ); 1589 mNewSubTodoAction->setEnabled( false );
1590 } 1590 }
1591} 1591}
1592 1592
1593void MainWindow::enableIncidenceActions( bool enabled ) 1593void MainWindow::enableIncidenceActions( bool enabled )
1594{ 1594{
1595 mShowAction->setEnabled( enabled ); 1595 mShowAction->setEnabled( enabled );
1596 mEditAction->setEnabled( enabled ); 1596 mEditAction->setEnabled( enabled );
1597 mDeleteAction->setEnabled( enabled ); 1597 mDeleteAction->setEnabled( enabled );
1598 1598
1599 mCloneAction->setEnabled( enabled ); 1599 mCloneAction->setEnabled( enabled );
1600 mMoveAction->setEnabled( enabled ); 1600 mMoveAction->setEnabled( enabled );
1601 mBeamAction->setEnabled( enabled ); 1601 mBeamAction->setEnabled( enabled );
1602 mCancelAction->setEnabled( enabled ); 1602 mCancelAction->setEnabled( enabled );
1603} 1603}
1604 1604
1605void MainWindow::importOL() 1605void MainWindow::importOL()
1606{ 1606{
1607#ifdef _OL_IMPORT_ 1607#ifdef _OL_IMPORT_
1608 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1608 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1609 id->exec(); 1609 id->exec();
1610 delete id; 1610 delete id;
1611 mView->updateView(); 1611 mView->updateView();
1612#endif 1612#endif
1613} 1613}
1614void MainWindow::importBday() 1614void MainWindow::importBday()
1615{ 1615{
1616 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1616 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1617 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1617 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1618 i18n("Import!"), i18n("Cancel"), 0, 1618 i18n("Import!"), i18n("Cancel"), 0,
1619 0, 1 ); 1619 0, 1 );
1620 if ( result == 0 ) { 1620 if ( result == 0 ) {
1621 mView->importBday(); 1621 mView->importBday();
1622 1622
1623 } 1623 }
1624 1624
1625 1625
1626} 1626}
1627void MainWindow::importQtopia() 1627void MainWindow::importQtopia()
1628{ 1628{
1629 //#ifndef DESKTOP_VERSION 1629 //#ifndef DESKTOP_VERSION
1630 QString mess = 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"); 1630 QString mess = 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");
1631#ifdef DESKTOP_VERSION 1631#ifdef DESKTOP_VERSION
1632 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1632 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1633#endif 1633#endif
1634 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1634 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1635 i18n("Import!"), i18n("Cancel"), 0, 1635 i18n("Import!"), i18n("Cancel"), 0,
1636 0, 1 ); 1636 0, 1 );
1637 if ( result == 0 ) { 1637 if ( result == 0 ) {
1638#ifndef DESKTOP_VERSION 1638#ifndef DESKTOP_VERSION
1639 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1639 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1640 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1640 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1641 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1641 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1642#else 1642#else
1643 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1643 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1644 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1644 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1645 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1645 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1646#endif 1646#endif
1647 mView->importQtopia( categories, datebook, todolist ); 1647 mView->importQtopia( categories, datebook, todolist );
1648 } 1648 }
1649#if 0 1649#if 0
1650 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1650 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1651 i18n("Not supported \non desktop!\n"), 1651 i18n("Not supported \non desktop!\n"),
1652 i18n("Ok"), i18n("Cancel"), 0, 1652 i18n("Ok"), i18n("Cancel"), 0,
1653 0, 1 ); 1653 0, 1 );
1654 1654
1655#endif 1655#endif
1656} 1656}
1657 1657
1658void MainWindow::saveOnClose() 1658void MainWindow::saveOnClose()
1659{ 1659{
1660 KOPrefs *p = KOPrefs::instance(); 1660 KOPrefs *p = KOPrefs::instance();
1661 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1661 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1662 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1663 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1664 if ( filterToolBar ) {
1665 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1666 }
1667#ifdef DESKTOP_VERSION
1668
1669 QPoint myP;
1670 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1671 if ( p->mToolBarHor )
1672 p->mToolBarUp = myP.y() > height()/2;
1673 else
1674 p->mToolBarUp = myP.x() > width()/2;
1675 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1676 if ( p->mToolBarHorV )
1677 p->mToolBarUpV = myP.y() > height()/2;
1678 else
1679 p->mToolBarUpV = myP.x() > width()/2 ;
1680 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1681 if ( p->mToolBarHorN )
1682 p->mToolBarUpN = myP.y() > height()/2;
1683 else
1684 p->mToolBarUpN = myP.x() > width()/2 ;
1685 if ( filterToolBar ) {
1686 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1687 if ( p->mToolBarHorF )
1688 p->mToolBarUpF = myP.y() > height()/2;
1689 else
1690 p->mToolBarUpF = myP.x() > width()/2 ;
1691 }
1692#else
1662 if ( p->mToolBarHor ) 1693 if ( p->mToolBarHor )
1663 p->mToolBarUp = iconToolBar->y() > height()/2; 1694 p->mToolBarUp = iconToolBar->y() > height()/2;
1664 else 1695 else
1665 p->mToolBarUp = iconToolBar->x() > width()/2; 1696 p->mToolBarUp = iconToolBar->x() > width()/2;
1666 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1667 if ( p->mToolBarHorV ) 1697 if ( p->mToolBarHorV )
1668 p->mToolBarUpV = viewToolBar->y() > height()/2; 1698 p->mToolBarUpV = viewToolBar->y() > height()/2;
1669 else 1699 else
1670 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1700 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1671 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1701
1672 if ( p->mToolBarHorN ) 1702 if ( p->mToolBarHorN )
1673 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1703 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1674 else 1704 else
1675 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1705 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1676 if ( filterToolBar ) { 1706 if ( filterToolBar ) {
1677 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1678 if ( p->mToolBarHorF ) 1707 if ( p->mToolBarHorF )
1679 p->mToolBarUpF = filterToolBar->y() > height()/2; 1708 p->mToolBarUpF = filterToolBar->y() > height()/2;
1680 else 1709 else
1681 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1710 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1682 } 1711 }
1712#endif
1713
1714
1683 mView->writeSettings(); 1715 mView->writeSettings();
1684 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1716 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1685 save(); 1717 save();
1686} 1718}
1687void MainWindow::slotModifiedChanged( bool changed ) 1719void MainWindow::slotModifiedChanged( bool changed )
1688{ 1720{
1689 if ( mBlockAtStartup ) 1721 if ( mBlockAtStartup )
1690 return; 1722 return;
1691 1723
1692 int msec; 1724 int msec;
1693 // we store the changes after 1 minute, 1725 // we store the changes after 1 minute,
1694 // and for safety reasons after 10 minutes again 1726 // and for safety reasons after 10 minutes again
1695 if ( !mSyncManager->blockSave() ) 1727 if ( !mSyncManager->blockSave() )
1696 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1728 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1697 else 1729 else
1698 msec = 1000 * 600; 1730 msec = 1000 * 600;
1699 mSaveTimer.start( msec, true ); // 1 minute 1731 mSaveTimer.start( msec, true ); // 1 minute
1700 qDebug("KO: Saving File in %d secs!", msec/1000); 1732 qDebug("KO: Saving File in %d secs!", msec/1000);
1701 mCalendarModifiedFlag = true; 1733 mCalendarModifiedFlag = true;
1702} 1734}
1703void MainWindow::saveStopTimer() 1735void MainWindow::saveStopTimer()
1704{ 1736{
1705 mSaveTimer.stop(); 1737 mSaveTimer.stop();
1706 if (mSaveTimer.isActive() ) 1738 if (mSaveTimer.isActive() )
1707 qDebug("ti active "); 1739 qDebug("ti active ");
1708 else 1740 else
1709 qDebug("KO: Save timer stopped"); 1741 qDebug("KO: Save timer stopped");
1710} 1742}
1711void MainWindow::save() 1743void MainWindow::save()
1712{ 1744{
1713 if ( !mCalendarModifiedFlag ) { 1745 if ( !mCalendarModifiedFlag ) {
1714 qDebug("KO: Calendar not modified. Nothing saved."); 1746 qDebug("KO: Calendar not modified. Nothing saved.");
1715 return; 1747 return;
1716 } 1748 }
1717 if ( mSyncManager->blockSave() ) 1749 if ( mSyncManager->blockSave() )
1718 return; 1750 return;
1719 mSyncManager->setBlockSave(true); 1751 mSyncManager->setBlockSave(true);
1720 if ( mView->checkFileVersion( defaultFileName()) ) { 1752 if ( mView->checkFileVersion( defaultFileName()) ) {
1721 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1753 QTime neededSaveTime = QDateTime::currentDateTime().time();
1722 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1754 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1723 qDebug("KO: Start saving data to file!"); 1755 qDebug("KO: Start saving data to file!");
1724 mView->saveCalendar( defaultFileName() ); 1756 mView->saveCalendar( defaultFileName() );
1725 mCalendarModifiedFlag = false; 1757 mCalendarModifiedFlag = false;
1726 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1758 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1727 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1759 qDebug("KO: Needed %d ms for saving.",msNeeded );
1728 QString savemes; 1760 QString savemes;
1729 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1761 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1730 setCaption(savemes); 1762 setCaption(savemes);
1731 } else 1763 } else
1732 setCaption(i18n("Saving cancelled!")); 1764 setCaption(i18n("Saving cancelled!"));
1733 mSyncManager->setBlockSave( false ); 1765 mSyncManager->setBlockSave( false );
1734} 1766}
1735 1767
1736void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1768void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1737{ 1769{
1738 if ( !e->isAutoRepeat() ) { 1770 if ( !e->isAutoRepeat() ) {
1739 mFlagKeyPressed = false; 1771 mFlagKeyPressed = false;
1740 } 1772 }
1741} 1773}
1742void MainWindow::keyPressEvent ( QKeyEvent * e ) 1774void MainWindow::keyPressEvent ( QKeyEvent * e )
1743{ 1775{
1744 qApp->processEvents(); 1776 qApp->processEvents();
1745 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1777 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1746 e->ignore(); 1778 e->ignore();
1747 // qDebug(" ignore %d",e->isAutoRepeat() ); 1779 // qDebug(" ignore %d",e->isAutoRepeat() );
1748 return; 1780 return;
1749 } 1781 }
1750 if (! e->isAutoRepeat() ) 1782 if (! e->isAutoRepeat() )
1751 mFlagKeyPressed = true; 1783 mFlagKeyPressed = true;
1752 KOPrefs *p = KOPrefs::instance(); 1784 KOPrefs *p = KOPrefs::instance();
1753 bool showSelectedDates = false; 1785 bool showSelectedDates = false;
1754 int size; 1786 int size;
1755 int pro = 0; 1787 int pro = 0;
1756 //qDebug("MainWindow::keyPressEvent "); 1788 //qDebug("MainWindow::keyPressEvent ");
1757 switch ( e->key() ) { 1789 switch ( e->key() ) {
1758 case Qt::Key_Right: 1790 case Qt::Key_Right:
1759 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1791 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1760 mView->goNextMonth(); 1792 mView->goNextMonth();
1761 else 1793 else
1762 mView->goNext(); 1794 mView->goNext();
1763 showSelectedDates = true; 1795 showSelectedDates = true;
1764 break; 1796 break;
1765 case Qt::Key_Left: 1797 case Qt::Key_Left:
1766 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1798 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1767 mView->goPreviousMonth(); 1799 mView->goPreviousMonth();
1768 else 1800 else
1769 mView->goPrevious(); 1801 mView->goPrevious();
1770 showSelectedDates = true; 1802 showSelectedDates = true;
1771 break; 1803 break;
1772 case Qt::Key_Down: 1804 case Qt::Key_Down:
1773 mView->viewManager()->agendaView()->scrollOneHourDown(); 1805 mView->viewManager()->agendaView()->scrollOneHourDown();
1774 break; 1806 break;
1775 case Qt::Key_Up: 1807 case Qt::Key_Up:
1776 mView->viewManager()->agendaView()->scrollOneHourUp(); 1808 mView->viewManager()->agendaView()->scrollOneHourUp();
1777 break; 1809 break;
1778 case Qt::Key_K: 1810 case Qt::Key_K:
1779 mView->viewManager()->showMonthViewWeek(); 1811 mView->viewManager()->showMonthViewWeek();
1780 break; 1812 break;
1781 case Qt::Key_I: 1813 case Qt::Key_I:
1782 mView->showIncidence(); 1814 mView->showIncidence();
1783 break; 1815 break;
1784 case Qt::Key_Delete: 1816 case Qt::Key_Delete:
1785 case Qt::Key_Backspace: 1817 case Qt::Key_Backspace:
1786 mView->deleteIncidence(); 1818 mView->deleteIncidence();
1787 break; 1819 break;
1788 case Qt::Key_D: 1820 case Qt::Key_D:
1789 mView->viewManager()->showDayView(); 1821 mView->viewManager()->showDayView();
1790 showSelectedDates = true; 1822 showSelectedDates = true;
1791 break; 1823 break;
1792 case Qt::Key_O: 1824 case Qt::Key_O:
1793 mView->toggleFilerEnabled( ); 1825 mView->toggleFilerEnabled( );
1794 break; 1826 break;
1795 case Qt::Key_0: 1827 case Qt::Key_0:
1796 case Qt::Key_1: 1828 case Qt::Key_1:
1797 case Qt::Key_2: 1829 case Qt::Key_2:
1798 case Qt::Key_3: 1830 case Qt::Key_3:
1799 case Qt::Key_4: 1831 case Qt::Key_4:
1800 case Qt::Key_5: 1832 case Qt::Key_5:
1801 case Qt::Key_6: 1833 case Qt::Key_6:
1802 case Qt::Key_7: 1834 case Qt::Key_7:
1803 case Qt::Key_8: 1835 case Qt::Key_8:
1804 case Qt::Key_9: 1836 case Qt::Key_9:
1805 pro = e->key()-48; 1837 pro = e->key()-48;
1806 if ( pro == 0 ) 1838 if ( pro == 0 )
1807 pro = 10; 1839 pro = 10;
1808 if ( e->state() == Qt::ControlButton) 1840 if ( e->state() == Qt::ControlButton)
1809 pro += 10; 1841 pro += 10;
1810 break; 1842 break;
1811 case Qt::Key_M: 1843 case Qt::Key_M:
1812 mView->viewManager()->showMonthView(); 1844 mView->viewManager()->showMonthView();
1813 showSelectedDates = true; 1845 showSelectedDates = true;
1814 break; 1846 break;
1815 case Qt::Key_Insert: 1847 case Qt::Key_Insert:
1816 mView->newEvent(); 1848 mView->newEvent();
1817 break; 1849 break;
1818 case Qt::Key_S : 1850 case Qt::Key_S :
1819 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1851 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1820 mView->newSubTodo(); 1852 mView->newSubTodo();
1821 else 1853 else
1822 mView->dialogManager()->showSearchDialog(); 1854 mView->dialogManager()->showSearchDialog();
1823 break; 1855 break;
1824 case Qt::Key_Y : 1856 case Qt::Key_Y :
1825 case Qt::Key_Z : 1857 case Qt::Key_Z :
1826 mView->viewManager()->showWorkWeekView(); 1858 mView->viewManager()->showWorkWeekView();
1827 showSelectedDates = true; 1859 showSelectedDates = true;
1828 break; 1860 break;
1829 case Qt::Key_U : 1861 case Qt::Key_U :
1830 mView->viewManager()->showWeekView(); 1862 mView->viewManager()->showWeekView();
1831 showSelectedDates = true; 1863 showSelectedDates = true;
1832 break; 1864 break;
1833 case Qt::Key_H : 1865 case Qt::Key_H :
1834 keyBindings(); 1866 keyBindings();
1835 break; 1867 break;
1836 case Qt::Key_W: 1868 case Qt::Key_W:
1837 mView->viewManager()->showWhatsNextView(); 1869 mView->viewManager()->showWhatsNextView();
1838 break; 1870 break;
1839 case Qt::Key_L: 1871 case Qt::Key_L:
1840 mView->viewManager()->showListView(); 1872 mView->viewManager()->showListView();
1841 break; 1873 break;
1842 case Qt::Key_N: 1874 case Qt::Key_N:
1843 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1875 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1844 mView->viewManager()->showNextView(); 1876 mView->viewManager()->showNextView();
1845 else { 1877 else {
1846 mView->viewManager()->showNextXView(); 1878 mView->viewManager()->showNextXView();
1847 showSelectedDates = true; 1879 showSelectedDates = true;
1848 } 1880 }
1849 break; 1881 break;
1850 case Qt::Key_V: 1882 case Qt::Key_V:
1851 mView->viewManager()->showTodoView(); 1883 mView->viewManager()->showTodoView();
1852 break; 1884 break;
1853 case Qt::Key_C: 1885 case Qt::Key_C:
1854 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1886 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1855 break; 1887 break;
1856 case Qt::Key_P: 1888 case Qt::Key_P:
1857 mView->showDatePicker( ); 1889 mView->showDatePicker( );
1858 break; 1890 break;
1859 case Qt::Key_F: 1891 case Qt::Key_F:
1860 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1892 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1861 mView->editFilters(); 1893 mView->editFilters();
1862 else 1894 else
1863 mView->toggleFilter(); 1895 mView->toggleFilter();
1864 break; 1896 break;
1865 case Qt::Key_X: 1897 case Qt::Key_X:
1866 mView->toggleDateNavigatorWidget(); 1898 mView->toggleDateNavigatorWidget();
1867 break; 1899 break;
1868 case Qt::Key_Space: 1900 case Qt::Key_Space:
1869 mView->toggleExpand(); 1901 mView->toggleExpand();
1870 break; 1902 break;
1871 case Qt::Key_A: 1903 case Qt::Key_A:
1872 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 1904 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
1873 mView->showNextAlarms(); 1905 mView->showNextAlarms();
1874 else 1906 else