summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookdayallday.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp
index 6014eca..2294f3c 100644
--- a/core/pim/datebook/datebookdayallday.cpp
+++ b/core/pim/datebook/datebookdayallday.cpp
@@ -1,188 +1,190 @@
1/**************************************************************************** 1/****************************************************************************
2** GPL by Rajko Albrecht 2** GPL by Rajko Albrecht
3** 3**
4** 4**
5** 5**
6** 6**
7** 7**
8****************************************************************************/ 8****************************************************************************/
9#include "datebookdayallday.h" 9#include "datebookdayallday.h"
10 10
11#include <qpushbutton.h> 11#include <qpushbutton.h>
12#include <qlayout.h> 12#include <qlayout.h>
13#include <qvariant.h> 13#include <qvariant.h>
14#include <qtooltip.h> 14#include <qtooltip.h>
15#include <qwhatsthis.h> 15#include <qwhatsthis.h>
16#include <qobjectlist.h> 16#include <qobjectlist.h>
17#include <qpe/event.h> 17#include <qpe/event.h>
18#include <qpe/ir.h> 18#include <qpe/ir.h>
19#include <qpe/datebookdb.h> 19#include <qpe/datebookdb.h>
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpopupmenu.h> 21#include <qpopupmenu.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qregexp.h> 23#include <qregexp.h>
24#include <qdatetime.h> 24#include <qdatetime.h>
25 25
26#include "datebookday.h" 26#include "datebookday.h"
27 27
28/* 28/*
29 * Constructs a DatebookdayAllday which is a child of 'parent', with the 29 * Constructs a DatebookdayAllday which is a child of 'parent', with the
30 * name 'name' and widget flags set to 'f' 30 * name 'name' and widget flags set to 'f'
31 */ 31 */
32DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags ) 32DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags )
33 : QScrollView( parent, name ),item_count(0),dateBook(db) 33 : QScrollView( parent, name ),item_count(0),dateBook(db)
34{ 34{
35 if ( !name ) 35 if ( !name )
36 setName( "DatebookdayAllday" ); 36 setName( "DatebookdayAllday" );
37 setMinimumSize( QSize( 0, 0 ) ); 37 setMinimumSize( QSize( 0, 0 ) );
38 setMaximumHeight(3* (QFontMetrics(font()).height()+4) ); 38 setMaximumHeight(3* (QFontMetrics(font()).height()+4) );
39 39
40 m_MainFrame = new QFrame(viewport()); 40 m_MainFrame = new QFrame(viewport());
41 m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain); 41 m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain);
42 setFrameStyle(QFrame::NoFrame|QFrame::Plain); 42 setFrameStyle(QFrame::NoFrame|QFrame::Plain);
43 setResizePolicy( QScrollView::AutoOneFit ); 43 setResizePolicy( QScrollView::Default );
44 setHScrollBarMode( AlwaysOff );
44 addChild(m_MainFrame); 45 addChild(m_MainFrame);
45 46
46 datebookdayalldayLayout = new QVBoxLayout( m_MainFrame ); 47 datebookdayalldayLayout = new QVBoxLayout( m_MainFrame );
47 datebookdayalldayLayout->setSpacing( 0 ); 48 datebookdayalldayLayout->setSpacing( 0 );
48 datebookdayalldayLayout->setMargin( 0 ); 49 datebookdayalldayLayout->setMargin( 0 );
49 50
50 lblDesc = new DatebookEventDesc(parent->parentWidget(),""); 51 lblDesc = new DatebookEventDesc(parent->parentWidget(),"");
51 lblDesc->setBackgroundColor(Qt::yellow); 52 lblDesc->setBackgroundColor(Qt::yellow);
52 lblDesc->hide(); 53 lblDesc->hide();
53 subWidgets.setAutoDelete(true); 54 subWidgets.setAutoDelete(true);
54} 55}
55 56
56/* 57/*
57 * Destroys the object and frees any allocated resources 58 * Destroys the object and frees any allocated resources
58 */ 59 */
59DatebookdayAllday::~DatebookdayAllday() 60DatebookdayAllday::~DatebookdayAllday()
60{ 61{
61 // no need to delete child widgets, Qt does it all for us 62 // no need to delete child widgets, Qt does it all for us
62} 63}
63 64
64DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) 65DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev)
65{ 66{
66 DatebookAlldayDisp * lb; 67 DatebookAlldayDisp * lb;
67 lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL); 68 lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL);
69 lb->show();
68 datebookdayalldayLayout->addWidget(lb); 70 datebookdayalldayLayout->addWidget(lb);
69 subWidgets.append(lb); 71 subWidgets.append(lb);
70 72
71 connect(lb,SIGNAL(displayMe(const Event &)),lblDesc,SLOT(disp_event(const Event&))); 73 connect(lb,SIGNAL(displayMe(const Event &)),lblDesc,SLOT(disp_event(const Event&)));
72 ++item_count; 74 ++item_count;
73 75
74 return lb; 76 return lb;
75} 77}
76 78
77void DatebookdayAllday::removeAllEvents() 79void DatebookdayAllday::removeAllEvents()
78{ 80{
79 subWidgets.clear(); 81 subWidgets.clear();
80 item_count = 0; 82 item_count = 0;
81} 83}
82 84
83DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, 85DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev,
84 QWidget* parent,const char* name,WFlags f) 86 QWidget* parent,const char* name,WFlags f)
85 : QLabel(parent,name,f),m_Ev(ev),dateBook(db) 87 : QLabel(parent,name,f),m_Ev(ev),dateBook(db)
86{ 88{
87 QString strDesc = m_Ev.description(); 89 QString strDesc = m_Ev.description();
88 strDesc = strDesc.replace(QRegExp("<"),"&#60;"); 90 strDesc = strDesc.replace(QRegExp("<"),"&#60;");
89 setBackgroundColor(yellow); 91 setBackgroundColor(yellow);
90 setText(strDesc); 92 setText(strDesc);
91 setFrameStyle(QFrame::Raised|QFrame::Panel); 93 setFrameStyle(QFrame::Raised|QFrame::Panel);
92 94
93 int s = QFontMetrics(font()).height()+4; 95 int s = QFontMetrics(font()).height()+4;
94 setMaximumHeight( s ); 96 setMaximumHeight( s );
95 setMinimumSize( QSize( 0, s ) ); 97 setMinimumSize( QSize( 0, s ) );
96} 98}
97 99
98DatebookAlldayDisp::~DatebookAlldayDisp() 100DatebookAlldayDisp::~DatebookAlldayDisp()
99{ 101{
100} 102}
101 103
102void DatebookAlldayDisp::beam_single_event() 104void DatebookAlldayDisp::beam_single_event()
103{ 105{
104 // create an Event and beam it... 106 // create an Event and beam it...
105 /* 107 /*
106 * Start with the easy stuff. If start and end date is the same we can just use 108 * Start with the easy stuff. If start and end date is the same we can just use
107 * the values of effective m_Events 109 * the values of effective m_Events
108 * If it is a multi day m_Event we need to find the real start and end date... 110 * If it is a multi day m_Event we need to find the real start and end date...
109 */ 111 */
110 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { 112 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) {
111 Event m_Event( m_Ev.event() ); 113 Event m_Event( m_Ev.event() );
112 114
113 QDateTime dt( m_Ev.date(), m_Ev.start() ); 115 QDateTime dt( m_Ev.date(), m_Ev.start() );
114 m_Event.setStart( dt ); 116 m_Event.setStart( dt );
115 117
116 dt.setTime( m_Ev.end() ); 118 dt.setTime( m_Ev.end() );
117 m_Event.setEnd( dt ); 119 m_Event.setEnd( dt );
118 emit beamMe( m_Event ); 120 emit beamMe( m_Event );
119 }else { 121 }else {
120 /* 122 /*
121 * at least the the Times are right now 123 * at least the the Times are right now
122 */ 124 */
123 QDateTime start( m_Ev.event().start() ); 125 QDateTime start( m_Ev.event().start() );
124 QDateTime end ( m_Ev.event().end () ); 126 QDateTime end ( m_Ev.event().end () );
125 127
126 /* 128 /*
127 * ok we know the start date or we need to find it 129 * ok we know the start date or we need to find it
128 */ 130 */
129 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { 131 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) {
130 start.setDate( m_Ev.date() ); 132 start.setDate( m_Ev.date() );
131 }else { 133 }else {
132 QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook ); 134 QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook );
133 start.setDate( dt ); 135 start.setDate( dt );
134 } 136 }
135 137
136 /* 138 /*
137 * ok we know now the end date... 139 * ok we know now the end date...
138 * else 140 * else
139 * get to know the offset btw the real start and real end 141 * get to know the offset btw the real start and real end
140 * and then add it to the new start date... 142 * and then add it to the new start date...
141 */ 143 */
142 if ( m_Ev.end() != QTime(23, 59, 59 ) ) { 144 if ( m_Ev.end() != QTime(23, 59, 59 ) ) {
143 end.setDate( m_Ev.date() ); 145 end.setDate( m_Ev.date() );
144 }else{ 146 }else{
145 int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() ); 147 int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() );
146 end.setDate( start.date().addDays( days ) ); 148 end.setDate( start.date().addDays( days ) );
147 } 149 }
148 Event m_Event( m_Ev.event() ); 150 Event m_Event( m_Ev.event() );
149 m_Event.setStart( start ); 151 m_Event.setStart( start );
150 m_Event.setEnd ( end ); 152 m_Event.setEnd ( end );
151 emit beamMe( m_Event ); 153 emit beamMe( m_Event );
152 } 154 }
153} 155}
154 156
155void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) 157void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
156{ 158{
157 QColor b = backgroundColor(); 159 QColor b = backgroundColor();
158 setBackgroundColor(green); 160 setBackgroundColor(green);
159 update(); 161 update();
160 QPopupMenu m; 162 QPopupMenu m;
161 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); 163 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 );
162 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); 164 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 );
163 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); 165 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 );
164 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); 166 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 );
165 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); 167 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 );
166 m.insertItem( tr( "Info"),6); 168 m.insertItem( tr( "Info"),6);
167 int r = m.exec( e->globalPos() ); 169 int r = m.exec( e->globalPos() );
168 setBackgroundColor(b); 170 setBackgroundColor(b);
169 update(); 171 update();
170 switch (r) { 172 switch (r) {
171 case 1: 173 case 1:
172 emit editMe( m_Ev.event() ); 174 emit editMe( m_Ev.event() );
173 break; 175 break;
174 case 2: 176 case 2:
175 emit deleteMe( m_Ev.event() ); 177 emit deleteMe( m_Ev.event() );
176 break; 178 break;
177 case 3: 179 case 3:
178 emit beamMe( m_Ev.event() ); 180 emit beamMe( m_Ev.event() );
179 break; 181 break;
180 case 4: 182 case 4:
181 emit duplicateMe( m_Ev.event() ); 183 emit duplicateMe( m_Ev.event() );
182 break; 184 break;
183 case 5: 185 case 5:
184 beam_single_event(); 186 beam_single_event();
185 break; 187 break;
186 case 6: 188 case 6:
187 emit displayMe( m_Ev.event() ); 189 emit displayMe( m_Ev.event() );
188 break; 190 break;