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