summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp2
-rw-r--r--korganizer/datenavigatorcontainer.cpp42
-rw-r--r--korganizer/datenavigatorcontainer.h2
-rw-r--r--korganizer/kdatenavigator.cpp3
4 files changed, 33 insertions, 16 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 9a4e719..6ed6a1c 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1825,200 +1825,200 @@ void CalendarView::readSettings()
1825 mTodoList->restoreLayout(config,QString("Todo Layout")); 1825 mTodoList->restoreLayout(config,QString("Todo Layout"));
1826 readFilterSettings(config); 1826 readFilterSettings(config);
1827 1827
1828#ifdef DESKTOP_VERSION 1828#ifdef DESKTOP_VERSION
1829 config->setGroup("WidgetLayout"); 1829 config->setGroup("WidgetLayout");
1830 QStringList list; 1830 QStringList list;
1831 list = config->readListEntry("MainLayout"); 1831 list = config->readListEntry("MainLayout");
1832 int x,y,w,h; 1832 int x,y,w,h;
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 topLevelWidget()->setGeometry(x,y,w,h); 1838 topLevelWidget()->setGeometry(x,y,w,h);
1839 1839
1840 } else { 1840 } else {
1841 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1841 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1842 } 1842 }
1843 list = config->readListEntry("EditEventLayout"); 1843 list = config->readListEntry("EditEventLayout");
1844 if ( ! list.isEmpty() ) { 1844 if ( ! list.isEmpty() ) {
1845 x = list[0].toInt(); 1845 x = list[0].toInt();
1846 y = list[1].toInt(); 1846 y = list[1].toInt();
1847 w = list[2].toInt(); 1847 w = list[2].toInt();
1848 h = list[3].toInt(); 1848 h = list[3].toInt();
1849 mEventEditor->setGeometry(x,y,w,h); 1849 mEventEditor->setGeometry(x,y,w,h);
1850 1850
1851 } 1851 }
1852 list = config->readListEntry("EditTodoLayout"); 1852 list = config->readListEntry("EditTodoLayout");
1853 if ( ! list.isEmpty() ) { 1853 if ( ! list.isEmpty() ) {
1854 x = list[0].toInt(); 1854 x = list[0].toInt();
1855 y = list[1].toInt(); 1855 y = list[1].toInt();
1856 w = list[2].toInt(); 1856 w = list[2].toInt();
1857 h = list[3].toInt(); 1857 h = list[3].toInt();
1858 mTodoEditor->setGeometry(x,y,w,h); 1858 mTodoEditor->setGeometry(x,y,w,h);
1859 1859
1860 } 1860 }
1861 list = config->readListEntry("ViewerLayout"); 1861 list = config->readListEntry("ViewerLayout");
1862 if ( ! list.isEmpty() ) { 1862 if ( ! list.isEmpty() ) {
1863 x = list[0].toInt(); 1863 x = list[0].toInt();
1864 y = list[1].toInt(); 1864 y = list[1].toInt();
1865 w = list[2].toInt(); 1865 w = list[2].toInt();
1866 h = list[3].toInt(); 1866 h = list[3].toInt();
1867 getEventViewerDialog()->setGeometry(x,y,w,h); 1867 getEventViewerDialog()->setGeometry(x,y,w,h);
1868 } 1868 }
1869#endif 1869#endif
1870 config->setGroup( "Views" ); 1870 config->setGroup( "Views" );
1871 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1871 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1872 1872
1873 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 1873 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
1874 1874
1875 int resetval = 0; 1875 int resetval = 0;
1876 int maxVal = 0; 1876 int maxVal = 0;
1877 if (sizes.count() != 3) { 1877 if (sizes.count() != 3) {
1878 if ( KOPrefs::instance()->mVerticalScreen ) { 1878 if ( KOPrefs::instance()->mVerticalScreen ) {
1879 resetval = mDateNavigator->sizeHint().width()+2; 1879 resetval = mDateNavigator->sizeHint().width()+2;
1880 } else { 1880 } else {
1881 resetval = mDateNavigator->sizeHint().height()+2; 1881 resetval = mDateNavigator->sizeHint().height()+2;
1882 } 1882 }
1883 } 1883 }
1884 if ( resetval ) { 1884 if ( resetval ) {
1885 sizes.clear(); 1885 sizes.clear();
1886 if ( KOPrefs::instance()->mVerticalScreen ) { 1886 if ( KOPrefs::instance()->mVerticalScreen ) {
1887 maxVal = QApplication::desktop()->width() -10; 1887 maxVal = QApplication::desktop()->width() -10;
1888 } else { 1888 } else {
1889 maxVal = QApplication::desktop()->height()-10; 1889 maxVal = QApplication::desktop()->height()-10;
1890 } 1890 }
1891 sizes << resetval; 1891 sizes << resetval;
1892 if ( maxVal < resetval + resetval) 1892 if ( maxVal < resetval + resetval)
1893 resetval = maxVal - resetval; 1893 resetval = maxVal - resetval;
1894 sizes << resetval; 1894 sizes << resetval;
1895 sizes << 100; 1895 sizes << 100;
1896 } 1896 }
1897 mLeftFrame->setSizes(sizes); 1897 mLeftFrame->setSizes(sizes);
1898 sizes = config->readIntListEntry("Main Splitter Frame"); 1898 sizes = config->readIntListEntry("Main Splitter Frame");
1899 resetval = 0; 1899 resetval = 0;
1900 maxVal = 0; 1900 maxVal = 0;
1901 if (sizes.count() != 2) { 1901 if (sizes.count() != 2) {
1902 if ( !KOPrefs::instance()->mVerticalScreen ) { 1902 if ( !KOPrefs::instance()->mVerticalScreen ) {
1903 resetval = mDateNavigator->sizeHint().width()+2; 1903 resetval = mDateNavigator->sizeHint().width()+2;
1904 } else { 1904 } else {
1905 resetval = mDateNavigator->sizeHint().height()+2; 1905 resetval = mDateNavigator->sizeHint().height()+2;
1906 } 1906 }
1907 } 1907 }
1908 if ( resetval ) { 1908 if ( resetval ) {
1909 sizes.clear(); 1909 sizes.clear();
1910 if ( !KOPrefs::instance()->mVerticalScreen ) { 1910 if ( !KOPrefs::instance()->mVerticalScreen ) {
1911 maxVal = QApplication::desktop()->width() -10; 1911 maxVal = QApplication::desktop()->width() -10;
1912 } else { 1912 } else {
1913 maxVal = QApplication::desktop()->height()-10; 1913 maxVal = QApplication::desktop()->height()-10;
1914 } 1914 }
1915 sizes << resetval; 1915 sizes << resetval;
1916 if ( maxVal < resetval + resetval) 1916 if ( maxVal < resetval + resetval)
1917 resetval = maxVal - resetval; 1917 resetval = maxVal - resetval;
1918 sizes << resetval; 1918 sizes << resetval;
1919 } 1919 }
1920 mMainFrame->setSizes(sizes); 1920 mMainFrame->setSizes(sizes);
1921
1922 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1921 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1923 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1922 else if ( dateCount == 7 ) mNavigator->selectWeek();
1924 else mNavigator->selectDates( dateCount ); 1923 else mNavigator->selectDates( dateCount );
1925 // mViewManager->readSettings( config ); 1924 // mViewManager->readSettings( config );
1926 updateConfig(); 1925 updateConfig();
1927 globalFlagBlockAgenda = 2; 1926 globalFlagBlockAgenda = 2;
1928 mViewManager->readSettings( config ); 1927 mViewManager->readSettings( config );
1928 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
1929} 1929}
1930 1930
1931 1931
1932void CalendarView::writeSettings() 1932void CalendarView::writeSettings()
1933{ 1933{
1934 // kdDebug() << "CalendarView::writeSettings" << endl; 1934 // kdDebug() << "CalendarView::writeSettings" << endl;
1935 1935
1936 KConfig *config = KOGlobals::config(); 1936 KConfig *config = KOGlobals::config();
1937 1937
1938 mViewManager->writeSettings( config ); 1938 mViewManager->writeSettings( config );
1939 mTodoList->saveLayout(config,QString("Todo Layout")); 1939 mTodoList->saveLayout(config,QString("Todo Layout"));
1940 mDialogManager->writeSettings( config ); 1940 mDialogManager->writeSettings( config );
1941 //KOPrefs::instance()->usrWriteConfig(); 1941 //KOPrefs::instance()->usrWriteConfig();
1942 KOPrefs::instance()->writeConfig(); 1942 KOPrefs::instance()->writeConfig();
1943 1943
1944 writeFilterSettings(config); 1944 writeFilterSettings(config);
1945 1945
1946 config->setGroup( "Views" ); 1946 config->setGroup( "Views" );
1947 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1947 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1948 1948
1949 QValueList<int> listINT = mLeftFrame->sizes(); 1949 QValueList<int> listINT = mLeftFrame->sizes();
1950 config->writeEntry("Left Splitter Frame",listINT); 1950 config->writeEntry("Left Splitter Frame",listINT);
1951 QValueList<int> listINT2 = mMainFrame->sizes(); 1951 QValueList<int> listINT2 = mMainFrame->sizes();
1952 config->writeEntry("Main Splitter Frame",listINT2); 1952 config->writeEntry("Main Splitter Frame",listINT2);
1953#ifdef DESKTOP_VERSION 1953#ifdef DESKTOP_VERSION
1954 config->setGroup("WidgetLayout"); 1954 config->setGroup("WidgetLayout");
1955 QStringList list ;//= config->readListEntry("MainLayout"); 1955 QStringList list ;//= config->readListEntry("MainLayout");
1956 int x,y,w,h; 1956 int x,y,w,h;
1957 QWidget* wid; 1957 QWidget* wid;
1958 wid = topLevelWidget(); 1958 wid = topLevelWidget();
1959 x = wid->geometry().x(); 1959 x = wid->geometry().x();
1960 y = wid->geometry().y(); 1960 y = wid->geometry().y();
1961 w = wid->width(); 1961 w = wid->width();
1962 h = wid->height(); 1962 h = wid->height();
1963 list.clear(); 1963 list.clear();
1964 list << QString::number( x ); 1964 list << QString::number( x );
1965 list << QString::number( y ); 1965 list << QString::number( y );
1966 list << QString::number( w ); 1966 list << QString::number( w );
1967 list << QString::number( h ); 1967 list << QString::number( h );
1968 config->writeEntry("MainLayout",list ); 1968 config->writeEntry("MainLayout",list );
1969 1969
1970 wid = mEventEditor; 1970 wid = mEventEditor;
1971 x = wid->geometry().x(); 1971 x = wid->geometry().x();
1972 y = wid->geometry().y(); 1972 y = wid->geometry().y();
1973 w = wid->width(); 1973 w = wid->width();
1974 h = wid->height(); 1974 h = wid->height();
1975 list.clear(); 1975 list.clear();
1976 list << QString::number( x ); 1976 list << QString::number( x );
1977 list << QString::number( y ); 1977 list << QString::number( y );
1978 list << QString::number( w ); 1978 list << QString::number( w );
1979 list << QString::number( h ); 1979 list << QString::number( h );
1980 config->writeEntry("EditEventLayout",list ); 1980 config->writeEntry("EditEventLayout",list );
1981 1981
1982 wid = mTodoEditor; 1982 wid = mTodoEditor;
1983 x = wid->geometry().x(); 1983 x = wid->geometry().x();
1984 y = wid->geometry().y(); 1984 y = wid->geometry().y();
1985 w = wid->width(); 1985 w = wid->width();
1986 h = wid->height(); 1986 h = wid->height();
1987 list.clear(); 1987 list.clear();
1988 list << QString::number( x ); 1988 list << QString::number( x );
1989 list << QString::number( y ); 1989 list << QString::number( y );
1990 list << QString::number( w ); 1990 list << QString::number( w );
1991 list << QString::number( h ); 1991 list << QString::number( h );
1992 config->writeEntry("EditTodoLayout",list ); 1992 config->writeEntry("EditTodoLayout",list );
1993 wid = getEventViewerDialog(); 1993 wid = getEventViewerDialog();
1994 x = wid->geometry().x(); 1994 x = wid->geometry().x();
1995 y = wid->geometry().y(); 1995 y = wid->geometry().y();
1996 w = wid->width(); 1996 w = wid->width();
1997 h = wid->height(); 1997 h = wid->height();
1998 list.clear(); 1998 list.clear();
1999 list << QString::number( x ); 1999 list << QString::number( x );
2000 list << QString::number( y ); 2000 list << QString::number( y );
2001 list << QString::number( w ); 2001 list << QString::number( w );
2002 list << QString::number( h ); 2002 list << QString::number( h );
2003 config->writeEntry("ViewerLayout",list ); 2003 config->writeEntry("ViewerLayout",list );
2004 wid = mDialogManager->getSearchDialog(); 2004 wid = mDialogManager->getSearchDialog();
2005 if ( wid ) { 2005 if ( wid ) {
2006 x = wid->geometry().x(); 2006 x = wid->geometry().x();
2007 y = wid->geometry().y(); 2007 y = wid->geometry().y();
2008 w = wid->width(); 2008 w = wid->width();
2009 h = wid->height(); 2009 h = wid->height();
2010 list.clear(); 2010 list.clear();
2011 list << QString::number( x ); 2011 list << QString::number( x );
2012 list << QString::number( y ); 2012 list << QString::number( y );
2013 list << QString::number( w ); 2013 list << QString::number( w );
2014 list << QString::number( h ); 2014 list << QString::number( h );
2015 config->writeEntry("SearchLayout",list ); 2015 config->writeEntry("SearchLayout",list );
2016 } 2016 }
2017#endif 2017#endif
2018 2018
2019 2019
2020 config->sync(); 2020 config->sync();
2021} 2021}
2022 2022
2023void CalendarView::readFilterSettings(KConfig *config) 2023void CalendarView::readFilterSettings(KConfig *config)
2024{ 2024{
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 2290c53..11dc592 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -1,415 +1,429 @@
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#include "koprefs.h" 36#include "koprefs.h"
37 37
38DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, 38DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
39 const char *name ) 39 const char *name )
40 : QWidget( parent, name ), mCalendar( 0 ), 40 : QWidget( parent, name ), mCalendar( 0 ),
41 mHorizontalCount( 1 ), mVerticalCount( 1 ) 41 mHorizontalCount( 1 ), mVerticalCount( 1 )
42{ 42{
43 mResizeEnabled = false;
43 mExtraViews.setAutoDelete( true ); 44 mExtraViews.setAutoDelete( true );
44 45
45 mNavigatorView = new KDateNavigator( this, name ); 46 mNavigatorView = new KDateNavigator( this, name );
46 47 mNavigatorView->hide();
47 connectNavigatorView( mNavigatorView ); 48 connectNavigatorView( mNavigatorView );
48 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 49 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
49 mLastDisplayedDN = 0; 50 mLastDisplayedDN = 0;
50 mUpdateTimer; 51 mUpdateTimer;
51 mUpdateTimer = new QTimer( this ); 52 mUpdateTimer = new QTimer( this );
52 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() )); 53 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() ));
53 mFirstSelectedDate = QDate::currentDate(); 54 mFirstSelectedDate = QDate::currentDate();
54 mSelectedDateCount = 1; 55 mSelectedDateCount = 1;
55} 56}
56 57
57DateNavigatorContainer::~DateNavigatorContainer() 58DateNavigatorContainer::~DateNavigatorContainer()
58{ 59{
59} 60}
60 61
61void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) 62void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
62{ 63{
63 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), 64 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ),
64 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 65 SIGNAL( datesSelected( const KCal::DateList & ) ) );
65#if 0 66#if 0
66 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), 67 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ),
67 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); 68 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) );
68 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), 69 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ),
69 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); 70 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) );
70#endif 71#endif
71 connect( v, SIGNAL( weekClicked( const QDate & ) ), 72 connect( v, SIGNAL( weekClicked( const QDate & ) ),
72 SIGNAL( weekClicked( const QDate & ) ) ); 73 SIGNAL( weekClicked( const QDate & ) ) );
73 74
74 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); 75 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
75 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); 76 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
76 77
77 connect( v, SIGNAL( goNextMonth() ), SLOT( slotgoNextMonth() ) ); 78 connect( v, SIGNAL( goNextMonth() ), SLOT( slotgoNextMonth() ) );
78 connect( v, SIGNAL( goPrevMonth() ), SLOT( slotgoPrevMonth() ) ); 79 connect( v, SIGNAL( goPrevMonth() ), SLOT( slotgoPrevMonth() ) );
79 connect( v, SIGNAL( goNextYear() ), SLOT( slotgoNextYear() ) ); 80 connect( v, SIGNAL( goNextYear() ), SLOT( slotgoNextYear() ) );
80 connect( v, SIGNAL( goPrevYear() ), SLOT( slotgoPrevYear() ) ); 81 connect( v, SIGNAL( goPrevYear() ), SLOT( slotgoPrevYear() ) );
81 82
82 connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 83 connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
83} 84}
84void DateNavigatorContainer::slotgoNextYear() 85void DateNavigatorContainer::slotgoNextYear()
85{ 86{
86 jumpMonth( 12 ); 87 jumpMonth( 12 );
87 emit goNextYear(); 88 emit goNextYear();
88 89
89} 90}
90void DateNavigatorContainer::slotgoPrevYear() 91void DateNavigatorContainer::slotgoPrevYear()
91{ 92{
92 jumpMonth( -12 ); 93 jumpMonth( -12 );
93 emit goPrevYear(); 94 emit goPrevYear();
94 95
95} 96}
96void DateNavigatorContainer::slotgoPrevMonth() 97void DateNavigatorContainer::slotgoPrevMonth()
97{ 98{
98 jumpMonth( -1 ); 99 jumpMonth( -1 );
99 emit goPrevMonth(); 100 emit goPrevMonth();
100 101
101} 102}
102void DateNavigatorContainer::slotgoNextMonth() 103void DateNavigatorContainer::slotgoNextMonth()
103{ 104{
104 jumpMonth( 1 ); 105 jumpMonth( 1 );
105 emit goNextMonth(); 106 emit goNextMonth();
106} 107}
107void DateNavigatorContainer::jumpMonth( int month ) 108void DateNavigatorContainer::jumpMonth( int month )
108{ 109{
109 110
110 QDate baseDate = mNavigatorView->baseDate(); 111 QDate baseDate = mNavigatorView->baseDate();
111 computeMonthSelected( baseDate.month() + month, false ); 112 computeMonthSelected( baseDate.month() + month, false );
112} 113}
113void DateNavigatorContainer::slotMonthSelected( int month ) 114void DateNavigatorContainer::slotMonthSelected( int month )
114{ 115{
115 computeMonthSelected( month, true ); 116 computeMonthSelected( month, true );
116} 117}
117void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit ) 118void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit )
118{ 119{
119 //qDebug("slotMonthSelected %d ", month); 120 //qDebug("slotMonthSelected %d ", month);
120 QDate baseDate = mNavigatorView->baseDate(); 121 QDate baseDate = mNavigatorView->baseDate();
121 if ( baseDate.month() == month ) 122 if ( baseDate.month() == month )
122 return; 123 return;
123 //qDebug("month %d %d ",baseDate.month(),month); 124 //qDebug("month %d %d ",baseDate.month(),month);
124 QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); 125 QDate date = QDate ( baseDate.year(), baseDate.month() , 15 );
125 date = date.addDays( -(baseDate.month()-month ) *30 ); 126 date = date.addDays( -(baseDate.month()-month ) *30 );
126 QDate newBase = QDate ( date.year(), date.month() , baseDate.day() ); 127 QDate newBase = QDate ( date.year(), date.month() , baseDate.day() );
127 128
128 //qDebug("NEW BASE %s", newBase.toString().latin1()); 129 //qDebug("NEW BASE %s", newBase.toString().latin1());
129 mNavigatorView->setBaseDate( newBase ); 130 mNavigatorView->setBaseDate( newBase );
130 QDate last = lastAvailableDate(); 131 QDate last = lastAvailableDate();
131 QDate first = firstAvailableDate(); 132 QDate first = firstAvailableDate();
132 133
133 QDate selFirst = mFirstSelectedDate; 134 QDate selFirst = mFirstSelectedDate;
134 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 135 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
135 if ( selFirst >= first && selLast <= last ) { 136 if ( selFirst >= first && selLast <= last ) {
136 setBaseDates(); 137 setBaseDates();
137 if ( forceEmit ) 138 if ( forceEmit )
138 updateDayMatrixDates(); 139 updateDayMatrixDates();
139 } 140 }
140 else { 141 else {
141 setBaseDates(); 142 setBaseDates();
142 if ( forceEmit ) 143 if ( forceEmit )
143 updateDayMatrixDates(); 144 updateDayMatrixDates();
144 if ( forceEmit ) 145 if ( forceEmit )
145 emit monthSelected( month ); 146 emit monthSelected( month );
146 } 147 }
147} 148}
148void DateNavigatorContainer::setCalendar( Calendar *cal ) 149void DateNavigatorContainer::setCalendar( Calendar *cal )
149{ 150{
150 mCalendar = cal; 151 mCalendar = cal;
151 mNavigatorView->setCalendar( cal ); 152 mNavigatorView->setCalendar( cal );
152 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 153 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
153 KDateNavigator *n = mExtraViews.at( i ); 154 KDateNavigator *n = mExtraViews.at( i );
154 n->setCalendar( cal ); 155 n->setCalendar( cal );
155 } 156 }
156} 157}
157void DateNavigatorContainer::checkUpdateDayMatrixDates() 158void DateNavigatorContainer::checkUpdateDayMatrixDates()
158{ 159{
159 //qDebug("KODNC: wid %d hei %d ", width(), height()); 160 //qDebug("KODNC: wid %d hei %d ", width(), height());
160 mUpdateTimer->stop(); 161 mUpdateTimer->stop();
161 //return; 162 //return;
162 if ( width() < 3 || height() < 3 ) 163 if ( width() < 3 || height() < 3 )
163 return; 164 return;
164 static int lastWid = 0; 165 static int lastWid = 0;
165 static int lastHei = 0; 166 static int lastHei = 0;
166 if ( lastWid == width() && height() == lastHei ) { 167 if ( lastWid == width() && height() == lastHei ) {
167 qDebug("KODNC: No layout computing needed. "); 168 qDebug("KODNC: No layout computing needed. ");
168 } else { 169 } else {
169 lastWid = width(); 170 lastWid = width();
170 lastHei = height(); 171 lastHei = height();
171 172
172 QSize minSize = mNavigatorView->yourSizeHint(); 173 QSize minSize = mNavigatorView->yourSizeHint();
173 174
174 int verticalCount = size().height() / minSize.height(); 175 int verticalCount = size().height() / minSize.height();
175 int horizontalCount = size().width() / minSize.width(); 176 int horizontalCount = size().width() / minSize.width();
176 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); 177 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
177 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); 178 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
178 bool fontchange = false; 179 bool fontchange = false;
179 if ( horizontalCount == 1) 180 if ( horizontalCount == 1)
180 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); 181 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
181 QFont fo; 182 QFont fo;
182 if ( horizontalCount != mHorizontalCount || 183 if ( horizontalCount != mHorizontalCount ||
183 verticalCount != mVerticalCount ) { 184 verticalCount != mVerticalCount ) {
184 uint count = horizontalCount * verticalCount; 185 uint count = horizontalCount * verticalCount;
185 if ( count == 0 ) { 186 if ( count == 0 ) {
186 bool ok; 187 bool ok;
187 fo = mNavigatorView->yourFontHint( size() , &ok ); 188 fo = mNavigatorView->yourFontHint( size() , &ok );
188 //mNavigatorView->resize( size() ); 189 //mNavigatorView->resize( size() );
189 //if ( ! ok ) 190 //if ( ! ok )
190 // return; 191 // return;
191 int butt = 2; 192 int butt = 2;
192 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); 193 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width();
193 if ( horizontalCount <= 1 ) 194 if ( horizontalCount <= 1 )
194 minSize = mNavigatorView->sizeHintTwoButtons( 4 ); 195 minSize = mNavigatorView->sizeHintTwoButtons( 4 );
195 else 196 else
196 minSize = mNavigatorView->sizeHintTwoButtons(); 197 minSize = mNavigatorView->sizeHintTwoButtons();
197 verticalCount = size().height() / minSize.height(); 198 verticalCount = size().height() / minSize.height();
198 horizontalCount = size().width() / minSize.width(); 199 horizontalCount = size().width() / minSize.width();
199 if ( horizontalCount == 0 ) 200 if ( horizontalCount == 0 )
200 horizontalCount = 1; 201 horizontalCount = 1;
201 if ( verticalCount == 0 ) 202 if ( verticalCount == 0 )
202 verticalCount = 1; 203 verticalCount = 1;
203 fontchange = true; 204 fontchange = true;
204 count = horizontalCount * verticalCount; 205 count = horizontalCount * verticalCount;
205 } else { 206 } else {
206 if ( mNavigatorView->fontChanged() ) { 207 if ( mNavigatorView->fontChanged() ) {
207 fontchange = true; 208 fontchange = true;
208 fo = KOPrefs::instance()->mDateNavigatorFont; 209 fo = KOPrefs::instance()->mDateNavigatorFont;
209 mNavigatorView->changeFont( fo ); 210 mNavigatorView->changeFont( fo );
210 mNavigatorView->unsetFontChanged(); 211 mNavigatorView->unsetFontChanged();
211 } 212 }
212 } 213 }
213 214
214 mLastDisplayedDN = horizontalCount*verticalCount-1; 215 mLastDisplayedDN = horizontalCount*verticalCount-1;
215 while ( count > ( mExtraViews.count() + 1 ) ) { 216 while ( count > ( mExtraViews.count() + 1 ) ) {
216 KDateNavigator *n = new KDateNavigator( this ); 217 KDateNavigator *n = new KDateNavigator( this );
217 n->setMonthSignalOffset ( mExtraViews.count()+1 ); 218 n->setMonthSignalOffset ( mExtraViews.count()+1 );
218 mExtraViews.append( n ); 219 mExtraViews.append( n );
219 n->setCalendar( mCalendar ); 220 n->setCalendar( mCalendar );
220 connectNavigatorView( n ); 221 connectNavigatorView( n );
221 n->show(); 222 // n->show();
222 }
223 int iii = 0;
224 while ( iii < ( mExtraViews.count() ) ) {
225 if ( iii < count-1 )
226 mExtraViews.at( iii )->show();
227 else
228 mExtraViews.at( iii )->hide();
229 ++iii;
230 } 223 }
224
231 225
232 setBaseDates(); 226 setBaseDates();
233 if ( fontchange ) { 227 if ( fontchange ) {
234 //mNavigatorView->changeFont( fo ); 228 //mNavigatorView->changeFont( fo );
235 uint i; 229 uint i;
236 for( i = 0; i < mExtraViews.count(); ++i ) { 230 for( i = 0; i < mExtraViews.count(); ++i ) {
237 KDateNavigator *view = mExtraViews.at( i ); 231 KDateNavigator *view = mExtraViews.at( i );
238 view->changeFont( fo ); 232 view->changeFont( fo );
239 } 233 }
240 } 234 }
241 mHorizontalCount = horizontalCount; 235 mHorizontalCount = horizontalCount;
242 mVerticalCount = verticalCount; 236 mVerticalCount = verticalCount;
243 237
244 } 238 }
245 239
246 int theight = height() / mVerticalCount; 240 int theight = height() / mVerticalCount;
247 int twidth = width() / mHorizontalCount; 241 int twidth = width() / mHorizontalCount;
248 242
249 NavigatorBar *bar = mNavigatorView->navigatorBar(); 243 NavigatorBar *bar = mNavigatorView->navigatorBar();
250 if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); 244 if ( mHorizontalCount > 1 ) bar->showButtons( true, false );
251 else bar->showButtons( true, true ); 245 else bar->showButtons( true, true );
252 246
253 mNavigatorView->setGeometry(0, 247 mNavigatorView->setGeometry(0,
254 0, twidth, theight ); 248 0, twidth, theight );
255 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 249 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
256 int x = ( i + 1 ) % mHorizontalCount; 250 int x = ( i + 1 ) % mHorizontalCount;
257 int y = ( i + 1 ) / mHorizontalCount; 251 int y = ( i + 1 ) / mHorizontalCount;
258 252
259 KDateNavigator *view = mExtraViews.at( i ); 253 KDateNavigator *view = mExtraViews.at( i );
260 bar = view->navigatorBar(); 254 bar = view->navigatorBar();
261 if ( y > 0 ) bar->showButtons( false, false ); 255 if ( y > 0 ) bar->showButtons( false, false );
262 else { 256 else {
263 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); 257 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true );
264 else bar->showButtons( false, false ); 258 else bar->showButtons( false, false );
265 } 259 }
266 view->setGeometry( x * twidth, 260 view->setGeometry( x * twidth,
267 y * theight, twidth, theight ); 261 y * theight, twidth, theight );
268 } 262 }
263 int iii = 0;
264 int ccc = mHorizontalCount * mVerticalCount;
265 mNavigatorView->show();
266 while ( iii < ( mExtraViews.count() ) ) {
267 if ( iii < ccc-1 )
268 mExtraViews.at( iii )->show();
269 else
270 mExtraViews.at( iii )->hide();
271 ++iii;
272 }
269 } 273 }
270 274
271 QDate last = lastAvailableDate(); 275 QDate last = lastAvailableDate();
272 QDate first = firstAvailableDate(); 276 QDate first = firstAvailableDate();
273 277
274 QDate selFirst = mFirstSelectedDate; 278 QDate selFirst = mFirstSelectedDate;
275 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 279 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
276 if ( selFirst >= first && selLast <= last ) { 280 if ( selFirst >= first && selLast <= last ) {
277 updateDayMatrixDates(); 281 updateDayMatrixDates();
278 } 282 }
279 else { 283 else {
280 updateDayMatrixDates(); 284 updateDayMatrixDates();
281 emit monthSelected( mFirstSelectedDate.month() ); 285 emit monthSelected( mFirstSelectedDate.month() );
282 } 286 }
283} 287}
284void DateNavigatorContainer::updateDayMatrixDates() 288void DateNavigatorContainer::updateDayMatrixDates()
285{ 289{
286 QDate fDate = mFirstSelectedDate; 290 QDate fDate = mFirstSelectedDate;
287 QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); 291 QDate lDate = fDate.addDays( mSelectedDateCount - 1 );
288 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); 292 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
289 mNavigatorView->dayMatrix()->repaint( false ); 293 mNavigatorView->dayMatrix()->repaint( false );
290 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 294 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
291 KDateNavigator *n = mExtraViews.at( i ); 295 KDateNavigator *n = mExtraViews.at( i );
292 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { 296 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
293 n->dayMatrix()->repaint( false ); 297 n->dayMatrix()->repaint( false );
294 } 298 }
295 } 299 }
296} 300}
297 301
298void DateNavigatorContainer::updateDayMatrix() 302void DateNavigatorContainer::updateDayMatrix()
299{ 303{
300 mNavigatorView->updateDayMatrix(); 304 mNavigatorView->updateDayMatrix();
301 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 305 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
302 KDateNavigator *n = mExtraViews.at( i ); 306 KDateNavigator *n = mExtraViews.at( i );
303 n->updateDayMatrix(); 307 n->updateDayMatrix();
304 } 308 }
305} 309}
306 310
307void DateNavigatorContainer::updateToday() 311void DateNavigatorContainer::updateToday()
308{ 312{
309 qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); 313 qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
310#if 0 314#if 0
311 mNavigatorView->updateToday(); 315 mNavigatorView->updateToday();
312 KDateNavigator *n; 316 KDateNavigator *n;
313 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 317 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
314 n->updateToday(); 318 n->updateToday();
315 } 319 }
316#endif 320#endif
317} 321}
318 322
319void DateNavigatorContainer::updateView() 323void DateNavigatorContainer::updateView()
320{ 324{
321 mNavigatorView->updateView(); 325 mNavigatorView->updateView();
322 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 326 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
323 KDateNavigator *n = mExtraViews.at( i ); 327 KDateNavigator *n = mExtraViews.at( i );
324 n->updateView(); 328 n->updateView();
325 } 329 }
326} 330}
327 331
328void DateNavigatorContainer::updateConfig() 332void DateNavigatorContainer::updateConfig()
329{ 333{
330 mNavigatorView->updateConfig(); 334 mNavigatorView->updateConfig();
331 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 335 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
332 KDateNavigator *n = mExtraViews.at( i ); 336 KDateNavigator *n = mExtraViews.at( i );
333 n->updateConfig(); 337 n->updateConfig();
334 } 338 }
335} 339}
336QDate DateNavigatorContainer::lastAvailableDate() const 340QDate DateNavigatorContainer::lastAvailableDate() const
337{ 341{
338 QDate date = mNavigatorView->baseDate(); 342 QDate date = mNavigatorView->baseDate();
339 QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); 343 QDate last = QDate ( date.year(), date.month(), date.daysInMonth() );
340 int iii = mLastDisplayedDN; 344 int iii = mLastDisplayedDN;
341 if ( mLastDisplayedDN ) 345 if ( mLastDisplayedDN )
342 last = last.addDays( 1); 346 last = last.addDays( 1);
343 while ( iii ) { 347 while ( iii ) {
344 last = last.addDays( last.daysInMonth ()); 348 last = last.addDays( last.daysInMonth ());
345 //qDebug("DATE %s ", last.toString().latin1() ); 349 //qDebug("DATE %s ", last.toString().latin1() );
346 --iii; 350 --iii;
347 } 351 }
348 if ( mLastDisplayedDN ) 352 if ( mLastDisplayedDN )
349 last = last.addDays( -1); 353 last = last.addDays( -1);
350 return last; 354 return last;
351} 355}
352QDate DateNavigatorContainer::firstAvailableDate() const 356QDate DateNavigatorContainer::firstAvailableDate() const
353{ 357{
354 return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); 358 return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 );
355} 359}
356void DateNavigatorContainer::selectDates( const DateList &dateList ) 360void DateNavigatorContainer::selectDates( const DateList &dateList )
357{ 361{
358 mFirstSelectedDate = dateList.first() ; 362 mFirstSelectedDate = dateList.first() ;
359 mSelectedDateCount = dateList.count() ; 363 mSelectedDateCount = dateList.count() ;
360 if ( !mLastDisplayedDN ) { 364 if ( !mLastDisplayedDN ) {
361 mNavigatorView->selectDates( dateList ); 365 mNavigatorView->selectDates( dateList );
362 return; 366 return;
363 } 367 }
364 QDate fDate = dateList.first(); 368 QDate fDate = dateList.first();
365 QDate lDate = dateList.last(); 369 QDate lDate = dateList.last();
366 //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); 370 //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() );
367 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); 371 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
368 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { 372 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) {
369 updateDayMatrixDates(); 373 updateDayMatrixDates();
370 return; 374 return;
371 } 375 }
372 mNavigatorView->selectDates( dateList ); 376 mNavigatorView->selectDates( dateList );
373 setBaseDates(); 377 setBaseDates();
374 if ( mLastDisplayedDN ) { 378 if ( mLastDisplayedDN ) {
375 KDateNavigator *view = mExtraViews.at( 0 ); 379 KDateNavigator *view = mExtraViews.at( 0 );
376 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 380 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
377 view->dayMatrix()->repaint( false ); 381 view->dayMatrix()->repaint( false );
378 if ( mLastDisplayedDN > 1 ) { 382 if ( mLastDisplayedDN > 1 ) {
379 KDateNavigator *view = mExtraViews.at( 1 ); 383 KDateNavigator *view = mExtraViews.at( 1 );
380 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 384 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
381 view->dayMatrix()->repaint( false ); 385 view->dayMatrix()->repaint( false );
382 } 386 }
383 } 387 }
384} 388}
385 389
386void DateNavigatorContainer::setBaseDates() 390void DateNavigatorContainer::setBaseDates()
387{ 391{
388 QDate baseDate = mNavigatorView->baseDate(); 392 QDate baseDate = mNavigatorView->baseDate();
389 bool doRepaint = true; 393 bool doRepaint = true;
390 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 394 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
391 KDateNavigator *n = mExtraViews.at( i ); 395 KDateNavigator *n = mExtraViews.at( i );
392 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 396 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
393 n->setBaseDate( baseDate, doRepaint ); 397 n->setBaseDate( baseDate, doRepaint );
394 } 398 }
395} 399}
396 400void DateNavigatorContainer::setResizeEnabled()
401{
402 mResizeEnabled = true;
403 //qDebug("DateNavigatorContainer::setResizeEnabled ");
404 checkUpdateDayMatrixDates();
405}
397void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) 406void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
398{ 407{
399 408
400 409 //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height());
401 //qDebug("COUNT %d ", mExtraViews.count()); 410 //qDebug("COUNT %d ", mExtraViews.count());
402 411 if ( ! mResizeEnabled ) {
403 mUpdateTimer->start( 250 ); 412 //qDebug("NOT ResizeEnabled");
413 return;
414 }
415 else
416 mUpdateTimer->start( 250 );
417
404 //updateDayMatrixDates(); 418 //updateDayMatrixDates();
405} 419}
406 420
407QSize DateNavigatorContainer::minimumSizeHint() const 421QSize DateNavigatorContainer::minimumSizeHint() const
408{ 422{
409 return mNavigatorView->minimumSizeHint(); 423 return mNavigatorView->minimumSizeHint();
410} 424}
411 425
412QSize DateNavigatorContainer::sizeHint() const 426QSize DateNavigatorContainer::sizeHint() const
413{ 427{
414 return mNavigatorView->yourSizeHint(); 428 return mNavigatorView->yourSizeHint();
415} 429}
diff --git a/korganizer/datenavigatorcontainer.h b/korganizer/datenavigatorcontainer.h
index d2f397d..ac9745d 100644
--- a/korganizer/datenavigatorcontainer.h
+++ b/korganizer/datenavigatorcontainer.h
@@ -1,106 +1,108 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> 5 Copyright (C) 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#ifndef DATENAVIGATORCONTAINER_H 25#ifndef DATENAVIGATORCONTAINER_H
26#define DATENAVIGATORCONTAINER_H 26#define DATENAVIGATORCONTAINER_H
27 27
28class KDateNavigator; 28class KDateNavigator;
29 29
30#include <qwidget.h> 30#include <qwidget.h>
31#include <qtimer.h> 31#include <qtimer.h>
32#include <libkcal/calendar.h> 32#include <libkcal/calendar.h>
33using namespace KCal; 33using namespace KCal;
34 34
35class DateNavigatorContainer: public QWidget 35class DateNavigatorContainer: public QWidget
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 DateNavigatorContainer( QWidget *parent = 0, const char *name = 0 ); 39 DateNavigatorContainer( QWidget *parent = 0, const char *name = 0 );
40 ~DateNavigatorContainer(); 40 ~DateNavigatorContainer();
41 41
42 /** 42 /**
43 Associate date navigator with a calendar. It is used by KODayMatrix. 43 Associate date navigator with a calendar. It is used by KODayMatrix.
44 */ 44 */
45 void setCalendar( Calendar * ); 45 void setCalendar( Calendar * );
46 46
47 QSize minimumSizeHint() const; 47 QSize minimumSizeHint() const;
48 QSize sizeHint() const; 48 QSize sizeHint() const;
49 KDateNavigator * navigatorView() { return mNavigatorView;} 49 KDateNavigator * navigatorView() { return mNavigatorView;}
50 QDate lastAvailableDate() const ; 50 QDate lastAvailableDate() const ;
51 QDate firstAvailableDate() const ; 51 QDate firstAvailableDate() const ;
52 52
53 public slots: 53 public slots:
54 void selectDates( const KCal::DateList & ); 54 void selectDates( const KCal::DateList & );
55 void updateView(); 55 void updateView();
56 void updateConfig(); 56 void updateConfig();
57 void updateDayMatrix(); 57 void updateDayMatrix();
58 void updateDayMatrixDates(); 58 void updateDayMatrixDates();
59 void checkUpdateDayMatrixDates(); 59 void checkUpdateDayMatrixDates();
60 void updateToday(); 60 void updateToday();
61 void slotMonthSelected( int month ); 61 void slotMonthSelected( int month );
62 void slotgoNextMonth(); 62 void slotgoNextMonth();
63 void slotgoPrevMonth(); 63 void slotgoPrevMonth();
64 void slotgoNextYear(); 64 void slotgoNextYear();
65 void slotgoPrevYear(); 65 void slotgoPrevYear();
66 void setResizeEnabled();
66 67
67 signals: 68 signals:
68 void datesSelected( const KCal::DateList & ); 69 void datesSelected( const KCal::DateList & );
69 void incidenceDropped( Incidence *, const QDate & ); 70 void incidenceDropped( Incidence *, const QDate & );
70 void incidenceDroppedMove( Incidence *, const QDate & ); 71 void incidenceDroppedMove( Incidence *, const QDate & );
71 void weekClicked( const QDate &); 72 void weekClicked( const QDate &);
72 73
73 void goPrevious(); 74 void goPrevious();
74 void goNext(); 75 void goNext();
75 76
76 void goNextMonth(); 77 void goNextMonth();
77 void goPrevMonth(); 78 void goPrevMonth();
78 void goNextYear(); 79 void goNextYear();
79 void goPrevYear(); 80 void goPrevYear();
80 81
81 void monthSelected( int month ); 82 void monthSelected( int month );
82 83
83 protected: 84 protected:
84 void computeMonthSelected( int month , bool forceEmit ); 85 void computeMonthSelected( int month , bool forceEmit );
85 void jumpMonth( int month ); 86 void jumpMonth( int month );
86 void resizeEvent( QResizeEvent * ); 87 void resizeEvent( QResizeEvent * );
87 88
88 void setBaseDates(); 89 void setBaseDates();
89 void connectNavigatorView( KDateNavigator *v ); 90 void connectNavigatorView( KDateNavigator *v );
90 91
91 private: 92 private:
93 bool mResizeEnabled;
92 QTimer* mUpdateTimer; 94 QTimer* mUpdateTimer;
93 int mLastDisplayedDN; 95 int mLastDisplayedDN;
94 QDate mFirstSelectedDate; 96 QDate mFirstSelectedDate;
95 int mSelectedDateCount; 97 int mSelectedDateCount;
96 KDateNavigator *mNavigatorView; 98 KDateNavigator *mNavigatorView;
97 99
98 KCal::Calendar *mCalendar; 100 KCal::Calendar *mCalendar;
99 101
100 QPtrList<KDateNavigator> mExtraViews; 102 QPtrList<KDateNavigator> mExtraViews;
101 103
102 int mHorizontalCount; 104 int mHorizontalCount;
103 int mVerticalCount; 105 int mVerticalCount;
104}; 106};
105 107
106#endif 108#endif
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 0cb767f..5eccfd6 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -26,193 +26,193 @@
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 headings[i]->installEventFilter(this); 86 headings[i]->installEventFilter(this);
87 87
88 topLayout->addWidget(headings[i],1,i+1); 88 topLayout->addWidget(headings[i],1,i+1);
89 } 89 }
90 90
91 // Create the weeknumber labels 91 // Create the weeknumber labels
92 for( i = 0; i < 6; i++ ) { 92 for( i = 0; i < 6; i++ ) {
93 weeknos[i] = new QLabel(this); 93 weeknos[i] = new QLabel(this);
94 weeknos[i]->setAlignment(AlignCenter); 94 weeknos[i]->setAlignment(AlignCenter);
95 //weeknos[i]->setFont(QFont("Arial", 10)); 95 //weeknos[i]->setFont(QFont("Arial", 10));
96 if(!m_bShowWeekNums) { 96 if(!m_bShowWeekNums) {
97 weeknos[i]->hide(); 97 weeknos[i]->hide();
98 } 98 }
99 weeknos[i]->installEventFilter(this); 99 weeknos[i]->installEventFilter(this);
100 100
101 topLayout->addWidget(weeknos[i],i+2,0); 101 topLayout->addWidget(weeknos[i],i+2,0);
102 } 102 }
103 103
104 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); 104 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix");
105 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); 105 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
106 daymatrix->setLineWidth(1); 106 daymatrix->setLineWidth(1);
107 107
108 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), 108 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
109 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 109 SIGNAL( datesSelected( const KCal::DateList & ) ) );
110 110
111 connect( daymatrix, SIGNAL( eventDropped( Event * ) ), 111 connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
112 SIGNAL( eventDropped( Event * ) ) ); 112 SIGNAL( eventDropped( Event * ) ) );
113 113
114 topLayout->addMultiCellWidget(daymatrix,2,7,1,7); 114 topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
115 115
116 // read settings from configuration file. 116 // read settings from configuration file.
117 updateConfig(); 117 updateConfig();
118 enableRollover(FollowMonth); 118 enableRollover(FollowMonth);
119 mySizeHint = sizeHintTwoButtons(); 119 mySizeHint = sizeHintTwoButtons();
120 myFullSizeHint = sizeHintTwoButtons( 4 ); 120 myFullSizeHint = sizeHintTwoButtons( 4 );
121 mFontChanged = false; 121 mFontChanged = false;
122 resize ( 3,3 ); 122 //resize ( 3,3 );
123 123
124} 124}
125void KDateNavigator::changeFont ( QFont fo ) 125void KDateNavigator::changeFont ( QFont fo )
126{ 126{
127 setFont( fo ); 127 setFont( fo );
128 mNavigatorBar->resetFont( fo ); 128 mNavigatorBar->resetFont( fo );
129} 129}
130QFont KDateNavigator::yourFontHint( QSize si , bool *b) 130QFont KDateNavigator::yourFontHint( QSize si , bool *b)
131{ 131{
132 QFont fo = KOPrefs::instance()->mDateNavigatorFont; 132 QFont fo = KOPrefs::instance()->mDateNavigatorFont;
133 *b = false; 133 *b = false;
134 int fontPoint = fo.pointSize(); 134 int fontPoint = fo.pointSize();
135 while ( fontPoint > 5 ) { 135 while ( fontPoint > 5 ) {
136 --fontPoint; 136 --fontPoint;
137 fo.setPointSize( fontPoint ); 137 fo.setPointSize( fontPoint );
138 setFont( fo ); 138 setFont( fo );
139 mFontChanged = true; 139 mFontChanged = true;
140 mNavigatorBar->resetFont( fo ); 140 mNavigatorBar->resetFont( fo );
141 QSize sh = sizeHintTwoButtons( 2 ); 141 QSize sh = sizeHintTwoButtons( 2 );
142 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); 142 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() );
143 if ( si.width() > sh.width() && si.height() > sh.height()) { 143 if ( si.width() > sh.width() && si.height() > sh.height()) {
144 if ( si.width() / sh.width() == 1 ) { 144 if ( si.width() / sh.width() == 1 ) {
145 if ( si.width() < sizeHintTwoButtons( 4 ).width()) 145 if ( si.width() < sizeHintTwoButtons( 4 ).width())
146 continue; 146 continue;
147 } 147 }
148 *b = true; 148 *b = true;
149 //qDebug("fooooooooooooooooooooooouuuuund "); 149 //qDebug("fooooooooooooooooooooooouuuuund ");
150 break; 150 break;
151 } 151 }
152 } 152 }
153 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); 153 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() );
154 return fo; 154 return fo;
155} 155}
156QSize KDateNavigator::sizeHint() const 156QSize KDateNavigator::sizeHint() const
157{ 157{
158 QFontMetrics fm ( font() ); 158 QFontMetrics fm ( font() );
159 QSize day = daymatrix->sizeHint(); 159 QSize day = daymatrix->sizeHint();
160 QSize nav = mNavigatorBar->sizeHint(); 160 QSize nav = mNavigatorBar->sizeHint();
161 int wid = fm.width( "30") + day.width()+3; 161 int wid = fm.width( "30") + day.width()+3;
162 int hei = fm.height() +day.height()+nav.height()+2; 162 int hei = fm.height() +day.height()+nav.height()+2;
163 if ( wid < nav.width() ) 163 if ( wid < nav.width() )
164 wid = nav.width() ; 164 wid = nav.width() ;
165 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); 165 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
166 return QSize ( wid, hei ); 166 return QSize ( wid, hei );
167} 167}
168QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const 168QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const
169{ 169{
170 QFontMetrics fm ( font() ); 170 QFontMetrics fm ( font() );
171 QSize day = daymatrix->sizeHint(); 171 QSize day = daymatrix->sizeHint();
172 QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); 172 QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum );
173 int wid = fm.width( "30") + day.width()+3; 173 int wid = fm.width( "30") + day.width()+3;
174 int hei = fm.height() +day.height()+nav.height()+2; 174 int hei = fm.height() +day.height()+nav.height()+2;
175 if ( wid < nav.width() ) 175 if ( wid < nav.width() )
176 wid = nav.width() ; 176 wid = nav.width() ;
177 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); 177 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
178 return QSize ( wid, hei ); 178 return QSize ( wid, hei );
179} 179}
180void KDateNavigator::slotMonthSelected( int m ) 180void KDateNavigator::slotMonthSelected( int m )
181{ 181{
182 if ( m_MthYr.month() <= mMonthSignalOffset) 182 if ( m_MthYr.month() <= mMonthSignalOffset)
183 m += 12; 183 m += 12;
184 //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); 184 //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset);
185 emit monthSelected( m - mMonthSignalOffset ); 185 emit monthSelected( m - mMonthSignalOffset );
186 186
187} 187}
188void KDateNavigator::setCalendar( Calendar *cal ) 188void KDateNavigator::setCalendar( Calendar *cal )
189{ 189{
190 daymatrix->setCalendar( cal ); 190 daymatrix->setCalendar( cal );
191} 191}
192 192
193void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true 193void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true
194{ 194{
195 m_MthYr = date; 195 m_MthYr = date;
196 //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); 196 //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1());
197 197
198 updateDates(); 198 updateDates();
199 updateView(); 199 updateView();
200 200
201 KCal::DateList dates; 201 KCal::DateList dates;
202 dates.append( date ); 202 dates.append( date );
203 mNavigatorBar->selectDates( dates ); 203 mNavigatorBar->selectDates( dates );
204 204
205 daymatrix->clearSelection(); 205 daymatrix->clearSelection();
206 if ( doRepaint ) 206 if ( doRepaint )
207 daymatrix->repaint( false ); 207 daymatrix->repaint( false );
208} 208}
209 209
210void KDateNavigator::enableRollover(RolloverType r) 210void KDateNavigator::enableRollover(RolloverType r)
211{ 211{
212 switch(r) 212 switch(r)
213 { 213 {
214 case None : 214 case None :
215 if (updateTimer) 215 if (updateTimer)
216 { 216 {
217 updateTimer->stop(); 217 updateTimer->stop();
218 delete updateTimer; 218 delete updateTimer;
@@ -278,189 +278,190 @@ void KDateNavigator::passedMidnight()
278 278
279 updateTimer->stop(); 279 updateTimer->stop();
280 updateTimer->start(msecsWait,true); 280 updateTimer->start(msecsWait,true);
281 } 281 }
282} 282}
283 283
284void KDateNavigator::updateDates() 284void KDateNavigator::updateDates()
285{ 285{
286 // Find the first day of the week of the current month. 286 // Find the first day of the week of the current month.
287 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); 287 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr );
288 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); 288 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() );
289 int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); 289 int d2 = KOGlobals::self()->calendarSystem()->day( dayone );
290 //int di = d1 - d2 + 1; 290 //int di = d1 - d2 + 1;
291 dayone = dayone.addDays( -d2 + 1 ); 291 dayone = dayone.addDays( -d2 + 1 );
292 292
293 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); 293 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone );
294 294
295 // If month begins on Monday and Monday is first day of week, 295 // If month begins on Monday and Monday is first day of week,
296 // month should begin on second line. Sunday doesn't have this problem. 296 // month should begin on second line. Sunday doesn't have this problem.
297 int nextLine = ( ( m_fstDayOfWkCalsys == 1) && 297 int nextLine = ( ( m_fstDayOfWkCalsys == 1) &&
298 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; 298 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0;
299 299
300 // update the matrix dates 300 // update the matrix dates
301 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; 301 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine;
302 302
303 303
304 daymatrix->updateView(dayone.addDays(index)); 304 daymatrix->updateView(dayone.addDays(index));
305//each updateDates is followed by an updateView -> repaint is issued there ! 305//each updateDates is followed by an updateView -> repaint is issued there !
306// daymatrix->repaint(); 306// daymatrix->repaint();
307} 307}
308 308
309void KDateNavigator::updateDayMatrix() 309void KDateNavigator::updateDayMatrix()
310{ 310{
311 daymatrix->updateView(); 311 daymatrix->updateView();
312 //daymatrix->repaint(); 312 //daymatrix->repaint();
313} 313}
314 314
315 315
316void KDateNavigator::updateView() 316void KDateNavigator::updateView()
317{ 317{
318 318
319 setUpdatesEnabled( false ); 319 setUpdatesEnabled( false );
320 320
321 int i; 321 int i;
322 322
323// kdDebug() << "updateView() -> daymatrix->updateView()" << endl; 323// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
324 daymatrix->updateView(); 324 daymatrix->updateView();
325 325
326 // set the week numbers. 326 // set the week numbers.
327 for(i = 0; i < 6; i++) { 327 for(i = 0; i < 6; i++) {
328 QString weeknum; 328 QString weeknum;
329 // remember, according to ISO 8601, the first week of the year is the 329 // remember, according to ISO 8601, the first week of the year is the
330 // first week that contains a thursday. Thus we must subtract off 4, 330 // first week that contains a thursday. Thus we must subtract off 4,
331 // not just 1. 331 // not just 1.
332 332
333 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); 333 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear();
334 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); 334 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4)));
335 335
336 int add = 0; 336 int add = 0;
337 if ( ! KGlobal::locale()->weekStartsMonday() ) 337 if ( ! KGlobal::locale()->weekStartsMonday() )
338 ++add; 338 ++add;
339 if (dayOfYear % 7 != 0) 339 if (dayOfYear % 7 != 0)
340 weeknum.setNum(dayOfYear / 7 + 1+add); 340 weeknum.setNum(dayOfYear / 7 + 1+add);
341 else 341 else
342 weeknum.setNum(dayOfYear / 7 +add); 342 weeknum.setNum(dayOfYear / 7 +add);
343 weeknos[i]->setText(weeknum); 343 weeknos[i]->setText(weeknum);
344 } 344 }
345 345
346 setUpdatesEnabled( true ); 346 setUpdatesEnabled( true );
347// kdDebug() << "updateView() -> repaint()" << endl; 347// kdDebug() << "updateView() -> repaint()" << endl;
348 repaint(); 348 repaint();
349 // daymatrix->repaint(); 349 // daymatrix->repaint();
350} 350}
351 351
352void KDateNavigator::updateConfig() 352void KDateNavigator::updateConfig()
353{ 353{
354 int day; 354 int day;
355 for(int i=0; i<7; i++) { 355 for(int i=0; i<7; i++) {
356 // take the first letter of the day name to be the abbreviation 356 // take the first letter of the day name to be the abbreviation
357 if (KGlobal::locale()->weekStartsMonday()) { 357 if (KGlobal::locale()->weekStartsMonday()) {
358 day = i+1; 358 day = i+1;
359 } else { 359 } else {
360 if (i==0) day = 7; 360 if (i==0) day = 7;
361 else day = i; 361 else day = i;
362 } 362 }
363 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, 363 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day,
364 true ); 364 true );
365 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); 365 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 );
366 headings[i]->setText( dayName ); 366 headings[i]->setText( dayName );
367 } 367 }
368 updateDates(); 368 updateDates();
369 updateView(); 369 updateView();
370} 370}
371 371
372void KDateNavigator::setShowWeekNums(bool enabled) 372void KDateNavigator::setShowWeekNums(bool enabled)
373{ 373{
374 qDebug("KDateNavigator::setShowWeekNums***************************** ");
374 m_bShowWeekNums = enabled; 375 m_bShowWeekNums = enabled;
375 for(int i=0; i<6; i++) { 376 for(int i=0; i<6; i++) {
376 if(enabled) 377 if(enabled)
377 weeknos[i]->show(); 378 weeknos[i]->show();
378 else 379 else
379 weeknos[i]->hide(); 380 weeknos[i]->hide();
380 } 381 }
381 resize(size()); 382 resize(size());
382} 383}
383 384
384void KDateNavigator::selectDates(const DateList& dateList) 385void KDateNavigator::selectDates(const DateList& dateList)
385{ 386{
386 387
387 if (dateList.count() > 0) { 388 if (dateList.count() > 0) {
388 mNavigatorBar->selectDates( dateList ); 389 mNavigatorBar->selectDates( dateList );
389 mSelectedDates = dateList; 390 mSelectedDates = dateList;
390 391
391 // set our record of the month and year that this datetbl is 392 // set our record of the month and year that this datetbl is
392 // displaying. 393 // displaying.
393 m_MthYr = mSelectedDates.first(); 394 m_MthYr = mSelectedDates.first();
394 395
395 396
396 // set our record of the first day of the week of the current 397 // set our record of the first day of the week of the current
397 // month. This needs to be done before calling dayToIndex, since it 398 // month. This needs to be done before calling dayToIndex, since it
398 // relies on this information being up to date. 399 // relies on this information being up to date.
399 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 400 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
400 m_fstDayOfWk = dayone.dayOfWeek(); 401 m_fstDayOfWk = dayone.dayOfWeek();
401 402
402 updateDates(); 403 updateDates();
403 404
404 daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 405 daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
405 406
406 updateView(); 407 updateView();
407 } 408 }
408} 409}
409 410
410int KDateNavigator::dayNum(int row, int col) 411int KDateNavigator::dayNum(int row, int col)
411{ 412{
412 return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; 413 return 7 * (row - 1) + (col + 1) - m_fstDayOfWk;
413} 414}
414 415
415int KDateNavigator::dayToIndex(int dayNum) 416int KDateNavigator::dayToIndex(int dayNum)
416{ 417{
417 int row, col; 418 int row, col;
418 419
419 row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; 420 row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7;
420 if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) 421 if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1))
421 row++; 422 row++;
422 col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; 423 col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7;
423 return row * 7 + col; 424 return row * 7 + col;
424} 425}
425 426
426void KDateNavigator::wheelEvent (QWheelEvent *e) 427void KDateNavigator::wheelEvent (QWheelEvent *e)
427{ 428{
428 if(e->delta()>0) emit goPrevious(); 429 if(e->delta()>0) emit goPrevious();
429 else emit goNext(); 430 else emit goNext();
430 431
431 e->accept(); 432 e->accept();
432} 433}
433 434
434bool KDateNavigator::eventFilter (QObject *o,QEvent *e) 435bool KDateNavigator::eventFilter (QObject *o,QEvent *e)
435{ 436{
436 if (e->type() == QEvent::MouseButtonPress) { 437 if (e->type() == QEvent::MouseButtonPress) {
437 int i; 438 int i;
438 for(i=0;i<6;++i) { 439 for(i=0;i<6;++i) {
439 if (o == weeknos[i]) { 440 if (o == weeknos[i]) {
440 QDate weekstart = daymatrix->getDate(i*7); 441 QDate weekstart = daymatrix->getDate(i*7);
441 emit weekClicked(weekstart); 442 emit weekClicked(weekstart);
442 break; 443 break;
443 } 444 }
444 } 445 }
445 for(i=0;i<7;++i) { 446 for(i=0;i<7;++i) {
446 if (o == headings[i]) { 447 if (o == headings[i]) {
447 KCal::DateList selDays; 448 KCal::DateList selDays;
448 QDate date = daymatrix->getDate(14); 449 QDate date = daymatrix->getDate(14);
449 int dio = date.daysInMonth(); 450 int dio = date.daysInMonth();
450 int j; 451 int j;
451 int ye = date.year(); 452 int ye = date.year();
452 int mo = date.month(); 453 int mo = date.month();
453 for ( j = 1; j <= dio; ++j ) { 454 for ( j = 1; j <= dio; ++j ) {
454 selDays.append( QDate( ye, mo, j ) ); 455 selDays.append( QDate( ye, mo, j ) );
455 } 456 }
456 emit datesSelected( selDays ); 457 emit datesSelected( selDays );
457 break; 458 break;
458 } 459 }
459 } 460 }
460 return true; 461 return true;
461 } else { 462 } else {
462 return false; 463 return false;
463 } 464 }
464} 465}
465 466
466//#include "kdatenavigator.moc" 467//#include "kdatenavigator.moc"