summaryrefslogtreecommitdiffabout
path: root/microkde
authorzautrix <zautrix>2005-02-08 18:29:59 (UTC)
committer zautrix <zautrix>2005-02-08 18:29:59 (UTC)
commit2124ce7f8c6edbd0e3ec32b1d1e6a625ef9450d6 (patch) (unidiff)
tree733f50ad5513065fe407fa341948172aae893b52 /microkde
parent126b79abd88bb13ab41c4d987ee759eb9ba7d483 (diff)
downloadkdepimpi-2124ce7f8c6edbd0e3ec32b1d1e6a625ef9450d6.zip
kdepimpi-2124ce7f8c6edbd0e3ec32b1d1e6a625ef9450d6.tar.gz
kdepimpi-2124ce7f8c6edbd0e3ec32b1d1e6a625ef9450d6.tar.bz2
font fix
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdatetbl.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index a9924ba..1024796 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -332,256 +332,258 @@ void
332KDateTable::contentsMousePressEvent(QMouseEvent *e) 332KDateTable::contentsMousePressEvent(QMouseEvent *e)
333{ 333{
334 if(e->type()!=QEvent::MouseButtonPress) 334 if(e->type()!=QEvent::MouseButtonPress)
335 { // the KDatePicker only reacts on mouse press events: 335 { // the KDatePicker only reacts on mouse press events:
336 return; 336 return;
337 } 337 }
338 if(!isEnabled()) 338 if(!isEnabled())
339 { 339 {
340 KNotifyClient::beep(); 340 KNotifyClient::beep();
341 return; 341 return;
342 } 342 }
343 343
344 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; 344 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
345 // ----- 345 // -----
346 int row, col, pos, temp; 346 int row, col, pos, temp;
347 QPoint mouseCoord; 347 QPoint mouseCoord;
348 // ----- 348 // -----
349 mouseCoord = e->pos(); 349 mouseCoord = e->pos();
350 row=rowAt(mouseCoord.y()); 350 row=rowAt(mouseCoord.y());
351 col=columnAt(mouseCoord.x()); 351 col=columnAt(mouseCoord.x());
352 if(row<0 || col<0) 352 if(row<0 || col<0)
353 { // the user clicked on the frame of the table 353 { // the user clicked on the frame of the table
354 return; 354 return;
355 } 355 }
356 pos=7*(row-1)+col+1; 356 pos=7*(row-1)+col+1;
357#if 0 357#if 0
358 if(pos+dayoff<=firstday) 358 if(pos+dayoff<=firstday)
359 { // this day is in the previous month 359 { // this day is in the previous month
360 KNotifyClient::beep(); 360 KNotifyClient::beep();
361 return; 361 return;
362 } 362 }
363 if(firstday+numdays<pos+dayoff) 363 if(firstday+numdays<pos+dayoff)
364 { // this date is in the next month 364 { // this date is in the next month
365 KNotifyClient::beep(); 365 KNotifyClient::beep();
366 return; 366 return;
367 } 367 }
368#endif 368#endif
369 temp=firstday+date.day()-dayoff-1; 369 temp=firstday+date.day()-dayoff-1;
370 QDate da = QDate(date.year(), date.month(),1); 370 QDate da = QDate(date.year(), date.month(),1);
371 setDate(da.addDays( pos-firstday+dayoff-1)); 371 setDate(da.addDays( pos-firstday+dayoff-1));
372 updateCell(temp/7+1, temp%7); // Update the previously selected cell 372 updateCell(temp/7+1, temp%7); // Update the previously selected cell
373 updateCell(row, col); // Update the selected cell 373 updateCell(row, col); // Update the selected cell
374 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); 374 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
375 emit(tableClicked()); 375 emit(tableClicked());
376} 376}
377 377
378bool 378bool
379KDateTable::setDate(const QDate& date_) 379KDateTable::setDate(const QDate& date_)
380{ 380{
381 bool changed=false; 381 bool changed=false;
382 QDate temp; 382 QDate temp;
383 mMarkCurrent = false; 383 mMarkCurrent = false;
384 // ----- 384 // -----
385 if(!date_.isValid()) 385 if(!date_.isValid())
386 { 386 {
387 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; 387 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl;
388 return false; 388 return false;
389 } 389 }
390 if(date!=date_) 390 if(date!=date_)
391 { 391 {
392 date=date_; 392 date=date_;
393 changed=true; 393 changed=true;
394 } 394 }
395 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); 395 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() );
396 temp.setYMD(date.year(), date.month(), 1); 396 temp.setYMD(date.year(), date.month(), 1);
397 firstday=temp.dayOfWeek(); 397 firstday=temp.dayOfWeek();
398 if(firstday==1) firstday=8; 398 if(firstday==1) firstday=8;
399 numdays=date.daysInMonth(); 399 numdays=date.daysInMonth();
400 if(date.month()==1) 400 if(date.month()==1)
401 { // set to december of previous year 401 { // set to december of previous year
402 temp.setYMD(date.year()-1, 12, 1); 402 temp.setYMD(date.year()-1, 12, 1);
403 } else { // set to previous month 403 } else { // set to previous month
404 temp.setYMD(date.year(), date.month()-1, 1); 404 temp.setYMD(date.year(), date.month()-1, 1);
405 } 405 }
406 numDaysPrevMonth=temp.daysInMonth(); 406 numDaysPrevMonth=temp.daysInMonth();
407 if(changed) 407 if(changed)
408 { 408 {
409 repaintContents(false); 409 repaintContents(false);
410 } 410 }
411 emit(dateChanged(date)); 411 emit(dateChanged(date));
412 return true; 412 return true;
413} 413}
414 414
415const QDate& 415const QDate&
416KDateTable::getDate() const 416KDateTable::getDate() const
417{ 417{
418 return date; 418 return date;
419} 419}
420 420
421void KDateTable::focusInEvent( QFocusEvent *e ) 421void KDateTable::focusInEvent( QFocusEvent *e )
422{ 422{
423 repaintContents(false); 423 repaintContents(false);
424 QGridView::focusInEvent( e ); 424 QGridView::focusInEvent( e );
425} 425}
426 426
427void KDateTable::focusOutEvent( QFocusEvent *e ) 427void KDateTable::focusOutEvent( QFocusEvent *e )
428{ 428{
429 repaintContents(false); 429 repaintContents(false);
430 QGridView::focusOutEvent( e ); 430 QGridView::focusOutEvent( e );
431} 431}
432 432
433QSize 433QSize
434KDateTable::sizeHint() const 434KDateTable::sizeHint() const
435{ 435{
436 if(maxCell.height()>0 && maxCell.width()>0) 436 if(maxCell.height()>0 && maxCell.width()>0)
437 { 437 {
438 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), 438 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(),
439 (maxCell.height()+4)*numRows()+2*frameWidth()); 439 (maxCell.height()+4)*numRows()+2*frameWidth());
440 } else { 440 } else {
441 return QSize(-1, -1); 441 return QSize(-1, -1);
442 } 442 }
443} 443}
444 444
445KDateInternalMonthPicker::KDateInternalMonthPicker 445KDateInternalMonthPicker::KDateInternalMonthPicker
446(QWidget* parent, const char* name) 446(QWidget* parent, const char* name)
447 : QGridView(parent, name), 447 : QGridView(parent, name),
448 result(0) // invalid 448 result(0) // invalid
449{ 449{
450 QRect rect; 450 QRect rect;
451 QFont font; 451 QFont font;
452 // ----- 452 // -----
453 activeCol = -1; 453 activeCol = -1;
454 activeRow = -1; 454 activeRow = -1;
455 font=KGlobalSettings::generalFont(); 455 font=KGlobalSettings::generalFont();
456 int fontsize = 10; 456 int fontsize = 10;
457 int add = 2; 457 int add = 2;
458 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 458 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
459 add += 8; 459 add += 8;
460 if ( QApplication::desktop()->width() > 640 )
461 add += 4;
460 font.setPointSize(fontsize+add); 462 font.setPointSize(fontsize+add);
461 setFont(font); 463 setFont(font);
462 setHScrollBarMode(AlwaysOff); 464 setHScrollBarMode(AlwaysOff);
463 setVScrollBarMode(AlwaysOff); 465 setVScrollBarMode(AlwaysOff);
464 setFrameStyle(QFrame::NoFrame); 466 setFrameStyle(QFrame::NoFrame);
465 setNumRows(4); 467 setNumRows(4);
466 setNumCols(3); 468 setNumCols(3);
467 // enable to find drawing failures: 469 // enable to find drawing failures:
468 // setTableFlags(Tbl_clipCellPainting); 470 // setTableFlags(Tbl_clipCellPainting);
469#if 0 471#if 0
470 viewport()->setEraseColor(lightGray); // for consistency with the datepicker 472 viewport()->setEraseColor(lightGray); // for consistency with the datepicker
471#endif 473#endif
472 // ----- find the preferred size 474 // ----- find the preferred size
473 // (this is slow, possibly, but unfortunatly it is needed here): 475 // (this is slow, possibly, but unfortunatly it is needed here):
474 QFontMetrics metrics(font); 476 QFontMetrics metrics(font);
475 for(int i=1; i <= 12; ++i) 477 for(int i=1; i <= 12; ++i)
476 { 478 {
477 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); 479 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false));
478 if(max.width()<rect.width()) max.setWidth(rect.width()); 480 if(max.width()<rect.width()) max.setWidth(rect.width());
479 if(max.height()<rect.height()) max.setHeight(rect.height()); 481 if(max.height()<rect.height()) max.setHeight(rect.height());
480 } 482 }
481 483
482} 484}
483 485
484QSize 486QSize
485KDateInternalMonthPicker::sizeHint() const 487KDateInternalMonthPicker::sizeHint() const
486{ 488{
487 return QSize((max.width()+6)*numCols()+2*frameWidth(), 489 return QSize((max.width()+6)*numCols()+2*frameWidth(),
488 (max.height()+6)*numRows()+2*frameWidth()); 490 (max.height()+6)*numRows()+2*frameWidth());
489} 491}
490 492
491int 493int
492KDateInternalMonthPicker::getResult() const 494KDateInternalMonthPicker::getResult() const
493{ 495{
494 return result; 496 return result;
495} 497}
496 498
497void 499void
498KDateInternalMonthPicker::setupPainter(QPainter *p) 500KDateInternalMonthPicker::setupPainter(QPainter *p)
499{ 501{
500 p->setPen(black); 502 p->setPen(black);
501} 503}
502 504
503void 505void
504KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) 506KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*)
505{ 507{
506 setCellWidth(width()/3); 508 setCellWidth(width()/3);
507 setCellHeight(height()/4); 509 setCellHeight(height()/4);
508} 510}
509 511
510void 512void
511KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) 513KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col)
512{ 514{
513 int index; 515 int index;
514 QString text; 516 QString text;
515 // ----- find the number of the cell: 517 // ----- find the number of the cell:
516 index=3*row+col+1; 518 index=3*row+col+1;
517 text=KGlobal::locale()->monthName(index, false); 519 text=KGlobal::locale()->monthName(index, false);
518 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); 520 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text);
519 if ( activeCol == col && activeRow == row ) 521 if ( activeCol == col && activeRow == row )
520 painter->drawRect( 0, 0, cellWidth(), cellHeight() ); 522 painter->drawRect( 0, 0, cellWidth(), cellHeight() );
521} 523}
522 524
523void 525void
524KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) 526KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e)
525{ 527{
526 if(!isEnabled() || e->button() != LeftButton) 528 if(!isEnabled() || e->button() != LeftButton)
527 { 529 {
528 KNotifyClient::beep(); 530 KNotifyClient::beep();
529 return; 531 return;
530 } 532 }
531 // ----- 533 // -----
532 int row, col; 534 int row, col;
533 QPoint mouseCoord; 535 QPoint mouseCoord;
534 // ----- 536 // -----
535 mouseCoord = e->pos(); 537 mouseCoord = e->pos();
536 row=rowAt(mouseCoord.y()); 538 row=rowAt(mouseCoord.y());
537 col=columnAt(mouseCoord.x()); 539 col=columnAt(mouseCoord.x());
538 540
539 if(row<0 || col<0) 541 if(row<0 || col<0)
540 { // the user clicked on the frame of the table 542 { // the user clicked on the frame of the table
541 activeCol = -1; 543 activeCol = -1;
542 activeRow = -1; 544 activeRow = -1;
543 } else { 545 } else {
544 activeCol = col; 546 activeCol = col;
545 activeRow = row; 547 activeRow = row;
546 updateCell( row, col /*, false */ ); 548 updateCell( row, col /*, false */ );
547 } 549 }
548} 550}
549 551
550void 552void
551KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) 553KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e)
552{ 554{
553 if (e->state() & LeftButton) 555 if (e->state() & LeftButton)
554 { 556 {
555 int row, col; 557 int row, col;
556 QPoint mouseCoord; 558 QPoint mouseCoord;
557 // ----- 559 // -----
558 mouseCoord = e->pos(); 560 mouseCoord = e->pos();
559 row=rowAt(mouseCoord.y()); 561 row=rowAt(mouseCoord.y());
560 col=columnAt(mouseCoord.x()); 562 col=columnAt(mouseCoord.x());
561 int tmpRow = -1, tmpCol = -1; 563 int tmpRow = -1, tmpCol = -1;
562 if(row<0 || col<0) 564 if(row<0 || col<0)
563 { // the user clicked on the frame of the table 565 { // the user clicked on the frame of the table
564 if ( activeCol > -1 ) 566 if ( activeCol > -1 )
565 { 567 {
566 tmpRow = activeRow; 568 tmpRow = activeRow;
567 tmpCol = activeCol; 569 tmpCol = activeCol;
568 } 570 }
569 activeCol = -1; 571 activeCol = -1;
570 activeRow = -1; 572 activeRow = -1;
571 } else { 573 } else {
572 bool differentCell = (activeRow != row || activeCol != col); 574 bool differentCell = (activeRow != row || activeCol != col);
573 if ( activeCol > -1 && differentCell) 575 if ( activeCol > -1 && differentCell)
574 { 576 {
575 tmpRow = activeRow; 577 tmpRow = activeRow;
576 tmpCol = activeCol; 578 tmpCol = activeCol;
577 } 579 }
578 if ( differentCell) 580 if ( differentCell)
579 { 581 {
580 activeRow = row; 582 activeRow = row;
581 activeCol = col; 583 activeCol = col;
582 updateCell( row, col /*, false */ ); // mark the new active cell 584 updateCell( row, col /*, false */ ); // mark the new active cell
583 } 585 }
584 } 586 }
585 if ( tmpRow > -1 ) // repaint the former active cell 587 if ( tmpRow > -1 ) // repaint the former active cell
586 updateCell( tmpRow, tmpCol /*, true */ ); 588 updateCell( tmpRow, tmpCol /*, true */ );
587 } 589 }