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