-rw-r--r-- | korganizer/koagendaitem.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index df7d612..6a312b3 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,704 +1,704 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qvbox.h> | 23 | #include <qvbox.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qwhatsthis.h> | 25 | #include <qwhatsthis.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | 29 | ||
30 | #include <kiconloader.h> | 30 | #include <kiconloader.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #define AGENDA_ICON_SIZE 5 | 36 | #define AGENDA_ICON_SIZE 5 |
37 | #else | 37 | #else |
38 | #define AGENDA_ICON_SIZE 7 | 38 | #define AGENDA_ICON_SIZE 7 |
39 | #endif | 39 | #endif |
40 | #include <libkcal/icaldrag.h> | 40 | #include <libkcal/icaldrag.h> |
41 | #include <libkcal/vcaldrag.h> | 41 | #include <libkcal/vcaldrag.h> |
42 | #include <libkcal/kincidenceformatter.h> | 42 | #include <libkcal/kincidenceformatter.h> |
43 | extern int globalFlagBlockAgenda; | 43 | extern int globalFlagBlockAgenda; |
44 | extern int globalFlagBlockAgendaItemPaint; | 44 | extern int globalFlagBlockAgendaItemPaint; |
45 | extern int globalFlagBlockAgendaItemUpdate; | 45 | extern int globalFlagBlockAgendaItemUpdate; |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | 48 | ||
49 | #include "koagendaitem.h" | 49 | #include "koagendaitem.h" |
50 | //#include "koagendaitem.moc" | 50 | //#include "koagendaitem.moc" |
51 | 51 | ||
52 | 52 | ||
53 | //-------------------------------------------------------------------------- | 53 | //-------------------------------------------------------------------------- |
54 | 54 | ||
55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
56 | 56 | ||
57 | //-------------------------------------------------------------------------- | 57 | //-------------------------------------------------------------------------- |
58 | 58 | ||
59 | class KOAgendaItemWhatsThis :public QWhatsThis | 59 | class KOAgendaItemWhatsThis :public QWhatsThis |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; | 62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | virtual QString text( const QPoint& ) | 65 | virtual QString text( const QPoint& ) |
66 | { | 66 | { |
67 | return _view->getWhatsThisText() ; | 67 | return _view->getWhatsThisText() ; |
68 | } | 68 | } |
69 | private: | 69 | private: |
70 | KOAgendaItem * _view; | 70 | KOAgendaItem * _view; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
74 | const char *name,WFlags) : | 74 | const char *name,WFlags) : |
75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
76 | { | 76 | { |
77 | #ifndef DESKTOP_VERSION | 77 | #ifndef DESKTOP_VERSION |
78 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 78 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
79 | #endif | 79 | #endif |
80 | new KOAgendaItemWhatsThis(this); | 80 | new KOAgendaItemWhatsThis(this); |
81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
82 | setWFlags ( wflags); | 82 | setWFlags ( wflags); |
83 | mAllDay = allday; | 83 | mAllDay = allday; |
84 | init ( incidence, qd ); | 84 | init ( incidence, qd ); |
85 | setMouseTracking(true); | 85 | setMouseTracking(true); |
86 | //setAcceptDrops(true); | 86 | //setAcceptDrops(true); |
87 | xPaintCoord = -1; | 87 | xPaintCoord = -1; |
88 | yPaintCoord = -1; | 88 | yPaintCoord = -1; |
89 | } | 89 | } |
90 | QString KOAgendaItem::getWhatsThisText() | 90 | QString KOAgendaItem::getWhatsThisText() |
91 | { | 91 | { |
92 | if ( mIncidence ) | 92 | if ( mIncidence ) |
93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence ); | 93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence ); |
94 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 94 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
95 | } | 95 | } |
96 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 96 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
97 | { | 97 | { |
98 | mIncidence = incidence; | 98 | mIncidence = incidence; |
99 | mDate = qd; | 99 | mDate = qd; |
100 | mFirstMultiItem = 0; | 100 | mFirstMultiItem = 0; |
101 | mNextMultiItem = 0; | 101 | mNextMultiItem = 0; |
102 | mLastMultiItem = 0; | 102 | mLastMultiItem = 0; |
103 | computeText(); | 103 | computeText(); |
104 | 104 | ||
105 | if ( (incidence->type() == "Todo") && | 105 | if ( (incidence->type() == "Todo") && |
106 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 106 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && |
107 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 107 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
108 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 108 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) |
109 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 109 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
110 | else | 110 | else |
111 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 111 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
112 | } | 112 | } |
113 | else { | 113 | else { |
114 | QStringList categories = mIncidence->categories(); | 114 | QStringList categories = mIncidence->categories(); |
115 | QString cat = categories.first(); | 115 | QString cat = categories.first(); |
116 | if (cat.isEmpty()) { | 116 | if (cat.isEmpty()) { |
117 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) | 117 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) |
118 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 118 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
119 | else | 119 | else |
120 | mBackgroundColor =KOPrefs::instance()->mEventColor; | 120 | mBackgroundColor =KOPrefs::instance()->mEventColor; |
121 | } else { | 121 | } else { |
122 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 122 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
123 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { | 123 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { |
124 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 124 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
125 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 125 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | } | 129 | } |
130 | mColorGroup = QColorGroup( mBackgroundColor.light(), | 130 | mColorGroup = QColorGroup( mBackgroundColor.light(), |
131 | mBackgroundColor.dark(),mBackgroundColor.light(), | 131 | mBackgroundColor.dark(),mBackgroundColor.light(), |
132 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; | 132 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; |
133 | setBackgroundColor( mBackgroundColor ); | 133 | setBackgroundColor( mBackgroundColor ); |
134 | 134 | ||
135 | setCellXY(0,0,1); | 135 | setCellXY(0,0,1); |
136 | setCellXWidth(0); | 136 | setCellXWidth(0); |
137 | setSubCell(0); | 137 | setSubCell(0); |
138 | setSubCells(1); | 138 | setSubCells(1); |
139 | setMultiItem(0,0,0); | 139 | setMultiItem(0,0,0); |
140 | startMove(); | 140 | startMove(); |
141 | mSelected = true; | 141 | mSelected = true; |
142 | select(false); | 142 | select(false); |
143 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 143 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
144 | mFontPixelSize = fontinf.height();; | 144 | mFontPixelSize = fontinf.height();; |
145 | hide(); | 145 | hide(); |
146 | xPaintCoord = -1; | 146 | xPaintCoord = -1; |
147 | yPaintCoord = -1; | 147 | yPaintCoord = -1; |
148 | } | 148 | } |
149 | 149 | ||
150 | 150 | ||
151 | KOAgendaItem::~KOAgendaItem() | 151 | KOAgendaItem::~KOAgendaItem() |
152 | { | 152 | { |
153 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 153 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
154 | 154 | ||
155 | } | 155 | } |
156 | 156 | ||
157 | void KOAgendaItem::recreateIncidence() | 157 | void KOAgendaItem::recreateIncidence() |
158 | { | 158 | { |
159 | #if 0 | 159 | #if 0 |
160 | Incidence* newInc = mIncidence->clone(); | 160 | Incidence* newInc = mIncidence->clone(); |
161 | newInc->recreate(); | 161 | newInc->recreate(); |
162 | if ( mIncidence->doesRecur() ) { | 162 | if ( mIncidence->doesRecur() ) { |
163 | mIncidence->addExDate( mDate ); | 163 | mIncidence->addExDate( mDate ); |
164 | newInc->recurrence()->unsetRecurs(); | 164 | newInc->recurrence()->unsetRecurs(); |
165 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 165 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
166 | QTime tim = mIncidence->dtStart().time(); | 166 | QTime tim = mIncidence->dtStart().time(); |
167 | newInc->setDtStart( QDateTime(mDate, tim) ); | 167 | newInc->setDtStart( QDateTime(mDate, tim) ); |
168 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 168 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
169 | } | 169 | } |
170 | #endif | 170 | #endif |
171 | mIncidence = mIncidence->recreateCloneException( mDate ); | 171 | mIncidence = mIncidence->recreateCloneException( mDate ); |
172 | } | 172 | } |
173 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 173 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
174 | { | 174 | { |
175 | int size = AGENDA_ICON_SIZE; | 175 | int size = AGENDA_ICON_SIZE; |
176 | 176 | ||
177 | int yOff = 0; | 177 | int yOff = 0; |
178 | int xOff = 0; | 178 | int xOff = 0; |
179 | int x = pos().x() +3; | 179 | int x = pos().x() +3; |
180 | int y; | 180 | int y; |
181 | if ( mAllDay ) | 181 | if ( mAllDay ) |
182 | y = pos().y()+3; | 182 | y = pos().y()+3; |
183 | else | 183 | else |
184 | y = mCellYTop * ( height() / cellHeight() ) +3; | 184 | y = mCellYTop * ( height() / cellHeight() ) +3; |
185 | if (mIncidence->cancelled()) { | 185 | if (mIncidence->cancelled()) { |
186 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 186 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
187 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 187 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
188 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 188 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
189 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 189 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
190 | if ( horLayout ) | 190 | if ( horLayout ) |
191 | ++xOff; | 191 | ++xOff; |
192 | else | 192 | else |
193 | ++yOff; | 193 | ++yOff; |
194 | } | 194 | } |
195 | if (mIncidence->isAlarmEnabled()) { | 195 | if (mIncidence->isAlarmEnabled()) { |
196 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 196 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
197 | if ( horLayout ) | 197 | if ( horLayout ) |
198 | ++xOff; | 198 | ++xOff; |
199 | else | 199 | else |
200 | ++yOff; | 200 | ++yOff; |
201 | } | 201 | } |
202 | if (mIncidence->recurrence()->doesRecur()) { | 202 | if (mIncidence->recurrence()->doesRecur()) { |
203 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 203 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
204 | if ( horLayout ) | 204 | if ( horLayout ) |
205 | ++xOff; | 205 | ++xOff; |
206 | else | 206 | else |
207 | ++yOff; | 207 | ++yOff; |
208 | } | 208 | } |
209 | if (mIncidence->description().length() > 0) { | 209 | if (mIncidence->description().length() > 0) { |
210 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 210 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
211 | if ( horLayout ) | 211 | if ( horLayout ) |
212 | ++xOff; | 212 | ++xOff; |
213 | else | 213 | else |
214 | ++yOff; | 214 | ++yOff; |
215 | } | 215 | } |
216 | if (mIncidence->isReadOnly()) { | 216 | if (mIncidence->isReadOnly()) { |
217 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 217 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
218 | if ( horLayout ) | 218 | if ( horLayout ) |
219 | ++xOff; | 219 | ++xOff; |
220 | else | 220 | else |
221 | ++yOff; | 221 | ++yOff; |
222 | } | 222 | } |
223 | 223 | ||
224 | if (mIncidence->attendeeCount()>0) { | 224 | if (mIncidence->attendeeCount()>0) { |
225 | 225 | ||
226 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 226 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
227 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 227 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
228 | if ( horLayout ) | 228 | if ( horLayout ) |
229 | ++xOff; | 229 | ++xOff; |
230 | else | 230 | else |
231 | ++yOff; | 231 | ++yOff; |
232 | } else { | 232 | } else { |
233 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 233 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
234 | if (me!=0) { | 234 | if (me!=0) { |
235 | 235 | ||
236 | 236 | ||
237 | } else { | 237 | } else { |
238 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 238 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
239 | if ( horLayout ) | 239 | if ( horLayout ) |
240 | ++xOff; | 240 | ++xOff; |
241 | else | 241 | else |
242 | ++yOff; | 242 | ++yOff; |
243 | 243 | ||
244 | } | 244 | } |
245 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 245 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
246 | if ( horLayout ) | 246 | if ( horLayout ) |
247 | ++xOff; | 247 | ++xOff; |
248 | else | 248 | else |
249 | ++yOff; | 249 | ++yOff; |
250 | 250 | ||
251 | } | 251 | } |
252 | 252 | ||
253 | } | 253 | } |
254 | return ( yOff || xOff ); | 254 | return ( yOff || xOff ); |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | void KOAgendaItem::select(bool selected) | 258 | void KOAgendaItem::select(bool selected) |
259 | { | 259 | { |
260 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 260 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
261 | if (mSelected == selected) return; | 261 | if (mSelected == selected) return; |
262 | mSelected = selected; | 262 | mSelected = selected; |
263 | if ( ! isVisible() ) | 263 | if ( ! isVisible() ) |
264 | return; | 264 | return; |
265 | if ( firstMultiItem() ) | 265 | if ( firstMultiItem() ) |
266 | firstMultiItem()->select( selected ); | 266 | firstMultiItem()->select( selected ); |
267 | if ( !firstMultiItem() && nextMultiItem() ) { | 267 | if ( !firstMultiItem() && nextMultiItem() ) { |
268 | KOAgendaItem * placeItem = nextMultiItem(); | 268 | KOAgendaItem * placeItem = nextMultiItem(); |
269 | while ( placeItem ) { | 269 | while ( placeItem ) { |
270 | placeItem->select( selected ); | 270 | placeItem->select( selected ); |
271 | placeItem = placeItem->nextMultiItem(); | 271 | placeItem = placeItem->nextMultiItem(); |
272 | } | 272 | } |
273 | } | 273 | } |
274 | globalFlagBlockAgendaItemUpdate = 0; | 274 | globalFlagBlockAgendaItemUpdate = 0; |
275 | paintMe( selected ); | 275 | paintMe( selected ); |
276 | globalFlagBlockAgendaItemUpdate = 1; | 276 | globalFlagBlockAgendaItemUpdate = 1; |
277 | repaint( false ); | 277 | repaint( false ); |
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | /* | 281 | /* |
282 | The eventFilter has to filter the mouse events of the agenda item childs. The | 282 | The eventFilter has to filter the mouse events of the agenda item childs. The |
283 | events are fed into the event handling method of KOAgendaItem. This allows the | 283 | events are fed into the event handling method of KOAgendaItem. This allows the |
284 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 284 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
285 | */ | 285 | */ |
286 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 286 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
287 | { | 287 | { |
288 | if (e->type() == QEvent::MouseButtonPress || | 288 | if (e->type() == QEvent::MouseButtonPress || |
289 | e->type() == QEvent::MouseButtonDblClick || | 289 | e->type() == QEvent::MouseButtonDblClick || |
290 | e->type() == QEvent::MouseButtonRelease || | 290 | e->type() == QEvent::MouseButtonRelease || |
291 | e->type() == QEvent::MouseMove) { | 291 | e->type() == QEvent::MouseMove) { |
292 | QMouseEvent *me = (QMouseEvent *)e; | 292 | QMouseEvent *me = (QMouseEvent *)e; |
293 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 293 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
294 | mapToGlobal(me->pos())); | 294 | mapToGlobal(me->pos())); |
295 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 295 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
296 | return event(&returnEvent); | 296 | return event(&returnEvent); |
297 | } else { | 297 | } else { |
298 | return false; | 298 | return false; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | void KOAgendaItem::repaintMe( ) | 301 | void KOAgendaItem::repaintMe( ) |
302 | { | 302 | { |
303 | paintMe ( mSelected ); | 303 | paintMe ( mSelected ); |
304 | } | 304 | } |
305 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 305 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
306 | { | 306 | { |
307 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 307 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
308 | return; | 308 | return; |
309 | QPainter pa; | 309 | QPainter pa; |
310 | 310 | ||
311 | if ( mSelected ) { | 311 | if ( mSelected ) { |
312 | pa.begin( paintPixSel() ); | 312 | pa.begin( paintPixSel() ); |
313 | } else { | 313 | } else { |
314 | if ( mAllDay ) | 314 | if ( mAllDay ) |
315 | pa.begin( paintPixAllday() ); | 315 | pa.begin( paintPixAllday() ); |
316 | else | 316 | else |
317 | pa.begin( paintPix() ); | 317 | pa.begin( paintPix() ); |
318 | } | 318 | } |
319 | int x, yy, w, h; | 319 | int x, yy, w, h; |
320 | float nfh; | 320 | float nfh = 7.0; |
321 | x = pos().x(); w = width(); h = height (); | 321 | x = pos().x(); w = width(); h = height (); |
322 | if ( mAllDay ) | 322 | if ( mAllDay ) |
323 | yy = y(); | 323 | yy = y(); |
324 | else | 324 | else |
325 | yy = mCellYTop * ( height() / cellHeight() ); | 325 | yy = mCellYTop * ( height() / cellHeight() ); |
326 | xPaintCoord= x; | 326 | xPaintCoord= x; |
327 | yPaintCoord = yy; | 327 | yPaintCoord = yy; |
328 | wPaintCoord = width(); | 328 | wPaintCoord = width(); |
329 | hPaintCoord = height(); | 329 | hPaintCoord = height(); |
330 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 330 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
331 | if ( paint == 0 ) | 331 | if ( paint == 0 ) |
332 | paint = &pa; | 332 | paint = &pa; |
333 | bool horLayout = ( w < h ); | 333 | bool horLayout = ( w < h ); |
334 | int maxhei = mFontPixelSize+4; | 334 | int maxhei = mFontPixelSize+4; |
335 | if ( horLayout ) | 335 | if ( horLayout ) |
336 | maxhei += AGENDA_ICON_SIZE -4; | 336 | maxhei += AGENDA_ICON_SIZE -4; |
337 | bool small = ( h < maxhei ); | 337 | bool small = ( h < maxhei ); |
338 | if ( ! small ) | 338 | if ( ! small ) |
339 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 339 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
340 | else { | 340 | else { |
341 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 341 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
342 | f.setBold( false ); | 342 | f.setBold( false ); |
343 | int fh = f.pointSize(); | 343 | int fh = f.pointSize(); |
344 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 344 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
345 | if ( nfh < 6 ) | 345 | if ( nfh < 6 ) |
346 | nfh = 6; | 346 | nfh = 6; |
347 | f.setPointSize( nfh ); | 347 | f.setPointSize( nfh ); |
348 | paint->setFont(f); | 348 | paint->setFont(f); |
349 | } | 349 | } |
350 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 350 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
351 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 351 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
352 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 352 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
353 | if ( mIncidence->type() == "Todo" ) { | 353 | if ( mIncidence->type() == "Todo" ) { |
354 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 354 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
355 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 355 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
356 | int yyy = yy+3; | 356 | int yyy = yy+3; |
357 | if ( tempTodo->isCompleted() ) | 357 | if ( tempTodo->isCompleted() ) |
358 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 358 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
359 | else { | 359 | else { |
360 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 360 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
361 | 361 | ||
362 | } | 362 | } |
363 | } | 363 | } |
364 | bool addIcon = false; | 364 | bool addIcon = false; |
365 | if ( ! small || w > 3 * h || h > 3* w ) | 365 | if ( ! small || w > 3 * h || h > 3* w ) |
366 | addIcon = updateIcons( paint, horLayout ); | 366 | addIcon = updateIcons( paint, horLayout ); |
367 | 367 | ||
368 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 368 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
369 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 369 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
370 | if ( ! small ) { | 370 | if ( ! small ) { |
371 | x += 3; yy += 3;w -= 6; h-= 5; | 371 | x += 3; yy += 3;w -= 6; h-= 5; |
372 | } else { | 372 | } else { |
373 | x += 2; yy += 1;w -= 4; h-= 4; | 373 | x += 2; yy += 1;w -= 4; h-= 4; |
374 | if ( nfh < 6.01 ) { | 374 | if ( nfh < 6.01 ) { |
375 | yy -= 2; | 375 | yy -= 2; |
376 | h += 4; | 376 | h += 4; |
377 | } | 377 | } |
378 | else | 378 | else |
379 | if ( nfh < h -2 ) | 379 | if ( nfh < h -2 ) |
380 | ++yy; | 380 | ++yy; |
381 | } | 381 | } |
382 | int align; | 382 | int align; |
383 | #ifndef DESKTOP_VERSION | 383 | #ifndef DESKTOP_VERSION |
384 | align = ( AlignLeft|WordBreak|AlignTop); | 384 | align = ( AlignLeft|WordBreak|AlignTop); |
385 | #else | 385 | #else |
386 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 386 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
387 | #endif | 387 | #endif |
388 | if ( addIcon ) { | 388 | if ( addIcon ) { |
389 | if ( ! horLayout ) { | 389 | if ( ! horLayout ) { |
390 | x += AGENDA_ICON_SIZE+3; | 390 | x += AGENDA_ICON_SIZE+3; |
391 | w -= (AGENDA_ICON_SIZE+3); | 391 | w -= (AGENDA_ICON_SIZE+3); |
392 | } | 392 | } |
393 | else { | 393 | else { |
394 | yy+= AGENDA_ICON_SIZE+2; | 394 | yy+= AGENDA_ICON_SIZE+2; |
395 | h -=(AGENDA_ICON_SIZE+3); | 395 | h -=(AGENDA_ICON_SIZE+3); |
396 | } | 396 | } |
397 | } | 397 | } |
398 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 398 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
399 | if ( colsum < 250 ) | 399 | if ( colsum < 250 ) |
400 | paint->setPen ( white); | 400 | paint->setPen ( white); |
401 | if ( x < 0 ) { | 401 | if ( x < 0 ) { |
402 | w = w+x-3; | 402 | w = w+x-3; |
403 | x = 3; | 403 | x = 3; |
404 | if ( w > parentWidget()->width() ){ | 404 | if ( w > parentWidget()->width() ){ |
405 | w = parentWidget()->width() - 6; | 405 | w = parentWidget()->width() - 6; |
406 | #ifndef DESKTOP_VERSION | 406 | #ifndef DESKTOP_VERSION |
407 | align = ( AlignCenter|WordBreak); | 407 | align = ( AlignCenter|WordBreak); |
408 | #else | 408 | #else |
409 | align = ( AlignCenter|BreakAnywhere|WordBreak); | 409 | align = ( AlignCenter|BreakAnywhere|WordBreak); |
410 | #endif | 410 | #endif |
411 | 411 | ||
412 | } | 412 | } |
413 | } | 413 | } |
414 | QRect dr; | 414 | QRect dr; |
415 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 415 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
416 | if ( mIncidence->cancelled() ){ | 416 | if ( mIncidence->cancelled() ){ |
417 | if ( ! small ) { | 417 | if ( ! small ) { |
418 | QFontMetrics fm ( paint->font() ); | 418 | QFontMetrics fm ( paint->font() ); |
419 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 419 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
420 | } | 420 | } |
421 | 421 | ||
422 | } | 422 | } |
423 | pa.end(); | 423 | pa.end(); |
424 | 424 | ||
425 | } | 425 | } |
426 | void KOAgendaItem::resizePixmap( int w , int h ) | 426 | void KOAgendaItem::resizePixmap( int w , int h ) |
427 | { | 427 | { |
428 | paintPix()->resize( w, h ); | 428 | paintPix()->resize( w, h ); |
429 | paintPixSel()->resize( w, h ); | 429 | paintPixSel()->resize( w, h ); |
430 | 430 | ||
431 | } | 431 | } |
432 | QPixmap * KOAgendaItem::paintPix() | 432 | QPixmap * KOAgendaItem::paintPix() |
433 | { | 433 | { |
434 | static QPixmap* mPaintPix = 0; | 434 | static QPixmap* mPaintPix = 0; |
435 | if ( ! mPaintPix ) | 435 | if ( ! mPaintPix ) |
436 | mPaintPix = new QPixmap(1,1); | 436 | mPaintPix = new QPixmap(1,1); |
437 | return mPaintPix ; | 437 | return mPaintPix ; |
438 | } | 438 | } |
439 | QPixmap * KOAgendaItem::paintPixAllday() | 439 | QPixmap * KOAgendaItem::paintPixAllday() |
440 | { | 440 | { |
441 | static QPixmap* mPaintPixA = 0; | 441 | static QPixmap* mPaintPixA = 0; |
442 | if ( ! mPaintPixA ) | 442 | if ( ! mPaintPixA ) |
443 | mPaintPixA = new QPixmap(1,1); | 443 | mPaintPixA = new QPixmap(1,1); |
444 | return mPaintPixA ; | 444 | return mPaintPixA ; |
445 | } | 445 | } |
446 | QPixmap * KOAgendaItem::paintPixSel() | 446 | QPixmap * KOAgendaItem::paintPixSel() |
447 | { | 447 | { |
448 | static QPixmap* mPaintPixSel = 0; | 448 | static QPixmap* mPaintPixSel = 0; |
449 | if ( ! mPaintPixSel ) | 449 | if ( ! mPaintPixSel ) |
450 | mPaintPixSel = new QPixmap(1,1); | 450 | mPaintPixSel = new QPixmap(1,1); |
451 | return mPaintPixSel ; | 451 | return mPaintPixSel ; |
452 | } | 452 | } |
453 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 453 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
454 | { | 454 | { |
455 | 455 | ||
456 | if ( globalFlagBlockAgendaItemPaint ) | 456 | if ( globalFlagBlockAgendaItemPaint ) |
457 | return; | 457 | return; |
458 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 458 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
459 | return; | 459 | return; |
460 | int yy; | 460 | int yy; |
461 | if ( mAllDay ) | 461 | if ( mAllDay ) |
462 | yy = y(); | 462 | yy = y(); |
463 | else | 463 | else |
464 | yy = mCellYTop * ( height() / cellHeight() ); | 464 | yy = mCellYTop * ( height() / cellHeight() ); |
465 | int xx = x(); | 465 | int xx = x(); |
466 | if ( xPaintCoord != xx || yPaintCoord != yy || | 466 | if ( xPaintCoord != xx || yPaintCoord != yy || |
467 | wPaintCoord != width() || hPaintCoord != height()) { | 467 | wPaintCoord != width() || hPaintCoord != height()) { |
468 | xPaintCoord= xx; | 468 | xPaintCoord= xx; |
469 | yPaintCoord = yy; | 469 | yPaintCoord = yy; |
470 | wPaintCoord = width(); | 470 | wPaintCoord = width(); |
471 | hPaintCoord = height(); | 471 | hPaintCoord = height(); |
472 | globalFlagBlockAgendaItemUpdate = 0; | 472 | globalFlagBlockAgendaItemUpdate = 0; |
473 | paintMe( mSelected ); | 473 | paintMe( mSelected ); |
474 | //qDebug("calling paintMe "); | 474 | //qDebug("calling paintMe "); |
475 | globalFlagBlockAgendaItemUpdate = 1; | 475 | globalFlagBlockAgendaItemUpdate = 1; |
476 | } | 476 | } |
477 | int rx, ry, rw, rh; | 477 | int rx, ry, rw, rh; |
478 | rx = e->rect().x(); | 478 | rx = e->rect().x(); |
479 | ry = e->rect().y(); | 479 | ry = e->rect().y(); |
480 | rw = e->rect().width(); | 480 | rw = e->rect().width(); |
481 | rh = e->rect().height(); | 481 | rh = e->rect().height(); |
482 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 482 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
483 | 483 | ||
484 | QPixmap* paintFrom ; | 484 | QPixmap* paintFrom ; |
485 | if ( mSelected ) { | 485 | if ( mSelected ) { |
486 | paintFrom = paintPixSel(); | 486 | paintFrom = paintPixSel(); |
487 | } else { | 487 | } else { |
488 | if ( mAllDay ) | 488 | if ( mAllDay ) |
489 | paintFrom = paintPixAllday(); | 489 | paintFrom = paintPixAllday(); |
490 | else | 490 | else |
491 | paintFrom = paintPix(); | 491 | paintFrom = paintPix(); |
492 | } | 492 | } |
493 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); | 493 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); |
494 | } | 494 | } |
495 | void KOAgendaItem::computeText() | 495 | void KOAgendaItem::computeText() |
496 | { | 496 | { |
497 | 497 | ||
498 | mDisplayedText = mIncidence->summary(); | 498 | mDisplayedText = mIncidence->summary(); |
499 | if ( (mIncidence->type() == "Todo") ) { | 499 | if ( (mIncidence->type() == "Todo") ) { |
500 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 500 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
501 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 501 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
502 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 502 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
503 | else if ( !(mIncidence->doesFloat())) | 503 | else if ( !(mIncidence->doesFloat())) |
504 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 504 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
505 | } | 505 | } |
506 | } else { | 506 | } else { |
507 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 507 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
508 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 508 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
509 | 509 | ||
510 | if ( mAllDay ) { | 510 | if ( mAllDay ) { |
511 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 511 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
512 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 512 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
513 | } | 513 | } |
514 | } | 514 | } |
515 | 515 | ||
516 | } | 516 | } |
517 | 517 | ||
518 | if ( !mIncidence->location().isEmpty() ) { | 518 | if ( !mIncidence->location().isEmpty() ) { |
519 | if ( mAllDay ) | 519 | if ( mAllDay ) |
520 | mDisplayedText += " ("; | 520 | mDisplayedText += " ("; |
521 | else | 521 | else |
522 | mDisplayedText += "\n("; | 522 | mDisplayedText += "\n("; |
523 | mDisplayedText += mIncidence->location() +")"; | 523 | mDisplayedText += mIncidence->location() +")"; |
524 | } | 524 | } |
525 | 525 | ||
526 | QString tipText = mIncidence->summary(); | 526 | QString tipText = mIncidence->summary(); |
527 | if ( !mIncidence->doesFloat() ) { | 527 | if ( !mIncidence->doesFloat() ) { |
528 | if ( mIncidence->type() == "Event" ) { | 528 | if ( mIncidence->type() == "Event" ) { |
529 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 529 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
530 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 530 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
531 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 531 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
532 | } | 532 | } |
533 | else { | 533 | else { |
534 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 534 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
535 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 535 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
536 | } | 536 | } |
537 | } | 537 | } |
538 | else if ( mIncidence->type() == "Todo" ) { | 538 | else if ( mIncidence->type() == "Todo" ) { |
539 | if (mIncidence->hasStartDate()) | 539 | if (mIncidence->hasStartDate()) |
540 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 540 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
541 | if (((Todo*)mIncidence)->hasDueDate()) | 541 | if (((Todo*)mIncidence)->hasDueDate()) |
542 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 542 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
543 | } | 543 | } |
544 | } else if ( mIncidence->type() == "Todo" ) { | 544 | } else if ( mIncidence->type() == "Todo" ) { |
545 | if (mIncidence->hasStartDate()) | 545 | if (mIncidence->hasStartDate()) |
546 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 546 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
547 | if (((Todo*)mIncidence)->hasDueDate()) | 547 | if (((Todo*)mIncidence)->hasDueDate()) |
548 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 548 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
549 | } | 549 | } |
550 | 550 | ||
551 | if (!mIncidence->location().isEmpty()) { | 551 | if (!mIncidence->location().isEmpty()) { |
552 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 552 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
553 | } | 553 | } |
554 | QToolTip::add(this,tipText,toolTipGroup(),""); | 554 | QToolTip::add(this,tipText,toolTipGroup(),""); |
555 | 555 | ||
556 | } | 556 | } |
557 | void KOAgendaItem::updateItem() | 557 | void KOAgendaItem::updateItem() |
558 | { | 558 | { |
559 | computeText(); | 559 | computeText(); |
560 | 560 | ||
561 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 561 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
562 | paintMe( mSelected ); | 562 | paintMe( mSelected ); |
563 | repaint( false); | 563 | repaint( false); |
564 | } | 564 | } |
565 | 565 | ||
566 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 566 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
567 | { | 567 | { |
568 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 568 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
569 | paintMe( mSelected ); | 569 | paintMe( mSelected ); |
570 | repaint( false ); | 570 | repaint( false ); |
571 | } | 571 | } |
572 | 572 | ||
573 | /* | 573 | /* |
574 | Return height of item in units of agenda cells | 574 | Return height of item in units of agenda cells |
575 | */ | 575 | */ |
576 | int KOAgendaItem::cellHeight() | 576 | int KOAgendaItem::cellHeight() |
577 | { | 577 | { |
578 | int ret = mCellYBottom - mCellYTop + 1; | 578 | int ret = mCellYBottom - mCellYTop + 1; |
579 | if ( ret <= 0 ) { | 579 | if ( ret <= 0 ) { |
580 | ret = 1; | 580 | ret = 1; |
581 | mCellYBottom = 0; | 581 | mCellYBottom = 0; |
582 | mCellYTop = 0; | 582 | mCellYTop = 0; |
583 | } | 583 | } |
584 | return ret; | 584 | return ret; |
585 | } | 585 | } |
586 | 586 | ||
587 | /* | 587 | /* |
588 | Return height of item in units of agenda cells | 588 | Return height of item in units of agenda cells |
589 | */ | 589 | */ |
590 | int KOAgendaItem::cellWidth() | 590 | int KOAgendaItem::cellWidth() |
591 | { | 591 | { |
592 | return mCellXWidth - mCellX + 1; | 592 | return mCellXWidth - mCellX + 1; |
593 | } | 593 | } |
594 | 594 | ||
595 | void KOAgendaItem::setItemDate(QDate qd) | 595 | void KOAgendaItem::setItemDate(QDate qd) |
596 | { | 596 | { |
597 | mDate = qd; | 597 | mDate = qd; |
598 | } | 598 | } |
599 | 599 | ||
600 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 600 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
601 | { | 601 | { |
602 | mCellX = X; | 602 | mCellX = X; |
603 | mCellYTop = YTop; | 603 | mCellYTop = YTop; |
604 | mCellYBottom = YBottom; | 604 | mCellYBottom = YBottom; |
605 | } | 605 | } |
606 | 606 | ||
607 | void KOAgendaItem::setCellXWidth(int xwidth) | 607 | void KOAgendaItem::setCellXWidth(int xwidth) |
608 | { | 608 | { |
609 | mCellXWidth = xwidth; | 609 | mCellXWidth = xwidth; |
610 | } | 610 | } |
611 | 611 | ||
612 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 612 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
613 | { | 613 | { |
614 | mCellX = XLeft; | 614 | mCellX = XLeft; |
615 | mCellXWidth = XRight; | 615 | mCellXWidth = XRight; |
616 | } | 616 | } |
617 | 617 | ||
618 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 618 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
619 | { | 619 | { |
620 | mCellYTop = YTop; | 620 | mCellYTop = YTop; |
621 | mCellYBottom = YBottom; | 621 | mCellYBottom = YBottom; |
622 | } | 622 | } |
623 | 623 | ||
624 | void KOAgendaItem::setSubCell(int subCell) | 624 | void KOAgendaItem::setSubCell(int subCell) |
625 | { | 625 | { |
626 | mSubCell = subCell; | 626 | mSubCell = subCell; |
627 | } | 627 | } |
628 | 628 | ||
629 | void KOAgendaItem::setSubCells(int subCells) | 629 | void KOAgendaItem::setSubCells(int subCells) |
630 | { | 630 | { |
631 | mSubCells = subCells; | 631 | mSubCells = subCells; |
632 | } | 632 | } |
633 | 633 | ||
634 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 634 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
635 | KOAgendaItem *last) | 635 | KOAgendaItem *last) |
636 | { | 636 | { |
637 | mFirstMultiItem = first; | 637 | mFirstMultiItem = first; |
638 | mNextMultiItem = next; | 638 | mNextMultiItem = next; |
639 | mLastMultiItem = last; | 639 | mLastMultiItem = last; |
640 | } | 640 | } |
641 | 641 | ||
642 | void KOAgendaItem::startMove() | 642 | void KOAgendaItem::startMove() |
643 | { | 643 | { |
644 | mStartCellX = mCellX; | 644 | mStartCellX = mCellX; |
645 | mStartCellXWidth = mCellXWidth; | 645 | mStartCellXWidth = mCellXWidth; |
646 | mStartCellYTop = mCellYTop; | 646 | mStartCellYTop = mCellYTop; |
647 | mStartCellYBottom = mCellYBottom; | 647 | mStartCellYBottom = mCellYBottom; |
648 | } | 648 | } |
649 | 649 | ||
650 | void KOAgendaItem::resetMove() | 650 | void KOAgendaItem::resetMove() |
651 | { | 651 | { |
652 | mCellX = mStartCellX; | 652 | mCellX = mStartCellX; |
653 | mCellXWidth = mStartCellXWidth; | 653 | mCellXWidth = mStartCellXWidth; |
654 | mCellYTop = mStartCellYTop; | 654 | mCellYTop = mStartCellYTop; |
655 | mCellYBottom = mStartCellYBottom; | 655 | mCellYBottom = mStartCellYBottom; |
656 | } | 656 | } |
657 | 657 | ||
658 | void KOAgendaItem::moveRelative(int dx, int dy) | 658 | void KOAgendaItem::moveRelative(int dx, int dy) |
659 | { | 659 | { |
660 | int newX = cellX() + dx; | 660 | int newX = cellX() + dx; |
661 | int newXWidth = cellXWidth() + dx; | 661 | int newXWidth = cellXWidth() + dx; |
662 | int newYTop = cellYTop() + dy; | 662 | int newYTop = cellYTop() + dy; |
663 | int newYBottom = cellYBottom() + dy; | 663 | int newYBottom = cellYBottom() + dy; |
664 | setCellXY(newX,newYTop,newYBottom); | 664 | setCellXY(newX,newYTop,newYBottom); |
665 | setCellXWidth(newXWidth); | 665 | setCellXWidth(newXWidth); |
666 | } | 666 | } |
667 | 667 | ||
668 | void KOAgendaItem::expandTop(int dy) | 668 | void KOAgendaItem::expandTop(int dy) |
669 | { | 669 | { |
670 | int newYTop = cellYTop() + dy; | 670 | int newYTop = cellYTop() + dy; |
671 | int newYBottom = cellYBottom(); | 671 | int newYBottom = cellYBottom(); |
672 | if (newYTop > newYBottom) newYTop = newYBottom; | 672 | if (newYTop > newYBottom) newYTop = newYBottom; |
673 | setCellY(newYTop, newYBottom); | 673 | setCellY(newYTop, newYBottom); |
674 | } | 674 | } |
675 | 675 | ||
676 | void KOAgendaItem::expandBottom(int dy) | 676 | void KOAgendaItem::expandBottom(int dy) |
677 | { | 677 | { |
678 | int newYTop = cellYTop(); | 678 | int newYTop = cellYTop(); |
679 | int newYBottom = cellYBottom() + dy; | 679 | int newYBottom = cellYBottom() + dy; |
680 | if (newYBottom < newYTop) newYBottom = newYTop; | 680 | if (newYBottom < newYTop) newYBottom = newYTop; |
681 | setCellY(newYTop, newYBottom); | 681 | setCellY(newYTop, newYBottom); |
682 | } | 682 | } |
683 | 683 | ||
684 | void KOAgendaItem::expandLeft(int dx) | 684 | void KOAgendaItem::expandLeft(int dx) |
685 | { | 685 | { |
686 | int newX = cellX() + dx; | 686 | int newX = cellX() + dx; |
687 | int newXWidth = cellXWidth(); | 687 | int newXWidth = cellXWidth(); |
688 | if (newX > newXWidth) newX = newXWidth; | 688 | if (newX > newXWidth) newX = newXWidth; |
689 | setCellX(newX,newXWidth); | 689 | setCellX(newX,newXWidth); |
690 | } | 690 | } |
691 | 691 | ||
692 | void KOAgendaItem::expandRight(int dx) | 692 | void KOAgendaItem::expandRight(int dx) |
693 | { | 693 | { |
694 | int newX = cellX(); | 694 | int newX = cellX(); |
695 | int newXWidth = cellXWidth() + dx; | 695 | int newXWidth = cellXWidth() + dx; |
696 | if (newXWidth < newX) newXWidth = newX; | 696 | if (newXWidth < newX) newXWidth = newX; |
697 | setCellX(newX,newXWidth); | 697 | setCellX(newX,newXWidth); |
698 | } | 698 | } |
699 | 699 | ||
700 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 700 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
701 | { | 701 | { |
702 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 702 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
703 | return mToolTipGroup; | 703 | return mToolTipGroup; |
704 | } | 704 | } |