summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookdayallday.cpp25
-rw-r--r--core/pim/datebook/datebookdayallday.h4
2 files changed, 19 insertions, 10 deletions
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp
index 985f31a..6014eca 100644
--- a/core/pim/datebook/datebookdayallday.cpp
+++ b/core/pim/datebook/datebookdayallday.cpp
@@ -1,226 +1,233 @@
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 fl ) 32DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags )
33 : QWidget( parent, name,fl ),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 39
39 datebookdayalldayLayout = new QVBoxLayout( this ); 40 m_MainFrame = new QFrame(viewport());
41 m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain);
42 setFrameStyle(QFrame::NoFrame|QFrame::Plain);
43 setResizePolicy( QScrollView::AutoOneFit );
44 addChild(m_MainFrame);
45
46 datebookdayalldayLayout = new QVBoxLayout( m_MainFrame );
40 datebookdayalldayLayout->setSpacing( 0 ); 47 datebookdayalldayLayout->setSpacing( 0 );
41 datebookdayalldayLayout->setMargin( 0 ); 48 datebookdayalldayLayout->setMargin( 0 );
42 49
43 lblDesc = new DatebookEventDesc(parent->parentWidget(),""); 50 lblDesc = new DatebookEventDesc(parent->parentWidget(),"");
44 lblDesc->setBackgroundColor(Qt::yellow); 51 lblDesc->setBackgroundColor(Qt::yellow);
45 lblDesc->hide(); 52 lblDesc->hide();
46 subWidgets.setAutoDelete(true); 53 subWidgets.setAutoDelete(true);
47} 54}
48 55
49/* 56/*
50 * Destroys the object and frees any allocated resources 57 * Destroys the object and frees any allocated resources
51 */ 58 */
52DatebookdayAllday::~DatebookdayAllday() 59DatebookdayAllday::~DatebookdayAllday()
53{ 60{
54 // no need to delete child widgets, Qt does it all for us 61 // no need to delete child widgets, Qt does it all for us
55} 62}
56 63
57DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) 64DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev)
58{ 65{
59 DatebookAlldayDisp * lb; 66 DatebookAlldayDisp * lb;
60 lb = new DatebookAlldayDisp(dateBook,ev,this,NULL); 67 lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL);
61 datebookdayalldayLayout->addWidget(lb); 68 datebookdayalldayLayout->addWidget(lb);
62 subWidgets.append(lb); 69 subWidgets.append(lb);
63 70
64 connect(lb,SIGNAL(displayMe(const Event &)),lblDesc,SLOT(disp_event(const Event&))); 71 connect(lb,SIGNAL(displayMe(const Event &)),lblDesc,SLOT(disp_event(const Event&)));
65 ++item_count; 72 ++item_count;
66 73
67 return lb; 74 return lb;
68} 75}
69 76
70void DatebookdayAllday::removeAllEvents() 77void DatebookdayAllday::removeAllEvents()
71{ 78{
72 subWidgets.clear(); 79 subWidgets.clear();
73 item_count = 0; 80 item_count = 0;
74} 81}
75 82
76DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, 83DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev,
77 QWidget* parent,const char* name,WFlags f) 84 QWidget* parent,const char* name,WFlags f)
78 : QLabel(parent,name,f),m_Ev(ev),dateBook(db) 85 : QLabel(parent,name,f),m_Ev(ev),dateBook(db)
79{ 86{
80 QString strDesc = m_Ev.description(); 87 QString strDesc = m_Ev.description();
81 strDesc = strDesc.replace(QRegExp("<"),"&#60;"); 88 strDesc = strDesc.replace(QRegExp("<"),"&#60;");
82 setBackgroundColor(yellow); 89 setBackgroundColor(yellow);
83 setText(strDesc); 90 setText(strDesc);
84 setFrameStyle(QFrame::Raised|QFrame::Panel); 91 setFrameStyle(QFrame::Raised|QFrame::Panel);
85 QSize s = sizeHint(); 92
86 setMaximumSize( QSize( 32767, s.height()-4 ) ); 93 int s = QFontMetrics(font()).height()+4;
87 setMinimumSize( QSize( 0, s.height()-4 ) ); 94 setMaximumHeight( s );
95 setMinimumSize( QSize( 0, s ) );
88} 96}
89 97
90DatebookAlldayDisp::~DatebookAlldayDisp() 98DatebookAlldayDisp::~DatebookAlldayDisp()
91{ 99{
92} 100}
93 101
94void DatebookAlldayDisp::beam_single_event() 102void DatebookAlldayDisp::beam_single_event()
95{ 103{
96 // create an Event and beam it... 104 // create an Event and beam it...
97 /* 105 /*
98 * Start with the easy stuff. If start and end date is the same we can just use 106 * Start with the easy stuff. If start and end date is the same we can just use
99 * the values of effective m_Events 107 * the values of effective m_Events
100 * If it is a multi day m_Event we need to find the real start and end date... 108 * If it is a multi day m_Event we need to find the real start and end date...
101 */ 109 */
102 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { 110 if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) {
103 Event m_Event( m_Ev.event() ); 111 Event m_Event( m_Ev.event() );
104 112
105 QDateTime dt( m_Ev.date(), m_Ev.start() ); 113 QDateTime dt( m_Ev.date(), m_Ev.start() );
106 m_Event.setStart( dt ); 114 m_Event.setStart( dt );
107 115
108 dt.setTime( m_Ev.end() ); 116 dt.setTime( m_Ev.end() );
109 m_Event.setEnd( dt ); 117 m_Event.setEnd( dt );
110 emit beamMe( m_Event ); 118 emit beamMe( m_Event );
111 }else { 119 }else {
112 /* 120 /*
113 * at least the the Times are right now 121 * at least the the Times are right now
114 */ 122 */
115 QDateTime start( m_Ev.event().start() ); 123 QDateTime start( m_Ev.event().start() );
116 QDateTime end ( m_Ev.event().end () ); 124 QDateTime end ( m_Ev.event().end () );
117 125
118 /* 126 /*
119 * ok we know the start date or we need to find it 127 * ok we know the start date or we need to find it
120 */ 128 */
121 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { 129 if ( m_Ev.start() != QTime( 0, 0, 0 ) ) {
122 start.setDate( m_Ev.date() ); 130 start.setDate( m_Ev.date() );
123 }else { 131 }else {
124 QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook ); 132 QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook );
125 start.setDate( dt ); 133 start.setDate( dt );
126 } 134 }
127 135
128 /* 136 /*
129 * ok we know now the end date... 137 * ok we know now the end date...
130 * else 138 * else
131 * get to know the offset btw the real start and real end 139 * get to know the offset btw the real start and real end
132 * and then add it to the new start date... 140 * and then add it to the new start date...
133 */ 141 */
134 if ( m_Ev.end() != QTime(23, 59, 59 ) ) { 142 if ( m_Ev.end() != QTime(23, 59, 59 ) ) {
135 end.setDate( m_Ev.date() ); 143 end.setDate( m_Ev.date() );
136 }else{ 144 }else{
137 int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() ); 145 int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() );
138 end.setDate( start.date().addDays( days ) ); 146 end.setDate( start.date().addDays( days ) );
139 } 147 }
140 Event m_Event( m_Ev.event() ); 148 Event m_Event( m_Ev.event() );
141 m_Event.setStart( start ); 149 m_Event.setStart( start );
142 m_Event.setEnd ( end ); 150 m_Event.setEnd ( end );
143 emit beamMe( m_Event ); 151 emit beamMe( m_Event );
144 } 152 }
145} 153}
146 154
147void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) 155void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
148{ 156{
149 QColor b = backgroundColor(); 157 QColor b = backgroundColor();
150 setBackgroundColor(green); 158 setBackgroundColor(green);
151 update(); 159 update();
152 QPopupMenu m; 160 QPopupMenu m;
153 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); 161 m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 );
154 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); 162 m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 );
155 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); 163 m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 );
156 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); 164 if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 );
157 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); 165 if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 );
158 m.insertItem( tr( "Info"),6); 166 m.insertItem( tr( "Info"),6);
159 int r = m.exec( e->globalPos() ); 167 int r = m.exec( e->globalPos() );
160 setBackgroundColor(b); 168 setBackgroundColor(b);
161 update(); 169 update();
162 switch (r) { 170 switch (r) {
163 case 1: 171 case 1:
164 emit editMe( m_Ev.event() ); 172 emit editMe( m_Ev.event() );
165 break; 173 break;
166 case 2: 174 case 2:
167 emit deleteMe( m_Ev.event() ); 175 emit deleteMe( m_Ev.event() );
168 break; 176 break;
169 case 3: 177 case 3:
170 emit beamMe( m_Ev.event() ); 178 emit beamMe( m_Ev.event() );
171 break; 179 break;
172 case 4: 180 case 4:
173 emit duplicateMe( m_Ev.event() ); 181 emit duplicateMe( m_Ev.event() );
174 break; 182 break;
175 case 5: 183 case 5:
176 beam_single_event(); 184 beam_single_event();
177 break; 185 break;
178 case 6: 186 case 6:
179 emit displayMe( m_Ev.event() ); 187 emit displayMe( m_Ev.event() );
180 break; 188 break;
181 default: 189 default:
182 break; 190 break;
183 } 191 }
184} 192}
185 193
186DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name) 194DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name)
187 :QLabel(parent,name) 195 :QLabel(parent,name)
188{ 196{
189 m_Timer=new QTimer(this); 197 m_Timer=new QTimer(this);
190 connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide())); 198 connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide()));
191 setFrameStyle(QFrame::Sunken|QFrame::Panel); 199 setFrameStyle(QFrame::Sunken|QFrame::Panel);
192 setTextFormat(RichText); 200 setTextFormat(RichText);
193} 201}
194 202
195DatebookEventDesc::~DatebookEventDesc() 203DatebookEventDesc::~DatebookEventDesc()
196{ 204{
197} 205}
198 206
199void DatebookEventDesc::mousePressEvent(QMouseEvent*) 207void DatebookEventDesc::mousePressEvent(QMouseEvent*)
200{ 208{
201 hide(); 209 hide();
202 if (m_Timer->isActive()) m_Timer->stop(); 210 if (m_Timer->isActive()) m_Timer->stop();
203} 211}
204 212
205void DatebookEventDesc::disp_event(const Event&e) 213void DatebookEventDesc::disp_event(const Event&e)
206{ 214{
207 if (m_Timer->isActive()) m_Timer->stop(); 215 if (m_Timer->isActive()) m_Timer->stop();
208 QString text; 216 QString text;
209 text = "<b><i>"+e.description()+"</i></b><br>"; 217 text = "<b><i>"+e.description()+"</i></b><br>";
210 if (e.notes().length()>0) { 218 if (e.notes().length()>0) {
211 text+="<b>"+e.notes()+"</b><br>"; 219 text+="<b>"+e.notes()+"</b><br>";
212 } 220 }
213 if (e.location().length()>0) { 221 if (e.location().length()>0) {
214 text+="<i>"+e.location()+"</i><br>"; 222 text+="<i>"+e.location()+"</i><br>";
215 } 223 }
216 text = text.replace(QRegExp("\n"),"<br>"); 224 text = text.replace(QRegExp("\n"),"<br>");
217 setText(text); 225 setText(text);
218 QSize s = sizeHint(); 226 QSize s = sizeHint();
219 s+=QSize(10,10); 227 s+=QSize(10,10);
220 resize(s); 228 resize(s);
221 move( QMAX(0,(parentWidget()->width()-width()) / 2), 229 move( QMAX(0,(parentWidget()->width()-width()) / 2),
222 (parentWidget()->height()-height())/2 ); 230 (parentWidget()->height()-height())/2 );
223 show(); 231 show();
224 m_Timer->start(2000,true); 232 m_Timer->start(2000,true);
225} 233}
226
diff --git a/core/pim/datebook/datebookdayallday.h b/core/pim/datebook/datebookdayallday.h
index c781785..f5867e5 100644
--- a/core/pim/datebook/datebookdayallday.h
+++ b/core/pim/datebook/datebookdayallday.h
@@ -1,80 +1,82 @@
1#ifndef DATEBOOKDAYALLDAYBASE_H 1#ifndef DATEBOOKDAYALLDAYBASE_H
2#define DATEBOOKDAYALLDAYBASE_H 2#define DATEBOOKDAYALLDAYBASE_H
3 3
4#include <qvariant.h> 4#include <qvariant.h>
5#include <qframe.h> 5#include <qframe.h>
6#include <qscrollview.h>
6#include <qlabel.h> 7#include <qlabel.h>
7#include <qlist.h> 8#include <qlist.h>
8#include <qpe/event.h> 9#include <qpe/event.h>
9 10
10class QVBoxLayout; 11class QVBoxLayout;
11class QHBoxLayout; 12class QHBoxLayout;
12class QGridLayout; 13class QGridLayout;
13class DatebookAlldayDisp; 14class DatebookAlldayDisp;
14class DatebookEventDesc; 15class DatebookEventDesc;
15class DateBookDB; 16class DateBookDB;
16 17
17class DatebookdayAllday : public QWidget 18class DatebookdayAllday : public QScrollView
18{ 19{
19 Q_OBJECT 20 Q_OBJECT
20 21
21public: 22public:
22 DatebookdayAllday(DateBookDB* db, 23 DatebookdayAllday(DateBookDB* db,
23 QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 24 QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
24 ~DatebookdayAllday(); 25 ~DatebookdayAllday();
25 DatebookAlldayDisp* addEvent(const EffectiveEvent&e); 26 DatebookAlldayDisp* addEvent(const EffectiveEvent&e);
26 const unsigned int items()const{return item_count;} 27 const unsigned int items()const{return item_count;}
27 28
28public slots: 29public slots:
29 void removeAllEvents(); 30 void removeAllEvents();
30 31
31protected: 32protected:
33 QFrame * m_MainFrame;
32 QVBoxLayout* datebookdayalldayLayout; 34 QVBoxLayout* datebookdayalldayLayout;
33 DatebookEventDesc * lblDesc; 35 DatebookEventDesc * lblDesc;
34 unsigned int item_count; 36 unsigned int item_count;
35 QList<DatebookAlldayDisp> subWidgets; 37 QList<DatebookAlldayDisp> subWidgets;
36 DateBookDB *dateBook; 38 DateBookDB *dateBook;
37}; 39};
38 40
39class DatebookAlldayDisp : public QLabel 41class DatebookAlldayDisp : public QLabel
40{ 42{
41 Q_OBJECT 43 Q_OBJECT
42 44
43public: 45public:
44 DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e, 46 DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e,
45 QWidget* parent=0,const char* name = 0, WFlags fl=0); 47 QWidget* parent=0,const char* name = 0, WFlags fl=0);
46 virtual ~DatebookAlldayDisp(); 48 virtual ~DatebookAlldayDisp();
47 49
48signals: 50signals:
49 void deleteMe( const Event &e ); 51 void deleteMe( const Event &e );
50 void duplicateMe( const Event &e ); 52 void duplicateMe( const Event &e );
51 void editMe( const Event &e ); 53 void editMe( const Event &e );
52 void beamMe( const Event &e ); 54 void beamMe( const Event &e );
53 void displayMe(const Event &e); 55 void displayMe(const Event &e);
54 56
55public slots: 57public slots:
56 58
57protected: 59protected:
58 EffectiveEvent m_Ev; 60 EffectiveEvent m_Ev;
59 DateBookDB* dateBook; 61 DateBookDB* dateBook;
60 void mousePressEvent( QMouseEvent *e ); 62 void mousePressEvent( QMouseEvent *e );
61 void beam_single_event(); 63 void beam_single_event();
62}; 64};
63 65
64class DatebookEventDesc: public QLabel 66class DatebookEventDesc: public QLabel
65{ 67{
66 Q_OBJECT 68 Q_OBJECT
67 69
68public: 70public:
69 DatebookEventDesc(QWidget* Parent=0,const char* name = 0); 71 DatebookEventDesc(QWidget* Parent=0,const char* name = 0);
70 virtual ~DatebookEventDesc(); 72 virtual ~DatebookEventDesc();
71 73
72public slots: 74public slots:
73 void disp_event(const Event&e); 75 void disp_event(const Event&e);
74 76
75protected: 77protected:
76 void mousePressEvent(QMouseEvent*e); 78 void mousePressEvent(QMouseEvent*e);
77 QTimer* m_Timer; 79 QTimer* m_Timer;
78}; 80};
79 81
80#endif // DATEBOOKDAYALLDAYBASE_H 82#endif // DATEBOOKDAYALLDAYBASE_H