summaryrefslogtreecommitdiff
path: root/library/datebookmonth.cpp
Unidiff
Diffstat (limited to 'library/datebookmonth.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/datebookmonth.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/library/datebookmonth.cpp b/library/datebookmonth.cpp
index 272c223..4a9dcbd 100644
--- a/library/datebookmonth.cpp
+++ b/library/datebookmonth.cpp
@@ -1,49 +1,49 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "config.h" 20#include "config.h"
21#include "datebookmonth.h" 21#include "datebookmonth.h"
22#include "datebookdb.h" 22#include "datebookdb.h"
23#include <qtopia/private/event.h> 23#include <qtopia/private/event.h>
24#include "resource.h" 24#include "resource.h"
25#include "qpeapplication.h" 25#include <qpe/qpeapplication.h>
26#include "timestring.h" 26#include "timestring.h"
27 27
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29#include <qspinbox.h> 29#include <qspinbox.h>
30#include <qcombobox.h> 30#include <qcombobox.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qpainter.h> 32#include <qpainter.h>
33#include <qpopupmenu.h> 33#include <qpopupmenu.h>
34#include <qvaluestack.h> 34#include <qvaluestack.h>
35#include <qwhatsthis.h> 35#include <qwhatsthis.h>
36 36
37 37
38DateBookMonthHeader::DateBookMonthHeader( QWidget *parent, const char *name ) 38DateBookMonthHeader::DateBookMonthHeader( QWidget *parent, const char *name )
39 : QHBox( parent, name ) 39 : QHBox( parent, name )
40{ 40{
41 setBackgroundMode( PaletteButton ); 41 setBackgroundMode( PaletteButton );
42 42
43 begin = new QToolButton( this ); 43 begin = new QToolButton( this );
44 begin->setFocusPolicy(NoFocus); 44 begin->setFocusPolicy(NoFocus);
45 begin->setPixmap( Resource::loadPixmap( "start" ) ); 45 begin->setPixmap( Resource::loadPixmap( "start" ) );
46 begin->setAutoRaise( TRUE ); 46 begin->setAutoRaise( TRUE );
47 begin->setFixedSize( begin->sizeHint() ); 47 begin->setFixedSize( begin->sizeHint() );
48 QWhatsThis::add( begin, tr("Show January in the selected year") ); 48 QWhatsThis::add( begin, tr("Show January in the selected year") );
49 49
@@ -533,52 +533,52 @@ void DayItemMonth::paint( QPainter *p, const QColorGroup &cg,
533 p->save(); 533 p->save();
534 534
535 QColorGroup g( cg ); 535 QColorGroup g( cg );
536 g.setBrush( QColorGroup::Base, back ); 536 g.setBrush( QColorGroup::Base, back );
537 g.setColor( QColorGroup::Text, forg ); 537 g.setColor( QColorGroup::Text, forg );
538 if ( selected ) 538 if ( selected )
539 p->setPen( g.highlightedText() ); 539 p->setPen( g.highlightedText() );
540 else 540 else
541 p->setPen( g.text() ); 541 p->setPen( g.text() );
542 542
543 QValueStack<int> normalLine; 543 QValueStack<int> normalLine;
544 QValueStack<int> repeatLine; 544 QValueStack<int> repeatLine;
545 QValueStack<int> travelLine; 545 QValueStack<int> travelLine;
546 546
547 bool normalAllDay = FALSE; 547 bool normalAllDay = FALSE;
548 bool repeatAllDay = FALSE; 548 bool repeatAllDay = FALSE;
549 bool travelAllDay = FALSE; 549 bool travelAllDay = FALSE;
550 550
551 QValueListIterator<EffectiveEvent> itDays = d->mDayEvents.begin(); 551 QValueListIterator<EffectiveEvent> itDays = d->mDayEvents.begin();
552 552
553 for ( ; itDays != d->mDayEvents.end(); ++itDays ) { 553 for ( ; itDays != d->mDayEvents.end(); ++itDays ) {
554 int w = cr.width(); 554 int w = cr.width();
555 Event ev = (*itDays).event(); 555 Event ev = (*itDays).event();
556 556
557 int f = (*itDays).start().hour(); // assume Effective event 557 int f = (*itDays).start().hour(); // assume Effective event
558 int t = (*itDays).end().hour(); // is truncated. 558 int t = (*itDays).end().hour(); // is truncated.
559 559
560 if (ev.isAllDay()) { 560 if (ev.isAllDay()) {
561 if (!ev.hasRepeat()) 561 if (!ev.hasRepeat())
562 normalAllDay = TRUE; 562 normalAllDay = TRUE;
563 else 563 else
564 repeatAllDay = TRUE; 564 repeatAllDay = TRUE;
565 } else { 565 } else {
566 int sLine, eLine; 566 int sLine, eLine;
567 if (f == 0) 567 if (f == 0)
568 sLine = 0; 568 sLine = 0;
569 else if (f < 8 ) 569 else if (f < 8 )
570 sLine = 1; 570 sLine = 1;
571 else if (f >= 17) 571 else if (f >= 17)
572 sLine = w - 4; 572 sLine = w - 4;
573 else { 573 else {
574 sLine = (f - 8) * (w - 8); 574 sLine = (f - 8) * (w - 8);
575 if (sLine) 575 if (sLine)
576 sLine /= 8; 576 sLine /= 8;
577 sLine += 4; 577 sLine += 4;
578 } 578 }
579 if (t == 23) 579 if (t == 23)
580 eLine = w; 580 eLine = w;
581 else if (t < 8) 581 else if (t < 8)
582 eLine = 4; 582 eLine = 4;
583 else if (t >= 17) 583 else if (t >= 17)
584 eLine = w - 1; 584 eLine = w - 1;
@@ -594,51 +594,51 @@ void DayItemMonth::paint( QPainter *p, const QColorGroup &cg,
594 } else { 594 } else {
595 repeatLine.push(sLine); 595 repeatLine.push(sLine);
596 repeatLine.push(eLine); 596 repeatLine.push(eLine);
597 } 597 }
598 } 598 }
599 } 599 }
600 600
601 // draw the background 601 // draw the background
602 if (normalAllDay || repeatAllDay || travelAllDay) { 602 if (normalAllDay || repeatAllDay || travelAllDay) {
603 p->save(); 603 p->save();
604 604
605 if (normalAllDay) 605 if (normalAllDay)
606 if (repeatAllDay) { 606 if (repeatAllDay) {
607 p->fillRect( 0, 0, cr.width(), cr.height() / 2, 607 p->fillRect( 0, 0, cr.width(), cr.height() / 2,
608 colorNormalLight ); 608 colorNormalLight );
609 p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2, 609 p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2,
610 colorRepeatLight ); 610 colorRepeatLight );
611 } else 611 } else
612 p->fillRect( 0, 0, cr.width(), cr.height(), 612 p->fillRect( 0, 0, cr.width(), cr.height(),
613 colorNormalLight ); 613 colorNormalLight );
614 else if (repeatAllDay) 614 else if (repeatAllDay)
615 p->fillRect( 0, 0, cr.width(), cr.height(), 615 p->fillRect( 0, 0, cr.width(), cr.height(),
616 colorRepeatLight ); 616 colorRepeatLight );
617 } else { 617 } else {
618 p->fillRect( 0, 0, cr.width(), 618 p->fillRect( 0, 0, cr.width(),
619 cr.height(), selected 619 cr.height(), selected
620 ? g.brush( QColorGroup::Highlight ) 620 ? g.brush( QColorGroup::Highlight )
621 : g.brush( QColorGroup::Base ) ); 621 : g.brush( QColorGroup::Base ) );
622 } 622 }
623 623
624 // The lines 624 // The lines
625 // now for the lines. 625 // now for the lines.
626 int h = 5; 626 int h = 5;
627 int y = cr.height() / 2 - h; 627 int y = cr.height() / 2 - h;
628 628
629 while(normalLine.count() >= 2) { 629 while(normalLine.count() >= 2) {
630 int x2 = normalLine.pop(); 630 int x2 = normalLine.pop();
631 int x1 = normalLine.pop(); 631 int x1 = normalLine.pop();
632 if (x2 < x1 + 2) 632 if (x2 < x1 + 2)
633 x2 = x1 + 2; 633 x2 = x1 + 2;
634 p->fillRect(x1, y, x2 - x1, h, colorNormal); 634 p->fillRect(x1, y, x2 - x1, h, colorNormal);
635 } 635 }
636 636
637 y += h; 637 y += h;
638 638
639 while(repeatLine.count() >= 2) { 639 while(repeatLine.count() >= 2) {
640 int x2 = repeatLine.pop(); 640 int x2 = repeatLine.pop();
641 int x1 = repeatLine.pop(); 641 int x1 = repeatLine.pop();
642 if (x2 < x1 + 2) 642 if (x2 < x1 + 2)
643 x2 = x1 + 2; 643 x2 = x1 + 2;
644 p->fillRect(x1, y, x2 - x1, h, colorRepeat); 644 p->fillRect(x1, y, x2 - x1, h, colorRepeat);
@@ -712,39 +712,39 @@ void DateButton::pickDate()
712 712
713void DateButton::gotHide() 713void DateButton::gotHide()
714{ 714{
715 // we have to redo the button... 715 // we have to redo the button...
716 setDown( false ); 716 setDown( false );
717} 717}
718 718
719 719
720// void dateSelected( int year, int month, int day ); 720// void dateSelected( int year, int month, int day );
721 721
722void DateButton::setWeekStartsMonday( int b ) 722void DateButton::setWeekStartsMonday( int b )
723{ 723{
724 weekStartsMonday = b; 724 weekStartsMonday = b;
725} 725}
726 726
727void DateButton::setDate( int y, int m, int d ) 727void DateButton::setDate( int y, int m, int d )
728{ 728{
729 setDate( QDate( y,m,d) ); 729 setDate( QDate( y,m,d) );
730} 730}
731 731
732void DateButton::setDate( QDate d ) 732void DateButton::setDate( QDate d )
733{ 733{
734 currDate = d; 734 currDate = d;
735 setText( longFormat ? TimeString::longDateString( d, df ) : 735 setText( longFormat ? TimeString::longDateString( d, df ) :
736 TimeString::shortDate( d, df ) ); 736 TimeString::shortDate( d, df ) );
737 737
738} 738}
739 739
740void DateButton::setDateFormat( DateFormat f ) 740void DateButton::setDateFormat( DateFormat f )
741{ 741{
742 df = f; 742 df = f;
743 setDate( currDate ); 743 setDate( currDate );
744} 744}
745 745
746bool DateButton::customWhatsThis() const 746bool DateButton::customWhatsThis() const
747{ 747{
748 return TRUE; 748 return TRUE;
749} 749}
750 750