summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp2
-rw-r--r--korganizer/kdatenavigator.cpp4
2 files changed, 3 insertions, 3 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index d4173e8..9506768 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -38,193 +38,193 @@
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 mExtraViews.setAutoDelete( true ); 43 mExtraViews.setAutoDelete( true );
44 44
45 mNavigatorView = new KDateNavigator( this, name ); 45 mNavigatorView = new KDateNavigator( this, name );
46 46
47 connectNavigatorView( mNavigatorView ); 47 connectNavigatorView( mNavigatorView );
48} 48}
49 49
50DateNavigatorContainer::~DateNavigatorContainer() 50DateNavigatorContainer::~DateNavigatorContainer()
51{ 51{
52} 52}
53 53
54void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) 54void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
55{ 55{
56 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), 56 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ),
57 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 57 SIGNAL( datesSelected( const KCal::DateList & ) ) );
58#if 0 58#if 0
59 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), 59 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ),
60 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); 60 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) );
61 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), 61 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ),
62 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); 62 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) );
63#endif 63#endif
64 connect( v, SIGNAL( weekClicked( const QDate & ) ), 64 connect( v, SIGNAL( weekClicked( const QDate & ) ),
65 SIGNAL( weekClicked( const QDate & ) ) ); 65 SIGNAL( weekClicked( const QDate & ) ) );
66 66
67 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); 67 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
68 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); 68 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
69 69
70 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 70 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
71 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 71 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
72 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 72 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
73 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 73 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
74 74
75 connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); 75 connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) );
76} 76}
77 77
78void DateNavigatorContainer::setCalendar( Calendar *cal ) 78void DateNavigatorContainer::setCalendar( Calendar *cal )
79{ 79{
80 mCalendar = cal; 80 mCalendar = cal;
81 mNavigatorView->setCalendar( cal ); 81 mNavigatorView->setCalendar( cal );
82 KDateNavigator *n; 82 KDateNavigator *n;
83 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 83 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
84 n->setCalendar( cal ); 84 n->setCalendar( cal );
85 } 85 }
86} 86}
87 87
88void DateNavigatorContainer::updateDayMatrix() 88void DateNavigatorContainer::updateDayMatrix()
89{ 89{
90 mNavigatorView->updateDayMatrix(); 90 mNavigatorView->updateDayMatrix();
91 KDateNavigator *n; 91 KDateNavigator *n;
92 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 92 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
93 n->updateDayMatrix(); 93 n->updateDayMatrix();
94 } 94 }
95} 95}
96 96
97void DateNavigatorContainer::updateToday() 97void DateNavigatorContainer::updateToday()
98{ 98{
99 qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); 99 qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
100#if 0 100#if 0
101 mNavigatorView->updateToday(); 101 mNavigatorView->updateToday();
102 KDateNavigator *n; 102 KDateNavigator *n;
103 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 103 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
104 n->updateToday(); 104 n->updateToday();
105 } 105 }
106#endif 106#endif
107} 107}
108 108
109void DateNavigatorContainer::updateView() 109void DateNavigatorContainer::updateView()
110{ 110{
111 mNavigatorView->updateView(); 111 mNavigatorView->updateView();
112 KDateNavigator *n; 112 KDateNavigator *n;
113 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 113 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
114 n->updateView(); 114 n->updateView();
115 } 115 }
116} 116}
117 117
118void DateNavigatorContainer::updateConfig() 118void DateNavigatorContainer::updateConfig()
119{ 119{
120 mNavigatorView->updateConfig(); 120 mNavigatorView->updateConfig();
121 KDateNavigator *n; 121 KDateNavigator *n;
122 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 122 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
123 n->updateConfig(); 123 n->updateConfig();
124 } 124 }
125} 125}
126 126
127void DateNavigatorContainer::selectDates( const DateList &dateList ) 127void DateNavigatorContainer::selectDates( const DateList &dateList )
128{ 128{
129 mNavigatorView->selectDates( dateList ); 129 mNavigatorView->selectDates( dateList );
130 setBaseDates(); 130 setBaseDates();
131 if ( mExtraViews.count() ) { 131 if ( mExtraViews.count() ) {
132 KDateNavigator *view = mExtraViews.at( 0 ); 132 KDateNavigator *view = mExtraViews.at( 0 );
133 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 133 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
134 view->dayMatrix()->repaint(); 134 view->dayMatrix()->repaint( false );
135 } 135 }
136} 136}
137 137
138void DateNavigatorContainer::setBaseDates() 138void DateNavigatorContainer::setBaseDates()
139{ 139{
140 KCal::DateList dateList = mNavigatorView->selectedDates(); 140 KCal::DateList dateList = mNavigatorView->selectedDates();
141 if ( dateList.isEmpty() ) { 141 if ( dateList.isEmpty() ) {
142 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; 142 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl;
143 } 143 }
144 QDate baseDate = dateList.first(); 144 QDate baseDate = dateList.first();
145 KDateNavigator *n; 145 KDateNavigator *n;
146 bool doRepaint = false; // skip first repaint 146 bool doRepaint = false; // skip first repaint
147 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 147 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
148 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 148 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
149 n->setBaseDate( baseDate, doRepaint ); 149 n->setBaseDate( baseDate, doRepaint );
150 doRepaint = true; 150 doRepaint = true;
151 } 151 }
152} 152}
153 153
154void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) 154void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
155{ 155{
156#if 0 156#if 0
157 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; 157 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl;
158 kdDebug(5850) << " CURRENT SIZE: " << size() << endl; 158 kdDebug(5850) << " CURRENT SIZE: " << size() << endl;
159 kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; 159 kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl;
160 kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; 160 kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl;
161 kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; 161 kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl;
162#endif 162#endif
163 //QSize minSize = mNavigatorView->sizeHintTwoButtons(); 163 //QSize minSize = mNavigatorView->sizeHintTwoButtons();
164 QSize minSize = mNavigatorView->yourSizeHint(); 164 QSize minSize = mNavigatorView->yourSizeHint();
165 165
166// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; 166// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl;
167 167
168 int verticalCount = size().height() / minSize.height(); 168 int verticalCount = size().height() / minSize.height();
169 int horizontalCount = size().width() / minSize.width(); 169 int horizontalCount = size().width() / minSize.width();
170 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); 170 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
171 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); 171 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
172 bool fontchange = false; 172 bool fontchange = false;
173 QFont fo; 173 QFont fo;
174 if ( horizontalCount != mHorizontalCount || 174 if ( horizontalCount != mHorizontalCount ||
175 verticalCount != mVerticalCount ) { 175 verticalCount != mVerticalCount ) {
176 uint count = horizontalCount * verticalCount; 176 uint count = horizontalCount * verticalCount;
177 if ( count == 0 ) { 177 if ( count == 0 ) {
178 bool ok; 178 bool ok;
179 fo = mNavigatorView->yourFontHint( size() , &ok); 179 fo = mNavigatorView->yourFontHint( size() , &ok);
180 //mNavigatorView->resize( size() ); 180 //mNavigatorView->resize( size() );
181 //if ( ! ok ) 181 //if ( ! ok )
182 // return; 182 // return;
183 minSize = mNavigatorView->sizeHintTwoButtons(); 183 minSize = mNavigatorView->sizeHintTwoButtons();
184 verticalCount = size().height() / minSize.height(); 184 verticalCount = size().height() / minSize.height();
185 horizontalCount = size().width() / minSize.width(); 185 horizontalCount = size().width() / minSize.width();
186 if ( horizontalCount == 0 ) 186 if ( horizontalCount == 0 )
187 horizontalCount = 1; 187 horizontalCount = 1;
188 if ( verticalCount == 0 ) 188 if ( verticalCount == 0 )
189 verticalCount = 1; 189 verticalCount = 1;
190 fontchange = true; 190 fontchange = true;
191 count = horizontalCount * verticalCount; 191 count = horizontalCount * verticalCount;
192 } else { 192 } else {
193 if ( mNavigatorView->fontChanged() ) { 193 if ( mNavigatorView->fontChanged() ) {
194 fontchange = true; 194 fontchange = true;
195 fo = KOPrefs::instance()->mDateNavigatorFont; 195 fo = KOPrefs::instance()->mDateNavigatorFont;
196 mNavigatorView->changeFont( fo ); 196 mNavigatorView->changeFont( fo );
197 mNavigatorView->unsetFontChanged(); 197 mNavigatorView->unsetFontChanged();
198 } 198 }
199 } 199 }
200 200
201 while ( count > ( mExtraViews.count() + 1 ) ) { 201 while ( count > ( mExtraViews.count() + 1 ) ) {
202 KDateNavigator *n = new KDateNavigator( this ); 202 KDateNavigator *n = new KDateNavigator( this );
203 n->setMonthSignalOffset ( mExtraViews.count()+1 ); 203 n->setMonthSignalOffset ( mExtraViews.count()+1 );
204 mExtraViews.append( n ); 204 mExtraViews.append( n );
205 n->setCalendar( mCalendar ); 205 n->setCalendar( mCalendar );
206 setBaseDates(); 206 setBaseDates();
207 connectNavigatorView( n ); 207 connectNavigatorView( n );
208 n->show(); 208 n->show();
209 } 209 }
210 int iii = 0; 210 int iii = 0;
211 while ( iii < ( mExtraViews.count() ) ) { 211 while ( iii < ( mExtraViews.count() ) ) {
212 if ( iii < count-1 ) 212 if ( iii < count-1 )
213 mExtraViews.at( iii )->show(); 213 mExtraViews.at( iii )->show();
214 else 214 else
215 mExtraViews.at( iii )->hide(); 215 mExtraViews.at( iii )->hide();
216 ++iii; 216 ++iii;
217 } 217 }
218 if ( fontchange ) { 218 if ( fontchange ) {
219 //mNavigatorView->changeFont( fo ); 219 //mNavigatorView->changeFont( fo );
220 uint i; 220 uint i;
221 for( i = 0; i < mExtraViews.count(); ++i ) { 221 for( i = 0; i < mExtraViews.count(); ++i ) {
222 KDateNavigator *view = mExtraViews.at( i ); 222 KDateNavigator *view = mExtraViews.at( i );
223 view->changeFont( fo ); 223 view->changeFont( fo );
224 } 224 }
225 } 225 }
226 mHorizontalCount = horizontalCount; 226 mHorizontalCount = horizontalCount;
227 mVerticalCount = verticalCount; 227 mVerticalCount = verticalCount;
228 } 228 }
229 int height = size().height() / verticalCount; 229 int height = size().height() / verticalCount;
230 int width = size().width() / horizontalCount; 230 int width = size().width() / horizontalCount;
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 2321acb..fe83e09 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -102,242 +102,242 @@ KDateNavigator::KDateNavigator( QWidget *parent, const char *name )
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 mySizeHint = sizeHintTwoButtons(); 118 mySizeHint = sizeHintTwoButtons();
119 mFontChanged = false; 119 mFontChanged = false;
120} 120}
121void KDateNavigator::changeFont ( QFont fo ) 121void KDateNavigator::changeFont ( QFont fo )
122{ 122{
123 setFont( fo ); 123 setFont( fo );
124 mNavigatorBar->resetFont( fo ); 124 mNavigatorBar->resetFont( fo );
125} 125}
126QFont KDateNavigator::yourFontHint( QSize si , bool *b) 126QFont KDateNavigator::yourFontHint( QSize si , bool *b)
127{ 127{
128 QFont fo = KOPrefs::instance()->mDateNavigatorFont; 128 QFont fo = KOPrefs::instance()->mDateNavigatorFont;
129 *b = false; 129 *b = false;
130 int fontPoint = fo.pointSize(); 130 int fontPoint = fo.pointSize();
131 while ( fontPoint > 5 ) { 131 while ( fontPoint > 5 ) {
132 --fontPoint; 132 --fontPoint;
133 fo.setPointSize( fontPoint ); 133 fo.setPointSize( fontPoint );
134 setFont( fo ); 134 setFont( fo );
135 mFontChanged = true; 135 mFontChanged = true;
136 mNavigatorBar->resetFont( fo ); 136 mNavigatorBar->resetFont( fo );
137 QSize sh = sizeHintTwoButtons(); 137 QSize sh = sizeHintTwoButtons();
138 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); 138 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() );
139 if ( si.width() > sh.width() && si.height() > sh.height()) { 139 if ( si.width() > sh.width() && si.height() > sh.height()) {
140 *b = true; 140 *b = true;
141 //qDebug("fooooooooooooooooooooooouuuuund "); 141 //qDebug("fooooooooooooooooooooooouuuuund ");
142 break; 142 break;
143 } 143 }
144 } 144 }
145 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); 145 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() );
146 return fo; 146 return fo;
147} 147}
148QSize KDateNavigator::sizeHint() const 148QSize KDateNavigator::sizeHint() const
149{ 149{
150 QFontMetrics fm ( font() ); 150 QFontMetrics fm ( font() );
151 QSize day = daymatrix->sizeHint(); 151 QSize day = daymatrix->sizeHint();
152 QSize nav = mNavigatorBar->sizeHint(); 152 QSize nav = mNavigatorBar->sizeHint();
153 int wid = fm.width( "30") + day.width()+3; 153 int wid = fm.width( "30") + day.width()+3;
154 int hei = fm.height() +day.height()+nav.height()+2; 154 int hei = fm.height() +day.height()+nav.height()+2;
155 if ( wid < nav.width() ) 155 if ( wid < nav.width() )
156 wid = nav.width() ; 156 wid = nav.width() ;
157 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); 157 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
158 return QSize ( wid, hei ); 158 return QSize ( wid, hei );
159} 159}
160QSize KDateNavigator::sizeHintTwoButtons() const 160QSize KDateNavigator::sizeHintTwoButtons() const
161{ 161{
162 QFontMetrics fm ( font() ); 162 QFontMetrics fm ( font() );
163 QSize day = daymatrix->sizeHint(); 163 QSize day = daymatrix->sizeHint();
164 QSize nav = mNavigatorBar->sizeHintTwoButtons(); 164 QSize nav = mNavigatorBar->sizeHintTwoButtons();
165 int wid = fm.width( "30") + day.width()+3; 165 int wid = fm.width( "30") + day.width()+3;
166 int hei = fm.height() +day.height()+nav.height()+2; 166 int hei = fm.height() +day.height()+nav.height()+2;
167 if ( wid < nav.width() ) 167 if ( wid < nav.width() )
168 wid = nav.width() ; 168 wid = nav.width() ;
169 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); 169 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
170 return QSize ( wid, hei ); 170 return QSize ( wid, hei );
171} 171}
172void KDateNavigator::slotMonthSelected( int m ) 172void KDateNavigator::slotMonthSelected( int m )
173{ 173{
174 if ( m_MthYr.month() <= mMonthSignalOffset) 174 if ( m_MthYr.month() <= mMonthSignalOffset)
175 m += 12; 175 m += 12;
176 //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); 176 //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset);
177 emit monthSelected( m - mMonthSignalOffset ); 177 emit monthSelected( m - mMonthSignalOffset );
178 178
179} 179}
180void KDateNavigator::setCalendar( Calendar *cal ) 180void KDateNavigator::setCalendar( Calendar *cal )
181{ 181{
182 daymatrix->setCalendar( cal ); 182 daymatrix->setCalendar( cal );
183} 183}
184 184
185void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true 185void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true
186{ 186{
187 m_MthYr = date; 187 m_MthYr = date;
188 188
189 updateDates(); 189 updateDates();
190 updateView(); 190 updateView();
191 191
192 KCal::DateList dates; 192 KCal::DateList dates;
193 dates.append( date ); 193 dates.append( date );
194 mNavigatorBar->selectDates( dates ); 194 mNavigatorBar->selectDates( dates );
195 195
196 daymatrix->clearSelection(); 196 daymatrix->clearSelection();
197 if ( doRepaint ) 197 if ( doRepaint )
198 daymatrix->repaint(); 198 daymatrix->repaint( false );
199} 199}
200 200
201void KDateNavigator::enableRollover(RolloverType r) 201void KDateNavigator::enableRollover(RolloverType r)
202{ 202{
203 switch(r) 203 switch(r)
204 { 204 {
205 case None : 205 case None :
206 if (updateTimer) 206 if (updateTimer)
207 { 207 {
208 updateTimer->stop(); 208 updateTimer->stop();
209 delete updateTimer; 209 delete updateTimer;
210 updateTimer=0L; 210 updateTimer=0L;
211 } 211 }
212 break; 212 break;
213 case FollowDay : 213 case FollowDay :
214 case FollowMonth : 214 case FollowMonth :
215 if (!updateTimer) 215 if (!updateTimer)
216 { 216 {
217 updateTimer = new QTimer(this); 217 updateTimer = new QTimer(this);
218 QObject::connect(updateTimer,SIGNAL(timeout()), 218 QObject::connect(updateTimer,SIGNAL(timeout()),
219 this,SLOT(possiblyPastMidnight())); 219 this,SLOT(possiblyPastMidnight()));
220 } 220 }
221 updateTimer->start(0,true); 221 updateTimer->start(0,true);
222 lastDayChecked = QDate::currentDate(); 222 lastDayChecked = QDate::currentDate();
223 } 223 }
224 updateRollover=r; 224 updateRollover=r;
225} 225}
226 226
227 227
228KDateNavigator::~KDateNavigator() 228KDateNavigator::~KDateNavigator()
229{ 229{
230} 230}
231 231
232 232
233void KDateNavigator::passedMidnight() 233void KDateNavigator::passedMidnight()
234{ 234{
235 QDate today = QDate::currentDate(); 235 QDate today = QDate::currentDate();
236 bool emitMonth = false; 236 bool emitMonth = false;
237 237
238 if (today.month() != lastDayChecked.month()) 238 if (today.month() != lastDayChecked.month())
239 { 239 {
240 if (updateRollover==FollowMonth && 240 if (updateRollover==FollowMonth &&
241 daymatrix->isEndOfMonth()) { 241 daymatrix->isEndOfMonth()) {
242 goNextMonth(); 242 goNextMonth();
243 emitMonth=true; 243 emitMonth=true;
244 } 244 }
245 } 245 }
246 daymatrix->recalculateToday(); 246 daymatrix->recalculateToday();
247 daymatrix->repaint(); 247 daymatrix->repaint( false );
248 emit dayPassed(today); 248 emit dayPassed(today);
249 if (emitMonth) { emit monthPassed(today); } 249 if (emitMonth) { emit monthPassed(today); }
250} 250}
251 251
252/* slot */ void KDateNavigator::possiblyPastMidnight() 252/* slot */ void KDateNavigator::possiblyPastMidnight()
253{ 253{
254 if (lastDayChecked!=QDate::currentDate()) 254 if (lastDayChecked!=QDate::currentDate())
255 { 255 {
256 passedMidnight(); 256 passedMidnight();
257 lastDayChecked=QDate::currentDate(); 257 lastDayChecked=QDate::currentDate();
258 } 258 }
259 // Set the timer to go off 1 second after midnight 259 // Set the timer to go off 1 second after midnight
260 // or after 8 minutes, whichever comes first. 260 // or after 8 minutes, whichever comes first.
261 if (updateTimer) 261 if (updateTimer)
262 { 262 {
263 QTime now = QTime::currentTime(); 263 QTime now = QTime::currentTime();
264 QTime midnight = QTime(23,59,59); 264 QTime midnight = QTime(23,59,59);
265 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); 265 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000);
266 266
267 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) 267 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait))
268 //.arg(now.toString()).arg(midnight.toString())); 268 //.arg(now.toString()).arg(midnight.toString()));
269 269
270 updateTimer->stop(); 270 updateTimer->stop();
271 updateTimer->start(msecsWait,true); 271 updateTimer->start(msecsWait,true);
272 } 272 }
273} 273}
274 274
275void KDateNavigator::updateDates() 275void KDateNavigator::updateDates()
276{ 276{
277 // Find the first day of the week of the current month. 277 // Find the first day of the week of the current month.
278 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); 278 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr );
279 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); 279 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() );
280 int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); 280 int d2 = KOGlobals::self()->calendarSystem()->day( dayone );
281 //int di = d1 - d2 + 1; 281 //int di = d1 - d2 + 1;
282 dayone = dayone.addDays( -d2 + 1 ); 282 dayone = dayone.addDays( -d2 + 1 );
283 283
284 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); 284 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone );
285 285
286 // If month begins on Monday and Monday is first day of week, 286 // If month begins on Monday and Monday is first day of week,
287 // month should begin on second line. Sunday doesn't have this problem. 287 // month should begin on second line. Sunday doesn't have this problem.
288 int nextLine = ( ( m_fstDayOfWkCalsys == 1) && 288 int nextLine = ( ( m_fstDayOfWkCalsys == 1) &&
289 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; 289 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0;
290 290
291 // update the matrix dates 291 // update the matrix dates
292 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; 292 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine;
293 293
294 294
295 daymatrix->updateView(dayone.addDays(index)); 295 daymatrix->updateView(dayone.addDays(index));
296//each updateDates is followed by an updateView -> repaint is issued there ! 296//each updateDates is followed by an updateView -> repaint is issued there !
297// daymatrix->repaint(); 297// daymatrix->repaint();
298} 298}
299 299
300void KDateNavigator::updateDayMatrix() 300void KDateNavigator::updateDayMatrix()
301{ 301{
302 daymatrix->updateView(); 302 daymatrix->updateView();
303 //daymatrix->repaint(); 303 //daymatrix->repaint();
304} 304}
305 305
306 306
307void KDateNavigator::updateView() 307void KDateNavigator::updateView()
308{ 308{
309 309
310 setUpdatesEnabled( false ); 310 setUpdatesEnabled( false );
311 311
312 int i; 312 int i;
313 313
314// kdDebug() << "updateView() -> daymatrix->updateView()" << endl; 314// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
315 daymatrix->updateView(); 315 daymatrix->updateView();
316 316
317 // set the week numbers. 317 // set the week numbers.
318 for(i = 0; i < 6; i++) { 318 for(i = 0; i < 6; i++) {
319 QString weeknum; 319 QString weeknum;
320 // remember, according to ISO 8601, the first week of the year is the 320 // remember, according to ISO 8601, the first week of the year is the
321 // first week that contains a thursday. Thus we must subtract off 4, 321 // first week that contains a thursday. Thus we must subtract off 4,
322 // not just 1. 322 // not just 1.
323 323
324 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); 324 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear();
325 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); 325 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4)));
326 326
327 int add = 0; 327 int add = 0;
328 if ( ! KGlobal::locale()->weekStartsMonday() ) 328 if ( ! KGlobal::locale()->weekStartsMonday() )
329 ++add; 329 ++add;
330 if (dayOfYear % 7 != 0) 330 if (dayOfYear % 7 != 0)
331 weeknum.setNum(dayOfYear / 7 + 1+add); 331 weeknum.setNum(dayOfYear / 7 + 1+add);
332 else 332 else
333 weeknum.setNum(dayOfYear / 7 +add); 333 weeknum.setNum(dayOfYear / 7 +add);
334 weeknos[i]->setText(weeknum); 334 weeknos[i]->setText(weeknum);
335 } 335 }
336 336
337 setUpdatesEnabled( true ); 337 setUpdatesEnabled( true );
338// kdDebug() << "updateView() -> repaint()" << endl; 338// kdDebug() << "updateView() -> repaint()" << endl;
339 repaint(); 339 repaint();
340 // daymatrix->repaint(); 340 // daymatrix->repaint();
341} 341}
342 342
343void KDateNavigator::updateConfig() 343void KDateNavigator::updateConfig()