summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-30 13:24:56 (UTC)
committer zautrix <zautrix>2005-03-30 13:24:56 (UTC)
commit056f171723a9301aea5a65340dffeda34e078abf (patch) (unidiff)
tree7930525c801dd9c5d9a910b71bca7dc79e10f666 /korganizer
parentb5222dd7a607f78235b1ea39fea0f95a9c08ccd3 (diff)
downloadkdepimpi-056f171723a9301aea5a65340dffeda34e078abf.zip
kdepimpi-056f171723a9301aea5a65340dffeda34e078abf.tar.gz
kdepimpi-056f171723a9301aea5a65340dffeda34e078abf.tar.bz2
fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp36
-rw-r--r--korganizer/kdatenavigator.cpp1
2 files changed, 17 insertions, 20 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 27ba9e0..f6f62a4 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -16,416 +16,414 @@
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 mResizeEnabled = false;
44 mExtraViews.setAutoDelete( true ); 44 mExtraViews.setAutoDelete( true );
45 45
46 mNavigatorView = new KDateNavigator( this, name ); 46 mNavigatorView = new KDateNavigator( this, name );
47 mNavigatorView->hide(); 47 mNavigatorView->hide();
48 connectNavigatorView( mNavigatorView ); 48 connectNavigatorView( mNavigatorView );
49 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 49 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
50 mLastDisplayedDN = 0; 50 mLastDisplayedDN = 0;
51 mUpdateTimer; 51 mUpdateTimer;
52 mUpdateTimer = new QTimer( this ); 52 mUpdateTimer = new QTimer( this );
53 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() )); 53 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() ));
54 mFirstSelectedDate = QDate::currentDate(); 54 mFirstSelectedDate = QDate::currentDate();
55 mSelectedDateCount = 1; 55 mSelectedDateCount = 1;
56} 56}
57 57
58DateNavigatorContainer::~DateNavigatorContainer() 58DateNavigatorContainer::~DateNavigatorContainer()
59{ 59{
60} 60}
61 61
62void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) 62void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
63{ 63{
64 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), 64 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ),
65 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 65 SIGNAL( datesSelected( const KCal::DateList & ) ) );
66#if 0 66#if 0
67 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), 67 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ),
68 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); 68 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) );
69 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), 69 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ),
70 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); 70 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) );
71#endif 71#endif
72 connect( v, SIGNAL( weekClicked( const QDate & ) ), 72 connect( v, SIGNAL( weekClicked( const QDate & ) ),
73 SIGNAL( weekClicked( const QDate & ) ) ); 73 SIGNAL( weekClicked( const QDate & ) ) );
74 connect( v, SIGNAL( showMonth( const QDate & ) ), 74 connect( v, SIGNAL( showMonth( const QDate & ) ),
75 SIGNAL( showMonth( const QDate & ) ) ); 75 SIGNAL( showMonth( const QDate & ) ) );
76 76
77 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); 77 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
78 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); 78 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
79 79
80 connect( v, SIGNAL( goNextMonth() ), SLOT( slotgoNextMonth() ) ); 80 connect( v, SIGNAL( goNextMonth() ), SLOT( slotgoNextMonth() ) );
81 connect( v, SIGNAL( goPrevMonth() ), SLOT( slotgoPrevMonth() ) ); 81 connect( v, SIGNAL( goPrevMonth() ), SLOT( slotgoPrevMonth() ) );
82 connect( v, SIGNAL( goNextYear() ), SLOT( slotgoNextYear() ) ); 82 connect( v, SIGNAL( goNextYear() ), SLOT( slotgoNextYear() ) );
83 connect( v, SIGNAL( goPrevYear() ), SLOT( slotgoPrevYear() ) ); 83 connect( v, SIGNAL( goPrevYear() ), SLOT( slotgoPrevYear() ) );
84 84
85 connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 85 connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
86} 86}
87void DateNavigatorContainer::slotgoNextYear() 87void DateNavigatorContainer::slotgoNextYear()
88{ 88{
89 jumpMonth( 12 ); 89 jumpMonth( 12 );
90 emit goNextYear(); 90 emit goNextYear();
91 91
92} 92}
93void DateNavigatorContainer::slotgoPrevYear() 93void DateNavigatorContainer::slotgoPrevYear()
94{ 94{
95 jumpMonth( -12 ); 95 jumpMonth( -12 );
96 emit goPrevYear(); 96 emit goPrevYear();
97 97
98} 98}
99void DateNavigatorContainer::slotgoPrevMonth() 99void DateNavigatorContainer::slotgoPrevMonth()
100{ 100{
101 jumpMonth( -1 ); 101 jumpMonth( -1 );
102 emit goPrevMonth(); 102 emit goPrevMonth();
103 103
104} 104}
105void DateNavigatorContainer::slotgoNextMonth() 105void DateNavigatorContainer::slotgoNextMonth()
106{ 106{
107 jumpMonth( 1 ); 107 jumpMonth( 1 );
108 emit goNextMonth(); 108 emit goNextMonth();
109} 109}
110void DateNavigatorContainer::jumpMonth( int month ) 110void DateNavigatorContainer::jumpMonth( int month )
111{ 111{
112 112
113 QDate baseDate = mNavigatorView->baseDate(); 113 QDate baseDate = mNavigatorView->baseDate();
114 computeMonthSelected( baseDate.month() + month, false ); 114 computeMonthSelected( baseDate.month() + month, false );
115} 115}
116void DateNavigatorContainer::slotMonthSelected( int month ) 116void DateNavigatorContainer::slotMonthSelected( int month )
117{ 117{
118 computeMonthSelected( month, true ); 118 computeMonthSelected( month, true );
119} 119}
120void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit ) 120void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit )
121{ 121{
122 //qDebug("slotMonthSelected %d ", month); 122 //qDebug("slotMonthSelected %d ", month);
123 QDate baseDate = mNavigatorView->baseDate(); 123 QDate baseDate = mNavigatorView->baseDate();
124 if ( baseDate.month() == month ) 124 if ( baseDate.month() == month )
125 return; 125 return;
126 //qDebug("month %d %d ",baseDate.month(),month); 126 //qDebug("month %d %d ",baseDate.month(),month);
127 QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); 127 QDate date = QDate ( baseDate.year(), baseDate.month() , 15 );
128 date = date.addDays( -(baseDate.month()-month ) *30 ); 128 date = date.addDays( -(baseDate.month()-month ) *30 );
129 QDate newBase = QDate ( date.year(), date.month() ,1 ); 129 QDate newBase = QDate ( date.year(), date.month() ,1 );
130 130
131 //qDebug("NEW BASE %s", newBase.toString().latin1()); 131 //qDebug("NEW BASE %s", newBase.toString().latin1());
132 mNavigatorView->setBaseDate( newBase ); 132 mNavigatorView->setBaseDate( newBase );
133 QDate last = lastAvailableDate(); 133 QDate last = lastAvailableDate();
134 QDate first = firstAvailableDate(); 134 QDate first = firstAvailableDate();
135 135
136 QDate selFirst = mFirstSelectedDate; 136 QDate selFirst = mFirstSelectedDate;
137 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 137 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
138 if ( selFirst >= first && selLast <= last ) { 138 if ( selFirst >= first && selLast <= last ) {
139 setBaseDates(); 139 setBaseDates();
140 if ( forceEmit ) 140 if ( forceEmit )
141 updateDayMatrixDates(); 141 updateDayMatrixDates();
142 } 142 }
143 else { 143 else {
144 setBaseDates(); 144 setBaseDates();
145 if ( forceEmit ) 145 if ( forceEmit )
146 updateDayMatrixDates(); 146 updateDayMatrixDates();
147 if ( forceEmit ) 147 if ( forceEmit )
148 emit monthSelected( month ); 148 emit monthSelected( month );
149 } 149 }
150} 150}
151void DateNavigatorContainer::setCalendar( Calendar *cal ) 151void DateNavigatorContainer::setCalendar( Calendar *cal )
152{ 152{
153 mCalendar = cal; 153 mCalendar = cal;
154 mNavigatorView->setCalendar( cal ); 154 mNavigatorView->setCalendar( cal );
155 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 155 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
156 KDateNavigator *n = mExtraViews.at( i ); 156 KDateNavigator *n = mExtraViews.at( i );
157 n->setCalendar( cal ); 157 n->setCalendar( cal );
158 } 158 }
159} 159}
160void DateNavigatorContainer::checkUpdateDayMatrixDates() 160void DateNavigatorContainer::checkUpdateDayMatrixDates()
161{ 161{
162 //qDebug("KODNC: wid %d hei %d ", width(), height()); 162 //qDebug("KODNC: wid %d hei %d ", width(), height());
163 mUpdateTimer->stop(); 163 mUpdateTimer->stop();
164 //return; 164 //return;
165 if ( width() < 3 || height() < 3 ) 165 if ( width() < 3 || height() < 3 )
166 return; 166 return;
167 static int lastWid = 0; 167 static int lastWid = 0;
168 static int lastHei = 0; 168 static int lastHei = 0;
169 if ( lastWid == width() && height() == lastHei ) { 169 if ( lastWid == width() && height() == lastHei ) {
170 qDebug("KODNC: No layout computing needed. "); 170 qDebug("KODNC: No layout computing needed. ");
171 } else { 171 } else {
172 lastWid = width(); 172 lastWid = width();
173 lastHei = height(); 173 lastHei = height();
174 174
175 QSize minSize = mNavigatorView->yourSizeHint(); 175 QSize minSize = mNavigatorView->yourSizeHint();
176 176
177 int verticalCount = size().height() / minSize.height(); 177 int verticalCount = size().height() / minSize.height();
178 int horizontalCount = size().width() / minSize.width(); 178 int horizontalCount = size().width() / minSize.width();
179 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); 179 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
180 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); 180 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
181 bool fontchange = false; 181 bool fontchange = false;
182 if ( horizontalCount == 1) 182 if ( horizontalCount == 1)
183 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); 183 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
184 QFont fo; 184 QFont fo;
185 if ( horizontalCount != mHorizontalCount || 185 if ( horizontalCount != mHorizontalCount ||
186 verticalCount != mVerticalCount ) { 186 verticalCount != mVerticalCount ) {
187 uint count = horizontalCount * verticalCount; 187 uint count = horizontalCount * verticalCount;
188 if ( count == 0 ) { 188 if ( count == 0 ) {
189 bool ok; 189 bool ok;
190 fo = mNavigatorView->yourFontHint( size() , &ok ); 190 fo = mNavigatorView->yourFontHint( size() , &ok );
191 //mNavigatorView->resize( size() ); 191 //mNavigatorView->resize( size() );
192 //if ( ! ok ) 192 //if ( ! ok )
193 // return; 193 // return;
194 int butt = 2; 194 int butt = 2;
195 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); 195 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width();
196 if ( horizontalCount <= 1 ) 196 if ( horizontalCount <= 1 )
197 minSize = mNavigatorView->sizeHintTwoButtons( 4 ); 197 minSize = mNavigatorView->sizeHintTwoButtons( 4 );
198 else 198 else
199 minSize = mNavigatorView->sizeHintTwoButtons(); 199 minSize = mNavigatorView->sizeHintTwoButtons();
200 verticalCount = size().height() / minSize.height(); 200 verticalCount = size().height() / minSize.height();
201 horizontalCount = size().width() / minSize.width(); 201 horizontalCount = size().width() / minSize.width();
202 if ( horizontalCount == 0 ) 202 if ( horizontalCount == 0 )
203 horizontalCount = 1; 203 horizontalCount = 1;
204 if ( verticalCount == 0 ) 204 if ( verticalCount == 0 )
205 verticalCount = 1; 205 verticalCount = 1;
206 fontchange = true; 206 fontchange = true;
207 count = horizontalCount * verticalCount; 207 count = horizontalCount * verticalCount;
208 } else { 208 }
209 if ( mNavigatorView->fontChanged() ) { 209
210 fontchange = true;
211 fo = KOPrefs::instance()->mDateNavigatorFont;
212 mNavigatorView->changeFont( fo );
213 mNavigatorView->unsetFontChanged();
214 }
215 }
216
217 mLastDisplayedDN = horizontalCount*verticalCount-1; 210 mLastDisplayedDN = horizontalCount*verticalCount-1;
218 while ( count > ( mExtraViews.count() + 1 ) ) { 211 while ( count > ( mExtraViews.count() + 1 ) ) {
219 KDateNavigator *n = new KDateNavigator( this ); 212 KDateNavigator *n = new KDateNavigator( this );
220 n->setMonthSignalOffset ( mExtraViews.count()+1 ); 213 n->setMonthSignalOffset ( mExtraViews.count()+1 );
221 mExtraViews.append( n ); 214 mExtraViews.append( n );
222 n->setCalendar( mCalendar ); 215 n->setCalendar( mCalendar );
223 connectNavigatorView( n ); 216 connectNavigatorView( n );
224 // n->show(); 217 // n->show();
225 } 218 }
226 219
227
228 setBaseDates(); 220 setBaseDates();
229 if ( fontchange ) {
230 //mNavigatorView->changeFont( fo );
231 uint i;
232 for( i = 0; i < mExtraViews.count(); ++i ) {
233 KDateNavigator *view = mExtraViews.at( i );
234 view->changeFont( fo );
235 }
236 }
237 mHorizontalCount = horizontalCount; 221 mHorizontalCount = horizontalCount;
238 mVerticalCount = verticalCount; 222 mVerticalCount = verticalCount;
239 223
240 } 224 }
241 225 if ( !fontchange ) {
226 if ( mNavigatorView->fontChanged() ) {
227 fontchange = true;
228 fo = KOPrefs::instance()->mDateNavigatorFont;
229 mNavigatorView->changeFont( fo );
230 mNavigatorView->unsetFontChanged();
231 }
232 }
233 if ( fontchange ) {
234 uint i;
235 for( i = 0; i < mLastDisplayedDN; ++i ) {
236 KDateNavigator *view = mExtraViews.at( i );
237 view->changeFont( fo );
238 }
239 }
242 int theight = height() / mVerticalCount; 240 int theight = height() / mVerticalCount;
243 int twidth = width() / mHorizontalCount; 241 int twidth = width() / mHorizontalCount;
244 242
245 NavigatorBar *bar = mNavigatorView->navigatorBar(); 243 NavigatorBar *bar = mNavigatorView->navigatorBar();
246 if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); 244 if ( mHorizontalCount > 1 ) bar->showButtons( true, false );
247 else bar->showButtons( true, true ); 245 else bar->showButtons( true, true );
248 246
249 mNavigatorView->setGeometry(0, 247 mNavigatorView->setGeometry(0,
250 0, twidth, theight ); 248 0, twidth, theight );
251 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 249 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
252 int x = ( i + 1 ) % mHorizontalCount; 250 int x = ( i + 1 ) % mHorizontalCount;
253 int y = ( i + 1 ) / mHorizontalCount; 251 int y = ( i + 1 ) / mHorizontalCount;
254 252
255 KDateNavigator *view = mExtraViews.at( i ); 253 KDateNavigator *view = mExtraViews.at( i );
256 bar = view->navigatorBar(); 254 bar = view->navigatorBar();
257 if ( y > 0 ) bar->showButtons( false, false ); 255 if ( y > 0 ) bar->showButtons( false, false );
258 else { 256 else {
259 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); 257 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true );
260 else bar->showButtons( false, false ); 258 else bar->showButtons( false, false );
261 } 259 }
262 view->setGeometry( x * twidth, 260 view->setGeometry( x * twidth,
263 y * theight, twidth, theight ); 261 y * theight, twidth, theight );
264 } 262 }
265 int iii = 0; 263 int iii = 0;
266 int ccc = mHorizontalCount * mVerticalCount; 264 int ccc = mHorizontalCount * mVerticalCount;
267 mNavigatorView->show(); 265 mNavigatorView->show();
268 while ( iii < ( mExtraViews.count() ) ) { 266 while ( iii < ( mExtraViews.count() ) ) {
269 if ( iii < ccc-1 ) 267 if ( iii < ccc-1 )
270 mExtraViews.at( iii )->show(); 268 mExtraViews.at( iii )->show();
271 else 269 else
272 mExtraViews.at( iii )->hide(); 270 mExtraViews.at( iii )->hide();
273 ++iii; 271 ++iii;
274 } 272 }
275 } 273 }
276 274
277 QDate last = lastAvailableDate(); 275 QDate last = lastAvailableDate();
278 QDate first = firstAvailableDate(); 276 QDate first = firstAvailableDate();
279 277
280 QDate selFirst = mFirstSelectedDate; 278 QDate selFirst = mFirstSelectedDate;
281 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 279 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
282 if ( selFirst >= first && selLast <= last ) { 280 if ( selFirst >= first && selLast <= last ) {
283 updateDayMatrixDates(); 281 updateDayMatrixDates();
284 } 282 }
285 else { 283 else {
286 updateDayMatrixDates(); 284 updateDayMatrixDates();
287 emit monthSelected( mFirstSelectedDate.month() ); 285 emit monthSelected( mFirstSelectedDate.month() );
288 } 286 }
289} 287}
290void DateNavigatorContainer::updateDayMatrixDates() 288void DateNavigatorContainer::updateDayMatrixDates()
291{ 289{
292 QDate fDate = mFirstSelectedDate; 290 QDate fDate = mFirstSelectedDate;
293 QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); 291 QDate lDate = fDate.addDays( mSelectedDateCount - 1 );
294 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); 292 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
295 mNavigatorView->dayMatrix()->repaint( false ); 293 mNavigatorView->dayMatrix()->repaint( false );
296 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 294 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
297 KDateNavigator *n = mExtraViews.at( i ); 295 KDateNavigator *n = mExtraViews.at( i );
298 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { 296 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
299 n->dayMatrix()->repaint( false ); 297 n->dayMatrix()->repaint( false );
300 } 298 }
301 } 299 }
302} 300}
303 301
304void DateNavigatorContainer::updateDayMatrix() 302void DateNavigatorContainer::updateDayMatrix()
305{ 303{
306 mNavigatorView->updateDayMatrix(); 304 mNavigatorView->updateDayMatrix();
307 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 305 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
308 KDateNavigator *n = mExtraViews.at( i ); 306 KDateNavigator *n = mExtraViews.at( i );
309 n->updateDayMatrix(); 307 n->updateDayMatrix();
310 } 308 }
311} 309}
312 310
313void DateNavigatorContainer::updateToday() 311void DateNavigatorContainer::updateToday()
314{ 312{
315 qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); 313 qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
316#if 0 314#if 0
317 mNavigatorView->updateToday(); 315 mNavigatorView->updateToday();
318 KDateNavigator *n; 316 KDateNavigator *n;
319 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 317 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
320 n->updateToday(); 318 n->updateToday();
321 } 319 }
322#endif 320#endif
323} 321}
324 322
325void DateNavigatorContainer::updateView() 323void DateNavigatorContainer::updateView()
326{ 324{
327 mNavigatorView->updateView(); 325 mNavigatorView->updateView();
328 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 326 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
329 KDateNavigator *n = mExtraViews.at( i ); 327 KDateNavigator *n = mExtraViews.at( i );
330 n->updateView(); 328 n->updateView();
331 } 329 }
332} 330}
333 331
334void DateNavigatorContainer::updateConfig() 332void DateNavigatorContainer::updateConfig()
335{ 333{
336 mNavigatorView->updateConfig(); 334 mNavigatorView->updateConfig();
337 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 335 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
338 KDateNavigator *n = mExtraViews.at( i ); 336 KDateNavigator *n = mExtraViews.at( i );
339 n->updateConfig(); 337 n->updateConfig();
340 } 338 }
341} 339}
342QDate DateNavigatorContainer::lastAvailableDate() const 340QDate DateNavigatorContainer::lastAvailableDate() const
343{ 341{
344 QDate date = mNavigatorView->baseDate(); 342 QDate date = mNavigatorView->baseDate();
345 QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); 343 QDate last = QDate ( date.year(), date.month(), date.daysInMonth() );
346 int iii = mLastDisplayedDN; 344 int iii = mLastDisplayedDN;
347 if ( mLastDisplayedDN ) 345 if ( mLastDisplayedDN )
348 last = last.addDays( 1); 346 last = last.addDays( 1);
349 while ( iii ) { 347 while ( iii ) {
350 last = last.addDays( last.daysInMonth ()); 348 last = last.addDays( last.daysInMonth ());
351 //qDebug("DATE %s ", last.toString().latin1() ); 349 //qDebug("DATE %s ", last.toString().latin1() );
352 --iii; 350 --iii;
353 } 351 }
354 if ( mLastDisplayedDN ) 352 if ( mLastDisplayedDN )
355 last = last.addDays( -1); 353 last = last.addDays( -1);
356 return last; 354 return last;
357} 355}
358QDate DateNavigatorContainer::firstAvailableDate() const 356QDate DateNavigatorContainer::firstAvailableDate() const
359{ 357{
360 return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); 358 return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 );
361} 359}
362void DateNavigatorContainer::selectDates( const DateList &dateList ) 360void DateNavigatorContainer::selectDates( const DateList &dateList )
363{ 361{
364 mFirstSelectedDate = dateList.first() ; 362 mFirstSelectedDate = dateList.first() ;
365 mSelectedDateCount = dateList.count() ; 363 mSelectedDateCount = dateList.count() ;
366 if ( !mLastDisplayedDN ) { 364 if ( !mLastDisplayedDN ) {
367 mNavigatorView->selectDates( dateList ); 365 mNavigatorView->selectDates( dateList );
368 return; 366 return;
369 } 367 }
370 QDate fDate = dateList.first(); 368 QDate fDate = dateList.first();
371 QDate lDate = dateList.last(); 369 QDate lDate = dateList.last();
372 //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); 370 //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() );
373 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); 371 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
374 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { 372 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) {
375 updateDayMatrixDates(); 373 updateDayMatrixDates();
376 return; 374 return;
377 } 375 }
378 mNavigatorView->selectDates( dateList ); 376 mNavigatorView->selectDates( dateList );
379 setBaseDates(); 377 setBaseDates();
380 if ( mLastDisplayedDN ) { 378 if ( mLastDisplayedDN ) {
381 KDateNavigator *view = mExtraViews.at( 0 ); 379 KDateNavigator *view = mExtraViews.at( 0 );
382 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 380 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
383 view->dayMatrix()->repaint( false ); 381 view->dayMatrix()->repaint( false );
384 if ( mLastDisplayedDN > 1 ) { 382 if ( mLastDisplayedDN > 1 ) {
385 KDateNavigator *view = mExtraViews.at( 1 ); 383 KDateNavigator *view = mExtraViews.at( 1 );
386 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 384 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
387 view->dayMatrix()->repaint( false ); 385 view->dayMatrix()->repaint( false );
388 } 386 }
389 } 387 }
390} 388}
391 389
392void DateNavigatorContainer::setBaseDates() 390void DateNavigatorContainer::setBaseDates()
393{ 391{
394 QDate baseDate = mNavigatorView->baseDate(); 392 QDate baseDate = mNavigatorView->baseDate();
395 bool doRepaint = true; 393 bool doRepaint = true;
396 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 394 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
397 KDateNavigator *n = mExtraViews.at( i ); 395 KDateNavigator *n = mExtraViews.at( i );
398 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 396 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
399 n->setBaseDate( baseDate, doRepaint ); 397 n->setBaseDate( baseDate, doRepaint );
400 } 398 }
401} 399}
402void DateNavigatorContainer::setResizeEnabled() 400void DateNavigatorContainer::setResizeEnabled()
403{ 401{
404 mResizeEnabled = true; 402 mResizeEnabled = true;
405 //qDebug("DateNavigatorContainer::setResizeEnabled "); 403 //qDebug("DateNavigatorContainer::setResizeEnabled ");
406 checkUpdateDayMatrixDates(); 404 checkUpdateDayMatrixDates();
407} 405}
408void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) 406void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
409{ 407{
410 408
411 //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height()); 409 //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height());
412 //qDebug("COUNT %d ", mExtraViews.count()); 410 //qDebug("COUNT %d ", mExtraViews.count());
413 if ( ! mResizeEnabled ) { 411 if ( ! mResizeEnabled ) {
414 //qDebug("NOT ResizeEnabled"); 412 //qDebug("NOT ResizeEnabled");
415 return; 413 return;
416 } 414 }
417 else 415 else
418 mUpdateTimer->start( 250 ); 416 mUpdateTimer->start( 250 );
419 417
420 //updateDayMatrixDates(); 418 //updateDayMatrixDates();
421} 419}
422 420
423QSize DateNavigatorContainer::minimumSizeHint() const 421QSize DateNavigatorContainer::minimumSizeHint() const
424{ 422{
425 return mNavigatorView->minimumSizeHint(); 423 return mNavigatorView->minimumSizeHint();
426} 424}
427 425
428QSize DateNavigatorContainer::sizeHint() const 426QSize DateNavigatorContainer::sizeHint() const
429{ 427{
430 return mNavigatorView->yourSizeHint(); 428 return mNavigatorView->yourSizeHint();
431} 429}
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 2fca49e..1d09f40 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -1,256 +1,255 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qkeycode.h> 25#include <qkeycode.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qframe.h> 28#include <qframe.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qapplication.h> 30#include <qapplication.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kglobal.h> 34#include <kglobal.h>
35 35
36#include "koglobals.h" 36#include "koglobals.h"
37#include "koprefs.h" 37#include "koprefs.h"
38#ifndef KORG_NOPLUGINS 38#ifndef KORG_NOPLUGINS
39#include "kocore.h" 39#include "kocore.h"
40#endif 40#endif
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#include "navigatorbar.h" 44#include "navigatorbar.h"
45 45
46#include "kdatenavigator.h" 46#include "kdatenavigator.h"
47 47
48KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) 48KDateNavigator::KDateNavigator( QWidget *parent, const char *name )
49 : QFrame(parent, name), 49 : QFrame(parent, name),
50 updateTimer(0L) 50 updateTimer(0L)
51{ 51{
52 setFrameStyle(QFrame::NoFrame); 52 setFrameStyle(QFrame::NoFrame);
53 QDate startDate = QDate::currentDate(); 53 QDate startDate = QDate::currentDate();
54 QGridLayout *topLayout = new QGridLayout(this,8,8); 54 QGridLayout *topLayout = new QGridLayout(this,8,8);
55 55
56 if (! startDate.isValid()) { 56 if (! startDate.isValid()) {
57 qDebug("KDateNavigator::invalid startdate "); 57 qDebug("KDateNavigator::invalid startdate ");
58 startDate = QDate::currentDate(); 58 startDate = QDate::currentDate();
59 } 59 }
60 mMonthSignalOffset = 0; 60 mMonthSignalOffset = 0;
61 mSelectedDates.append(startDate); 61 mSelectedDates.append(startDate);
62 m_MthYr = startDate; 62 m_MthYr = startDate;
63 m_bShowWeekNums = true; 63 m_bShowWeekNums = true;
64
65 setFont( KOPrefs::instance()->mDateNavigatorFont ); 64 setFont( KOPrefs::instance()->mDateNavigatorFont );
66 mNavigatorBar = new NavigatorBar( startDate, this ); 65 mNavigatorBar = new NavigatorBar( startDate, this );
67 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); 66 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 );
68 //mNavigatorBar->resize( 1,1); 67 //mNavigatorBar->resize( 1,1);
69 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 68 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
70 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 69 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
71 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 70 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
72 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 71 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
73 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 72 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
74 73
75 // get the day of the week on the first day 74 // get the day of the week on the first day
76 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 75 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
77 m_fstDayOfWk = dayone.dayOfWeek(); 76 m_fstDayOfWk = dayone.dayOfWeek();
78 77
79 int i; 78 int i;
80 79
81 // Set up the heading fields. 80 // Set up the heading fields.
82 for( i = 0; i < 7; i++ ) { 81 for( i = 0; i < 7; i++ ) {
83 headings[i] = new QLabel("",this); 82 headings[i] = new QLabel("",this);
84 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); 83 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
85 headings[i]->setAlignment(AlignCenter); 84 headings[i]->setAlignment(AlignCenter);
86 headings[i]->installEventFilter(this); 85 headings[i]->installEventFilter(this);
87 86
88 topLayout->addWidget(headings[i],1,i+1); 87 topLayout->addWidget(headings[i],1,i+1);
89 } 88 }
90 89
91 // Create the weeknumber labels 90 // Create the weeknumber labels
92 for( i = 0; i < 6; i++ ) { 91 for( i = 0; i < 6; i++ ) {
93 weeknos[i] = new QLabel(this); 92 weeknos[i] = new QLabel(this);
94 weeknos[i]->setAlignment(AlignCenter); 93 weeknos[i]->setAlignment(AlignCenter);
95 //weeknos[i]->setFont(QFont("Arial", 10)); 94 //weeknos[i]->setFont(QFont("Arial", 10));
96 if(!m_bShowWeekNums) { 95 if(!m_bShowWeekNums) {
97 weeknos[i]->hide(); 96 weeknos[i]->hide();
98 } 97 }
99 weeknos[i]->installEventFilter(this); 98 weeknos[i]->installEventFilter(this);
100 99
101 topLayout->addWidget(weeknos[i],i+2,0); 100 topLayout->addWidget(weeknos[i],i+2,0);
102 } 101 }
103 102
104 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); 103 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix");
105 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); 104 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
106 daymatrix->setLineWidth(1); 105 daymatrix->setLineWidth(1);
107 106
108 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), 107 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
109 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 108 SIGNAL( datesSelected( const KCal::DateList & ) ) );
110 109
111 connect( daymatrix, SIGNAL( eventDropped( Event * ) ), 110 connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
112 SIGNAL( eventDropped( Event * ) ) ); 111 SIGNAL( eventDropped( Event * ) ) );
113 112
114 topLayout->addMultiCellWidget(daymatrix,2,7,1,7); 113 topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
115 114
116 // read settings from configuration file. 115 // read settings from configuration file.
117 updateConfig(); 116 updateConfig();
118 enableRollover(FollowMonth); 117 enableRollover(FollowMonth);
119 mySizeHint = sizeHintTwoButtons(); 118 mySizeHint = sizeHintTwoButtons();
120 myFullSizeHint = sizeHintTwoButtons( 4 ); 119 myFullSizeHint = sizeHintTwoButtons( 4 );
121 mFontChanged = false; 120 mFontChanged = false;
122 //resize ( 3,3 ); 121 //resize ( 3,3 );
123 122
124} 123}
125void KDateNavigator::changeFont ( QFont fo ) 124void KDateNavigator::changeFont ( QFont fo )
126{ 125{
127 setFont( fo ); 126 setFont( fo );
128 mNavigatorBar->resetFont( fo ); 127 mNavigatorBar->resetFont( fo );
129} 128}
130QFont KDateNavigator::yourFontHint( QSize si , bool *b) 129QFont KDateNavigator::yourFontHint( QSize si , bool *b)
131{ 130{
132 QFont fo = KOPrefs::instance()->mDateNavigatorFont; 131 QFont fo = KOPrefs::instance()->mDateNavigatorFont;
133 *b = false; 132 *b = false;
134 int fontPoint = fo.pointSize(); 133 int fontPoint = fo.pointSize();
135 while ( fontPoint > 5 ) { 134 while ( fontPoint > 5 ) {
136 --fontPoint; 135 --fontPoint;
137 fo.setPointSize( fontPoint ); 136 fo.setPointSize( fontPoint );
138 setFont( fo ); 137 setFont( fo );
139 mFontChanged = true; 138 mFontChanged = true;
140 mNavigatorBar->resetFont( fo ); 139 mNavigatorBar->resetFont( fo );
141 QSize sh = sizeHintTwoButtons( 2 ); 140 QSize sh = sizeHintTwoButtons( 2 );
142 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); 141 //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()) { 142 if ( si.width() > sh.width() && si.height() > sh.height()) {
144 if ( si.width() / sh.width() == 1 ) { 143 if ( si.width() / sh.width() == 1 ) {
145 if ( si.width() < sizeHintTwoButtons( 4 ).width()) 144 if ( si.width() < sizeHintTwoButtons( 4 ).width())
146 continue; 145 continue;
147 } 146 }
148 *b = true; 147 *b = true;
149 //qDebug("fooooooooooooooooooooooouuuuund "); 148 //qDebug("fooooooooooooooooooooooouuuuund ");
150 break; 149 break;
151 } 150 }
152 } 151 }
153 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); 152 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() );
154 return fo; 153 return fo;
155} 154}
156QSize KDateNavigator::sizeHint() const 155QSize KDateNavigator::sizeHint() const
157{ 156{
158 QFontMetrics fm ( font() ); 157 QFontMetrics fm ( font() );
159 QSize day = daymatrix->sizeHint(); 158 QSize day = daymatrix->sizeHint();
160 QSize nav = mNavigatorBar->sizeHint(); 159 QSize nav = mNavigatorBar->sizeHint();
161 int wid = fm.width( "30") + day.width()+3; 160 int wid = fm.width( "30") + day.width()+3;
162 int hei = fm.height() +day.height()+nav.height()+2; 161 int hei = fm.height() +day.height()+nav.height()+2;
163 if ( wid < nav.width() ) 162 if ( wid < nav.width() )
164 wid = nav.width() ; 163 wid = nav.width() ;
165 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); 164 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
166 return QSize ( wid, hei ); 165 return QSize ( wid, hei );
167} 166}
168QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const 167QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const
169{ 168{
170 QFontMetrics fm ( font() ); 169 QFontMetrics fm ( font() );
171 QSize day = daymatrix->sizeHint(); 170 QSize day = daymatrix->sizeHint();
172 QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); 171 QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum );
173 int wid = fm.width( "30") + day.width()+3; 172 int wid = fm.width( "30") + day.width()+3;
174 int hei = fm.height() +day.height()+nav.height()+2; 173 int hei = fm.height() +day.height()+nav.height()+2;
175 if ( wid < nav.width() ) 174 if ( wid < nav.width() )
176 wid = nav.width() ; 175 wid = nav.width() ;
177 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); 176 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
178 return QSize ( wid, hei ); 177 return QSize ( wid, hei );
179} 178}
180void KDateNavigator::slotMonthSelected( int m ) 179void KDateNavigator::slotMonthSelected( int m )
181{ 180{
182 if ( m_MthYr.month() <= mMonthSignalOffset) 181 if ( m_MthYr.month() <= mMonthSignalOffset)
183 m += 12; 182 m += 12;
184 //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); 183 //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset);
185 emit monthSelected( m - mMonthSignalOffset ); 184 emit monthSelected( m - mMonthSignalOffset );
186 185
187} 186}
188void KDateNavigator::setCalendar( Calendar *cal ) 187void KDateNavigator::setCalendar( Calendar *cal )
189{ 188{
190 daymatrix->setCalendar( cal ); 189 daymatrix->setCalendar( cal );
191} 190}
192 191
193void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true 192void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true
194{ 193{
195 m_MthYr = date; 194 m_MthYr = date;
196 //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); 195 //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1());
197 196
198 updateDates(); 197 updateDates();
199 updateView(); 198 updateView();
200 199
201 KCal::DateList dates; 200 KCal::DateList dates;
202 dates.append( date ); 201 dates.append( date );
203 mNavigatorBar->selectDates( dates ); 202 mNavigatorBar->selectDates( dates );
204 203
205 daymatrix->clearSelection(); 204 daymatrix->clearSelection();
206 if ( doRepaint ) 205 if ( doRepaint )
207 daymatrix->repaint( false ); 206 daymatrix->repaint( false );
208} 207}
209 208
210void KDateNavigator::enableRollover(RolloverType r) 209void KDateNavigator::enableRollover(RolloverType r)
211{ 210{
212 switch(r) 211 switch(r)
213 { 212 {
214 case None : 213 case None :
215 if (updateTimer) 214 if (updateTimer)
216 { 215 {
217 updateTimer->stop(); 216 updateTimer->stop();
218 delete updateTimer; 217 delete updateTimer;
219 updateTimer=0L; 218 updateTimer=0L;
220 } 219 }
221 break; 220 break;
222 case FollowDay : 221 case FollowDay :
223 case FollowMonth : 222 case FollowMonth :
224 if (!updateTimer) 223 if (!updateTimer)
225 { 224 {
226 updateTimer = new QTimer(this); 225 updateTimer = new QTimer(this);
227 QObject::connect(updateTimer,SIGNAL(timeout()), 226 QObject::connect(updateTimer,SIGNAL(timeout()),
228 this,SLOT(possiblyPastMidnight())); 227 this,SLOT(possiblyPastMidnight()));
229 } 228 }
230 updateTimer->start(0,true); 229 updateTimer->start(0,true);
231 lastDayChecked = QDate::currentDate(); 230 lastDayChecked = QDate::currentDate();
232 } 231 }
233 updateRollover=r; 232 updateRollover=r;
234} 233}
235 234
236 235
237KDateNavigator::~KDateNavigator() 236KDateNavigator::~KDateNavigator()
238{ 237{
239} 238}
240 239
241 240
242void KDateNavigator::passedMidnight() 241void KDateNavigator::passedMidnight()
243{ 242{
244 QDate today = QDate::currentDate(); 243 QDate today = QDate::currentDate();
245 bool emitMonth = false; 244 bool emitMonth = false;
246 245
247 if (today.month() != lastDayChecked.month()) 246 if (today.month() != lastDayChecked.month())
248 { 247 {
249 if (updateRollover==FollowMonth && 248 if (updateRollover==FollowMonth &&
250 daymatrix->isEndOfMonth()) { 249 daymatrix->isEndOfMonth()) {
251 goNextMonth(); 250 goNextMonth();
252 emitMonth=true; 251 emitMonth=true;
253 } 252 }
254 } 253 }
255 daymatrix->recalculateToday(); 254 daymatrix->recalculateToday();
256 daymatrix->repaint( false ); 255 daymatrix->repaint( false );