Diffstat (limited to 'core/pim/today/plugins/datebook/datebookevent.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/today/plugins/datebook/datebookevent.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/pim/today/plugins/datebook/datebookevent.cpp b/core/pim/today/plugins/datebook/datebookevent.cpp index 9a820f2..f5b0d0a 100644 --- a/core/pim/today/plugins/datebook/datebookevent.cpp +++ b/core/pim/today/plugins/datebook/datebookevent.cpp | |||
@@ -1,121 +1,122 @@ | |||
1 | /* | 1 | /* |
2 | * datebookevent.cpp | 2 | * datebookevent.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002, 2003, 2004 by Maximilian Reiß | 4 | * copyright : (c) 2002, 2003, 2004 by Maximilian Reiß |
5 | * email : harlekin@handhelds.org | 5 | * email : harlekin@handhelds.org |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | #include "datebookevent.h" | 17 | #include "datebookevent.h" |
18 | 18 | ||
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | #include <qpe/qcopenvelope_qws.h> | 20 | #include <qpe/qcopenvelope_qws.h> |
21 | #include <qpe/calendar.h> | 21 | #include <qpe/calendar.h> |
22 | 22 | ||
23 | #include <opie2/odevice.h> | 23 | #include <opie2/odevice.h> |
24 | 24 | ||
25 | using namespace Opie; | 25 | using namespace Opie::Ui; |
26 | using namespace Opie::Core; | ||
26 | 27 | ||
27 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | 28 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, |
28 | QWidget* parent, | 29 | QWidget* parent, |
29 | bool show_location, | 30 | bool show_location, |
30 | bool show_notes, | 31 | bool show_notes, |
31 | bool timeExtraLine, | 32 | bool timeExtraLine, |
32 | int maxCharClip, | 33 | int maxCharClip, |
33 | const char* name, | 34 | const char* name, |
34 | WFlags fl) : | 35 | WFlags fl) : |
35 | OClickableLabel(parent,name,fl), event(ev) { | 36 | OClickableLabel(parent,name,fl), event(ev) { |
36 | 37 | ||
37 | // setAlignment( AlignTop ); | 38 | // setAlignment( AlignTop ); |
38 | 39 | ||
39 | QString msg; | 40 | QString msg; |
40 | 41 | ||
41 | Config config( "qpe" ); | 42 | Config config( "qpe" ); |
42 | config.setGroup( "Time" ); | 43 | config.setGroup( "Time" ); |
43 | // if 24 h format | 44 | // if 24 h format |
44 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 45 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
45 | 46 | ||
46 | msg += "<B>" + (ev).description() + "</B>"; | 47 | msg += "<B>" + (ev).description() + "</B>"; |
47 | if ( (ev).event().hasAlarm() ) { | 48 | if ( (ev).event().hasAlarm() ) { |
48 | msg += " <b>" + tr("[with alarm]") +"</b>"; | 49 | msg += " <b>" + tr("[with alarm]") +"</b>"; |
49 | } | 50 | } |
50 | 51 | ||
51 | // include location or not | 52 | // include location or not |
52 | if ( show_location ) { | 53 | if ( show_location ) { |
53 | msg += "<BR><i>" + (ev).location() + "</i>"; | 54 | msg += "<BR><i>" + (ev).location() + "</i>"; |
54 | } | 55 | } |
55 | 56 | ||
56 | QString timeSpacer = " "; | 57 | QString timeSpacer = " "; |
57 | if ( timeExtraLine ) { | 58 | if ( timeExtraLine ) { |
58 | timeSpacer = "<br>"; | 59 | timeSpacer = "<br>"; |
59 | } | 60 | } |
60 | 61 | ||
61 | if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" ) | 62 | if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" ) |
62 | && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) { | 63 | && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) { |
63 | msg += tr ( "All day" ); | 64 | msg += tr ( "All day" ); |
64 | } else { | 65 | } else { |
65 | // start time of event | 66 | // start time of event |
66 | // QDate tempDate = (ev).event().start().date(); | 67 | // QDate tempDate = (ev).event().start().date(); |
67 | msg += timeSpacer; | 68 | msg += timeSpacer; |
68 | msg += ampmTime( QTime( (ev).event().start().time() ) ) | 69 | msg += ampmTime( QTime( (ev).event().start().time() ) ) |
69 | // end time of event | 70 | // end time of event |
70 | + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) ); | 71 | + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) ); |
71 | } | 72 | } |
72 | 73 | ||
73 | if ( (ev).date() != QDate::currentDate() ) { | 74 | if ( (ev).date() != QDate::currentDate() ) { |
74 | msg += differDate( (ev).date() /* tempDate*/ ); | 75 | msg += differDate( (ev).date() /* tempDate*/ ); |
75 | } | 76 | } |
76 | 77 | ||
77 | // include possible note or not | 78 | // include possible note or not |
78 | if ( show_notes ) { | 79 | if ( show_notes ) { |
79 | msg += "<br> <i>" + tr("note") + "</i>:" +( (ev).notes() ).mid( 0, maxCharClip ); | 80 | msg += "<br> <i>" + tr("note") + "</i>:" +( (ev).notes() ).mid( 0, maxCharClip ); |
80 | } | 81 | } |
81 | setText( msg ); | 82 | setText( msg ); |
82 | connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) ); | 83 | connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) ); |
83 | } | 84 | } |
84 | 85 | ||
85 | DateBookEvent::~DateBookEvent() { | 86 | DateBookEvent::~DateBookEvent() { |
86 | } | 87 | } |
87 | 88 | ||
88 | /** | 89 | /** |
89 | * AM/PM timestring conversion. | 90 | * AM/PM timestring conversion. |
90 | * @param tm the timestring | 91 | * @param tm the timestring |
91 | * @return formatted to am/pm is system is set to it | 92 | * @return formatted to am/pm is system is set to it |
92 | */ | 93 | */ |
93 | QString DateBookEvent::ampmTime( QTime tm ) { | 94 | QString DateBookEvent::ampmTime( QTime tm ) { |
94 | QString s; | 95 | QString s; |
95 | if( ampm ) { | 96 | if( ampm ) { |
96 | int hour = tm.hour(); | 97 | int hour = tm.hour(); |
97 | if ( hour == 0 ) { | 98 | if ( hour == 0 ) { |
98 | hour = 12; | 99 | hour = 12; |
99 | } | 100 | } |
100 | if ( hour > 12 ) { | 101 | if ( hour > 12 ) { |
101 | hour -= 12; | 102 | hour -= 12; |
102 | } | 103 | } |
103 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 104 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
104 | (tm.hour() >= 12) ? "PM" : "AM" ); | 105 | (tm.hour() >= 12) ? "PM" : "AM" ); |
105 | return s; | 106 | return s; |
106 | } else { | 107 | } else { |
107 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 108 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
108 | return s; | 109 | return s; |
109 | } | 110 | } |
110 | } | 111 | } |
111 | 112 | ||
112 | QString DateBookEvent::differDate( QDate date ) { | 113 | QString DateBookEvent::differDate( QDate date ) { |
113 | // QDate currentDate = QDate::currentDate(); | 114 | // QDate currentDate = QDate::currentDate(); |
114 | QString returnText = "<font color = #407DD9><b> "; | 115 | QString returnText = "<font color = #407DD9><b> "; |
115 | // int differDate = currentDate.daysTo( date ); | 116 | // int differDate = currentDate.daysTo( date ); |
116 | // if ( currentDate.dayOfWeek() == date.dayOfWeek() ) { | 117 | // if ( currentDate.dayOfWeek() == date.dayOfWeek() ) { |
117 | // returnText += "" ; | 118 | // returnText += "" ; |
118 | // // not working right for recurring events | 119 | // // not working right for recurring events |
119 | // //} else if ( differDate == 1 ) { | 120 | // //} else if ( differDate == 1 ) { |
120 | // //returnText += tr( "tomorrow" ); | 121 | // //returnText += tr( "tomorrow" ); |
121 | // } else { | 122 | // } else { |