Diffstat (limited to 'core/pim/datebook/datebookdayallday.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookdayallday.cpp | 23 |
1 files changed, 15 insertions, 8 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 | |||
@@ -8,104 +8,112 @@ | |||
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 | */ |
32 | DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags fl ) | 32 | DatebookdayAllday::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 | */ |
52 | DatebookdayAllday::~DatebookdayAllday() | 59 | DatebookdayAllday::~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 | ||
57 | DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) | 64 | DatebookAlldayDisp* 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 | ||
70 | void DatebookdayAllday::removeAllEvents() | 77 | void DatebookdayAllday::removeAllEvents() |
71 | { | 78 | { |
72 | subWidgets.clear(); | 79 | subWidgets.clear(); |
73 | item_count = 0; | 80 | item_count = 0; |
74 | } | 81 | } |
75 | 82 | ||
76 | DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, | 83 | DatebookAlldayDisp::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("<"),"<"); | 88 | strDesc = strDesc.replace(QRegExp("<"),"<"); |
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 | ||
90 | DatebookAlldayDisp::~DatebookAlldayDisp() | 98 | DatebookAlldayDisp::~DatebookAlldayDisp() |
91 | { | 99 | { |
92 | } | 100 | } |
93 | 101 | ||
94 | void DatebookAlldayDisp::beam_single_event() | 102 | void 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 { |
@@ -202,25 +210,24 @@ void DatebookEventDesc::mousePressEvent(QMouseEvent*) | |||
202 | if (m_Timer->isActive()) m_Timer->stop(); | 210 | if (m_Timer->isActive()) m_Timer->stop(); |
203 | } | 211 | } |
204 | 212 | ||
205 | void DatebookEventDesc::disp_event(const Event&e) | 213 | void 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 | |||