-rw-r--r-- | korganizer/koagendaitem.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index b30ad75..23afe7a 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,804 +1,808 @@ | |||
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 | mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); | 80 | mKOAgendaItemWhatsThis = 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 | KOPrefs::instance()->mWTshowDetails, | 94 | KOPrefs::instance()->mWTshowDetails, |
95 | KOPrefs::instance()->mWTshowCreated, | 95 | KOPrefs::instance()->mWTshowCreated, |
96 | KOPrefs::instance()->mWTshowChanged); | 96 | KOPrefs::instance()->mWTshowChanged); |
97 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 97 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
98 | } | 98 | } |
99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
100 | { | 100 | { |
101 | mIncidence = incidence; | 101 | mIncidence = incidence; |
102 | mDate = qd; | 102 | mDate = qd; |
103 | mFirstMultiItem = 0; | 103 | mFirstMultiItem = 0; |
104 | mNextMultiItem = 0; | 104 | mNextMultiItem = 0; |
105 | mLastMultiItem = 0; | 105 | mLastMultiItem = 0; |
106 | computeText(); | 106 | computeText(); |
107 | 107 | ||
108 | if ( (incidence->type() == "Todo") && | 108 | if ( (incidence->type() == "Todo") && |
109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && |
110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) |
112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
113 | else | 113 | else |
114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
115 | } | 115 | } |
116 | else { | 116 | else { |
117 | QStringList categories = mIncidence->categories(); | 117 | QStringList categories = mIncidence->categories(); |
118 | QString cat = categories.first(); | 118 | QString cat = categories.first(); |
119 | if (cat.isEmpty()) { | 119 | if (cat.isEmpty()) { |
120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) | 120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) |
121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
122 | else | 122 | else |
123 | mBackgroundColor =KOPrefs::instance()->mEventColor; | 123 | mBackgroundColor =KOPrefs::instance()->mEventColor; |
124 | } else { | 124 | } else { |
125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { | 126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { |
127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | } | 132 | } |
133 | mColorGroup = QColorGroup( mBackgroundColor.light(), | 133 | mColorGroup = QColorGroup( mBackgroundColor.light(), |
134 | mBackgroundColor.dark(),mBackgroundColor.light(), | 134 | mBackgroundColor.dark(),mBackgroundColor.light(), |
135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; | 135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; |
136 | setBackgroundColor( mBackgroundColor ); | 136 | setBackgroundColor( mBackgroundColor ); |
137 | 137 | ||
138 | mConflictItems.clear(); | 138 | mConflictItems.clear(); |
139 | setCellXY(0,0,1); | 139 | setCellXY(0,0,1); |
140 | setCellXWidth(0); | 140 | setCellXWidth(0); |
141 | setSubCell(0); | 141 | setSubCell(0); |
142 | setSubCells(1); | 142 | setSubCells(1); |
143 | setMultiItem(0,0,0); | 143 | setMultiItem(0,0,0); |
144 | startMove(); | 144 | startMove(); |
145 | mSelected = true; | 145 | mSelected = true; |
146 | select(false); | 146 | select(false); |
147 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 147 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
148 | mFontPixelSize = fontinf.height();; | 148 | mFontPixelSize = fontinf.height();; |
149 | hide(); | 149 | hide(); |
150 | xPaintCoord = -1; | 150 | xPaintCoord = -1; |
151 | yPaintCoord = -1; | 151 | yPaintCoord = -1; |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | KOAgendaItem::~KOAgendaItem() | 155 | KOAgendaItem::~KOAgendaItem() |
156 | { | 156 | { |
157 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 157 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
158 | // delete mKOAgendaItemWhatsThis; | 158 | // delete mKOAgendaItemWhatsThis; |
159 | } | 159 | } |
160 | 160 | ||
161 | void KOAgendaItem::recreateIncidence() | 161 | void KOAgendaItem::recreateIncidence() |
162 | { | 162 | { |
163 | #if 0 | 163 | #if 0 |
164 | Incidence* newInc = mIncidence->clone(); | 164 | Incidence* newInc = mIncidence->clone(); |
165 | newInc->recreate(); | 165 | newInc->recreate(); |
166 | if ( mIncidence->doesRecur() ) { | 166 | if ( mIncidence->doesRecur() ) { |
167 | mIncidence->addExDate( mDate ); | 167 | mIncidence->addExDate( mDate ); |
168 | newInc->recurrence()->unsetRecurs(); | 168 | newInc->recurrence()->unsetRecurs(); |
169 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 169 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
170 | QTime tim = mIncidence->dtStart().time(); | 170 | QTime tim = mIncidence->dtStart().time(); |
171 | newInc->setDtStart( QDateTime(mDate, tim) ); | 171 | newInc->setDtStart( QDateTime(mDate, tim) ); |
172 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 172 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
173 | } | 173 | } |
174 | #endif | 174 | #endif |
175 | mIncidence = mIncidence->recreateCloneException( mDate ); | 175 | mIncidence = mIncidence->recreateCloneException( mDate ); |
176 | } | 176 | } |
177 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 177 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
178 | { | 178 | { |
179 | int size = AGENDA_ICON_SIZE; | 179 | int size = AGENDA_ICON_SIZE; |
180 | 180 | ||
181 | int yOff = 0; | 181 | int yOff = 0; |
182 | int xOff = 0; | 182 | int xOff = 0; |
183 | int x = pos().x() +3; | 183 | int x = pos().x() +3; |
184 | int y; | 184 | int y; |
185 | if ( mAllDay ) | 185 | if ( mAllDay ) |
186 | y = pos().y()+3; | 186 | y = pos().y()+3; |
187 | else | 187 | else |
188 | y = mCellYTop * ( height() / cellHeight() ) +3; | 188 | y = mCellYTop * ( height() / cellHeight() ) +3; |
189 | if (mIncidence->cancelled()) { | 189 | if (mIncidence->cancelled()) { |
190 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 190 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
191 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 191 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
192 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 192 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
193 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 193 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
194 | if ( horLayout ) | 194 | if ( horLayout ) |
195 | ++xOff; | 195 | ++xOff; |
196 | else | 196 | else |
197 | ++yOff; | 197 | ++yOff; |
198 | } | 198 | } |
199 | if (mIncidence->isAlarmEnabled()) { | 199 | if (mIncidence->isAlarmEnabled()) { |
200 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 200 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
201 | if ( horLayout ) | 201 | if ( horLayout ) |
202 | ++xOff; | 202 | ++xOff; |
203 | else | 203 | else |
204 | ++yOff; | 204 | ++yOff; |
205 | } | 205 | } |
206 | if (mIncidence->recurrence()->doesRecur()) { | 206 | if (mIncidence->recurrence()->doesRecur()) { |
207 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 207 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
208 | if ( horLayout ) | 208 | if ( horLayout ) |
209 | ++xOff; | 209 | ++xOff; |
210 | else | 210 | else |
211 | ++yOff; | 211 | ++yOff; |
212 | } | 212 | } |
213 | if (mIncidence->description().length() > 0) { | 213 | if (mIncidence->description().length() > 0) { |
214 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 214 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
215 | if ( horLayout ) | 215 | if ( horLayout ) |
216 | ++xOff; | 216 | ++xOff; |
217 | else | 217 | else |
218 | ++yOff; | 218 | ++yOff; |
219 | } | 219 | } |
220 | if (mIncidence->isReadOnly()) { | 220 | if (mIncidence->isReadOnly()) { |
221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
222 | if ( horLayout ) | 222 | if ( horLayout ) |
223 | ++xOff; | 223 | ++xOff; |
224 | else | 224 | else |
225 | ++yOff; | 225 | ++yOff; |
226 | } | 226 | } |
227 | 227 | ||
228 | if (mIncidence->attendeeCount()>0) { | 228 | if (mIncidence->attendeeCount()>0) { |
229 | 229 | ||
230 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 230 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
232 | if ( horLayout ) | 232 | if ( horLayout ) |
233 | ++xOff; | 233 | ++xOff; |
234 | else | 234 | else |
235 | ++yOff; | 235 | ++yOff; |
236 | } else { | 236 | } else { |
237 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 237 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
238 | if (me!=0) { | 238 | if (me!=0) { |
239 | 239 | ||
240 | 240 | ||
241 | } else { | 241 | } else { |
242 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 242 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
243 | if ( horLayout ) | 243 | if ( horLayout ) |
244 | ++xOff; | 244 | ++xOff; |
245 | else | 245 | else |
246 | ++yOff; | 246 | ++yOff; |
247 | 247 | ||
248 | } | 248 | } |
249 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 249 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
250 | if ( horLayout ) | 250 | if ( horLayout ) |
251 | ++xOff; | 251 | ++xOff; |
252 | else | 252 | else |
253 | ++yOff; | 253 | ++yOff; |
254 | 254 | ||
255 | } | 255 | } |
256 | 256 | ||
257 | } | 257 | } |
258 | return ( yOff || xOff ); | 258 | return ( yOff || xOff ); |
259 | } | 259 | } |
260 | 260 | ||
261 | 261 | ||
262 | void KOAgendaItem::select(bool selected) | 262 | void KOAgendaItem::select(bool selected) |
263 | { | 263 | { |
264 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 264 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
265 | if (mSelected == selected) return; | 265 | if (mSelected == selected) return; |
266 | mSelected = selected; | 266 | mSelected = selected; |
267 | if ( ! isVisible() ) | 267 | if ( ! isVisible() ) |
268 | return; | 268 | return; |
269 | if ( firstMultiItem() ) | 269 | if ( firstMultiItem() ) |
270 | firstMultiItem()->select( selected ); | 270 | firstMultiItem()->select( selected ); |
271 | if ( !firstMultiItem() && nextMultiItem() ) { | 271 | if ( !firstMultiItem() && nextMultiItem() ) { |
272 | KOAgendaItem * placeItem = nextMultiItem(); | 272 | KOAgendaItem * placeItem = nextMultiItem(); |
273 | while ( placeItem ) { | 273 | while ( placeItem ) { |
274 | placeItem->select( selected ); | 274 | placeItem->select( selected ); |
275 | placeItem = placeItem->nextMultiItem(); | 275 | placeItem = placeItem->nextMultiItem(); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | globalFlagBlockAgendaItemUpdate = 0; | 278 | globalFlagBlockAgendaItemUpdate = 0; |
279 | paintMe( selected ); | 279 | paintMe( selected ); |
280 | globalFlagBlockAgendaItemUpdate = 1; | 280 | globalFlagBlockAgendaItemUpdate = 1; |
281 | repaint( false ); | 281 | repaint( false ); |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | /* | 285 | /* |
286 | The eventFilter has to filter the mouse events of the agenda item childs. The | 286 | The eventFilter has to filter the mouse events of the agenda item childs. The |
287 | events are fed into the event handling method of KOAgendaItem. This allows the | 287 | events are fed into the event handling method of KOAgendaItem. This allows the |
288 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 288 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
289 | */ | 289 | */ |
290 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 290 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
291 | { | 291 | { |
292 | if (e->type() == QEvent::MouseButtonPress || | 292 | if (e->type() == QEvent::MouseButtonPress || |
293 | e->type() == QEvent::MouseButtonDblClick || | 293 | e->type() == QEvent::MouseButtonDblClick || |
294 | e->type() == QEvent::MouseButtonRelease || | 294 | e->type() == QEvent::MouseButtonRelease || |
295 | e->type() == QEvent::MouseMove) { | 295 | e->type() == QEvent::MouseMove) { |
296 | QMouseEvent *me = (QMouseEvent *)e; | 296 | QMouseEvent *me = (QMouseEvent *)e; |
297 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 297 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
298 | mapToGlobal(me->pos())); | 298 | mapToGlobal(me->pos())); |
299 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 299 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
300 | return event(&returnEvent); | 300 | return event(&returnEvent); |
301 | } else { | 301 | } else { |
302 | return false; | 302 | return false; |
303 | } | 303 | } |
304 | } | 304 | } |
305 | void KOAgendaItem::repaintMe( ) | 305 | void KOAgendaItem::repaintMe( ) |
306 | { | 306 | { |
307 | paintMe ( mSelected ); | 307 | paintMe ( mSelected ); |
308 | } | 308 | } |
309 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 309 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
310 | { | 310 | { |
311 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 311 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
312 | return; | 312 | return; |
313 | QPainter pa; | 313 | QPainter pa; |
314 | 314 | ||
315 | if ( mSelected ) { | 315 | if ( mSelected ) { |
316 | pa.begin( paintPixSel() ); | 316 | pa.begin( paintPixSel() ); |
317 | } else { | 317 | } else { |
318 | if ( mAllDay ) | 318 | if ( mAllDay ) |
319 | pa.begin( paintPixAllday() ); | 319 | pa.begin( paintPixAllday() ); |
320 | else | 320 | else |
321 | pa.begin( paintPix() ); | 321 | pa.begin( paintPix() ); |
322 | } | 322 | } |
323 | int x, yy, w, h; | 323 | int x, yy, w, h; |
324 | float nfh = 7.0; | 324 | float nfh = 7.0; |
325 | x = pos().x(); w = width(); h = height (); | 325 | x = pos().x(); w = width(); h = height (); |
326 | if ( mAllDay ) | 326 | if ( mAllDay ) |
327 | yy = y(); | 327 | yy = y(); |
328 | else | 328 | else |
329 | yy = mCellYTop * ( height() / cellHeight() ); | 329 | yy = mCellYTop * ( height() / cellHeight() ); |
330 | xPaintCoord= x; | 330 | xPaintCoord= x; |
331 | yPaintCoord = yy; | 331 | yPaintCoord = yy; |
332 | wPaintCoord = width(); | 332 | wPaintCoord = width(); |
333 | hPaintCoord = height(); | 333 | hPaintCoord = height(); |
334 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 334 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
335 | if ( paint == 0 ) | 335 | if ( paint == 0 ) |
336 | paint = &pa; | 336 | paint = &pa; |
337 | bool horLayout = ( w < h ); | 337 | bool horLayout = ( w < h ); |
338 | int maxhei = mFontPixelSize+4; | 338 | int maxhei = mFontPixelSize+4; |
339 | if ( horLayout ) | 339 | if ( horLayout ) |
340 | maxhei += AGENDA_ICON_SIZE -4; | 340 | maxhei += AGENDA_ICON_SIZE -4; |
341 | bool small = ( h < maxhei ); | 341 | bool small = ( h < maxhei ); |
342 | if ( ! small ) | 342 | if ( ! small ) |
343 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 343 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
344 | else { | 344 | else { |
345 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 345 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
346 | f.setBold( false ); | 346 | f.setBold( false ); |
347 | int fh = f.pointSize(); | 347 | int fh = f.pointSize(); |
348 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 348 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
349 | if ( nfh < 6 ) | 349 | if ( nfh < 6 ) |
350 | nfh = 6; | 350 | nfh = 6; |
351 | f.setPointSize( nfh ); | 351 | f.setPointSize( nfh ); |
352 | paint->setFont(f); | 352 | paint->setFont(f); |
353 | } | 353 | } |
354 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 354 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
355 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 355 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
356 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 356 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
357 | if ( mIncidence->type() == "Todo" ) { | 357 | if ( mIncidence->type() == "Todo" ) { |
358 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 358 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
359 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 359 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
360 | int yyy = yy+3; | 360 | int yyy = yy+3; |
361 | if ( tempTodo->isCompleted() ) | 361 | if ( tempTodo->isCompleted() ) |
362 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 362 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
363 | else { | 363 | else { |
364 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 364 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
365 | 365 | ||
366 | } | 366 | } |
367 | } | 367 | } |
368 | bool addIcon = false; | 368 | bool addIcon = false; |
369 | if ( ! small || w > 3 * h || h > 3* w ) | 369 | if ( ! small || w > 3 * h || h > 3* w ) |
370 | addIcon = updateIcons( paint, horLayout ); | 370 | addIcon = updateIcons( paint, horLayout ); |
371 | 371 | ||
372 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 372 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
373 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 373 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
374 | if ( ! small ) { | 374 | if ( ! small ) { |
375 | x += 3; yy += 3;w -= 6; h-= 5; | 375 | x += 3; yy += 3;w -= 6; h-= 5; |
376 | } else { | 376 | } else { |
377 | x += 2; yy += 1;w -= 4; h-= 4; | 377 | x += 2; yy += 1;w -= 4; h-= 4; |
378 | if ( nfh < 6.01 ) { | 378 | if ( nfh < 6.01 ) { |
379 | yy -= 2; | 379 | yy -= 2; |
380 | h += 4; | 380 | h += 4; |
381 | } | 381 | } |
382 | else | 382 | else |
383 | if ( nfh < h -2 ) | 383 | if ( nfh < h -2 ) |
384 | ++yy; | 384 | ++yy; |
385 | } | 385 | } |
386 | int align; | 386 | int align; |
387 | #ifndef DESKTOP_VERSION | 387 | #ifndef DESKTOP_VERSION |
388 | align = ( AlignLeft|WordBreak|AlignTop); | 388 | align = ( AlignLeft|WordBreak|AlignTop); |
389 | #else | 389 | #else |
390 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 390 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
391 | #endif | 391 | #endif |
392 | if ( addIcon ) { | 392 | if ( addIcon ) { |
393 | if ( ! horLayout ) { | 393 | if ( ! horLayout ) { |
394 | x += AGENDA_ICON_SIZE+3; | 394 | x += AGENDA_ICON_SIZE+3; |
395 | w -= (AGENDA_ICON_SIZE+3); | 395 | w -= (AGENDA_ICON_SIZE+3); |
396 | } | 396 | } |
397 | else { | 397 | else { |
398 | yy+= AGENDA_ICON_SIZE+2; | 398 | yy+= AGENDA_ICON_SIZE+2; |
399 | h -=(AGENDA_ICON_SIZE+3); | 399 | h -=(AGENDA_ICON_SIZE+3); |
400 | } | 400 | } |
401 | } | 401 | } |
402 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 402 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
403 | if ( colsum < 250 ) | 403 | if ( colsum < 250 ) |
404 | paint->setPen ( white); | 404 | paint->setPen ( white); |
405 | if ( x < 0 ) { | 405 | if ( x < 0 ) { |
406 | w = w+x-3; | 406 | w = w+x-3; |
407 | x = 3; | 407 | x = 3; |
408 | if ( w > parentWidget()->width() ){ | 408 | if ( w > parentWidget()->width() ){ |
409 | w = parentWidget()->width() - 6; | 409 | w = parentWidget()->width() - 6; |
410 | #ifndef DESKTOP_VERSION | 410 | #ifndef DESKTOP_VERSION |
411 | align = ( AlignHCenter|WordBreak|AlignTop); | 411 | align = ( AlignHCenter|WordBreak|AlignTop); |
412 | #else | 412 | #else |
413 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 413 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
414 | #endif | 414 | #endif |
415 | 415 | ||
416 | } | 416 | } |
417 | } | 417 | } |
418 | QRect dr; | 418 | QRect dr; |
419 | if ( w + x > parentWidget()->width() ) | 419 | if ( w + x > parentWidget()->width() ) |
420 | w = parentWidget()->width()-x; | 420 | w = parentWidget()->width()-x; |
421 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 421 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
422 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 422 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
423 | if ( mIncidence->cancelled() ){ | 423 | if ( mIncidence->cancelled() ){ |
424 | |||
425 | |||
426 | small = ( height() < 20 ); | ||
427 | |||
424 | if ( ! small ) { | 428 | if ( ! small ) { |
425 | QFontMetrics fm ( paint->font() ); | 429 | QFontMetrics fm ( paint->font() ); |
426 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 430 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
427 | } | 431 | } |
428 | 432 | ||
429 | } | 433 | } |
430 | pa.end(); | 434 | pa.end(); |
431 | 435 | ||
432 | } | 436 | } |
433 | void KOAgendaItem::resizePixmap( int w , int h ) | 437 | void KOAgendaItem::resizePixmap( int w , int h ) |
434 | { | 438 | { |
435 | paintPix()->resize( w, h ); | 439 | paintPix()->resize( w, h ); |
436 | paintPixSel()->resize( w, h ); | 440 | paintPixSel()->resize( w, h ); |
437 | 441 | ||
438 | } | 442 | } |
439 | QPixmap * KOAgendaItem::paintPix() | 443 | QPixmap * KOAgendaItem::paintPix() |
440 | { | 444 | { |
441 | static QPixmap* mPaintPix = 0; | 445 | static QPixmap* mPaintPix = 0; |
442 | if ( ! mPaintPix ) | 446 | if ( ! mPaintPix ) |
443 | mPaintPix = new QPixmap(1,1); | 447 | mPaintPix = new QPixmap(1,1); |
444 | return mPaintPix ; | 448 | return mPaintPix ; |
445 | } | 449 | } |
446 | QPixmap * KOAgendaItem::paintPixAllday() | 450 | QPixmap * KOAgendaItem::paintPixAllday() |
447 | { | 451 | { |
448 | static QPixmap* mPaintPixA = 0; | 452 | static QPixmap* mPaintPixA = 0; |
449 | if ( ! mPaintPixA ) | 453 | if ( ! mPaintPixA ) |
450 | mPaintPixA = new QPixmap(1,1); | 454 | mPaintPixA = new QPixmap(1,1); |
451 | return mPaintPixA ; | 455 | return mPaintPixA ; |
452 | } | 456 | } |
453 | QPixmap * KOAgendaItem::paintPixSel() | 457 | QPixmap * KOAgendaItem::paintPixSel() |
454 | { | 458 | { |
455 | static QPixmap* mPaintPixSel = 0; | 459 | static QPixmap* mPaintPixSel = 0; |
456 | if ( ! mPaintPixSel ) | 460 | if ( ! mPaintPixSel ) |
457 | mPaintPixSel = new QPixmap(1,1); | 461 | mPaintPixSel = new QPixmap(1,1); |
458 | return mPaintPixSel ; | 462 | return mPaintPixSel ; |
459 | } | 463 | } |
460 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 464 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
461 | { | 465 | { |
462 | 466 | ||
463 | if ( globalFlagBlockAgendaItemPaint ) | 467 | if ( globalFlagBlockAgendaItemPaint ) |
464 | return; | 468 | return; |
465 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 469 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
466 | return; | 470 | return; |
467 | int yy; | 471 | int yy; |
468 | if ( mAllDay ) | 472 | if ( mAllDay ) |
469 | yy = y(); | 473 | yy = y(); |
470 | else | 474 | else |
471 | yy = mCellYTop * ( height() / cellHeight() ); | 475 | yy = mCellYTop * ( height() / cellHeight() ); |
472 | int xx = x(); | 476 | int xx = x(); |
473 | 477 | ||
474 | if ( xPaintCoord != xx || yPaintCoord != yy || | 478 | if ( xPaintCoord != xx || yPaintCoord != yy || |
475 | wPaintCoord != width() || hPaintCoord != height()) { | 479 | wPaintCoord != width() || hPaintCoord != height()) { |
476 | xPaintCoord= xx; | 480 | xPaintCoord= xx; |
477 | yPaintCoord = yy; | 481 | yPaintCoord = yy; |
478 | wPaintCoord = width(); | 482 | wPaintCoord = width(); |
479 | hPaintCoord = height(); | 483 | hPaintCoord = height(); |
480 | globalFlagBlockAgendaItemUpdate = 0; | 484 | globalFlagBlockAgendaItemUpdate = 0; |
481 | paintMe( mSelected ); | 485 | paintMe( mSelected ); |
482 | //qDebug("calling paintMe "); | 486 | //qDebug("calling paintMe "); |
483 | globalFlagBlockAgendaItemUpdate = 1; | 487 | globalFlagBlockAgendaItemUpdate = 1; |
484 | } | 488 | } |
485 | int rx, ry, rw, rh; | 489 | int rx, ry, rw, rh; |
486 | rx = e->rect().x(); | 490 | rx = e->rect().x(); |
487 | ry = e->rect().y(); | 491 | ry = e->rect().y(); |
488 | rw = e->rect().width(); | 492 | rw = e->rect().width(); |
489 | rh = e->rect().height(); | 493 | rh = e->rect().height(); |
490 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 494 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
491 | 495 | ||
492 | QPixmap* paintFrom ; | 496 | QPixmap* paintFrom ; |
493 | if ( mSelected ) { | 497 | if ( mSelected ) { |
494 | paintFrom = paintPixSel(); | 498 | paintFrom = paintPixSel(); |
495 | } else { | 499 | } else { |
496 | if ( mAllDay ) | 500 | if ( mAllDay ) |
497 | paintFrom = paintPixAllday(); | 501 | paintFrom = paintPixAllday(); |
498 | else | 502 | else |
499 | paintFrom = paintPix(); | 503 | paintFrom = paintPix(); |
500 | } | 504 | } |
501 | xx += rx; | 505 | xx += rx; |
502 | 506 | ||
503 | if ( xx < 0 ) { | 507 | if ( xx < 0 ) { |
504 | rw = rw + xx; | 508 | rw = rw + xx; |
505 | rx -= xx; | 509 | rx -= xx; |
506 | xx = 0; | 510 | xx = 0; |
507 | if ( rw <= 1 ) { | 511 | if ( rw <= 1 ) { |
508 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); | 512 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); |
509 | return; | 513 | return; |
510 | } | 514 | } |
511 | } | 515 | } |
512 | if ( paintFrom->width() < xx+rw ) { | 516 | if ( paintFrom->width() < xx+rw ) { |
513 | rw = paintFrom->width() - xx; | 517 | rw = paintFrom->width() - xx; |
514 | if ( rw <= 1 ) { | 518 | if ( rw <= 1 ) { |
515 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); | 519 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); |
516 | return; | 520 | return; |
517 | } | 521 | } |
518 | } | 522 | } |
519 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); | 523 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); |
520 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); | 524 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); |
521 | } | 525 | } |
522 | void KOAgendaItem::computeText() | 526 | void KOAgendaItem::computeText() |
523 | { | 527 | { |
524 | 528 | ||
525 | mDisplayedText = mIncidence->summary(); | 529 | mDisplayedText = mIncidence->summary(); |
526 | if ( (mIncidence->type() == "Todo") ) { | 530 | if ( (mIncidence->type() == "Todo") ) { |
527 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 531 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
528 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 532 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
529 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 533 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
530 | else if ( !(mIncidence->doesFloat())) | 534 | else if ( !(mIncidence->doesFloat())) |
531 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 535 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
532 | } | 536 | } |
533 | } else { | 537 | } else { |
534 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 538 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
535 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 539 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
536 | 540 | ||
537 | if ( mAllDay ) { | 541 | if ( mAllDay ) { |
538 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 542 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
539 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 543 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
540 | } | 544 | } |
541 | } | 545 | } |
542 | 546 | ||
543 | } | 547 | } |
544 | 548 | ||
545 | if ( !mIncidence->location().isEmpty() ) { | 549 | if ( !mIncidence->location().isEmpty() ) { |
546 | if ( mAllDay ) | 550 | if ( mAllDay ) |
547 | mDisplayedText += " ("; | 551 | mDisplayedText += " ("; |
548 | else | 552 | else |
549 | mDisplayedText += "\n("; | 553 | mDisplayedText += "\n("; |
550 | mDisplayedText += mIncidence->location() +")"; | 554 | mDisplayedText += mIncidence->location() +")"; |
551 | } | 555 | } |
552 | 556 | ||
553 | QString tipText = mIncidence->summary(); | 557 | QString tipText = mIncidence->summary(); |
554 | if ( !mIncidence->doesFloat() ) { | 558 | if ( !mIncidence->doesFloat() ) { |
555 | if ( mIncidence->type() == "Event" ) { | 559 | if ( mIncidence->type() == "Event" ) { |
556 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 560 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
557 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 561 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
558 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 562 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
559 | } | 563 | } |
560 | else { | 564 | else { |
561 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 565 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
562 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 566 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
563 | } | 567 | } |
564 | } | 568 | } |
565 | else if ( mIncidence->type() == "Todo" ) { | 569 | else if ( mIncidence->type() == "Todo" ) { |
566 | if (mIncidence->hasStartDate()) | 570 | if (mIncidence->hasStartDate()) |
567 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 571 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
568 | if (((Todo*)mIncidence)->hasDueDate()) | 572 | if (((Todo*)mIncidence)->hasDueDate()) |
569 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 573 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
570 | } | 574 | } |
571 | } else if ( mIncidence->type() == "Todo" ) { | 575 | } else if ( mIncidence->type() == "Todo" ) { |
572 | if (mIncidence->hasStartDate()) | 576 | if (mIncidence->hasStartDate()) |
573 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 577 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
574 | if (((Todo*)mIncidence)->hasDueDate()) | 578 | if (((Todo*)mIncidence)->hasDueDate()) |
575 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 579 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
576 | } | 580 | } |
577 | 581 | ||
578 | if (!mIncidence->location().isEmpty()) { | 582 | if (!mIncidence->location().isEmpty()) { |
579 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 583 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
580 | } | 584 | } |
581 | QToolTip::add(this,tipText,toolTipGroup(),""); | 585 | QToolTip::add(this,tipText,toolTipGroup(),""); |
582 | 586 | ||
583 | } | 587 | } |
584 | void KOAgendaItem::updateItem() | 588 | void KOAgendaItem::updateItem() |
585 | { | 589 | { |
586 | computeText(); | 590 | computeText(); |
587 | 591 | ||
588 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 592 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
589 | paintMe( mSelected ); | 593 | paintMe( mSelected ); |
590 | repaint( false); | 594 | repaint( false); |
591 | } | 595 | } |
592 | 596 | ||
593 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 597 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
594 | { | 598 | { |
595 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 599 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
596 | paintMe( mSelected ); | 600 | paintMe( mSelected ); |
597 | repaint( false ); | 601 | repaint( false ); |
598 | } | 602 | } |
599 | 603 | ||
600 | /* | 604 | /* |
601 | Return height of item in units of agenda cells | 605 | Return height of item in units of agenda cells |
602 | */ | 606 | */ |
603 | int KOAgendaItem::cellHeight() | 607 | int KOAgendaItem::cellHeight() |
604 | { | 608 | { |
605 | int ret = mCellYBottom - mCellYTop + 1; | 609 | int ret = mCellYBottom - mCellYTop + 1; |
606 | if ( ret <= 0 ) { | 610 | if ( ret <= 0 ) { |
607 | ret = 1; | 611 | ret = 1; |
608 | mCellYBottom = 0; | 612 | mCellYBottom = 0; |
609 | mCellYTop = 0; | 613 | mCellYTop = 0; |
610 | } | 614 | } |
611 | return ret; | 615 | return ret; |
612 | } | 616 | } |
613 | 617 | ||
614 | /* | 618 | /* |
615 | Return height of item in units of agenda cells | 619 | Return height of item in units of agenda cells |
616 | */ | 620 | */ |
617 | int KOAgendaItem::cellWidth() | 621 | int KOAgendaItem::cellWidth() |
618 | { | 622 | { |
619 | return mCellXWidth - mCellX + 1; | 623 | return mCellXWidth - mCellX + 1; |
620 | } | 624 | } |
621 | 625 | ||
622 | void KOAgendaItem::setItemDate(QDate qd) | 626 | void KOAgendaItem::setItemDate(QDate qd) |
623 | { | 627 | { |
624 | mDate = qd; | 628 | mDate = qd; |
625 | } | 629 | } |
626 | 630 | ||
627 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 631 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
628 | { | 632 | { |
629 | mCellX = X; | 633 | mCellX = X; |
630 | mCellYTop = YTop; | 634 | mCellYTop = YTop; |
631 | mCellYBottom = YBottom; | 635 | mCellYBottom = YBottom; |
632 | } | 636 | } |
633 | 637 | ||
634 | void KOAgendaItem::setCellXWidth(int xwidth) | 638 | void KOAgendaItem::setCellXWidth(int xwidth) |
635 | { | 639 | { |
636 | mCellXWidth = xwidth; | 640 | mCellXWidth = xwidth; |
637 | } | 641 | } |
638 | 642 | ||
639 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 643 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
640 | { | 644 | { |
641 | mCellX = XLeft; | 645 | mCellX = XLeft; |
642 | mCellXWidth = XRight; | 646 | mCellXWidth = XRight; |
643 | } | 647 | } |
644 | 648 | ||
645 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 649 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
646 | { | 650 | { |
647 | mCellYTop = YTop; | 651 | mCellYTop = YTop; |
648 | mCellYBottom = YBottom; | 652 | mCellYBottom = YBottom; |
649 | } | 653 | } |
650 | 654 | ||
651 | void KOAgendaItem::setSubCell(int subCell) | 655 | void KOAgendaItem::setSubCell(int subCell) |
652 | { | 656 | { |
653 | mSubCell = subCell; | 657 | mSubCell = subCell; |
654 | } | 658 | } |
655 | 659 | ||
656 | void KOAgendaItem::setSubCells(int subCells) | 660 | void KOAgendaItem::setSubCells(int subCells) |
657 | { | 661 | { |
658 | mSubCells = subCells; | 662 | mSubCells = subCells; |
659 | } | 663 | } |
660 | 664 | ||
661 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 665 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
662 | KOAgendaItem *last) | 666 | KOAgendaItem *last) |
663 | { | 667 | { |
664 | mFirstMultiItem = first; | 668 | mFirstMultiItem = first; |
665 | mNextMultiItem = next; | 669 | mNextMultiItem = next; |
666 | mLastMultiItem = last; | 670 | mLastMultiItem = last; |
667 | } | 671 | } |
668 | 672 | ||
669 | void KOAgendaItem::startMove() | 673 | void KOAgendaItem::startMove() |
670 | { | 674 | { |
671 | mStartCellX = mCellX; | 675 | mStartCellX = mCellX; |
672 | mStartCellXWidth = mCellXWidth; | 676 | mStartCellXWidth = mCellXWidth; |
673 | mStartCellYTop = mCellYTop; | 677 | mStartCellYTop = mCellYTop; |
674 | mStartCellYBottom = mCellYBottom; | 678 | mStartCellYBottom = mCellYBottom; |
675 | } | 679 | } |
676 | 680 | ||
677 | void KOAgendaItem::resetMove() | 681 | void KOAgendaItem::resetMove() |
678 | { | 682 | { |
679 | mCellX = mStartCellX; | 683 | mCellX = mStartCellX; |
680 | mCellXWidth = mStartCellXWidth; | 684 | mCellXWidth = mStartCellXWidth; |
681 | mCellYTop = mStartCellYTop; | 685 | mCellYTop = mStartCellYTop; |
682 | mCellYBottom = mStartCellYBottom; | 686 | mCellYBottom = mStartCellYBottom; |
683 | } | 687 | } |
684 | 688 | ||
685 | void KOAgendaItem::moveRelative(int dx, int dy) | 689 | void KOAgendaItem::moveRelative(int dx, int dy) |
686 | { | 690 | { |
687 | int newX = cellX() + dx; | 691 | int newX = cellX() + dx; |
688 | int newXWidth = cellXWidth() + dx; | 692 | int newXWidth = cellXWidth() + dx; |
689 | int newYTop = cellYTop() + dy; | 693 | int newYTop = cellYTop() + dy; |
690 | int newYBottom = cellYBottom() + dy; | 694 | int newYBottom = cellYBottom() + dy; |
691 | setCellXY(newX,newYTop,newYBottom); | 695 | setCellXY(newX,newYTop,newYBottom); |
692 | setCellXWidth(newXWidth); | 696 | setCellXWidth(newXWidth); |
693 | } | 697 | } |
694 | 698 | ||
695 | void KOAgendaItem::expandTop(int dy) | 699 | void KOAgendaItem::expandTop(int dy) |
696 | { | 700 | { |
697 | int newYTop = cellYTop() + dy; | 701 | int newYTop = cellYTop() + dy; |
698 | int newYBottom = cellYBottom(); | 702 | int newYBottom = cellYBottom(); |
699 | if (newYTop > newYBottom) newYTop = newYBottom; | 703 | if (newYTop > newYBottom) newYTop = newYBottom; |
700 | setCellY(newYTop, newYBottom); | 704 | setCellY(newYTop, newYBottom); |
701 | } | 705 | } |
702 | 706 | ||
703 | void KOAgendaItem::expandBottom(int dy) | 707 | void KOAgendaItem::expandBottom(int dy) |
704 | { | 708 | { |
705 | int newYTop = cellYTop(); | 709 | int newYTop = cellYTop(); |
706 | int newYBottom = cellYBottom() + dy; | 710 | int newYBottom = cellYBottom() + dy; |
707 | if (newYBottom < newYTop) newYBottom = newYTop; | 711 | if (newYBottom < newYTop) newYBottom = newYTop; |
708 | setCellY(newYTop, newYBottom); | 712 | setCellY(newYTop, newYBottom); |
709 | } | 713 | } |
710 | 714 | ||
711 | void KOAgendaItem::expandLeft(int dx) | 715 | void KOAgendaItem::expandLeft(int dx) |
712 | { | 716 | { |
713 | int newX = cellX() + dx; | 717 | int newX = cellX() + dx; |
714 | int newXWidth = cellXWidth(); | 718 | int newXWidth = cellXWidth(); |
715 | if (newX > newXWidth) newX = newXWidth; | 719 | if (newX > newXWidth) newX = newXWidth; |
716 | setCellX(newX,newXWidth); | 720 | setCellX(newX,newXWidth); |
717 | } | 721 | } |
718 | 722 | ||
719 | void KOAgendaItem::expandRight(int dx) | 723 | void KOAgendaItem::expandRight(int dx) |
720 | { | 724 | { |
721 | int newX = cellX(); | 725 | int newX = cellX(); |
722 | int newXWidth = cellXWidth() + dx; | 726 | int newXWidth = cellXWidth() + dx; |
723 | if (newXWidth < newX) newXWidth = newX; | 727 | if (newXWidth < newX) newXWidth = newX; |
724 | setCellX(newX,newXWidth); | 728 | setCellX(newX,newXWidth); |
725 | } | 729 | } |
726 | 730 | ||
727 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 731 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
728 | { | 732 | { |
729 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 733 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
730 | return mToolTipGroup; | 734 | return mToolTipGroup; |
731 | } | 735 | } |
732 | 736 | ||
733 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 737 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
734 | { | 738 | { |
735 | #ifndef KORG_NODND | 739 | #ifndef KORG_NODND |
736 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 740 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
737 | !QTextDrag::canDecode( e ) ) { | 741 | !QTextDrag::canDecode( e ) ) { |
738 | e->ignore(); | 742 | e->ignore(); |
739 | return; | 743 | return; |
740 | } | 744 | } |
741 | e->accept(); | 745 | e->accept(); |
742 | #endif | 746 | #endif |
743 | } | 747 | } |
744 | 748 | ||
745 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 749 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
746 | { | 750 | { |
747 | #ifndef KORG_NODND | 751 | #ifndef KORG_NODND |
748 | QString text; | 752 | QString text; |
749 | if(QTextDrag::decode(e,text)) | 753 | if(QTextDrag::decode(e,text)) |
750 | { | 754 | { |
751 | kdDebug() << "Dropped : " << text << endl; | 755 | kdDebug() << "Dropped : " << text << endl; |
752 | QStringList emails = QStringList::split(",",text); | 756 | QStringList emails = QStringList::split(",",text); |
753 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 757 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
754 | kdDebug() << " Email: " << (*it) << endl; | 758 | kdDebug() << " Email: " << (*it) << endl; |
755 | int pos = (*it).find("<"); | 759 | int pos = (*it).find("<"); |
756 | QString name = (*it).left(pos); | 760 | QString name = (*it).left(pos); |
757 | QString email = (*it).mid(pos); | 761 | QString email = (*it).mid(pos); |
758 | if (!email.isEmpty()) { | 762 | if (!email.isEmpty()) { |
759 | mIncidence->addAttendee(new Attendee(name,email)); | 763 | mIncidence->addAttendee(new Attendee(name,email)); |
760 | } | 764 | } |
761 | } | 765 | } |
762 | } | 766 | } |
763 | #endif | 767 | #endif |
764 | } | 768 | } |
765 | 769 | ||
766 | 770 | ||
767 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 771 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
768 | { | 772 | { |
769 | return mConflictItems; | 773 | return mConflictItems; |
770 | } | 774 | } |
771 | 775 | ||
772 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 776 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
773 | { | 777 | { |
774 | mConflictItems = ci; | 778 | mConflictItems = ci; |
775 | KOAgendaItem *item; | 779 | KOAgendaItem *item; |
776 | for ( item=mConflictItems.first(); item != 0; | 780 | for ( item=mConflictItems.first(); item != 0; |
777 | item=mConflictItems.next() ) { | 781 | item=mConflictItems.next() ) { |
778 | item->addConflictItem(this); | 782 | item->addConflictItem(this); |
779 | } | 783 | } |
780 | } | 784 | } |
781 | 785 | ||
782 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 786 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
783 | { | 787 | { |
784 | if (mConflictItems.find(ci)<0) | 788 | if (mConflictItems.find(ci)<0) |
785 | mConflictItems.append(ci); | 789 | mConflictItems.append(ci); |
786 | } | 790 | } |
787 | 791 | ||
788 | bool KOAgendaItem::checkLayout() | 792 | bool KOAgendaItem::checkLayout() |
789 | { | 793 | { |
790 | if ( !mConflictItems.count() ) | 794 | if ( !mConflictItems.count() ) |
791 | return true; | 795 | return true; |
792 | int max = 0; | 796 | int max = 0; |
793 | KOAgendaItem *item; | 797 | KOAgendaItem *item; |
794 | for ( item=mConflictItems.first(); item != 0; | 798 | for ( item=mConflictItems.first(); item != 0; |
795 | item=mConflictItems.next() ) { | 799 | item=mConflictItems.next() ) { |
796 | if ( item->subCells() > max ) | 800 | if ( item->subCells() > max ) |
797 | max = item->subCells(); | 801 | max = item->subCells(); |
798 | } | 802 | } |
799 | if ( max > subCells() ) { | 803 | if ( max > subCells() ) { |
800 | setSubCells( max ); | 804 | setSubCells( max ); |
801 | return false; | 805 | return false; |
802 | } | 806 | } |
803 | return true; | 807 | return true; |
804 | } | 808 | } |