author | zautrix <zautrix> | 2005-03-22 14:59:07 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-22 14:59:07 (UTC) |
commit | 0fe23b2c9b74bac46f409098f950259bffbdbe3c (patch) (unidiff) | |
tree | 80b4077661301ee3216217dfcb0bc9fd0a74b7d7 | |
parent | 03b3e902ed6362d8f72d0acfc5a9be9d9ee1ef21 (diff) | |
download | kdepimpi-0fe23b2c9b74bac46f409098f950259bffbdbe3c.zip kdepimpi-0fe23b2c9b74bac46f409098f950259bffbdbe3c.tar.gz kdepimpi-0fe23b2c9b74bac46f409098f950259bffbdbe3c.tar.bz2 |
more layout fixes
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 7 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 6de7c45..9720146 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -193,195 +193,194 @@ QDate DateNavigatorContainer::lastAvailableDate() const | |||
193 | QDate date = mNavigatorView->baseDate(); | 193 | QDate date = mNavigatorView->baseDate(); |
194 | QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); | 194 | QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); |
195 | int iii = mLastDisplayedDN; | 195 | int iii = mLastDisplayedDN; |
196 | if ( mLastDisplayedDN ) | 196 | if ( mLastDisplayedDN ) |
197 | last = last.addDays( 1); | 197 | last = last.addDays( 1); |
198 | while ( iii ) { | 198 | while ( iii ) { |
199 | last = last.addDays( last.daysInMonth ()); | 199 | last = last.addDays( last.daysInMonth ()); |
200 | //qDebug("DATE %s ", last.toString().latin1() ); | 200 | //qDebug("DATE %s ", last.toString().latin1() ); |
201 | --iii; | 201 | --iii; |
202 | } | 202 | } |
203 | if ( mLastDisplayedDN ) | 203 | if ( mLastDisplayedDN ) |
204 | last = last.addDays( -1); | 204 | last = last.addDays( -1); |
205 | return last; | 205 | return last; |
206 | } | 206 | } |
207 | QDate DateNavigatorContainer::firstAvailableDate() const | 207 | QDate DateNavigatorContainer::firstAvailableDate() const |
208 | { | 208 | { |
209 | return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); | 209 | return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); |
210 | } | 210 | } |
211 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 211 | void DateNavigatorContainer::selectDates( const DateList &dateList ) |
212 | { | 212 | { |
213 | mFirstSelectedDate = dateList.first() ; | 213 | mFirstSelectedDate = dateList.first() ; |
214 | mSelectedDateCount = dateList.count() ; | 214 | mSelectedDateCount = dateList.count() ; |
215 | if ( !mLastDisplayedDN ) { | 215 | if ( !mLastDisplayedDN ) { |
216 | mNavigatorView->selectDates( dateList ); | 216 | mNavigatorView->selectDates( dateList ); |
217 | return; | 217 | return; |
218 | } | 218 | } |
219 | QDate fDate = dateList.first(); | 219 | QDate fDate = dateList.first(); |
220 | QDate lDate = dateList.last(); | 220 | QDate lDate = dateList.last(); |
221 | if ( mLastDisplayedDN <= 2 ) { | 221 | if ( mLastDisplayedDN <= 2 ) { |
222 | mNavigatorView->selectDates( dateList ); | 222 | mNavigatorView->selectDates( dateList ); |
223 | KDateNavigator *view = mExtraViews.at( 0 ); | 223 | KDateNavigator *view = mExtraViews.at( 0 ); |
224 | QDate bDate = fDate.addDays( fDate.daysInMonth () - fDate.day() +1 ); | 224 | QDate bDate = fDate.addDays( fDate.daysInMonth () - fDate.day() +1 ); |
225 | view->setBaseDate( bDate, false ); | 225 | view->setBaseDate( bDate, false ); |
226 | view->dayMatrix()->setSelectedDaysFrom(fDate , lDate); | 226 | view->dayMatrix()->setSelectedDaysFrom(fDate , lDate); |
227 | if ( mLastDisplayedDN == 2 ) { | 227 | if ( mLastDisplayedDN == 2 ) { |
228 | view = mExtraViews.at( 1 ); | 228 | view = mExtraViews.at( 1 ); |
229 | bDate = bDate.addDays( bDate.daysInMonth () - bDate.day() +1 ); | 229 | bDate = bDate.addDays( bDate.daysInMonth () - bDate.day() +1 ); |
230 | view->setBaseDate( bDate, false ); | 230 | view->setBaseDate( bDate, false ); |
231 | view->dayMatrix()->setSelectedDaysFrom(fDate , lDate); | 231 | view->dayMatrix()->setSelectedDaysFrom(fDate , lDate); |
232 | } | 232 | } |
233 | return; | 233 | return; |
234 | } | 234 | } |
235 | //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); | 235 | //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); |
236 | //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); | 236 | //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); |
237 | if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { | 237 | if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { |
238 | updateDayMatrixDates(); | 238 | updateDayMatrixDates(); |
239 | return; | 239 | return; |
240 | } | 240 | } |
241 | mNavigatorView->selectDates( dateList ); | 241 | mNavigatorView->selectDates( dateList ); |
242 | setBaseDates(); | 242 | setBaseDates(); |
243 | if ( mLastDisplayedDN ) { | 243 | if ( mLastDisplayedDN ) { |
244 | KDateNavigator *view = mExtraViews.at( 0 ); | 244 | KDateNavigator *view = mExtraViews.at( 0 ); |
245 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 245 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
246 | view->dayMatrix()->repaint( false ); | 246 | view->dayMatrix()->repaint( false ); |
247 | if ( mLastDisplayedDN > 1 ) { | 247 | if ( mLastDisplayedDN > 1 ) { |
248 | KDateNavigator *view = mExtraViews.at( 1 ); | 248 | KDateNavigator *view = mExtraViews.at( 1 ); |
249 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 249 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
250 | view->dayMatrix()->repaint( false ); | 250 | view->dayMatrix()->repaint( false ); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | void DateNavigatorContainer::setBaseDates() | 255 | void DateNavigatorContainer::setBaseDates() |
256 | { | 256 | { |
257 | QDate baseDate = mNavigatorView->baseDate(); | 257 | QDate baseDate = mNavigatorView->baseDate(); |
258 | bool doRepaint = true; | 258 | bool doRepaint = true; |
259 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 259 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
260 | KDateNavigator *n = mExtraViews.at( i ); | 260 | KDateNavigator *n = mExtraViews.at( i ); |
261 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); | 261 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); |
262 | n->setBaseDate( baseDate, doRepaint ); | 262 | n->setBaseDate( baseDate, doRepaint ); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) | 266 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) |
267 | { | 267 | { |
268 | #if 0 | 268 | #if 0 |
269 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; | 269 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; |
270 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; | 270 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; |
271 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; | 271 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; |
272 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; | 272 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; |
273 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; | 273 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; |
274 | #endif | 274 | #endif |
275 | //QSize minSize = mNavigatorView->sizeHintTwoButtons(); | 275 | //QSize minSize = mNavigatorView->sizeHintTwoButtons(); |
276 | QSize minSize = mNavigatorView->yourSizeHint(); | 276 | QSize minSize = mNavigatorView->yourSizeHint(); |
277 | 277 | ||
278 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; | 278 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; |
279 | 279 | ||
280 | int verticalCount = size().height() / minSize.height(); | 280 | int verticalCount = size().height() / minSize.height(); |
281 | int horizontalCount = size().width() / minSize.width(); | 281 | int horizontalCount = size().width() / minSize.width(); |
282 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); | 282 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); |
283 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); | 283 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); |
284 | bool fontchange = false; | 284 | bool fontchange = false; |
285 | if ( horizontalCount == 1) | 285 | if ( horizontalCount == 1) |
286 | horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); | 286 | horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); |
287 | QFont fo; | 287 | QFont fo; |
288 | if ( horizontalCount != mHorizontalCount || | 288 | if ( horizontalCount != mHorizontalCount || |
289 | verticalCount != mVerticalCount ) { | 289 | verticalCount != mVerticalCount ) { |
290 | uint count = horizontalCount * verticalCount; | 290 | uint count = horizontalCount * verticalCount; |
291 | if ( count == 0 ) { | 291 | if ( count == 0 ) { |
292 | bool ok; | 292 | bool ok; |
293 | fo = mNavigatorView->yourFontHint( size() , &ok ); | 293 | fo = mNavigatorView->yourFontHint( size() , &ok ); |
294 | //mNavigatorView->resize( size() ); | 294 | //mNavigatorView->resize( size() ); |
295 | //if ( ! ok ) | 295 | //if ( ! ok ) |
296 | // return; | 296 | // return; |
297 | int butt = 2; | 297 | int butt = 2; |
298 | horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); | 298 | horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); |
299 | if ( horizontalCount <= 1 ) | 299 | if ( horizontalCount <= 1 ) |
300 | minSize = mNavigatorView->sizeHintTwoButtons( 4 ); | 300 | minSize = mNavigatorView->sizeHintTwoButtons( 4 ); |
301 | else | 301 | else |
302 | minSize = mNavigatorView->sizeHintTwoButtons(); | 302 | minSize = mNavigatorView->sizeHintTwoButtons(); |
303 | verticalCount = size().height() / minSize.height(); | 303 | verticalCount = size().height() / minSize.height(); |
304 | horizontalCount = size().width() / minSize.width(); | 304 | horizontalCount = size().width() / minSize.width(); |
305 | if ( horizontalCount == 0 ) | 305 | if ( horizontalCount == 0 ) |
306 | horizontalCount = 1; | 306 | horizontalCount = 1; |
307 | if ( verticalCount == 0 ) | 307 | if ( verticalCount == 0 ) |
308 | verticalCount = 1; | 308 | verticalCount = 1; |
309 | fontchange = true; | 309 | fontchange = true; |
310 | count = horizontalCount * verticalCount; | 310 | count = horizontalCount * verticalCount; |
311 | } else { | 311 | } else { |
312 | if ( mNavigatorView->fontChanged() ) { | 312 | if ( mNavigatorView->fontChanged() ) { |
313 | fontchange = true; | 313 | fontchange = true; |
314 | fo = KOPrefs::instance()->mDateNavigatorFont; | 314 | fo = KOPrefs::instance()->mDateNavigatorFont; |
315 | mNavigatorView->changeFont( fo ); | 315 | mNavigatorView->changeFont( fo ); |
316 | mNavigatorView->unsetFontChanged(); | 316 | mNavigatorView->unsetFontChanged(); |
317 | } | 317 | } |
318 | } | 318 | } |
319 | 319 | ||
320 | mLastDisplayedDN = horizontalCount*verticalCount-1; | 320 | mLastDisplayedDN = horizontalCount*verticalCount-1; |
321 | bool setBaseD = false; | ||
322 | while ( count > ( mExtraViews.count() + 1 ) ) { | 321 | while ( count > ( mExtraViews.count() + 1 ) ) { |
323 | KDateNavigator *n = new KDateNavigator( this ); | 322 | KDateNavigator *n = new KDateNavigator( this ); |
324 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | 323 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); |
325 | mExtraViews.append( n ); | 324 | mExtraViews.append( n ); |
326 | n->setCalendar( mCalendar ); | 325 | n->setCalendar( mCalendar ); |
327 | setBaseD = true; | ||
328 | connectNavigatorView( n ); | 326 | connectNavigatorView( n ); |
329 | n->show(); | 327 | n->show(); |
330 | } | 328 | } |
331 | int iii = 0; | 329 | int iii = 0; |
332 | while ( iii < ( mExtraViews.count() ) ) { | 330 | while ( iii < ( mExtraViews.count() ) ) { |
333 | if ( iii < count-1 ) | 331 | if ( iii < count-1 ) |
334 | mExtraViews.at( iii )->show(); | 332 | mExtraViews.at( iii )->show(); |
335 | else | 333 | else |
336 | mExtraViews.at( iii )->hide(); | 334 | mExtraViews.at( iii )->hide(); |
337 | ++iii; | 335 | ++iii; |
338 | } | 336 | } |
339 | if ( setBaseD ) | 337 | |
340 | setBaseDates(); | 338 | setBaseDates(); |
341 | if ( fontchange ) { | 339 | if ( fontchange ) { |
342 | //mNavigatorView->changeFont( fo ); | 340 | //mNavigatorView->changeFont( fo ); |
343 | uint i; | 341 | uint i; |
344 | for( i = 0; i < mExtraViews.count(); ++i ) { | 342 | for( i = 0; i < mExtraViews.count(); ++i ) { |
345 | KDateNavigator *view = mExtraViews.at( i ); | 343 | KDateNavigator *view = mExtraViews.at( i ); |
346 | view->changeFont( fo ); | 344 | view->changeFont( fo ); |
347 | } | 345 | } |
348 | } | 346 | } |
349 | mHorizontalCount = horizontalCount; | 347 | mHorizontalCount = horizontalCount; |
350 | mVerticalCount = verticalCount; | 348 | mVerticalCount = verticalCount; |
351 | 349 | ||
352 | } | 350 | } |
353 | //qDebug("COUNT %d ", mExtraViews.count()); | 351 | //qDebug("COUNT %d ", mExtraViews.count()); |
354 | int height = size().height() / verticalCount; | 352 | int height = size().height() / verticalCount; |
355 | int width = size().width() / horizontalCount; | 353 | int width = size().width() / horizontalCount; |
356 | 354 | ||
357 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | 355 | NavigatorBar *bar = mNavigatorView->navigatorBar(); |
358 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); | 356 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); |
359 | else bar->showButtons( true, true ); | 357 | else bar->showButtons( true, true ); |
360 | 358 | ||
361 | mNavigatorView->setGeometry(0, | 359 | mNavigatorView->setGeometry(0, |
362 | 0, width, height ); | 360 | 0, width, height ); |
363 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 361 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
364 | int x = ( i + 1 ) % horizontalCount; | 362 | int x = ( i + 1 ) % horizontalCount; |
365 | int y = ( i + 1 ) / horizontalCount; | 363 | int y = ( i + 1 ) / horizontalCount; |
366 | 364 | ||
367 | KDateNavigator *view = mExtraViews.at( i ); | 365 | KDateNavigator *view = mExtraViews.at( i ); |
368 | bar = view->navigatorBar(); | 366 | bar = view->navigatorBar(); |
369 | if ( y > 0 ) bar->showButtons( false, false ); | 367 | if ( y > 0 ) bar->showButtons( false, false ); |
370 | else { | 368 | else { |
371 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); | 369 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); |
372 | else bar->showButtons( false, false ); | 370 | else bar->showButtons( false, false ); |
373 | } | 371 | } |
374 | view->setGeometry( x * width, | 372 | view->setGeometry( x * width, |
375 | y * height, width, height ); | 373 | y * height, width, height ); |
376 | } | 374 | } |
375 | //updateDayMatrixDates(); | ||
377 | } | 376 | } |
378 | 377 | ||
379 | QSize DateNavigatorContainer::minimumSizeHint() const | 378 | QSize DateNavigatorContainer::minimumSizeHint() const |
380 | { | 379 | { |
381 | return mNavigatorView->minimumSizeHint(); | 380 | return mNavigatorView->minimumSizeHint(); |
382 | } | 381 | } |
383 | 382 | ||
384 | QSize DateNavigatorContainer::sizeHint() const | 383 | QSize DateNavigatorContainer::sizeHint() const |
385 | { | 384 | { |
386 | return mNavigatorView->yourSizeHint(); | 385 | return mNavigatorView->yourSizeHint(); |
387 | } | 386 | } |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 3ee1fa7..366e8b8 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,234 +1,234 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #include <libkcal/vcaldrag.h> | 35 | #include <libkcal/vcaldrag.h> |
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/dndfactory.h> | 37 | #include <libkcal/dndfactory.h> |
38 | #include <libkcal/calendarresources.h> | 38 | #include <libkcal/calendarresources.h> |
39 | #include <libkcal/resourcecalendar.h> | 39 | #include <libkcal/resourcecalendar.h> |
40 | #include <kresources/resourceselectdialog.h> | 40 | #include <kresources/resourceselectdialog.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPLUGINS | 44 | #ifndef KORG_NOPLUGINS |
45 | #include "kocore.h" | 45 | #include "kocore.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "koglobals.h" | 48 | #include "koglobals.h" |
49 | 49 | ||
50 | #include "kodaymatrix.h" | 50 | #include "kodaymatrix.h" |
51 | 51 | ||
52 | // ============================================================================ | 52 | // ============================================================================ |
53 | // D Y N A M I C T I P | 53 | // D Y N A M I C T I P |
54 | // ============================================================================ | 54 | // ============================================================================ |
55 | 55 | ||
56 | DynamicTip::DynamicTip( QWidget * parent ) | 56 | DynamicTip::DynamicTip( QWidget * parent ) |
57 | : QToolTip( parent ) | 57 | : QToolTip( parent ) |
58 | { | 58 | { |
59 | matrix = (KODayMatrix*)parent; | 59 | matrix = (KODayMatrix*)parent; |
60 | } | 60 | } |
61 | 61 | ||
62 | class KODaymatrixWhatsThis :public QWhatsThis | 62 | class KODaymatrixWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; | 65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; |
66 | ~KODaymatrixWhatsThis() { ; }; | 66 | ~KODaymatrixWhatsThis() { ; }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p ) | 69 | virtual QString text( const QPoint& p ) |
70 | { | 70 | { |
71 | return _view->getWhatsThisText( p ) ; | 71 | return _view->getWhatsThisText( p ) ; |
72 | } | 72 | } |
73 | private: | 73 | private: |
74 | KODayMatrix * _view; | 74 | KODayMatrix * _view; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | void DynamicTip::maybeTip( const QPoint &pos ) | 77 | void DynamicTip::maybeTip( const QPoint &pos ) |
78 | { | 78 | { |
79 | //calculate which cell of the matrix the mouse is in | 79 | //calculate which cell of the matrix the mouse is in |
80 | QRect sz = matrix->frameRect(); | 80 | QRect sz = matrix->frameRect(); |
81 | int dheight = sz.height()*7 / 42; | 81 | int dheight = sz.height()*7 / 42; |
82 | int dwidth = sz.width() / 7; | 82 | int dwidth = sz.width() / 7; |
83 | int row = pos.y()/dheight; | 83 | int row = pos.y()/dheight; |
84 | int col = pos.x()/dwidth; | 84 | int col = pos.x()/dwidth; |
85 | 85 | ||
86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
87 | 87 | ||
88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
89 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 89 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
90 | 90 | ||
91 | //show holiday names only | 91 | //show holiday names only |
92 | QString str = matrix->getHolidayLabel(col+row*7); | 92 | QString str = matrix->getHolidayLabel(col+row*7); |
93 | if (str.isEmpty()) return; | 93 | if (str.isEmpty()) return; |
94 | tip(rct, str); | 94 | tip(rct, str); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | // ============================================================================ | 98 | // ============================================================================ |
99 | // K O D A Y M A T R I X | 99 | // K O D A Y M A T R I X |
100 | // ============================================================================ | 100 | // ============================================================================ |
101 | 101 | ||
102 | const int KODayMatrix::NOSELECTION = -1000; | 102 | const int KODayMatrix::NOSELECTION = -1000; |
103 | const int KODayMatrix::NUMDAYS = 42; | 103 | const int KODayMatrix::NUMDAYS = 42; |
104 | 104 | ||
105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
106 | : QFrame( parent, name ), mCalendar( 0 ) | 106 | : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) |
107 | 107 | ||
108 | #if 0 | 108 | #if 0 |
109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
110 | QFrame(parent, name) | 110 | QFrame(parent, name) |
111 | #endif | 111 | #endif |
112 | { | 112 | { |
113 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); | 113 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); |
114 | mPendingUpdateBeforeRepaint = false; | 114 | mPendingUpdateBeforeRepaint = false; |
115 | mouseDown = false; | 115 | mouseDown = false; |
116 | // initialize dynamic arrays | 116 | // initialize dynamic arrays |
117 | bDays.resize ( NUMDAYS ); | 117 | bDays.resize ( NUMDAYS ); |
118 | days = new QDate[NUMDAYS]; | 118 | days = new QDate[NUMDAYS]; |
119 | daylbls = new QString[NUMDAYS]; | 119 | daylbls = new QString[NUMDAYS]; |
120 | events = new int[NUMDAYS]; | 120 | events = new int[NUMDAYS]; |
121 | mToolTip = new DynamicTip(this); | 121 | mToolTip = new DynamicTip(this); |
122 | 122 | ||
123 | // set default values used for drawing the matrix | 123 | // set default values used for drawing the matrix |
124 | mDefaultBackColor = palette().active().base(); | 124 | mDefaultBackColor = palette().active().base(); |
125 | mDefaultTextColor = palette().active().foreground(); | 125 | mDefaultTextColor = palette().active().foreground(); |
126 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 126 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
127 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 127 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
128 | mSelectedDaysColor = QColor("white"); | 128 | mSelectedDaysColor = QColor("white"); |
129 | mTodayMarginWidth = 2; | 129 | mTodayMarginWidth = 2; |
130 | mSelEnd = mSelStart = NOSELECTION; | 130 | mSelEnd = mSelStart = NOSELECTION; |
131 | 131 | ||
132 | setAcceptDrops(true); | 132 | setAcceptDrops(true); |
133 | //setFont( QFont("Arial", 10) ); | 133 | //setFont( QFont("Arial", 10) ); |
134 | 134 | ||
135 | mUpdateTimer = new QTimer( this ); | 135 | mUpdateTimer = new QTimer( this ); |
136 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 136 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
137 | mRepaintTimer = new QTimer( this ); | 137 | mRepaintTimer = new QTimer( this ); |
138 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 138 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
139 | mDayChanged = false; | 139 | mDayChanged = false; |
140 | updateView(); | 140 | updateView(); |
141 | } | 141 | } |
142 | QString KODayMatrix::getWhatsThisText( QPoint p ) | 142 | QString KODayMatrix::getWhatsThisText( QPoint p ) |
143 | { | 143 | { |
144 | 144 | ||
145 | int tmp = getDayIndexFrom(p.x(), p.y()); | 145 | int tmp = getDayIndexFrom(p.x(), p.y()); |
146 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) | 146 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) |
147 | return QString(); | 147 | return QString(); |
148 | QDate mDate = days[tmp]; | 148 | QDate mDate = days[tmp]; |
149 | QPtrList<Event> eventlist = mCalendar->events(mDate); | 149 | QPtrList<Event> eventlist = mCalendar->events(mDate); |
150 | Event *event; | 150 | Event *event; |
151 | QStringList mToolTip; | 151 | QStringList mToolTip; |
152 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 152 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
153 | QString mToolTipText; | 153 | QString mToolTipText; |
154 | QString text; | 154 | QString text; |
155 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 155 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
156 | if (event->isMultiDay()) { | 156 | if (event->isMultiDay()) { |
157 | QString prefix = "<->";multiday = 2; | 157 | QString prefix = "<->";multiday = 2; |
158 | QString time; | 158 | QString time; |
159 | if ( event->doesRecur() ) { | 159 | if ( event->doesRecur() ) { |
160 | if ( event->recursOn( mDate) ) { | 160 | if ( event->recursOn( mDate) ) { |
161 | prefix ="->" ;multiday = 1; | 161 | prefix ="->" ;multiday = 1; |
162 | } | 162 | } |
163 | else { | 163 | else { |
164 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 164 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
165 | if ( event->recursOn( mDate.addDays( -days)) ) { | 165 | if ( event->recursOn( mDate.addDays( -days)) ) { |
166 | prefix ="<-" ;multiday = 3; | 166 | prefix ="<-" ;multiday = 3; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | } else { | 169 | } else { |
170 | if (mDate == event->dtStart().date()) { | 170 | if (mDate == event->dtStart().date()) { |
171 | prefix ="->" ;multiday = 1; | 171 | prefix ="->" ;multiday = 1; |
172 | } else if (mDate == event->dtEnd().date()) { | 172 | } else if (mDate == event->dtEnd().date()) { |
173 | prefix ="<-" ;multiday = 3; | 173 | prefix ="<-" ;multiday = 3; |
174 | } | 174 | } |
175 | } | 175 | } |
176 | if ( !event->doesFloat() ) { | 176 | if ( !event->doesFloat() ) { |
177 | if ( mDate == event->dtStart().date () ) | 177 | if ( mDate == event->dtStart().date () ) |
178 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 178 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
179 | else if ( mDate == event->dtEnd().date () ) | 179 | else if ( mDate == event->dtEnd().date () ) |
180 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 180 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
181 | 181 | ||
182 | } | 182 | } |
183 | text = time + event->summary(); | 183 | text = time + event->summary(); |
184 | mToolTipText += prefix + text; | 184 | mToolTipText += prefix + text; |
185 | } else { | 185 | } else { |
186 | if (event->doesFloat()) { | 186 | if (event->doesFloat()) { |
187 | text = event->summary(); | 187 | text = event->summary(); |
188 | mToolTipText += text; | 188 | mToolTipText += text; |
189 | } | 189 | } |
190 | else { | 190 | else { |
191 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 191 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
192 | text += " " + event->summary(); | 192 | text += " " + event->summary(); |
193 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 193 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | if ( !event->location().isEmpty() ) | 196 | if ( !event->location().isEmpty() ) |
197 | mToolTipText += " (" + event->location() + ")"; | 197 | mToolTipText += " (" + event->location() + ")"; |
198 | #if QT_VERSION >= 0x030000 | 198 | #if QT_VERSION >= 0x030000 |
199 | mToolTipText.replace( '<' , "<" ); | 199 | mToolTipText.replace( '<' , "<" ); |
200 | mToolTipText.replace( '>' , ">" ); | 200 | mToolTipText.replace( '>' , ">" ); |
201 | #else | 201 | #else |
202 | if ( mToolTipText.find ('<') >= 0 ) { | 202 | if ( mToolTipText.find ('<') >= 0 ) { |
203 | mToolTipText.replace( QRegExp("<") , "<" ); | 203 | mToolTipText.replace( QRegExp("<") , "<" ); |
204 | } | 204 | } |
205 | if ( mToolTipText.find ('>') >= 0 ) { | 205 | if ( mToolTipText.find ('>') >= 0 ) { |
206 | mToolTipText.replace( QRegExp(">") , ">" ); | 206 | mToolTipText.replace( QRegExp(">") , ">" ); |
207 | } | 207 | } |
208 | #endif | 208 | #endif |
209 | //qDebug("TTT: %s ", mToolTipText.latin1()); | 209 | //qDebug("TTT: %s ", mToolTipText.latin1()); |
210 | mToolTip.append( mToolTipText ); | 210 | mToolTip.append( mToolTipText ); |
211 | } | 211 | } |
212 | mToolTip.sort(); | 212 | mToolTip.sort(); |
213 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); | 213 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); |
214 | } | 214 | } |
215 | void KODayMatrix::setCalendar( Calendar *cal ) | 215 | void KODayMatrix::setCalendar( Calendar *cal ) |
216 | { | 216 | { |
217 | mCalendar = cal; | 217 | mCalendar = cal; |
218 | 218 | ||
219 | setAcceptDrops( mCalendar ); | 219 | setAcceptDrops( mCalendar ); |
220 | 220 | ||
221 | updateEvents(); | 221 | updateEvents(); |
222 | } | 222 | } |
223 | 223 | ||
224 | QColor KODayMatrix::getShadedColor(QColor color) | 224 | QColor KODayMatrix::getShadedColor(QColor color) |
225 | { | 225 | { |
226 | QColor shaded; | 226 | QColor shaded; |
227 | int h=0; | 227 | int h=0; |
228 | int s=0; | 228 | int s=0; |
229 | int v=0; | 229 | int v=0; |
230 | color.hsv(&h,&s,&v); | 230 | color.hsv(&h,&s,&v); |
231 | s = s/4; | 231 | s = s/4; |
232 | v = 192+v/4; | 232 | v = 192+v/4; |
233 | shaded.setHsv(h,s,v); | 233 | shaded.setHsv(h,s,v); |
234 | 234 | ||