summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-30 13:46:29 (UTC)
committer zautrix <zautrix>2005-03-30 13:46:29 (UTC)
commit8c160d7aeeab1d22382ced11440712f6541a6db7 (patch) (unidiff)
tree83fd0df6d30db6bbb05d82dc400d6f51823f5b3a /korganizer
parent056f171723a9301aea5a65340dffeda34e078abf (diff)
downloadkdepimpi-8c160d7aeeab1d22382ced11440712f6541a6db7.zip
kdepimpi-8c160d7aeeab1d22382ced11440712f6541a6db7.tar.gz
kdepimpi-8c160d7aeeab1d22382ced11440712f6541a6db7.tar.bz2
fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index f6f62a4..92abae6 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -1,429 +1,439 @@
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 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 } 208 } else {
209 209 if ( mNavigatorView->fontChanged() ) {
210 fontchange = true;
211 fo = KOPrefs::instance()->mDateNavigatorFont;
212 mNavigatorView->changeFont( fo );
213 mNavigatorView->unsetFontChanged();
214 }
215 }
210 mLastDisplayedDN = horizontalCount*verticalCount-1; 216 mLastDisplayedDN = horizontalCount*verticalCount-1;
211 while ( count > ( mExtraViews.count() + 1 ) ) { 217 while ( count > ( mExtraViews.count() + 1 ) ) {
212 KDateNavigator *n = new KDateNavigator( this ); 218 KDateNavigator *n = new KDateNavigator( this );
213 n->setMonthSignalOffset ( mExtraViews.count()+1 ); 219 n->setMonthSignalOffset ( mExtraViews.count()+1 );
214 mExtraViews.append( n ); 220 mExtraViews.append( n );
215 n->setCalendar( mCalendar ); 221 n->setCalendar( mCalendar );
216 connectNavigatorView( n ); 222 connectNavigatorView( n );
217 // n->show(); 223 // n->show();
218 } 224 }
219 225
220 setBaseDates(); 226 setBaseDates();
227 if ( fontchange ) {
228 //mNavigatorView->changeFont( fo );
229 uint i;
230 for( i = 0; i < mExtraViews.count(); ++i ) {
231 KDateNavigator *view = mExtraViews.at( i );
232 view->changeFont( fo );
233 }
234 }
221 mHorizontalCount = horizontalCount; 235 mHorizontalCount = horizontalCount;
222 mVerticalCount = verticalCount; 236 mVerticalCount = verticalCount;
223 237
224 } 238 }
225 if ( !fontchange ) { 239 if ( mNavigatorView->fontChanged() && ! fontchange ) {
226 if ( mNavigatorView->fontChanged() ) { 240 qDebug("KDNC: Resetting all fonts ");
227 fontchange = true; 241 fo = KOPrefs::instance()->mDateNavigatorFont;
228 fo = KOPrefs::instance()->mDateNavigatorFont; 242 mNavigatorView->changeFont( fo );
229 mNavigatorView->changeFont( fo ); 243 mNavigatorView->unsetFontChanged();
230 mNavigatorView->unsetFontChanged();
231 }
232 }
233 if ( fontchange ) {
234 uint i; 244 uint i;
235 for( i = 0; i < mLastDisplayedDN; ++i ) { 245 for( i = 0; i < mExtraViews.count(); ++i ) {
236 KDateNavigator *view = mExtraViews.at( i ); 246 KDateNavigator *view = mExtraViews.at( i );
237 view->changeFont( fo ); 247 view->changeFont( fo );
238 } 248 }
239 } 249 }
240 int theight = height() / mVerticalCount; 250 int theight = height() / mVerticalCount;
241 int twidth = width() / mHorizontalCount; 251 int twidth = width() / mHorizontalCount;
242 252
243 NavigatorBar *bar = mNavigatorView->navigatorBar(); 253 NavigatorBar *bar = mNavigatorView->navigatorBar();
244 if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); 254 if ( mHorizontalCount > 1 ) bar->showButtons( true, false );
245 else bar->showButtons( true, true ); 255 else bar->showButtons( true, true );
246 256
247 mNavigatorView->setGeometry(0, 257 mNavigatorView->setGeometry(0,
248 0, twidth, theight ); 258 0, twidth, theight );
249 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 259 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
250 int x = ( i + 1 ) % mHorizontalCount; 260 int x = ( i + 1 ) % mHorizontalCount;
251 int y = ( i + 1 ) / mHorizontalCount; 261 int y = ( i + 1 ) / mHorizontalCount;
252 262
253 KDateNavigator *view = mExtraViews.at( i ); 263 KDateNavigator *view = mExtraViews.at( i );
254 bar = view->navigatorBar(); 264 bar = view->navigatorBar();
255 if ( y > 0 ) bar->showButtons( false, false ); 265 if ( y > 0 ) bar->showButtons( false, false );
256 else { 266 else {
257 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); 267 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true );
258 else bar->showButtons( false, false ); 268 else bar->showButtons( false, false );
259 } 269 }
260 view->setGeometry( x * twidth, 270 view->setGeometry( x * twidth,
261 y * theight, twidth, theight ); 271 y * theight, twidth, theight );
262 } 272 }
263 int iii = 0; 273 int iii = 0;
264 int ccc = mHorizontalCount * mVerticalCount; 274 int ccc = mHorizontalCount * mVerticalCount;
265 mNavigatorView->show(); 275 mNavigatorView->show();
266 while ( iii < ( mExtraViews.count() ) ) { 276 while ( iii < ( mExtraViews.count() ) ) {
267 if ( iii < ccc-1 ) 277 if ( iii < ccc-1 )
268 mExtraViews.at( iii )->show(); 278 mExtraViews.at( iii )->show();
269 else 279 else
270 mExtraViews.at( iii )->hide(); 280 mExtraViews.at( iii )->hide();
271 ++iii; 281 ++iii;
272 } 282 }
273 } 283 }
274 284
275 QDate last = lastAvailableDate(); 285 QDate last = lastAvailableDate();
276 QDate first = firstAvailableDate(); 286 QDate first = firstAvailableDate();
277 287
278 QDate selFirst = mFirstSelectedDate; 288 QDate selFirst = mFirstSelectedDate;
279 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 289 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
280 if ( selFirst >= first && selLast <= last ) { 290 if ( selFirst >= first && selLast <= last ) {
281 updateDayMatrixDates(); 291 updateDayMatrixDates();
282 } 292 }
283 else { 293 else {
284 updateDayMatrixDates(); 294 updateDayMatrixDates();
285 emit monthSelected( mFirstSelectedDate.month() ); 295 emit monthSelected( mFirstSelectedDate.month() );
286 } 296 }
287} 297}
288void DateNavigatorContainer::updateDayMatrixDates() 298void DateNavigatorContainer::updateDayMatrixDates()
289{ 299{
290 QDate fDate = mFirstSelectedDate; 300 QDate fDate = mFirstSelectedDate;
291 QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); 301 QDate lDate = fDate.addDays( mSelectedDateCount - 1 );
292 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); 302 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
293 mNavigatorView->dayMatrix()->repaint( false ); 303 mNavigatorView->dayMatrix()->repaint( false );
294 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 304 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
295 KDateNavigator *n = mExtraViews.at( i ); 305 KDateNavigator *n = mExtraViews.at( i );
296 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { 306 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
297 n->dayMatrix()->repaint( false ); 307 n->dayMatrix()->repaint( false );
298 } 308 }
299 } 309 }
300} 310}
301 311
302void DateNavigatorContainer::updateDayMatrix() 312void DateNavigatorContainer::updateDayMatrix()
303{ 313{
304 mNavigatorView->updateDayMatrix(); 314 mNavigatorView->updateDayMatrix();
305 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 315 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
306 KDateNavigator *n = mExtraViews.at( i ); 316 KDateNavigator *n = mExtraViews.at( i );
307 n->updateDayMatrix(); 317 n->updateDayMatrix();
308 } 318 }
309} 319}
310 320
311void DateNavigatorContainer::updateToday() 321void DateNavigatorContainer::updateToday()
312{ 322{
313 qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); 323 qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
314#if 0 324#if 0
315 mNavigatorView->updateToday(); 325 mNavigatorView->updateToday();
316 KDateNavigator *n; 326 KDateNavigator *n;
317 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 327 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
318 n->updateToday(); 328 n->updateToday();
319 } 329 }
320#endif 330#endif
321} 331}
322 332
323void DateNavigatorContainer::updateView() 333void DateNavigatorContainer::updateView()
324{ 334{
325 mNavigatorView->updateView(); 335 mNavigatorView->updateView();
326 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 336 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
327 KDateNavigator *n = mExtraViews.at( i ); 337 KDateNavigator *n = mExtraViews.at( i );
328 n->updateView(); 338 n->updateView();
329 } 339 }
330} 340}
331 341
332void DateNavigatorContainer::updateConfig() 342void DateNavigatorContainer::updateConfig()
333{ 343{
334 mNavigatorView->updateConfig(); 344 mNavigatorView->updateConfig();
335 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 345 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
336 KDateNavigator *n = mExtraViews.at( i ); 346 KDateNavigator *n = mExtraViews.at( i );
337 n->updateConfig(); 347 n->updateConfig();
338 } 348 }
339} 349}
340QDate DateNavigatorContainer::lastAvailableDate() const 350QDate DateNavigatorContainer::lastAvailableDate() const
341{ 351{
342 QDate date = mNavigatorView->baseDate(); 352 QDate date = mNavigatorView->baseDate();
343 QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); 353 QDate last = QDate ( date.year(), date.month(), date.daysInMonth() );
344 int iii = mLastDisplayedDN; 354 int iii = mLastDisplayedDN;
345 if ( mLastDisplayedDN ) 355 if ( mLastDisplayedDN )
346 last = last.addDays( 1); 356 last = last.addDays( 1);
347 while ( iii ) { 357 while ( iii ) {
348 last = last.addDays( last.daysInMonth ()); 358 last = last.addDays( last.daysInMonth ());
349 //qDebug("DATE %s ", last.toString().latin1() ); 359 //qDebug("DATE %s ", last.toString().latin1() );
350 --iii; 360 --iii;
351 } 361 }
352 if ( mLastDisplayedDN ) 362 if ( mLastDisplayedDN )
353 last = last.addDays( -1); 363 last = last.addDays( -1);
354 return last; 364 return last;
355} 365}
356QDate DateNavigatorContainer::firstAvailableDate() const 366QDate DateNavigatorContainer::firstAvailableDate() const
357{ 367{
358 return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); 368 return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 );
359} 369}
360void DateNavigatorContainer::selectDates( const DateList &dateList ) 370void DateNavigatorContainer::selectDates( const DateList &dateList )
361{ 371{
362 mFirstSelectedDate = dateList.first() ; 372 mFirstSelectedDate = dateList.first() ;
363 mSelectedDateCount = dateList.count() ; 373 mSelectedDateCount = dateList.count() ;
364 if ( !mLastDisplayedDN ) { 374 if ( !mLastDisplayedDN ) {
365 mNavigatorView->selectDates( dateList ); 375 mNavigatorView->selectDates( dateList );
366 return; 376 return;
367 } 377 }
368 QDate fDate = dateList.first(); 378 QDate fDate = dateList.first();
369 QDate lDate = dateList.last(); 379 QDate lDate = dateList.last();
370 //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); 380 //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() );
371 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); 381 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
372 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { 382 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) {
373 updateDayMatrixDates(); 383 updateDayMatrixDates();
374 return; 384 return;
375 } 385 }
376 mNavigatorView->selectDates( dateList ); 386 mNavigatorView->selectDates( dateList );
377 setBaseDates(); 387 setBaseDates();
378 if ( mLastDisplayedDN ) { 388 if ( mLastDisplayedDN ) {
379 KDateNavigator *view = mExtraViews.at( 0 ); 389 KDateNavigator *view = mExtraViews.at( 0 );
380 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 390 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
381 view->dayMatrix()->repaint( false ); 391 view->dayMatrix()->repaint( false );
382 if ( mLastDisplayedDN > 1 ) { 392 if ( mLastDisplayedDN > 1 ) {
383 KDateNavigator *view = mExtraViews.at( 1 ); 393 KDateNavigator *view = mExtraViews.at( 1 );
384 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 394 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
385 view->dayMatrix()->repaint( false ); 395 view->dayMatrix()->repaint( false );
386 } 396 }
387 } 397 }
388} 398}
389 399
390void DateNavigatorContainer::setBaseDates() 400void DateNavigatorContainer::setBaseDates()
391{ 401{
392 QDate baseDate = mNavigatorView->baseDate(); 402 QDate baseDate = mNavigatorView->baseDate();
393 bool doRepaint = true; 403 bool doRepaint = true;
394 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 404 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
395 KDateNavigator *n = mExtraViews.at( i ); 405 KDateNavigator *n = mExtraViews.at( i );
396 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 406 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
397 n->setBaseDate( baseDate, doRepaint ); 407 n->setBaseDate( baseDate, doRepaint );
398 } 408 }
399} 409}
400void DateNavigatorContainer::setResizeEnabled() 410void DateNavigatorContainer::setResizeEnabled()
401{ 411{
402 mResizeEnabled = true; 412 mResizeEnabled = true;
403 //qDebug("DateNavigatorContainer::setResizeEnabled "); 413 //qDebug("DateNavigatorContainer::setResizeEnabled ");
404 checkUpdateDayMatrixDates(); 414 checkUpdateDayMatrixDates();
405} 415}
406void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) 416void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
407{ 417{
408 418
409 //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height()); 419 //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height());
410 //qDebug("COUNT %d ", mExtraViews.count()); 420 //qDebug("COUNT %d ", mExtraViews.count());
411 if ( ! mResizeEnabled ) { 421 if ( ! mResizeEnabled ) {
412 //qDebug("NOT ResizeEnabled"); 422 //qDebug("NOT ResizeEnabled");
413 return; 423 return;
414 } 424 }
415 else 425 else
416 mUpdateTimer->start( 250 ); 426 mUpdateTimer->start( 250 );
417 427
418 //updateDayMatrixDates(); 428 //updateDayMatrixDates();
419} 429}
420 430
421QSize DateNavigatorContainer::minimumSizeHint() const 431QSize DateNavigatorContainer::minimumSizeHint() const
422{ 432{
423 return mNavigatorView->minimumSizeHint(); 433 return mNavigatorView->minimumSizeHint();
424} 434}
425 435
426QSize DateNavigatorContainer::sizeHint() const 436QSize DateNavigatorContainer::sizeHint() const
427{ 437{
428 return mNavigatorView->yourSizeHint(); 438 return mNavigatorView->yourSizeHint();
429} 439}