author | leseb <leseb> | 2002-07-09 16:50:46 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-07-09 16:50:46 (UTC) |
commit | 5f549398401acc5591ffcb67459dbf55ea323b91 (patch) (unidiff) | |
tree | d7c8846531a263acfb5bdafbae24fc7cfbbce170 | |
parent | 235f43313ac455b0240c5ab4d5a50f75f488edfd (diff) | |
download | opie-5f549398401acc5591ffcb67459dbf55ea323b91.zip opie-5f549398401acc5591ffcb67459dbf55ea323b91.tar.gz opie-5f549398401acc5591ffcb67459dbf55ea323b91.tar.bz2 |
Check for Ir support
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 3 |
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,94 +1,95 @@ | |||
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 | ||
42 | DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, | 43 | DateBookDayView::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 | ||
70 | void DateBookDayView::initHeader() | 71 | void 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 | ||
@@ -661,129 +662,129 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e ) | |||
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 | ||
711 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) | 712 | void 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 | ||
736 | void DateBookDayWidget::setGeometry( const QRect &r ) | 737 | void 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 | ||
749 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) | 750 | DateBookDayTimeMarker::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 | ||
755 | DateBookDayTimeMarker::~DateBookDayTimeMarker() | 756 | DateBookDayTimeMarker::~DateBookDayTimeMarker() |
756 | { | 757 | { |
757 | } | 758 | } |
758 | 759 | ||
759 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) | 760 | void 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 | ||
771 | void DateBookDayTimeMarker::setTime( const QTime &t ) | 772 | void 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 | ||