summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-19 22:56:08 (UTC)
committer zautrix <zautrix>2005-03-19 22:56:08 (UTC)
commit84c18843bbd1203878367572d3a6800a0586c7f1 (patch) (unidiff)
tree9f58b7356ea700d47e6ec84fb4a462a666a24049 /korganizer
parent39b719bdc75d95913c3aaf9a03aaa57b1161cc61 (diff)
downloadkdepimpi-84c18843bbd1203878367572d3a6800a0586c7f1.zip
kdepimpi-84c18843bbd1203878367572d3a6800a0586c7f1.tar.gz
kdepimpi-84c18843bbd1203878367572d3a6800a0586c7f1.tar.bz2
mochn fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp1
-rw-r--r--korganizer/datenavigatorcontainer.cpp20
-rw-r--r--korganizer/kdatenavigator.cpp7
-rw-r--r--korganizer/kdatenavigator.h5
-rw-r--r--korganizer/kodaymatrix.cpp2
5 files changed, 24 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 29c530b..9acbbb1 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1667,385 +1667,384 @@ bool CalendarView::openCalendar(QString filename, bool merge)
1667 if ( !merge ) { 1667 if ( !merge ) {
1668 mCalendar->close(); 1668 mCalendar->close();
1669 mViewManager->setDocumentId( filename ); 1669 mViewManager->setDocumentId( filename );
1670 mDialogManager->setDocumentId( filename ); 1670 mDialogManager->setDocumentId( filename );
1671 mTodoList->setDocumentId( filename ); 1671 mTodoList->setDocumentId( filename );
1672 } 1672 }
1673 1673
1674 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1674 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1675 1675
1676 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1676 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1677 globalFlagBlockAgenda = 2; 1677 globalFlagBlockAgenda = 2;
1678 mCalendar->reInitAlarmSettings(); 1678 mCalendar->reInitAlarmSettings();
1679 setSyncEventsReadOnly(); 1679 setSyncEventsReadOnly();
1680 updateUnmanagedViews(); 1680 updateUnmanagedViews();
1681 updateView(); 1681 updateView();
1682 } 1682 }
1683 return false; 1683 return false;
1684} 1684}
1685void CalendarView::showOpenError() 1685void CalendarView::showOpenError()
1686{ 1686{
1687 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1687 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1688} 1688}
1689void CalendarView::setLoadedFileVersion(QDateTime dt) 1689void CalendarView::setLoadedFileVersion(QDateTime dt)
1690{ 1690{
1691 loadedFileVersion = dt; 1691 loadedFileVersion = dt;
1692} 1692}
1693bool CalendarView::checkFileChanged(QString fn) 1693bool CalendarView::checkFileChanged(QString fn)
1694{ 1694{
1695 QFileInfo finf ( fn ); 1695 QFileInfo finf ( fn );
1696 if ( !finf.exists() ) 1696 if ( !finf.exists() )
1697 return true; 1697 return true;
1698 QDateTime dt = finf.lastModified (); 1698 QDateTime dt = finf.lastModified ();
1699 if ( dt <= loadedFileVersion ) 1699 if ( dt <= loadedFileVersion )
1700 return false; 1700 return false;
1701 return true; 1701 return true;
1702 1702
1703} 1703}
1704void CalendarView::watchSavedFile() 1704void CalendarView::watchSavedFile()
1705{ 1705{
1706 QFileInfo finf ( MainWindow::defaultFileName()); 1706 QFileInfo finf ( MainWindow::defaultFileName());
1707 if ( !finf.exists() ) 1707 if ( !finf.exists() )
1708 return; 1708 return;
1709 QDateTime dt = finf.lastModified (); 1709 QDateTime dt = finf.lastModified ();
1710 if ( dt < loadedFileVersion ) { 1710 if ( dt < loadedFileVersion ) {
1711 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1711 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1712 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1712 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1713 return; 1713 return;
1714 } 1714 }
1715 loadedFileVersion = dt; 1715 loadedFileVersion = dt;
1716} 1716}
1717 1717
1718bool CalendarView::checkFileVersion(QString fn) 1718bool CalendarView::checkFileVersion(QString fn)
1719{ 1719{
1720 QFileInfo finf ( fn ); 1720 QFileInfo finf ( fn );
1721 if ( !finf.exists() ) 1721 if ( !finf.exists() )
1722 return true; 1722 return true;
1723 QDateTime dt = finf.lastModified (); 1723 QDateTime dt = finf.lastModified ();
1724 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1724 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1725 //qDebug("file on disk version %s",dt.toString().latin1()); 1725 //qDebug("file on disk version %s",dt.toString().latin1());
1726 if ( dt <= loadedFileVersion ) 1726 if ( dt <= loadedFileVersion )
1727 return true; 1727 return true;
1728 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)) , 1728 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)) ,
1729 i18n("KO/Pi Warning"),i18n("Overwrite"), 1729 i18n("KO/Pi Warning"),i18n("Overwrite"),
1730 i18n("Sync+save")); 1730 i18n("Sync+save"));
1731 1731
1732 if ( km == KMessageBox::Cancel ) 1732 if ( km == KMessageBox::Cancel )
1733 return false; 1733 return false;
1734 if ( km == KMessageBox::Yes ) 1734 if ( km == KMessageBox::Yes )
1735 return true; 1735 return true;
1736 1736
1737 setSyncDevice("deleteaftersync" ); 1737 setSyncDevice("deleteaftersync" );
1738 mSyncManager->mAskForPreferences = true; 1738 mSyncManager->mAskForPreferences = true;
1739 mSyncManager->mSyncAlgoPrefs = 3; 1739 mSyncManager->mSyncAlgoPrefs = 3;
1740 mSyncManager->mWriteBackFile = false; 1740 mSyncManager->mWriteBackFile = false;
1741 mSyncManager->mWriteBackExistingOnly = false; 1741 mSyncManager->mWriteBackExistingOnly = false;
1742 mSyncManager->mShowSyncSummary = false; 1742 mSyncManager->mShowSyncSummary = false;
1743 syncCalendar( fn, 3 ); 1743 syncCalendar( fn, 3 );
1744 Event * e = getLastSyncEvent(); 1744 Event * e = getLastSyncEvent();
1745 mCalendar->deleteEvent ( e ); 1745 mCalendar->deleteEvent ( e );
1746 updateView(); 1746 updateView();
1747 return true; 1747 return true;
1748} 1748}
1749 1749
1750bool CalendarView::saveCalendar( QString filename ) 1750bool CalendarView::saveCalendar( QString filename )
1751{ 1751{
1752 1752
1753 // Store back all unsaved data into calendar object 1753 // Store back all unsaved data into calendar object
1754 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1754 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1755 if ( mViewManager->currentView() ) 1755 if ( mViewManager->currentView() )
1756 mViewManager->currentView()->flushView(); 1756 mViewManager->currentView()->flushView();
1757 1757
1758 1758
1759 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1759 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1760 mStorage->setSaveFormat( new ICalFormat() ); 1760 mStorage->setSaveFormat( new ICalFormat() );
1761 mStorage->setFileName( filename ); 1761 mStorage->setFileName( filename );
1762 bool success; 1762 bool success;
1763 success = mStorage->save(); 1763 success = mStorage->save();
1764 if ( !success ) { 1764 if ( !success ) {
1765 return false; 1765 return false;
1766 } 1766 }
1767 if ( filename == MainWindow::defaultFileName() ) { 1767 if ( filename == MainWindow::defaultFileName() ) {
1768 setLoadedFileVersion( lfv ); 1768 setLoadedFileVersion( lfv );
1769 watchSavedFile(); 1769 watchSavedFile();
1770 } 1770 }
1771 return true; 1771 return true;
1772} 1772}
1773 1773
1774void CalendarView::closeCalendar() 1774void CalendarView::closeCalendar()
1775{ 1775{
1776 1776
1777 // child windows no longer valid 1777 // child windows no longer valid
1778 emit closingDown(); 1778 emit closingDown();
1779 1779
1780 mCalendar->close(); 1780 mCalendar->close();
1781 setModified(false); 1781 setModified(false);
1782 updateView(); 1782 updateView();
1783} 1783}
1784 1784
1785void CalendarView::archiveCalendar() 1785void CalendarView::archiveCalendar()
1786{ 1786{
1787 mDialogManager->showArchiveDialog(); 1787 mDialogManager->showArchiveDialog();
1788} 1788}
1789 1789
1790 1790
1791void CalendarView::readSettings() 1791void CalendarView::readSettings()
1792{ 1792{
1793 1793
1794 1794
1795 // mViewManager->showAgendaView(); 1795 // mViewManager->showAgendaView();
1796 QString str; 1796 QString str;
1797 //qDebug("CalendarView::readSettings() "); 1797 //qDebug("CalendarView::readSettings() ");
1798 // read settings from the KConfig, supplying reasonable 1798 // read settings from the KConfig, supplying reasonable
1799 // defaults where none are to be found 1799 // defaults where none are to be found
1800 KConfig *config = KOGlobals::config(); 1800 KConfig *config = KOGlobals::config();
1801#ifndef KORG_NOSPLITTER 1801#ifndef KORG_NOSPLITTER
1802 config->setGroup("KOrganizer Geometry"); 1802 config->setGroup("KOrganizer Geometry");
1803 1803
1804 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1804 QValueList<int> sizes = config->readIntListEntry("Separator1");
1805 if (sizes.count() != 2) { 1805 if (sizes.count() != 2) {
1806 sizes << mDateNavigator->minimumSizeHint().width(); 1806 sizes << mDateNavigator->minimumSizeHint().width();
1807 sizes << 300; 1807 sizes << 300;
1808 } 1808 }
1809 mPanner->setSizes(sizes); 1809 mPanner->setSizes(sizes);
1810 1810
1811 sizes = config->readIntListEntry("Separator2"); 1811 sizes = config->readIntListEntry("Separator2");
1812 if ( ( mResourceView && sizes.count() == 4 ) || 1812 if ( ( mResourceView && sizes.count() == 4 ) ||
1813 ( !mResourceView && sizes.count() == 3 ) ) { 1813 ( !mResourceView && sizes.count() == 3 ) ) {
1814 mLeftSplitter->setSizes(sizes); 1814 mLeftSplitter->setSizes(sizes);
1815 } 1815 }
1816#endif 1816#endif
1817 globalFlagBlockAgenda = 1; 1817 globalFlagBlockAgenda = 1;
1818 mViewManager->showAgendaView(); 1818 mViewManager->showAgendaView();
1819 //mViewManager->readSettings( config ); 1819 //mViewManager->readSettings( config );
1820 mTodoList->restoreLayout(config,QString("Todo Layout")); 1820 mTodoList->restoreLayout(config,QString("Todo Layout"));
1821 readFilterSettings(config); 1821 readFilterSettings(config);
1822 config->setGroup( "Views" ); 1822 config->setGroup( "Views" );
1823 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1823 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1824 1824
1825 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 1825 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
1826 1826
1827 int resetval = 0; 1827 int resetval = 0;
1828 int maxVal = 0; 1828 int maxVal = 0;
1829 if (sizes.count() != 3) { 1829 if (sizes.count() != 3) {
1830 if ( KOPrefs::instance()->mVerticalScreen ) { 1830 if ( KOPrefs::instance()->mVerticalScreen ) {
1831 resetval = mDateNavigator->sizeHint().width()+2; 1831 resetval = mDateNavigator->sizeHint().width()+2;
1832 } else { 1832 } else {
1833 resetval = mDateNavigator->sizeHint().height()+2; 1833 resetval = mDateNavigator->sizeHint().height()+2;
1834 } 1834 }
1835 } 1835 }
1836 if ( !resetval ){// i.e. sizes.count() == 3 1836 if ( !resetval ){// i.e. sizes.count() == 3
1837 if ( KOPrefs::instance()->mVerticalScreen ) { 1837 if ( KOPrefs::instance()->mVerticalScreen ) {
1838 if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) 1838 if ( sizes[0] < mDateNavigator->sizeHint().width()+1 )
1839 resetval = mDateNavigator->sizeHint().width()+2; 1839 resetval = mDateNavigator->sizeHint().width()+2;
1840 } else { 1840 } else {
1841 if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) 1841 if ( sizes[0] < mDateNavigator->sizeHint().height()+1 )
1842 resetval = mDateNavigator->sizeHint().height()+2; 1842 resetval = mDateNavigator->sizeHint().height()+2;
1843 } 1843 }
1844 } 1844 }
1845 if ( resetval ) { 1845 if ( resetval ) {
1846 sizes.clear(); 1846 sizes.clear();
1847 if ( KOPrefs::instance()->mVerticalScreen ) { 1847 if ( KOPrefs::instance()->mVerticalScreen ) {
1848 maxVal = QApplication::desktop()->width() -10; 1848 maxVal = QApplication::desktop()->width() -10;
1849 } else { 1849 } else {
1850 maxVal = QApplication::desktop()->height()-10; 1850 maxVal = QApplication::desktop()->height()-10;
1851 } 1851 }
1852 sizes << resetval; 1852 sizes << resetval;
1853 if ( maxVal < resetval + resetval) 1853 if ( maxVal < resetval + resetval)
1854 resetval = maxVal - resetval; 1854 resetval = maxVal - resetval;
1855 sizes << resetval; 1855 sizes << resetval;
1856 sizes << 100; 1856 sizes << 100;
1857 } 1857 }
1858 mLeftFrame->setSizes(sizes); 1858 mLeftFrame->setSizes(sizes);
1859 qDebug("sizes count %d ", sizes.count());
1860 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1859 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1861 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1860 else if ( dateCount == 7 ) mNavigator->selectWeek();
1862 else mNavigator->selectDates( dateCount ); 1861 else mNavigator->selectDates( dateCount );
1863 // mViewManager->readSettings( config ); 1862 // mViewManager->readSettings( config );
1864 updateConfig(); 1863 updateConfig();
1865 globalFlagBlockAgenda = 2; 1864 globalFlagBlockAgenda = 2;
1866 mViewManager->readSettings( config ); 1865 mViewManager->readSettings( config );
1867#ifdef DESKTOP_VERSION 1866#ifdef DESKTOP_VERSION
1868 config->setGroup("WidgetLayout"); 1867 config->setGroup("WidgetLayout");
1869 QStringList list; 1868 QStringList list;
1870 list = config->readListEntry("MainLayout"); 1869 list = config->readListEntry("MainLayout");
1871 int x,y,w,h; 1870 int x,y,w,h;
1872 if ( ! list.isEmpty() ) { 1871 if ( ! list.isEmpty() ) {
1873 x = list[0].toInt(); 1872 x = list[0].toInt();
1874 y = list[1].toInt(); 1873 y = list[1].toInt();
1875 w = list[2].toInt(); 1874 w = list[2].toInt();
1876 h = list[3].toInt(); 1875 h = list[3].toInt();
1877 topLevelWidget()->setGeometry(x,y,w,h); 1876 topLevelWidget()->setGeometry(x,y,w,h);
1878 1877
1879 } else { 1878 } else {
1880 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1879 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1881 } 1880 }
1882 list = config->readListEntry("EditEventLayout"); 1881 list = config->readListEntry("EditEventLayout");
1883 if ( ! list.isEmpty() ) { 1882 if ( ! list.isEmpty() ) {
1884 x = list[0].toInt(); 1883 x = list[0].toInt();
1885 y = list[1].toInt(); 1884 y = list[1].toInt();
1886 w = list[2].toInt(); 1885 w = list[2].toInt();
1887 h = list[3].toInt(); 1886 h = list[3].toInt();
1888 mEventEditor->setGeometry(x,y,w,h); 1887 mEventEditor->setGeometry(x,y,w,h);
1889 1888
1890 } 1889 }
1891 list = config->readListEntry("EditTodoLayout"); 1890 list = config->readListEntry("EditTodoLayout");
1892 if ( ! list.isEmpty() ) { 1891 if ( ! list.isEmpty() ) {
1893 x = list[0].toInt(); 1892 x = list[0].toInt();
1894 y = list[1].toInt(); 1893 y = list[1].toInt();
1895 w = list[2].toInt(); 1894 w = list[2].toInt();
1896 h = list[3].toInt(); 1895 h = list[3].toInt();
1897 mTodoEditor->setGeometry(x,y,w,h); 1896 mTodoEditor->setGeometry(x,y,w,h);
1898 1897
1899 } 1898 }
1900 list = config->readListEntry("ViewerLayout"); 1899 list = config->readListEntry("ViewerLayout");
1901 if ( ! list.isEmpty() ) { 1900 if ( ! list.isEmpty() ) {
1902 x = list[0].toInt(); 1901 x = list[0].toInt();
1903 y = list[1].toInt(); 1902 y = list[1].toInt();
1904 w = list[2].toInt(); 1903 w = list[2].toInt();
1905 h = list[3].toInt(); 1904 h = list[3].toInt();
1906 getEventViewerDialog()->setGeometry(x,y,w,h); 1905 getEventViewerDialog()->setGeometry(x,y,w,h);
1907 } 1906 }
1908#endif 1907#endif
1909 1908
1910} 1909}
1911 1910
1912 1911
1913void CalendarView::writeSettings() 1912void CalendarView::writeSettings()
1914{ 1913{
1915 // kdDebug() << "CalendarView::writeSettings" << endl; 1914 // kdDebug() << "CalendarView::writeSettings" << endl;
1916 1915
1917 KConfig *config = KOGlobals::config(); 1916 KConfig *config = KOGlobals::config();
1918 1917
1919#ifndef KORG_NOSPLITTER 1918#ifndef KORG_NOSPLITTER
1920 config->setGroup("KOrganizer Geometry"); 1919 config->setGroup("KOrganizer Geometry");
1921 1920
1922 QValueList<int> list = mPanner->sizes(); 1921 QValueList<int> list = mPanner->sizes();
1923 config->writeEntry("Separator1",list); 1922 config->writeEntry("Separator1",list);
1924 1923
1925 list = mLeftSplitter->sizes(); 1924 list = mLeftSplitter->sizes();
1926 config->writeEntry("Separator2",list); 1925 config->writeEntry("Separator2",list);
1927#endif 1926#endif
1928 1927
1929 mViewManager->writeSettings( config ); 1928 mViewManager->writeSettings( config );
1930 mTodoList->saveLayout(config,QString("Todo Layout")); 1929 mTodoList->saveLayout(config,QString("Todo Layout"));
1931 mDialogManager->writeSettings( config ); 1930 mDialogManager->writeSettings( config );
1932 //KOPrefs::instance()->usrWriteConfig(); 1931 //KOPrefs::instance()->usrWriteConfig();
1933 KOPrefs::instance()->writeConfig(); 1932 KOPrefs::instance()->writeConfig();
1934 1933
1935 writeFilterSettings(config); 1934 writeFilterSettings(config);
1936 1935
1937 config->setGroup( "Views" ); 1936 config->setGroup( "Views" );
1938 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1937 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1939 1938
1940 QValueList<int> list = mLeftFrame->sizes(); 1939 QValueList<int> list = mLeftFrame->sizes();
1941 config->writeEntry("Left Splitter Frame",list); 1940 config->writeEntry("Left Splitter Frame",list);
1942 1941
1943#ifdef DESKTOP_VERSION 1942#ifdef DESKTOP_VERSION
1944 config->setGroup("WidgetLayout"); 1943 config->setGroup("WidgetLayout");
1945 QStringList list ;//= config->readListEntry("MainLayout"); 1944 QStringList list ;//= config->readListEntry("MainLayout");
1946 int x,y,w,h; 1945 int x,y,w,h;
1947 QWidget* wid; 1946 QWidget* wid;
1948 wid = topLevelWidget(); 1947 wid = topLevelWidget();
1949 x = wid->geometry().x(); 1948 x = wid->geometry().x();
1950 y = wid->geometry().y(); 1949 y = wid->geometry().y();
1951 w = wid->width(); 1950 w = wid->width();
1952 h = wid->height(); 1951 h = wid->height();
1953 list.clear(); 1952 list.clear();
1954 list << QString::number( x ); 1953 list << QString::number( x );
1955 list << QString::number( y ); 1954 list << QString::number( y );
1956 list << QString::number( w ); 1955 list << QString::number( w );
1957 list << QString::number( h ); 1956 list << QString::number( h );
1958 config->writeEntry("MainLayout",list ); 1957 config->writeEntry("MainLayout",list );
1959 1958
1960 wid = mEventEditor; 1959 wid = mEventEditor;
1961 x = wid->geometry().x(); 1960 x = wid->geometry().x();
1962 y = wid->geometry().y(); 1961 y = wid->geometry().y();
1963 w = wid->width(); 1962 w = wid->width();
1964 h = wid->height(); 1963 h = wid->height();
1965 list.clear(); 1964 list.clear();
1966 list << QString::number( x ); 1965 list << QString::number( x );
1967 list << QString::number( y ); 1966 list << QString::number( y );
1968 list << QString::number( w ); 1967 list << QString::number( w );
1969 list << QString::number( h ); 1968 list << QString::number( h );
1970 config->writeEntry("EditEventLayout",list ); 1969 config->writeEntry("EditEventLayout",list );
1971 1970
1972 wid = mTodoEditor; 1971 wid = mTodoEditor;
1973 x = wid->geometry().x(); 1972 x = wid->geometry().x();
1974 y = wid->geometry().y(); 1973 y = wid->geometry().y();
1975 w = wid->width(); 1974 w = wid->width();
1976 h = wid->height(); 1975 h = wid->height();
1977 list.clear(); 1976 list.clear();
1978 list << QString::number( x ); 1977 list << QString::number( x );
1979 list << QString::number( y ); 1978 list << QString::number( y );
1980 list << QString::number( w ); 1979 list << QString::number( w );
1981 list << QString::number( h ); 1980 list << QString::number( h );
1982 config->writeEntry("EditTodoLayout",list ); 1981 config->writeEntry("EditTodoLayout",list );
1983 wid = getEventViewerDialog(); 1982 wid = getEventViewerDialog();
1984 x = wid->geometry().x(); 1983 x = wid->geometry().x();
1985 y = wid->geometry().y(); 1984 y = wid->geometry().y();
1986 w = wid->width(); 1985 w = wid->width();
1987 h = wid->height(); 1986 h = wid->height();
1988 list.clear(); 1987 list.clear();
1989 list << QString::number( x ); 1988 list << QString::number( x );
1990 list << QString::number( y ); 1989 list << QString::number( y );
1991 list << QString::number( w ); 1990 list << QString::number( w );
1992 list << QString::number( h ); 1991 list << QString::number( h );
1993 config->writeEntry("ViewerLayout",list ); 1992 config->writeEntry("ViewerLayout",list );
1994 wid = mDialogManager->getSearchDialog(); 1993 wid = mDialogManager->getSearchDialog();
1995 if ( wid ) { 1994 if ( wid ) {
1996 x = wid->geometry().x(); 1995 x = wid->geometry().x();
1997 y = wid->geometry().y(); 1996 y = wid->geometry().y();
1998 w = wid->width(); 1997 w = wid->width();
1999 h = wid->height(); 1998 h = wid->height();
2000 list.clear(); 1999 list.clear();
2001 list << QString::number( x ); 2000 list << QString::number( x );
2002 list << QString::number( y ); 2001 list << QString::number( y );
2003 list << QString::number( w ); 2002 list << QString::number( w );
2004 list << QString::number( h ); 2003 list << QString::number( h );
2005 config->writeEntry("SearchLayout",list ); 2004 config->writeEntry("SearchLayout",list );
2006 } 2005 }
2007#endif 2006#endif
2008 2007
2009 2008
2010 config->sync(); 2009 config->sync();
2011} 2010}
2012 2011
2013void CalendarView::readFilterSettings(KConfig *config) 2012void CalendarView::readFilterSettings(KConfig *config)
2014{ 2013{
2015 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2014 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2016 2015
2017 mFilters.clear(); 2016 mFilters.clear();
2018 2017
2019 config->setGroup("General"); 2018 config->setGroup("General");
2020 QStringList filterList = config->readListEntry("CalendarFilters"); 2019 QStringList filterList = config->readListEntry("CalendarFilters");
2021 2020
2022 QStringList::ConstIterator it = filterList.begin(); 2021 QStringList::ConstIterator it = filterList.begin();
2023 QStringList::ConstIterator end = filterList.end(); 2022 QStringList::ConstIterator end = filterList.end();
2024 while(it != end) { 2023 while(it != end) {
2025 // kdDebug() << " filter: " << (*it) << endl; 2024 // kdDebug() << " filter: " << (*it) << endl;
2026 2025
2027 CalFilter *filter; 2026 CalFilter *filter;
2028 filter = new CalFilter(*it); 2027 filter = new CalFilter(*it);
2029 config->setGroup("Filter_" + (*it)); 2028 config->setGroup("Filter_" + (*it));
2030 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2029 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2031 filter->setCriteria(config->readNumEntry("Criteria",0)); 2030 filter->setCriteria(config->readNumEntry("Criteria",0));
2032 filter->setCategoryList(config->readListEntry("CategoryList")); 2031 filter->setCategoryList(config->readListEntry("CategoryList"));
2033 mFilters.append(filter); 2032 mFilters.append(filter);
2034 2033
2035 ++it; 2034 ++it;
2036 } 2035 }
2037 2036
2038 if (mFilters.count() == 0) { 2037 if (mFilters.count() == 0) {
2039 CalFilter *filter = new CalFilter(i18n("Default")); 2038 CalFilter *filter = new CalFilter(i18n("Default"));
2040 mFilters.append(filter); 2039 mFilters.append(filter);
2041 } 2040 }
2042 mFilterView->updateFilters(); 2041 mFilterView->updateFilters();
2043 config->setGroup("FilterView"); 2042 config->setGroup("FilterView");
2044 2043
2045 mFilterView->blockSignals(true); 2044 mFilterView->blockSignals(true);
2046 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2045 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2047 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2046 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2048 mFilterView->blockSignals(false); 2047 mFilterView->blockSignals(false);
2049 // We do it manually to avoid it being done twice by the above calls 2048 // We do it manually to avoid it being done twice by the above calls
2050 updateFilter(); 2049 updateFilter();
2051} 2050}
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 3f6e29b..d09f484 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -1,219 +1,229 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 5 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <kdebug.h> 26#include <kdebug.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29//#include "koglobals.h" 29//#include "koglobals.h"
30#include "navigatorbar.h" 30#include "navigatorbar.h"
31#include "kdatenavigator.h" 31#include "kdatenavigator.h"
32 32
33#include <kcalendarsystem.h> 33#include <kcalendarsystem.h>
34 34
35#include "datenavigatorcontainer.h" 35#include "datenavigatorcontainer.h"
36 36
37DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, 37DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
38 const char *name ) 38 const char *name )
39 : QWidget( parent, name ), mCalendar( 0 ), 39 : QWidget( parent, name ), mCalendar( 0 ),
40 mHorizontalCount( 1 ), mVerticalCount( 1 ) 40 mHorizontalCount( 1 ), mVerticalCount( 1 )
41{ 41{
42 mExtraViews.setAutoDelete( true ); 42 mExtraViews.setAutoDelete( true );
43 43
44 mNavigatorView = new KDateNavigator( this, name ); 44 mNavigatorView = new KDateNavigator( this, name );
45 45
46 connectNavigatorView( mNavigatorView ); 46 connectNavigatorView( mNavigatorView );
47} 47}
48 48
49DateNavigatorContainer::~DateNavigatorContainer() 49DateNavigatorContainer::~DateNavigatorContainer()
50{ 50{
51} 51}
52 52
53void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) 53void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
54{ 54{
55 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), 55 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ),
56 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 56 SIGNAL( datesSelected( const KCal::DateList & ) ) );
57#if 0 57#if 0
58 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), 58 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ),
59 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); 59 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) );
60 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), 60 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ),
61 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); 61 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) );
62#endif 62#endif
63 connect( v, SIGNAL( weekClicked( const QDate & ) ), 63 connect( v, SIGNAL( weekClicked( const QDate & ) ),
64 SIGNAL( weekClicked( const QDate & ) ) ); 64 SIGNAL( weekClicked( const QDate & ) ) );
65 65
66 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); 66 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
67 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); 67 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
68 68
69 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 69 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
70 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 70 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
71 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 71 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
72 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 72 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
73 73
74 connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); 74 connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) );
75} 75}
76 76
77void DateNavigatorContainer::setCalendar( Calendar *cal ) 77void DateNavigatorContainer::setCalendar( Calendar *cal )
78{ 78{
79 mCalendar = cal; 79 mCalendar = cal;
80 mNavigatorView->setCalendar( cal ); 80 mNavigatorView->setCalendar( cal );
81 KDateNavigator *n; 81 KDateNavigator *n;
82 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 82 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
83 n->setCalendar( cal ); 83 n->setCalendar( cal );
84 } 84 }
85} 85}
86 86
87void DateNavigatorContainer::updateDayMatrix() 87void DateNavigatorContainer::updateDayMatrix()
88{ 88{
89 mNavigatorView->updateDayMatrix(); 89 mNavigatorView->updateDayMatrix();
90 KDateNavigator *n; 90 KDateNavigator *n;
91 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 91 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
92 n->updateDayMatrix(); 92 n->updateDayMatrix();
93 } 93 }
94} 94}
95 95
96void DateNavigatorContainer::updateToday() 96void DateNavigatorContainer::updateToday()
97{ 97{
98 qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); 98 qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
99#if 0 99#if 0
100 mNavigatorView->updateToday(); 100 mNavigatorView->updateToday();
101 KDateNavigator *n; 101 KDateNavigator *n;
102 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 102 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
103 n->updateToday(); 103 n->updateToday();
104 } 104 }
105#endif 105#endif
106} 106}
107 107
108void DateNavigatorContainer::updateView() 108void DateNavigatorContainer::updateView()
109{ 109{
110 mNavigatorView->updateView(); 110 mNavigatorView->updateView();
111 KDateNavigator *n; 111 KDateNavigator *n;
112 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 112 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
113 n->updateView(); 113 n->updateView();
114 } 114 }
115} 115}
116 116
117void DateNavigatorContainer::updateConfig() 117void DateNavigatorContainer::updateConfig()
118{ 118{
119 mNavigatorView->updateConfig(); 119 mNavigatorView->updateConfig();
120 KDateNavigator *n; 120 KDateNavigator *n;
121 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 121 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
122 n->updateConfig(); 122 n->updateConfig();
123 } 123 }
124} 124}
125 125
126void DateNavigatorContainer::selectDates( const DateList &dateList ) 126void DateNavigatorContainer::selectDates( const DateList &dateList )
127{ 127{
128 mNavigatorView->selectDates( dateList ); 128 mNavigatorView->selectDates( dateList );
129 setBaseDates(); 129 setBaseDates();
130 if ( mExtraViews.count() ) {
131 KDateNavigator *view = mExtraViews.at( 0 );
132 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
133 view->dayMatrix()->repaint();
134 }
130} 135}
131 136
132void DateNavigatorContainer::setBaseDates() 137void DateNavigatorContainer::setBaseDates()
133{ 138{
134 KCal::DateList dateList = mNavigatorView->selectedDates(); 139 KCal::DateList dateList = mNavigatorView->selectedDates();
135 if ( dateList.isEmpty() ) { 140 if ( dateList.isEmpty() ) {
136 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; 141 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl;
137 } 142 }
138 QDate baseDate = dateList.first(); 143 QDate baseDate = dateList.first();
139 KDateNavigator *n; 144 KDateNavigator *n;
145 bool doRepaint = false; // skip first repaint
140 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 146 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
141 baseDate = baseDate.addDays( baseDate.daysInMonth () ); 147 baseDate = baseDate.addDays( baseDate.daysInMonth () );
142 n->setBaseDate( baseDate ); 148 n->setBaseDate( baseDate, doRepaint );
149 doRepaint = true;
143 } 150 }
144} 151}
145 152
146void DateNavigatorContainer::resizeEvent( QResizeEvent * ) 153void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
147{ 154{
148#if 0 155#if 0
149 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; 156 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl;
150 kdDebug(5850) << " CURRENT SIZE: " << size() << endl; 157 kdDebug(5850) << " CURRENT SIZE: " << size() << endl;
151 kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; 158 kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl;
152 kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; 159 kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl;
153 kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; 160 kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl;
154#endif 161#endif
155 162 QSize minSize = mNavigatorView->yourSizeHint();
156 QSize minSize = mNavigatorView->minimumSizeHint();
157 163
158// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; 164// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl;
159 165
160 int verticalCount = size().height() / minSize.height(); 166 int verticalCount = size().height() / minSize.height();
161 int horizontalCount = size().width() / minSize.width(); 167 int horizontalCount = size().width() / minSize.width();
168 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
162 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); 169 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
163 if ( horizontalCount != mHorizontalCount || 170 if ( horizontalCount != mHorizontalCount ||
164 verticalCount != mVerticalCount ) { 171 verticalCount != mVerticalCount ) {
165 uint count = horizontalCount * verticalCount; 172 uint count = horizontalCount * verticalCount;
166 if ( count == 0 ) return; 173 if ( count == 0 ) {
174 mNavigatorView->resize( minSize );
175 return;
176 }
167 177
168 while ( count > ( mExtraViews.count() + 1 ) ) { 178 while ( count > ( mExtraViews.count() + 1 ) ) {
169 KDateNavigator *n = new KDateNavigator( this ); 179 KDateNavigator *n = new KDateNavigator( this );
170 n->setMonthSignalOffset ( mExtraViews.count()+1 ); 180 n->setMonthSignalOffset ( mExtraViews.count()+1 );
171 mExtraViews.append( n ); 181 mExtraViews.append( n );
172 n->setCalendar( mCalendar ); 182 n->setCalendar( mCalendar );
173 setBaseDates(); 183 setBaseDates();
174 connectNavigatorView( n ); 184 connectNavigatorView( n );
175 n->show(); 185 n->show();
176 } 186 }
177 187
178 while ( count < ( mExtraViews.count() + 1 ) ) { 188 while ( count < ( mExtraViews.count() + 1 ) ) {
179 mExtraViews.removeLast(); 189 mExtraViews.removeLast();
180 } 190 }
181 191
182 mHorizontalCount = horizontalCount; 192 mHorizontalCount = horizontalCount;
183 mVerticalCount = verticalCount; 193 mVerticalCount = verticalCount;
184 } 194 }
185 195
186 int height = size().height() / verticalCount; 196 int height = size().height() / verticalCount;
187 int width = size().width() / horizontalCount; 197 int width = size().width() / horizontalCount;
188 198
189 NavigatorBar *bar = mNavigatorView->navigatorBar(); 199 NavigatorBar *bar = mNavigatorView->navigatorBar();
190 if ( horizontalCount > 1 ) bar->showButtons( true, false ); 200 if ( horizontalCount > 1 ) bar->showButtons( true, false );
191 else bar->showButtons( true, true ); 201 else bar->showButtons( true, true );
192 202
193 mNavigatorView->setGeometry(0, 203 mNavigatorView->setGeometry(0,
194 0, width, height ); 204 0, width, height );
195 for( uint i = 0; i < mExtraViews.count(); ++i ) { 205 for( uint i = 0; i < mExtraViews.count(); ++i ) {
196 int x = ( i + 1 ) % horizontalCount; 206 int x = ( i + 1 ) % horizontalCount;
197 int y = ( i + 1 ) / horizontalCount; 207 int y = ( i + 1 ) / horizontalCount;
198 208
199 KDateNavigator *view = mExtraViews.at( i ); 209 KDateNavigator *view = mExtraViews.at( i );
200 bar = view->navigatorBar(); 210 bar = view->navigatorBar();
201 if ( y > 0 ) bar->showButtons( false, false ); 211 if ( y > 0 ) bar->showButtons( false, false );
202 else { 212 else {
203 if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); 213 if ( x + 1 == horizontalCount ) bar->showButtons( false, true );
204 else bar->showButtons( false, false ); 214 else bar->showButtons( false, false );
205 } 215 }
206 view->setGeometry( x * width, 216 view->setGeometry( x * width,
207 y * height, width, height ); 217 y * height, width, height );
208 } 218 }
209} 219}
210 220
211QSize DateNavigatorContainer::minimumSizeHint() const 221QSize DateNavigatorContainer::minimumSizeHint() const
212{ 222{
213 return mNavigatorView->minimumSizeHint(); 223 return mNavigatorView->minimumSizeHint();
214} 224}
215 225
216QSize DateNavigatorContainer::sizeHint() const 226QSize DateNavigatorContainer::sizeHint() const
217{ 227{
218 return mNavigatorView->sizeHint(); 228 return mNavigatorView->sizeHint();
219} 229}
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index ab9a40f..b097dc1 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -1,337 +1,338 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qkeycode.h> 25#include <qkeycode.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qframe.h> 28#include <qframe.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qapplication.h> 30#include <qapplication.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kglobal.h> 34#include <kglobal.h>
35 35
36#include "koglobals.h" 36#include "koglobals.h"
37#include "koprefs.h" 37#include "koprefs.h"
38#ifndef KORG_NOPLUGINS 38#ifndef KORG_NOPLUGINS
39#include "kocore.h" 39#include "kocore.h"
40#endif 40#endif
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#include "navigatorbar.h" 44#include "navigatorbar.h"
45 45
46#include "kdatenavigator.h" 46#include "kdatenavigator.h"
47 47
48KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) 48KDateNavigator::KDateNavigator( QWidget *parent, const char *name )
49 : QFrame(parent, name), 49 : QFrame(parent, name),
50 updateTimer(0L) 50 updateTimer(0L)
51{ 51{
52 setFrameStyle(QFrame::NoFrame); 52 setFrameStyle(QFrame::NoFrame);
53 QDate startDate = QDate::currentDate(); 53 QDate startDate = QDate::currentDate();
54 QGridLayout *topLayout = new QGridLayout(this,8,8); 54 QGridLayout *topLayout = new QGridLayout(this,8,8);
55 55
56 if (! startDate.isValid()) { 56 if (! startDate.isValid()) {
57 qDebug("KDateNavigator::invalid startdate "); 57 qDebug("KDateNavigator::invalid startdate ");
58 startDate = QDate::currentDate(); 58 startDate = QDate::currentDate();
59 } 59 }
60 mMonthSignalOffset = 0; 60 mMonthSignalOffset = 0;
61 mSelectedDates.append(startDate); 61 mSelectedDates.append(startDate);
62 m_MthYr = startDate; 62 m_MthYr = startDate;
63 m_bShowWeekNums = true; 63 m_bShowWeekNums = true;
64 64
65 setFont( KOPrefs::instance()->mDateNavigatorFont ); 65 setFont( KOPrefs::instance()->mDateNavigatorFont );
66 mNavigatorBar = new NavigatorBar( startDate, this ); 66 mNavigatorBar = new NavigatorBar( startDate, this );
67 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); 67 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 );
68 //mNavigatorBar->resize( 1,1); 68 //mNavigatorBar->resize( 1,1);
69 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 69 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
70 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 70 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
71 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 71 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
72 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 72 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
73 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 73 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
74 74
75 // get the day of the week on the first day 75 // get the day of the week on the first day
76 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 76 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
77 m_fstDayOfWk = dayone.dayOfWeek(); 77 m_fstDayOfWk = dayone.dayOfWeek();
78 78
79 int i; 79 int i;
80 80
81 // Set up the heading fields. 81 // Set up the heading fields.
82 for( i = 0; i < 7; i++ ) { 82 for( i = 0; i < 7; i++ ) {
83 headings[i] = new QLabel("",this); 83 headings[i] = new QLabel("",this);
84 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); 84 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
85 headings[i]->setAlignment(AlignCenter); 85 headings[i]->setAlignment(AlignCenter);
86 86
87 topLayout->addWidget(headings[i],1,i+1); 87 topLayout->addWidget(headings[i],1,i+1);
88 } 88 }
89 89
90 // Create the weeknumber labels 90 // Create the weeknumber labels
91 for( i = 0; i < 6; i++ ) { 91 for( i = 0; i < 6; i++ ) {
92 weeknos[i] = new QLabel(this); 92 weeknos[i] = new QLabel(this);
93 weeknos[i]->setAlignment(AlignCenter); 93 weeknos[i]->setAlignment(AlignCenter);
94 //weeknos[i]->setFont(QFont("Arial", 10)); 94 //weeknos[i]->setFont(QFont("Arial", 10));
95 if(!m_bShowWeekNums) { 95 if(!m_bShowWeekNums) {
96 weeknos[i]->hide(); 96 weeknos[i]->hide();
97 } 97 }
98 weeknos[i]->installEventFilter(this); 98 weeknos[i]->installEventFilter(this);
99 99
100 topLayout->addWidget(weeknos[i],i+2,0); 100 topLayout->addWidget(weeknos[i],i+2,0);
101 } 101 }
102 102
103 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); 103 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix");
104 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); 104 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
105 daymatrix->setLineWidth(1); 105 daymatrix->setLineWidth(1);
106 106
107 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), 107 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
108 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 108 SIGNAL( datesSelected( const KCal::DateList & ) ) );
109 109
110 connect( daymatrix, SIGNAL( eventDropped( Event * ) ), 110 connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
111 SIGNAL( eventDropped( Event * ) ) ); 111 SIGNAL( eventDropped( Event * ) ) );
112 112
113 topLayout->addMultiCellWidget(daymatrix,2,7,1,7); 113 topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
114 114
115 // read settings from configuration file. 115 // read settings from configuration file.
116 updateConfig(); 116 updateConfig();
117 enableRollover(FollowMonth); 117 enableRollover(FollowMonth);
118 //setFixedSize ( sizeHint() ); 118 mySizeHint = sizeHint();
119} 119}
120void KDateNavigator::slotMonthSelected( int m ) 120void KDateNavigator::slotMonthSelected( int m )
121{ 121{
122 if ( m_MthYr.month() <= mMonthSignalOffset) 122 if ( m_MthYr.month() <= mMonthSignalOffset)
123 m += 12; 123 m += 12;
124 int mo = m - mMonthSignalOffset; 124 int mo = m - mMonthSignalOffset;
125 emit monthSelected( m - mMonthSignalOffset ); 125 emit monthSelected( m - mMonthSignalOffset );
126 126
127} 127}
128void KDateNavigator::setCalendar( Calendar *cal ) 128void KDateNavigator::setCalendar( Calendar *cal )
129{ 129{
130 daymatrix->setCalendar( cal ); 130 daymatrix->setCalendar( cal );
131} 131}
132 132
133void KDateNavigator::setBaseDate( const QDate &date ) 133void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true
134{ 134{
135 m_MthYr = date; 135 m_MthYr = date;
136 136
137 updateDates(); 137 updateDates();
138 updateView(); 138 updateView();
139 139
140 KCal::DateList dates; 140 KCal::DateList dates;
141 dates.append( date ); 141 dates.append( date );
142 mNavigatorBar->selectDates( dates ); 142 mNavigatorBar->selectDates( dates );
143 143
144 daymatrix->clearSelection(); 144 daymatrix->clearSelection();
145 daymatrix->repaint(); 145 if ( doRepaint )
146 daymatrix->repaint();
146} 147}
147 148
148void KDateNavigator::enableRollover(RolloverType r) 149void KDateNavigator::enableRollover(RolloverType r)
149{ 150{
150 switch(r) 151 switch(r)
151 { 152 {
152 case None : 153 case None :
153 if (updateTimer) 154 if (updateTimer)
154 { 155 {
155 updateTimer->stop(); 156 updateTimer->stop();
156 delete updateTimer; 157 delete updateTimer;
157 updateTimer=0L; 158 updateTimer=0L;
158 } 159 }
159 break; 160 break;
160 case FollowDay : 161 case FollowDay :
161 case FollowMonth : 162 case FollowMonth :
162 if (!updateTimer) 163 if (!updateTimer)
163 { 164 {
164 updateTimer = new QTimer(this); 165 updateTimer = new QTimer(this);
165 QObject::connect(updateTimer,SIGNAL(timeout()), 166 QObject::connect(updateTimer,SIGNAL(timeout()),
166 this,SLOT(possiblyPastMidnight())); 167 this,SLOT(possiblyPastMidnight()));
167 } 168 }
168 updateTimer->start(0,true); 169 updateTimer->start(0,true);
169 lastDayChecked = QDate::currentDate(); 170 lastDayChecked = QDate::currentDate();
170 } 171 }
171 updateRollover=r; 172 updateRollover=r;
172} 173}
173 174
174 175
175KDateNavigator::~KDateNavigator() 176KDateNavigator::~KDateNavigator()
176{ 177{
177} 178}
178 179
179 180
180void KDateNavigator::passedMidnight() 181void KDateNavigator::passedMidnight()
181{ 182{
182 QDate today = QDate::currentDate(); 183 QDate today = QDate::currentDate();
183 bool emitMonth = false; 184 bool emitMonth = false;
184 185
185 if (today.month() != lastDayChecked.month()) 186 if (today.month() != lastDayChecked.month())
186 { 187 {
187 if (updateRollover==FollowMonth && 188 if (updateRollover==FollowMonth &&
188 daymatrix->isEndOfMonth()) { 189 daymatrix->isEndOfMonth()) {
189 goNextMonth(); 190 goNextMonth();
190 emitMonth=true; 191 emitMonth=true;
191 } 192 }
192 } 193 }
193 daymatrix->recalculateToday(); 194 daymatrix->recalculateToday();
194 daymatrix->repaint(); 195 daymatrix->repaint();
195 emit dayPassed(today); 196 emit dayPassed(today);
196 if (emitMonth) { emit monthPassed(today); } 197 if (emitMonth) { emit monthPassed(today); }
197} 198}
198 199
199/* slot */ void KDateNavigator::possiblyPastMidnight() 200/* slot */ void KDateNavigator::possiblyPastMidnight()
200{ 201{
201 if (lastDayChecked!=QDate::currentDate()) 202 if (lastDayChecked!=QDate::currentDate())
202 { 203 {
203 passedMidnight(); 204 passedMidnight();
204 lastDayChecked=QDate::currentDate(); 205 lastDayChecked=QDate::currentDate();
205 } 206 }
206 // Set the timer to go off 1 second after midnight 207 // Set the timer to go off 1 second after midnight
207 // or after 8 minutes, whichever comes first. 208 // or after 8 minutes, whichever comes first.
208 if (updateTimer) 209 if (updateTimer)
209 { 210 {
210 QTime now = QTime::currentTime(); 211 QTime now = QTime::currentTime();
211 QTime midnight = QTime(23,59,59); 212 QTime midnight = QTime(23,59,59);
212 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); 213 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000);
213 214
214 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) 215 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait))
215 //.arg(now.toString()).arg(midnight.toString())); 216 //.arg(now.toString()).arg(midnight.toString()));
216 217
217 updateTimer->stop(); 218 updateTimer->stop();
218 updateTimer->start(msecsWait,true); 219 updateTimer->start(msecsWait,true);
219 } 220 }
220} 221}
221 222
222void KDateNavigator::updateDates() 223void KDateNavigator::updateDates()
223{ 224{
224 // Find the first day of the week of the current month. 225 // Find the first day of the week of the current month.
225 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); 226 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr );
226 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); 227 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() );
227 int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); 228 int d2 = KOGlobals::self()->calendarSystem()->day( dayone );
228 //int di = d1 - d2 + 1; 229 //int di = d1 - d2 + 1;
229 dayone = dayone.addDays( -d2 + 1 ); 230 dayone = dayone.addDays( -d2 + 1 );
230 231
231 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); 232 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone );
232 233
233 // If month begins on Monday and Monday is first day of week, 234 // If month begins on Monday and Monday is first day of week,
234 // month should begin on second line. Sunday doesn't have this problem. 235 // month should begin on second line. Sunday doesn't have this problem.
235 int nextLine = ( ( m_fstDayOfWkCalsys == 1) && 236 int nextLine = ( ( m_fstDayOfWkCalsys == 1) &&
236 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; 237 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0;
237 238
238 // update the matrix dates 239 // update the matrix dates
239 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; 240 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine;
240 241
241 242
242 daymatrix->updateView(dayone.addDays(index)); 243 daymatrix->updateView(dayone.addDays(index));
243//each updateDates is followed by an updateView -> repaint is issued there ! 244//each updateDates is followed by an updateView -> repaint is issued there !
244// daymatrix->repaint(); 245// daymatrix->repaint();
245} 246}
246 247
247void KDateNavigator::updateDayMatrix() 248void KDateNavigator::updateDayMatrix()
248{ 249{
249 daymatrix->updateView(); 250 daymatrix->updateView();
250 //daymatrix->repaint(); 251 //daymatrix->repaint();
251} 252}
252 253
253 254
254void KDateNavigator::updateView() 255void KDateNavigator::updateView()
255{ 256{
256 257
257 setUpdatesEnabled( false ); 258 setUpdatesEnabled( false );
258 259
259 int i; 260 int i;
260 261
261// kdDebug() << "updateView() -> daymatrix->updateView()" << endl; 262// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
262 daymatrix->updateView(); 263 daymatrix->updateView();
263 264
264 // set the week numbers. 265 // set the week numbers.
265 for(i = 0; i < 6; i++) { 266 for(i = 0; i < 6; i++) {
266 QString weeknum; 267 QString weeknum;
267 // remember, according to ISO 8601, the first week of the year is the 268 // remember, according to ISO 8601, the first week of the year is the
268 // first week that contains a thursday. Thus we must subtract off 4, 269 // first week that contains a thursday. Thus we must subtract off 4,
269 // not just 1. 270 // not just 1.
270 271
271 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); 272 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear();
272 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); 273 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4)));
273 274
274 int add = 0; 275 int add = 0;
275 if ( ! KGlobal::locale()->weekStartsMonday() ) 276 if ( ! KGlobal::locale()->weekStartsMonday() )
276 ++add; 277 ++add;
277 if (dayOfYear % 7 != 0) 278 if (dayOfYear % 7 != 0)
278 weeknum.setNum(dayOfYear / 7 + 1+add); 279 weeknum.setNum(dayOfYear / 7 + 1+add);
279 else 280 else
280 weeknum.setNum(dayOfYear / 7 +add); 281 weeknum.setNum(dayOfYear / 7 +add);
281 weeknos[i]->setText(weeknum); 282 weeknos[i]->setText(weeknum);
282 } 283 }
283 284
284 setUpdatesEnabled( true ); 285 setUpdatesEnabled( true );
285// kdDebug() << "updateView() -> repaint()" << endl; 286// kdDebug() << "updateView() -> repaint()" << endl;
286 repaint(); 287 repaint();
287 // daymatrix->repaint(); 288 // daymatrix->repaint();
288} 289}
289 290
290void KDateNavigator::updateConfig() 291void KDateNavigator::updateConfig()
291{ 292{
292 int day; 293 int day;
293 for(int i=0; i<7; i++) { 294 for(int i=0; i<7; i++) {
294 // take the first letter of the day name to be the abbreviation 295 // take the first letter of the day name to be the abbreviation
295 if (KGlobal::locale()->weekStartsMonday()) { 296 if (KGlobal::locale()->weekStartsMonday()) {
296 day = i+1; 297 day = i+1;
297 } else { 298 } else {
298 if (i==0) day = 7; 299 if (i==0) day = 7;
299 else day = i; 300 else day = i;
300 } 301 }
301 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, 302 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day,
302 true ); 303 true );
303 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); 304 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 );
304 headings[i]->setText( dayName ); 305 headings[i]->setText( dayName );
305 } 306 }
306 updateDates(); 307 updateDates();
307 updateView(); 308 updateView();
308} 309}
309 310
310void KDateNavigator::setShowWeekNums(bool enabled) 311void KDateNavigator::setShowWeekNums(bool enabled)
311{ 312{
312 m_bShowWeekNums = enabled; 313 m_bShowWeekNums = enabled;
313 for(int i=0; i<6; i++) { 314 for(int i=0; i<6; i++) {
314 if(enabled) 315 if(enabled)
315 weeknos[i]->show(); 316 weeknos[i]->show();
316 else 317 else
317 weeknos[i]->hide(); 318 weeknos[i]->hide();
318 } 319 }
319 resize(size()); 320 resize(size());
320} 321}
321 322
322void KDateNavigator::selectDates(const DateList& dateList) 323void KDateNavigator::selectDates(const DateList& dateList)
323{ 324{
324 325
325 if (dateList.count() > 0) { 326 if (dateList.count() > 0) {
326 mNavigatorBar->selectDates( dateList ); 327 mNavigatorBar->selectDates( dateList );
327 mSelectedDates = dateList; 328 mSelectedDates = dateList;
328 329
329 // set our record of the month and year that this datetbl is 330 // set our record of the month and year that this datetbl is
330 // displaying. 331 // displaying.
331 m_MthYr = mSelectedDates.first(); 332 m_MthYr = mSelectedDates.first();
332 333
333 334
334 // set our record of the first day of the week of the current 335 // set our record of the first day of the week of the current
335 // month. This needs to be done before calling dayToIndex, since it 336 // month. This needs to be done before calling dayToIndex, since it
336 // relies on this information being up to date. 337 // relies on this information being up to date.
337 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 338 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h
index 56822fa..292e71c 100644
--- a/korganizer/kdatenavigator.h
+++ b/korganizer/kdatenavigator.h
@@ -1,151 +1,154 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KDATENAVIGATOR_H 23#ifndef KDATENAVIGATOR_H
24#define KDATENAVIGATOR_H 24#define KDATENAVIGATOR_H
25 25
26#include <qframe.h> 26#include <qframe.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qlabel.h> 28#include <qlabel.h>
29 29
30#include <libkcal/calendar.h> 30#include <libkcal/calendar.h>
31 31
32#include "kodaymatrix.h" 32#include "kodaymatrix.h"
33 33
34class QPushButton; 34class QPushButton;
35class QTimer; 35class QTimer;
36 36
37class KCalendarSystem; 37class KCalendarSystem;
38 38
39class NavigatorBar; 39class NavigatorBar;
40 40
41class KDateNavigator: public QFrame 41class KDateNavigator: public QFrame
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44 public: 44 public:
45 KDateNavigator( QWidget *parent = 0,const char *name = 0 ); 45 KDateNavigator( QWidget *parent = 0,const char *name = 0 );
46 ~KDateNavigator(); 46 ~KDateNavigator();
47 47
48 /** The DateNavigator automatically checks for 48 /** The DateNavigator automatically checks for
49 * the passage of midnight. If rollover type is 49 * the passage of midnight. If rollover type is
50 * set to None, no signals are emitted and no 50 * set to None, no signals are emitted and no
51 * processing is done. With rollover set to 51 * processing is done. With rollover set to
52 * FollowDay, the day highlighter changes at 52 * FollowDay, the day highlighter changes at
53 * midnight and dayPassed() is emitted. 53 * midnight and dayPassed() is emitted.
54 * With FollowMonth, it has the same effect 54 * With FollowMonth, it has the same effect
55 * as FollowDay but also adjusts the month that is 55 * as FollowDay but also adjusts the month that is
56 * visible and emits monthPassed() when the month changes. 56 * visible and emits monthPassed() when the month changes.
57 */ 57 */
58 enum RolloverType { None, FollowDay, FollowMonth } ; 58 enum RolloverType { None, FollowDay, FollowMonth } ;
59 void enableRollover( RolloverType ); 59 void enableRollover( RolloverType );
60 60
61 void setShowWeekNums( bool enabled ); 61 void setShowWeekNums( bool enabled );
62 void setCalendar( Calendar * ); 62 void setCalendar( Calendar * );
63 void setBaseDate( const QDate & ); 63 void setBaseDate( const QDate & , bool doRepaint = true );
64 KCal::DateList selectedDates() const { return mSelectedDates; } 64 KCal::DateList selectedDates() const { return mSelectedDates; }
65 NavigatorBar *navigatorBar() const { return mNavigatorBar; } 65 NavigatorBar *navigatorBar() const { return mNavigatorBar; }
66 void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;} 66 void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;}
67 QSize yourSizeHint() { return mySizeHint; }
68 KODayMatrix *dayMatrix() { return daymatrix ;}
67 public slots: 69 public slots:
68 void selectDates( const KCal::DateList & ); 70 void selectDates( const KCal::DateList & );
69 void updateView(); 71 void updateView();
70 void updateConfig(); 72 void updateConfig();
71 void updateDayMatrix(); 73 void updateDayMatrix();
72 74
73 signals: 75 signals:
74 void datesSelected( const KCal::DateList & ); 76 void datesSelected( const KCal::DateList & );
75 void eventDropped( Event * ); 77 void eventDropped( Event * );
76 void weekClicked( const QDate &); 78 void weekClicked( const QDate &);
77 79
78 void goPrevious(); 80 void goPrevious();
79 void goNext(); 81 void goNext();
80 82
81 void goNextMonth(); 83 void goNextMonth();
82 void goPrevMonth(); 84 void goPrevMonth();
83 void goNextYear(); 85 void goNextYear();
84 void goPrevYear(); 86 void goPrevYear();
85 void monthSelected( int ); 87 void monthSelected( int );
86 88
87 // Signals emitted at midnight carrying the new date. 89 // Signals emitted at midnight carrying the new date.
88 void dayPassed( QDate ); 90 void dayPassed( QDate );
89 void monthPassed( QDate ); 91 void monthPassed( QDate );
90 92
91 protected slots: 93 protected slots:
92 94
93 /** 95 /**
94 * Called regularly to see if we need to update the view 96 * Called regularly to see if we need to update the view
95 * wrt. the today box and the month box. Only important 97 * wrt. the today box and the month box. Only important
96 * if you leave KOrganizer idle for long periods of time. 98 * if you leave KOrganizer idle for long periods of time.
97 * 99 *
98 * Until we have a reliable way of setting QTimers to go 100 * Until we have a reliable way of setting QTimers to go
99 * off at a particular wall-clock time, we need this, 101 * off at a particular wall-clock time, we need this,
100 * which calls passedMidnight() at the right moments. 102 * which calls passedMidnight() at the right moments.
101 */ 103 */
102 void possiblyPastMidnight(); 104 void possiblyPastMidnight();
103 105
104 /** handles updating the view when midnight has come by due to idle time. 106 /** handles updating the view when midnight has come by due to idle time.
105 * 107 *
106 */ 108 */
107 void passedMidnight(); 109 void passedMidnight();
108 void slotMonthSelected( int m ); 110 void slotMonthSelected( int m );
109 protected: 111 protected:
110 void updateDates(); 112 void updateDates();
111 113
112 void wheelEvent (QWheelEvent *); 114 void wheelEvent (QWheelEvent *);
113 115
114 bool eventFilter (QObject *,QEvent *); 116 bool eventFilter (QObject *,QEvent *);
115 117
116 private: 118 private:
119 QSize mySizeHint;
117 int mMonthSignalOffset; 120 int mMonthSignalOffset;
118 NavigatorBar *mNavigatorBar; 121 NavigatorBar *mNavigatorBar;
119 122
120 QFrame *headingSep; 123 QFrame *headingSep;
121 QFrame *weeknumSep; 124 QFrame *weeknumSep;
122 QLabel *headings[7]; 125 QLabel *headings[7];
123 QLabel *weeknos[7]; 126 QLabel *weeknos[7];
124 KODayMatrix *daymatrix; 127 KODayMatrix *daymatrix;
125 128
126 KCal::DateList mSelectedDates; 129 KCal::DateList mSelectedDates;
127 QDate m_MthYr; 130 QDate m_MthYr;
128 int m_fstDayOfWk; 131 int m_fstDayOfWk;
129 bool m_bShowWeekNums; 132 bool m_bShowWeekNums;
130 133
131 int dayNum(int row, int col); 134 int dayNum(int row, int col);
132 int dayToIndex(int dayNum); 135 int dayToIndex(int dayNum);
133 136
134 Calendar *mCalendar; 137 Calendar *mCalendar;
135 KCalendarSystem *mCalendarSystem; 138 KCalendarSystem *mCalendarSystem;
136 139
137 const QString *curHeaders; 140 const QString *curHeaders;
138 141
139 /** used to update the day view periodically, in particular every 142 /** used to update the day view periodically, in particular every
140 * midnight to move the "today" rectangle. 143 * midnight to move the "today" rectangle.
141 */ 144 */
142 QTimer *updateTimer; 145 QTimer *updateTimer;
143 QDate lastDayChecked; 146 QDate lastDayChecked;
144 RolloverType updateRollover; 147 RolloverType updateRollover;
145 148
146 // Disabling copy constructor and assignment operator 149 // Disabling copy constructor and assignment operator
147 KDateNavigator(const KDateNavigator & ); 150 KDateNavigator(const KDateNavigator & );
148 KDateNavigator &operator=(const KDateNavigator &); 151 KDateNavigator &operator=(const KDateNavigator &);
149}; 152};
150 153
151#endif 154#endif
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index a886f4a..17a8546 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -12,385 +12,385 @@
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source ode for Qt in the source distribution. 22 without including the source ode for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qevent.h> 25#include <qevent.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qptrlist.h> 27#include <qptrlist.h>
28#include <qtimer.h> 28#include <qtimer.h>
29 29
30#include <kglobal.h> 30#include <kglobal.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <klocale.h> 32#include <klocale.h>
33 33
34#include <libkcal/vcaldrag.h> 34#include <libkcal/vcaldrag.h>
35#include <libkcal/icaldrag.h> 35#include <libkcal/icaldrag.h>
36#include <libkcal/dndfactory.h> 36#include <libkcal/dndfactory.h>
37#include <libkcal/calendarresources.h> 37#include <libkcal/calendarresources.h>
38#include <libkcal/resourcecalendar.h> 38#include <libkcal/resourcecalendar.h>
39#include <kresources/resourceselectdialog.h> 39#include <kresources/resourceselectdialog.h>
40 40
41#include <kcalendarsystem.h> 41#include <kcalendarsystem.h>
42 42
43#ifndef KORG_NOPLUGINS 43#ifndef KORG_NOPLUGINS
44#include "kocore.h" 44#include "kocore.h"
45#endif 45#endif
46#include "koprefs.h" 46#include "koprefs.h"
47#include "koglobals.h" 47#include "koglobals.h"
48 48
49#include "kodaymatrix.h" 49#include "kodaymatrix.h"
50 50
51// ============================================================================ 51// ============================================================================
52// D Y N A M I C T I P 52// D Y N A M I C T I P
53// ============================================================================ 53// ============================================================================
54 54
55DynamicTip::DynamicTip( QWidget * parent ) 55DynamicTip::DynamicTip( QWidget * parent )
56 : QToolTip( parent ) 56 : QToolTip( parent )
57{ 57{
58 matrix = (KODayMatrix*)parent; 58 matrix = (KODayMatrix*)parent;
59} 59}
60 60
61 61
62void DynamicTip::maybeTip( const QPoint &pos ) 62void DynamicTip::maybeTip( const QPoint &pos )
63{ 63{
64 //calculate which cell of the matrix the mouse is in 64 //calculate which cell of the matrix the mouse is in
65 QRect sz = matrix->frameRect(); 65 QRect sz = matrix->frameRect();
66 int dheight = sz.height()*7 / 42; 66 int dheight = sz.height()*7 / 42;
67 int dwidth = sz.width() / 7; 67 int dwidth = sz.width() / 7;
68 int row = pos.y()/dheight; 68 int row = pos.y()/dheight;
69 int col = pos.x()/dwidth; 69 int col = pos.x()/dwidth;
70 70
71 QRect rct(col*dwidth, row*dheight, dwidth, dheight); 71 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
72 72
73// kdDebug() << "DynamicTip::maybeTip matrix cell index [" << 73// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
74// col << "][" << row << "] => " <<(col+row*7) << endl; 74// col << "][" << row << "] => " <<(col+row*7) << endl;
75 75
76 //show holiday names only 76 //show holiday names only
77 QString str = matrix->getHolidayLabel(col+row*7); 77 QString str = matrix->getHolidayLabel(col+row*7);
78 if (str.isEmpty()) return; 78 if (str.isEmpty()) return;
79 tip(rct, str); 79 tip(rct, str);
80} 80}
81 81
82 82
83// ============================================================================ 83// ============================================================================
84// K O D A Y M A T R I X 84// K O D A Y M A T R I X
85// ============================================================================ 85// ============================================================================
86 86
87const int KODayMatrix::NOSELECTION = -1000; 87const int KODayMatrix::NOSELECTION = -1000;
88const int KODayMatrix::NUMDAYS = 42; 88const int KODayMatrix::NUMDAYS = 42;
89 89
90KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) 90KODayMatrix::KODayMatrix( QWidget *parent, const char *name )
91 : QFrame( parent, name ), mCalendar( 0 ) 91 : QFrame( parent, name ), mCalendar( 0 )
92 92
93#if 0 93#if 0
94KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : 94KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
95 QFrame(parent, name) 95 QFrame(parent, name)
96#endif 96#endif
97{ 97{
98 98
99 mPendingUpdateBeforeRepaint = false; 99 mPendingUpdateBeforeRepaint = false;
100 100
101 // initialize dynamic arrays 101 // initialize dynamic arrays
102 days = new QDate[NUMDAYS]; 102 days = new QDate[NUMDAYS];
103 daylbls = new QString[NUMDAYS]; 103 daylbls = new QString[NUMDAYS];
104 events = new int[NUMDAYS]; 104 events = new int[NUMDAYS];
105 mToolTip = new DynamicTip(this); 105 mToolTip = new DynamicTip(this);
106 106
107 // set default values used for drawing the matrix 107 // set default values used for drawing the matrix
108 mDefaultBackColor = palette().active().base(); 108 mDefaultBackColor = palette().active().base();
109 mDefaultTextColor = palette().active().foreground(); 109 mDefaultTextColor = palette().active().foreground();
110 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 110 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
111 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 111 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
112 mSelectedDaysColor = QColor("white"); 112 mSelectedDaysColor = QColor("white");
113 mTodayMarginWidth = 2; 113 mTodayMarginWidth = 2;
114 mSelEnd = mSelStart = NOSELECTION; 114 mSelEnd = mSelStart = NOSELECTION;
115 115
116 setAcceptDrops(true); 116 setAcceptDrops(true);
117 //setFont( QFont("Arial", 10) ); 117 //setFont( QFont("Arial", 10) );
118 118
119 mUpdateTimer = new QTimer( this ); 119 mUpdateTimer = new QTimer( this );
120 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); 120 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
121 mRepaintTimer = new QTimer( this ); 121 mRepaintTimer = new QTimer( this );
122 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); 122 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
123 mDayChanged = false; 123 mDayChanged = false;
124 updateView(); 124 updateView();
125} 125}
126void KODayMatrix::setCalendar( Calendar *cal ) 126void KODayMatrix::setCalendar( Calendar *cal )
127{ 127{
128 mCalendar = cal; 128 mCalendar = cal;
129 129
130 setAcceptDrops( mCalendar ); 130 setAcceptDrops( mCalendar );
131 131
132 updateEvents(); 132 updateEvents();
133} 133}
134 134
135QColor KODayMatrix::getShadedColor(QColor color) 135QColor KODayMatrix::getShadedColor(QColor color)
136{ 136{
137 QColor shaded; 137 QColor shaded;
138 int h=0; 138 int h=0;
139 int s=0; 139 int s=0;
140 int v=0; 140 int v=0;
141 color.hsv(&h,&s,&v); 141 color.hsv(&h,&s,&v);
142 s = s/4; 142 s = s/4;
143 v = 192+v/4; 143 v = 192+v/4;
144 shaded.setHsv(h,s,v); 144 shaded.setHsv(h,s,v);
145 145
146 return shaded; 146 return shaded;
147} 147}
148 148
149KODayMatrix::~KODayMatrix() 149KODayMatrix::~KODayMatrix()
150{ 150{
151 delete [] days; 151 delete [] days;
152 delete [] daylbls; 152 delete [] daylbls;
153 delete [] events; 153 delete [] events;
154 delete mToolTip; 154 delete mToolTip;
155} 155}
156 156
157/* 157/*
158void KODayMatrix::setStartDate(QDate start) 158void KODayMatrix::setStartDate(QDate start)
159{ 159{
160 updateView(start); 160 updateView(start);
161} 161}
162*/ 162*/
163 163
164void KODayMatrix::addSelectedDaysTo(DateList& selDays) 164void KODayMatrix::addSelectedDaysTo(DateList& selDays)
165{ 165{
166 166
167 if (mSelStart == NOSELECTION) { 167 if (mSelStart == NOSELECTION) {
168 return; 168 return;
169 } 169 }
170 170
171 //cope with selection being out of matrix limits at top (< 0) 171 //cope with selection being out of matrix limits at top (< 0)
172 int i0 = mSelStart; 172 int i0 = mSelStart;
173 if (i0 < 0) { 173 if (i0 < 0) {
174 for (int i = i0; i < 0; i++) { 174 for (int i = i0; i < 0; i++) {
175 selDays.append(days[0].addDays(i)); 175 selDays.append(days[0].addDays(i));
176 } 176 }
177 i0 = 0; 177 i0 = 0;
178 } 178 }
179 179
180 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 180 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
181 if (mSelEnd > NUMDAYS-1) { 181 if (mSelEnd > NUMDAYS-1) {
182 for (int i = i0; i <= NUMDAYS-1; i++) { 182 for (int i = i0; i <= NUMDAYS-1; i++) {
183 selDays.append(days[i]); 183 selDays.append(days[i]);
184 } 184 }
185 for (int i = NUMDAYS; i < mSelEnd; i++) { 185 for (int i = NUMDAYS; i < mSelEnd; i++) {
186 selDays.append(days[0].addDays(i)); 186 selDays.append(days[0].addDays(i));
187 } 187 }
188 188
189 // apply normal routine to selection being entirely within matrix limits 189 // apply normal routine to selection being entirely within matrix limits
190 } else { 190 } else {
191 for (int i = i0; i <= mSelEnd; i++) { 191 for (int i = i0; i <= mSelEnd; i++) {
192 selDays.append(days[i]); 192 selDays.append(days[i]);
193 } 193 }
194 } 194 }
195} 195}
196 196
197void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 197void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
198{ 198{
199 mSelStart = startdate.daysTo(start); 199 mSelStart = startdate.daysTo(start);
200 mSelEnd = startdate.daysTo(end); 200 mSelEnd = startdate.daysTo(end);
201} 201}
202void KODayMatrix::clearSelection() 202void KODayMatrix::clearSelection()
203{ 203{
204 mSelEnd = mSelStart = NOSELECTION; 204 mSelEnd = mSelStart = NOSELECTION;
205} 205}
206 206
207 207
208void KODayMatrix::recalculateToday() 208void KODayMatrix::recalculateToday()
209{ 209{
210 today = -1; 210 today = -1;
211 for (int i=0; i<NUMDAYS; i++) { 211 for (int i=0; i<NUMDAYS; i++) {
212 events[i] = 0; 212 events[i] = 0;
213 days[i] = startdate.addDays(i); 213 days[i] = startdate.addDays(i);
214 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 214 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
215 215
216 // if today is in the currently displayed month, hilight today 216 // if today is in the currently displayed month, hilight today
217 if (days[i].year() == QDate::currentDate().year() && 217 if (days[i].year() == QDate::currentDate().year() &&
218 days[i].month() == QDate::currentDate().month() && 218 days[i].month() == QDate::currentDate().month() &&
219 days[i].day() == QDate::currentDate().day()) { 219 days[i].day() == QDate::currentDate().day()) {
220 today = i; 220 today = i;
221 } 221 }
222 } 222 }
223 // qDebug(QString("Today is visible at %1.").arg(today)); 223 // qDebug(QString("Today is visible at %1.").arg(today));
224} 224}
225 225
226void KODayMatrix::updateView() 226void KODayMatrix::updateView()
227{ 227{
228 updateView(startdate); 228 updateView(startdate);
229} 229}
230void KODayMatrix::repaintViewTimed() 230void KODayMatrix::repaintViewTimed()
231{ 231{
232 mRepaintTimer->stop(); 232 mRepaintTimer->stop();
233 repaint(false); 233 repaint(false);
234} 234}
235void KODayMatrix::updateViewTimed() 235void KODayMatrix::updateViewTimed()
236{ 236{
237 mUpdateTimer->stop(); 237 mUpdateTimer->stop();
238 if ( !mCalendar ) { 238 if ( !mCalendar ) {
239 qDebug("NOT CAL "); 239 qDebug("NOT CAL ");
240 return; 240 return;
241 } 241 }
242 //qDebug("KODayMatrix::updateViewTimed "); 242 //qDebug("KODayMatrix::updateViewTimed ");
243 for(int i = 0; i < NUMDAYS; i++) { 243 for(int i = 0; i < NUMDAYS; i++) {
244 // if events are set for the day then remember to draw it bold 244 // if events are set for the day then remember to draw it bold
245 QPtrList<Event> eventlist = mCalendar->events(days[i]); 245 QPtrList<Event> eventlist = mCalendar->events(days[i]);
246 Event *event; 246 Event *event;
247 int numEvents = eventlist.count(); 247 int numEvents = eventlist.count();
248 QString holiStr = ""; 248 QString holiStr = "";
249 for(event=eventlist.first();event != 0;event=eventlist.next()) { 249 for(event=eventlist.first();event != 0;event=eventlist.next()) {
250 ushort recurType = event->recurrence()->doesRecur(); 250 ushort recurType = event->recurrence()->doesRecur();
251 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 251 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
252 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 252 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
253 numEvents--; 253 numEvents--;
254 } 254 }
255 if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { 255 if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) {
256 if ( !holiStr.isEmpty() ) 256 if ( !holiStr.isEmpty() )
257 holiStr += "\n"; 257 holiStr += "\n";
258 holiStr += event->summary(); 258 holiStr += event->summary();
259 } 259 }
260 } 260 }
261 events[i] = numEvents; 261 events[i] = numEvents;
262 //if it is a holy day then draw it red. Sundays are consider holidays, too 262 //if it is a holy day then draw it red. Sundays are consider holidays, too
263 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 263 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
264 !holiStr.isEmpty()) { 264 !holiStr.isEmpty()) {
265 mHolidays[i] = holiStr; 265 mHolidays[i] = holiStr;
266 } else { 266 } else {
267 mHolidays[i] = QString::null; 267 mHolidays[i] = QString::null;
268 } 268 }
269 } 269 }
270 if ( ! mPendingUpdateBeforeRepaint ) 270 if ( ! mPendingUpdateBeforeRepaint )
271 repaint(false); 271 repaint(false);
272} 272}
273void KODayMatrix::updateView(QDate actdate) 273void KODayMatrix::updateView(QDate actdate)
274{ 274{
275 275
276 if ( ! actdate.isValid() ) { 276 if ( ! actdate.isValid() ) {
277 //qDebug("date not valid "); 277 //qDebug("date not valid ");
278 return; 278 return;
279 } 279 }
280 mDayChanged = false; 280 mDayChanged = false;
281 //flag to indicate if the starting day of the matrix has changed by this call 281 //flag to indicate if the starting day of the matrix has changed by this call
282 //mDayChanged = false; 282 //mDayChanged = false;
283 // if a new startdate is to be set then apply Cornelius's calculation 283 // if a new startdate is to be set then apply Cornelius's calculation
284 // of the first day to be shown 284 // of the first day to be shown
285 if (actdate != startdate) { 285 if (actdate != startdate) {
286 // reset index of selection according to shift of starting date from startdate to actdate 286 // reset index of selection according to shift of starting date from startdate to actdate
287 if (mSelStart != NOSELECTION) { 287 if (mSelStart != NOSELECTION) {
288 int tmp = actdate.daysTo(startdate); 288 int tmp = actdate.daysTo(startdate);
289 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 289 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
290 // shift selection if new one would be visible at least partly ! 290 // shift selection if new one would be visible at least partly !
291 291
292 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 292 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
293 // nested if is required for next X display pushed from a different month - correction required 293 // nested if is required for next X display pushed from a different month - correction required
294 // otherwise, for month forward and backward, it must be avoided 294 // otherwise, for month forward and backward, it must be avoided
295 if( mSelStart > NUMDAYS || mSelStart < 0 ) 295 if( mSelStart > NUMDAYS || mSelStart < 0 )
296 mSelStart = mSelStart + tmp; 296 mSelStart = mSelStart + tmp;
297 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 297 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
298 mSelEnd = mSelEnd + tmp; 298 mSelEnd = mSelEnd + tmp;
299 } 299 }
300 } 300 }
301 startdate = actdate; 301 startdate = actdate;
302 mDayChanged = true; 302 mDayChanged = true;
303 recalculateToday(); 303 recalculateToday();
304 } 304 }
305 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 305 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
306 if ( !isVisible() ) { 306 if ( !isVisible() ) {
307 mPendingUpdateBeforeRepaint = true; 307 mPendingUpdateBeforeRepaint = true;
308 } else { 308 } else {
309#ifdef DESKTOP_VERSION 309#ifdef DESKTOP_VERSION
310 //mRepaintTimer->start( 250 ); 310 //mRepaintTimer->start( 250 );
311 mUpdateTimer->start( 250 ); 311 mUpdateTimer->start( 250 );
312#else 312#else
313 mRepaintTimer->start( 350 ); 313 mRepaintTimer->start( 350 );
314 mUpdateTimer->start( 2000 ); 314 mUpdateTimer->start( 2000 );
315#endif 315#endif
316 } 316 }
317} 317}
318void KODayMatrix::updateEvents() 318void KODayMatrix::updateEvents()
319{ 319{
320 if ( !mCalendar ) return; 320 if ( !mCalendar ) return;
321 321
322 for( int i = 0; i < NUMDAYS; i++ ) { 322 for( int i = 0; i < NUMDAYS; i++ ) {
323 // if events are set for the day then remember to draw it bold 323 // if events are set for the day then remember to draw it bold
324 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 324 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
325 int numEvents = eventlist.count(); 325 int numEvents = eventlist.count();
326 Event *event; 326 Event *event;
327 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 327 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
328 ushort recurType = event->doesRecur(); 328 ushort recurType = event->doesRecur();
329 329
330 if ( ( recurType == Recurrence::rDaily && 330 if ( ( recurType == Recurrence::rDaily &&
331 !KOPrefs::instance()->mDailyRecur ) || 331 !KOPrefs::instance()->mDailyRecur ) ||
332 ( recurType == Recurrence::rWeekly && 332 ( recurType == Recurrence::rWeekly &&
333 !KOPrefs::instance()->mWeeklyRecur ) ) { 333 !KOPrefs::instance()->mWeeklyRecur ) ) {
334 numEvents--; 334 numEvents--;
335 } 335 }
336 } 336 }
337 events[ i ] = numEvents; 337 events[ i ] = numEvents;
338 } 338 }
339} 339}
340 340
341const QDate& KODayMatrix::getDate(int offset) 341const QDate& KODayMatrix::getDate(int offset)
342{ 342{
343 if (offset < 0 || offset > NUMDAYS-1) { 343 if (offset < 0 || offset > NUMDAYS-1) {
344 qDebug("Wrong offset2 "); 344 qDebug("Wrong offset2 ");
345 return days[0]; 345 return days[0];
346 } 346 }
347 return days[offset]; 347 return days[offset];
348} 348}
349 349
350QString KODayMatrix::getHolidayLabel(int offset) 350QString KODayMatrix::getHolidayLabel(int offset)
351{ 351{
352 if (offset < 0 || offset > NUMDAYS-1) { 352 if (offset < 0 || offset > NUMDAYS-1) {
353 qDebug("Wrong offset1 "); 353 qDebug("Wrong offset1 ");
354 return 0; 354 return 0;
355 } 355 }
356 return mHolidays[offset]; 356 return mHolidays[offset];
357} 357}
358 358
359int KODayMatrix::getDayIndexFrom(int x, int y) 359int KODayMatrix::getDayIndexFrom(int x, int y)
360{ 360{
361 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 361 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
362 6 - x/daysize.width() : x/daysize.width()); 362 6 - x/daysize.width() : x/daysize.width());
363} 363}
364 364
365// ---------------------------------------------------------------------------- 365// ----------------------------------------------------------------------------
366// M O U S E E V E N T H A N D L I N G 366// M O U S E E V E N T H A N D L I N G
367// ---------------------------------------------------------------------------- 367// ----------------------------------------------------------------------------
368 368
369void KODayMatrix::mousePressEvent (QMouseEvent* e) 369void KODayMatrix::mousePressEvent (QMouseEvent* e)
370{ 370{
371 mSelStart = getDayIndexFrom(e->x(), e->y()); 371 mSelStart = getDayIndexFrom(e->x(), e->y());
372 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 372 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
373 mSelInit = mSelStart; 373 mSelInit = mSelStart;
374} 374}
375 375
376void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 376void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
377{ 377{
378 378
379 int tmp = getDayIndexFrom(e->x(), e->y()); 379 int tmp = getDayIndexFrom(e->x(), e->y());
380 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 380 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
381 381
382 if (mSelInit > tmp) { 382 if (mSelInit > tmp) {
383 mSelEnd = mSelInit; 383 mSelEnd = mSelInit;
384 if (tmp != mSelStart) { 384 if (tmp != mSelStart) {
385 mSelStart = tmp; 385 mSelStart = tmp;
386 repaint(false); 386 repaint(false);
387 } 387 }
388 } else { 388 } else {
389 mSelStart = mSelInit; 389 mSelStart = mSelInit;
390 390
391 //repaint only if selection has changed 391 //repaint only if selection has changed
392 if (tmp != mSelEnd) { 392 if (tmp != mSelEnd) {
393 mSelEnd = tmp; 393 mSelEnd = tmp;
394 repaint(false); 394 repaint(false);
395 } 395 }
396 } 396 }