summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookday.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index 5474cfc..325b902 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -1,158 +1,159 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of 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 <qmessagebox.h> 20#include <qmessagebox.h>
21 21
22#include "datebookday.h" 22#include "datebookday.h"
23#include "datebookdayheaderimpl.h" 23#include "datebookdayheaderimpl.h"
24 24
25#include <qpe/datebookdb.h> 25#include <qpe/datebookdb.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/event.h> 27#include <qpe/event.h>
28#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
29#include <qpe/timestring.h> 29#include <qpe/timestring.h>
30#include <qpe/qpedebug.h> 30#include <qpe/qpedebug.h>
31#include <qpe/ir.h>
31 32
32#include <qheader.h> 33#include <qheader.h>
33#include <qdatetime.h> 34#include <qdatetime.h>
34#include <qpainter.h> 35#include <qpainter.h>
35#include <qsimplerichtext.h> 36#include <qsimplerichtext.h>
36#include <qpopupmenu.h> 37#include <qpopupmenu.h>
37#include <qtextcodec.h> 38#include <qtextcodec.h>
38#include <qpalette.h> 39#include <qpalette.h>
39 40
40#include <qtimer.h> 41#include <qtimer.h>
41 42
42DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, 43DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent,
43 const char *name ) 44 const char *name )
44 : QTable( 24, 1, parent, name ), 45 : QTable( 24, 1, parent, name ),
45 ampm( whichClock ) 46 ampm( whichClock )
46{ 47{
47 enableClipper(TRUE); 48 enableClipper(TRUE);
48 setTopMargin( 0 ); 49 setTopMargin( 0 );
49 horizontalHeader()->hide(); 50 horizontalHeader()->hide();
50 setLeftMargin(38); 51 setLeftMargin(38);
51 setColumnStretchable( 0, TRUE ); 52 setColumnStretchable( 0, TRUE );
52 setHScrollBarMode( QScrollView::AlwaysOff ); 53 setHScrollBarMode( QScrollView::AlwaysOff );
53 verticalHeader()->setPalette(white); 54 verticalHeader()->setPalette(white);
54 verticalHeader()->setResizeEnabled(FALSE); 55 verticalHeader()->setResizeEnabled(FALSE);
55 setSelectionMode( Single ); 56 setSelectionMode( Single );
56 57
57 // get rid of being able to edit things... 58 // get rid of being able to edit things...
58 QTableItem *tmp; 59 QTableItem *tmp;
59 int row; 60 int row;
60 for ( row = 0; row < numRows(); row++ ) { 61 for ( row = 0; row < numRows(); row++ ) {
61 tmp = new QTableItem( this, QTableItem::Never, QString::null); 62 tmp = new QTableItem( this, QTableItem::Never, QString::null);
62 setItem( row, 0, tmp ); 63 setItem( row, 0, tmp );
63 //setRowHeight( row, 40); 64 //setRowHeight( row, 40);
64 } 65 }
65 initHeader(); 66 initHeader();
66 QObject::connect( qApp, SIGNAL(clockChanged(bool)), 67 QObject::connect( qApp, SIGNAL(clockChanged(bool)),
67 this, SLOT(slotChangeClock(bool)) ); 68 this, SLOT(slotChangeClock(bool)) );
68} 69}
69 70
70void DateBookDayView::initHeader() 71void DateBookDayView::initHeader()
71{ 72{
72 QString strTmp; 73 QString strTmp;
73 for ( int i = 0; i < 24; ++i ) { 74 for ( int i = 0; i < 24; ++i ) {
74 if ( ampm ) { 75 if ( ampm ) {
75 if ( i == 0 ) 76 if ( i == 0 )
76 strTmp = QString::number(12) + ":00"; 77 strTmp = QString::number(12) + ":00";
77 else if ( i == 12 ) 78 else if ( i == 12 )
78 strTmp = QString::number(12) + tr(":00p"); 79 strTmp = QString::number(12) + tr(":00p");
79 else if ( i > 12 ) 80 else if ( i > 12 )
80 strTmp = QString::number( i - 12 ) + tr(":00p"); 81 strTmp = QString::number( i - 12 ) + tr(":00p");
81 else 82 else
82 strTmp = QString::number(i) + ":00"; 83 strTmp = QString::number(i) + ":00";
83 } else { 84 } else {
84 if ( i < 10 ) 85 if ( i < 10 )
85 strTmp = "0" + QString::number(i) + ":00"; 86 strTmp = "0" + QString::number(i) + ":00";
86 else 87 else
87 strTmp = QString::number(i) + ":00"; 88 strTmp = QString::number(i) + ":00";
88 } 89 }
89 strTmp = strTmp.rightJustify( 6, ' ' ); 90 strTmp = strTmp.rightJustify( 6, ' ' );
90 verticalHeader()->setLabel( i, strTmp ); 91 verticalHeader()->setLabel( i, strTmp );
91 setRowStretchable( i, FALSE ); 92 setRowStretchable( i, FALSE );
92 } 93 }
93} 94}
94 95
95void DateBookDayView::slotChangeClock( bool newClock ) 96void DateBookDayView::slotChangeClock( bool newClock )
96{ 97{
97 ampm = newClock; 98 ampm = newClock;
98 initHeader(); 99 initHeader();
99} 100}
100 101
101bool DateBookDayView::whichClock() const 102bool DateBookDayView::whichClock() const
102{ 103{
103 return ampm; 104 return ampm;
104} 105}
105 106
106void DateBookDayView::moveUp() 107void DateBookDayView::moveUp()
107{ 108{
108 scrollBy(0, -20); 109 scrollBy(0, -20);
109} 110}
110 111
111void DateBookDayView::moveDown() 112void DateBookDayView::moveDown()
112{ 113{
113 scrollBy(0, 20); 114 scrollBy(0, 20);
114} 115}
115 116
116void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool ) 117void DateBookDayView::paintCell( QPainter *p, int, int, const QRect &cr, bool )
117{ 118{
118 int w = cr.width(); 119 int w = cr.width();
119 int h = cr.height(); 120 int h = cr.height();
120 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) ); 121 p->fillRect( 0, 0, w, h, colorGroup().brush( QColorGroup::Base ) );
121 if ( showGrid() ) { 122 if ( showGrid() ) {
122 // Draw our lines 123 // Draw our lines
123 int x2 = w - 1; 124 int x2 = w - 1;
124 int y2 = h - 1; 125 int y2 = h - 1;
125 QPen pen( p->pen() ); 126 QPen pen( p->pen() );
126 p->setPen( colorGroup().dark() ); 127 p->setPen( colorGroup().dark() );
127 p->drawLine( x2, 0, x2, y2 ); 128 p->drawLine( x2, 0, x2, y2 );
128 p->drawLine( 0, y2, x2, y2 ); 129 p->drawLine( 0, y2, x2, y2 );
129 130
130 p->setPen( colorGroup().midlight() ); 131 p->setPen( colorGroup().midlight() );
131 p->drawLine( 0, y2 - h/2, x2, y2 - h/2); 132 p->drawLine( 0, y2 - h/2, x2, y2 - h/2);
132 133
133 p->setPen( pen ); 134 p->setPen( pen );
134 } 135 }
135} 136}
136 137
137void DateBookDayView::paintFocus( QPainter *, const QRect & ) 138void DateBookDayView::paintFocus( QPainter *, const QRect & )
138{ 139{
139} 140}
140 141
141 142
142void DateBookDayView::resizeEvent( QResizeEvent *e ) 143void DateBookDayView::resizeEvent( QResizeEvent *e )
143{ 144{
144 QTable::resizeEvent( e ); 145 QTable::resizeEvent( e );
145 columnWidthChanged( 0 ); 146 columnWidthChanged( 0 );
146 emit sigColWidthChanged(); 147 emit sigColWidthChanged();
147} 148}
148 149
149void DateBookDayView::keyPressEvent( QKeyEvent *e ) 150void DateBookDayView::keyPressEvent( QKeyEvent *e )
150{ 151{
151 QString txt = e->text(); 152 QString txt = e->text();
152 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) { 153 if ( !txt.isNull() && txt[0] > ' ' && e->key() < 0x1000 ) {
153 // we this is some sort of thing we know about... 154 // we this is some sort of thing we know about...
154 e->accept(); 155 e->accept();
155 emit sigCapturedKey( txt ); 156 emit sigCapturedKey( txt );
156 } else { 157 } else {
157 // I don't know what this key is, do you? 158 // I don't know what this key is, do you?
158 e->ignore(); 159 e->ignore();
@@ -597,200 +598,200 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e,
597 } 598 }
598 599
599 text = "<b>" + strDesc + "</b><br>" + "<i>" 600 text = "<b>" + strDesc + "</b><br>" + "<i>"
600 + strCat + "</i><br>"; 601 + strCat + "</i><br>";
601 if (ev.event().type() == Event::Normal ) 602 if (ev.event().type() == Event::Normal )
602 setEventText( text ); 603 setEventText( text );
603 else 604 else
604 setAllDayText( text ); 605 setAllDayText( text );
605 606
606 text += "<br><br>" + strNote; 607 text += "<br><br>" + strNote;
607 608
608 setBackgroundMode( PaletteBase ); 609 setBackgroundMode( PaletteBase );
609 610
610 QTime start = ev.start(); 611 QTime start = ev.start();
611 QTime end = ev.end(); 612 QTime end = ev.end();
612 int y = start.hour()*60+start.minute(); 613 int y = start.hour()*60+start.minute();
613 int h = end.hour()*60+end.minute()-y; 614 int h = end.hour()*60+end.minute()-y;
614 int rh = dateBook->dayView()->rowHeight(0); 615 int rh = dateBook->dayView()->rowHeight(0);
615 y = y*rh/60; 616 y = y*rh/60;
616 h = h*rh/60; 617 h = h*rh/60;
617 if ( h < 3 ) 618 if ( h < 3 )
618 h = 3; 619 h = 3;
619 geom.setY( y ); 620 geom.setY( y );
620 geom.setHeight( h ); 621 geom.setHeight( h );
621 geom.setX( 0 ); 622 geom.setX( 0 );
622 geom.setWidth(dateBook->dayView()->columnWidth(0)-1); 623 geom.setWidth(dateBook->dayView()->columnWidth(0)-1);
623 624
624} 625}
625void DateBookDayWidget::setAllDayText( QString &text ) { 626void DateBookDayWidget::setAllDayText( QString &text ) {
626 text += "<b>" + tr("This is an all day event.") + "</b><br>"; 627 text += "<b>" + tr("This is an all day event.") + "</b><br>";
627} 628}
628void DateBookDayWidget::setEventText( QString& text ) { 629void DateBookDayWidget::setEventText( QString& text ) {
629 bool whichClock = dateBook->dayView()->whichClock(); 630 bool whichClock = dateBook->dayView()->whichClock();
630 text += "<b>" + tr("Start") + "</b>: "; 631 text += "<b>" + tr("Start") + "</b>: ";
631 if ( ev.startDate() != ev.date() ) { 632 if ( ev.startDate() != ev.date() ) {
632 // multi-day event. Show start date 633 // multi-day event. Show start date
633 text += TimeString::longDateString( ev.startDate() ); 634 text += TimeString::longDateString( ev.startDate() );
634 } else { 635 } else {
635 // Show start time. 636 // Show start time.
636 text += TimeString::timeString( ev.start(), whichClock, FALSE ); 637 text += TimeString::timeString( ev.start(), whichClock, FALSE );
637 } 638 }
638 639
639 text += "<br><b>" + tr("End") + "</b>: "; 640 text += "<br><b>" + tr("End") + "</b>: ";
640 if ( ev.endDate() != ev.date() ) { 641 if ( ev.endDate() != ev.date() ) {
641 // multi-day event. Show end date 642 // multi-day event. Show end date
642 text += TimeString::longDateString( ev.endDate() ); 643 text += TimeString::longDateString( ev.endDate() );
643 } else { 644 } else {
644 // Show end time. 645 // Show end time.
645 text += TimeString::timeString( ev.end(), whichClock, FALSE ); 646 text += TimeString::timeString( ev.end(), whichClock, FALSE );
646 } 647 }
647 648
648} 649}
649 650
650DateBookDayWidget::~DateBookDayWidget() 651DateBookDayWidget::~DateBookDayWidget()
651{ 652{
652} 653}
653 654
654void DateBookDayWidget::paintEvent( QPaintEvent *e ) 655void DateBookDayWidget::paintEvent( QPaintEvent *e )
655{ 656{
656 QPainter p( this ); 657 QPainter p( this );
657 658
658 if (dateBook->getSelectedWidget() == this) 659 if (dateBook->getSelectedWidget() == this)
659 { 660 {
660 p.setBrush( QColor( 155, 240, 230 ) ); // selected item 661 p.setBrush( QColor( 155, 240, 230 ) ); // selected item
661 } else 662 } else
662 { 663 {
663 if (dateBook->date() == QDate::currentDate()) 664 if (dateBook->date() == QDate::currentDate())
664 { 665 {
665 QTime curTime = QTime::currentTime(); 666 QTime curTime = QTime::currentTime();
666 667
667 if (ev.end() < curTime) 668 if (ev.end() < curTime)
668 { 669 {
669 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive 670 p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive
670 } else 671 } else
671 { 672 {
672 //change color in dependence of the time till the event starts 673 //change color in dependence of the time till the event starts
673 int duration = curTime.secsTo(ev.start()); 674 int duration = curTime.secsTo(ev.start());
674 if (duration < 0) duration = 0; 675 if (duration < 0) duration = 0;
675 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift 676 int colChange = duration*160/86400; //86400: secs per day, 160: max color shift
676 677
677 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue 678 p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue
678 } 679 }
679 } else 680 } else
680 { 681 {
681 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) 682 p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date)
682 //perhaps make a distinction between future/past dates 683 //perhaps make a distinction between future/past dates
683 } 684 }
684 } 685 }
685 686
686 p.setPen( QColor(100, 100, 100) ); 687 p.setPen( QColor(100, 100, 100) );
687 p.drawRect(rect()); 688 p.drawRect(rect());
688 689
689 // p.drawRect(0,0, 5, height()); 690 // p.drawRect(0,0, 5, height());
690 691
691 int y = 0; 692 int y = 0;
692 int d = 0; 693 int d = 0;
693 694
694 if ( ev.event().hasAlarm() ) { 695 if ( ev.event().hasAlarm() ) {
695 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); 696 p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) );
696 y = 20; 697 y = 20;
697 d = 20; 698 d = 20;
698 } 699 }
699 700
700 if ( ev.event().hasRepeat() ) { 701 if ( ev.event().hasRepeat() ) {
701 p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); 702 p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) );
702 d = 20; 703 d = 20;
703 y += 20; 704 y += 20;
704 } 705 }
705 706
706 QSimpleRichText rt( text, font() ); 707 QSimpleRichText rt( text, font() );
707 rt.setWidth( geom.width() - d - 6 ); 708 rt.setWidth( geom.width() - d - 6 );
708 rt.draw( &p, 7, 0, e->region(), colorGroup() ); 709 rt.draw( &p, 7, 0, e->region(), colorGroup() );
709} 710}
710 711
711void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) 712void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
712{ 713{
713 DateBookDayWidget *item; 714 DateBookDayWidget *item;
714 715
715 item = dateBook->getSelectedWidget(); 716 item = dateBook->getSelectedWidget();
716 if (item) item->update(); 717 if (item) item->update();
717 718
718 dateBook->setSelectedWidget(this); 719 dateBook->setSelectedWidget(this);
719 update(); 720 update();
720 dateBook->repaint(); 721 dateBook->repaint();
721 722
722 QPopupMenu m; 723 QPopupMenu m;
723 m.insertItem( tr( "Edit" ), 1 ); 724 m.insertItem( tr( "Edit" ), 1 );
724 m.insertItem( tr( "Delete" ), 2 ); 725 m.insertItem( tr( "Delete" ), 2 );
725 m.insertItem( tr( "Beam" ), 3 ); 726 if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 );
726 int r = m.exec( e->globalPos() ); 727 int r = m.exec( e->globalPos() );
727 if ( r == 1 ) { 728 if ( r == 1 ) {
728 emit editMe( ev.event() ); 729 emit editMe( ev.event() );
729 } else if ( r == 2 ) { 730 } else if ( r == 2 ) {
730 emit deleteMe( ev.event() ); 731 emit deleteMe( ev.event() );
731 } else if ( r == 3 ) { 732 } else if ( r == 3 ) {
732 emit beamMe( ev.event() ); 733 emit beamMe( ev.event() );
733 } 734 }
734} 735}
735 736
736void DateBookDayWidget::setGeometry( const QRect &r ) 737void DateBookDayWidget::setGeometry( const QRect &r )
737{ 738{
738 geom = r; 739 geom = r;
739 setFixedSize( r.width()+1, r.height()+1 ); 740 setFixedSize( r.width()+1, r.height()+1 );
740 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); 741 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 );
741 show(); 742 show();
742} 743}
743 744
744 745
745//--------------------------------------------------------------------------------------------- 746//---------------------------------------------------------------------------------------------
746//--------------------------------------------------------------------------------------------- 747//---------------------------------------------------------------------------------------------
747 748
748 749
749DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) 750DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db )
750 : QWidget( db->dayView()->viewport() ), dateBook( db ) 751 : QWidget( db->dayView()->viewport() ), dateBook( db )
751{ 752{
752 setBackgroundMode( PaletteBase ); 753 setBackgroundMode( PaletteBase );
753} 754}
754 755
755DateBookDayTimeMarker::~DateBookDayTimeMarker() 756DateBookDayTimeMarker::~DateBookDayTimeMarker()
756{ 757{
757} 758}
758 759
759void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) 760void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ )
760{ 761{
761 QPainter p( this ); 762 QPainter p( this );
762 p.setBrush( QColor( 255, 0, 0 ) ); 763 p.setBrush( QColor( 255, 0, 0 ) );
763 764
764 QPen pen; 765 QPen pen;
765 pen.setStyle(NoPen); 766 pen.setStyle(NoPen);
766 767
767 p.setPen( pen ); 768 p.setPen( pen );
768 p.drawRect(rect()); 769 p.drawRect(rect());
769} 770}
770 771
771void DateBookDayTimeMarker::setTime( const QTime &t ) 772void DateBookDayTimeMarker::setTime( const QTime &t )
772{ 773{
773 int y = t.hour()*60+t.minute(); 774 int y = t.hour()*60+t.minute();
774 int rh = dateBook->dayView()->rowHeight(0); 775 int rh = dateBook->dayView()->rowHeight(0);
775 y = y*rh/60; 776 y = y*rh/60;
776 777
777 geom.setX( 0 ); 778 geom.setX( 0 );
778 779
779 int x = dateBook->dayView()->columnWidth(0)-1; 780 int x = dateBook->dayView()->columnWidth(0)-1;
780 geom.setWidth( x ); 781 geom.setWidth( x );
781 782
782 geom.setY( y ); 783 geom.setY( y );
783 geom.setHeight( 1 ); 784 geom.setHeight( 1 );
784 785
785 setGeometry( geom ); 786 setGeometry( geom );
786 787
787 time = t; 788 time = t;
788} 789}
789 790
790void DateBookDayTimeMarker::setGeometry( const QRect &r ) 791void DateBookDayTimeMarker::setGeometry( const QRect &r )
791{ 792{
792 geom = r; 793 geom = r;
793 setFixedSize( r.width()+1, r.height()+1 ); 794 setFixedSize( r.width()+1, r.height()+1 );
794 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); 795 dateBook->dayView()->moveChild( this, r.x(), r.y()-1 );
795 show(); 796 show();
796} 797}