summaryrefslogtreecommitdiff
path: root/core/pim/today/plugins/datebook/datebookevent.cpp
Unidiff
Diffstat (limited to 'core/pim/today/plugins/datebook/datebookevent.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/today/plugins/datebook/datebookevent.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/core/pim/today/plugins/datebook/datebookevent.cpp b/core/pim/today/plugins/datebook/datebookevent.cpp
index 0a0d186..8277529 100644
--- a/core/pim/today/plugins/datebook/datebookevent.cpp
+++ b/core/pim/today/plugins/datebook/datebookevent.cpp
@@ -36,81 +36,101 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
36 setAlignment( AlignTop ); 36 setAlignment( AlignTop );
37 37
38 QString msg; 38 QString msg;
39 39
40 Config config( "qpe" ); 40 Config config( "qpe" );
41 config.setGroup( "Time" ); 41 config.setGroup( "Time" );
42 // if 24 h format 42 // if 24 h format
43 ampm = config.readBoolEntry( "AMPM", TRUE ); 43 ampm = config.readBoolEntry( "AMPM", TRUE );
44 44
45 msg += "<B>" + (ev).description() + "</B>"; 45 msg += "<B>" + (ev).description() + "</B>";
46 if ( (ev).event().hasAlarm() ) { 46 if ( (ev).event().hasAlarm() ) {
47 msg += " <b>[with alarm]</b>"; 47 msg += " <b>[with alarm]</b>";
48 } 48 }
49 49
50 // include location or not 50 // include location or not
51 if ( show_location ) { 51 if ( show_location ) {
52 msg += "<BR><i>" + (ev).location() + "</i>"; 52 msg += "<BR><i>" + (ev).location() + "</i>";
53 } 53 }
54 54
55 if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" ) 55 if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" )
56 && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) { 56 && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59" ) ) {
57 msg += "<br>All day"; 57 msg += "<br>All day";
58 } else { 58 } else {
59 // start time of event 59 // start time of event
60 msg += "<br>" + ampmTime(QTime( (ev).event().start().time() ) ) 60 QDate tempDate = (ev).event().start().date();
61 msg += "<br>"
62 + ampmTime( QTime( (ev).event().start().time() ) )
61 // end time of event 63 // end time of event
62 + "<b> - </b>" + ampmTime(QTime( (ev).event().end().time() ) ); 64 + "<b> - </b>" + ampmTime( QTime( (ev).event().end().time() ) )
65 + differDate( tempDate );
63 } 66 }
64 67
65 // include possible note or not 68 // include possible note or not
66 if ( show_notes ) { 69 if ( show_notes ) {
67 msg += "<br> <i>note</i>:" +( (ev).notes() ).mid( 0, maxCharClip ); 70 msg += "<br> <i>note</i>:" +( (ev).notes() ).mid( 0, maxCharClip );
68 } 71 }
69 setText( msg ); 72 setText( msg );
70 connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) ); 73 connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) );
71} 74}
72 75
73 76
74/** 77/**
75 * AM/PM timestring conversion. 78 * AM/PM timestring conversion.
76 * @param tm the timestring 79 * @param tm the timestring
77 * @return formatted to am/pm is system is set to it 80 * @return formatted to am/pm is system is set to it
78 */ 81 */
79QString DateBookEvent::ampmTime( QTime tm ) { 82QString DateBookEvent::ampmTime( QTime tm ) {
80 QString s; 83 QString s;
81 if( ampm ) { 84 if( ampm ) {
82 int hour = tm.hour(); 85 int hour = tm.hour();
83 if ( hour == 0 ) { 86 if ( hour == 0 ) {
84 hour = 12; 87 hour = 12;
85 } 88 }
86 if ( hour > 12 ) { 89 if ( hour > 12 ) {
87 hour -= 12; 90 hour -= 12;
88 } 91 }
89 s.sprintf( "%2d:%02d %s", hour, tm.minute(), 92 s.sprintf( "%2d:%02d %s", hour, tm.minute(),
90 (tm.hour() >= 12) ? "PM" : "AM" ); 93 (tm.hour() >= 12) ? "PM" : "AM" );
91 return s; 94 return s;
92 } else { 95 } else {
93 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); 96 s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
94 return s; 97 return s;
95 } 98 }
96} 99}
97 100
101QString DateBookEvent::differDate( QDate date ) {
102 QDate currentDate = QDate::currentDate();
103 QString returnText = "<font color = #407DD9><b> ";
104 int differDate = currentDate.daysTo( date );
105 if ( currentDate.dayOfWeek() == date.dayOfWeek() ) {
106 returnText += "" ;
107 // not working right for recurring events
108 //} else if ( differDate == 1 ) {
109 //returnText += tr( "tomorrow" );
110 } else {
111 //returnText += tr( "in %1 days" ).arg( differDate );
112 returnText += " [ " + date.dayName( date.dayOfWeek() ) + " ] ";
113 }
114 returnText += "</b></font>";
115 return returnText;
116}
117
98 118
99/** 119/**
100 * starts the edit dialog as known from datebook 120 * starts the edit dialog as known from datebook
101 */ 121 */
102void DateBookEvent::editEventSlot( const Event &e ) { 122void DateBookEvent::editEventSlot( const Event &e ) {
103 123
104 if ( ODevice::inst()->system() == System_Zaurus ) { 124 if ( ODevice::inst()->system() == System_Zaurus ) {
105 QCopEnvelope env( "QPE/Application/datebook", "raise()" ); 125 QCopEnvelope env( "QPE/Application/datebook", "raise()" );
106 } else { 126 } else {
107 QCopEnvelope env( "QPE/Datebook", "editEvent(int)" ); 127 QCopEnvelope env( "QPE/Datebook", "editEvent(int)" );
108 env << e.uid(); 128 env << e.uid();
109 } 129 }
110} 130}
111 131
112 132
113void DateBookEvent::editMe() { 133void DateBookEvent::editMe() {
114 emit editEvent( event.event() ); 134 emit editEvent( event.event() );
115} 135}
116 136