-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index edeebdf..27ba9e0 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -1,385 +1,385 @@ | |||
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 | ||
38 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, | 38 | DateNavigatorContainer::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 | ||
58 | DateNavigatorContainer::~DateNavigatorContainer() | 58 | DateNavigatorContainer::~DateNavigatorContainer() |
59 | { | 59 | { |
60 | } | 60 | } |
61 | 61 | ||
62 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) | 62 | void 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 | } |
87 | void DateNavigatorContainer::slotgoNextYear() | 87 | void DateNavigatorContainer::slotgoNextYear() |
88 | { | 88 | { |
89 | jumpMonth( 12 ); | 89 | jumpMonth( 12 ); |
90 | emit goNextYear(); | 90 | emit goNextYear(); |
91 | 91 | ||
92 | } | 92 | } |
93 | void DateNavigatorContainer::slotgoPrevYear() | 93 | void DateNavigatorContainer::slotgoPrevYear() |
94 | { | 94 | { |
95 | jumpMonth( -12 ); | 95 | jumpMonth( -12 ); |
96 | emit goPrevYear(); | 96 | emit goPrevYear(); |
97 | 97 | ||
98 | } | 98 | } |
99 | void DateNavigatorContainer::slotgoPrevMonth() | 99 | void DateNavigatorContainer::slotgoPrevMonth() |
100 | { | 100 | { |
101 | jumpMonth( -1 ); | 101 | jumpMonth( -1 ); |
102 | emit goPrevMonth(); | 102 | emit goPrevMonth(); |
103 | 103 | ||
104 | } | 104 | } |
105 | void DateNavigatorContainer::slotgoNextMonth() | 105 | void DateNavigatorContainer::slotgoNextMonth() |
106 | { | 106 | { |
107 | jumpMonth( 1 ); | 107 | jumpMonth( 1 ); |
108 | emit goNextMonth(); | 108 | emit goNextMonth(); |
109 | } | 109 | } |
110 | void DateNavigatorContainer::jumpMonth( int month ) | 110 | void 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 | } |
116 | void DateNavigatorContainer::slotMonthSelected( int month ) | 116 | void DateNavigatorContainer::slotMonthSelected( int month ) |
117 | { | 117 | { |
118 | computeMonthSelected( month, true ); | 118 | computeMonthSelected( month, true ); |
119 | } | 119 | } |
120 | void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit ) | 120 | void 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() , baseDate.day() ); | 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 | } |
151 | void DateNavigatorContainer::setCalendar( Calendar *cal ) | 151 | void 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 | } |
160 | void DateNavigatorContainer::checkUpdateDayMatrixDates() | 160 | void 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 | } else { |
209 | if ( mNavigatorView->fontChanged() ) { | 209 | if ( mNavigatorView->fontChanged() ) { |
210 | fontchange = true; | 210 | fontchange = true; |
211 | fo = KOPrefs::instance()->mDateNavigatorFont; | 211 | fo = KOPrefs::instance()->mDateNavigatorFont; |
212 | mNavigatorView->changeFont( fo ); | 212 | mNavigatorView->changeFont( fo ); |
213 | mNavigatorView->unsetFontChanged(); | 213 | mNavigatorView->unsetFontChanged(); |
214 | } | 214 | } |
215 | } | 215 | } |
216 | 216 | ||
217 | mLastDisplayedDN = horizontalCount*verticalCount-1; | 217 | mLastDisplayedDN = horizontalCount*verticalCount-1; |
218 | while ( count > ( mExtraViews.count() + 1 ) ) { | 218 | while ( count > ( mExtraViews.count() + 1 ) ) { |
219 | KDateNavigator *n = new KDateNavigator( this ); | 219 | KDateNavigator *n = new KDateNavigator( this ); |
220 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | 220 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); |
221 | mExtraViews.append( n ); | 221 | mExtraViews.append( n ); |
222 | n->setCalendar( mCalendar ); | 222 | n->setCalendar( mCalendar ); |
223 | connectNavigatorView( n ); | 223 | connectNavigatorView( n ); |
224 | // n->show(); | 224 | // n->show(); |
225 | } | 225 | } |
226 | 226 | ||
227 | 227 | ||
228 | setBaseDates(); | 228 | setBaseDates(); |
229 | if ( fontchange ) { | 229 | if ( fontchange ) { |
230 | //mNavigatorView->changeFont( fo ); | 230 | //mNavigatorView->changeFont( fo ); |
231 | uint i; | 231 | uint i; |
232 | for( i = 0; i < mExtraViews.count(); ++i ) { | 232 | for( i = 0; i < mExtraViews.count(); ++i ) { |
233 | KDateNavigator *view = mExtraViews.at( i ); | 233 | KDateNavigator *view = mExtraViews.at( i ); |
234 | view->changeFont( fo ); | 234 | view->changeFont( fo ); |
235 | } | 235 | } |
236 | } | 236 | } |
237 | mHorizontalCount = horizontalCount; | 237 | mHorizontalCount = horizontalCount; |
238 | mVerticalCount = verticalCount; | 238 | mVerticalCount = verticalCount; |
239 | 239 | ||
240 | } | 240 | } |
241 | 241 | ||
242 | int theight = height() / mVerticalCount; | 242 | int theight = height() / mVerticalCount; |
243 | int twidth = width() / mHorizontalCount; | 243 | int twidth = width() / mHorizontalCount; |
244 | 244 | ||
245 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | 245 | NavigatorBar *bar = mNavigatorView->navigatorBar(); |
246 | if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); | 246 | if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); |
247 | else bar->showButtons( true, true ); | 247 | else bar->showButtons( true, true ); |
248 | 248 | ||
249 | mNavigatorView->setGeometry(0, | 249 | mNavigatorView->setGeometry(0, |
250 | 0, twidth, theight ); | 250 | 0, twidth, theight ); |
251 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 251 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
252 | int x = ( i + 1 ) % mHorizontalCount; | 252 | int x = ( i + 1 ) % mHorizontalCount; |
253 | int y = ( i + 1 ) / mHorizontalCount; | 253 | int y = ( i + 1 ) / mHorizontalCount; |
254 | 254 | ||
255 | KDateNavigator *view = mExtraViews.at( i ); | 255 | KDateNavigator *view = mExtraViews.at( i ); |
256 | bar = view->navigatorBar(); | 256 | bar = view->navigatorBar(); |
257 | if ( y > 0 ) bar->showButtons( false, false ); | 257 | if ( y > 0 ) bar->showButtons( false, false ); |
258 | else { | 258 | else { |
259 | if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); | 259 | if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); |
260 | else bar->showButtons( false, false ); | 260 | else bar->showButtons( false, false ); |
261 | } | 261 | } |
262 | view->setGeometry( x * twidth, | 262 | view->setGeometry( x * twidth, |
263 | y * theight, twidth, theight ); | 263 | y * theight, twidth, theight ); |
264 | } | 264 | } |
265 | int iii = 0; | 265 | int iii = 0; |
266 | int ccc = mHorizontalCount * mVerticalCount; | 266 | int ccc = mHorizontalCount * mVerticalCount; |
267 | mNavigatorView->show(); | 267 | mNavigatorView->show(); |
268 | while ( iii < ( mExtraViews.count() ) ) { | 268 | while ( iii < ( mExtraViews.count() ) ) { |
269 | if ( iii < ccc-1 ) | 269 | if ( iii < ccc-1 ) |
270 | mExtraViews.at( iii )->show(); | 270 | mExtraViews.at( iii )->show(); |
271 | else | 271 | else |
272 | mExtraViews.at( iii )->hide(); | 272 | mExtraViews.at( iii )->hide(); |
273 | ++iii; | 273 | ++iii; |
274 | } | 274 | } |
275 | } | 275 | } |
276 | 276 | ||
277 | QDate last = lastAvailableDate(); | 277 | QDate last = lastAvailableDate(); |
278 | QDate first = firstAvailableDate(); | 278 | QDate first = firstAvailableDate(); |
279 | 279 | ||
280 | QDate selFirst = mFirstSelectedDate; | 280 | QDate selFirst = mFirstSelectedDate; |
281 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); | 281 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); |
282 | if ( selFirst >= first && selLast <= last ) { | 282 | if ( selFirst >= first && selLast <= last ) { |
283 | updateDayMatrixDates(); | 283 | updateDayMatrixDates(); |
284 | } | 284 | } |
285 | else { | 285 | else { |
286 | updateDayMatrixDates(); | 286 | updateDayMatrixDates(); |
287 | emit monthSelected( mFirstSelectedDate.month() ); | 287 | emit monthSelected( mFirstSelectedDate.month() ); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | void DateNavigatorContainer::updateDayMatrixDates() | 290 | void DateNavigatorContainer::updateDayMatrixDates() |
291 | { | 291 | { |
292 | QDate fDate = mFirstSelectedDate; | 292 | QDate fDate = mFirstSelectedDate; |
293 | QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); | 293 | QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); |
294 | mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); | 294 | mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); |
295 | mNavigatorView->dayMatrix()->repaint( false ); | 295 | mNavigatorView->dayMatrix()->repaint( false ); |
296 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 296 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
297 | KDateNavigator *n = mExtraViews.at( i ); | 297 | KDateNavigator *n = mExtraViews.at( i ); |
298 | if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { | 298 | if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { |
299 | n->dayMatrix()->repaint( false ); | 299 | n->dayMatrix()->repaint( false ); |
300 | } | 300 | } |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | void DateNavigatorContainer::updateDayMatrix() | 304 | void DateNavigatorContainer::updateDayMatrix() |
305 | { | 305 | { |
306 | mNavigatorView->updateDayMatrix(); | 306 | mNavigatorView->updateDayMatrix(); |
307 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 307 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
308 | KDateNavigator *n = mExtraViews.at( i ); | 308 | KDateNavigator *n = mExtraViews.at( i ); |
309 | n->updateDayMatrix(); | 309 | n->updateDayMatrix(); |
310 | } | 310 | } |
311 | } | 311 | } |
312 | 312 | ||
313 | void DateNavigatorContainer::updateToday() | 313 | void DateNavigatorContainer::updateToday() |
314 | { | 314 | { |
315 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); | 315 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); |
316 | #if 0 | 316 | #if 0 |
317 | mNavigatorView->updateToday(); | 317 | mNavigatorView->updateToday(); |
318 | KDateNavigator *n; | 318 | KDateNavigator *n; |
319 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 319 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
320 | n->updateToday(); | 320 | n->updateToday(); |
321 | } | 321 | } |
322 | #endif | 322 | #endif |
323 | } | 323 | } |
324 | 324 | ||
325 | void DateNavigatorContainer::updateView() | 325 | void DateNavigatorContainer::updateView() |
326 | { | 326 | { |
327 | mNavigatorView->updateView(); | 327 | mNavigatorView->updateView(); |
328 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 328 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
329 | KDateNavigator *n = mExtraViews.at( i ); | 329 | KDateNavigator *n = mExtraViews.at( i ); |
330 | n->updateView(); | 330 | n->updateView(); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | void DateNavigatorContainer::updateConfig() | 334 | void DateNavigatorContainer::updateConfig() |
335 | { | 335 | { |
336 | mNavigatorView->updateConfig(); | 336 | mNavigatorView->updateConfig(); |
337 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 337 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
338 | KDateNavigator *n = mExtraViews.at( i ); | 338 | KDateNavigator *n = mExtraViews.at( i ); |
339 | n->updateConfig(); | 339 | n->updateConfig(); |
340 | } | 340 | } |
341 | } | 341 | } |
342 | QDate DateNavigatorContainer::lastAvailableDate() const | 342 | QDate DateNavigatorContainer::lastAvailableDate() const |
343 | { | 343 | { |
344 | QDate date = mNavigatorView->baseDate(); | 344 | QDate date = mNavigatorView->baseDate(); |
345 | QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); | 345 | QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); |
346 | int iii = mLastDisplayedDN; | 346 | int iii = mLastDisplayedDN; |
347 | if ( mLastDisplayedDN ) | 347 | if ( mLastDisplayedDN ) |
348 | last = last.addDays( 1); | 348 | last = last.addDays( 1); |
349 | while ( iii ) { | 349 | while ( iii ) { |
350 | last = last.addDays( last.daysInMonth ()); | 350 | last = last.addDays( last.daysInMonth ()); |
351 | //qDebug("DATE %s ", last.toString().latin1() ); | 351 | //qDebug("DATE %s ", last.toString().latin1() ); |
352 | --iii; | 352 | --iii; |
353 | } | 353 | } |
354 | if ( mLastDisplayedDN ) | 354 | if ( mLastDisplayedDN ) |
355 | last = last.addDays( -1); | 355 | last = last.addDays( -1); |
356 | return last; | 356 | return last; |
357 | } | 357 | } |
358 | QDate DateNavigatorContainer::firstAvailableDate() const | 358 | QDate DateNavigatorContainer::firstAvailableDate() const |
359 | { | 359 | { |
360 | return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); | 360 | return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); |
361 | } | 361 | } |
362 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 362 | void DateNavigatorContainer::selectDates( const DateList &dateList ) |
363 | { | 363 | { |
364 | mFirstSelectedDate = dateList.first() ; | 364 | mFirstSelectedDate = dateList.first() ; |
365 | mSelectedDateCount = dateList.count() ; | 365 | mSelectedDateCount = dateList.count() ; |
366 | if ( !mLastDisplayedDN ) { | 366 | if ( !mLastDisplayedDN ) { |
367 | mNavigatorView->selectDates( dateList ); | 367 | mNavigatorView->selectDates( dateList ); |
368 | return; | 368 | return; |
369 | } | 369 | } |
370 | QDate fDate = dateList.first(); | 370 | QDate fDate = dateList.first(); |
371 | QDate lDate = dateList.last(); | 371 | QDate lDate = dateList.last(); |
372 | //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); | 372 | //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); |
373 | //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); | 373 | //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); |
374 | if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { | 374 | if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { |
375 | updateDayMatrixDates(); | 375 | updateDayMatrixDates(); |
376 | return; | 376 | return; |
377 | } | 377 | } |
378 | mNavigatorView->selectDates( dateList ); | 378 | mNavigatorView->selectDates( dateList ); |
379 | setBaseDates(); | 379 | setBaseDates(); |
380 | if ( mLastDisplayedDN ) { | 380 | if ( mLastDisplayedDN ) { |
381 | KDateNavigator *view = mExtraViews.at( 0 ); | 381 | KDateNavigator *view = mExtraViews.at( 0 ); |
382 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 382 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
383 | view->dayMatrix()->repaint( false ); | 383 | view->dayMatrix()->repaint( false ); |
384 | if ( mLastDisplayedDN > 1 ) { | 384 | if ( mLastDisplayedDN > 1 ) { |
385 | KDateNavigator *view = mExtraViews.at( 1 ); | 385 | KDateNavigator *view = mExtraViews.at( 1 ); |