summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index d6918d3..6eaac1c 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1565,2424 +1565,2428 @@ bool CalendarView::importQtopia( const QString &categories,
1565 loadOk = qtopiaFormat.load( calendar, categories ); 1565 loadOk = qtopiaFormat.load( calendar, categories );
1566 if ( loadOk && !datebook.isEmpty() ) 1566 if ( loadOk && !datebook.isEmpty() )
1567 loadOk = qtopiaFormat.load( calendar, datebook ); 1567 loadOk = qtopiaFormat.load( calendar, datebook );
1568 if ( loadOk && !todolist.isEmpty() ) 1568 if ( loadOk && !todolist.isEmpty() )
1569 loadOk = qtopiaFormat.load( calendar, todolist ); 1569 loadOk = qtopiaFormat.load( calendar, todolist );
1570 1570
1571 if ( loadOk ) { 1571 if ( loadOk ) {
1572 getEventViewerDialog()->setSyncMode( true ); 1572 getEventViewerDialog()->setSyncMode( true );
1573 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1573 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1574 getEventViewerDialog()->setSyncMode( false ); 1574 getEventViewerDialog()->setSyncMode( false );
1575 qApp->processEvents(); 1575 qApp->processEvents();
1576 if ( syncOK ) { 1576 if ( syncOK ) {
1577 if ( mSyncManager->mWriteBackFile ) 1577 if ( mSyncManager->mWriteBackFile )
1578 { 1578 {
1579 // write back XML file 1579 // write back XML file
1580 1580
1581 } 1581 }
1582 setModified( true ); 1582 setModified( true );
1583 } 1583 }
1584 } else { 1584 } else {
1585 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1585 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1586 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1586 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1587 question, i18n("Ok")) ; 1587 question, i18n("Ok")) ;
1588 } 1588 }
1589 delete calendar; 1589 delete calendar;
1590 updateView(); 1590 updateView();
1591 return syncOK; 1591 return syncOK;
1592 1592
1593 1593
1594#endif 1594#endif
1595 1595
1596} 1596}
1597 1597
1598void CalendarView::setSyncEventsReadOnly() 1598void CalendarView::setSyncEventsReadOnly()
1599{ 1599{
1600 Event * ev; 1600 Event * ev;
1601 QPtrList<Event> eL = mCalendar->rawEvents(); 1601 QPtrList<Event> eL = mCalendar->rawEvents();
1602 ev = eL.first(); 1602 ev = eL.first();
1603 while ( ev ) { 1603 while ( ev ) {
1604 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1604 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1605 ev->setReadOnly( true ); 1605 ev->setReadOnly( true );
1606 ev = eL.next(); 1606 ev = eL.next();
1607 } 1607 }
1608} 1608}
1609bool CalendarView::openCalendar(QString filename, bool merge) 1609bool CalendarView::openCalendar(QString filename, bool merge)
1610{ 1610{
1611 1611
1612 if (filename.isEmpty()) { 1612 if (filename.isEmpty()) {
1613 return false; 1613 return false;
1614 } 1614 }
1615 1615
1616 if (!QFile::exists(filename)) { 1616 if (!QFile::exists(filename)) {
1617 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1617 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1618 return false; 1618 return false;
1619 } 1619 }
1620 1620
1621 globalFlagBlockAgenda = 1; 1621 globalFlagBlockAgenda = 1;
1622 if (!merge) mCalendar->close(); 1622 if (!merge) mCalendar->close();
1623 1623
1624 mStorage->setFileName( filename ); 1624 mStorage->setFileName( filename );
1625 1625
1626 if ( mStorage->load() ) { 1626 if ( mStorage->load() ) {
1627 if ( merge ) ;//setModified( true ); 1627 if ( merge ) ;//setModified( true );
1628 else { 1628 else {
1629 //setModified( true ); 1629 //setModified( true );
1630 mViewManager->setDocumentId( filename ); 1630 mViewManager->setDocumentId( filename );
1631 mDialogManager->setDocumentId( filename ); 1631 mDialogManager->setDocumentId( filename );
1632 mTodoList->setDocumentId( filename ); 1632 mTodoList->setDocumentId( filename );
1633 } 1633 }
1634 globalFlagBlockAgenda = 2; 1634 globalFlagBlockAgenda = 2;
1635 // if ( getLastSyncEvent() ) 1635 // if ( getLastSyncEvent() )
1636 // getLastSyncEvent()->setReadOnly( true ); 1636 // getLastSyncEvent()->setReadOnly( true );
1637 mCalendar->reInitAlarmSettings(); 1637 mCalendar->reInitAlarmSettings();
1638 setSyncEventsReadOnly(); 1638 setSyncEventsReadOnly();
1639 updateUnmanagedViews(); 1639 updateUnmanagedViews();
1640 updateView(); 1640 updateView();
1641 if ( filename != MainWindow::defaultFileName() ) { 1641 if ( filename != MainWindow::defaultFileName() ) {
1642 saveCalendar( MainWindow::defaultFileName() ); 1642 saveCalendar( MainWindow::defaultFileName() );
1643 } else { 1643 } else {
1644 QFileInfo finf ( MainWindow::defaultFileName()); 1644 QFileInfo finf ( MainWindow::defaultFileName());
1645 if ( finf.exists() ) { 1645 if ( finf.exists() ) {
1646 setLoadedFileVersion( finf.lastModified () ); 1646 setLoadedFileVersion( finf.lastModified () );
1647 } 1647 }
1648 } 1648 }
1649 return true; 1649 return true;
1650 } else { 1650 } else {
1651 // while failing to load, the calendar object could 1651 // while failing to load, the calendar object could
1652 // have become partially populated. Clear it out. 1652 // have become partially populated. Clear it out.
1653 if ( !merge ) { 1653 if ( !merge ) {
1654 mCalendar->close(); 1654 mCalendar->close();
1655 mViewManager->setDocumentId( filename ); 1655 mViewManager->setDocumentId( filename );
1656 mDialogManager->setDocumentId( filename ); 1656 mDialogManager->setDocumentId( filename );
1657 mTodoList->setDocumentId( filename ); 1657 mTodoList->setDocumentId( filename );
1658 } 1658 }
1659 1659
1660 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1660 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1661 1661
1662 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1662 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1663 globalFlagBlockAgenda = 2; 1663 globalFlagBlockAgenda = 2;
1664 mCalendar->reInitAlarmSettings(); 1664 mCalendar->reInitAlarmSettings();
1665 setSyncEventsReadOnly(); 1665 setSyncEventsReadOnly();
1666 updateUnmanagedViews(); 1666 updateUnmanagedViews();
1667 updateView(); 1667 updateView();
1668 } 1668 }
1669 return false; 1669 return false;
1670} 1670}
1671void CalendarView::showOpenError() 1671void CalendarView::showOpenError()
1672{ 1672{
1673 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1673 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1674} 1674}
1675void CalendarView::setLoadedFileVersion(QDateTime dt) 1675void CalendarView::setLoadedFileVersion(QDateTime dt)
1676{ 1676{
1677 loadedFileVersion = dt; 1677 loadedFileVersion = dt;
1678} 1678}
1679bool CalendarView::checkFileChanged(QString fn) 1679bool CalendarView::checkFileChanged(QString fn)
1680{ 1680{
1681 QFileInfo finf ( fn ); 1681 QFileInfo finf ( fn );
1682 if ( !finf.exists() ) 1682 if ( !finf.exists() )
1683 return true; 1683 return true;
1684 QDateTime dt = finf.lastModified (); 1684 QDateTime dt = finf.lastModified ();
1685 if ( dt <= loadedFileVersion ) 1685 if ( dt <= loadedFileVersion )
1686 return false; 1686 return false;
1687 return true; 1687 return true;
1688 1688
1689} 1689}
1690void CalendarView::watchSavedFile() 1690void CalendarView::watchSavedFile()
1691{ 1691{
1692 QFileInfo finf ( MainWindow::defaultFileName()); 1692 QFileInfo finf ( MainWindow::defaultFileName());
1693 if ( !finf.exists() ) 1693 if ( !finf.exists() )
1694 return; 1694 return;
1695 QDateTime dt = finf.lastModified (); 1695 QDateTime dt = finf.lastModified ();
1696 if ( dt < loadedFileVersion ) { 1696 if ( dt < loadedFileVersion ) {
1697 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1697 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1698 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1698 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1699 return; 1699 return;
1700 } 1700 }
1701 loadedFileVersion = dt; 1701 loadedFileVersion = dt;
1702} 1702}
1703 1703
1704bool CalendarView::checkFileVersion(QString fn) 1704bool CalendarView::checkFileVersion(QString fn)
1705{ 1705{
1706 QFileInfo finf ( fn ); 1706 QFileInfo finf ( fn );
1707 if ( !finf.exists() ) 1707 if ( !finf.exists() )
1708 return true; 1708 return true;
1709 QDateTime dt = finf.lastModified (); 1709 QDateTime dt = finf.lastModified ();
1710 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1710 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1711 //qDebug("file on disk version %s",dt.toString().latin1()); 1711 //qDebug("file on disk version %s",dt.toString().latin1());
1712 if ( dt <= loadedFileVersion ) 1712 if ( dt <= loadedFileVersion )
1713 return true; 1713 return true;
1714 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1714 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1715 i18n("KO/Pi Warning"),i18n("Overwrite"), 1715 i18n("KO/Pi Warning"),i18n("Overwrite"),
1716 i18n("Sync+save")); 1716 i18n("Sync+save"));
1717 1717
1718 if ( km == KMessageBox::Cancel ) 1718 if ( km == KMessageBox::Cancel )
1719 return false; 1719 return false;
1720 if ( km == KMessageBox::Yes ) 1720 if ( km == KMessageBox::Yes )
1721 return true; 1721 return true;
1722 1722
1723 setSyncDevice("deleteaftersync" ); 1723 setSyncDevice("deleteaftersync" );
1724 mSyncManager->mAskForPreferences = true; 1724 mSyncManager->mAskForPreferences = true;
1725 mSyncManager->mSyncAlgoPrefs = 3; 1725 mSyncManager->mSyncAlgoPrefs = 3;
1726 mSyncManager->mWriteBackFile = false; 1726 mSyncManager->mWriteBackFile = false;
1727 mSyncManager->mWriteBackExistingOnly = false; 1727 mSyncManager->mWriteBackExistingOnly = false;
1728 mSyncManager->mShowSyncSummary = false; 1728 mSyncManager->mShowSyncSummary = false;
1729 syncCalendar( fn, 3 ); 1729 syncCalendar( fn, 3 );
1730 Event * e = getLastSyncEvent(); 1730 Event * e = getLastSyncEvent();
1731 mCalendar->deleteEvent ( e ); 1731 mCalendar->deleteEvent ( e );
1732 updateView(); 1732 updateView();
1733 return true; 1733 return true;
1734} 1734}
1735 1735
1736bool CalendarView::saveCalendar( QString filename ) 1736bool CalendarView::saveCalendar( QString filename )
1737{ 1737{
1738 1738
1739 // Store back all unsaved data into calendar object 1739 // Store back all unsaved data into calendar object
1740 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1740 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1741 if ( mViewManager->currentView() ) 1741 if ( mViewManager->currentView() )
1742 mViewManager->currentView()->flushView(); 1742 mViewManager->currentView()->flushView();
1743 1743
1744 1744
1745 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1745 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1746 mStorage->setSaveFormat( new ICalFormat() ); 1746 mStorage->setSaveFormat( new ICalFormat() );
1747 mStorage->setFileName( filename ); 1747 mStorage->setFileName( filename );
1748 bool success; 1748 bool success;
1749 success = mStorage->save(); 1749 success = mStorage->save();
1750 if ( !success ) { 1750 if ( !success ) {
1751 return false; 1751 return false;
1752 } 1752 }
1753 if ( filename == MainWindow::defaultFileName() ) { 1753 if ( filename == MainWindow::defaultFileName() ) {
1754 setLoadedFileVersion( lfv ); 1754 setLoadedFileVersion( lfv );
1755 watchSavedFile(); 1755 watchSavedFile();
1756 } 1756 }
1757 return true; 1757 return true;
1758} 1758}
1759 1759
1760void CalendarView::closeCalendar() 1760void CalendarView::closeCalendar()
1761{ 1761{
1762 1762
1763 // child windows no longer valid 1763 // child windows no longer valid
1764 emit closingDown(); 1764 emit closingDown();
1765 1765
1766 mCalendar->close(); 1766 mCalendar->close();
1767 setModified(false); 1767 setModified(false);
1768 updateView(); 1768 updateView();
1769} 1769}
1770 1770
1771void CalendarView::archiveCalendar() 1771void CalendarView::archiveCalendar()
1772{ 1772{
1773 mDialogManager->showArchiveDialog(); 1773 mDialogManager->showArchiveDialog();
1774} 1774}
1775 1775
1776 1776
1777void CalendarView::readSettings() 1777void CalendarView::readSettings()
1778{ 1778{
1779 1779
1780 1780
1781 // mViewManager->showAgendaView(); 1781 // mViewManager->showAgendaView();
1782 QString str; 1782 QString str;
1783 //qDebug("CalendarView::readSettings() "); 1783 //qDebug("CalendarView::readSettings() ");
1784 // read settings from the KConfig, supplying reasonable 1784 // read settings from the KConfig, supplying reasonable
1785 // defaults where none are to be found 1785 // defaults where none are to be found
1786 KConfig *config = KOGlobals::config(); 1786 KConfig *config = KOGlobals::config();
1787#ifndef KORG_NOSPLITTER 1787#ifndef KORG_NOSPLITTER
1788 config->setGroup("KOrganizer Geometry"); 1788 config->setGroup("KOrganizer Geometry");
1789 1789
1790 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1790 QValueList<int> sizes = config->readIntListEntry("Separator1");
1791 if (sizes.count() != 2) { 1791 if (sizes.count() != 2) {
1792 sizes << mDateNavigator->minimumSizeHint().width(); 1792 sizes << mDateNavigator->minimumSizeHint().width();
1793 sizes << 300; 1793 sizes << 300;
1794 } 1794 }
1795 mPanner->setSizes(sizes); 1795 mPanner->setSizes(sizes);
1796 1796
1797 sizes = config->readIntListEntry("Separator2"); 1797 sizes = config->readIntListEntry("Separator2");
1798 if ( ( mResourceView && sizes.count() == 4 ) || 1798 if ( ( mResourceView && sizes.count() == 4 ) ||
1799 ( !mResourceView && sizes.count() == 3 ) ) { 1799 ( !mResourceView && sizes.count() == 3 ) ) {
1800 mLeftSplitter->setSizes(sizes); 1800 mLeftSplitter->setSizes(sizes);
1801 } 1801 }
1802#endif 1802#endif
1803 globalFlagBlockAgenda = 1; 1803 globalFlagBlockAgenda = 1;
1804 mViewManager->showAgendaView(); 1804 mViewManager->showAgendaView();
1805 //mViewManager->readSettings( config ); 1805 //mViewManager->readSettings( config );
1806 mTodoList->restoreLayout(config,QString("Todo Layout")); 1806 mTodoList->restoreLayout(config,QString("Todo Layout"));
1807 readFilterSettings(config); 1807 readFilterSettings(config);
1808 config->setGroup( "Views" ); 1808 config->setGroup( "Views" );
1809 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1809 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1810 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1810 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1811 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1811 else if ( dateCount == 7 ) mNavigator->selectWeek();
1812 else mNavigator->selectDates( dateCount ); 1812 else mNavigator->selectDates( dateCount );
1813 // mViewManager->readSettings( config ); 1813 // mViewManager->readSettings( config );
1814 updateConfig(); 1814 updateConfig();
1815 globalFlagBlockAgenda = 2; 1815 globalFlagBlockAgenda = 2;
1816 mViewManager->readSettings( config ); 1816 mViewManager->readSettings( config );
1817#ifdef DESKTOP_VERSION 1817#ifdef DESKTOP_VERSION
1818 config->setGroup("WidgetLayout"); 1818 config->setGroup("WidgetLayout");
1819 QStringList list; 1819 QStringList list;
1820 list = config->readListEntry("MainLayout"); 1820 list = config->readListEntry("MainLayout");
1821 int x,y,w,h; 1821 int x,y,w,h;
1822 if ( ! list.isEmpty() ) { 1822 if ( ! list.isEmpty() ) {
1823 x = list[0].toInt(); 1823 x = list[0].toInt();
1824 y = list[1].toInt(); 1824 y = list[1].toInt();
1825 w = list[2].toInt(); 1825 w = list[2].toInt();
1826 h = list[3].toInt(); 1826 h = list[3].toInt();
1827 topLevelWidget()->setGeometry(x,y,w,h); 1827 topLevelWidget()->setGeometry(x,y,w,h);
1828 1828
1829 } else { 1829 } else {
1830 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1830 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1831 } 1831 }
1832 list = config->readListEntry("EditEventLayout"); 1832 list = config->readListEntry("EditEventLayout");
1833 if ( ! list.isEmpty() ) { 1833 if ( ! list.isEmpty() ) {
1834 x = list[0].toInt(); 1834 x = list[0].toInt();
1835 y = list[1].toInt(); 1835 y = list[1].toInt();
1836 w = list[2].toInt(); 1836 w = list[2].toInt();
1837 h = list[3].toInt(); 1837 h = list[3].toInt();
1838 mEventEditor->setGeometry(x,y,w,h); 1838 mEventEditor->setGeometry(x,y,w,h);
1839 1839
1840 } 1840 }
1841 list = config->readListEntry("EditTodoLayout"); 1841 list = config->readListEntry("EditTodoLayout");
1842 if ( ! list.isEmpty() ) { 1842 if ( ! list.isEmpty() ) {
1843 x = list[0].toInt(); 1843 x = list[0].toInt();
1844 y = list[1].toInt(); 1844 y = list[1].toInt();
1845 w = list[2].toInt(); 1845 w = list[2].toInt();
1846 h = list[3].toInt(); 1846 h = list[3].toInt();
1847 mTodoEditor->setGeometry(x,y,w,h); 1847 mTodoEditor->setGeometry(x,y,w,h);
1848 1848
1849 } 1849 }
1850 list = config->readListEntry("ViewerLayout"); 1850 list = config->readListEntry("ViewerLayout");
1851 if ( ! list.isEmpty() ) { 1851 if ( ! list.isEmpty() ) {
1852 x = list[0].toInt(); 1852 x = list[0].toInt();
1853 y = list[1].toInt(); 1853 y = list[1].toInt();
1854 w = list[2].toInt(); 1854 w = list[2].toInt();
1855 h = list[3].toInt(); 1855 h = list[3].toInt();
1856 getEventViewerDialog()->setGeometry(x,y,w,h); 1856 getEventViewerDialog()->setGeometry(x,y,w,h);
1857 } 1857 }
1858#endif 1858#endif
1859 1859
1860} 1860}
1861 1861
1862 1862
1863void CalendarView::writeSettings() 1863void CalendarView::writeSettings()
1864{ 1864{
1865 // kdDebug() << "CalendarView::writeSettings" << endl; 1865 // kdDebug() << "CalendarView::writeSettings" << endl;
1866 1866
1867 KConfig *config = KOGlobals::config(); 1867 KConfig *config = KOGlobals::config();
1868 1868
1869#ifndef KORG_NOSPLITTER 1869#ifndef KORG_NOSPLITTER
1870 config->setGroup("KOrganizer Geometry"); 1870 config->setGroup("KOrganizer Geometry");
1871 1871
1872 QValueList<int> list = mPanner->sizes(); 1872 QValueList<int> list = mPanner->sizes();
1873 config->writeEntry("Separator1",list); 1873 config->writeEntry("Separator1",list);
1874 1874
1875 list = mLeftSplitter->sizes(); 1875 list = mLeftSplitter->sizes();
1876 config->writeEntry("Separator2",list); 1876 config->writeEntry("Separator2",list);
1877#endif 1877#endif
1878 1878
1879 mViewManager->writeSettings( config ); 1879 mViewManager->writeSettings( config );
1880 mTodoList->saveLayout(config,QString("Todo Layout")); 1880 mTodoList->saveLayout(config,QString("Todo Layout"));
1881 mDialogManager->writeSettings( config ); 1881 mDialogManager->writeSettings( config );
1882 //KOPrefs::instance()->usrWriteConfig(); 1882 //KOPrefs::instance()->usrWriteConfig();
1883 KOPrefs::instance()->writeConfig(); 1883 KOPrefs::instance()->writeConfig();
1884 1884
1885 writeFilterSettings(config); 1885 writeFilterSettings(config);
1886 1886
1887 config->setGroup( "Views" ); 1887 config->setGroup( "Views" );
1888 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1888 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1889 1889
1890#ifdef DESKTOP_VERSION 1890#ifdef DESKTOP_VERSION
1891 config->setGroup("WidgetLayout"); 1891 config->setGroup("WidgetLayout");
1892 QStringList list ;//= config->readListEntry("MainLayout"); 1892 QStringList list ;//= config->readListEntry("MainLayout");
1893 int x,y,w,h; 1893 int x,y,w,h;
1894 QWidget* wid; 1894 QWidget* wid;
1895 wid = topLevelWidget(); 1895 wid = topLevelWidget();
1896 x = wid->geometry().x(); 1896 x = wid->geometry().x();
1897 y = wid->geometry().y(); 1897 y = wid->geometry().y();
1898 w = wid->width(); 1898 w = wid->width();
1899 h = wid->height(); 1899 h = wid->height();
1900 list.clear(); 1900 list.clear();
1901 list << QString::number( x ); 1901 list << QString::number( x );
1902 list << QString::number( y ); 1902 list << QString::number( y );
1903 list << QString::number( w ); 1903 list << QString::number( w );
1904 list << QString::number( h ); 1904 list << QString::number( h );
1905 config->writeEntry("MainLayout",list ); 1905 config->writeEntry("MainLayout",list );
1906 1906
1907 wid = mEventEditor; 1907 wid = mEventEditor;
1908 x = wid->geometry().x(); 1908 x = wid->geometry().x();
1909 y = wid->geometry().y(); 1909 y = wid->geometry().y();
1910 w = wid->width(); 1910 w = wid->width();
1911 h = wid->height(); 1911 h = wid->height();
1912 list.clear(); 1912 list.clear();
1913 list << QString::number( x ); 1913 list << QString::number( x );
1914 list << QString::number( y ); 1914 list << QString::number( y );
1915 list << QString::number( w ); 1915 list << QString::number( w );
1916 list << QString::number( h ); 1916 list << QString::number( h );
1917 config->writeEntry("EditEventLayout",list ); 1917 config->writeEntry("EditEventLayout",list );
1918 1918
1919 wid = mTodoEditor; 1919 wid = mTodoEditor;
1920 x = wid->geometry().x(); 1920 x = wid->geometry().x();
1921 y = wid->geometry().y(); 1921 y = wid->geometry().y();
1922 w = wid->width(); 1922 w = wid->width();
1923 h = wid->height(); 1923 h = wid->height();
1924 list.clear(); 1924 list.clear();
1925 list << QString::number( x ); 1925 list << QString::number( x );
1926 list << QString::number( y ); 1926 list << QString::number( y );
1927 list << QString::number( w ); 1927 list << QString::number( w );
1928 list << QString::number( h ); 1928 list << QString::number( h );
1929 config->writeEntry("EditTodoLayout",list ); 1929 config->writeEntry("EditTodoLayout",list );
1930 wid = getEventViewerDialog(); 1930 wid = getEventViewerDialog();
1931 x = wid->geometry().x(); 1931 x = wid->geometry().x();
1932 y = wid->geometry().y(); 1932 y = wid->geometry().y();
1933 w = wid->width(); 1933 w = wid->width();
1934 h = wid->height(); 1934 h = wid->height();
1935 list.clear(); 1935 list.clear();
1936 list << QString::number( x ); 1936 list << QString::number( x );
1937 list << QString::number( y ); 1937 list << QString::number( y );
1938 list << QString::number( w ); 1938 list << QString::number( w );
1939 list << QString::number( h ); 1939 list << QString::number( h );
1940 config->writeEntry("ViewerLayout",list ); 1940 config->writeEntry("ViewerLayout",list );
1941 wid = mDialogManager->getSearchDialog(); 1941 wid = mDialogManager->getSearchDialog();
1942 if ( wid ) { 1942 if ( wid ) {
1943 x = wid->geometry().x(); 1943 x = wid->geometry().x();
1944 y = wid->geometry().y(); 1944 y = wid->geometry().y();
1945 w = wid->width(); 1945 w = wid->width();
1946 h = wid->height(); 1946 h = wid->height();
1947 list.clear(); 1947 list.clear();
1948 list << QString::number( x ); 1948 list << QString::number( x );
1949 list << QString::number( y ); 1949 list << QString::number( y );
1950 list << QString::number( w ); 1950 list << QString::number( w );
1951 list << QString::number( h ); 1951 list << QString::number( h );
1952 config->writeEntry("SearchLayout",list ); 1952 config->writeEntry("SearchLayout",list );
1953 } 1953 }
1954#endif 1954#endif
1955 1955
1956 1956
1957 config->sync(); 1957 config->sync();
1958} 1958}
1959 1959
1960void CalendarView::readFilterSettings(KConfig *config) 1960void CalendarView::readFilterSettings(KConfig *config)
1961{ 1961{
1962 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1962 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1963 1963
1964 mFilters.clear(); 1964 mFilters.clear();
1965 1965
1966 config->setGroup("General"); 1966 config->setGroup("General");
1967 QStringList filterList = config->readListEntry("CalendarFilters"); 1967 QStringList filterList = config->readListEntry("CalendarFilters");
1968 1968
1969 QStringList::ConstIterator it = filterList.begin(); 1969 QStringList::ConstIterator it = filterList.begin();
1970 QStringList::ConstIterator end = filterList.end(); 1970 QStringList::ConstIterator end = filterList.end();
1971 while(it != end) { 1971 while(it != end) {
1972 // kdDebug() << " filter: " << (*it) << endl; 1972 // kdDebug() << " filter: " << (*it) << endl;
1973 1973
1974 CalFilter *filter; 1974 CalFilter *filter;
1975 filter = new CalFilter(*it); 1975 filter = new CalFilter(*it);
1976 config->setGroup("Filter_" + (*it)); 1976 config->setGroup("Filter_" + (*it));
1977 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1977 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1978 filter->setCriteria(config->readNumEntry("Criteria",0)); 1978 filter->setCriteria(config->readNumEntry("Criteria",0));
1979 filter->setCategoryList(config->readListEntry("CategoryList")); 1979 filter->setCategoryList(config->readListEntry("CategoryList"));
1980 mFilters.append(filter); 1980 mFilters.append(filter);
1981 1981
1982 ++it; 1982 ++it;
1983 } 1983 }
1984 1984
1985 if (mFilters.count() == 0) { 1985 if (mFilters.count() == 0) {
1986 CalFilter *filter = new CalFilter(i18n("Default")); 1986 CalFilter *filter = new CalFilter(i18n("Default"));
1987 mFilters.append(filter); 1987 mFilters.append(filter);
1988 } 1988 }
1989 mFilterView->updateFilters(); 1989 mFilterView->updateFilters();
1990 config->setGroup("FilterView"); 1990 config->setGroup("FilterView");
1991 1991
1992 mFilterView->blockSignals(true); 1992 mFilterView->blockSignals(true);
1993 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1993 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1994 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1994 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1995 mFilterView->blockSignals(false); 1995 mFilterView->blockSignals(false);
1996 // We do it manually to avoid it being done twice by the above calls 1996 // We do it manually to avoid it being done twice by the above calls
1997 updateFilter(); 1997 updateFilter();
1998} 1998}
1999 1999
2000void CalendarView::writeFilterSettings(KConfig *config) 2000void CalendarView::writeFilterSettings(KConfig *config)
2001{ 2001{
2002 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2002 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2003 2003
2004 QStringList filterList; 2004 QStringList filterList;
2005 2005
2006 CalFilter *filter = mFilters.first(); 2006 CalFilter *filter = mFilters.first();
2007 while(filter) { 2007 while(filter) {
2008 // kdDebug() << " fn: " << filter->name() << endl; 2008 // kdDebug() << " fn: " << filter->name() << endl;
2009 filterList << filter->name(); 2009 filterList << filter->name();
2010 config->setGroup("Filter_" + filter->name()); 2010 config->setGroup("Filter_" + filter->name());
2011 config->writeEntry("Criteria",filter->criteria()); 2011 config->writeEntry("Criteria",filter->criteria());
2012 config->writeEntry("CategoryList",filter->categoryList()); 2012 config->writeEntry("CategoryList",filter->categoryList());
2013 filter = mFilters.next(); 2013 filter = mFilters.next();
2014 } 2014 }
2015 config->setGroup("General"); 2015 config->setGroup("General");
2016 config->writeEntry("CalendarFilters",filterList); 2016 config->writeEntry("CalendarFilters",filterList);
2017 2017
2018 config->setGroup("FilterView"); 2018 config->setGroup("FilterView");
2019 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2019 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2020 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2020 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2021} 2021}
2022 2022
2023 2023
2024void CalendarView::goToday() 2024void CalendarView::goToday()
2025{ 2025{
2026 if ( mViewManager->currentView()->isMonthView() ) 2026 if ( mViewManager->currentView()->isMonthView() )
2027 mNavigator->selectTodayMonth(); 2027 mNavigator->selectTodayMonth();
2028 else 2028 else
2029 mNavigator->selectToday(); 2029 mNavigator->selectToday();
2030} 2030}
2031 2031
2032void CalendarView::goNext() 2032void CalendarView::goNext()
2033{ 2033{
2034 mNavigator->selectNext(); 2034 mNavigator->selectNext();
2035} 2035}
2036 2036
2037void CalendarView::goPrevious() 2037void CalendarView::goPrevious()
2038{ 2038{
2039 mNavigator->selectPrevious(); 2039 mNavigator->selectPrevious();
2040} 2040}
2041void CalendarView::goNextMonth() 2041void CalendarView::goNextMonth()
2042{ 2042{
2043 mNavigator->selectNextMonth(); 2043 mNavigator->selectNextMonth();
2044} 2044}
2045 2045
2046void CalendarView::goPreviousMonth() 2046void CalendarView::goPreviousMonth()
2047{ 2047{
2048 mNavigator->selectPreviousMonth(); 2048 mNavigator->selectPreviousMonth();
2049} 2049}
2050void CalendarView::writeLocale() 2050void CalendarView::writeLocale()
2051{ 2051{
2052 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2052 //KPimGlobalPrefs::instance()->setGlobalConfig();
2053#if 0 2053#if 0
2054 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2054 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2055 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2055 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2056 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2056 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2057 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2057 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2058 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2058 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2059 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2059 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2060 dummy = KOPrefs::instance()->mUserDateFormatShort; 2060 dummy = KOPrefs::instance()->mUserDateFormatShort;
2061 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2061 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2062 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2062 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2063 KOPrefs::instance()->mDaylightsavingStart, 2063 KOPrefs::instance()->mDaylightsavingStart,
2064 KOPrefs::instance()->mDaylightsavingEnd ); 2064 KOPrefs::instance()->mDaylightsavingEnd );
2065 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2065 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2066#endif 2066#endif
2067} 2067}
2068void CalendarView::updateConfig() 2068void CalendarView::updateConfig()
2069{ 2069{
2070 writeLocale(); 2070 writeLocale();
2071 if ( KOPrefs::instance()->mUseAppColors ) 2071 if ( KOPrefs::instance()->mUseAppColors )
2072 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2072 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2073 emit configChanged(); 2073 emit configChanged();
2074 mTodoList->updateConfig(); 2074 mTodoList->updateConfig();
2075 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2075 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2076 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2076 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2077 // To make the "fill window" configurations work 2077 // To make the "fill window" configurations work
2078 //mViewManager->raiseCurrentView(); 2078 //mViewManager->raiseCurrentView();
2079} 2079}
2080 2080
2081 2081
2082void CalendarView::eventChanged(Event *event) 2082void CalendarView::eventChanged(Event *event)
2083{ 2083{
2084 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2084 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2085 //updateUnmanagedViews(); 2085 //updateUnmanagedViews();
2086} 2086}
2087 2087
2088void CalendarView::eventAdded(Event *event) 2088void CalendarView::eventAdded(Event *event)
2089{ 2089{
2090 changeEventDisplay(event,KOGlobals::EVENTADDED); 2090 changeEventDisplay(event,KOGlobals::EVENTADDED);
2091} 2091}
2092 2092
2093void CalendarView::eventToBeDeleted(Event *) 2093void CalendarView::eventToBeDeleted(Event *)
2094{ 2094{
2095 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2095 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2096} 2096}
2097 2097
2098void CalendarView::eventDeleted() 2098void CalendarView::eventDeleted()
2099{ 2099{
2100 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2100 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2101} 2101}
2102void CalendarView::changeTodoDisplay(Todo *which, int action) 2102void CalendarView::changeTodoDisplay(Todo *which, int action)
2103{ 2103{
2104 changeIncidenceDisplay((Incidence *)which, action); 2104 changeIncidenceDisplay((Incidence *)which, action);
2105 mDateNavigator->updateView(); //LR 2105 mDateNavigator->updateView(); //LR
2106 //mDialogManager->updateSearchDialog(); 2106 //mDialogManager->updateSearchDialog();
2107 2107
2108 if (which) { 2108 if (which) {
2109 mViewManager->updateWNview(); 2109 mViewManager->updateWNview();
2110 //mTodoList->updateView(); 2110 //mTodoList->updateView();
2111 } 2111 }
2112 2112
2113} 2113}
2114 2114
2115void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2115void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2116{ 2116{
2117 updateUnmanagedViews(); 2117 updateUnmanagedViews();
2118 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2118 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2119 if ( action == KOGlobals::EVENTDELETED ) { //delete 2119 if ( action == KOGlobals::EVENTDELETED ) { //delete
2120 mCalendar->checkAlarmForIncidence( 0, true ); 2120 mCalendar->checkAlarmForIncidence( 0, true );
2121 if ( mEventViewerDialog ) 2121 if ( mEventViewerDialog )
2122 mEventViewerDialog->hide(); 2122 mEventViewerDialog->hide();
2123 } 2123 }
2124 else 2124 else
2125 mCalendar->checkAlarmForIncidence( which , false ); 2125 mCalendar->checkAlarmForIncidence( which , false );
2126} 2126}
2127 2127
2128// most of the changeEventDisplays() right now just call the view's 2128// most of the changeEventDisplays() right now just call the view's
2129// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2129// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2130void CalendarView::changeEventDisplay(Event *which, int action) 2130void CalendarView::changeEventDisplay(Event *which, int action)
2131{ 2131{
2132 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2132 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2133 changeIncidenceDisplay((Incidence *)which, action); 2133 changeIncidenceDisplay((Incidence *)which, action);
2134 mDateNavigator->updateView(); 2134 mDateNavigator->updateView();
2135 //mDialogManager->updateSearchDialog(); 2135 //mDialogManager->updateSearchDialog();
2136 2136
2137 if (which) { 2137 if (which) {
2138 // If there is an event view visible update the display 2138 // If there is an event view visible update the display
2139 mViewManager->currentView()->changeEventDisplay(which,action); 2139 mViewManager->currentView()->changeEventDisplay(which,action);
2140 // TODO: check, if update needed 2140 // TODO: check, if update needed
2141 // if (which->getTodoStatus()) { 2141 // if (which->getTodoStatus()) {
2142 mTodoList->updateView(); 2142 mTodoList->updateView();
2143 // } 2143 // }
2144 } else { 2144 } else {
2145 mViewManager->currentView()->updateView(); 2145 mViewManager->currentView()->updateView();
2146 } 2146 }
2147} 2147}
2148 2148
2149 2149
2150void CalendarView::updateTodoViews() 2150void CalendarView::updateTodoViews()
2151{ 2151{
2152 mTodoList->updateView(); 2152 mTodoList->updateView();
2153 mViewManager->currentView()->updateView(); 2153 mViewManager->currentView()->updateView();
2154 2154
2155} 2155}
2156 2156
2157 2157
2158void CalendarView::updateView(const QDate &start, const QDate &end) 2158void CalendarView::updateView(const QDate &start, const QDate &end)
2159{ 2159{
2160 mTodoList->updateView(); 2160 mTodoList->updateView();
2161 mViewManager->updateView(start, end); 2161 mViewManager->updateView(start, end);
2162 //mDateNavigator->updateView(); 2162 //mDateNavigator->updateView();
2163} 2163}
2164 2164
2165void CalendarView::updateView() 2165void CalendarView::updateView()
2166{ 2166{
2167 DateList tmpList = mNavigator->selectedDates(); 2167 DateList tmpList = mNavigator->selectedDates();
2168 2168
2169 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2169 if ( KOPrefs::instance()->mHideNonStartedTodos )
2170 mTodoList->updateView(); 2170 mTodoList->updateView();
2171 // We assume that the navigator only selects consecutive days. 2171 // We assume that the navigator only selects consecutive days.
2172 updateView( tmpList.first(), tmpList.last() ); 2172 updateView( tmpList.first(), tmpList.last() );
2173} 2173}
2174 2174
2175void CalendarView::updateUnmanagedViews() 2175void CalendarView::updateUnmanagedViews()
2176{ 2176{
2177 mDateNavigator->updateDayMatrix(); 2177 mDateNavigator->updateDayMatrix();
2178} 2178}
2179 2179
2180int CalendarView::msgItemDelete(const QString name) 2180int CalendarView::msgItemDelete(const QString name)
2181{ 2181{
2182 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2182 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2183 i18n("This item will be\npermanently deleted."), 2183 i18n("This item will be\npermanently deleted."),
2184 i18n("KO/Pi Confirmation"),i18n("Delete")); 2184 i18n("KO/Pi Confirmation"),i18n("Delete"));
2185} 2185}
2186 2186
2187 2187
2188void CalendarView::edit_cut() 2188void CalendarView::edit_cut()
2189{ 2189{
2190 Event *anEvent=0; 2190 Event *anEvent=0;
2191 2191
2192 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2192 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2193 2193
2194 if (mViewManager->currentView()->isEventView()) { 2194 if (mViewManager->currentView()->isEventView()) {
2195 if ( incidence && incidence->type() == "Event" ) { 2195 if ( incidence && incidence->type() == "Event" ) {
2196 anEvent = static_cast<Event *>(incidence); 2196 anEvent = static_cast<Event *>(incidence);
2197 } 2197 }
2198 } 2198 }
2199 2199
2200 if (!anEvent) { 2200 if (!anEvent) {
2201 KNotifyClient::beep(); 2201 KNotifyClient::beep();
2202 return; 2202 return;
2203 } 2203 }
2204 DndFactory factory( mCalendar ); 2204 DndFactory factory( mCalendar );
2205 factory.cutIncidence(anEvent); 2205 factory.cutIncidence(anEvent);
2206 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2206 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2207} 2207}
2208 2208
2209void CalendarView::edit_copy() 2209void CalendarView::edit_copy()
2210{ 2210{
2211 Event *anEvent=0; 2211 Event *anEvent=0;
2212 2212
2213 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2213 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2214 2214
2215 if (mViewManager->currentView()->isEventView()) { 2215 if (mViewManager->currentView()->isEventView()) {
2216 if ( incidence && incidence->type() == "Event" ) { 2216 if ( incidence && incidence->type() == "Event" ) {
2217 anEvent = static_cast<Event *>(incidence); 2217 anEvent = static_cast<Event *>(incidence);
2218 } 2218 }
2219 } 2219 }
2220 2220
2221 if (!anEvent) { 2221 if (!anEvent) {
2222 KNotifyClient::beep(); 2222 KNotifyClient::beep();
2223 return; 2223 return;
2224 } 2224 }
2225 DndFactory factory( mCalendar ); 2225 DndFactory factory( mCalendar );
2226 factory.copyIncidence(anEvent); 2226 factory.copyIncidence(anEvent);
2227} 2227}
2228 2228
2229void CalendarView::edit_paste() 2229void CalendarView::edit_paste()
2230{ 2230{
2231 QDate date = mNavigator->selectedDates().first(); 2231 QDate date = mNavigator->selectedDates().first();
2232 2232
2233 DndFactory factory( mCalendar ); 2233 DndFactory factory( mCalendar );
2234 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2234 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2235 2235
2236 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2236 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2237} 2237}
2238 2238
2239void CalendarView::edit_options() 2239void CalendarView::edit_options()
2240{ 2240{
2241 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2241 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2242 emit save(); 2242 emit save();
2243 emit saveStopTimer(); 2243 emit saveStopTimer();
2244 mDialogManager->showOptionsDialog(); 2244 mDialogManager->showOptionsDialog();
2245 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2245 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2246 emit saveStopTimer(); 2246 emit saveStopTimer();
2247 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2247 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2248 i18n("Timezone settings"),i18n("Reload"))) { 2248 i18n("Timezone settings"),i18n("Reload"))) {
2249 qDebug("KO: TZ reload cancelled "); 2249 qDebug("KO: TZ reload cancelled ");
2250 return; 2250 return;
2251 } 2251 }
2252 qDebug("KO: Timezone change "); 2252 qDebug("KO: Timezone change ");
2253 openCalendar( MainWindow::defaultFileName() ); 2253 openCalendar( MainWindow::defaultFileName() );
2254 setModified(true); 2254 setModified(true);
2255 } 2255 }
2256 else 2256 else
2257 qDebug("KO: No tz change "); 2257 qDebug("KO: No tz change ");
2258 2258
2259} 2259}
2260 2260
2261 2261
2262void CalendarView::slotSelectPickerDate( QDate d) 2262void CalendarView::slotSelectPickerDate( QDate d)
2263{ 2263{
2264 mDateFrame->hide(); 2264 mDateFrame->hide();
2265 if ( mDatePickerMode == 1 ) { 2265 if ( mDatePickerMode == 1 ) {
2266 mNavigator->slotDaySelect( d ); 2266 mNavigator->slotDaySelect( d );
2267 } else if ( mDatePickerMode == 2 ) { 2267 } else if ( mDatePickerMode == 2 ) {
2268 if ( mMoveIncidence->type() == "Todo" ) { 2268 if ( mMoveIncidence->type() == "Todo" ) {
2269 Todo * to = (Todo *) mMoveIncidence; 2269 Todo * to = (Todo *) mMoveIncidence;
2270 QTime tim; 2270 QTime tim;
2271 int len = 0; 2271 int len = 0;
2272 if ( to->hasStartDate() && to->hasDueDate() ) 2272 if ( to->hasStartDate() && to->hasDueDate() )
2273 len = to->dtStart().secsTo( to->dtDue()); 2273 len = to->dtStart().secsTo( to->dtDue());
2274 if ( to->hasDueDate() ) 2274 if ( to->hasDueDate() )
2275 tim = to->dtDue().time(); 2275 tim = to->dtDue().time();
2276 else { 2276 else {
2277 tim = QTime ( 0,0,0 ); 2277 tim = QTime ( 0,0,0 );
2278 to->setFloats( true ); 2278 to->setFloats( true );
2279 to->setHasDueDate( true ); 2279 to->setHasDueDate( true );
2280 } 2280 }
2281 QDateTime dt ( d,tim ); 2281 QDateTime dt ( d,tim );
2282 to->setDtDue( dt ); 2282 to->setDtDue( dt );
2283 2283
2284 if ( to->hasStartDate() ) { 2284 if ( to->hasStartDate() ) {
2285 if ( len>0 ) 2285 if ( len>0 )
2286 to->setDtStart(to->dtDue().addSecs( -len )); 2286 to->setDtStart(to->dtDue().addSecs( -len ));
2287 else 2287 else
2288 if (to->dtStart() > to->dtDue() ) 2288 if (to->dtStart() > to->dtDue() )
2289 to->setDtStart(to->dtDue().addDays( -3 )); 2289 to->setDtStart(to->dtDue().addDays( -3 ));
2290 } 2290 }
2291 2291
2292 todoChanged( to ); 2292 todoChanged( to );
2293 } else { 2293 } else {
2294 if ( mMoveIncidence->doesRecur() ) { 2294 if ( mMoveIncidence->doesRecur() ) {
2295#if 0 2295#if 0
2296 // PENDING implement this 2296 // PENDING implement this
2297 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2297 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2298 mCalendar()->addIncidence( newInc ); 2298 mCalendar()->addIncidence( newInc );
2299 if ( mMoveIncidence->type() == "Todo" ) 2299 if ( mMoveIncidence->type() == "Todo" )
2300 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2300 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2301 else 2301 else
2302 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2302 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2303 mMoveIncidence = newInc; 2303 mMoveIncidence = newInc;
2304 2304
2305#endif 2305#endif
2306 } 2306 }
2307 QTime tim = mMoveIncidence->dtStart().time(); 2307 QTime tim = mMoveIncidence->dtStart().time();
2308 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2308 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2309 QDateTime dt ( d,tim ); 2309 QDateTime dt ( d,tim );
2310 mMoveIncidence->setDtStart( dt ); 2310 mMoveIncidence->setDtStart( dt );
2311 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2311 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2312 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2312 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2313 } 2313 }
2314 2314
2315 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2315 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2316 } 2316 }
2317} 2317}
2318 2318
2319void CalendarView::removeCategories() 2319void CalendarView::removeCategories()
2320{ 2320{
2321 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2321 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2322 QStringList catList = KOPrefs::instance()->mCustomCategories; 2322 QStringList catList = KOPrefs::instance()->mCustomCategories;
2323 QStringList catIncList; 2323 QStringList catIncList;
2324 QStringList newCatList; 2324 QStringList newCatList;
2325 Incidence* inc = incList.first(); 2325 Incidence* inc = incList.first();
2326 int i; 2326 int i;
2327 int count = 0; 2327 int count = 0;
2328 while ( inc ) { 2328 while ( inc ) {
2329 newCatList.clear(); 2329 newCatList.clear();
2330 catIncList = inc->categories() ; 2330 catIncList = inc->categories() ;
2331 for( i = 0; i< catIncList.count(); ++i ) { 2331 for( i = 0; i< catIncList.count(); ++i ) {
2332 if ( catList.contains (catIncList[i])) 2332 if ( catList.contains (catIncList[i]))
2333 newCatList.append( catIncList[i] ); 2333 newCatList.append( catIncList[i] );
2334 } 2334 }
2335 newCatList.sort(); 2335 newCatList.sort();
2336 inc->setCategories( newCatList.join(",") ); 2336 inc->setCategories( newCatList.join(",") );
2337 inc = incList.next(); 2337 inc = incList.next();
2338 } 2338 }
2339} 2339}
2340 2340
2341int CalendarView::addCategories() 2341int CalendarView::addCategories()
2342{ 2342{
2343 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2343 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2344 QStringList catList = KOPrefs::instance()->mCustomCategories; 2344 QStringList catList = KOPrefs::instance()->mCustomCategories;
2345 QStringList catIncList; 2345 QStringList catIncList;
2346 Incidence* inc = incList.first(); 2346 Incidence* inc = incList.first();
2347 int i; 2347 int i;
2348 int count = 0; 2348 int count = 0;
2349 while ( inc ) { 2349 while ( inc ) {
2350 catIncList = inc->categories() ; 2350 catIncList = inc->categories() ;
2351 for( i = 0; i< catIncList.count(); ++i ) { 2351 for( i = 0; i< catIncList.count(); ++i ) {
2352 if ( !catList.contains (catIncList[i])) { 2352 if ( !catList.contains (catIncList[i])) {
2353 catList.append( catIncList[i] ); 2353 catList.append( catIncList[i] );
2354 //qDebug("add cat %s ", catIncList[i].latin1()); 2354 //qDebug("add cat %s ", catIncList[i].latin1());
2355 ++count; 2355 ++count;
2356 } 2356 }
2357 } 2357 }
2358 inc = incList.next(); 2358 inc = incList.next();
2359 } 2359 }
2360 catList.sort(); 2360 catList.sort();
2361 KOPrefs::instance()->mCustomCategories = catList; 2361 KOPrefs::instance()->mCustomCategories = catList;
2362 return count; 2362 return count;
2363} 2363}
2364 2364
2365void CalendarView::manageCategories() 2365void CalendarView::manageCategories()
2366{ 2366{
2367 KOCatPrefs* cp = new KOCatPrefs(); 2367 KOCatPrefs* cp = new KOCatPrefs();
2368 cp->show(); 2368 cp->show();
2369 int w =cp->sizeHint().width() ; 2369 int w =cp->sizeHint().width() ;
2370 int h = cp->sizeHint().height() ; 2370 int h = cp->sizeHint().height() ;
2371 int dw = QApplication::desktop()->width(); 2371 int dw = QApplication::desktop()->width();
2372 int dh = QApplication::desktop()->height(); 2372 int dh = QApplication::desktop()->height();
2373 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2373 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2374 if ( !cp->exec() ) { 2374 if ( !cp->exec() ) {
2375 delete cp; 2375 delete cp;
2376 return; 2376 return;
2377 } 2377 }
2378 int count = 0; 2378 int count = 0;
2379 if ( cp->addCat() ) { 2379 if ( cp->addCat() ) {
2380 count = addCategories(); 2380 count = addCategories();
2381 if ( count ) { 2381 if ( count ) {
2382 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2382 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2383 writeSettings(); 2383 writeSettings();
2384 } else 2384 } else
2385 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2385 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2386 } else { 2386 } else {
2387 removeCategories(); 2387 removeCategories();
2388 updateView(); 2388 updateView();
2389 } 2389 }
2390 delete cp; 2390 delete cp;
2391} 2391}
2392 2392
2393void CalendarView::beamIncidence(Incidence * Inc) 2393void CalendarView::beamIncidence(Incidence * Inc)
2394{ 2394{
2395 QPtrList<Incidence> delSel ; 2395 QPtrList<Incidence> delSel ;
2396 delSel.append(Inc); 2396 delSel.append(Inc);
2397 beamIncidenceList( delSel ); 2397 beamIncidenceList( delSel );
2398} 2398}
2399void CalendarView::beamCalendar() 2399void CalendarView::beamCalendar()
2400{ 2400{
2401 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2401 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2402 //qDebug("beamCalendar() "); 2402 //qDebug("beamCalendar() ");
2403 beamIncidenceList( delSel ); 2403 beamIncidenceList( delSel );
2404} 2404}
2405void CalendarView::beamFilteredCalendar() 2405void CalendarView::beamFilteredCalendar()
2406{ 2406{
2407 QPtrList<Incidence> delSel = mCalendar->incidences(); 2407 QPtrList<Incidence> delSel = mCalendar->incidences();
2408 //qDebug("beamFilteredCalendar() "); 2408 //qDebug("beamFilteredCalendar() ");
2409 beamIncidenceList( delSel ); 2409 beamIncidenceList( delSel );
2410} 2410}
2411void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2411void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2412{ 2412{
2413 if ( beamDialog->exec () == QDialog::Rejected ) 2413 if ( beamDialog->exec () == QDialog::Rejected )
2414 return; 2414 return;
2415#ifdef DESKTOP_VERSION 2415#ifdef DESKTOP_VERSION
2416 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2416 QString fn = locateLocal( "tmp", "kopibeamfile" );
2417#else 2417#else
2418 QString fn = "/tmp/kopibeamfile"; 2418 QString fn = "/tmp/kopibeamfile";
2419#endif 2419#endif
2420 QString mes; 2420 QString mes;
2421 bool createbup = true; 2421 bool createbup = true;
2422 if ( createbup ) { 2422 if ( createbup ) {
2423 QString description = "\n"; 2423 QString description = "\n";
2424 CalendarLocal* cal = new CalendarLocal(); 2424 CalendarLocal* cal = new CalendarLocal();
2425 if ( beamDialog->beamLocal() ) 2425 if ( beamDialog->beamLocal() )
2426 cal->setLocalTime(); 2426 cal->setLocalTime();
2427 else 2427 else
2428 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2428 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2429 Incidence *incidence = delSel.first(); 2429 Incidence *incidence = delSel.first();
2430 bool addText = false; 2430 bool addText = false;
2431 if ( delSel.count() < 10 ) 2431 if ( delSel.count() < 10 )
2432 addText = true; 2432 addText = true;
2433 else { 2433 else {
2434 description.sprintf(i18n(" %d items?"),delSel.count() ); 2434 description.sprintf(i18n(" %d items?"),delSel.count() );
2435 } 2435 }
2436 while ( incidence ) { 2436 while ( incidence ) {
2437 Incidence *in = incidence->clone(); 2437 Incidence *in = incidence->clone();
2438 if ( ! in->summary().isEmpty() ) { 2438 if ( ! in->summary().isEmpty() ) {
2439 in->setDescription(""); 2439 in->setDescription("");
2440 } else { 2440 } else {
2441 in->setSummary( in->description().left(20)); 2441 in->setSummary( in->description().left(20));
2442 in->setDescription(""); 2442 in->setDescription("");
2443 } 2443 }
2444 if ( addText ) 2444 if ( addText )
2445 description += in->summary() + "\n"; 2445 description += in->summary() + "\n";
2446 cal->addIncidence( in ); 2446 cal->addIncidence( in );
2447 incidence = delSel.next(); 2447 incidence = delSel.next();
2448 } 2448 }
2449 if ( beamDialog->beamVcal() ) { 2449 if ( beamDialog->beamVcal() ) {
2450 fn += ".vcs"; 2450 fn += ".vcs";
2451 FileStorage storage( cal, fn, new VCalFormat ); 2451 FileStorage storage( cal, fn, new VCalFormat );
2452 storage.save(); 2452 storage.save();
2453 } else { 2453 } else {
2454 fn += ".ics"; 2454 fn += ".ics";
2455 FileStorage storage( cal, fn, new ICalFormat( ) ); 2455 FileStorage storage( cal, fn, new ICalFormat( ) );
2456 storage.save(); 2456 storage.save();
2457 } 2457 }
2458 delete cal; 2458 delete cal;
2459 mes = i18n("KO/Pi: Ready for beaming"); 2459 mes = i18n("KO/Pi: Ready for beaming");
2460 topLevelWidget()->setCaption(mes); 2460 topLevelWidget()->setCaption(mes);
2461 KApplication::convert2latin1( fn ); 2461 KApplication::convert2latin1( fn );
2462#ifndef DESKTOP_VERSION 2462#ifndef DESKTOP_VERSION
2463 Ir *ir = new Ir( this ); 2463 Ir *ir = new Ir( this );
2464 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2464 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2465 ir->send( fn, description, "text/x-vCalendar" ); 2465 ir->send( fn, description, "text/x-vCalendar" );
2466#endif 2466#endif
2467 } 2467 }
2468} 2468}
2469void CalendarView::beamDone( Ir *ir ) 2469void CalendarView::beamDone( Ir *ir )
2470{ 2470{
2471#ifndef DESKTOP_VERSION 2471#ifndef DESKTOP_VERSION
2472 delete ir; 2472 delete ir;
2473#endif 2473#endif
2474 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2474 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2475 topLevelWidget()->raise(); 2475 topLevelWidget()->raise();
2476} 2476}
2477 2477
2478void CalendarView::moveIncidence(Incidence * inc ) 2478void CalendarView::moveIncidence(Incidence * inc )
2479{ 2479{
2480 if ( !inc ) return; 2480 if ( !inc ) return;
2481 showDatePickerPopup(); 2481 showDatePickerPopup();
2482 mDatePickerMode = 2; 2482 mDatePickerMode = 2;
2483 mMoveIncidence = inc ; 2483 mMoveIncidence = inc ;
2484 QDate da; 2484 QDate da;
2485 if ( mMoveIncidence->type() == "Todo" ) { 2485 if ( mMoveIncidence->type() == "Todo" ) {
2486 Todo * to = (Todo *) mMoveIncidence; 2486 Todo * to = (Todo *) mMoveIncidence;
2487 if ( to->hasDueDate() ) 2487 if ( to->hasDueDate() )
2488 da = to->dtDue().date(); 2488 da = to->dtDue().date();
2489 else 2489 else
2490 da = QDate::currentDate(); 2490 da = QDate::currentDate();
2491 } else { 2491 } else {
2492 da = mMoveIncidence->dtStart().date(); 2492 da = mMoveIncidence->dtStart().date();
2493 } 2493 }
2494 //PENDING set date for recurring incidence to date of recurrence 2494 //PENDING set date for recurring incidence to date of recurrence
2495 //mMoveIncidenceOldDate; 2495 //mMoveIncidenceOldDate;
2496 mDatePicker->setDate( da ); 2496 mDatePicker->setDate( da );
2497} 2497}
2498void CalendarView::showDatePickerPopup() 2498void CalendarView::showDatePickerPopup()
2499{ 2499{
2500 if ( mDateFrame->isVisible() ) 2500 if ( mDateFrame->isVisible() )
2501 mDateFrame->hide(); 2501 mDateFrame->hide();
2502 else { 2502 else {
2503 int offX = 0, offY = 0; 2503 int offX = 0, offY = 0;
2504#ifdef DESKTOP_VERSION 2504#ifdef DESKTOP_VERSION
2505 int w =mDatePicker->sizeHint().width() ; 2505 int w =mDatePicker->sizeHint().width() ;
2506 int h = mDatePicker->sizeHint().height() ; 2506 int h = mDatePicker->sizeHint().height() ;
2507 int dw = topLevelWidget()->width(); 2507 int dw = topLevelWidget()->width();
2508 int dh = topLevelWidget()->height(); 2508 int dh = topLevelWidget()->height();
2509 offX = topLevelWidget()->x(); 2509 offX = topLevelWidget()->x();
2510 offY = topLevelWidget()->y(); 2510 offY = topLevelWidget()->y();
2511#else 2511#else
2512 int w =mDatePicker->sizeHint().width() ; 2512 int w =mDatePicker->sizeHint().width() ;
2513 int h = mDatePicker->sizeHint().height() ; 2513 int h = mDatePicker->sizeHint().height() ;
2514 int dw = QApplication::desktop()->width(); 2514 int dw = QApplication::desktop()->width();
2515 int dh = QApplication::desktop()->height(); 2515 int dh = QApplication::desktop()->height();
2516#endif 2516#endif
2517 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2517 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2518 mDateFrame->show(); 2518 mDateFrame->show();
2519 } 2519 }
2520} 2520}
2521void CalendarView::showDatePicker( ) 2521void CalendarView::showDatePicker( )
2522{ 2522{
2523 showDatePickerPopup(); 2523 showDatePickerPopup();
2524 mDatePickerMode = 1; 2524 mDatePickerMode = 1;
2525 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2525 mDatePicker->setDate( mNavigator->selectedDates().first() );
2526} 2526}
2527 2527
2528void CalendarView::showEventEditor() 2528void CalendarView::showEventEditor()
2529{ 2529{
2530#ifdef DESKTOP_VERSION 2530#ifdef DESKTOP_VERSION
2531 int x,y,w,h; 2531 int x,y,w,h;
2532 x = mEventEditor->geometry().x(); 2532 x = mEventEditor->geometry().x();
2533 y = mEventEditor->geometry().y(); 2533 y = mEventEditor->geometry().y();
2534 w = mEventEditor->width(); 2534 w = mEventEditor->width();
2535 h = mEventEditor->height(); 2535 h = mEventEditor->height();
2536 mEventEditor->show(); 2536 mEventEditor->show();
2537 mEventEditor->setGeometry(x,y,w,h); 2537 mEventEditor->setGeometry(x,y,w,h);
2538#else 2538#else
2539 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2539 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2540 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2540 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2541 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2541 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2542 qApp->processEvents(); 2542 qApp->processEvents();
2543 delete mEventEditor; 2543 delete mEventEditor;
2544 mEventEditor = mDialogManager->getEventEditor(); 2544 mEventEditor = mDialogManager->getEventEditor();
2545 topLevelWidget()->setCaption( i18n("") ); 2545 topLevelWidget()->setCaption( i18n("") );
2546 } 2546 }
2547 mEventEditor->showMaximized(); 2547 mEventEditor->showMaximized();
2548#endif 2548#endif
2549} 2549}
2550void CalendarView::showTodoEditor() 2550void CalendarView::showTodoEditor()
2551{ 2551{
2552#ifdef DESKTOP_VERSION 2552#ifdef DESKTOP_VERSION
2553 int x,y,w,h; 2553 int x,y,w,h;
2554 x = mTodoEditor->geometry().x(); 2554 x = mTodoEditor->geometry().x();
2555 y = mTodoEditor->geometry().y(); 2555 y = mTodoEditor->geometry().y();
2556 w = mTodoEditor->width(); 2556 w = mTodoEditor->width();
2557 h = mTodoEditor->height(); 2557 h = mTodoEditor->height();
2558 mTodoEditor->show(); 2558 mTodoEditor->show();
2559 mTodoEditor->setGeometry(x,y,w,h); 2559 mTodoEditor->setGeometry(x,y,w,h);
2560#else 2560#else
2561 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2561 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2562 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2562 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2563 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2563 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2564 qApp->processEvents(); 2564 qApp->processEvents();
2565 delete mTodoEditor; 2565 delete mTodoEditor;
2566 mTodoEditor = mDialogManager->getTodoEditor(); 2566 mTodoEditor = mDialogManager->getTodoEditor();
2567 topLevelWidget()->setCaption( i18n("") ); 2567 topLevelWidget()->setCaption( i18n("") );
2568 } 2568 }
2569 mTodoEditor->showMaximized(); 2569 mTodoEditor->showMaximized();
2570#endif 2570#endif
2571} 2571}
2572 2572
2573void CalendarView::cloneIncidence() 2573void CalendarView::cloneIncidence()
2574{ 2574{
2575 Incidence *incidence = currentSelection(); 2575 Incidence *incidence = currentSelection();
2576 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2576 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2577 if ( incidence ) { 2577 if ( incidence ) {
2578 cloneIncidence(incidence); 2578 cloneIncidence(incidence);
2579 } 2579 }
2580} 2580}
2581void CalendarView::moveIncidence() 2581void CalendarView::moveIncidence()
2582{ 2582{
2583 Incidence *incidence = currentSelection(); 2583 Incidence *incidence = currentSelection();
2584 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2584 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2585 if ( incidence ) { 2585 if ( incidence ) {
2586 moveIncidence(incidence); 2586 moveIncidence(incidence);
2587 } 2587 }
2588} 2588}
2589void CalendarView::beamIncidence() 2589void CalendarView::beamIncidence()
2590{ 2590{
2591 Incidence *incidence = currentSelection(); 2591 Incidence *incidence = currentSelection();
2592 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2592 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2593 if ( incidence ) { 2593 if ( incidence ) {
2594 beamIncidence(incidence); 2594 beamIncidence(incidence);
2595 } 2595 }
2596} 2596}
2597void CalendarView::toggleCancelIncidence() 2597void CalendarView::toggleCancelIncidence()
2598{ 2598{
2599 Incidence *incidence = currentSelection(); 2599 Incidence *incidence = currentSelection();
2600 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2600 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2601 if ( incidence ) { 2601 if ( incidence ) {
2602 cancelIncidence(incidence); 2602 cancelIncidence(incidence);
2603 } 2603 }
2604} 2604}
2605 2605
2606 2606
2607void CalendarView::cancelIncidence(Incidence * inc ) 2607void CalendarView::cancelIncidence(Incidence * inc )
2608{ 2608{
2609 inc->setCancelled( ! inc->cancelled() ); 2609 inc->setCancelled( ! inc->cancelled() );
2610 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2610 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2611 updateView(); 2611 updateView();
2612} 2612}
2613void CalendarView::cloneIncidence(Incidence * orgInc ) 2613void CalendarView::cloneIncidence(Incidence * orgInc )
2614{ 2614{
2615 Incidence * newInc = orgInc->clone(); 2615 Incidence * newInc = orgInc->clone();
2616 newInc->recreate(); 2616 newInc->recreate();
2617 2617
2618 if ( newInc->type() == "Todo" ) { 2618 if ( newInc->type() == "Todo" ) {
2619 Todo* t = (Todo*) newInc; 2619 Todo* t = (Todo*) newInc;
2620 showTodoEditor(); 2620 showTodoEditor();
2621 mTodoEditor->editTodo( t ); 2621 mTodoEditor->editTodo( t );
2622 if ( mTodoEditor->exec() ) { 2622 if ( mTodoEditor->exec() ) {
2623 mCalendar->addTodo( t ); 2623 mCalendar->addTodo( t );
2624 updateView(); 2624 updateView();
2625 } else { 2625 } else {
2626 delete t; 2626 delete t;
2627 } 2627 }
2628 } 2628 }
2629 else { 2629 else {
2630 Event* e = (Event*) newInc; 2630 Event* e = (Event*) newInc;
2631 showEventEditor(); 2631 showEventEditor();
2632 mEventEditor->editEvent( e ); 2632 mEventEditor->editEvent( e );
2633 if ( mEventEditor->exec() ) { 2633 if ( mEventEditor->exec() ) {
2634 mCalendar->addEvent( e ); 2634 mCalendar->addEvent( e );
2635 updateView(); 2635 updateView();
2636 } else { 2636 } else {
2637 delete e; 2637 delete e;
2638 } 2638 }
2639 } 2639 }
2640 setActiveWindow(); 2640 setActiveWindow();
2641} 2641}
2642 2642
2643void CalendarView::newEvent() 2643void CalendarView::newEvent()
2644{ 2644{
2645 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2645 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2646 KOAgendaView *aView = mViewManager->agendaView(); 2646 KOAgendaView *aView = mViewManager->agendaView();
2647 if (aView) { 2647 if (aView) {
2648 if (aView->selectionStart().isValid()) { 2648 if (aView->selectionStart().isValid()) {
2649 if (aView->selectedIsAllDay()) { 2649 if (aView->selectedIsAllDay()) {
2650 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2650 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2651 } else { 2651 } else {
2652 newEvent(aView->selectionStart(),aView->selectionEnd()); 2652 newEvent(aView->selectionStart(),aView->selectionEnd());
2653 } 2653 }
2654 return; 2654 return;
2655 } 2655 }
2656 } 2656 }
2657 2657
2658 QDate date = mNavigator->selectedDates().first(); 2658 QDate date = mNavigator->selectedDates().first();
2659 QDateTime current = QDateTime::currentDateTime(); 2659 QDateTime current = QDateTime::currentDateTime();
2660 if ( date <= current.date() ) { 2660 if ( date <= current.date() ) {
2661 int hour = current.time().hour() +1; 2661 int hour = current.time().hour() +1;
2662 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2662 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2663 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2663 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2664 } else 2664 } else
2665 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2665 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2666 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2666 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2667 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2667 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2668} 2668}
2669 2669
2670void CalendarView::newEvent(QDateTime fh) 2670void CalendarView::newEvent(QDateTime fh)
2671{ 2671{
2672 newEvent(fh, 2672 newEvent(fh,
2673 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2673 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2674} 2674}
2675 2675
2676void CalendarView::newEvent(QDate dt) 2676void CalendarView::newEvent(QDate dt)
2677{ 2677{
2678 newEvent(QDateTime(dt, QTime(0,0,0)), 2678 newEvent(QDateTime(dt, QTime(0,0,0)),
2679 QDateTime(dt, QTime(0,0,0)), true); 2679 QDateTime(dt, QTime(0,0,0)), true);
2680} 2680}
2681void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2681void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2682{ 2682{
2683 newEvent(fromHint, toHint, false); 2683 newEvent(fromHint, toHint, false);
2684} 2684}
2685void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2685void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2686{ 2686{
2687 2687
2688 showEventEditor(); 2688 showEventEditor();
2689 mEventEditor->newEvent(fromHint,toHint,allDay); 2689 mEventEditor->newEvent(fromHint,toHint,allDay);
2690 if ( mFilterView->filtersEnabled() ) { 2690 if ( mFilterView->filtersEnabled() ) {
2691 CalFilter *filter = mFilterView->selectedFilter(); 2691 CalFilter *filter = mFilterView->selectedFilter();
2692 if (filter && filter->showCategories()) { 2692 if (filter && filter->showCategories()) {
2693 mEventEditor->setCategories(filter->categoryList().join(",") ); 2693 mEventEditor->setCategories(filter->categoryList().join(",") );
2694 } 2694 }
2695 if ( filter ) 2695 if ( filter )
2696 mEventEditor->setSecrecy( filter->getSecrecy() ); 2696 mEventEditor->setSecrecy( filter->getSecrecy() );
2697 } 2697 }
2698 mEventEditor->exec(); 2698 mEventEditor->exec();
2699 setActiveWindow(); 2699 setActiveWindow();
2700} 2700}
2701void CalendarView::todoAdded(Todo * t) 2701void CalendarView::todoAdded(Todo * t)
2702{ 2702{
2703 2703
2704 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2704 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2705 updateTodoViews(); 2705 updateTodoViews();
2706} 2706}
2707void CalendarView::todoChanged(Todo * t) 2707void CalendarView::todoChanged(Todo * t)
2708{ 2708{
2709 emit todoModified( t, 4 ); 2709 emit todoModified( t, 4 );
2710 // updateTodoViews(); 2710 // updateTodoViews();
2711} 2711}
2712void CalendarView::todoToBeDeleted(Todo *) 2712void CalendarView::todoToBeDeleted(Todo *)
2713{ 2713{
2714 //qDebug("todoToBeDeleted(Todo *) "); 2714 //qDebug("todoToBeDeleted(Todo *) ");
2715 updateTodoViews(); 2715 updateTodoViews();
2716} 2716}
2717void CalendarView::todoDeleted() 2717void CalendarView::todoDeleted()
2718{ 2718{
2719 //qDebug(" todoDeleted()"); 2719 //qDebug(" todoDeleted()");
2720 updateTodoViews(); 2720 updateTodoViews();
2721} 2721}
2722 2722
2723 2723
2724void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2724void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2725{ 2725{
2726 showTodoEditor(); 2726 showTodoEditor();
2727 mTodoEditor->newTodo(dt,0,allday); 2727 mTodoEditor->newTodo(dt,0,allday);
2728 if ( mFilterView->filtersEnabled() ) { 2728 if ( mFilterView->filtersEnabled() ) {
2729 CalFilter *filter = mFilterView->selectedFilter(); 2729 CalFilter *filter = mFilterView->selectedFilter();
2730 if (filter && filter->showCategories()) { 2730 if (filter && filter->showCategories()) {
2731 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2731 mTodoEditor->setCategories(filter->categoryList().join(",") );
2732 } 2732 }
2733 if ( filter ) 2733 if ( filter )
2734 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2734 mTodoEditor->setSecrecy( filter->getSecrecy() );
2735 } 2735 }
2736 mTodoEditor->exec(); 2736 mTodoEditor->exec();
2737 setActiveWindow(); 2737 setActiveWindow();
2738} 2738}
2739 2739
2740void CalendarView::newTodo() 2740void CalendarView::newTodo()
2741{ 2741{
2742 newTodoDateTime( QDateTime(),true ); 2742 newTodoDateTime( QDateTime(),true );
2743} 2743}
2744 2744
2745void CalendarView::newSubTodo() 2745void CalendarView::newSubTodo()
2746{ 2746{
2747 Todo *todo = selectedTodo(); 2747 Todo *todo = selectedTodo();
2748 if ( todo ) newSubTodo( todo ); 2748 if ( todo ) newSubTodo( todo );
2749} 2749}
2750 2750
2751void CalendarView::newSubTodo(Todo *parentEvent) 2751void CalendarView::newSubTodo(Todo *parentEvent)
2752{ 2752{
2753 2753
2754 showTodoEditor(); 2754 showTodoEditor();
2755 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2755 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2756 mTodoEditor->exec(); 2756 mTodoEditor->exec();
2757 setActiveWindow(); 2757 setActiveWindow();
2758} 2758}
2759 2759
2760void CalendarView::newFloatingEvent() 2760void CalendarView::newFloatingEvent()
2761{ 2761{
2762 DateList tmpList = mNavigator->selectedDates(); 2762 DateList tmpList = mNavigator->selectedDates();
2763 QDate date = tmpList.first(); 2763 QDate date = tmpList.first();
2764 2764
2765 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2765 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2766 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2766 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2767} 2767}
2768 2768
2769 2769
2770void CalendarView::editEvent( Event *event ) 2770void CalendarView::editEvent( Event *event )
2771{ 2771{
2772 2772
2773 if ( !event ) return; 2773 if ( !event ) return;
2774 if ( event->isReadOnly() ) { 2774 if ( event->isReadOnly() ) {
2775 showEvent( event ); 2775 showEvent( event );
2776 return; 2776 return;
2777 } 2777 }
2778 showEventEditor(); 2778 showEventEditor();
2779 mEventEditor->editEvent( event , mFlagEditDescription); 2779 mEventEditor->editEvent( event , mFlagEditDescription);
2780 mEventEditor->exec(); 2780 mEventEditor->exec();
2781 setActiveWindow(); 2781 setActiveWindow();
2782 2782
2783} 2783}
2784void CalendarView::editJournal( Journal *jour ) 2784void CalendarView::editJournal( Journal *jour )
2785{ 2785{
2786 if ( !jour ) return; 2786 if ( !jour ) return;
2787 mDialogManager->hideSearchDialog(); 2787 mDialogManager->hideSearchDialog();
2788 mViewManager->showJournalView(); 2788 mViewManager->showJournalView();
2789 mNavigator->slotDaySelect( jour->dtStart().date() ); 2789 mNavigator->slotDaySelect( jour->dtStart().date() );
2790} 2790}
2791void CalendarView::editTodo( Todo *todo ) 2791void CalendarView::editTodo( Todo *todo )
2792{ 2792{
2793 if ( !todo ) return; 2793 if ( !todo ) return;
2794 2794
2795 if ( todo->isReadOnly() ) { 2795 if ( todo->isReadOnly() ) {
2796 showTodo( todo ); 2796 showTodo( todo );
2797 return; 2797 return;
2798 } 2798 }
2799 showTodoEditor(); 2799 showTodoEditor();
2800 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2800 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2801 mTodoEditor->exec(); 2801 mTodoEditor->exec();
2802 setActiveWindow(); 2802 setActiveWindow();
2803 2803
2804} 2804}
2805 2805
2806KOEventViewerDialog* CalendarView::getEventViewerDialog() 2806KOEventViewerDialog* CalendarView::getEventViewerDialog()
2807{ 2807{
2808 if ( !mEventViewerDialog ) { 2808 if ( !mEventViewerDialog ) {
2809 mEventViewerDialog = new KOEventViewerDialog(0); 2809 mEventViewerDialog = new KOEventViewerDialog(0);
2810 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2810 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2811 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2811 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2812 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2812 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2813 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2813 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2814 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2814 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2815 viewManager(), SLOT( showAgendaView( bool ) ) ); 2815 viewManager(), SLOT( showAgendaView( bool ) ) );
2816 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 2816 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
2817 this, SLOT( slotViewerClosed() ) ); 2817 this, SLOT( slotViewerClosed() ) );
2818 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2818 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2819 this, SLOT( todoChanged(Todo *) ) ); 2819 this, SLOT( todoChanged(Todo *) ) );
2820 mEventViewerDialog->resize( 640, 480 ); 2820 mEventViewerDialog->resize( 640, 480 );
2821 2821
2822 } 2822 }
2823 return mEventViewerDialog; 2823 return mEventViewerDialog;
2824} 2824}
2825void CalendarView::showEvent(Event *event) 2825void CalendarView::showEvent(Event *event)
2826{ 2826{
2827 getEventViewerDialog()->setEvent(event); 2827 getEventViewerDialog()->setEvent(event);
2828 getEventViewerDialog()->showMe(); 2828 getEventViewerDialog()->showMe();
2829} 2829}
2830 2830
2831void CalendarView::showTodo(Todo *event) 2831void CalendarView::showTodo(Todo *event)
2832{ 2832{
2833 getEventViewerDialog()->setTodo(event); 2833 getEventViewerDialog()->setTodo(event);
2834 getEventViewerDialog()->showMe(); 2834 getEventViewerDialog()->showMe();
2835} 2835}
2836void CalendarView::showJournal( Journal *jour ) 2836void CalendarView::showJournal( Journal *jour )
2837{ 2837{
2838 getEventViewerDialog()->setJournal(jour); 2838 getEventViewerDialog()->setJournal(jour);
2839 getEventViewerDialog()->showMe(); 2839 getEventViewerDialog()->showMe();
2840 2840
2841} 2841}
2842// void CalendarView::todoModified (Todo *event, int changed) 2842// void CalendarView::todoModified (Todo *event, int changed)
2843// { 2843// {
2844// // if (mDialogList.find (event) != mDialogList.end ()) { 2844// // if (mDialogList.find (event) != mDialogList.end ()) {
2845// // kdDebug() << "Todo modified and open" << endl; 2845// // kdDebug() << "Todo modified and open" << endl;
2846// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2846// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2847// // temp->modified (changed); 2847// // temp->modified (changed);
2848 2848
2849// // } 2849// // }
2850 2850
2851// mViewManager->updateView(); 2851// mViewManager->updateView();
2852// } 2852// }
2853 2853
2854void CalendarView::appointment_show() 2854void CalendarView::appointment_show()
2855{ 2855{
2856 Event *anEvent = 0; 2856 Event *anEvent = 0;
2857 2857
2858 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2858 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2859 2859
2860 if (mViewManager->currentView()->isEventView()) { 2860 if (mViewManager->currentView()->isEventView()) {
2861 if ( incidence && incidence->type() == "Event" ) { 2861 if ( incidence && incidence->type() == "Event" ) {
2862 anEvent = static_cast<Event *>(incidence); 2862 anEvent = static_cast<Event *>(incidence);
2863 } 2863 }
2864 } 2864 }
2865 2865
2866 if (!anEvent) { 2866 if (!anEvent) {
2867 KNotifyClient::beep(); 2867 KNotifyClient::beep();
2868 return; 2868 return;
2869 } 2869 }
2870 2870
2871 showEvent(anEvent); 2871 showEvent(anEvent);
2872} 2872}
2873 2873
2874void CalendarView::appointment_edit() 2874void CalendarView::appointment_edit()
2875{ 2875{
2876 Event *anEvent = 0; 2876 Event *anEvent = 0;
2877 2877
2878 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2878 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2879 2879
2880 if (mViewManager->currentView()->isEventView()) { 2880 if (mViewManager->currentView()->isEventView()) {
2881 if ( incidence && incidence->type() == "Event" ) { 2881 if ( incidence && incidence->type() == "Event" ) {
2882 anEvent = static_cast<Event *>(incidence); 2882 anEvent = static_cast<Event *>(incidence);
2883 } 2883 }
2884 } 2884 }
2885 2885
2886 if (!anEvent) { 2886 if (!anEvent) {
2887 KNotifyClient::beep(); 2887 KNotifyClient::beep();
2888 return; 2888 return;
2889 } 2889 }
2890 2890
2891 editEvent(anEvent); 2891 editEvent(anEvent);
2892} 2892}
2893 2893
2894void CalendarView::appointment_delete() 2894void CalendarView::appointment_delete()
2895{ 2895{
2896 Event *anEvent = 0; 2896 Event *anEvent = 0;
2897 2897
2898 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2898 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2899 2899
2900 if (mViewManager->currentView()->isEventView()) { 2900 if (mViewManager->currentView()->isEventView()) {
2901 if ( incidence && incidence->type() == "Event" ) { 2901 if ( incidence && incidence->type() == "Event" ) {
2902 anEvent = static_cast<Event *>(incidence); 2902 anEvent = static_cast<Event *>(incidence);
2903 } 2903 }
2904 } 2904 }
2905 2905
2906 if (!anEvent) { 2906 if (!anEvent) {
2907 KNotifyClient::beep(); 2907 KNotifyClient::beep();
2908 return; 2908 return;
2909 } 2909 }
2910 2910
2911 deleteEvent(anEvent); 2911 deleteEvent(anEvent);
2912} 2912}
2913 2913
2914void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2914void CalendarView::todo_resub( Todo * parent, Todo * sub )
2915{ 2915{
2916 if (!sub) return; 2916 if (!sub) return;
2917 if (!parent) return; 2917 if (!parent) return;
2918 if ( sub->relatedTo() ) 2918 if ( sub->relatedTo() )
2919 sub->relatedTo()->removeRelation(sub); 2919 sub->relatedTo()->removeRelation(sub);
2920 sub->setRelatedTo(parent); 2920 sub->setRelatedTo(parent);
2921 sub->setRelatedToUid(parent->uid()); 2921 sub->setRelatedToUid(parent->uid());
2922 parent->addRelation(sub); 2922 parent->addRelation(sub);
2923 sub->updated(); 2923 sub->updated();
2924 parent->updated(); 2924 parent->updated();
2925 setModified(true); 2925 setModified(true);
2926 updateView(); 2926 updateView();
2927} 2927}
2928void CalendarView::todo_unsub(Todo *anTodo ) 2928void CalendarView::todo_unsub(Todo *anTodo )
2929{ 2929{
2930 // Todo *anTodo = selectedTodo(); 2930 // Todo *anTodo = selectedTodo();
2931 if (!anTodo) return; 2931 if (!anTodo) return;
2932 if (!anTodo->relatedTo()) return; 2932 if (!anTodo->relatedTo()) return;
2933 anTodo->relatedTo()->removeRelation(anTodo); 2933 anTodo->relatedTo()->removeRelation(anTodo);
2934 anTodo->setRelatedTo(0); 2934 anTodo->setRelatedTo(0);
2935 anTodo->updated(); 2935 anTodo->updated();
2936 anTodo->setRelatedToUid(""); 2936 anTodo->setRelatedToUid("");
2937 setModified(true); 2937 setModified(true);
2938 updateView(); 2938 updateView();
2939} 2939}
2940 2940
2941void CalendarView::deleteTodo(Todo *todo) 2941void CalendarView::deleteTodo(Todo *todo)
2942{ 2942{
2943 if (!todo) { 2943 if (!todo) {
2944 KNotifyClient::beep(); 2944 KNotifyClient::beep();
2945 return; 2945 return;
2946 } 2946 }
2947 if (KOPrefs::instance()->mConfirm) { 2947 if (KOPrefs::instance()->mConfirm) {
2948 QString text = todo->summary().left(20); 2948 QString text = todo->summary().left(20);
2949 if (!todo->relations().isEmpty()) { 2949 if (!todo->relations().isEmpty()) {
2950 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 2950 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
2951 2951
2952 } 2952 }
2953 switch (msgItemDelete(text)) { 2953 switch (msgItemDelete(text)) {
2954 case KMessageBox::Continue: // OK 2954 case KMessageBox::Continue: // OK
2955 bool deleteT = false; 2955 bool deleteT = false;
2956 if (!todo->relations().isEmpty()) { 2956 if (!todo->relations().isEmpty()) {
2957 deleteT = removeCompletedSubTodos( todo ); 2957 deleteT = removeCompletedSubTodos( todo );
2958 } 2958 }
2959 // deleteT == true: todo already deleted in removeCompletedSubTodos 2959 // deleteT == true: todo already deleted in removeCompletedSubTodos
2960 if ( !deleteT ) { 2960 if ( !deleteT ) {
2961 checkExternalId( todo ); 2961 checkExternalId( todo );
2962 calendar()->deleteTodo(todo); 2962 calendar()->deleteTodo(todo);
2963 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2963 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2964 updateView(); 2964 updateView();
2965 } 2965 }
2966 break; 2966 break;
2967 } // switch 2967 } // switch
2968 } else { 2968 } else {
2969 checkExternalId( todo ); 2969 checkExternalId( todo );
2970 mCalendar->deleteTodo(todo); 2970 mCalendar->deleteTodo(todo);
2971 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2971 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2972 updateView(); 2972 updateView();
2973 } 2973 }
2974 2974
2975 emit updateSearchDialog(); 2975 emit updateSearchDialog();
2976} 2976}
2977void CalendarView::deleteJournal(Journal *jour) 2977void CalendarView::deleteJournal(Journal *jour)
2978{ 2978{
2979 if (!jour) { 2979 if (!jour) {
2980 KNotifyClient::beep(); 2980 KNotifyClient::beep();
2981 return; 2981 return;
2982 } 2982 }
2983 if (KOPrefs::instance()->mConfirm) { 2983 if (KOPrefs::instance()->mConfirm) {
2984 switch (msgItemDelete( jour->description().left(20))) { 2984 switch (msgItemDelete( jour->description().left(20))) {
2985 case KMessageBox::Continue: // OK 2985 case KMessageBox::Continue: // OK
2986 calendar()->deleteJournal(jour); 2986 calendar()->deleteJournal(jour);
2987 updateView(); 2987 updateView();
2988 break; 2988 break;
2989 } // switch 2989 } // switch
2990 } else { 2990 } else {
2991 calendar()->deleteJournal(jour);; 2991 calendar()->deleteJournal(jour);;
2992 updateView(); 2992 updateView();
2993 } 2993 }
2994 emit updateSearchDialog(); 2994 emit updateSearchDialog();
2995} 2995}
2996 2996
2997void CalendarView::deleteEvent(Event *anEvent) 2997void CalendarView::deleteEvent(Event *anEvent)
2998{ 2998{
2999 if (!anEvent) { 2999 if (!anEvent) {
3000 KNotifyClient::beep(); 3000 KNotifyClient::beep();
3001 return; 3001 return;
3002 } 3002 }
3003 3003
3004 if (anEvent->recurrence()->doesRecur()) { 3004 if (anEvent->recurrence()->doesRecur()) {
3005 QDate itemDate = mViewManager->currentSelectionDate(); 3005 QDate itemDate = mViewManager->currentSelectionDate();
3006 int km; 3006 int km;
3007 if (!itemDate.isValid()) { 3007 if (!itemDate.isValid()) {
3008 //kdDebug() << "Date Not Valid" << endl; 3008 //kdDebug() << "Date Not Valid" << endl;
3009 if (KOPrefs::instance()->mConfirm) { 3009 if (KOPrefs::instance()->mConfirm) {
3010 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3010 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3011 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3011 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3012 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3012 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3013 if ( km == KMessageBox::Continue ) 3013 if ( km == KMessageBox::Continue )
3014 km = KMessageBox::No; // No = all below 3014 km = KMessageBox::No; // No = all below
3015 } else 3015 } else
3016 km = KMessageBox::No; 3016 km = KMessageBox::No;
3017 } else { 3017 } else {
3018 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3018 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3019 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3019 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3020 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3020 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3021 i18n("KO/Pi Confirmation"),i18n("Current"), 3021 i18n("KO/Pi Confirmation"),i18n("Current"),
3022 i18n("All")); 3022 i18n("All"));
3023 } 3023 }
3024 switch(km) { 3024 switch(km) {
3025 3025
3026 case KMessageBox::No: // Continue // all 3026 case KMessageBox::No: // Continue // all
3027 //qDebug("KMessageBox::No "); 3027 //qDebug("KMessageBox::No ");
3028 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3028 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3029 schedule(Scheduler::Cancel,anEvent); 3029 schedule(Scheduler::Cancel,anEvent);
3030 3030
3031 checkExternalId( anEvent); 3031 checkExternalId( anEvent);
3032 mCalendar->deleteEvent(anEvent); 3032 mCalendar->deleteEvent(anEvent);
3033 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3033 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3034 break; 3034 break;
3035 3035
3036 // Disabled because it does not work 3036 // Disabled because it does not work
3037 //#if 0 3037 //#if 0
3038 case KMessageBox::Yes: // just this one 3038 case KMessageBox::Yes: // just this one
3039 //QDate qd = mNavigator->selectedDates().first(); 3039 //QDate qd = mNavigator->selectedDates().first();
3040 //if (!qd.isValid()) { 3040 //if (!qd.isValid()) {
3041 // kdDebug() << "no date selected, or invalid date" << endl; 3041 // kdDebug() << "no date selected, or invalid date" << endl;
3042 // KNotifyClient::beep(); 3042 // KNotifyClient::beep();
3043 // return; 3043 // return;
3044 //} 3044 //}
3045 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3045 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3046 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3046 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3047 anEvent->addExDate(itemDate); 3047 anEvent->addExDate(itemDate);
3048 int duration = anEvent->recurrence()->duration(); 3048 int duration = anEvent->recurrence()->duration();
3049 if ( duration > 0 ) { 3049 if ( duration > 0 ) {
3050 anEvent->recurrence()->setDuration( duration - 1 ); 3050 anEvent->recurrence()->setDuration( duration - 1 );
3051 } 3051 }
3052 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3052 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3053 } 3053 }
3054 break; 3054 break;
3055 //#endif 3055 //#endif
3056 } // switch 3056 } // switch
3057 } else { 3057 } else {
3058 if (KOPrefs::instance()->mConfirm) { 3058 if (KOPrefs::instance()->mConfirm) {
3059 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3059 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3060 i18n("\nAre you sure you want\nto delete this event?"), 3060 i18n("\nAre you sure you want\nto delete this event?"),
3061 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3061 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3062 case KMessageBox::Continue: // OK 3062 case KMessageBox::Continue: // OK
3063 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3063 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3064 schedule(Scheduler::Cancel,anEvent); 3064 schedule(Scheduler::Cancel,anEvent);
3065 checkExternalId( anEvent); 3065 checkExternalId( anEvent);
3066 mCalendar->deleteEvent(anEvent); 3066 mCalendar->deleteEvent(anEvent);
3067 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3067 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3068 break; 3068 break;
3069 } // switch 3069 } // switch
3070 } else { 3070 } else {
3071 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3071 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3072 schedule(Scheduler::Cancel,anEvent); 3072 schedule(Scheduler::Cancel,anEvent);
3073 checkExternalId( anEvent); 3073 checkExternalId( anEvent);
3074 mCalendar->deleteEvent(anEvent); 3074 mCalendar->deleteEvent(anEvent);
3075 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3075 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3076 } 3076 }
3077 } // if-else 3077 } // if-else
3078 emit updateSearchDialog(); 3078 emit updateSearchDialog();
3079} 3079}
3080 3080
3081bool CalendarView::deleteEvent(const QString &uid) 3081bool CalendarView::deleteEvent(const QString &uid)
3082{ 3082{
3083 Event *ev = mCalendar->event(uid); 3083 Event *ev = mCalendar->event(uid);
3084 if (ev) { 3084 if (ev) {
3085 deleteEvent(ev); 3085 deleteEvent(ev);
3086 return true; 3086 return true;
3087 } else { 3087 } else {
3088 return false; 3088 return false;
3089 } 3089 }
3090} 3090}
3091 3091
3092/*****************************************************************************/ 3092/*****************************************************************************/
3093 3093
3094void CalendarView::action_mail() 3094void CalendarView::action_mail()
3095{ 3095{
3096#ifndef KORG_NOMAIL 3096#ifndef KORG_NOMAIL
3097 KOMailClient mailClient; 3097 KOMailClient mailClient;
3098 3098
3099 Incidence *incidence = currentSelection(); 3099 Incidence *incidence = currentSelection();
3100 3100
3101 if (!incidence) { 3101 if (!incidence) {
3102 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3102 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3103 return; 3103 return;
3104 } 3104 }
3105 if(incidence->attendeeCount() == 0 ) { 3105 if(incidence->attendeeCount() == 0 ) {
3106 KMessageBox::sorry(this, 3106 KMessageBox::sorry(this,
3107 i18n("Can't generate mail:\nNo attendees defined.\n")); 3107 i18n("Can't generate mail:\nNo attendees defined.\n"));
3108 return; 3108 return;
3109 } 3109 }
3110 3110
3111 CalendarLocal cal_tmp; 3111 CalendarLocal cal_tmp;
3112 Event *event = 0; 3112 Event *event = 0;
3113 Event *ev = 0; 3113 Event *ev = 0;
3114 if ( incidence && incidence->type() == "Event" ) { 3114 if ( incidence && incidence->type() == "Event" ) {
3115 event = static_cast<Event *>(incidence); 3115 event = static_cast<Event *>(incidence);
3116 ev = new Event(*event); 3116 ev = new Event(*event);
3117 cal_tmp.addEvent(ev); 3117 cal_tmp.addEvent(ev);
3118 } 3118 }
3119 ICalFormat mForm(); 3119 ICalFormat mForm();
3120 QString attachment = mForm.toString( &cal_tmp ); 3120 QString attachment = mForm.toString( &cal_tmp );
3121 if (ev) delete(ev); 3121 if (ev) delete(ev);
3122 3122
3123 mailClient.mailAttendees(currentSelection(), attachment); 3123 mailClient.mailAttendees(currentSelection(), attachment);
3124 3124
3125#endif 3125#endif
3126 3126
3127#if 0 3127#if 0
3128 Event *anEvent = 0; 3128 Event *anEvent = 0;
3129 if (mViewManager->currentView()->isEventView()) { 3129 if (mViewManager->currentView()->isEventView()) {
3130 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3130 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3131 } 3131 }
3132 3132
3133 if (!anEvent) { 3133 if (!anEvent) {
3134 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3134 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3135 return; 3135 return;
3136 } 3136 }
3137 if(anEvent->attendeeCount() == 0 ) { 3137 if(anEvent->attendeeCount() == 0 ) {
3138 KMessageBox::sorry(this, 3138 KMessageBox::sorry(this,
3139 i18n("Can't generate mail:\nNo attendees defined.\n")); 3139 i18n("Can't generate mail:\nNo attendees defined.\n"));
3140 return; 3140 return;
3141 } 3141 }
3142 3142
3143 mailobject.emailEvent(anEvent); 3143 mailobject.emailEvent(anEvent);
3144#endif 3144#endif
3145} 3145}
3146 3146
3147 3147
3148void CalendarView::schedule_publish(Incidence *incidence) 3148void CalendarView::schedule_publish(Incidence *incidence)
3149{ 3149{
3150 Event *event = 0; 3150 Event *event = 0;
3151 Todo *todo = 0; 3151 Todo *todo = 0;
3152 3152
3153 if (incidence == 0) { 3153 if (incidence == 0) {
3154 incidence = mViewManager->currentView()->selectedIncidences().first(); 3154 incidence = mViewManager->currentView()->selectedIncidences().first();
3155 if (incidence == 0) { 3155 if (incidence == 0) {
3156 incidence = mTodoList->selectedIncidences().first(); 3156 incidence = mTodoList->selectedIncidences().first();
3157 } 3157 }
3158 } 3158 }
3159 if ( incidence && incidence->type() == "Event" ) { 3159 if ( incidence && incidence->type() == "Event" ) {
3160 event = static_cast<Event *>(incidence); 3160 event = static_cast<Event *>(incidence);
3161 } else { 3161 } else {
3162 if ( incidence && incidence->type() == "Todo" ) { 3162 if ( incidence && incidence->type() == "Todo" ) {
3163 todo = static_cast<Todo *>(incidence); 3163 todo = static_cast<Todo *>(incidence);
3164 } 3164 }
3165 } 3165 }
3166 3166
3167 if (!event && !todo) { 3167 if (!event && !todo) {
3168 KMessageBox::sorry(this,i18n("No event selected.")); 3168 KMessageBox::sorry(this,i18n("No event selected."));
3169 return; 3169 return;
3170 } 3170 }
3171 3171
3172 PublishDialog *publishdlg = new PublishDialog(); 3172 PublishDialog *publishdlg = new PublishDialog();
3173 if (incidence->attendeeCount()>0) { 3173 if (incidence->attendeeCount()>0) {
3174 QPtrList<Attendee> attendees = incidence->attendees(); 3174 QPtrList<Attendee> attendees = incidence->attendees();
3175 attendees.first(); 3175 attendees.first();
3176 while ( attendees.current()!=0 ) { 3176 while ( attendees.current()!=0 ) {
3177 publishdlg->addAttendee(attendees.current()); 3177 publishdlg->addAttendee(attendees.current());
3178 attendees.next(); 3178 attendees.next();
3179 } 3179 }
3180 } 3180 }
3181 bool send = true; 3181 bool send = true;
3182 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3182 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3183 if ( publishdlg->exec() != QDialog::Accepted ) 3183 if ( publishdlg->exec() != QDialog::Accepted )
3184 send = false; 3184 send = false;
3185 } 3185 }
3186 if ( send ) { 3186 if ( send ) {
3187 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3187 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3188 if ( event ) { 3188 if ( event ) {
3189 Event *ev = new Event(*event); 3189 Event *ev = new Event(*event);
3190 ev->registerObserver(0); 3190 ev->registerObserver(0);
3191 ev->clearAttendees(); 3191 ev->clearAttendees();
3192 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3192 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3193 delete(ev); 3193 delete(ev);
3194 } 3194 }
3195 } else { 3195 } else {
3196 if ( todo ) { 3196 if ( todo ) {
3197 Todo *ev = new Todo(*todo); 3197 Todo *ev = new Todo(*todo);
3198 ev->registerObserver(0); 3198 ev->registerObserver(0);
3199 ev->clearAttendees(); 3199 ev->clearAttendees();
3200 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3200 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3201 delete(ev); 3201 delete(ev);
3202 } 3202 }
3203 } 3203 }
3204 } 3204 }
3205 } 3205 }
3206 delete publishdlg; 3206 delete publishdlg;
3207} 3207}
3208 3208
3209void CalendarView::schedule_request(Incidence *incidence) 3209void CalendarView::schedule_request(Incidence *incidence)
3210{ 3210{
3211 schedule(Scheduler::Request,incidence); 3211 schedule(Scheduler::Request,incidence);
3212} 3212}
3213 3213
3214void CalendarView::schedule_refresh(Incidence *incidence) 3214void CalendarView::schedule_refresh(Incidence *incidence)
3215{ 3215{
3216 schedule(Scheduler::Refresh,incidence); 3216 schedule(Scheduler::Refresh,incidence);
3217} 3217}
3218 3218
3219void CalendarView::schedule_cancel(Incidence *incidence) 3219void CalendarView::schedule_cancel(Incidence *incidence)
3220{ 3220{
3221 schedule(Scheduler::Cancel,incidence); 3221 schedule(Scheduler::Cancel,incidence);
3222} 3222}
3223 3223
3224void CalendarView::schedule_add(Incidence *incidence) 3224void CalendarView::schedule_add(Incidence *incidence)
3225{ 3225{
3226 schedule(Scheduler::Add,incidence); 3226 schedule(Scheduler::Add,incidence);
3227} 3227}
3228 3228
3229void CalendarView::schedule_reply(Incidence *incidence) 3229void CalendarView::schedule_reply(Incidence *incidence)
3230{ 3230{
3231 schedule(Scheduler::Reply,incidence); 3231 schedule(Scheduler::Reply,incidence);
3232} 3232}
3233 3233
3234void CalendarView::schedule_counter(Incidence *incidence) 3234void CalendarView::schedule_counter(Incidence *incidence)
3235{ 3235{
3236 schedule(Scheduler::Counter,incidence); 3236 schedule(Scheduler::Counter,incidence);
3237} 3237}
3238 3238
3239void CalendarView::schedule_declinecounter(Incidence *incidence) 3239void CalendarView::schedule_declinecounter(Incidence *incidence)
3240{ 3240{
3241 schedule(Scheduler::Declinecounter,incidence); 3241 schedule(Scheduler::Declinecounter,incidence);
3242} 3242}
3243 3243
3244void CalendarView::schedule_publish_freebusy(int daysToPublish) 3244void CalendarView::schedule_publish_freebusy(int daysToPublish)
3245{ 3245{
3246 QDateTime start = QDateTime::currentDateTime(); 3246 QDateTime start = QDateTime::currentDateTime();
3247 QDateTime end = start.addDays(daysToPublish); 3247 QDateTime end = start.addDays(daysToPublish);
3248 3248
3249 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3249 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3250 freebusy->setOrganizer(KOPrefs::instance()->email()); 3250 freebusy->setOrganizer(KOPrefs::instance()->email());
3251 3251
3252 3252
3253 PublishDialog *publishdlg = new PublishDialog(); 3253 PublishDialog *publishdlg = new PublishDialog();
3254 if ( publishdlg->exec() == QDialog::Accepted ) { 3254 if ( publishdlg->exec() == QDialog::Accepted ) {
3255 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3255 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3256 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3256 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3257 delete(freebusy); 3257 delete(freebusy);
3258 } 3258 }
3259 } 3259 }
3260 delete publishdlg; 3260 delete publishdlg;
3261} 3261}
3262 3262
3263void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3263void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3264{ 3264{
3265 Event *event = 0; 3265 Event *event = 0;
3266 Todo *todo = 0; 3266 Todo *todo = 0;
3267 3267
3268 if (incidence == 0) { 3268 if (incidence == 0) {
3269 incidence = mViewManager->currentView()->selectedIncidences().first(); 3269 incidence = mViewManager->currentView()->selectedIncidences().first();
3270 if (incidence == 0) { 3270 if (incidence == 0) {
3271 incidence = mTodoList->selectedIncidences().first(); 3271 incidence = mTodoList->selectedIncidences().first();
3272 } 3272 }
3273 } 3273 }
3274 if ( incidence && incidence->type() == "Event" ) { 3274 if ( incidence && incidence->type() == "Event" ) {
3275 event = static_cast<Event *>(incidence); 3275 event = static_cast<Event *>(incidence);
3276 } 3276 }
3277 if ( incidence && incidence->type() == "Todo" ) { 3277 if ( incidence && incidence->type() == "Todo" ) {
3278 todo = static_cast<Todo *>(incidence); 3278 todo = static_cast<Todo *>(incidence);
3279 } 3279 }
3280 3280
3281 if (!event && !todo) { 3281 if (!event && !todo) {
3282 KMessageBox::sorry(this,i18n("No event selected.")); 3282 KMessageBox::sorry(this,i18n("No event selected."));
3283 return; 3283 return;
3284 } 3284 }
3285 3285
3286 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3286 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3287 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3287 KMessageBox::sorry(this,i18n("The event has no attendees."));
3288 return; 3288 return;
3289 } 3289 }
3290 3290
3291 Event *ev = 0; 3291 Event *ev = 0;
3292 if (event) ev = new Event(*event); 3292 if (event) ev = new Event(*event);
3293 Todo *to = 0; 3293 Todo *to = 0;
3294 if (todo) to = new Todo(*todo); 3294 if (todo) to = new Todo(*todo);
3295 3295
3296 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3296 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3297 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3297 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3298 if (!me) { 3298 if (!me) {
3299 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3299 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3300 return; 3300 return;
3301 } 3301 }
3302 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3302 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3303 StatusDialog *statdlg = new StatusDialog(this); 3303 StatusDialog *statdlg = new StatusDialog(this);
3304 if (!statdlg->exec()==QDialog::Accepted) return; 3304 if (!statdlg->exec()==QDialog::Accepted) return;
3305 me->setStatus( statdlg->status() ); 3305 me->setStatus( statdlg->status() );
3306 delete(statdlg); 3306 delete(statdlg);
3307 } 3307 }
3308 Attendee *menew = new Attendee(*me); 3308 Attendee *menew = new Attendee(*me);
3309 if (ev) { 3309 if (ev) {
3310 ev->clearAttendees(); 3310 ev->clearAttendees();
3311 ev->addAttendee(menew,false); 3311 ev->addAttendee(menew,false);
3312 } else { 3312 } else {
3313 if (to) { 3313 if (to) {
3314 todo->clearAttendees(); 3314 todo->clearAttendees();
3315 todo->addAttendee(menew,false); 3315 todo->addAttendee(menew,false);
3316 } 3316 }
3317 } 3317 }
3318 } 3318 }
3319 3319
3320 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3320 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3321 if (ev) { 3321 if (ev) {
3322 if ( !dlg->addMessage(ev,method) ) delete(ev); 3322 if ( !dlg->addMessage(ev,method) ) delete(ev);
3323 } else { 3323 } else {
3324 if (to) { 3324 if (to) {
3325 if ( !dlg->addMessage(to,method) ) delete(to); 3325 if ( !dlg->addMessage(to,method) ) delete(to);
3326 } 3326 }
3327 } 3327 }
3328} 3328}
3329 3329
3330void CalendarView::openAddressbook() 3330void CalendarView::openAddressbook()
3331{ 3331{
3332 KRun::runCommand("kaddressbook"); 3332 KRun::runCommand("kaddressbook");
3333} 3333}
3334 3334
3335void CalendarView::setModified(bool modified) 3335void CalendarView::setModified(bool modified)
3336{ 3336{
3337 if ( modified ) 3337 if ( modified )
3338 emit signalmodified(); 3338 emit signalmodified();
3339 if (mModified != modified) { 3339 if (mModified != modified) {
3340 mModified = modified; 3340 mModified = modified;
3341 emit modifiedChanged(mModified); 3341 emit modifiedChanged(mModified);
3342 } 3342 }
3343} 3343}
3344 3344
3345bool CalendarView::isReadOnly() 3345bool CalendarView::isReadOnly()
3346{ 3346{
3347 return mReadOnly; 3347 return mReadOnly;
3348} 3348}
3349 3349
3350void CalendarView::setReadOnly(bool readOnly) 3350void CalendarView::setReadOnly(bool readOnly)
3351{ 3351{
3352 if (mReadOnly != readOnly) { 3352 if (mReadOnly != readOnly) {
3353 mReadOnly = readOnly; 3353 mReadOnly = readOnly;
3354 emit readOnlyChanged(mReadOnly); 3354 emit readOnlyChanged(mReadOnly);
3355 } 3355 }
3356} 3356}
3357 3357
3358bool CalendarView::isModified() 3358bool CalendarView::isModified()
3359{ 3359{
3360 return mModified; 3360 return mModified;
3361} 3361}
3362 3362
3363void CalendarView::printSetup() 3363void CalendarView::printSetup()
3364{ 3364{
3365#ifndef KORG_NOPRINTER 3365#ifndef KORG_NOPRINTER
3366 createPrinter(); 3366 createPrinter();
3367 3367
3368 mCalPrinter->setupPrinter(); 3368 mCalPrinter->setupPrinter();
3369#endif 3369#endif
3370} 3370}
3371 3371
3372void CalendarView::print() 3372void CalendarView::print()
3373{ 3373{
3374#ifndef KORG_NOPRINTER 3374#ifndef KORG_NOPRINTER
3375 createPrinter(); 3375 createPrinter();
3376 3376
3377 DateList tmpDateList = mNavigator->selectedDates(); 3377 DateList tmpDateList = mNavigator->selectedDates();
3378 mCalPrinter->print(CalPrinter::Month, 3378 mCalPrinter->print(CalPrinter::Month,
3379 tmpDateList.first(), tmpDateList.last()); 3379 tmpDateList.first(), tmpDateList.last());
3380#endif 3380#endif
3381} 3381}
3382 3382
3383void CalendarView::printPreview() 3383void CalendarView::printPreview()
3384{ 3384{
3385#ifndef KORG_NOPRINTER 3385#ifndef KORG_NOPRINTER
3386 kdDebug() << "CalendarView::printPreview()" << endl; 3386 kdDebug() << "CalendarView::printPreview()" << endl;
3387 3387
3388 createPrinter(); 3388 createPrinter();
3389 3389
3390 DateList tmpDateList = mNavigator->selectedDates(); 3390 DateList tmpDateList = mNavigator->selectedDates();
3391 3391
3392 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3392 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3393 tmpDateList.last()); 3393 tmpDateList.last());
3394#endif 3394#endif
3395} 3395}
3396 3396
3397void CalendarView::exportICalendar() 3397void CalendarView::exportICalendar()
3398{ 3398{
3399 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3399 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3400 3400
3401 // Force correct extension 3401 // Force correct extension
3402 if (filename.right(4) != ".ics") filename += ".ics"; 3402 if (filename.right(4) != ".ics") filename += ".ics";
3403 3403
3404 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3404 FileStorage storage( mCalendar, filename, new ICalFormat() );
3405 storage.save(); 3405 storage.save();
3406} 3406}
3407 3407
3408bool CalendarView::exportVCalendar( QString filename ) 3408bool CalendarView::exportVCalendar( QString filename )
3409{ 3409{
3410 if (mCalendar->journals().count() > 0) { 3410 if (mCalendar->journals().count() > 0) {
3411 int result = KMessageBox::warningContinueCancel(this, 3411 int result = KMessageBox::warningContinueCancel(this,
3412 i18n("The journal entries can not be\nexported to a vCalendar file."), 3412 i18n("The journal entries can not be\nexported to a vCalendar file."),
3413 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3413 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3414 true); 3414 true);
3415 if (result != KMessageBox::Continue) return false; 3415 if (result != KMessageBox::Continue) return false;
3416 } 3416 }
3417 3417
3418 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3418 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3419 3419
3420 // Force correct extension 3420 // Force correct extension
3421 if (filename.right(4) != ".vcs") filename += ".vcs"; 3421 if (filename.right(4) != ".vcs") filename += ".vcs";
3422 3422
3423 FileStorage storage( mCalendar, filename, new VCalFormat ); 3423 FileStorage storage( mCalendar, filename, new VCalFormat );
3424 return storage.save(); 3424 return storage.save();
3425 3425
3426} 3426}
3427 3427
3428void CalendarView::eventUpdated(Incidence *) 3428void CalendarView::eventUpdated(Incidence *)
3429{ 3429{
3430 setModified(); 3430 setModified();
3431 // Don't call updateView here. The code, which has caused the update of the 3431 // Don't call updateView here. The code, which has caused the update of the
3432 // event is responsible for updating the view. 3432 // event is responsible for updating the view.
3433 // updateView(); 3433 // updateView();
3434} 3434}
3435 3435
3436void CalendarView::adaptNavigationUnits() 3436void CalendarView::adaptNavigationUnits()
3437{ 3437{
3438 if (mViewManager->currentView()->isEventView()) { 3438 if (mViewManager->currentView()->isEventView()) {
3439 int days = mViewManager->currentView()->currentDateCount(); 3439 int days = mViewManager->currentView()->currentDateCount();
3440 if (days == 1) { 3440 if (days == 1) {
3441 emit changeNavStringPrev(i18n("&Previous Day")); 3441 emit changeNavStringPrev(i18n("&Previous Day"));
3442 emit changeNavStringNext(i18n("&Next Day")); 3442 emit changeNavStringNext(i18n("&Next Day"));
3443 } else { 3443 } else {
3444 emit changeNavStringPrev(i18n("&Previous Week")); 3444 emit changeNavStringPrev(i18n("&Previous Week"));
3445 emit changeNavStringNext(i18n("&Next Week")); 3445 emit changeNavStringNext(i18n("&Next Week"));
3446 } 3446 }
3447 } 3447 }
3448} 3448}
3449 3449
3450void CalendarView::processMainViewSelection( Incidence *incidence ) 3450void CalendarView::processMainViewSelection( Incidence *incidence )
3451{ 3451{
3452 if ( incidence ) mTodoList->clearSelection(); 3452 if ( incidence ) mTodoList->clearSelection();
3453 processIncidenceSelection( incidence ); 3453 processIncidenceSelection( incidence );
3454} 3454}
3455 3455
3456void CalendarView::processTodoListSelection( Incidence *incidence ) 3456void CalendarView::processTodoListSelection( Incidence *incidence )
3457{ 3457{
3458 if ( incidence && mViewManager->currentView() ) { 3458 if ( incidence && mViewManager->currentView() ) {
3459 mViewManager->currentView()->clearSelection(); 3459 mViewManager->currentView()->clearSelection();
3460 } 3460 }
3461 processIncidenceSelection( incidence ); 3461 processIncidenceSelection( incidence );
3462} 3462}
3463 3463
3464void CalendarView::processIncidenceSelection( Incidence *incidence ) 3464void CalendarView::processIncidenceSelection( Incidence *incidence )
3465{ 3465{
3466 if ( incidence == mSelectedIncidence ) return; 3466 if ( incidence == mSelectedIncidence ) return;
3467 3467
3468 mSelectedIncidence = incidence; 3468 mSelectedIncidence = incidence;
3469 3469
3470 emit incidenceSelected( mSelectedIncidence ); 3470 emit incidenceSelected( mSelectedIncidence );
3471 3471
3472 if ( incidence && incidence->type() == "Event" ) { 3472 if ( incidence && incidence->type() == "Event" ) {
3473 Event *event = static_cast<Event *>( incidence ); 3473 Event *event = static_cast<Event *>( incidence );
3474 if ( event->organizer() == KOPrefs::instance()->email() ) { 3474 if ( event->organizer() == KOPrefs::instance()->email() ) {
3475 emit organizerEventsSelected( true ); 3475 emit organizerEventsSelected( true );
3476 } else { 3476 } else {
3477 emit organizerEventsSelected(false); 3477 emit organizerEventsSelected(false);
3478 } 3478 }
3479 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3479 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3480 KOPrefs::instance()->email() ) ) { 3480 KOPrefs::instance()->email() ) ) {
3481 emit groupEventsSelected( true ); 3481 emit groupEventsSelected( true );
3482 } else { 3482 } else {
3483 emit groupEventsSelected(false); 3483 emit groupEventsSelected(false);
3484 } 3484 }
3485 return; 3485 return;
3486 } else { 3486 } else {
3487 if ( incidence && incidence->type() == "Todo" ) { 3487 if ( incidence && incidence->type() == "Todo" ) {
3488 emit todoSelected( true ); 3488 emit todoSelected( true );
3489 Todo *event = static_cast<Todo *>( incidence ); 3489 Todo *event = static_cast<Todo *>( incidence );
3490 if ( event->organizer() == KOPrefs::instance()->email() ) { 3490 if ( event->organizer() == KOPrefs::instance()->email() ) {
3491 emit organizerEventsSelected( true ); 3491 emit organizerEventsSelected( true );
3492 } else { 3492 } else {
3493 emit organizerEventsSelected(false); 3493 emit organizerEventsSelected(false);
3494 } 3494 }
3495 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3495 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3496 KOPrefs::instance()->email() ) ) { 3496 KOPrefs::instance()->email() ) ) {
3497 emit groupEventsSelected( true ); 3497 emit groupEventsSelected( true );
3498 } else { 3498 } else {
3499 emit groupEventsSelected(false); 3499 emit groupEventsSelected(false);
3500 } 3500 }
3501 return; 3501 return;
3502 } else { 3502 } else {
3503 emit todoSelected( false ); 3503 emit todoSelected( false );
3504 emit organizerEventsSelected(false); 3504 emit organizerEventsSelected(false);
3505 emit groupEventsSelected(false); 3505 emit groupEventsSelected(false);
3506 } 3506 }
3507 return; 3507 return;
3508 } 3508 }
3509 3509
3510 /* if ( incidence && incidence->type() == "Todo" ) { 3510 /* if ( incidence && incidence->type() == "Todo" ) {
3511 emit todoSelected( true ); 3511 emit todoSelected( true );
3512 } else { 3512 } else {
3513 emit todoSelected( false ); 3513 emit todoSelected( false );
3514 }*/ 3514 }*/
3515} 3515}
3516 3516
3517 3517
3518void CalendarView::checkClipboard() 3518void CalendarView::checkClipboard()
3519{ 3519{
3520#ifndef KORG_NODND 3520#ifndef KORG_NODND
3521 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3521 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3522 emit pasteEnabled(true); 3522 emit pasteEnabled(true);
3523 } else { 3523 } else {
3524 emit pasteEnabled(false); 3524 emit pasteEnabled(false);
3525 } 3525 }
3526#endif 3526#endif
3527} 3527}
3528 3528
3529void CalendarView::showDates(const DateList &selectedDates) 3529void CalendarView::showDates(const DateList &selectedDates)
3530{ 3530{
3531 // kdDebug() << "CalendarView::selectDates()" << endl; 3531 // kdDebug() << "CalendarView::selectDates()" << endl;
3532 3532
3533 3533
3534 if ( !mBlockShowDates ) { 3534 if ( !mBlockShowDates ) {
3535 if ( mViewManager->currentView() ) { 3535 if ( mViewManager->currentView() ) {
3536 updateView( selectedDates.first(), selectedDates.last() ); 3536 updateView( selectedDates.first(), selectedDates.last() );
3537 } else { 3537 } else {
3538 mViewManager->showAgendaView(); 3538 mViewManager->showAgendaView();
3539 } 3539 }
3540 } 3540 }
3541 3541
3542 QString selDates; 3542 QString selDates;
3543 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3543 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3544 if (selectedDates.first() < selectedDates.last() ) 3544 if (selectedDates.first() < selectedDates.last() )
3545 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3545 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3546 else { 3546 else {
3547 QString addString; 3547 QString addString;
3548 if ( selectedDates.first() == QDateTime::currentDateTime().date() ) 3548 if ( selectedDates.first() == QDateTime::currentDateTime().date() )
3549 addString = i18n("Today"); 3549 addString = i18n("Today");
3550 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 3550 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
3551 addString = i18n("Tomorrow"); 3551 addString = i18n("Tomorrow");
3552 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 3552 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
3553 addString = i18n("Yesterday"); 3553 addString = i18n("Yesterday");
3554 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 3554 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
3555 addString = i18n("Day before yesterday"); 3555 addString = i18n("Day before yesterday");
3556 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 3556 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
3557 addString = i18n("Day after tomorrow"); 3557 addString = i18n("Day after tomorrow");
3558 if ( !addString.isEmpty() ) { 3558 if ( !addString.isEmpty() ) {
3559 topLevelWidget()->setCaption( addString+", " + selDates ); 3559 topLevelWidget()->setCaption( addString+", " + selDates );
3560 return; 3560 return;
3561 } 3561 }
3562 } 3562 }
3563 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3563 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3564 3564
3565} 3565}
3566 3566
3567QPtrList<CalFilter> CalendarView::filters() 3567QPtrList<CalFilter> CalendarView::filters()
3568{ 3568{
3569 return mFilters; 3569 return mFilters;
3570 3570
3571} 3571}
3572void CalendarView::editFilters() 3572void CalendarView::editFilters()
3573{ 3573{
3574 // kdDebug() << "CalendarView::editFilters()" << endl; 3574 // kdDebug() << "CalendarView::editFilters()" << endl;
3575 3575
3576 CalFilter *filter = mFilters.first(); 3576 CalFilter *filter = mFilters.first();
3577 while(filter) { 3577 while(filter) {
3578 kdDebug() << " Filter: " << filter->name() << endl; 3578 kdDebug() << " Filter: " << filter->name() << endl;
3579 filter = mFilters.next(); 3579 filter = mFilters.next();
3580 } 3580 }
3581 3581
3582 mDialogManager->showFilterEditDialog(&mFilters); 3582 mDialogManager->showFilterEditDialog(&mFilters);
3583} 3583}
3584void CalendarView::toggleFilter() 3584void CalendarView::toggleFilter()
3585{ 3585{
3586 showFilter(! mFilterView->isVisible()); 3586 showFilter(! mFilterView->isVisible());
3587} 3587}
3588 3588
3589KOFilterView *CalendarView::filterView() 3589KOFilterView *CalendarView::filterView()
3590{ 3590{
3591 return mFilterView; 3591 return mFilterView;
3592} 3592}
3593void CalendarView::selectFilter( int fil ) 3593void CalendarView::selectFilter( int fil )
3594{ 3594{
3595 mFilterView->setSelectedFilter( fil ); 3595 mFilterView->setSelectedFilter( fil );
3596} 3596}
3597void CalendarView::showFilter(bool visible) 3597void CalendarView::showFilter(bool visible)
3598{ 3598{
3599 if (visible) mFilterView->show(); 3599 if (visible) mFilterView->show();
3600 else mFilterView->hide(); 3600 else mFilterView->hide();
3601} 3601}
3602void CalendarView::toggleFilerEnabled( ) 3602void CalendarView::toggleFilerEnabled( )
3603{ 3603{
3604 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3604 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3605 if ( !mFilterView->filtersEnabled() ) 3605 if ( !mFilterView->filtersEnabled() )
3606 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3606 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3607 3607
3608} 3608}
3609void CalendarView::updateFilter() 3609void CalendarView::updateFilter()
3610{ 3610{
3611 CalFilter *filter = mFilterView->selectedFilter(); 3611 CalFilter *filter = mFilterView->selectedFilter();
3612 if (filter) { 3612 if (filter) {
3613 QString mess;
3613 if (mFilterView->filtersEnabled()) { 3614 if (mFilterView->filtersEnabled()) {
3614 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3615 mess = i18n("Filter selected: ")+filter->name();
3615 filter->setEnabled(true); 3616 filter->setEnabled(true);
3616 } 3617 }
3617 else filter->setEnabled(false); 3618 else filter->setEnabled(false);
3618 mCalendar->setFilter(filter); 3619 mCalendar->setFilter(filter);
3619 updateView(); 3620 updateView();
3621 if ( !mess.isEmpty() )
3622 topLevelWidget()->setCaption( mess );
3623
3620 } 3624 }
3621} 3625}
3622 3626
3623void CalendarView::filterEdited() 3627void CalendarView::filterEdited()
3624{ 3628{
3625 mFilterView->updateFilters(); 3629 mFilterView->updateFilters();
3626 updateFilter(); 3630 updateFilter();
3627 writeSettings(); 3631 writeSettings();
3628} 3632}
3629 3633
3630 3634
3631void CalendarView::takeOverEvent() 3635void CalendarView::takeOverEvent()
3632{ 3636{
3633 Incidence *incidence = currentSelection(); 3637 Incidence *incidence = currentSelection();
3634 3638
3635 if (!incidence) return; 3639 if (!incidence) return;
3636 3640
3637 incidence->setOrganizer(KOPrefs::instance()->email()); 3641 incidence->setOrganizer(KOPrefs::instance()->email());
3638 incidence->recreate(); 3642 incidence->recreate();
3639 incidence->setReadOnly(false); 3643 incidence->setReadOnly(false);
3640 3644
3641 updateView(); 3645 updateView();
3642} 3646}
3643 3647
3644void CalendarView::takeOverCalendar() 3648void CalendarView::takeOverCalendar()
3645{ 3649{
3646 // TODO: Create Calendar::allIncidences() function and use it here 3650 // TODO: Create Calendar::allIncidences() function and use it here
3647 3651
3648 QPtrList<Event> events = mCalendar->events(); 3652 QPtrList<Event> events = mCalendar->events();
3649 for(uint i=0; i<events.count(); ++i) { 3653 for(uint i=0; i<events.count(); ++i) {
3650 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3654 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3651 events.at(i)->recreate(); 3655 events.at(i)->recreate();
3652 events.at(i)->setReadOnly(false); 3656 events.at(i)->setReadOnly(false);
3653 } 3657 }
3654 3658
3655 QPtrList<Todo> todos = mCalendar->todos(); 3659 QPtrList<Todo> todos = mCalendar->todos();
3656 for(uint i=0; i<todos.count(); ++i) { 3660 for(uint i=0; i<todos.count(); ++i) {
3657 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3661 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3658 todos.at(i)->recreate(); 3662 todos.at(i)->recreate();
3659 todos.at(i)->setReadOnly(false); 3663 todos.at(i)->setReadOnly(false);
3660 } 3664 }
3661 3665
3662 QPtrList<Journal> journals = mCalendar->journals(); 3666 QPtrList<Journal> journals = mCalendar->journals();
3663 for(uint i=0; i<journals.count(); ++i) { 3667 for(uint i=0; i<journals.count(); ++i) {
3664 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3668 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3665 journals.at(i)->recreate(); 3669 journals.at(i)->recreate();
3666 journals.at(i)->setReadOnly(false); 3670 journals.at(i)->setReadOnly(false);
3667 } 3671 }
3668 3672
3669 updateView(); 3673 updateView();
3670} 3674}
3671 3675
3672void CalendarView::showIntro() 3676void CalendarView::showIntro()
3673{ 3677{
3674 kdDebug() << "To be implemented." << endl; 3678 kdDebug() << "To be implemented." << endl;
3675} 3679}
3676 3680
3677QWidgetStack *CalendarView::viewStack() 3681QWidgetStack *CalendarView::viewStack()
3678{ 3682{
3679 return mRightFrame; 3683 return mRightFrame;
3680} 3684}
3681 3685
3682QWidget *CalendarView::leftFrame() 3686QWidget *CalendarView::leftFrame()
3683{ 3687{
3684 return mLeftFrame; 3688 return mLeftFrame;
3685} 3689}
3686 3690
3687DateNavigator *CalendarView::dateNavigator() 3691DateNavigator *CalendarView::dateNavigator()
3688{ 3692{
3689 return mNavigator; 3693 return mNavigator;
3690} 3694}
3691 3695
3692KDateNavigator* CalendarView::dateNavigatorWidget() 3696KDateNavigator* CalendarView::dateNavigatorWidget()
3693{ 3697{
3694 return mDateNavigator; 3698 return mDateNavigator;
3695} 3699}
3696void CalendarView::toggleDateNavigatorWidget() 3700void CalendarView::toggleDateNavigatorWidget()
3697{ 3701{
3698 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3702 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3699 if (!KOPrefs::instance()->mShowDateNavigator ) 3703 if (!KOPrefs::instance()->mShowDateNavigator )
3700 mDateNavigator->hide(); 3704 mDateNavigator->hide();
3701 else 3705 else
3702 mDateNavigator->show(); 3706 mDateNavigator->show();
3703} 3707}
3704void CalendarView::addView(KOrg::BaseView *view) 3708void CalendarView::addView(KOrg::BaseView *view)
3705{ 3709{
3706 mViewManager->addView(view); 3710 mViewManager->addView(view);
3707} 3711}
3708 3712
3709void CalendarView::showView(KOrg::BaseView *view) 3713void CalendarView::showView(KOrg::BaseView *view)
3710{ 3714{
3711 mViewManager->showView(view, mLeftFrame->isVisible()); 3715 mViewManager->showView(view, mLeftFrame->isVisible());
3712} 3716}
3713 3717
3714Incidence *CalendarView::currentSelection() 3718Incidence *CalendarView::currentSelection()
3715{ 3719{
3716 return mViewManager->currentSelection(); 3720 return mViewManager->currentSelection();
3717} 3721}
3718void CalendarView::toggleAllDaySize() 3722void CalendarView::toggleAllDaySize()
3719{ 3723{
3720 /* 3724 /*
3721 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3725 if ( KOPrefs::instance()->mAllDaySize > 47 )
3722 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3726 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3723 else 3727 else
3724 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3728 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3725 */ 3729 */
3726 viewManager()->agendaView()->toggleAllDay(); 3730 viewManager()->agendaView()->toggleAllDay();
3727} 3731}
3728void CalendarView::toggleExpand() 3732void CalendarView::toggleExpand()
3729{ 3733{
3730 // if ( mLeftFrame->isHidden() ) { 3734 // if ( mLeftFrame->isHidden() ) {
3731 // mLeftFrame->show(); 3735 // mLeftFrame->show();
3732 // emit calendarViewExpanded( false ); 3736 // emit calendarViewExpanded( false );
3733 // } else { 3737 // } else {
3734 // mLeftFrame->hide(); 3738 // mLeftFrame->hide();
3735 // emit calendarViewExpanded( true ); 3739 // emit calendarViewExpanded( true );
3736 // } 3740 // }
3737 //qDebug(" CalendarView::toggleExpand()"); 3741 //qDebug(" CalendarView::toggleExpand()");
3738 globalFlagBlockAgenda = 1; 3742 globalFlagBlockAgenda = 1;
3739 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3743 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3740 globalFlagBlockAgenda = 5; 3744 globalFlagBlockAgenda = 5;
3741 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3745 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3742 //mViewManager->showView( 0, true ); 3746 //mViewManager->showView( 0, true );
3743} 3747}
3744 3748
3745void CalendarView::calendarModified( bool modified, Calendar * ) 3749void CalendarView::calendarModified( bool modified, Calendar * )
3746{ 3750{
3747 setModified( modified ); 3751 setModified( modified );
3748} 3752}
3749 3753
3750Todo *CalendarView::selectedTodo() 3754Todo *CalendarView::selectedTodo()
3751{ 3755{
3752 Incidence *incidence = currentSelection(); 3756 Incidence *incidence = currentSelection();
3753 if ( incidence && incidence->type() == "Todo" ) { 3757 if ( incidence && incidence->type() == "Todo" ) {
3754 return static_cast<Todo *>( incidence ); 3758 return static_cast<Todo *>( incidence );
3755 } 3759 }
3756 3760
3757 incidence = mTodoList->selectedIncidences().first(); 3761 incidence = mTodoList->selectedIncidences().first();
3758 if ( incidence && incidence->type() == "Todo" ) { 3762 if ( incidence && incidence->type() == "Todo" ) {
3759 return static_cast<Todo *>( incidence ); 3763 return static_cast<Todo *>( incidence );
3760 } 3764 }
3761 3765
3762 return 0; 3766 return 0;
3763} 3767}
3764 3768
3765void CalendarView::dialogClosing(Incidence *in) 3769void CalendarView::dialogClosing(Incidence *in)
3766{ 3770{
3767 // mDialogList.remove(in); 3771 // mDialogList.remove(in);
3768} 3772}
3769 3773
3770void CalendarView::showIncidence() 3774void CalendarView::showIncidence()
3771{ 3775{
3772 mViewerCallerIsSearchDialog = false; 3776 mViewerCallerIsSearchDialog = false;
3773 Incidence *incidence = currentSelection(); 3777 Incidence *incidence = currentSelection();
3774 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3778 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3775 if ( incidence ) { 3779 if ( incidence ) {
3776 ShowIncidenceVisitor v; 3780 ShowIncidenceVisitor v;
3777 v.act( incidence, this ); 3781 v.act( incidence, this );
3778 } 3782 }
3779} 3783}
3780void CalendarView::editIncidenceDescription() 3784void CalendarView::editIncidenceDescription()
3781{ 3785{
3782 mFlagEditDescription = true; 3786 mFlagEditDescription = true;
3783 editIncidence(); 3787 editIncidence();
3784 mFlagEditDescription = false; 3788 mFlagEditDescription = false;
3785} 3789}
3786void CalendarView::editIncidence() 3790void CalendarView::editIncidence()
3787{ 3791{
3788 // qDebug("editIncidence() "); 3792 // qDebug("editIncidence() ");
3789 Incidence *incidence = currentSelection(); 3793 Incidence *incidence = currentSelection();
3790 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3794 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3791 if ( incidence ) { 3795 if ( incidence ) {
3792 EditIncidenceVisitor v; 3796 EditIncidenceVisitor v;
3793 v.act( incidence, this ); 3797 v.act( incidence, this );
3794 } 3798 }
3795} 3799}
3796 3800
3797void CalendarView::deleteIncidence() 3801void CalendarView::deleteIncidence()
3798{ 3802{
3799 Incidence *incidence = currentSelection(); 3803 Incidence *incidence = currentSelection();
3800 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3804 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3801 if ( incidence ) { 3805 if ( incidence ) {
3802 deleteIncidence(incidence); 3806 deleteIncidence(incidence);
3803 } 3807 }
3804} 3808}
3805 3809
3806void CalendarView::showIncidence(Incidence *incidence) 3810void CalendarView::showIncidence(Incidence *incidence)
3807{ 3811{
3808 mViewerCallerIsSearchDialog = false; 3812 mViewerCallerIsSearchDialog = false;
3809 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 3813 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
3810 if ( sender() && mDialogManager->getSearchDialog() ) { 3814 if ( sender() && mDialogManager->getSearchDialog() ) {
3811 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 3815 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
3812 mViewerCallerIsSearchDialog = true; 3816 mViewerCallerIsSearchDialog = true;
3813 } 3817 }
3814 } 3818 }
3815 if ( incidence ) { 3819 if ( incidence ) {
3816 ShowIncidenceVisitor v; 3820 ShowIncidenceVisitor v;
3817 v.act( incidence, this ); 3821 v.act( incidence, this );
3818 } 3822 }
3819} 3823}
3820 3824
3821void CalendarView::editIncidence(Incidence *incidence) 3825void CalendarView::editIncidence(Incidence *incidence)
3822{ 3826{
3823 if ( incidence ) { 3827 if ( incidence ) {
3824 3828
3825 EditIncidenceVisitor v; 3829 EditIncidenceVisitor v;
3826 v.act( incidence, this ); 3830 v.act( incidence, this );
3827 3831
3828 } 3832 }
3829} 3833}
3830 3834
3831void CalendarView::deleteIncidence(Incidence *incidence) 3835void CalendarView::deleteIncidence(Incidence *incidence)
3832{ 3836{
3833 //qDebug(" CalendarView::deleteIncidence "); 3837 //qDebug(" CalendarView::deleteIncidence ");
3834 if ( incidence ) { 3838 if ( incidence ) {
3835 DeleteIncidenceVisitor v; 3839 DeleteIncidenceVisitor v;
3836 v.act( incidence, this ); 3840 v.act( incidence, this );
3837 } 3841 }
3838} 3842}
3839 3843
3840 3844
3841void CalendarView::lookForOutgoingMessages() 3845void CalendarView::lookForOutgoingMessages()
3842{ 3846{
3843 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3847 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3844 ogd->loadMessages(); 3848 ogd->loadMessages();
3845} 3849}
3846 3850
3847void CalendarView::lookForIncomingMessages() 3851void CalendarView::lookForIncomingMessages()
3848{ 3852{
3849 IncomingDialog *icd = mDialogManager->incomingDialog(); 3853 IncomingDialog *icd = mDialogManager->incomingDialog();
3850 icd->retrieve(); 3854 icd->retrieve();
3851} 3855}
3852 3856
3853bool CalendarView::removeCompletedSubTodos( Todo* t ) 3857bool CalendarView::removeCompletedSubTodos( Todo* t )
3854{ 3858{
3855 bool deleteTodo = true; 3859 bool deleteTodo = true;
3856 QPtrList<Incidence> subTodos; 3860 QPtrList<Incidence> subTodos;
3857 Incidence *aTodo; 3861 Incidence *aTodo;
3858 subTodos = t->relations(); 3862 subTodos = t->relations();
3859 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3863 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3860 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3864 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3861 deleteTodo = false; 3865 deleteTodo = false;
3862 } 3866 }
3863 if ( deleteTodo ) { 3867 if ( deleteTodo ) {
3864 if ( t->isCompleted() && !t->doesRecur()) { 3868 if ( t->isCompleted() && !t->doesRecur()) {
3865 checkExternalId( t ); 3869 checkExternalId( t );
3866 mCalendar->deleteTodo( t ); 3870 mCalendar->deleteTodo( t );
3867 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3871 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3868 } 3872 }
3869 else 3873 else
3870 deleteTodo = false; 3874 deleteTodo = false;
3871 } 3875 }
3872 return deleteTodo; 3876 return deleteTodo;
3873 3877
3874} 3878}
3875void CalendarView::purgeCompleted() 3879void CalendarView::purgeCompleted()
3876{ 3880{
3877 int result = KMessageBox::warningContinueCancel(this, 3881 int result = KMessageBox::warningContinueCancel(this,
3878 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3882 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3879 3883
3880 if (result == KMessageBox::Continue) { 3884 if (result == KMessageBox::Continue) {
3881 3885
3882 QPtrList<Todo> todoCal; 3886 QPtrList<Todo> todoCal;
3883 QPtrList<Todo> rootTodos; 3887 QPtrList<Todo> rootTodos;
3884 //QPtrList<Incidence> rel; 3888 //QPtrList<Incidence> rel;
3885 Todo *aTodo;//, *rTodo; 3889 Todo *aTodo;//, *rTodo;
3886 Incidence *rIncidence; 3890 Incidence *rIncidence;
3887 bool childDelete = false; 3891 bool childDelete = false;
3888 bool deletedOne = true; 3892 bool deletedOne = true;
3889 todoCal = calendar()->todos(); 3893 todoCal = calendar()->todos();
3890 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3894 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3891 if ( !aTodo->relatedTo() ) 3895 if ( !aTodo->relatedTo() )
3892 rootTodos.append( aTodo ); 3896 rootTodos.append( aTodo );
3893 } 3897 }
3894 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3898 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3895 removeCompletedSubTodos( aTodo ); 3899 removeCompletedSubTodos( aTodo );
3896 } 3900 }
3897 3901
3898 updateView(); 3902 updateView();
3899 } 3903 }
3900} 3904}
3901 3905
3902void CalendarView::slotCalendarChanged() 3906void CalendarView::slotCalendarChanged()
3903{ 3907{
3904 ; 3908 ;
3905} 3909}
3906 3910
3907void CalendarView::keyPressEvent ( QKeyEvent *e) 3911void CalendarView::keyPressEvent ( QKeyEvent *e)
3908{ 3912{
3909 //qDebug(" alendarView::keyPressEvent "); 3913 //qDebug(" alendarView::keyPressEvent ");
3910 e->ignore(); 3914 e->ignore();
3911} 3915}
3912 3916
3913 3917
3914bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3918bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3915{ 3919{
3916 // mSyncManager = manager; 3920 // mSyncManager = manager;
3917 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3921 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3918 qDebug("KO: SyncKDE request detected!"); 3922 qDebug("KO: SyncKDE request detected!");
3919 } 3923 }
3920 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3924 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3921 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3925 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3922 return syncCalendar( filename, mode ); 3926 return syncCalendar( filename, mode );
3923} 3927}
3924bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3928bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3925{ 3929{
3926 //mSyncManager = manager; 3930 //mSyncManager = manager;
3927 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3931 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3928 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3932 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3929 if ( resource == "sharp" ) 3933 if ( resource == "sharp" )
3930 syncExternal( 0 ); 3934 syncExternal( 0 );
3931 if ( resource == "phone" ) 3935 if ( resource == "phone" )
3932 syncExternal( 1 ); 3936 syncExternal( 1 );
3933 // pending setmodified 3937 // pending setmodified
3934 return true; 3938 return true;
3935} 3939}
3936void CalendarView::setSyncManager(KSyncManager* manager) 3940void CalendarView::setSyncManager(KSyncManager* manager)
3937{ 3941{
3938 mSyncManager = manager; 3942 mSyncManager = manager;
3939} 3943}
3940 3944
3941void CalendarView::removeSyncInfo( QString syncProfile) 3945void CalendarView::removeSyncInfo( QString syncProfile)
3942{ 3946{
3943 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 3947 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
3944 mCalendar->removeSyncInfo( syncProfile ); 3948 mCalendar->removeSyncInfo( syncProfile );
3945 3949
3946} 3950}
3947 3951
3948void CalendarView::undo_delete() 3952void CalendarView::undo_delete()
3949{ 3953{
3950 //qDebug("undo_delete() "); 3954 //qDebug("undo_delete() ");
3951 Incidence* undo = mCalendar->undoIncidence(); 3955 Incidence* undo = mCalendar->undoIncidence();
3952 if ( !undo ) { 3956 if ( !undo ) {
3953 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 3957 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
3954 i18n("KO/Pi")); 3958 i18n("KO/Pi"));
3955 return; 3959 return;
3956 } 3960 }
3957 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 3961 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
3958 i18n("\nAre you sure you want\nto restore this?"), 3962 i18n("\nAre you sure you want\nto restore this?"),
3959 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 3963 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
3960 mCalendar->undoDeleteIncidence(); 3964 mCalendar->undoDeleteIncidence();
3961 updateView(); 3965 updateView();
3962 } 3966 }
3963} 3967}
3964 3968
3965void CalendarView::slotViewerClosed() 3969void CalendarView::slotViewerClosed()
3966{ 3970{
3967 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 3971 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
3968} 3972}
3969 3973
3970void CalendarView::resetFocus() 3974void CalendarView::resetFocus()
3971{ 3975{
3972 if ( mViewerCallerIsSearchDialog ) { 3976 if ( mViewerCallerIsSearchDialog ) {
3973 if ( mDialogManager->getSearchDialog()->isVisible() ){ 3977 if ( mDialogManager->getSearchDialog()->isVisible() ){
3974 mDialogManager->getSearchDialog()->raise(); 3978 mDialogManager->getSearchDialog()->raise();
3975 mDialogManager->getSearchDialog()->setActiveWindow(); 3979 mDialogManager->getSearchDialog()->setActiveWindow();
3976 mDialogManager->getSearchDialog()->listview()->resetFocus(); 3980 mDialogManager->getSearchDialog()->listview()->resetFocus();
3977 } else 3981 } else
3978 mViewerCallerIsSearchDialog = false; 3982 mViewerCallerIsSearchDialog = false;
3979 } 3983 }
3980 if ( !mViewerCallerIsSearchDialog ) { 3984 if ( !mViewerCallerIsSearchDialog ) {
3981 //mViewManager->currentView()->setFocus(); 3985 //mViewManager->currentView()->setFocus();
3982 //qDebug("sssssssssssssssset focus "); 3986 //qDebug("sssssssssssssssset focus ");
3983 topLevelWidget()->raise(); 3987 topLevelWidget()->raise();
3984 setActiveWindow(); 3988 setActiveWindow();
3985 //setFocus(); 3989 //setFocus();
3986 } 3990 }
3987 mViewerCallerIsSearchDialog = false; 3991 mViewerCallerIsSearchDialog = false;
3988} 3992}