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 | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/core/pim/today/plugins/datebook/datebookevent.cpp b/core/pim/today/plugins/datebook/datebookevent.cpp new file mode 100644 index 0000000..1caf061 --- a/dev/null +++ b/core/pim/today/plugins/datebook/datebookevent.cpp | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | * datebookevent.cpp | ||
3 | * | ||
4 | * copyright : (c) 2002 by Maximilian Reiß | ||
5 | * email : harlekin@handhelds.org | ||
6 | * | ||
7 | */ | ||
8 | /*************************************************************************** | ||
9 | * * | ||
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 * | ||
12 | * the Free Software Foundation; either version 2 of the License, or * | ||
13 | * (at your option) any later version. * | ||
14 | * * | ||
15 | ***************************************************************************/ | ||
16 | |||
17 | #include "datebookevent.h" | ||
18 | #include <qpe/config.h> | ||
19 | #include <qpe/timestring.h> | ||
20 | #include <qpe/qcopenvelope_qws.h> | ||
21 | #include <qpe/qpeapplication.h> | ||
22 | |||
23 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | ||
24 | QWidget* parent, | ||
25 | int show_location, | ||
26 | int show_notes, | ||
27 | // int onlyLater, | ||
28 | int maxCharClip, | ||
29 | const char* name, | ||
30 | WFlags fl) : | ||
31 | OClickableLabel(parent,name,fl), event(ev) { | ||
32 | |||
33 | QString msg; | ||
34 | |||
35 | Config config( "qpe" ); | ||
36 | config.setGroup( "Time" ); | ||
37 | // if 24 h format | ||
38 | ampm = config.readBoolEntry( "AMPM", TRUE ); | ||
39 | |||
40 | msg += "<B>" + (ev).description() + "</B>"; | ||
41 | if ( (ev).event().hasAlarm() ) { | ||
42 | msg += " <b>[with alarm]</b>"; | ||
43 | } | ||
44 | |||
45 | // include location or not | ||
46 | if ( show_location == 1) { | ||
47 | msg += "<BR><i>" + (ev).location() + "</i>"; | ||
48 | } | ||
49 | |||
50 | if ( ( TimeString::timeString( QTime( (ev).event().start().time() ) ) == "00:00" ) | ||
51 | && ( TimeString::timeString( QTime( (ev).event().end().time() ) ) == "23:59") ) { | ||
52 | msg += "<br>All day"; | ||
53 | } else { | ||
54 | // start time of event | ||
55 | msg += "<br>" + ampmTime(QTime( (ev).event().start().time() ) ) | ||
56 | // end time of event | ||
57 | + "<b> - </b>" + ampmTime(QTime( (ev).event().end().time() ) ); | ||
58 | } | ||
59 | |||
60 | // include possible note or not | ||
61 | if ( show_notes == 1) { | ||
62 | msg += "<br> <i>note</i>:" +( (ev).notes() ).mid( 0, maxCharClip ); | ||
63 | } | ||
64 | |||
65 | setText( msg ); | ||
66 | connect( this, SIGNAL( clicked() ), this, SLOT( editMe() ) ); | ||
67 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | ||
68 | } | ||
69 | |||
70 | |||
71 | QString DateBookEvent::ampmTime( QTime tm ) { | ||
72 | |||
73 | QString s; | ||
74 | if( ampm ) { | ||
75 | int hour = tm.hour(); | ||
76 | if ( hour == 0 ) { | ||
77 | hour = 12; | ||
78 | } | ||
79 | if ( hour > 12 ) { | ||
80 | hour -= 12; | ||
81 | } | ||
82 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | ||
83 | (tm.hour() >= 12) ? "PM" : "AM" ); | ||
84 | return s; | ||
85 | } else { | ||
86 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | ||
87 | return s; | ||
88 | } | ||
89 | |||
90 | } | ||
91 | |||
92 | |||
93 | //extern QPEApplication *todayApp; | ||
94 | |||
95 | /* | ||
96 | * starts the edit dialog as known from datebook | ||
97 | */ | ||
98 | void DateBookEvent::editEventSlot( const Event &e ) { | ||
99 | startDatebook(); | ||
100 | |||
101 | while( !QCopChannel::isRegistered( "QPE/Datebook" ) ) qApp->processEvents(); | ||
102 | QCopEnvelope env( "QPE/Datebook", "editEvent(int)" ); | ||
103 | env << e.uid(); | ||
104 | } | ||
105 | |||
106 | |||
107 | /** | ||
108 | * launches datebook | ||
109 | */ | ||
110 | void DateBookEvent::startDatebook() { | ||
111 | QCopEnvelope e("QPE/System", "execute(QString)"); | ||
112 | e << QString("datebook"); | ||
113 | } | ||
114 | |||
115 | void DateBookEvent::editMe() { | ||
116 | emit editEvent(event.event()); | ||
117 | } | ||
118 | |||