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 | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/core/pim/today/plugins/datebook/datebookevent.cpp b/core/pim/today/plugins/datebook/datebookevent.cpp index 3c1e97a..e595047 100644 --- a/core/pim/today/plugins/datebook/datebookevent.cpp +++ b/core/pim/today/plugins/datebook/datebookevent.cpp | |||
@@ -1,12 +1,12 @@ | |||
1 | /* | 1 | /* |
2 | * datebookevent.cpp | 2 | * datebookevent.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002 by Maximilian Reiß | 4 | * copyright : (c) 2002, 2003 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 * |
@@ -14,25 +14,27 @@ | |||
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | #include "datebookevent.h" | 17 | #include "datebookevent.h" |
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qpe/timestring.h> | 19 | #include <qpe/timestring.h> |
20 | #include <qpe/qcopenvelope_qws.h> | 20 | #include <qpe/qcopenvelope_qws.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/calendar.h> | ||
22 | 23 | ||
23 | #include <opie/odevice.h> | 24 | #include <opie/odevice.h> |
24 | 25 | ||
25 | using namespace Opie; | 26 | using namespace Opie; |
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, |
32 | bool timeExtraLine, | ||
31 | int maxCharClip, | 33 | int maxCharClip, |
32 | const char* name, | 34 | const char* name, |
33 | WFlags fl) : | 35 | WFlags fl) : |
34 | OClickableLabel(parent,name,fl), event(ev) { | 36 | OClickableLabel(parent,name,fl), event(ev) { |
35 | 37 | ||
36 | // setAlignment( AlignTop ); | 38 | // setAlignment( AlignTop ); |
37 | 39 | ||
38 | QString msg; | 40 | QString msg; |
@@ -47,27 +49,35 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | |||
47 | msg += " <b>" + tr("[with alarm]") +"</b>"; | 49 | msg += " <b>" + tr("[with alarm]") +"</b>"; |
48 | } | 50 | } |
49 | 51 | ||
50 | // include location or not | 52 | // include location or not |
51 | if ( show_location ) { | 53 | if ( show_location ) { |
52 | msg += "<BR><i>" + (ev).location() + "</i>"; | 54 | msg += "<BR><i>" + (ev).location() + "</i>"; |
53 | } | 55 | } |
54 | 56 | ||
57 | QString timeSpacer = " "; | ||
58 | if ( timeExtraLine ) { | ||
59 | timeSpacer = "<br>"; | ||
60 | } | ||
61 | |||
55 | if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" ) | 62 | if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" ) |
56 | && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) { | 63 | && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) { |
57 | msg += "<br>All day"; | 64 | msg += tr ( "All day" ); |
58 | } else { | 65 | } else { |
59 | // start time of event | 66 | // start time of event |
60 | QDate tempDate = (ev).event().start().date(); | 67 | // QDate tempDate = (ev).event().start().date(); |
61 | msg += "<br>" | 68 | msg += timeSpacer; |
62 | + ampmTime( QTime( (ev).event().start().time() ) ) | 69 | msg += ampmTime( QTime( (ev).event().start().time() ) ) |
63 | // end time of event | 70 | // end time of event |
64 | + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) ) | 71 | + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) ); |
65 | + differDate( tempDate ); | 72 | } |
73 | |||
74 | if ( (ev).date() != QDate::currentDate() ) { | ||
75 | msg += differDate( (ev).date() /* tempDate*/ ); | ||
66 | } | 76 | } |
67 | 77 | ||
68 | // include possible note or not | 78 | // include possible note or not |
69 | if ( show_notes ) { | 79 | if ( show_notes ) { |
70 | msg += "<br> <i>" + tr("note") + "</i>:" +( (ev).notes() ).mid( 0, maxCharClip ); | 80 | msg += "<br> <i>" + tr("note") + "</i>:" +( (ev).notes() ).mid( 0, maxCharClip ); |
71 | } | 81 | } |
72 | setText( msg ); | 82 | setText( msg ); |
73 | connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) ); | 83 | connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) ); |
@@ -96,42 +106,42 @@ QString DateBookEvent::ampmTime( QTime tm ) { | |||
96 | return s; | 106 | return s; |
97 | } else { | 107 | } else { |
98 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 108 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
99 | return s; | 109 | return s; |
100 | } | 110 | } |
101 | } | 111 | } |
102 | 112 | ||
103 | QString DateBookEvent::differDate( QDate date ) { | 113 | QString DateBookEvent::differDate( QDate date ) { |
104 | QDate currentDate = QDate::currentDate(); | 114 | // QDate currentDate = QDate::currentDate(); |
105 | QString returnText = "<font color = #407DD9><b> "; | 115 | QString returnText = "<font color = #407DD9><b> "; |
106 | int differDate = currentDate.daysTo( date ); | 116 | // int differDate = currentDate.daysTo( date ); |
107 | if ( currentDate.dayOfWeek() == date.dayOfWeek() ) { | 117 | // if ( currentDate.dayOfWeek() == date.dayOfWeek() ) { |
108 | returnText += "" ; | 118 | // returnText += "" ; |
109 | // not working right for recurring events | 119 | // // not working right for recurring events |
110 | //} else if ( differDate == 1 ) { | 120 | // //} else if ( differDate == 1 ) { |
111 | //returnText += tr( "tomorrow" ); | 121 | // //returnText += tr( "tomorrow" ); |
112 | } else { | 122 | // } else { |
113 | //returnText += tr( "in %1 days" ).arg( differDate ); | 123 | // returnText += " [ " + Calendar::nameOfDay( date.dayOfWeek() ) + " ] "; |
114 | returnText += " [ " + date.dayName( date.dayOfWeek() ) + " ] "; | 124 | // } |
115 | } | 125 | returnText += " [ " + Calendar::nameOfDay( date.dayOfWeek() ) + " ] "; |
116 | returnText += "</b></font>"; | 126 | returnText += "</b></font>"; |
117 | return returnText; | 127 | return returnText; |
118 | } | 128 | } |
119 | 129 | ||
120 | 130 | ||
121 | /** | 131 | /** |
122 | * starts the edit dialog as known from datebook | 132 | * starts the edit dialog as known from datebook |
123 | */ | 133 | */ |
124 | void DateBookEvent::editEventSlot( const Event &e ) { | 134 | void DateBookEvent::editEventSlot( const Event &e ) { |
125 | 135 | ||
126 | if ( ODevice::inst()->system() == System_Zaurus ) { | 136 | if ( ODevice::inst()->system() == System_Zaurus ) { |
127 | QCopEnvelope env( "QPE/Application/datebook", "raise()" ); | 137 | QCopEnvelope env( "QPE/Application/datebook", "raise()" ); |
128 | } else { | 138 | } else { |
129 | QCopEnvelope env( "QPE/Datebook", "editEvent(int)" ); | 139 | QCopEnvelope env( "QPE/Application/datebook", "editEvent(int)" ); |
130 | env << e.uid(); | 140 | env << e.uid(); |
131 | } | 141 | } |
132 | } | 142 | } |
133 | 143 | ||
134 | 144 | ||
135 | void DateBookEvent::editMe() { | 145 | void DateBookEvent::editMe() { |
136 | emit editEvent( event.event() ); | 146 | emit editEvent( event.event() ); |
137 | } | 147 | } |