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