Diffstat (limited to 'core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp index 797f766..881e8f1 100644 --- a/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp +++ b/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp | |||
@@ -1,85 +1,98 @@ | |||
1 | #include "datebookweeklstevent.h" | 1 | #include "datebookweeklstevent.h" |
2 | #include "datebooktypes.h" | 2 | #include "datebooktypes.h" |
3 | 3 | ||
4 | #include <opie2/odebug.h> | 4 | #include <opie2/odebug.h> |
5 | 5 | ||
6 | #include <qpe/ir.h> | 6 | #include <qpe/ir.h> |
7 | 7 | ||
8 | #include <qstring.h> | 8 | #include <qstring.h> |
9 | #include <qpopupmenu.h> | 9 | #include <qpopupmenu.h> |
10 | 10 | ||
11 | DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, | 11 | DateBookWeekLstEvent::DateBookWeekLstEvent(bool ap, const EffectiveEvent &ev, |
12 | int weeklistviewconfig, | 12 | int weeklistviewconfig, |
13 | QWidget* parent, | 13 | QWidget* parent, |
14 | const char* name, | 14 | const char* name, |
15 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) | 15 | WFlags fl ) : OClickableLabel(parent,name,fl), event(ev), ampm(ap) |
16 | { | 16 | { |
17 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", | 17 | // old values... lastday = "__|__", middle=" |---", Firstday="00:00", |
18 | QString s,start,middle,end,day; | 18 | QString s,start,middle,end,day; |
19 | 19 | ||
20 | odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; | 20 | odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; |
21 | if(weeklistviewconfig==NONE) { // No times displayed. | 21 | if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. |
22 | // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | 22 | if ( ampm ) { |
23 | // middle.sprintf("<--->"); | 23 | int shour = ev.start().hour(); |
24 | // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | 24 | int smin = ev.start().minute(); |
25 | // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | 25 | if ( shour >= 12 ) { |
26 | } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. | 26 | if ( shour > 12 ) { |
27 | shour -= 12; | ||
28 | } | ||
29 | start.sprintf( "%.2d:%.2d PM", shour, smin ); | ||
30 | day.sprintf("%.2d:%.2d PM",shour,smin); | ||
31 | } else { | ||
32 | if ( shour == 0 ) { | ||
33 | shour = 12; | ||
34 | } | ||
35 | start.sprintf( "%.2d:%.2d AM", shour, smin ); | ||
36 | day.sprintf("%.2d:%.2d AM",shour,smin); | ||
37 | } | ||
38 | } else { | ||
27 | start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | 39 | start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); |
40 | day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | ||
41 | } | ||
28 | middle.sprintf(" |---"); | 42 | middle.sprintf(" |---"); |
29 | end.sprintf("__|__"); | 43 | end.sprintf("__|__"); |
30 | day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); | ||
31 | } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. | 44 | } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. |
32 | start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); | 45 | start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); |
33 | middle.sprintf("<--->"); | 46 | middle.sprintf("<--->"); |
34 | end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); | 47 | end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); |
35 | day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); | 48 | day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); |
36 | } | 49 | } |
37 | 50 | ||
38 | if(ev.event().type() == Event::Normal) { | 51 | if(ev.event().type() == Event::Normal) { |
39 | if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. | 52 | if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. |
40 | s=day; | 53 | s=day; |
41 | } else if(ev.startDate()==ev.date()) { // start event. | 54 | } else if(ev.startDate()==ev.date()) { // start event. |
42 | s=start; | 55 | s=start; |
43 | } else if(ev.endDate()==ev.date()) { // end event. | 56 | } else if(ev.endDate()==ev.date()) { // end event. |
44 | s=end; | 57 | s=end; |
45 | } else { // middle day. | 58 | } else { // middle day. |
46 | s=middle; | 59 | s=middle; |
47 | } | 60 | } |
48 | } else { | 61 | } else { |
49 | s=""; | 62 | s=""; |
50 | } | 63 | } |
51 | setText(QString(s) + " " + ev.description()); | 64 | setText(QString(s) + " " + ev.description()); |
52 | // connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 65 | // connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
53 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 66 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
54 | } | 67 | } |
55 | void DateBookWeekLstEvent::editMe() { | 68 | void DateBookWeekLstEvent::editMe() { |
56 | emit editEvent(event.event()); | 69 | emit editEvent(event.event()); |
57 | } | 70 | } |
58 | void DateBookWeekLstEvent::duplicateMe() | 71 | void DateBookWeekLstEvent::duplicateMe() |
59 | { | 72 | { |
60 | emit duplicateEvent(event.event()); | 73 | emit duplicateEvent(event.event()); |
61 | } | 74 | } |
62 | void DateBookWeekLstEvent::deleteMe() | 75 | void DateBookWeekLstEvent::deleteMe() |
63 | { | 76 | { |
64 | emit removeEvent(event.event()); | 77 | emit removeEvent(event.event()); |
65 | emit redraw(); | 78 | emit redraw(); |
66 | } | 79 | } |
67 | void DateBookWeekLstEvent::beamMe() | 80 | void DateBookWeekLstEvent::beamMe() |
68 | { | 81 | { |
69 | emit beamEvent( event.event() ); | 82 | emit beamEvent( event.event() ); |
70 | } | 83 | } |
71 | void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) | 84 | void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) |
72 | { | 85 | { |
73 | if (!event.event().isValidUid()) { | 86 | if (!event.event().isValidUid()) { |
74 | // this is just such a holiday event. | 87 | // this is just such a holiday event. |
75 | return; | 88 | return; |
76 | } | 89 | } |
77 | popmenue = new QPopupMenu; | 90 | popmenue = new QPopupMenu; |
78 | 91 | ||
79 | popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); | 92 | popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); |
80 | popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); | 93 | popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); |
81 | popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); | 94 | popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); |
82 | if(Ir::supported()) | 95 | if(Ir::supported()) |
83 | popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); | 96 | popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); |
84 | popmenue->popup( mapToGlobal( e->pos() )); | 97 | popmenue->popup( mapToGlobal( e->pos() )); |
85 | } | 98 | } |