-rw-r--r-- | korganizer/calendarview.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 7eca69d..7444bad 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1489,768 +1489,776 @@ bool CalendarView::checkFileVersion(QString fn) | |||
1489 | if ( dt <= loadedFileVersion ) | 1489 | if ( dt <= loadedFileVersion ) |
1490 | return true; | 1490 | return true; |
1491 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , | 1491 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , |
1492 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1492 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1493 | i18n("Sync+save")); | 1493 | i18n("Sync+save")); |
1494 | 1494 | ||
1495 | if ( km == KMessageBox::Cancel ) | 1495 | if ( km == KMessageBox::Cancel ) |
1496 | return false; | 1496 | return false; |
1497 | if ( km == KMessageBox::Yes ) | 1497 | if ( km == KMessageBox::Yes ) |
1498 | return true; | 1498 | return true; |
1499 | 1499 | ||
1500 | setSyncDevice("deleteaftersync" ); | 1500 | setSyncDevice("deleteaftersync" ); |
1501 | KOPrefs::instance()->mAskForPreferences = true; | 1501 | KOPrefs::instance()->mAskForPreferences = true; |
1502 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1502 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1503 | KOPrefs::instance()->mWriteBackFile = false; | 1503 | KOPrefs::instance()->mWriteBackFile = false; |
1504 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1504 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1505 | KOPrefs::instance()->mShowSyncSummary = false; | 1505 | KOPrefs::instance()->mShowSyncSummary = false; |
1506 | syncCalendar( fn, 3 ); | 1506 | syncCalendar( fn, 3 ); |
1507 | Event * e = getLastSyncEvent(); | 1507 | Event * e = getLastSyncEvent(); |
1508 | mCalendar->deleteEvent ( e ); | 1508 | mCalendar->deleteEvent ( e ); |
1509 | updateView(); | 1509 | updateView(); |
1510 | return true; | 1510 | return true; |
1511 | } | 1511 | } |
1512 | 1512 | ||
1513 | bool CalendarView::saveCalendar( QString filename ) | 1513 | bool CalendarView::saveCalendar( QString filename ) |
1514 | { | 1514 | { |
1515 | 1515 | ||
1516 | // Store back all unsaved data into calendar object | 1516 | // Store back all unsaved data into calendar object |
1517 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1517 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1518 | if ( mViewManager->currentView() ) | 1518 | if ( mViewManager->currentView() ) |
1519 | mViewManager->currentView()->flushView(); | 1519 | mViewManager->currentView()->flushView(); |
1520 | 1520 | ||
1521 | //mStorage->setFileName( filename ); | 1521 | //mStorage->setFileName( filename ); |
1522 | 1522 | ||
1523 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1523 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1524 | mStorage->setFileName( filename ); | 1524 | mStorage->setFileName( filename ); |
1525 | bool success; | 1525 | bool success; |
1526 | success = mStorage->save(); | 1526 | success = mStorage->save(); |
1527 | if ( !success ) { | 1527 | if ( !success ) { |
1528 | return false; | 1528 | return false; |
1529 | } | 1529 | } |
1530 | 1530 | ||
1531 | return true; | 1531 | return true; |
1532 | } | 1532 | } |
1533 | 1533 | ||
1534 | void CalendarView::closeCalendar() | 1534 | void CalendarView::closeCalendar() |
1535 | { | 1535 | { |
1536 | 1536 | ||
1537 | // child windows no longer valid | 1537 | // child windows no longer valid |
1538 | emit closingDown(); | 1538 | emit closingDown(); |
1539 | 1539 | ||
1540 | mCalendar->close(); | 1540 | mCalendar->close(); |
1541 | setModified(false); | 1541 | setModified(false); |
1542 | updateView(); | 1542 | updateView(); |
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | void CalendarView::archiveCalendar() | 1545 | void CalendarView::archiveCalendar() |
1546 | { | 1546 | { |
1547 | mDialogManager->showArchiveDialog(); | 1547 | mDialogManager->showArchiveDialog(); |
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | 1550 | ||
1551 | void CalendarView::readSettings() | 1551 | void CalendarView::readSettings() |
1552 | { | 1552 | { |
1553 | 1553 | ||
1554 | 1554 | ||
1555 | // mViewManager->showAgendaView(); | 1555 | // mViewManager->showAgendaView(); |
1556 | QString str; | 1556 | QString str; |
1557 | //qDebug("CalendarView::readSettings() "); | 1557 | //qDebug("CalendarView::readSettings() "); |
1558 | // read settings from the KConfig, supplying reasonable | 1558 | // read settings from the KConfig, supplying reasonable |
1559 | // defaults where none are to be found | 1559 | // defaults where none are to be found |
1560 | KConfig *config = KOGlobals::config(); | 1560 | KConfig *config = KOGlobals::config(); |
1561 | #ifndef KORG_NOSPLITTER | 1561 | #ifndef KORG_NOSPLITTER |
1562 | config->setGroup("KOrganizer Geometry"); | 1562 | config->setGroup("KOrganizer Geometry"); |
1563 | 1563 | ||
1564 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1564 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1565 | if (sizes.count() != 2) { | 1565 | if (sizes.count() != 2) { |
1566 | sizes << mDateNavigator->minimumSizeHint().width(); | 1566 | sizes << mDateNavigator->minimumSizeHint().width(); |
1567 | sizes << 300; | 1567 | sizes << 300; |
1568 | } | 1568 | } |
1569 | mPanner->setSizes(sizes); | 1569 | mPanner->setSizes(sizes); |
1570 | 1570 | ||
1571 | sizes = config->readIntListEntry("Separator2"); | 1571 | sizes = config->readIntListEntry("Separator2"); |
1572 | if ( ( mResourceView && sizes.count() == 4 ) || | 1572 | if ( ( mResourceView && sizes.count() == 4 ) || |
1573 | ( !mResourceView && sizes.count() == 3 ) ) { | 1573 | ( !mResourceView && sizes.count() == 3 ) ) { |
1574 | mLeftSplitter->setSizes(sizes); | 1574 | mLeftSplitter->setSizes(sizes); |
1575 | } | 1575 | } |
1576 | #endif | 1576 | #endif |
1577 | globalFlagBlockAgenda = 1; | 1577 | globalFlagBlockAgenda = 1; |
1578 | mViewManager->showAgendaView(); | 1578 | mViewManager->showAgendaView(); |
1579 | //mViewManager->readSettings( config ); | 1579 | //mViewManager->readSettings( config ); |
1580 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1580 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1581 | readFilterSettings(config); | 1581 | readFilterSettings(config); |
1582 | config->setGroup( "Views" ); | 1582 | config->setGroup( "Views" ); |
1583 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1583 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1584 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1584 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1585 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1585 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1586 | else mNavigator->selectDates( dateCount ); | 1586 | else mNavigator->selectDates( dateCount ); |
1587 | // mViewManager->readSettings( config ); | 1587 | // mViewManager->readSettings( config ); |
1588 | updateConfig(); | 1588 | updateConfig(); |
1589 | globalFlagBlockAgenda = 2; | 1589 | globalFlagBlockAgenda = 2; |
1590 | mViewManager->readSettings( config ); | 1590 | mViewManager->readSettings( config ); |
1591 | #ifdef DESKTOP_VERSION | 1591 | #ifdef DESKTOP_VERSION |
1592 | config->setGroup("WidgetLayout"); | 1592 | config->setGroup("WidgetLayout"); |
1593 | QStringList list; | 1593 | QStringList list; |
1594 | list = config->readListEntry("MainLayout"); | 1594 | list = config->readListEntry("MainLayout"); |
1595 | int x,y,w,h; | 1595 | int x,y,w,h; |
1596 | if ( ! list.isEmpty() ) { | 1596 | if ( ! list.isEmpty() ) { |
1597 | x = list[0].toInt(); | 1597 | x = list[0].toInt(); |
1598 | y = list[1].toInt(); | 1598 | y = list[1].toInt(); |
1599 | w = list[2].toInt(); | 1599 | w = list[2].toInt(); |
1600 | h = list[3].toInt(); | 1600 | h = list[3].toInt(); |
1601 | topLevelWidget()->setGeometry(x,y,w,h); | 1601 | topLevelWidget()->setGeometry(x,y,w,h); |
1602 | 1602 | ||
1603 | } else { | 1603 | } else { |
1604 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1604 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1605 | } | 1605 | } |
1606 | list = config->readListEntry("EditEventLayout"); | 1606 | list = config->readListEntry("EditEventLayout"); |
1607 | if ( ! list.isEmpty() ) { | 1607 | if ( ! list.isEmpty() ) { |
1608 | x = list[0].toInt(); | 1608 | x = list[0].toInt(); |
1609 | y = list[1].toInt(); | 1609 | y = list[1].toInt(); |
1610 | w = list[2].toInt(); | 1610 | w = list[2].toInt(); |
1611 | h = list[3].toInt(); | 1611 | h = list[3].toInt(); |
1612 | mEventEditor->setGeometry(x,y,w,h); | 1612 | mEventEditor->setGeometry(x,y,w,h); |
1613 | 1613 | ||
1614 | } | 1614 | } |
1615 | list = config->readListEntry("EditTodoLayout"); | 1615 | list = config->readListEntry("EditTodoLayout"); |
1616 | if ( ! list.isEmpty() ) { | 1616 | if ( ! list.isEmpty() ) { |
1617 | x = list[0].toInt(); | 1617 | x = list[0].toInt(); |
1618 | y = list[1].toInt(); | 1618 | y = list[1].toInt(); |
1619 | w = list[2].toInt(); | 1619 | w = list[2].toInt(); |
1620 | h = list[3].toInt(); | 1620 | h = list[3].toInt(); |
1621 | mTodoEditor->setGeometry(x,y,w,h); | 1621 | mTodoEditor->setGeometry(x,y,w,h); |
1622 | 1622 | ||
1623 | } | 1623 | } |
1624 | list = config->readListEntry("ViewerLayout"); | 1624 | list = config->readListEntry("ViewerLayout"); |
1625 | if ( ! list.isEmpty() ) { | 1625 | if ( ! list.isEmpty() ) { |
1626 | x = list[0].toInt(); | 1626 | x = list[0].toInt(); |
1627 | y = list[1].toInt(); | 1627 | y = list[1].toInt(); |
1628 | w = list[2].toInt(); | 1628 | w = list[2].toInt(); |
1629 | h = list[3].toInt(); | 1629 | h = list[3].toInt(); |
1630 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1630 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1631 | } | 1631 | } |
1632 | #endif | 1632 | #endif |
1633 | 1633 | ||
1634 | } | 1634 | } |
1635 | 1635 | ||
1636 | 1636 | ||
1637 | void CalendarView::writeSettings() | 1637 | void CalendarView::writeSettings() |
1638 | { | 1638 | { |
1639 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1639 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1640 | 1640 | ||
1641 | KConfig *config = KOGlobals::config(); | 1641 | KConfig *config = KOGlobals::config(); |
1642 | 1642 | ||
1643 | #ifndef KORG_NOSPLITTER | 1643 | #ifndef KORG_NOSPLITTER |
1644 | config->setGroup("KOrganizer Geometry"); | 1644 | config->setGroup("KOrganizer Geometry"); |
1645 | 1645 | ||
1646 | QValueList<int> list = mPanner->sizes(); | 1646 | QValueList<int> list = mPanner->sizes(); |
1647 | config->writeEntry("Separator1",list); | 1647 | config->writeEntry("Separator1",list); |
1648 | 1648 | ||
1649 | list = mLeftSplitter->sizes(); | 1649 | list = mLeftSplitter->sizes(); |
1650 | config->writeEntry("Separator2",list); | 1650 | config->writeEntry("Separator2",list); |
1651 | #endif | 1651 | #endif |
1652 | 1652 | ||
1653 | mViewManager->writeSettings( config ); | 1653 | mViewManager->writeSettings( config ); |
1654 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1654 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1655 | mDialogManager->writeSettings( config ); | 1655 | mDialogManager->writeSettings( config ); |
1656 | //KOPrefs::instance()->usrWriteConfig(); | 1656 | //KOPrefs::instance()->usrWriteConfig(); |
1657 | KOPrefs::instance()->writeConfig(); | 1657 | KOPrefs::instance()->writeConfig(); |
1658 | 1658 | ||
1659 | writeFilterSettings(config); | 1659 | writeFilterSettings(config); |
1660 | 1660 | ||
1661 | config->setGroup( "Views" ); | 1661 | config->setGroup( "Views" ); |
1662 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1662 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1663 | 1663 | ||
1664 | #ifdef DESKTOP_VERSION | 1664 | #ifdef DESKTOP_VERSION |
1665 | config->setGroup("WidgetLayout"); | 1665 | config->setGroup("WidgetLayout"); |
1666 | QStringList list ;//= config->readListEntry("MainLayout"); | 1666 | QStringList list ;//= config->readListEntry("MainLayout"); |
1667 | int x,y,w,h; | 1667 | int x,y,w,h; |
1668 | QWidget* wid; | 1668 | QWidget* wid; |
1669 | wid = topLevelWidget(); | 1669 | wid = topLevelWidget(); |
1670 | x = wid->geometry().x(); | 1670 | x = wid->geometry().x(); |
1671 | y = wid->geometry().y(); | 1671 | y = wid->geometry().y(); |
1672 | w = wid->width(); | 1672 | w = wid->width(); |
1673 | h = wid->height(); | 1673 | h = wid->height(); |
1674 | list.clear(); | 1674 | list.clear(); |
1675 | list << QString::number( x ); | 1675 | list << QString::number( x ); |
1676 | list << QString::number( y ); | 1676 | list << QString::number( y ); |
1677 | list << QString::number( w ); | 1677 | list << QString::number( w ); |
1678 | list << QString::number( h ); | 1678 | list << QString::number( h ); |
1679 | config->writeEntry("MainLayout",list ); | 1679 | config->writeEntry("MainLayout",list ); |
1680 | 1680 | ||
1681 | wid = mEventEditor; | 1681 | wid = mEventEditor; |
1682 | x = wid->geometry().x(); | 1682 | x = wid->geometry().x(); |
1683 | y = wid->geometry().y(); | 1683 | y = wid->geometry().y(); |
1684 | w = wid->width(); | 1684 | w = wid->width(); |
1685 | h = wid->height(); | 1685 | h = wid->height(); |
1686 | list.clear(); | 1686 | list.clear(); |
1687 | list << QString::number( x ); | 1687 | list << QString::number( x ); |
1688 | list << QString::number( y ); | 1688 | list << QString::number( y ); |
1689 | list << QString::number( w ); | 1689 | list << QString::number( w ); |
1690 | list << QString::number( h ); | 1690 | list << QString::number( h ); |
1691 | config->writeEntry("EditEventLayout",list ); | 1691 | config->writeEntry("EditEventLayout",list ); |
1692 | 1692 | ||
1693 | wid = mTodoEditor; | 1693 | wid = mTodoEditor; |
1694 | x = wid->geometry().x(); | 1694 | x = wid->geometry().x(); |
1695 | y = wid->geometry().y(); | 1695 | y = wid->geometry().y(); |
1696 | w = wid->width(); | 1696 | w = wid->width(); |
1697 | h = wid->height(); | 1697 | h = wid->height(); |
1698 | list.clear(); | 1698 | list.clear(); |
1699 | list << QString::number( x ); | 1699 | list << QString::number( x ); |
1700 | list << QString::number( y ); | 1700 | list << QString::number( y ); |
1701 | list << QString::number( w ); | 1701 | list << QString::number( w ); |
1702 | list << QString::number( h ); | 1702 | list << QString::number( h ); |
1703 | config->writeEntry("EditTodoLayout",list ); | 1703 | config->writeEntry("EditTodoLayout",list ); |
1704 | wid = getEventViewerDialog(); | 1704 | wid = getEventViewerDialog(); |
1705 | x = wid->geometry().x(); | 1705 | x = wid->geometry().x(); |
1706 | y = wid->geometry().y(); | 1706 | y = wid->geometry().y(); |
1707 | w = wid->width(); | 1707 | w = wid->width(); |
1708 | h = wid->height(); | 1708 | h = wid->height(); |
1709 | list.clear(); | 1709 | list.clear(); |
1710 | list << QString::number( x ); | 1710 | list << QString::number( x ); |
1711 | list << QString::number( y ); | 1711 | list << QString::number( y ); |
1712 | list << QString::number( w ); | 1712 | list << QString::number( w ); |
1713 | list << QString::number( h ); | 1713 | list << QString::number( h ); |
1714 | config->writeEntry("ViewerLayout",list ); | 1714 | config->writeEntry("ViewerLayout",list ); |
1715 | wid = mDialogManager->getSearchDialog(); | 1715 | wid = mDialogManager->getSearchDialog(); |
1716 | if ( wid ) { | 1716 | if ( wid ) { |
1717 | x = wid->geometry().x(); | 1717 | x = wid->geometry().x(); |
1718 | y = wid->geometry().y(); | 1718 | y = wid->geometry().y(); |
1719 | w = wid->width(); | 1719 | w = wid->width(); |
1720 | h = wid->height(); | 1720 | h = wid->height(); |
1721 | list.clear(); | 1721 | list.clear(); |
1722 | list << QString::number( x ); | 1722 | list << QString::number( x ); |
1723 | list << QString::number( y ); | 1723 | list << QString::number( y ); |
1724 | list << QString::number( w ); | 1724 | list << QString::number( w ); |
1725 | list << QString::number( h ); | 1725 | list << QString::number( h ); |
1726 | config->writeEntry("SearchLayout",list ); | 1726 | config->writeEntry("SearchLayout",list ); |
1727 | } | 1727 | } |
1728 | #endif | 1728 | #endif |
1729 | 1729 | ||
1730 | 1730 | ||
1731 | config->sync(); | 1731 | config->sync(); |
1732 | } | 1732 | } |
1733 | 1733 | ||
1734 | void CalendarView::readFilterSettings(KConfig *config) | 1734 | void CalendarView::readFilterSettings(KConfig *config) |
1735 | { | 1735 | { |
1736 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1736 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1737 | 1737 | ||
1738 | mFilters.clear(); | 1738 | mFilters.clear(); |
1739 | 1739 | ||
1740 | config->setGroup("General"); | 1740 | config->setGroup("General"); |
1741 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1741 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1742 | 1742 | ||
1743 | QStringList::ConstIterator it = filterList.begin(); | 1743 | QStringList::ConstIterator it = filterList.begin(); |
1744 | QStringList::ConstIterator end = filterList.end(); | 1744 | QStringList::ConstIterator end = filterList.end(); |
1745 | while(it != end) { | 1745 | while(it != end) { |
1746 | // kdDebug() << " filter: " << (*it) << endl; | 1746 | // kdDebug() << " filter: " << (*it) << endl; |
1747 | 1747 | ||
1748 | CalFilter *filter; | 1748 | CalFilter *filter; |
1749 | filter = new CalFilter(*it); | 1749 | filter = new CalFilter(*it); |
1750 | config->setGroup("Filter_" + (*it)); | 1750 | config->setGroup("Filter_" + (*it)); |
1751 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1751 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1752 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1752 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1753 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1753 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1754 | mFilters.append(filter); | 1754 | mFilters.append(filter); |
1755 | 1755 | ||
1756 | ++it; | 1756 | ++it; |
1757 | } | 1757 | } |
1758 | 1758 | ||
1759 | if (mFilters.count() == 0) { | 1759 | if (mFilters.count() == 0) { |
1760 | CalFilter *filter = new CalFilter(i18n("Default")); | 1760 | CalFilter *filter = new CalFilter(i18n("Default")); |
1761 | mFilters.append(filter); | 1761 | mFilters.append(filter); |
1762 | } | 1762 | } |
1763 | mFilterView->updateFilters(); | 1763 | mFilterView->updateFilters(); |
1764 | config->setGroup("FilterView"); | 1764 | config->setGroup("FilterView"); |
1765 | 1765 | ||
1766 | mFilterView->blockSignals(true); | 1766 | mFilterView->blockSignals(true); |
1767 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1767 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1768 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1768 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1769 | mFilterView->blockSignals(false); | 1769 | mFilterView->blockSignals(false); |
1770 | // We do it manually to avoid it being done twice by the above calls | 1770 | // We do it manually to avoid it being done twice by the above calls |
1771 | updateFilter(); | 1771 | updateFilter(); |
1772 | } | 1772 | } |
1773 | 1773 | ||
1774 | void CalendarView::writeFilterSettings(KConfig *config) | 1774 | void CalendarView::writeFilterSettings(KConfig *config) |
1775 | { | 1775 | { |
1776 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1776 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1777 | 1777 | ||
1778 | QStringList filterList; | 1778 | QStringList filterList; |
1779 | 1779 | ||
1780 | CalFilter *filter = mFilters.first(); | 1780 | CalFilter *filter = mFilters.first(); |
1781 | while(filter) { | 1781 | while(filter) { |
1782 | // kdDebug() << " fn: " << filter->name() << endl; | 1782 | // kdDebug() << " fn: " << filter->name() << endl; |
1783 | filterList << filter->name(); | 1783 | filterList << filter->name(); |
1784 | config->setGroup("Filter_" + filter->name()); | 1784 | config->setGroup("Filter_" + filter->name()); |
1785 | config->writeEntry("Criteria",filter->criteria()); | 1785 | config->writeEntry("Criteria",filter->criteria()); |
1786 | config->writeEntry("CategoryList",filter->categoryList()); | 1786 | config->writeEntry("CategoryList",filter->categoryList()); |
1787 | filter = mFilters.next(); | 1787 | filter = mFilters.next(); |
1788 | } | 1788 | } |
1789 | config->setGroup("General"); | 1789 | config->setGroup("General"); |
1790 | config->writeEntry("CalendarFilters",filterList); | 1790 | config->writeEntry("CalendarFilters",filterList); |
1791 | 1791 | ||
1792 | config->setGroup("FilterView"); | 1792 | config->setGroup("FilterView"); |
1793 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1793 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1794 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1794 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1795 | } | 1795 | } |
1796 | 1796 | ||
1797 | 1797 | ||
1798 | void CalendarView::goToday() | 1798 | void CalendarView::goToday() |
1799 | { | 1799 | { |
1800 | mNavigator->selectToday(); | 1800 | mNavigator->selectToday(); |
1801 | } | 1801 | } |
1802 | 1802 | ||
1803 | void CalendarView::goNext() | 1803 | void CalendarView::goNext() |
1804 | { | 1804 | { |
1805 | mNavigator->selectNext(); | 1805 | mNavigator->selectNext(); |
1806 | } | 1806 | } |
1807 | 1807 | ||
1808 | void CalendarView::goPrevious() | 1808 | void CalendarView::goPrevious() |
1809 | { | 1809 | { |
1810 | mNavigator->selectPrevious(); | 1810 | mNavigator->selectPrevious(); |
1811 | } | 1811 | } |
1812 | void CalendarView::goNextMonth() | 1812 | void CalendarView::goNextMonth() |
1813 | { | 1813 | { |
1814 | mNavigator->selectNextMonth(); | 1814 | mNavigator->selectNextMonth(); |
1815 | } | 1815 | } |
1816 | 1816 | ||
1817 | void CalendarView::goPreviousMonth() | 1817 | void CalendarView::goPreviousMonth() |
1818 | { | 1818 | { |
1819 | mNavigator->selectPreviousMonth(); | 1819 | mNavigator->selectPreviousMonth(); |
1820 | } | 1820 | } |
1821 | void CalendarView::writeLocale() | 1821 | void CalendarView::writeLocale() |
1822 | { | 1822 | { |
1823 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1823 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1824 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1824 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1825 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1825 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1826 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1826 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1827 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1827 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1828 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1828 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1829 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1829 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1830 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1830 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1831 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1831 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1832 | KOPrefs::instance()->mDaylightsavingStart, | 1832 | KOPrefs::instance()->mDaylightsavingStart, |
1833 | KOPrefs::instance()->mDaylightsavingEnd ); | 1833 | KOPrefs::instance()->mDaylightsavingEnd ); |
1834 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 1834 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
1835 | } | 1835 | } |
1836 | void CalendarView::updateConfig() | 1836 | void CalendarView::updateConfig() |
1837 | { | 1837 | { |
1838 | writeLocale(); | 1838 | writeLocale(); |
1839 | if ( KOPrefs::instance()->mUseAppColors ) | 1839 | if ( KOPrefs::instance()->mUseAppColors ) |
1840 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 1840 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
1841 | emit configChanged(); | 1841 | emit configChanged(); |
1842 | mTodoList->updateConfig(); | 1842 | mTodoList->updateConfig(); |
1843 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 1843 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
1844 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1844 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1845 | // To make the "fill window" configurations work | 1845 | // To make the "fill window" configurations work |
1846 | //mViewManager->raiseCurrentView(); | 1846 | //mViewManager->raiseCurrentView(); |
1847 | } | 1847 | } |
1848 | 1848 | ||
1849 | 1849 | ||
1850 | void CalendarView::eventChanged(Event *event) | 1850 | void CalendarView::eventChanged(Event *event) |
1851 | { | 1851 | { |
1852 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 1852 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
1853 | //updateUnmanagedViews(); | 1853 | //updateUnmanagedViews(); |
1854 | } | 1854 | } |
1855 | 1855 | ||
1856 | void CalendarView::eventAdded(Event *event) | 1856 | void CalendarView::eventAdded(Event *event) |
1857 | { | 1857 | { |
1858 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 1858 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
1859 | } | 1859 | } |
1860 | 1860 | ||
1861 | void CalendarView::eventToBeDeleted(Event *) | 1861 | void CalendarView::eventToBeDeleted(Event *) |
1862 | { | 1862 | { |
1863 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 1863 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
1864 | } | 1864 | } |
1865 | 1865 | ||
1866 | void CalendarView::eventDeleted() | 1866 | void CalendarView::eventDeleted() |
1867 | { | 1867 | { |
1868 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 1868 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
1869 | } | 1869 | } |
1870 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 1870 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
1871 | { | 1871 | { |
1872 | changeIncidenceDisplay((Incidence *)which, action); | 1872 | changeIncidenceDisplay((Incidence *)which, action); |
1873 | mDateNavigator->updateView(); | ||
1874 | //mDialogManager->updateSearchDialog(); | ||
1875 | |||
1876 | if (which) { | ||
1877 | mViewManager->currentView()->updateView(); | ||
1878 | mTodoList->updateView(); | ||
1879 | } | ||
1880 | |||
1873 | } | 1881 | } |
1874 | 1882 | ||
1875 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 1883 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
1876 | { | 1884 | { |
1877 | updateUnmanagedViews(); | 1885 | updateUnmanagedViews(); |
1878 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 1886 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
1879 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 1887 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
1880 | mCalendar->checkAlarmForIncidence( 0, true ); | 1888 | mCalendar->checkAlarmForIncidence( 0, true ); |
1881 | if ( mEventViewerDialog ) | 1889 | if ( mEventViewerDialog ) |
1882 | mEventViewerDialog->hide(); | 1890 | mEventViewerDialog->hide(); |
1883 | } | 1891 | } |
1884 | else | 1892 | else |
1885 | mCalendar->checkAlarmForIncidence( which , false ); | 1893 | mCalendar->checkAlarmForIncidence( which , false ); |
1886 | } | 1894 | } |
1887 | 1895 | ||
1888 | // most of the changeEventDisplays() right now just call the view's | 1896 | // most of the changeEventDisplays() right now just call the view's |
1889 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 1897 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
1890 | void CalendarView::changeEventDisplay(Event *which, int action) | 1898 | void CalendarView::changeEventDisplay(Event *which, int action) |
1891 | { | 1899 | { |
1892 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 1900 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
1893 | changeIncidenceDisplay((Incidence *)which, action); | 1901 | changeIncidenceDisplay((Incidence *)which, action); |
1894 | mDateNavigator->updateView(); | 1902 | mDateNavigator->updateView(); |
1895 | //mDialogManager->updateSearchDialog(); | 1903 | //mDialogManager->updateSearchDialog(); |
1896 | 1904 | ||
1897 | if (which) { | 1905 | if (which) { |
1898 | // If there is an event view visible update the display | 1906 | // If there is an event view visible update the display |
1899 | mViewManager->currentView()->changeEventDisplay(which,action); | 1907 | mViewManager->currentView()->changeEventDisplay(which,action); |
1900 | // TODO: check, if update needed | 1908 | // TODO: check, if update needed |
1901 | // if (which->getTodoStatus()) { | 1909 | // if (which->getTodoStatus()) { |
1902 | mTodoList->updateView(); | 1910 | mTodoList->updateView(); |
1903 | // } | 1911 | // } |
1904 | } else { | 1912 | } else { |
1905 | mViewManager->currentView()->updateView(); | 1913 | mViewManager->currentView()->updateView(); |
1906 | } | 1914 | } |
1907 | } | 1915 | } |
1908 | 1916 | ||
1909 | 1917 | ||
1910 | void CalendarView::updateTodoViews() | 1918 | void CalendarView::updateTodoViews() |
1911 | { | 1919 | { |
1912 | 1920 | ||
1913 | mTodoList->updateView(); | 1921 | mTodoList->updateView(); |
1914 | mViewManager->currentView()->updateView(); | 1922 | mViewManager->currentView()->updateView(); |
1915 | 1923 | ||
1916 | } | 1924 | } |
1917 | 1925 | ||
1918 | 1926 | ||
1919 | void CalendarView::updateView(const QDate &start, const QDate &end) | 1927 | void CalendarView::updateView(const QDate &start, const QDate &end) |
1920 | { | 1928 | { |
1921 | mTodoList->updateView(); | 1929 | mTodoList->updateView(); |
1922 | mViewManager->updateView(start, end); | 1930 | mViewManager->updateView(start, end); |
1923 | //mDateNavigator->updateView(); | 1931 | //mDateNavigator->updateView(); |
1924 | } | 1932 | } |
1925 | 1933 | ||
1926 | void CalendarView::updateView() | 1934 | void CalendarView::updateView() |
1927 | { | 1935 | { |
1928 | DateList tmpList = mNavigator->selectedDates(); | 1936 | DateList tmpList = mNavigator->selectedDates(); |
1929 | 1937 | ||
1930 | // We assume that the navigator only selects consecutive days. | 1938 | // We assume that the navigator only selects consecutive days. |
1931 | updateView( tmpList.first(), tmpList.last() ); | 1939 | updateView( tmpList.first(), tmpList.last() ); |
1932 | } | 1940 | } |
1933 | 1941 | ||
1934 | void CalendarView::updateUnmanagedViews() | 1942 | void CalendarView::updateUnmanagedViews() |
1935 | { | 1943 | { |
1936 | mDateNavigator->updateDayMatrix(); | 1944 | mDateNavigator->updateDayMatrix(); |
1937 | } | 1945 | } |
1938 | 1946 | ||
1939 | int CalendarView::msgItemDelete() | 1947 | int CalendarView::msgItemDelete() |
1940 | { | 1948 | { |
1941 | return KMessageBox::warningContinueCancel(this, | 1949 | return KMessageBox::warningContinueCancel(this, |
1942 | i18n("This item will be\npermanently deleted."), | 1950 | i18n("This item will be\npermanently deleted."), |
1943 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 1951 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
1944 | } | 1952 | } |
1945 | 1953 | ||
1946 | 1954 | ||
1947 | void CalendarView::edit_cut() | 1955 | void CalendarView::edit_cut() |
1948 | { | 1956 | { |
1949 | Event *anEvent=0; | 1957 | Event *anEvent=0; |
1950 | 1958 | ||
1951 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 1959 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
1952 | 1960 | ||
1953 | if (mViewManager->currentView()->isEventView()) { | 1961 | if (mViewManager->currentView()->isEventView()) { |
1954 | if ( incidence && incidence->type() == "Event" ) { | 1962 | if ( incidence && incidence->type() == "Event" ) { |
1955 | anEvent = static_cast<Event *>(incidence); | 1963 | anEvent = static_cast<Event *>(incidence); |
1956 | } | 1964 | } |
1957 | } | 1965 | } |
1958 | 1966 | ||
1959 | if (!anEvent) { | 1967 | if (!anEvent) { |
1960 | KNotifyClient::beep(); | 1968 | KNotifyClient::beep(); |
1961 | return; | 1969 | return; |
1962 | } | 1970 | } |
1963 | DndFactory factory( mCalendar ); | 1971 | DndFactory factory( mCalendar ); |
1964 | factory.cutEvent(anEvent); | 1972 | factory.cutEvent(anEvent); |
1965 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 1973 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
1966 | } | 1974 | } |
1967 | 1975 | ||
1968 | void CalendarView::edit_copy() | 1976 | void CalendarView::edit_copy() |
1969 | { | 1977 | { |
1970 | Event *anEvent=0; | 1978 | Event *anEvent=0; |
1971 | 1979 | ||
1972 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 1980 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
1973 | 1981 | ||
1974 | if (mViewManager->currentView()->isEventView()) { | 1982 | if (mViewManager->currentView()->isEventView()) { |
1975 | if ( incidence && incidence->type() == "Event" ) { | 1983 | if ( incidence && incidence->type() == "Event" ) { |
1976 | anEvent = static_cast<Event *>(incidence); | 1984 | anEvent = static_cast<Event *>(incidence); |
1977 | } | 1985 | } |
1978 | } | 1986 | } |
1979 | 1987 | ||
1980 | if (!anEvent) { | 1988 | if (!anEvent) { |
1981 | KNotifyClient::beep(); | 1989 | KNotifyClient::beep(); |
1982 | return; | 1990 | return; |
1983 | } | 1991 | } |
1984 | DndFactory factory( mCalendar ); | 1992 | DndFactory factory( mCalendar ); |
1985 | factory.copyEvent(anEvent); | 1993 | factory.copyEvent(anEvent); |
1986 | } | 1994 | } |
1987 | 1995 | ||
1988 | void CalendarView::edit_paste() | 1996 | void CalendarView::edit_paste() |
1989 | { | 1997 | { |
1990 | QDate date = mNavigator->selectedDates().first(); | 1998 | QDate date = mNavigator->selectedDates().first(); |
1991 | 1999 | ||
1992 | DndFactory factory( mCalendar ); | 2000 | DndFactory factory( mCalendar ); |
1993 | Event *pastedEvent = factory.pasteEvent( date ); | 2001 | Event *pastedEvent = factory.pasteEvent( date ); |
1994 | 2002 | ||
1995 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2003 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
1996 | } | 2004 | } |
1997 | 2005 | ||
1998 | void CalendarView::edit_options() | 2006 | void CalendarView::edit_options() |
1999 | { | 2007 | { |
2000 | mDialogManager->showOptionsDialog(); | 2008 | mDialogManager->showOptionsDialog(); |
2001 | //writeSettings(); | 2009 | //writeSettings(); |
2002 | } | 2010 | } |
2003 | void CalendarView::edit_sync_options() | 2011 | void CalendarView::edit_sync_options() |
2004 | { | 2012 | { |
2005 | //mDialogManager->showSyncOptions(); | 2013 | //mDialogManager->showSyncOptions(); |
2006 | //KOPrefs::instance()->mSyncAlgoPrefs | 2014 | //KOPrefs::instance()->mSyncAlgoPrefs |
2007 | QDialog dia( this, "dia", true ); | 2015 | QDialog dia( this, "dia", true ); |
2008 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2016 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2009 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2017 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2010 | QVBoxLayout lay ( &dia ); | 2018 | QVBoxLayout lay ( &dia ); |
2011 | lay.setSpacing( 2 ); | 2019 | lay.setSpacing( 2 ); |
2012 | lay.setMargin( 3 ); | 2020 | lay.setMargin( 3 ); |
2013 | lay.addWidget(&gr); | 2021 | lay.addWidget(&gr); |
2014 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2022 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2015 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2023 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2016 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2024 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2017 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2025 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2018 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2026 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2019 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2027 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2020 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2028 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2021 | QPushButton pb ( "OK", &dia); | 2029 | QPushButton pb ( "OK", &dia); |
2022 | lay.addWidget( &pb ); | 2030 | lay.addWidget( &pb ); |
2023 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2031 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2024 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { | 2032 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { |
2025 | case 0: | 2033 | case 0: |
2026 | loc.setChecked( true); | 2034 | loc.setChecked( true); |
2027 | break; | 2035 | break; |
2028 | case 1: | 2036 | case 1: |
2029 | rem.setChecked( true ); | 2037 | rem.setChecked( true ); |
2030 | break; | 2038 | break; |
2031 | case 2: | 2039 | case 2: |
2032 | newest.setChecked( true); | 2040 | newest.setChecked( true); |
2033 | break; | 2041 | break; |
2034 | case 3: | 2042 | case 3: |
2035 | ask.setChecked( true); | 2043 | ask.setChecked( true); |
2036 | break; | 2044 | break; |
2037 | case 4: | 2045 | case 4: |
2038 | f_loc.setChecked( true); | 2046 | f_loc.setChecked( true); |
2039 | break; | 2047 | break; |
2040 | case 5: | 2048 | case 5: |
2041 | f_rem.setChecked( true); | 2049 | f_rem.setChecked( true); |
2042 | break; | 2050 | break; |
2043 | case 6: | 2051 | case 6: |
2044 | // both.setChecked( true); | 2052 | // both.setChecked( true); |
2045 | break; | 2053 | break; |
2046 | default: | 2054 | default: |
2047 | break; | 2055 | break; |
2048 | } | 2056 | } |
2049 | if ( dia.exec() ) { | 2057 | if ( dia.exec() ) { |
2050 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2058 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2051 | } | 2059 | } |
2052 | 2060 | ||
2053 | } | 2061 | } |
2054 | 2062 | ||
2055 | void CalendarView::slotSelectPickerDate( QDate d) | 2063 | void CalendarView::slotSelectPickerDate( QDate d) |
2056 | { | 2064 | { |
2057 | mDateFrame->hide(); | 2065 | mDateFrame->hide(); |
2058 | if ( mDatePickerMode == 1 ) { | 2066 | if ( mDatePickerMode == 1 ) { |
2059 | mNavigator->slotDaySelect( d ); | 2067 | mNavigator->slotDaySelect( d ); |
2060 | } else if ( mDatePickerMode == 2 ) { | 2068 | } else if ( mDatePickerMode == 2 ) { |
2061 | if ( mMoveIncidence->type() == "Todo" ) { | 2069 | if ( mMoveIncidence->type() == "Todo" ) { |
2062 | Todo * to = (Todo *) mMoveIncidence; | 2070 | Todo * to = (Todo *) mMoveIncidence; |
2063 | QTime tim; | 2071 | QTime tim; |
2064 | if ( to->hasDueDate() ) | 2072 | if ( to->hasDueDate() ) |
2065 | tim = to->dtDue().time(); | 2073 | tim = to->dtDue().time(); |
2066 | else { | 2074 | else { |
2067 | tim = QTime ( 0,0,0 ); | 2075 | tim = QTime ( 0,0,0 ); |
2068 | to->setFloats( true ); | 2076 | to->setFloats( true ); |
2069 | to->setHasDueDate( true ); | 2077 | to->setHasDueDate( true ); |
2070 | } | 2078 | } |
2071 | QDateTime dt ( d,tim ); | 2079 | QDateTime dt ( d,tim ); |
2072 | to->setDtDue( dt ); | 2080 | to->setDtDue( dt ); |
2073 | todoChanged( to ); | 2081 | todoChanged( to ); |
2074 | } else { | 2082 | } else { |
2075 | QTime tim = mMoveIncidence->dtStart().time(); | 2083 | QTime tim = mMoveIncidence->dtStart().time(); |
2076 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2084 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2077 | QDateTime dt ( d,tim ); | 2085 | QDateTime dt ( d,tim ); |
2078 | mMoveIncidence->setDtStart( dt ); | 2086 | mMoveIncidence->setDtStart( dt ); |
2079 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2087 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2080 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2088 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2081 | } | 2089 | } |
2082 | 2090 | ||
2083 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2091 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2084 | } | 2092 | } |
2085 | } | 2093 | } |
2086 | 2094 | ||
2087 | void CalendarView::removeCategories() | 2095 | void CalendarView::removeCategories() |
2088 | { | 2096 | { |
2089 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2097 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2090 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2098 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2091 | QStringList catIncList; | 2099 | QStringList catIncList; |
2092 | QStringList newCatList; | 2100 | QStringList newCatList; |
2093 | Incidence* inc = incList.first(); | 2101 | Incidence* inc = incList.first(); |
2094 | int i; | 2102 | int i; |
2095 | int count = 0; | 2103 | int count = 0; |
2096 | while ( inc ) { | 2104 | while ( inc ) { |
2097 | newCatList.clear(); | 2105 | newCatList.clear(); |
2098 | catIncList = inc->categories() ; | 2106 | catIncList = inc->categories() ; |
2099 | for( i = 0; i< catIncList.count(); ++i ) { | 2107 | for( i = 0; i< catIncList.count(); ++i ) { |
2100 | if ( catList.contains (catIncList[i])) | 2108 | if ( catList.contains (catIncList[i])) |
2101 | newCatList.append( catIncList[i] ); | 2109 | newCatList.append( catIncList[i] ); |
2102 | } | 2110 | } |
2103 | newCatList.sort(); | 2111 | newCatList.sort(); |
2104 | inc->setCategories( newCatList.join(",") ); | 2112 | inc->setCategories( newCatList.join(",") ); |
2105 | inc = incList.next(); | 2113 | inc = incList.next(); |
2106 | } | 2114 | } |
2107 | } | 2115 | } |
2108 | 2116 | ||
2109 | int CalendarView::addCategories() | 2117 | int CalendarView::addCategories() |
2110 | { | 2118 | { |
2111 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2119 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2112 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2120 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2113 | QStringList catIncList; | 2121 | QStringList catIncList; |
2114 | Incidence* inc = incList.first(); | 2122 | Incidence* inc = incList.first(); |
2115 | int i; | 2123 | int i; |
2116 | int count = 0; | 2124 | int count = 0; |
2117 | while ( inc ) { | 2125 | while ( inc ) { |
2118 | catIncList = inc->categories() ; | 2126 | catIncList = inc->categories() ; |
2119 | for( i = 0; i< catIncList.count(); ++i ) { | 2127 | for( i = 0; i< catIncList.count(); ++i ) { |
2120 | if ( !catList.contains (catIncList[i])) { | 2128 | if ( !catList.contains (catIncList[i])) { |
2121 | catList.append( catIncList[i] ); | 2129 | catList.append( catIncList[i] ); |
2122 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2130 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2123 | ++count; | 2131 | ++count; |
2124 | } | 2132 | } |
2125 | } | 2133 | } |
2126 | inc = incList.next(); | 2134 | inc = incList.next(); |
2127 | } | 2135 | } |
2128 | catList.sort(); | 2136 | catList.sort(); |
2129 | KOPrefs::instance()->mCustomCategories = catList; | 2137 | KOPrefs::instance()->mCustomCategories = catList; |
2130 | return count; | 2138 | return count; |
2131 | } | 2139 | } |
2132 | 2140 | ||
2133 | void CalendarView::manageCategories() | 2141 | void CalendarView::manageCategories() |
2134 | { | 2142 | { |
2135 | KOCatPrefs* cp = new KOCatPrefs(); | 2143 | KOCatPrefs* cp = new KOCatPrefs(); |
2136 | cp->show(); | 2144 | cp->show(); |
2137 | int w =cp->sizeHint().width() ; | 2145 | int w =cp->sizeHint().width() ; |
2138 | int h = cp->sizeHint().height() ; | 2146 | int h = cp->sizeHint().height() ; |
2139 | int dw = QApplication::desktop()->width(); | 2147 | int dw = QApplication::desktop()->width(); |
2140 | int dh = QApplication::desktop()->height(); | 2148 | int dh = QApplication::desktop()->height(); |
2141 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2149 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2142 | if ( !cp->exec() ) { | 2150 | if ( !cp->exec() ) { |
2143 | delete cp; | 2151 | delete cp; |
2144 | return; | 2152 | return; |
2145 | } | 2153 | } |
2146 | int count = 0; | 2154 | int count = 0; |
2147 | if ( cp->addCat() ) { | 2155 | if ( cp->addCat() ) { |
2148 | count = addCategories(); | 2156 | count = addCategories(); |
2149 | if ( count ) { | 2157 | if ( count ) { |
2150 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2158 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2151 | writeSettings(); | 2159 | writeSettings(); |
2152 | } | 2160 | } |
2153 | } else { | 2161 | } else { |
2154 | removeCategories(); | 2162 | removeCategories(); |
2155 | updateView(); | 2163 | updateView(); |
2156 | } | 2164 | } |
2157 | delete cp; | 2165 | delete cp; |
2158 | } | 2166 | } |
2159 | 2167 | ||
2160 | void CalendarView::beamIncidence(Incidence * Inc) | 2168 | void CalendarView::beamIncidence(Incidence * Inc) |
2161 | { | 2169 | { |
2162 | QPtrList<Incidence> delSel ; | 2170 | QPtrList<Incidence> delSel ; |
2163 | delSel.append(Inc); | 2171 | delSel.append(Inc); |
2164 | beamIncidenceList( delSel ); | 2172 | beamIncidenceList( delSel ); |
2165 | } | 2173 | } |
2166 | void CalendarView::beamCalendar() | 2174 | void CalendarView::beamCalendar() |
2167 | { | 2175 | { |
2168 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2176 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2169 | //qDebug("beamCalendar() "); | 2177 | //qDebug("beamCalendar() "); |
2170 | beamIncidenceList( delSel ); | 2178 | beamIncidenceList( delSel ); |
2171 | } | 2179 | } |
2172 | void CalendarView::beamFilteredCalendar() | 2180 | void CalendarView::beamFilteredCalendar() |
2173 | { | 2181 | { |
2174 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2182 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2175 | //qDebug("beamFilteredCalendar() "); | 2183 | //qDebug("beamFilteredCalendar() "); |
2176 | beamIncidenceList( delSel ); | 2184 | beamIncidenceList( delSel ); |
2177 | } | 2185 | } |
2178 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2186 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2179 | { | 2187 | { |
2180 | if ( beamDialog->exec () == QDialog::Rejected ) | 2188 | if ( beamDialog->exec () == QDialog::Rejected ) |
2181 | return; | 2189 | return; |
2182 | 2190 | ||
2183 | QString fn = "/tmp/kopibeamfile"; | 2191 | QString fn = "/tmp/kopibeamfile"; |
2184 | QString mes; | 2192 | QString mes; |
2185 | bool createbup = true; | 2193 | bool createbup = true; |
2186 | if ( createbup ) { | 2194 | if ( createbup ) { |
2187 | QString description = "\n"; | 2195 | QString description = "\n"; |
2188 | CalendarLocal* cal = new CalendarLocal(); | 2196 | CalendarLocal* cal = new CalendarLocal(); |
2189 | if ( beamDialog->beamLocal() ) | 2197 | if ( beamDialog->beamLocal() ) |
2190 | cal->setLocalTime(); | 2198 | cal->setLocalTime(); |
2191 | else | 2199 | else |
2192 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2200 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2193 | Incidence *incidence = delSel.first(); | 2201 | Incidence *incidence = delSel.first(); |
2194 | bool addText = false; | 2202 | bool addText = false; |
2195 | if ( delSel.count() < 10 ) | 2203 | if ( delSel.count() < 10 ) |
2196 | addText = true; | 2204 | addText = true; |
2197 | else { | 2205 | else { |
2198 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2206 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2199 | } | 2207 | } |
2200 | while ( incidence ) { | 2208 | while ( incidence ) { |
2201 | Incidence *in = incidence->clone(); | 2209 | Incidence *in = incidence->clone(); |
2202 | if ( addText ) | 2210 | if ( addText ) |
2203 | description += in->summary() + "\n"; | 2211 | description += in->summary() + "\n"; |
2204 | cal->addIncidence( in ); | 2212 | cal->addIncidence( in ); |
2205 | incidence = delSel.next(); | 2213 | incidence = delSel.next(); |
2206 | } | 2214 | } |
2207 | if ( beamDialog->beamVcal() ) { | 2215 | if ( beamDialog->beamVcal() ) { |
2208 | fn += ".vcs"; | 2216 | fn += ".vcs"; |
2209 | FileStorage storage( cal, fn, new VCalFormat ); | 2217 | FileStorage storage( cal, fn, new VCalFormat ); |
2210 | storage.save(); | 2218 | storage.save(); |
2211 | } else { | 2219 | } else { |
2212 | fn += ".ics"; | 2220 | fn += ".ics"; |
2213 | FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2221 | FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2214 | storage.save(); | 2222 | storage.save(); |
2215 | } | 2223 | } |
2216 | delete cal; | 2224 | delete cal; |
2217 | mes = i18n("KO/Pi: Ready for beaming"); | 2225 | mes = i18n("KO/Pi: Ready for beaming"); |
2218 | setCaption(mes); | 2226 | setCaption(mes); |
2219 | 2227 | ||
2220 | #ifndef DESKTOP_VERSION | 2228 | #ifndef DESKTOP_VERSION |
2221 | Ir *ir = new Ir( this ); | 2229 | Ir *ir = new Ir( this ); |
2222 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2230 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2223 | ir->send( fn, description, "text/x-vCalendar" ); | 2231 | ir->send( fn, description, "text/x-vCalendar" ); |
2224 | #endif | 2232 | #endif |
2225 | } | 2233 | } |
2226 | } | 2234 | } |
2227 | void CalendarView::beamDone( Ir *ir ) | 2235 | void CalendarView::beamDone( Ir *ir ) |
2228 | { | 2236 | { |
2229 | #ifndef DESKTOP_VERSION | 2237 | #ifndef DESKTOP_VERSION |
2230 | delete ir; | 2238 | delete ir; |
2231 | #endif | 2239 | #endif |
2232 | } | 2240 | } |
2233 | 2241 | ||
2234 | void CalendarView::moveIncidence(Incidence * inc ) | 2242 | void CalendarView::moveIncidence(Incidence * inc ) |
2235 | { | 2243 | { |
2236 | if ( !inc ) return; | 2244 | if ( !inc ) return; |
2237 | // qDebug("showDatePickerForIncidence( ) "); | 2245 | // qDebug("showDatePickerForIncidence( ) "); |
2238 | if ( mDateFrame->isVisible() ) | 2246 | if ( mDateFrame->isVisible() ) |
2239 | mDateFrame->hide(); | 2247 | mDateFrame->hide(); |
2240 | else { | 2248 | else { |
2241 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2249 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2242 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2250 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2243 | int dw = QApplication::desktop()->width(); | 2251 | int dw = QApplication::desktop()->width(); |
2244 | int dh = QApplication::desktop()->height(); | 2252 | int dh = QApplication::desktop()->height(); |
2245 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2253 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2246 | mDateFrame->show(); | 2254 | mDateFrame->show(); |
2247 | } | 2255 | } |
2248 | mDatePickerMode = 2; | 2256 | mDatePickerMode = 2; |
2249 | mMoveIncidence = inc ; | 2257 | mMoveIncidence = inc ; |
2250 | QDate da; | 2258 | QDate da; |
2251 | if ( mMoveIncidence->type() == "Todo" ) { | 2259 | if ( mMoveIncidence->type() == "Todo" ) { |
2252 | Todo * to = (Todo *) mMoveIncidence; | 2260 | Todo * to = (Todo *) mMoveIncidence; |
2253 | if ( to->hasDueDate() ) | 2261 | if ( to->hasDueDate() ) |
2254 | da = to->dtDue().date(); | 2262 | da = to->dtDue().date(); |
2255 | else | 2263 | else |
2256 | da = QDate::currentDate(); | 2264 | da = QDate::currentDate(); |