summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-02 18:47:56 (UTC)
committer zautrix <zautrix>2005-07-02 18:47:56 (UTC)
commit27c100807f471a63d91ee08bdba3549d3a0cff8c (patch) (unidiff)
treee731c6f1891ecf3ea843769a2c91053ee79ed24e
parent80fe6533cb7d751aa72ae5ad0871a9fb76fb3d0b (diff)
downloadkdepimpi-27c100807f471a63d91ee08bdba3549d3a0cff8c.zip
kdepimpi-27c100807f471a63d91ee08bdba3549d3a0cff8c.tar.gz
kdepimpi-27c100807f471a63d91ee08bdba3549d3a0cff8c.tar.bz2
fox
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index a42d07b..c055eb8 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,394 +1,408 @@
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>
44extern int globalFlagBlockAgenda; 44extern int globalFlagBlockAgenda;
45extern int globalFlagBlockAgendaItemPaint; 45extern int globalFlagBlockAgendaItemPaint;
46extern int globalFlagBlockAgendaItemUpdate; 46extern 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
56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
57 57
58//-------------------------------------------------------------------------- 58//--------------------------------------------------------------------------
59 59
60class KOAgendaItemWhatsThis :public QWhatsThis 60class KOAgendaItemWhatsThis :public QWhatsThis
61{ 61{
62public: 62public:
63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
64 64
65protected: 65protected:
66 virtual QString text( const QPoint& ) 66 virtual QString text( const QPoint& )
67 { 67 {
68 return _view->getWhatsThisText() ; 68 return _view->getWhatsThisText() ;
69 } 69 }
70private: 70private:
71 KOAgendaItem * _view; 71 KOAgendaItem * _view;
72}; 72};
73 73
74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 74KOAgendaItem::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}
91QString KOAgendaItem::getWhatsThisText() 91QString 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 100
101void KOAgendaItem::initColor () 101void KOAgendaItem::initColor ()
102{ 102{
103 if ( (mIncidence->typeID() == todoID ) && 103 if ( (mIncidence->typeID() == todoID ) &&
104 ( !((static_cast<Todo*>(mIncidence))->isCompleted()) && 104 ( !((static_cast<Todo*>(mIncidence))->isCompleted()) &&
105 ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) { 105 ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) {
106 if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date()) 106 if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date())
107 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 107 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
108 else 108 else
109 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 109 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
110 } 110 }
111 else { 111 else {
112 QStringList categories = mIncidence->categories(); 112 QStringList categories = mIncidence->categories();
113 QString cat = categories.first(); 113 QString cat = categories.first();
114 if (cat.isEmpty()) { 114 if (cat.isEmpty()) {
115 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) 115 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) )
116 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 116 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
117 else 117 else
118 mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() ); 118 mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() );
119 } else { 119 } else {
120 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 120 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
121 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) { 121 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) {
122 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 122 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
123 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; 123 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor;
124 } 124 }
125 } 125 }
126 126
127 } 127 }
128 128
129 QColor BackgroundColor ( mBackgroundColor ); 129 QColor BackgroundColor ( mBackgroundColor );
130 if ( mIncidence->calID() > 1 ) { 130 if ( mIncidence->calID() > 1 ) {
131 BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); 131 //BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() );
132 } 132 }
133 mColorGroup = QColorGroup( BackgroundColor.light(), 133 mColorGroup = QColorGroup( BackgroundColor.light(),
134 BackgroundColor.dark(),BackgroundColor.light(), 134 BackgroundColor.dark(),BackgroundColor.light(),
135 BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; 135 BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ;
136 setBackgroundColor( mBackgroundColor ); 136 setBackgroundColor( mBackgroundColor );
137 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); 137 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250);
138} 138}
139void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 139void KOAgendaItem::init ( Incidence *incidence, QDate qd )
140{ 140{
141 mIncidence = incidence; 141 mIncidence = incidence;
142 mDate = qd; 142 mDate = qd;
143 mFirstMultiItem = 0; 143 mFirstMultiItem = 0;
144 mNextMultiItem = 0; 144 mNextMultiItem = 0;
145 mLastMultiItem = 0; 145 mLastMultiItem = 0;
146 computeText(); 146 computeText();
147 initColor(); 147 initColor();
148 mConflictItems.clear(); 148 mConflictItems.clear();
149 setCellXY(0,0,1); 149 setCellXY(0,0,1);
150 setCellXWidth(0); 150 setCellXWidth(0);
151 setSubCell(0); 151 setSubCell(0);
152 setSubCells(1); 152 setSubCells(1);
153 setMultiItem(0,0,0); 153 setMultiItem(0,0,0);
154 startMove(); 154 startMove();
155 mSelected = true; 155 mSelected = true;
156 select(false); 156 select(false);
157 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 157 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
158 mFontPixelSize = fontinf.height();; 158 mFontPixelSize = fontinf.height();;
159 hide(); 159 hide();
160 xPaintCoord = -1; 160 xPaintCoord = -1;
161 yPaintCoord = -1; 161 yPaintCoord = -1;
162} 162}
163 163
164 164
165KOAgendaItem::~KOAgendaItem() 165KOAgendaItem::~KOAgendaItem()
166{ 166{
167#if QT_VERSION >= 0x030000 167#if QT_VERSION >= 0x030000
168 168
169#else 169#else
170 delete mKOAgendaItemWhatsThis; 170 delete mKOAgendaItemWhatsThis;
171#endif 171#endif
172 172
173} 173}
174 174
175void KOAgendaItem::recreateIncidence() 175void KOAgendaItem::recreateIncidence()
176{ 176{
177#if 0 177#if 0
178 Incidence* newInc = mIncidence->clone(); 178 Incidence* newInc = mIncidence->clone();
179 newInc->recreate(); 179 newInc->recreate();
180 if ( mIncidence->doesRecur() ) { 180 if ( mIncidence->doesRecur() ) {
181 mIncidence->addExDate( mDate ); 181 mIncidence->addExDate( mDate );
182 newInc->recurrence()->unsetRecurs(); 182 newInc->recurrence()->unsetRecurs();
183 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 183 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
184 QTime tim = mIncidence->dtStart().time(); 184 QTime tim = mIncidence->dtStart().time();
185 newInc->setDtStart( QDateTime(mDate, tim) ); 185 newInc->setDtStart( QDateTime(mDate, tim) );
186 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 186 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
187 } 187 }
188#endif 188#endif
189 mIncidence = mIncidence->recreateCloneException( mDate ); 189 mIncidence = mIncidence->recreateCloneException( mDate );
190} 190}
191bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 191bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
192{ 192{
193 int size = AGENDA_ICON_SIZE; 193 int size = AGENDA_ICON_SIZE;
194 194
195 int yOff = 0; 195 int yOff = 0;
196 int xOff = 0; 196 int xOff = 0;
197 int x = pos().x() +3; 197 int x = pos().x() +3;
198 int y; 198 int y;
199 if ( mAllDay ) 199 if ( mAllDay )
200 y = pos().y()+3; 200 y = pos().y()+3;
201 else 201 else
202 y = mCellYTop * ( height() / cellHeight() ) +3; 202 y = mCellYTop * ( height() / cellHeight() ) +3;
203
204
205 if ( mIncidence->calID() > 1 ) {
206 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) );
207 p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 );
208 if ( horLayout ){
209 ++xOff;
210 ++x;
211 }
212 else {
213 ++yOff;
214 ++y;
215 }
216 }
203 if (mIncidence->cancelled()) { 217 if (mIncidence->cancelled()) {
204 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 218 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
205 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 219 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
206 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 220 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
207 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 221 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
208 if ( horLayout ) 222 if ( horLayout )
209 ++xOff; 223 ++xOff;
210 else 224 else
211 ++yOff; 225 ++yOff;
212 } 226 }
213 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { 227 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) {
214 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 228 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
215 if ( horLayout ) 229 if ( horLayout )
216 ++xOff; 230 ++xOff;
217 else 231 else
218 ++yOff; 232 ++yOff;
219 } 233 }
220 if (mIncidence->recurrence()->doesRecur()) { 234 if (mIncidence->recurrence()->doesRecur()) {
221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 235 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
222 if ( horLayout ) 236 if ( horLayout )
223 ++xOff; 237 ++xOff;
224 else 238 else
225 ++yOff; 239 ++yOff;
226 } 240 }
227 if (mIncidence->description().length() > 0) { 241 if (mIncidence->description().length() > 0) {
228 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 242 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
229 if ( horLayout ) 243 if ( horLayout )
230 ++xOff; 244 ++xOff;
231 else 245 else
232 ++yOff; 246 ++yOff;
233 } 247 }
234 if (mIncidence->isReadOnly()) { 248 if (mIncidence->isReadOnly()) {
235 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 249 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
236 if ( horLayout ) 250 if ( horLayout )
237 ++xOff; 251 ++xOff;
238 else 252 else
239 ++yOff; 253 ++yOff;
240 } 254 }
241 255
242 if (mIncidence->attendeeCount()>0) { 256 if (mIncidence->attendeeCount()>0) {
243 257
244 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 258 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
245 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 259 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
246 if ( horLayout ) 260 if ( horLayout )
247 ++xOff; 261 ++xOff;
248 else 262 else
249 ++yOff; 263 ++yOff;
250 } else { 264 } else {
251 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 265 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
252 if (me!=0) { 266 if (me!=0) {
253 267
254 268
255 } else { 269 } else {
256 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 270 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
257 if ( horLayout ) 271 if ( horLayout )
258 ++xOff; 272 ++xOff;
259 else 273 else
260 ++yOff; 274 ++yOff;
261 275
262 } 276 }
263 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 277 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
264 if ( horLayout ) 278 if ( horLayout )
265 ++xOff; 279 ++xOff;
266 else 280 else
267 ++yOff; 281 ++yOff;
268 282
269 } 283 }
270 284
271 } 285 }
272 return ( yOff || xOff ); 286 return ( yOff || xOff );
273} 287}
274 288
275 289
276void KOAgendaItem::select(bool selected) 290void KOAgendaItem::select(bool selected)
277{ 291{
278 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 292 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
279 if (mSelected == selected) return; 293 if (mSelected == selected) return;
280 mSelected = selected; 294 mSelected = selected;
281 if ( ! isVisible() ) 295 if ( ! isVisible() )
282 return; 296 return;
283 if ( firstMultiItem() ) 297 if ( firstMultiItem() )
284 firstMultiItem()->select( selected ); 298 firstMultiItem()->select( selected );
285 if ( !firstMultiItem() && nextMultiItem() ) { 299 if ( !firstMultiItem() && nextMultiItem() ) {
286 KOAgendaItem * placeItem = nextMultiItem(); 300 KOAgendaItem * placeItem = nextMultiItem();
287 while ( placeItem ) { 301 while ( placeItem ) {
288 placeItem->select( selected ); 302 placeItem->select( selected );
289 placeItem = placeItem->nextMultiItem(); 303 placeItem = placeItem->nextMultiItem();
290 } 304 }
291 } 305 }
292 globalFlagBlockAgendaItemUpdate = 0; 306 globalFlagBlockAgendaItemUpdate = 0;
293 paintMe( selected ); 307 paintMe( selected );
294 globalFlagBlockAgendaItemUpdate = 1; 308 globalFlagBlockAgendaItemUpdate = 1;
295 repaint( false ); 309 repaint( false );
296} 310}
297 311
298 312
299/* 313/*
300 The eventFilter has to filter the mouse events of the agenda item childs. The 314 The eventFilter has to filter the mouse events of the agenda item childs. The
301 events are fed into the event handling method of KOAgendaItem. This allows the 315 events are fed into the event handling method of KOAgendaItem. This allows the
302 KOAgenda to handle the KOAgendaItems by using an eventFilter. 316 KOAgenda to handle the KOAgendaItems by using an eventFilter.
303*/ 317*/
304bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 318bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
305{ 319{
306 if (e->type() == QEvent::MouseButtonPress || 320 if (e->type() == QEvent::MouseButtonPress ||
307 e->type() == QEvent::MouseButtonDblClick || 321 e->type() == QEvent::MouseButtonDblClick ||
308 e->type() == QEvent::MouseButtonRelease || 322 e->type() == QEvent::MouseButtonRelease ||
309 e->type() == QEvent::MouseMove) { 323 e->type() == QEvent::MouseMove) {
310 QMouseEvent *me = (QMouseEvent *)e; 324 QMouseEvent *me = (QMouseEvent *)e;
311 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 325 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
312 mapToGlobal(me->pos())); 326 mapToGlobal(me->pos()));
313 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 327 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
314 return event(&returnEvent); 328 return event(&returnEvent);
315 } else { 329 } else {
316 return false; 330 return false;
317 } 331 }
318} 332}
319void KOAgendaItem::repaintMe( ) 333void KOAgendaItem::repaintMe( )
320{ 334{
321 paintMe ( mSelected ); 335 paintMe ( mSelected );
322} 336}
323void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 337void KOAgendaItem::paintMe( bool selected, QPainter* paint )
324{ 338{
325 if ( globalFlagBlockAgendaItemUpdate && ! selected) 339 if ( globalFlagBlockAgendaItemUpdate && ! selected)
326 return; 340 return;
327 QPainter pa; 341 QPainter pa;
328 342
329 if ( mSelected ) { 343 if ( mSelected ) {
330 pa.begin( paintPixSel() ); 344 pa.begin( paintPixSel() );
331 } else { 345 } else {
332 if ( mAllDay ) 346 if ( mAllDay )
333 pa.begin( paintPixAllday() ); 347 pa.begin( paintPixAllday() );
334 else 348 else
335 pa.begin( paintPix() ); 349 pa.begin( paintPix() );
336 } 350 }
337 int x, yy, w, h; 351 int x, yy, w, h;
338 float nfh = 7.0; 352 float nfh = 7.0;
339 x = pos().x(); w = width(); h = height (); 353 x = pos().x(); w = width(); h = height ();
340 if ( mAllDay ) 354 if ( mAllDay )
341 yy = y(); 355 yy = y();
342 else 356 else
343 yy = mCellYTop * ( height() / cellHeight() ); 357 yy = mCellYTop * ( height() / cellHeight() );
344 xPaintCoord= x; 358 xPaintCoord= x;
345 yPaintCoord = yy; 359 yPaintCoord = yy;
346 wPaintCoord = width(); 360 wPaintCoord = width();
347 hPaintCoord = height(); 361 hPaintCoord = height();
348 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 362 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
349 if ( paint == 0 ) 363 if ( paint == 0 )
350 paint = &pa; 364 paint = &pa;
351 bool horLayout = ( w < h ); 365 bool horLayout = ( w < h );
352 int maxhei = mFontPixelSize+4; 366 int maxhei = mFontPixelSize+4;
353 if ( horLayout ) 367 if ( horLayout )
354 maxhei += AGENDA_ICON_SIZE -4; 368 maxhei += AGENDA_ICON_SIZE -4;
355 bool small = ( h < maxhei ); 369 bool small = ( h < maxhei );
356 if ( ! small ) 370 if ( ! small )
357 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 371 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
358 else { 372 else {
359 QFont f = KOPrefs::instance()->mAgendaViewFont; 373 QFont f = KOPrefs::instance()->mAgendaViewFont;
360 f.setBold( false ); 374 f.setBold( false );
361 int fh = f.pointSize(); 375 int fh = f.pointSize();
362 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 376 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
363 if ( nfh < 6 ) 377 if ( nfh < 6 )
364 nfh = 6; 378 nfh = 6;
365 f.setPointSize( nfh ); 379 f.setPointSize( nfh );
366 paint->setFont(f); 380 paint->setFont(f);
367 } 381 }
368 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 382 paint->fillRect ( x, yy, w, h, mBackgroundColor );
369 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 383 static const QPixmap completedPxmp = SmallIcon("greenhook16");
370 static const QPixmap overduePxmp = SmallIcon("redcross16"); 384 static const QPixmap overduePxmp = SmallIcon("redcross16");
371 if ( mIncidence->typeID() == todoID ) { 385 if ( mIncidence->typeID() == todoID ) {
372 Todo* tempTodo = static_cast<Todo*>(mIncidence); 386 Todo* tempTodo = static_cast<Todo*>(mIncidence);
373 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 387 int xx = pos().x()+(width()-completedPxmp.width()-3 );
374 int yyy = yy+3; 388 int yyy = yy+3;
375 if ( tempTodo->isCompleted() ) 389 if ( tempTodo->isCompleted() )
376 paint->drawPixmap ( xx, yyy, completedPxmp ); 390 paint->drawPixmap ( xx, yyy, completedPxmp );
377 else { 391 else {
378 paint->drawPixmap ( xx, yyy, overduePxmp ); 392 paint->drawPixmap ( xx, yyy, overduePxmp );
379 393
380 } 394 }
381 } 395 }
382 bool addIcon = false; 396 bool addIcon = false;
383 if ( ! small || w > 3 * h || h > 3* w ) 397 if ( ! small || w > 3 * h || h > 3* w )
384 addIcon = updateIcons( paint, horLayout ); 398 addIcon = updateIcons( paint, horLayout );
385 399
386 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 400 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
387 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); 401 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0);
388 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 402 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
389 if ( ! small ) { 403 if ( ! small ) {
390 x += 3; yy += 3;w -= 6; h-= 5; 404 x += 3; yy += 3;w -= 6; h-= 5;
391 } else { 405 } else {
392 x += 2; yy += 1;w -= 4; h-= 4; 406 x += 2; yy += 1;w -= 4; h-= 4;
393 if ( nfh < 6.01 ) { 407 if ( nfh < 6.01 ) {
394 yy -= 2; 408 yy -= 2;