summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp24
-rw-r--r--korganizer/koagendaitem.h1
-rw-r--r--korganizer/koagendaview.cpp2
3 files changed, 11 insertions, 16 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 9fe1be4..abb29f7 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,852 +1,848 @@
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(); 197 int x = pos().x();
198 198
199 if ( x < 0 ) x = 0; 199 if ( x < 0 ) x = 0;
200 x += 3; 200 x += 3;
201 int y; 201 int y;
202 if ( mAllDay ) 202 if ( mAllDay )
203 y = pos().y()+3; 203 y = pos().y()+3;
204 else 204 else
205 y = mCellYTop * ( height() / cellHeight() ) +3; 205 y = mCellYTop * ( height() / cellHeight() ) +3;
206 206
207 207
208 if ( mIncidence->calID() > 1 ) { 208 if ( mIncidence->calID() > 1 ) {
209 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() ) ); 209 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() ) );
210 p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 ); 210 p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 );
211 if ( horLayout ){ 211 if ( horLayout ){
212 ++xOff; 212 ++xOff;
213 ++x; 213 ++x;
214 } 214 }
215 else { 215 else {
216 ++yOff; 216 ++yOff;
217 ++y; 217 ++y;
218 } 218 }
219 } 219 }
220 if (mIncidence->cancelled() && height() < 20 ) { 220 if (mIncidence->cancelled() && height() < 20 ) {
221 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 221 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
222 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 222 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
223 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 223 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
224 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 224 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
225 if ( horLayout ) 225 if ( horLayout )
226 ++xOff; 226 ++xOff;
227 else 227 else
228 ++yOff; 228 ++yOff;
229 } 229 }
230 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { 230 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) {
231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
232 if ( horLayout ) 232 if ( horLayout )
233 ++xOff; 233 ++xOff;
234 else 234 else
235 ++yOff; 235 ++yOff;
236 } 236 }
237 if (mIncidence->recurrence()->doesRecur()) { 237 if (mIncidence->recurrence()->doesRecur()) {
238 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 238 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
239 if ( horLayout ) 239 if ( horLayout )
240 ++xOff; 240 ++xOff;
241 else 241 else
242 ++yOff; 242 ++yOff;
243 } 243 }
244 if (mIncidence->description().length() > 0) { 244 if (mIncidence->description().length() > 0) {
245 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 245 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
246 if ( horLayout ) 246 if ( horLayout )
247 ++xOff; 247 ++xOff;
248 else 248 else
249 ++yOff; 249 ++yOff;
250 } 250 }
251 if (mIncidence->isReadOnly()) { 251 if (mIncidence->isReadOnly()) {
252 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 252 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
253 if ( horLayout ) 253 if ( horLayout )
254 ++xOff; 254 ++xOff;
255 else 255 else
256 ++yOff; 256 ++yOff;
257 } 257 }
258 258
259 if (mIncidence->attendeeCount()>0) { 259 if (mIncidence->attendeeCount()>0) {
260 260
261 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 261 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
262 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 262 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
263 if ( horLayout ) 263 if ( horLayout )
264 ++xOff; 264 ++xOff;
265 else 265 else
266 ++yOff; 266 ++yOff;
267 } else { 267 } else {
268 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 268 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
269 if (me!=0) { 269 if (me!=0) {
270 270
271 271
272 } else { 272 } else {
273 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 273 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
274 if ( horLayout ) 274 if ( horLayout )
275 ++xOff; 275 ++xOff;
276 else 276 else
277 ++yOff; 277 ++yOff;
278 278
279 } 279 }
280 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 280 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
281 if ( horLayout ) 281 if ( horLayout )
282 ++xOff; 282 ++xOff;
283 else 283 else
284 ++yOff; 284 ++yOff;
285 285
286 } 286 }
287 287
288 } 288 }
289 return ( yOff || xOff ); 289 return ( yOff || xOff );
290} 290}
291 291
292 292
293void KOAgendaItem::select(bool selected) 293void KOAgendaItem::select(bool selected)
294{ 294{
295 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 295 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
296 if (mSelected == selected) return; 296 if (mSelected == selected) return;
297 mSelected = selected; 297 mSelected = selected;
298 if ( ! isVisible() ) 298 if ( ! isVisible() )
299 return; 299 return;
300 if ( firstMultiItem() ) 300 if ( firstMultiItem() )
301 firstMultiItem()->select( selected ); 301 firstMultiItem()->select( selected );
302 if ( !firstMultiItem() && nextMultiItem() ) { 302 if ( !firstMultiItem() && nextMultiItem() ) {
303 KOAgendaItem * placeItem = nextMultiItem(); 303 KOAgendaItem * placeItem = nextMultiItem();
304 while ( placeItem ) { 304 while ( placeItem ) {
305 placeItem->select( selected ); 305 placeItem->select( selected );
306 placeItem = placeItem->nextMultiItem(); 306 placeItem = placeItem->nextMultiItem();
307 } 307 }
308 } 308 }
309 globalFlagBlockAgendaItemUpdate = 0; 309 globalFlagBlockAgendaItemUpdate = 0;
310 paintMe( selected ); 310 paintMe( selected );
311 globalFlagBlockAgendaItemUpdate = 1; 311 globalFlagBlockAgendaItemUpdate = 1;
312 repaint( false ); 312 repaint( false );
313} 313}
314 314
315 315
316/* 316/*
317 The eventFilter has to filter the mouse events of the agenda item childs. The 317 The eventFilter has to filter the mouse events of the agenda item childs. The
318 events are fed into the event handling method of KOAgendaItem. This allows the 318 events are fed into the event handling method of KOAgendaItem. This allows the
319 KOAgenda to handle the KOAgendaItems by using an eventFilter. 319 KOAgenda to handle the KOAgendaItems by using an eventFilter.
320*/ 320*/
321bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 321bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
322{ 322{
323 if (e->type() == QEvent::MouseButtonPress || 323 if (e->type() == QEvent::MouseButtonPress ||
324 e->type() == QEvent::MouseButtonDblClick || 324 e->type() == QEvent::MouseButtonDblClick ||
325 e->type() == QEvent::MouseButtonRelease || 325 e->type() == QEvent::MouseButtonRelease ||
326 e->type() == QEvent::MouseMove) { 326 e->type() == QEvent::MouseMove) {
327 QMouseEvent *me = (QMouseEvent *)e; 327 QMouseEvent *me = (QMouseEvent *)e;
328 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 328 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
329 mapToGlobal(me->pos())); 329 mapToGlobal(me->pos()));
330 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 330 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
331 return event(&returnEvent); 331 return event(&returnEvent);
332 } else { 332 } else {
333 return false; 333 return false;
334 } 334 }
335} 335}
336void KOAgendaItem::repaintMe( ) 336void KOAgendaItem::repaintMe( )
337{ 337{
338 paintMe ( mSelected ); 338 paintMe ( mSelected );
339} 339}
340void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 340void KOAgendaItem::paintMe( bool selected, QPainter* paint )
341{ 341{
342 if ( globalFlagBlockAgendaItemUpdate && ! selected) 342 if ( globalFlagBlockAgendaItemUpdate && ! selected)
343 return; 343 return;
344 QPainter pa; 344 QPainter pa;
345 345
346 if ( mSelected ) { 346 if ( mSelected ) {
347 pa.begin( paintPixSel() ); 347 pa.begin( this );
348 } else { 348 } else {
349 if ( mAllDay ) 349 if ( mAllDay )
350 pa.begin( paintPixAllday() ); 350 pa.begin( paintPixAllday() );
351 else 351 else
352 pa.begin( paintPix() ); 352 pa.begin( paintPix() );
353 } 353 }
354 int x, yy, w, h; 354 int x, yy, w, h;
355 float nfh = 7.0; 355 float nfh = 7.0;
356 x = pos().x(); w = width(); h = height (); 356 x = pos().x(); w = width(); h = height ();
357 if ( mAllDay ) 357 if ( mAllDay )
358 yy = y(); 358 yy = y();
359 else 359 else
360 yy = mCellYTop * ( height() / cellHeight() ); 360 yy = mCellYTop * ( height() / cellHeight() );
361 if ( mSelected ) {
362 pa.translate( -x, -yy );
363 }
361 xPaintCoord= x; 364 xPaintCoord= x;
362 yPaintCoord = yy; 365 yPaintCoord = yy;
363 wPaintCoord = width(); 366 wPaintCoord = width();
364 hPaintCoord = height(); 367 hPaintCoord = height();
365 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 368 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
366 if ( paint == 0 ) 369 if ( paint == 0 )
367 paint = &pa; 370 paint = &pa;
368 bool horLayout = ( w < h ); 371 bool horLayout = ( w < h );
369 int maxhei = mFontPixelSize+4; 372 int maxhei = mFontPixelSize+4;
370 if ( horLayout ) 373 if ( horLayout )
371 maxhei += AGENDA_ICON_SIZE -4; 374 maxhei += AGENDA_ICON_SIZE -4;
372 bool small = ( h < maxhei ); 375 bool small = ( h < maxhei );
373 if ( ! small ) 376 if ( ! small )
374 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 377 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
375 else { 378 else {
376 QFont f = KOPrefs::instance()->mAgendaViewFont; 379 QFont f = KOPrefs::instance()->mAgendaViewFont;
377 f.setBold( false ); 380 f.setBold( false );
378 int fh = f.pointSize(); 381 int fh = f.pointSize();
379 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 382 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
380 if ( nfh < 6 ) 383 if ( nfh < 6 )
381 nfh = 6; 384 nfh = 6;
382 f.setPointSize( nfh ); 385 f.setPointSize( nfh );
383 paint->setFont(f); 386 paint->setFont(f);
384 } 387 }
385 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 388 paint->fillRect ( x, yy, w, h, mBackgroundColor );
386 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 389 static const QPixmap completedPxmp = SmallIcon("greenhook16");
387 static const QPixmap overduePxmp = SmallIcon("redcross16"); 390 static const QPixmap overduePxmp = SmallIcon("redcross16");
388 if ( mIncidence->typeID() == todoID ) { 391 if ( mIncidence->typeID() == todoID ) {
389 Todo* tempTodo = static_cast<Todo*>(mIncidence); 392 Todo* tempTodo = static_cast<Todo*>(mIncidence);
390 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 393 int xx = pos().x()+(width()-completedPxmp.width()-3 );
391 int yyy = yy+3; 394 int yyy = yy+3;
392 if ( tempTodo->isCompleted() ) 395 if ( tempTodo->isCompleted() )
393 paint->drawPixmap ( xx, yyy, completedPxmp ); 396 paint->drawPixmap ( xx, yyy, completedPxmp );
394 else { 397 else {
395 paint->drawPixmap ( xx, yyy, overduePxmp ); 398 paint->drawPixmap ( xx, yyy, overduePxmp );
396 399
397 } 400 }
398 } 401 }
399 bool addIcon = false; 402 bool addIcon = false;
400 if ( ! small || w > 3 * h || h > 3* w ) 403 if ( ! small || w > 3 * h || h > 3* w )
401 addIcon = updateIcons( paint, horLayout ); 404 addIcon = updateIcons( paint, horLayout );
402 405
403 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 406 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
404 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); 407 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0);
405 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 408 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
406 if ( ! small ) { 409 if ( ! small ) {
407 x += 3; yy += 3;w -= 6; h-= 5; 410 x += 3; yy += 3;w -= 6; h-= 5;
408 } else { 411 } else {
409 x += 2; yy += 1;w -= 4; h-= 4; 412 x += 2; yy += 1;w -= 4; h-= 4;
410 if ( nfh < 6.01 ) { 413 if ( nfh < 6.01 ) {
411 yy -= 2; 414 yy -= 2;
412 h += 4; 415 h += 4;
413 } 416 }
414 else 417 else
415 if ( nfh < h -2 ) 418 if ( nfh < h -2 )
416 ++yy; 419 ++yy;
417 } 420 }
418 int align; 421 int align;
419#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
420 align = ( AlignLeft|WordBreak|AlignTop); 423 align = ( AlignLeft|WordBreak|AlignTop);
421#else 424#else
422 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 425 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
423#endif 426#endif
424 if ( addIcon ) { 427 if ( addIcon ) {
425 if ( ! horLayout ) { 428 if ( ! horLayout ) {
426 x += AGENDA_ICON_SIZE+3; 429 x += AGENDA_ICON_SIZE+3;
427 w -= (AGENDA_ICON_SIZE+3); 430 w -= (AGENDA_ICON_SIZE+3);
428 } 431 }
429 else { 432 else {
430 yy+= AGENDA_ICON_SIZE+2; 433 yy+= AGENDA_ICON_SIZE+2;
431 h -=(AGENDA_ICON_SIZE+3); 434 h -=(AGENDA_ICON_SIZE+3);
432 } 435 }
433 } 436 }
434 if ( mWhiteText ) 437 if ( mWhiteText )
435 paint->setPen ( white); 438 paint->setPen ( white);
436 if ( x < 0 ) { 439 if ( x < 0 ) {
437 w = w+x-3; 440 w = w+x-3;
438 x = 3; 441 x = 3;
439 if ( !horLayout && addIcon ) 442 if ( !horLayout && addIcon )
440 x += AGENDA_ICON_SIZE+3; 443 x += AGENDA_ICON_SIZE+3;
441 if ( w > parentWidget()->width() ){ 444 if ( w > parentWidget()->width() ){
442 w = parentWidget()->width() - 6; 445 w = parentWidget()->width() - 6;
443#ifndef DESKTOP_VERSION 446#ifndef DESKTOP_VERSION
444 align = ( AlignHCenter|WordBreak|AlignTop); 447 align = ( AlignHCenter|WordBreak|AlignTop);
445#else 448#else
446 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 449 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
447#endif 450#endif
448 451
449 } 452 }
450 } 453 }
451 QRect dr; 454 QRect dr;
452 if ( w + x > parentWidget()->width() ) 455 if ( w + x > parentWidget()->width() )
453 w = parentWidget()->width()-x; 456 w = parentWidget()->width()-x;
454 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 457 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
455 //qDebug("%d %d %d %d ", x, yy, w, h ); 458 //qDebug("%d %d %d %d ", x, yy, w, h );
456 if ( mIncidence->cancelled() ){ 459 if ( mIncidence->cancelled() ){
457 460
458 461
459 small = ( height() < 20 ); 462 small = ( height() < 20 );
460 463
461 if ( ! small ) { 464 if ( ! small ) {
462 QFontMetrics fm ( paint->font() ); 465 QFontMetrics fm ( paint->font() );
463 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 466 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
464 } 467 }
465 468
466 } 469 }
467 pa.end(); 470 pa.end();
468 471
469} 472}
470void KOAgendaItem::resizePixmap( int w , int h ) 473void KOAgendaItem::resizePixmap( int w , int h )
471{ 474{
472 paintPix()->resize( w, h ); 475 paintPix()->resize( w, h );
473 paintPixSel()->resize( w, h );
474 476
475} 477}
476QPixmap * KOAgendaItem::paintPix() 478QPixmap * KOAgendaItem::paintPix()
477{ 479{
478 static QPixmap* mPaintPix = 0; 480 static QPixmap* mPaintPix = 0;
479 if ( ! mPaintPix ) { 481 if ( ! mPaintPix ) {
480 int w = QApplication::desktop()->width(); 482 int w = QApplication::desktop()->width();
481 int h = QApplication::desktop()->height(); 483 int h = QApplication::desktop()->height();
482 mPaintPix = new QPixmap(w,h); 484 mPaintPix = new QPixmap(w,h);
483 } 485 }
484 return mPaintPix ; 486 return mPaintPix ;
485} 487}
486QPixmap * KOAgendaItem::paintPixAllday() 488QPixmap * KOAgendaItem::paintPixAllday()
487{ 489{
488 static QPixmap* mPaintPixA = 0; 490 static QPixmap* mPaintPixA = 0;
489 if ( ! mPaintPixA ) { 491 if ( ! mPaintPixA ) {
490 int w = QApplication::desktop()->width(); 492 int w = QApplication::desktop()->width();
491 int h = QApplication::desktop()->height()/3; 493 int h = QApplication::desktop()->height()/3;
492 mPaintPixA = new QPixmap(w,h); 494 mPaintPixA = new QPixmap(w,h);
493 } 495 }
494 return mPaintPixA ; 496 return mPaintPixA ;
495} 497}
496QPixmap * KOAgendaItem::paintPixSel() 498
497{
498 static QPixmap* mPaintPixSel = 0;
499 if ( ! mPaintPixSel ) {
500 int w = QApplication::desktop()->width();
501 int h = QApplication::desktop()->height();
502 mPaintPixSel = new QPixmap(w,h);
503 }
504 return mPaintPixSel ;
505}
506void KOAgendaItem::paintEvent ( QPaintEvent *e ) 499void KOAgendaItem::paintEvent ( QPaintEvent *e )
507{ 500{
508 501
509 if ( globalFlagBlockAgendaItemPaint ) 502 if ( globalFlagBlockAgendaItemPaint )
510 return; 503 return;
511 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 504 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
512 return; 505 return;
513 int yy; 506 int yy;
514 if ( mAllDay ) 507 if ( mAllDay )
515 yy = y(); 508 yy = y();
516 else 509 else
517 yy = mCellYTop * ( height() / cellHeight() ); 510 yy = mCellYTop * ( height() / cellHeight() );
518 int xx = x(); 511 int xx = x();
519 512
520 if ( xPaintCoord != xx || yPaintCoord != yy || 513 if ( xPaintCoord != xx || yPaintCoord != yy ||
521 wPaintCoord != width() || hPaintCoord != height()) { 514 wPaintCoord != width() || hPaintCoord != height()) {
522 xPaintCoord= xx; 515 xPaintCoord= xx;
523 yPaintCoord = yy; 516 yPaintCoord = yy;
524 wPaintCoord = width(); 517 wPaintCoord = width();
525 hPaintCoord = height(); 518 hPaintCoord = height();
526 globalFlagBlockAgendaItemUpdate = 0; 519 globalFlagBlockAgendaItemUpdate = 0;
527 paintMe( mSelected ); 520 paintMe( mSelected );
528 //qDebug("calling paintMe "); 521 //qDebug("calling paintMe ");
529 globalFlagBlockAgendaItemUpdate = 1; 522 globalFlagBlockAgendaItemUpdate = 1;
523 if ( mSelected )
524 return;
530 } 525 }
531 int rx, ry, rw, rh; 526 int rx, ry, rw, rh;
532 rx = e->rect().x(); 527 rx = e->rect().x();
533 ry = e->rect().y(); 528 ry = e->rect().y();
534 rw = e->rect().width(); 529 rw = e->rect().width();
535 rh = e->rect().height(); 530 rh = e->rect().height();
536 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 531 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
537 532
538 QPixmap* paintFrom ; 533 QPixmap* paintFrom ;
539 if ( mSelected ) { 534 if ( mSelected ) {
540 paintFrom = paintPixSel(); 535 paintMe( mSelected );
536 return;
541 } else { 537 } else {
542 if ( mAllDay ) 538 if ( mAllDay )
543 paintFrom = paintPixAllday(); 539 paintFrom = paintPixAllday();
544 else 540 else
545 paintFrom = paintPix(); 541 paintFrom = paintPix();
546 } 542 }
547 xx += rx; 543 xx += rx;
548 544
549 if ( xx < 0 ) { 545 if ( xx < 0 ) {
550 rw = rw + xx; 546 rw = rw + xx;
551 rx -= xx; 547 rx -= xx;
552 xx = 0; 548 xx = 0;
553 if ( rw <= 1 ) { 549 if ( rw <= 1 ) {
554 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 550 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
555 return; 551 return;
556 } 552 }
557 } 553 }
558 if ( paintFrom->width() < xx+rw ) { 554 if ( paintFrom->width() < xx+rw ) {
559 rw = paintFrom->width() - xx; 555 rw = paintFrom->width() - xx;
560 if ( rw <= 1 ) { 556 if ( rw <= 1 ) {
561 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 557 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
562 return; 558 return;
563 } 559 }
564 } 560 }
565 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 561 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
566 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 562 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
567} 563}
568void KOAgendaItem::computeText() 564void KOAgendaItem::computeText()
569{ 565{
570 mDisplayedText = mIncidence->summary(); 566 mDisplayedText = mIncidence->summary();
571 if ( (mIncidence->typeID() == todoID ) ) { 567 if ( (mIncidence->typeID() == todoID ) ) {
572 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 568 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
573 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 569 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
574 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 570 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
575 else if ( !(mIncidence->doesFloat())) 571 else if ( !(mIncidence->doesFloat()))
576 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 572 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
577 } 573 }
578 } else { 574 } else {
579 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 575 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
580 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 576 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
581 577
582 if ( mAllDay ) { 578 if ( mAllDay ) {
583 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 579 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
584 if ( mIncidence->doesRecur() ) { 580 if ( mIncidence->doesRecur() ) {
585 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; 581 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
586 } else { 582 } else {
587 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 583 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
588 } 584 }
589 } 585 }
590 } 586 }
591 } 587 }
592 588
593 if ( !mIncidence->location().isEmpty() ) { 589 if ( !mIncidence->location().isEmpty() ) {
594 if ( mAllDay ) 590 if ( mAllDay )
595 mDisplayedText += " ("; 591 mDisplayedText += " (";
596 else 592 else
597 mDisplayedText += "\n("; 593 mDisplayedText += "\n(";
598 mDisplayedText += mIncidence->location() +")"; 594 mDisplayedText += mIncidence->location() +")";
599 } 595 }
600#ifdef DESKTOP_VERSION 596#ifdef DESKTOP_VERSION
601 QString tipText = mIncidence->summary(); 597 QString tipText = mIncidence->summary();
602 if ( !mIncidence->doesFloat() ) { 598 if ( !mIncidence->doesFloat() ) {
603 if ( mIncidence->typeID() == eventID ) { 599 if ( mIncidence->typeID() == eventID ) {
604 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 600 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
605 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 601 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
606 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 602 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
607 } 603 }
608 else { 604 else {
609 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 605 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
610 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 606 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
611 } 607 }
612 } 608 }
613 else if ( mIncidence->typeID() == todoID ) { 609 else if ( mIncidence->typeID() == todoID ) {
614 if (mIncidence->hasStartDate()) 610 if (mIncidence->hasStartDate())
615 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 611 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
616 if (((Todo*)mIncidence)->hasDueDate()) 612 if (((Todo*)mIncidence)->hasDueDate())
617 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 613 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
618 } 614 }
619 } else if ( mIncidence->typeID() == todoID ) { 615 } else if ( mIncidence->typeID() == todoID ) {
620 if (mIncidence->hasStartDate()) 616 if (mIncidence->hasStartDate())
621 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 617 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
622 if (((Todo*)mIncidence)->hasDueDate()) 618 if (((Todo*)mIncidence)->hasDueDate())
623 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 619 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
624 } 620 }
625 621
626 if (!mIncidence->location().isEmpty()) { 622 if (!mIncidence->location().isEmpty()) {
627 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 623 tipText += "\n"+i18n("Location: ")+mIncidence->location();
628 } 624 }
629 QToolTip::add(this,tipText,toolTipGroup(),""); 625 QToolTip::add(this,tipText,toolTipGroup(),"");
630#endif 626#endif
631} 627}
632void KOAgendaItem::updateItem() 628void KOAgendaItem::updateItem()
633{ 629{
634 computeText(); 630 computeText();
635 631
636 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 632 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
637 paintMe( mSelected ); 633 paintMe( mSelected );
638 repaint( false); 634 repaint( false);
639} 635}
640 636
641void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 637void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
642{ 638{
643 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 639 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
644 paintMe( mSelected ); 640 paintMe( mSelected );
645 repaint( false ); 641 repaint( false );
646} 642}
647 643
648/* 644/*
649 Return height of item in units of agenda cells 645 Return height of item in units of agenda cells
650*/ 646*/
651int KOAgendaItem::cellHeight() 647int KOAgendaItem::cellHeight()
652{ 648{
653 int ret = mCellYBottom - mCellYTop + 1; 649 int ret = mCellYBottom - mCellYTop + 1;
654 if ( ret <= 0 ) { 650 if ( ret <= 0 ) {
655 ret = 1; 651 ret = 1;
656 mCellYBottom = 0; 652 mCellYBottom = 0;
657 mCellYTop = 0; 653 mCellYTop = 0;
658 } 654 }
659 return ret; 655 return ret;
660} 656}
661 657
662/* 658/*
663 Return height of item in units of agenda cells 659 Return height of item in units of agenda cells
664*/ 660*/
665int KOAgendaItem::cellWidth() 661int KOAgendaItem::cellWidth()
666{ 662{
667 return mCellXWidth - mCellX + 1; 663 return mCellXWidth - mCellX + 1;
668} 664}
669 665
670void KOAgendaItem::setItemDate(QDate qd) 666void KOAgendaItem::setItemDate(QDate qd)
671{ 667{
672 mDate = qd; 668 mDate = qd;
673} 669}
674 670
675void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 671void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
676{ 672{
677 mCellX = X; 673 mCellX = X;
678 mCellYTop = YTop; 674 mCellYTop = YTop;
679 mCellYBottom = YBottom; 675 mCellYBottom = YBottom;
680} 676}
681 677
682void KOAgendaItem::setCellXWidth(int xwidth) 678void KOAgendaItem::setCellXWidth(int xwidth)
683{ 679{
684 mCellXWidth = xwidth; 680 mCellXWidth = xwidth;
685} 681}
686 682
687void KOAgendaItem::setCellX(int XLeft, int XRight) 683void KOAgendaItem::setCellX(int XLeft, int XRight)
688{ 684{
689 mCellX = XLeft; 685 mCellX = XLeft;
690 mCellXWidth = XRight; 686 mCellXWidth = XRight;
691} 687}
692 688
693void KOAgendaItem::setCellY(int YTop, int YBottom) 689void KOAgendaItem::setCellY(int YTop, int YBottom)
694{ 690{
695 mCellYTop = YTop; 691 mCellYTop = YTop;
696 mCellYBottom = YBottom; 692 mCellYBottom = YBottom;
697} 693}
698 694
699void KOAgendaItem::setSubCell(int subCell) 695void KOAgendaItem::setSubCell(int subCell)
700{ 696{
701 mSubCell = subCell; 697 mSubCell = subCell;
702} 698}
703 699
704void KOAgendaItem::setSubCells(int subCells) 700void KOAgendaItem::setSubCells(int subCells)
705{ 701{
706 mSubCells = subCells; 702 mSubCells = subCells;
707} 703}
708 704
709void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 705void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
710 KOAgendaItem *last) 706 KOAgendaItem *last)
711{ 707{
712 mFirstMultiItem = first; 708 mFirstMultiItem = first;
713 mNextMultiItem = next; 709 mNextMultiItem = next;
714 mLastMultiItem = last; 710 mLastMultiItem = last;
715} 711}
716 712
717void KOAgendaItem::startMove() 713void KOAgendaItem::startMove()
718{ 714{
719 mStartCellX = mCellX; 715 mStartCellX = mCellX;
720 mStartCellXWidth = mCellXWidth; 716 mStartCellXWidth = mCellXWidth;
721 mStartCellYTop = mCellYTop; 717 mStartCellYTop = mCellYTop;
722 mStartCellYBottom = mCellYBottom; 718 mStartCellYBottom = mCellYBottom;
723} 719}
724 720
725void KOAgendaItem::resetMove() 721void KOAgendaItem::resetMove()
726{ 722{
727 mCellX = mStartCellX; 723 mCellX = mStartCellX;
728 mCellXWidth = mStartCellXWidth; 724 mCellXWidth = mStartCellXWidth;
729 mCellYTop = mStartCellYTop; 725 mCellYTop = mStartCellYTop;
730 mCellYBottom = mStartCellYBottom; 726 mCellYBottom = mStartCellYBottom;
731} 727}
732 728
733void KOAgendaItem::moveRelative(int dx, int dy) 729void KOAgendaItem::moveRelative(int dx, int dy)
734{ 730{
735 int newX = cellX() + dx; 731 int newX = cellX() + dx;
736 int newXWidth = cellXWidth() + dx; 732 int newXWidth = cellXWidth() + dx;
737 int newYTop = cellYTop() + dy; 733 int newYTop = cellYTop() + dy;
738 int newYBottom = cellYBottom() + dy; 734 int newYBottom = cellYBottom() + dy;
739 setCellXY(newX,newYTop,newYBottom); 735 setCellXY(newX,newYTop,newYBottom);
740 setCellXWidth(newXWidth); 736 setCellXWidth(newXWidth);
741} 737}
742 738
743void KOAgendaItem::expandTop(int dy) 739void KOAgendaItem::expandTop(int dy)
744{ 740{
745 int newYTop = cellYTop() + dy; 741 int newYTop = cellYTop() + dy;
746 int newYBottom = cellYBottom(); 742 int newYBottom = cellYBottom();
747 if (newYTop > newYBottom) newYTop = newYBottom; 743 if (newYTop > newYBottom) newYTop = newYBottom;
748 setCellY(newYTop, newYBottom); 744 setCellY(newYTop, newYBottom);
749} 745}
750 746
751void KOAgendaItem::expandBottom(int dy) 747void KOAgendaItem::expandBottom(int dy)
752{ 748{
753 int newYTop = cellYTop(); 749 int newYTop = cellYTop();
754 int newYBottom = cellYBottom() + dy; 750 int newYBottom = cellYBottom() + dy;
755 if (newYBottom < newYTop) newYBottom = newYTop; 751 if (newYBottom < newYTop) newYBottom = newYTop;
756 setCellY(newYTop, newYBottom); 752 setCellY(newYTop, newYBottom);
757} 753}
758 754
759void KOAgendaItem::expandLeft(int dx) 755void KOAgendaItem::expandLeft(int dx)
760{ 756{
761 int newX = cellX() + dx; 757 int newX = cellX() + dx;
762 int newXWidth = cellXWidth(); 758 int newXWidth = cellXWidth();
763 if (newX > newXWidth) newX = newXWidth; 759 if (newX > newXWidth) newX = newXWidth;
764 setCellX(newX,newXWidth); 760 setCellX(newX,newXWidth);
765} 761}
766 762
767void KOAgendaItem::expandRight(int dx) 763void KOAgendaItem::expandRight(int dx)
768{ 764{
769 int newX = cellX(); 765 int newX = cellX();
770 int newXWidth = cellXWidth() + dx; 766 int newXWidth = cellXWidth() + dx;
771 if (newXWidth < newX) newXWidth = newX; 767 if (newXWidth < newX) newXWidth = newX;
772 setCellX(newX,newXWidth); 768 setCellX(newX,newXWidth);
773} 769}
774 770
775QToolTipGroup *KOAgendaItem::toolTipGroup() 771QToolTipGroup *KOAgendaItem::toolTipGroup()
776{ 772{
777 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 773 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
778 return mToolTipGroup; 774 return mToolTipGroup;
779} 775}
780 776
781void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 777void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
782{ 778{
783#ifndef KORG_NODND 779#ifndef KORG_NODND
784 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 780 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
785 !QTextDrag::canDecode( e ) ) { 781 !QTextDrag::canDecode( e ) ) {
786 e->ignore(); 782 e->ignore();
787 return; 783 return;
788 } 784 }
789 e->accept(); 785 e->accept();
790#endif 786#endif
791} 787}
792 788
793void KOAgendaItem::dropEvent( QDropEvent *e ) 789void KOAgendaItem::dropEvent( QDropEvent *e )
794{ 790{
795#ifndef KORG_NODND 791#ifndef KORG_NODND
796 QString text; 792 QString text;
797 if(QTextDrag::decode(e,text)) 793 if(QTextDrag::decode(e,text))
798 { 794 {
799 kdDebug() << "Dropped : " << text << endl; 795 kdDebug() << "Dropped : " << text << endl;
800 QStringList emails = QStringList::split(",",text); 796 QStringList emails = QStringList::split(",",text);
801 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 797 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
802 kdDebug() << " Email: " << (*it) << endl; 798 kdDebug() << " Email: " << (*it) << endl;
803 int pos = (*it).find("<"); 799 int pos = (*it).find("<");
804 QString name = (*it).left(pos); 800 QString name = (*it).left(pos);
805 QString email = (*it).mid(pos); 801 QString email = (*it).mid(pos);
806 if (!email.isEmpty()) { 802 if (!email.isEmpty()) {
807 mIncidence->addAttendee(new Attendee(name,email)); 803 mIncidence->addAttendee(new Attendee(name,email));
808 } 804 }
809 } 805 }
810 } 806 }
811#endif 807#endif
812} 808}
813 809
814 810
815QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 811QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
816{ 812{
817 return mConflictItems; 813 return mConflictItems;
818} 814}
819 815
820void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 816void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
821{ 817{
822 mConflictItems = ci; 818 mConflictItems = ci;
823 KOAgendaItem *item; 819 KOAgendaItem *item;
824 for ( item=mConflictItems.first(); item != 0; 820 for ( item=mConflictItems.first(); item != 0;
825 item=mConflictItems.next() ) { 821 item=mConflictItems.next() ) {
826 item->addConflictItem(this); 822 item->addConflictItem(this);
827 } 823 }
828} 824}
829 825
830void KOAgendaItem::addConflictItem(KOAgendaItem *ci) 826void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
831{ 827{
832 if (mConflictItems.find(ci)<0) 828 if (mConflictItems.find(ci)<0)
833 mConflictItems.append(ci); 829 mConflictItems.append(ci);
834} 830}
835 831
836bool KOAgendaItem::checkLayout() 832bool KOAgendaItem::checkLayout()
837{ 833{
838 if ( !mConflictItems.count() ) 834 if ( !mConflictItems.count() )
839 return true; 835 return true;
840 int max = 0; 836 int max = 0;
841 KOAgendaItem *item; 837 KOAgendaItem *item;
842 for ( item=mConflictItems.first(); item != 0; 838 for ( item=mConflictItems.first(); item != 0;
843 item=mConflictItems.next() ) { 839 item=mConflictItems.next() ) {
844 if ( item->subCells() > max ) 840 if ( item->subCells() > max )
845 max = item->subCells(); 841 max = item->subCells();
846 } 842 }
847 if ( max > subCells() ) { 843 if ( max > subCells() ) {
848 setSubCells( max ); 844 setSubCells( max );
849 return false; 845 return false;
850 } 846 }
851 return true; 847 return true;
852} 848}
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index dc2316a..7103abe 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -1,166 +1,165 @@
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#ifndef KOAGENDAITEM_H 19#ifndef KOAGENDAITEM_H
20#define KOAGENDAITEM_H 20#define KOAGENDAITEM_H
21 21
22#include <qframe.h> 22#include <qframe.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qpalette.h> 26#include <qpalette.h>
27 27
28#include <libkcal/incidence.h> 28#include <libkcal/incidence.h>
29 29
30class KOAgendaItemWhatsThis; 30class KOAgendaItemWhatsThis;
31class QToolTipGroup; 31class QToolTipGroup;
32class QDragEnterEvent; 32class QDragEnterEvent;
33class QDropEvent; 33class QDropEvent;
34 34
35using namespace KCal; 35using namespace KCal;
36 36
37/* 37/*
38 The KOAgendaItem has to make sure that it receives all mouse events, which are 38 The KOAgendaItem has to make sure that it receives all mouse events, which are
39 to be used for dragging and resizing. That means it has to be installed as 39 to be used for dragging and resizing. That means it has to be installed as
40 eventfiler for its children, if it has children, and it has to pass mouse 40 eventfiler for its children, if it has children, and it has to pass mouse
41 events from the cildren to itself. See eventFilter(). 41 events from the cildren to itself. See eventFilter().
42*/ 42*/
43class KOAgendaItem : public QWidget 43class KOAgendaItem : public QWidget
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 public: 46 public:
47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, 47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0,
48 WFlags f=0 ); 48 WFlags f=0 );
49 ~KOAgendaItem(); 49 ~KOAgendaItem();
50 QString getWhatsThisText(); 50 QString getWhatsThisText();
51 void init ( Incidence *incidence, QDate qd ); 51 void init ( Incidence *incidence, QDate qd );
52 int cellX() { return mCellX; } 52 int cellX() { return mCellX; }
53 int cellXWidth() { return mCellXWidth; } 53 int cellXWidth() { return mCellXWidth; }
54 int cellYTop() { return mCellYTop; } 54 int cellYTop() { return mCellYTop; }
55 int cellYBottom() { return mCellYBottom; } 55 int cellYBottom() { return mCellYBottom; }
56 int cellHeight(); 56 int cellHeight();
57 int cellWidth(); 57 int cellWidth();
58 int subCell() { return mSubCell; } 58 int subCell() { return mSubCell; }
59 int subCells() { return mSubCells; } 59 int subCells() { return mSubCells; }
60 60
61 void setCellXY(int X, int YTop, int YBottom); 61 void setCellXY(int X, int YTop, int YBottom);
62 void setCellY(int YTop, int YBottom); 62 void setCellY(int YTop, int YBottom);
63 void setCellX(int XLeft, int XRight); 63 void setCellX(int XLeft, int XRight);
64 void setCellXWidth(int xwidth); 64 void setCellXWidth(int xwidth);
65 void setSubCell(int subCell); 65 void setSubCell(int subCell);
66 void setSubCells(int subCells); 66 void setSubCells(int subCells);
67 67
68 /** Start movement */ 68 /** Start movement */
69 void startMove(); 69 void startMove();
70 /** Reset to original values */ 70 /** Reset to original values */
71 void resetMove(); 71 void resetMove();
72 72
73 void moveRelative(int dx,int dy); 73 void moveRelative(int dx,int dy);
74 void expandTop(int dy); 74 void expandTop(int dy);
75 void expandBottom(int dy); 75 void expandBottom(int dy);
76 void expandLeft(int dx); 76 void expandLeft(int dx);
77 void expandRight(int dx); 77 void expandRight(int dx);
78 int mLastMoveXPos; 78 int mLastMoveXPos;
79 79
80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
81 KOAgendaItem *last); 81 KOAgendaItem *last);
82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } 82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; } 83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; } 84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; }
85 85
86 Incidence *incidence() const { return mIncidence; } 86 Incidence *incidence() const { return mIncidence; }
87 QDate itemDate() { return mDate; } 87 QDate itemDate() { return mDate; }
88 88
89 /** Update the date of this item's occurence (not in the event) */ 89 /** Update the date of this item's occurence (not in the event) */
90 void setItemDate(QDate qd); 90 void setItemDate(QDate qd);
91 91
92 void setText ( const QString & text ) { mDisplayedText = text; } 92 void setText ( const QString & text ) { mDisplayedText = text; }
93 QString text () { return mDisplayedText; } 93 QString text () { return mDisplayedText; }
94 94
95 virtual bool eventFilter ( QObject *, QEvent * ); 95 virtual bool eventFilter ( QObject *, QEvent * );
96 96
97 static QToolTipGroup *toolTipGroup(); 97 static QToolTipGroup *toolTipGroup();
98 98
99 QPtrList<KOAgendaItem> conflictItems(); 99 QPtrList<KOAgendaItem> conflictItems();
100 void setConflictItems(QPtrList<KOAgendaItem>); 100 void setConflictItems(QPtrList<KOAgendaItem>);
101 void addConflictItem(KOAgendaItem *ci); 101 void addConflictItem(KOAgendaItem *ci);
102 void paintMe( bool, QPainter* painter = 0 ); 102 void paintMe( bool, QPainter* painter = 0 );
103 void repaintMe(); 103 void repaintMe();
104 static void resizePixmap( int, int ); 104 static void resizePixmap( int, int );
105 static QPixmap * paintPix(); 105 static QPixmap * paintPix();
106 static QPixmap * paintPixSel();
107 static QPixmap * paintPixAllday(); 106 static QPixmap * paintPixAllday();
108 void updateItem(); 107 void updateItem();
109 void computeText(); 108 void computeText();
110 void recreateIncidence(); 109 void recreateIncidence();
111 bool checkLayout(); 110 bool checkLayout();
112 void initColor (); 111 void initColor ();
113 public slots: 112 public slots:
114 bool updateIcons( QPainter *, bool ); 113 bool updateIcons( QPainter *, bool );
115 void select(bool=true); 114 void select(bool=true);
116 115
117 protected: 116 protected:
118 void dragEnterEvent(QDragEnterEvent *e); 117 void dragEnterEvent(QDragEnterEvent *e);
119 void dropEvent(QDropEvent *e); 118 void dropEvent(QDropEvent *e);
120 void paintEvent ( QPaintEvent * ); 119 void paintEvent ( QPaintEvent * );
121 void resizeEvent ( QResizeEvent *ev ); 120 void resizeEvent ( QResizeEvent *ev );
122 121
123 private: 122 private:
124 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; 123 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis;
125 bool mAllDay; 124 bool mAllDay;
126 bool mWhiteText; 125 bool mWhiteText;
127 int mCellX; 126 int mCellX;
128 int mCellXWidth; 127 int mCellXWidth;
129 int mCellYTop,mCellYBottom; 128 int mCellYTop,mCellYBottom;
130 int mSubCell; // subcell number of this item 129 int mSubCell; // subcell number of this item
131 int mSubCells; // Total number of subcells in cell of this item 130 int mSubCells; // Total number of subcells in cell of this item
132 int xPaintCoord; 131 int xPaintCoord;
133 int yPaintCoord; 132 int yPaintCoord;
134 int wPaintCoord; 133 int wPaintCoord;
135 int hPaintCoord; 134 int hPaintCoord;
136 // Variables to remember start position 135 // Variables to remember start position
137 int mStartCellX; 136 int mStartCellX;
138 int mStartCellXWidth; 137 int mStartCellXWidth;
139 int mStartCellYTop,mStartCellYBottom; 138 int mStartCellYTop,mStartCellYBottom;
140 int mLastMovePos; 139 int mLastMovePos;
141 140
142 // Multi item pointers 141 // Multi item pointers
143 KOAgendaItem *mFirstMultiItem; 142 KOAgendaItem *mFirstMultiItem;
144 KOAgendaItem *mNextMultiItem; 143 KOAgendaItem *mNextMultiItem;
145 KOAgendaItem *mLastMultiItem; 144 KOAgendaItem *mLastMultiItem;
146 145
147 int mFontPixelSize; 146 int mFontPixelSize;
148 Incidence *mIncidence; // corresponding event or todo 147 Incidence *mIncidence; // corresponding event or todo
149 QDate mDate; //date this events occurs (for recurrence) 148 QDate mDate; //date this events occurs (for recurrence)
150 //void showIcon( QLabel*, int ); 149 //void showIcon( QLabel*, int );
151 //QLabel *mTodoIconLabel; 150 //QLabel *mTodoIconLabel;
152 //QLabel *mItemLabel; 151 //QLabel *mItemLabel;
153 //QWidget *mIconBox; 152 //QWidget *mIconBox;
154 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; 153 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
155 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; 154 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
156 //QLabel *mIconMoreInfo; 155 //QLabel *mIconMoreInfo;
157 static QToolTipGroup *mToolTipGroup; 156 static QToolTipGroup *mToolTipGroup;
158 157
159 QColor mBackgroundColor; 158 QColor mBackgroundColor;
160 QColorGroup mColorGroup; 159 QColorGroup mColorGroup;
161 QString mDisplayedText; 160 QString mDisplayedText;
162 bool mSelected; 161 bool mSelected;
163 QPtrList<KOAgendaItem> mConflictItems; 162 QPtrList<KOAgendaItem> mConflictItems;
164}; 163};
165 164
166#endif // KOAGENDAITEM_H 165#endif // KOAGENDAITEM_H
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 5a63b35..f811fba 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -222,769 +222,769 @@ void TimeLabels::updateConfig()
222void TimeLabels::positionChanged() 222void TimeLabels::positionChanged()
223{ 223{
224 int adjustment = mAgenda->contentsY(); 224 int adjustment = mAgenda->contentsY();
225 setContentsPos(0, adjustment); 225 setContentsPos(0, adjustment);
226} 226}
227 227
228/** */ 228/** */
229void TimeLabels::setAgenda(KOAgenda* agenda) 229void TimeLabels::setAgenda(KOAgenda* agenda)
230{ 230{
231 mAgenda = agenda; 231 mAgenda = agenda;
232} 232}
233 233
234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
235{ 235{
236 mMouseDownY = e->pos().y(); 236 mMouseDownY = e->pos().y();
237 mOrgCap = topLevelWidget()->caption(); 237 mOrgCap = topLevelWidget()->caption();
238} 238}
239 239
240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
241{ 241{
242 int diff = mMouseDownY - e->pos().y(); 242 int diff = mMouseDownY - e->pos().y();
243 if ( diff < 10 && diff > -10 ) 243 if ( diff < 10 && diff > -10 )
244 return; 244 return;
245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
246 if ( tSize < 4 ) 246 if ( tSize < 4 )
247 tSize = 4; 247 tSize = 4;
248 if ( tSize > 22 ) 248 if ( tSize > 22 )
249 tSize = 22; 249 tSize = 22;
250 tSize = (tSize-2)/2; 250 tSize = (tSize-2)/2;
251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
252 252
253} 253}
254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
255{ 255{
256 topLevelWidget()->setCaption( mOrgCap ); 256 topLevelWidget()->setCaption( mOrgCap );
257 int diff = mMouseDownY - e->pos().y(); 257 int diff = mMouseDownY - e->pos().y();
258 if ( diff < 10 && diff > -10 ) 258 if ( diff < 10 && diff > -10 )
259 return; 259 return;
260 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 260 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
261 if ( tSize < 4 ) 261 if ( tSize < 4 )
262 tSize = 4; 262 tSize = 4;
263 if ( tSize > 22 ) 263 if ( tSize > 22 )
264 tSize = 22; 264 tSize = 22;
265 tSize = (tSize/2)*2; 265 tSize = (tSize/2)*2;
266 if ( tSize == KOPrefs::instance()->mHourSize ) 266 if ( tSize == KOPrefs::instance()->mHourSize )
267 return; 267 return;
268 KOPrefs::instance()->mHourSize = tSize; 268 KOPrefs::instance()->mHourSize = tSize;
269 emit scaleChanged(); 269 emit scaleChanged();
270} 270}
271 271
272/** This is called in response to repaint() */ 272/** This is called in response to repaint() */
273void TimeLabels::paintEvent(QPaintEvent*) 273void TimeLabels::paintEvent(QPaintEvent*)
274{ 274{
275 275
276 // kdDebug() << "paintevent..." << endl; 276 // kdDebug() << "paintevent..." << endl;
277 // this is another hack! 277 // this is another hack!
278 // QPainter painter(this); 278 // QPainter painter(this);
279 //QString c 279 //QString c
280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
281} 281}
282 282
283//////////////////////////////////////////////////////////////////////////// 283////////////////////////////////////////////////////////////////////////////
284 284
285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
286 : QFrame(parent,name) 286 : QFrame(parent,name)
287{ 287{
288 mColumns = 1; 288 mColumns = 1;
289 mTopBox = 0; 289 mTopBox = 0;
290 mLocation = loc; 290 mLocation = loc;
291 mTopLayout = 0; 291 mTopLayout = 0;
292 mPaintWidget = 0; 292 mPaintWidget = 0;
293 mXOffset = 0; 293 mXOffset = 0;
294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
295 else mPixmap = SmallIcon("1downarrow"); 295 else mPixmap = SmallIcon("1downarrow");
296 mEnabled.resize(mColumns); 296 mEnabled.resize(mColumns);
297 mEnabled.fill( false ); 297 mEnabled.fill( false );
298 setMinimumHeight(mPixmap.height()); 298 setMinimumHeight(mPixmap.height());
299} 299}
300 300
301EventIndicator::~EventIndicator() 301EventIndicator::~EventIndicator()
302{ 302{
303} 303}
304 304
305void EventIndicator::drawContents(QPainter *p) 305void EventIndicator::drawContents(QPainter *p)
306{ 306{
307 307
308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
309 KDGanttSplitterHandle* han = 0; 309 KDGanttSplitterHandle* han = 0;
310 if ( mPaintWidget ) 310 if ( mPaintWidget )
311 han = mPaintWidget->firstHandle(); 311 han = mPaintWidget->firstHandle();
312 if ( ! han ) { 312 if ( ! han ) {
313 int i; 313 int i;
314 for(i=0;i<mColumns;++i) { 314 for(i=0;i<mColumns;++i) {
315 if (mEnabled[i]) { 315 if (mEnabled[i]) {
316 int cellWidth = contentsRect().right()/mColumns; 316 int cellWidth = contentsRect().right()/mColumns;
317 int xOffset = KOGlobals::self()->reverseLayout() ? 317 int xOffset = KOGlobals::self()->reverseLayout() ?
318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
319 i*cellWidth + (cellWidth -mPixmap.width()) /2; 319 i*cellWidth + (cellWidth -mPixmap.width()) /2;
320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
321 } 321 }
322 } 322 }
323 } else { 323 } else {
324 han->repaint(); 324 han->repaint();
325 //mPaintWidget->setBackgroundColor( red ); 325 //mPaintWidget->setBackgroundColor( red );
326 326
327 QPainter pa( han ); 327 QPainter pa( han );
328 int i; 328 int i;
329 bool setColor = false; 329 bool setColor = false;
330 for(i=0;i<mColumns;++i) { 330 for(i=0;i<mColumns;++i) {
331 if (mEnabled[i]) { 331 if (mEnabled[i]) {
332 setColor = true; 332 setColor = true;
333 333
334 int cellWidth = contentsRect().right()/mColumns; 334 int cellWidth = contentsRect().right()/mColumns;
335 int xOffset = KOGlobals::self()->reverseLayout() ? 335 int xOffset = KOGlobals::self()->reverseLayout() ?
336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
337 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 337 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
339 //qDebug("222draw pix %d ",xOffset ); 339 //qDebug("222draw pix %d ",xOffset );
340 340
341 } 341 }
342 342
343 } 343 }
344 pa.end(); 344 pa.end();
345 345
346 } 346 }
347} 347}
348 348
349void EventIndicator::setXOffset( int x ) 349void EventIndicator::setXOffset( int x )
350{ 350{
351 mXOffset = x; 351 mXOffset = x;
352} 352}
353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
354{ 354{
355 mPaintWidget = w; 355 mPaintWidget = w;
356 setMaximumHeight(0); 356 setMaximumHeight(0);
357 setMinimumHeight(0); 357 setMinimumHeight(0);
358} 358}
359void EventIndicator::changeColumns(int columns) 359void EventIndicator::changeColumns(int columns)
360{ 360{
361 mColumns = columns; 361 mColumns = columns;
362 mEnabled.resize(mColumns); 362 mEnabled.resize(mColumns);
363 363
364 update(); 364 update();
365} 365}
366 366
367void EventIndicator::enableColumn(int column, bool enable) 367void EventIndicator::enableColumn(int column, bool enable)
368{ 368{
369 mEnabled[column] = enable; 369 mEnabled[column] = enable;
370} 370}
371 371
372 372
373//////////////////////////////////////////////////////////////////////////// 373////////////////////////////////////////////////////////////////////////////
374//////////////////////////////////////////////////////////////////////////// 374////////////////////////////////////////////////////////////////////////////
375//////////////////////////////////////////////////////////////////////////// 375////////////////////////////////////////////////////////////////////////////
376 376
377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
378 KOEventView (cal,parent,name) 378 KOEventView (cal,parent,name)
379{ 379{
380 mBlockUpdating = true; 380 mBlockUpdating = true;
381 mStartHour = 8; 381 mStartHour = 8;
382 mSelectedDates.append(QDate::currentDate()); 382 mSelectedDates.append(QDate::currentDate());
383 383
384 mLayoutDayLabels = 0; 384 mLayoutDayLabels = 0;
385 mDayLabelsFrame = 0; 385 mDayLabelsFrame = 0;
386 mDayLabels = 0; 386 mDayLabels = 0;
387 bool isRTL = KOGlobals::self()->reverseLayout(); 387 bool isRTL = KOGlobals::self()->reverseLayout();
388 QPixmap expandPix; 388 QPixmap expandPix;
389 if ( KOPrefs::instance()->mVerticalScreen ) { 389 if ( KOPrefs::instance()->mVerticalScreen ) {
390 expandPix = SmallIcon( "1updownarrow" ); 390 expandPix = SmallIcon( "1updownarrow" );
391 } else { 391 } else {
392 expandPix = SmallIcon("1leftrightarrow" ); 392 expandPix = SmallIcon("1leftrightarrow" );
393 } 393 }
394 394
395 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
396 396
397 // Create day name labels for agenda columns 397 // Create day name labels for agenda columns
398 // Create agenda splitter 398 // Create agenda splitter
399 399
400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
402 topLayout->addWidget( mSplitterAgenda ); 402 topLayout->addWidget( mSplitterAgenda );
403 mAllDayFrame = new QHBox(mSplitterAgenda); 403 mAllDayFrame = new QHBox(mSplitterAgenda);
404 mAllDayFrame->setFocusPolicy(NoFocus); 404 mAllDayFrame->setFocusPolicy(NoFocus);
405 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 405 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
406 agendaFrame->setFocusPolicy(NoFocus); 406 agendaFrame->setFocusPolicy(NoFocus);
407 407
408 // Create all-day agenda widget 408 // Create all-day agenda widget
409 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 409 mDummyAllDayLeft = new QVBox( mAllDayFrame );
410 410
411 mExpandButton = new QPushButton(mDummyAllDayLeft); 411 mExpandButton = new QPushButton(mDummyAllDayLeft);
412 mExpandButton->setPixmap( expandPix ); 412 mExpandButton->setPixmap( expandPix );
413 int widebut = mExpandButton->sizeHint().width()+4; 413 int widebut = mExpandButton->sizeHint().width()+4;
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
438#endif 438#endif
439 mDayLabelsFrame = new QHBox(agendaFrame); 439 mDayLabelsFrame = new QHBox(agendaFrame);
440 //topLayout->addWidget(mDayLabelsFrame); 440 //topLayout->addWidget(mDayLabelsFrame);
441 mDayLabels = new QFrame (mDayLabelsFrame); 441 mDayLabels = new QFrame (mDayLabelsFrame);
442 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 442 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
444 agendaLayout->addWidget(mEventIndicatorTop,1,1); 444 agendaLayout->addWidget(mEventIndicatorTop,1,1);
445 445
446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
447 agendaFrame); 447 agendaFrame);
448 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 448 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
449 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 449 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
450 agendaLayout->addWidget(dummyAgendaRight,1,2); 450 agendaLayout->addWidget(dummyAgendaRight,1,2);
451 451
452 // Create time labels 452 // Create time labels
453 mTimeLabels = new TimeLabels(24,agendaFrame); 453 mTimeLabels = new TimeLabels(24,agendaFrame);
454 agendaLayout->addWidget(mTimeLabels,2,0); 454 agendaLayout->addWidget(mTimeLabels,2,0);
455 connect(mTimeLabels,SIGNAL( scaleChanged()), 455 connect(mTimeLabels,SIGNAL( scaleChanged()),
456 this,SLOT(updateConfig())); 456 this,SLOT(updateConfig()));
457 457
458 // Create agenda 458 // Create agenda
459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
461 agendaLayout->setColStretch(1,1); 461 agendaLayout->setColStretch(1,1);
462 mAgenda->setFocusPolicy(NoFocus); 462 mAgenda->setFocusPolicy(NoFocus);
463 // Create event context menu for agenda 463 // Create event context menu for agenda
464 mAllAgendaPopup = eventPopup(); 464 mAllAgendaPopup = eventPopup();
465 465
466#if 0 466#if 0
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
470 470
471#endif 471#endif
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 474
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477 477
478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), 478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)),
479 this,SLOT(categoryChanged(Incidence *))); 479 this,SLOT(categoryChanged(Incidence *)));
480 480
481 481
482 mAgenda->setPopup( mAllAgendaPopup ); 482 mAgenda->setPopup( mAllAgendaPopup );
483 mAllDayAgenda->setPopup( mAllAgendaPopup ); 483 mAllDayAgenda->setPopup( mAllAgendaPopup );
484 // make connections between dependent widgets 484 // make connections between dependent widgets
485 mTimeLabels->setAgenda(mAgenda); 485 mTimeLabels->setAgenda(mAgenda);
486 486
487 // Update widgets to reflect user preferences 487 // Update widgets to reflect user preferences
488 // updateConfig(); 488 // updateConfig();
489 489
490 // createDayLabels(); 490 // createDayLabels();
491 491
492 // these blank widgets make the All Day Event box line up with the agenda 492 // these blank widgets make the All Day Event box line up with the agenda
493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
496 496
497 // Scrolling 497 // Scrolling
498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
499 mTimeLabels, SLOT(positionChanged())); 499 mTimeLabels, SLOT(positionChanged()));
500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
501 SLOT(setContentsPos(int))); 501 SLOT(setContentsPos(int)));
502 502
503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
505 505
506 // Create/Show/Edit/Delete Event 506 // Create/Show/Edit/Delete Event
507 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 507 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
508 SLOT(newEvent(int,int))); 508 SLOT(newEvent(int,int)));
509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
510 SLOT(newTodo(int,int))); 510 SLOT(newTodo(int,int)));
511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
512 SLOT(newEvent(int,int,int,int))); 512 SLOT(newEvent(int,int,int,int)));
513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
514 SLOT(newEventAllDay(int,int))); 514 SLOT(newEventAllDay(int,int)));
515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
516 SLOT(newTodoAllDay(int,int))); 516 SLOT(newTodoAllDay(int,int)));
517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
518 SLOT(newEventAllDay(int,int))); 518 SLOT(newEventAllDay(int,int)));
519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
520 SLOT(newTimeSpanSelected(int,int,int,int))); 520 SLOT(newTimeSpanSelected(int,int,int,int)));
521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
525 525
526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
527 SIGNAL(editIncidenceSignal(Incidence *))); 527 SIGNAL(editIncidenceSignal(Incidence *)));
528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
529 SIGNAL(editIncidenceSignal(Incidence *))); 529 SIGNAL(editIncidenceSignal(Incidence *)));
530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
531 SIGNAL(showIncidenceSignal(Incidence *))); 531 SIGNAL(showIncidenceSignal(Incidence *)));
532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
533 SIGNAL(showIncidenceSignal(Incidence *))); 533 SIGNAL(showIncidenceSignal(Incidence *)));
534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
535 SIGNAL(deleteIncidenceSignal(Incidence *))); 535 SIGNAL(deleteIncidenceSignal(Incidence *)));
536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
537 SIGNAL(deleteIncidenceSignal(Incidence *))); 537 SIGNAL(deleteIncidenceSignal(Incidence *)));
538 538
539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
540 SLOT(updateEventDates(KOAgendaItem *, int ))); 540 SLOT(updateEventDates(KOAgendaItem *, int )));
541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
542 SLOT(updateEventDates(KOAgendaItem *, int))); 542 SLOT(updateEventDates(KOAgendaItem *, int)));
543 543
544 // event indicator update 544 // event indicator update
545 connect(mAgenda,SIGNAL(lowerYChanged(int)), 545 connect(mAgenda,SIGNAL(lowerYChanged(int)),
546 SLOT(updateEventIndicatorTop(int))); 546 SLOT(updateEventIndicatorTop(int)));
547 connect(mAgenda,SIGNAL(upperYChanged(int)), 547 connect(mAgenda,SIGNAL(upperYChanged(int)),
548 SLOT(updateEventIndicatorBottom(int))); 548 SLOT(updateEventIndicatorBottom(int)));
549 // drag signals 549 // drag signals
550 /* 550 /*
551 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 551 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
552 SLOT(startDrag(Event *))); 552 SLOT(startDrag(Event *)));
553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
554 SLOT(startDrag(Event *))); 554 SLOT(startDrag(Event *)));
555 */ 555 */
556 // synchronize selections 556 // synchronize selections
557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
558 mAllDayAgenda, SLOT( deselectItem() ) ); 558 mAllDayAgenda, SLOT( deselectItem() ) );
559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
560 mAgenda, SLOT( deselectItem() ) ); 560 mAgenda, SLOT( deselectItem() ) );
561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
562 SIGNAL( incidenceSelected( Incidence * ) ) ); 562 SIGNAL( incidenceSelected( Incidence * ) ) );
563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
564 SIGNAL( incidenceSelected( Incidence * ) ) ); 564 SIGNAL( incidenceSelected( Incidence * ) ) );
565 connect( mAgenda, SIGNAL( resizedSignal() ), 565 connect( mAgenda, SIGNAL( resizedSignal() ),
566 SLOT( updateConfig( ) ) ); 566 SLOT( updateConfig( ) ) );
567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
570 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 570 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
573 573
574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
576 576
577} 577}
578 578
579void KOAgendaView::toggleAllDay() 579void KOAgendaView::toggleAllDay()
580{ 580{
581 if ( mSplitterAgenda->firstHandle() ) 581 if ( mSplitterAgenda->firstHandle() )
582 mSplitterAgenda->firstHandle()->toggle(); 582 mSplitterAgenda->firstHandle()->toggle();
583} 583}
584void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 584void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
585{ 585{
586 calendar()->addIncidence( inc ); 586 calendar()->addIncidence( inc );
587 587
588 if ( incOld ) { 588 if ( incOld ) {
589 if ( incOld->typeID() == todoID ) 589 if ( incOld->typeID() == todoID )
590 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 590 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
591 else 591 else
592 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 592 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
593 } 593 }
594 594
595} 595}
596void KOAgendaView::categoryChanged(Incidence * inc) 596void KOAgendaView::categoryChanged(Incidence * inc)
597{ 597{
598 mAgenda->categoryChanged( inc ); 598 mAgenda->categoryChanged( inc );
599 mAllDayAgenda->categoryChanged( inc ); 599 mAllDayAgenda->categoryChanged( inc );
600} 600}
601KOAgendaView::~KOAgendaView() 601KOAgendaView::~KOAgendaView()
602{ 602{
603 delete mAllAgendaPopup; 603 delete mAllAgendaPopup;
604 //delete mAllDayAgendaPopup; 604 //delete mAllDayAgendaPopup;
605 delete KOAgendaItem::paintPix(); 605 delete KOAgendaItem::paintPix();
606 delete KOAgendaItem::paintPixSel(); 606 delete KOAgendaItem::paintPixAllday();
607} 607}
608void KOAgendaView::resizeEvent( QResizeEvent* e ) 608void KOAgendaView::resizeEvent( QResizeEvent* e )
609{ 609{
610 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 610 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
611 bool uc = false; 611 bool uc = false;
612 int ow = e->oldSize().width(); 612 int ow = e->oldSize().width();
613 int oh = e->oldSize().height(); 613 int oh = e->oldSize().height();
614 int w = e->size().width(); 614 int w = e->size().width();
615 int h = e->size().height(); 615 int h = e->size().height();
616 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 616 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
617 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 617 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
618 uc = true; 618 uc = true;
619 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 619 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
620 } 620 }
621 mUpcomingWidth = e->size().width() ; 621 mUpcomingWidth = e->size().width() ;
622 if ( mBlockUpdating || uc ) { 622 if ( mBlockUpdating || uc ) {
623 mBlockUpdating = false; 623 mBlockUpdating = false;
624 //mAgenda->setMinimumSize(800 , 600 ); 624 //mAgenda->setMinimumSize(800 , 600 );
625 //qDebug("mAgenda->resize+++++++++++++++ "); 625 //qDebug("mAgenda->resize+++++++++++++++ ");
626 updateConfig(); 626 updateConfig();
627 //qDebug("KOAgendaView::Updating now possible "); 627 //qDebug("KOAgendaView::Updating now possible ");
628 } else 628 } else
629 createDayLabels(); 629 createDayLabels();
630 //qDebug("resizeEvent end "); 630 //qDebug("resizeEvent end ");
631 631
632} 632}
633void KOAgendaView::slotDaylabelClicked( int num ) 633void KOAgendaView::slotDaylabelClicked( int num )
634{ 634{
635 635
636 QDate firstDate = mSelectedDates.first(); 636 QDate firstDate = mSelectedDates.first();
637 if ( num == -1 ) 637 if ( num == -1 )
638 emit showDateView( 6, firstDate ); 638 emit showDateView( 6, firstDate );
639 else if (num >= 0 ) { 639 else if (num >= 0 ) {
640 if ( mSelectedDates.count() == 1) 640 if ( mSelectedDates.count() == 1)
641 emit showDateView( 9, firstDate.addDays( num ) ); 641 emit showDateView( 9, firstDate.addDays( num ) );
642 else 642 else
643 emit showDateView( 3, firstDate.addDays( num ) ); 643 emit showDateView( 3, firstDate.addDays( num ) );
644 } 644 }
645 else 645 else
646 showDateView( 10, firstDate.addDays(1) ); 646 showDateView( 10, firstDate.addDays(1) );
647} 647}
648 648
649KOAgendaButton* KOAgendaView::getNewDaylabel() 649KOAgendaButton* KOAgendaView::getNewDaylabel()
650{ 650{
651 651
652 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 652 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
653 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 653 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
654 mDayLabelsList.append( dayLabel ); 654 mDayLabelsList.append( dayLabel );
655 mLayoutDayLabels->addWidget(dayLabel); 655 mLayoutDayLabels->addWidget(dayLabel);
656 return dayLabel ; 656 return dayLabel ;
657} 657}
658 658
659void KOAgendaView::createDayLabels() 659void KOAgendaView::createDayLabels()
660{ 660{
661 661
662 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 662 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
663 // qDebug(" KOAgendaView::createDayLabels() blocked "); 663 // qDebug(" KOAgendaView::createDayLabels() blocked ");
664 return; 664 return;
665 665
666 } 666 }
667 int newHight; 667 int newHight;
668 if ( !mSelectedDates.count()) 668 if ( !mSelectedDates.count())
669 return; 669 return;
670 670
671 // ### Before deleting and recreating we could check if mSelectedDates changed... 671 // ### Before deleting and recreating we could check if mSelectedDates changed...
672 // It would remove some flickering and gain speed (since this is called by 672 // It would remove some flickering and gain speed (since this is called by
673 // each updateView() call) 673 // each updateView() call)
674 674
675 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 675 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
676 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 676 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
677 if ( maxWid < 20 ) 677 if ( maxWid < 20 )
678 maxWid = 20; 678 maxWid = 20;
679 679
680 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 680 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
681 QFontMetrics fm ( dlf ); 681 QFontMetrics fm ( dlf );
682 dlf.setBold( true ); 682 dlf.setBold( true );
683 int selCount = mSelectedDates.count(); 683 int selCount = mSelectedDates.count();
684 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 684 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
685 QString dayTest = "Mon 20"; 685 QString dayTest = "Mon 20";
686 //QString dayTest = "Mon 20"; 686 //QString dayTest = "Mon 20";
687 int wid = fm.width( dayTest ); 687 int wid = fm.width( dayTest );
688 //maxWid -= ( selCount * 3 ); //working for QLabels 688 //maxWid -= ( selCount * 3 ); //working for QLabels
689 if ( QApplication::desktop()->width() <= 320 ) 689 if ( QApplication::desktop()->width() <= 320 )
690 maxWid -= ( selCount * 3 ); //working for QPushButton 690 maxWid -= ( selCount * 3 ); //working for QPushButton
691 else 691 else
692 maxWid -= ( selCount * 4 ); //working for QPushButton 692 maxWid -= ( selCount * 4 ); //working for QPushButton
693 if ( maxWid < 0 ) 693 if ( maxWid < 0 )
694 maxWid = 20; 694 maxWid = 20;
695 int needWid = wid * selCount; 695 int needWid = wid * selCount;
696 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 696 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
697 //if ( needWid > maxWid ) 697 //if ( needWid > maxWid )
698 // qDebug("DAYLABELS TOOOOOOO BIG "); 698 // qDebug("DAYLABELS TOOOOOOO BIG ");
699 while ( needWid > maxWid ) { 699 while ( needWid > maxWid ) {
700 dayTest = dayTest.left( dayTest.length() - 1 ); 700 dayTest = dayTest.left( dayTest.length() - 1 );
701 wid = fm.width( dayTest ); 701 wid = fm.width( dayTest );
702 needWid = wid * selCount; 702 needWid = wid * selCount;
703 } 703 }
704 int maxLen = dayTest.length(); 704 int maxLen = dayTest.length();
705 int fontPoint = dlf.pointSize(); 705 int fontPoint = dlf.pointSize();
706 if ( maxLen < 2 ) { 706 if ( maxLen < 2 ) {
707 int fontPoint = dlf.pointSize(); 707 int fontPoint = dlf.pointSize();
708 while ( fontPoint > 4 ) { 708 while ( fontPoint > 4 ) {
709 --fontPoint; 709 --fontPoint;
710 dlf.setPointSize( fontPoint ); 710 dlf.setPointSize( fontPoint );
711 QFontMetrics f( dlf ); 711 QFontMetrics f( dlf );
712 wid = f.width( "30" ); 712 wid = f.width( "30" );
713 needWid = wid * selCount; 713 needWid = wid * selCount;
714 if ( needWid < maxWid ) 714 if ( needWid < maxWid )
715 break; 715 break;
716 } 716 }
717 maxLen = 2; 717 maxLen = 2;
718 } 718 }
719 //qDebug("Max len %d ", dayTest.length() ); 719 //qDebug("Max len %d ", dayTest.length() );
720 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) 720 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() )
721 dlf.setBold( false ); 721 dlf.setBold( false );
722 QFontMetrics tempF( dlf ); 722 QFontMetrics tempF( dlf );
723 newHight = tempF.height(); 723 newHight = tempF.height();
724 mDayLabels->setFont( dlf ); 724 mDayLabels->setFont( dlf );
725 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 725 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
726 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 726 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
727 //mLayoutDayLabels->addSpacing( 2 ); 727 //mLayoutDayLabels->addSpacing( 2 );
728 // QFont lFont = dlf; 728 // QFont lFont = dlf;
729 bool appendLabels = false; 729 bool appendLabels = false;
730 KOAgendaButton *dayLabel; 730 KOAgendaButton *dayLabel;
731 dayLabel = mDayLabelsList.first(); 731 dayLabel = mDayLabelsList.first();
732 if ( !dayLabel ) { 732 if ( !dayLabel ) {
733 appendLabels = true; 733 appendLabels = true;
734 dayLabel = getNewDaylabel(); 734 dayLabel = getNewDaylabel();
735 } 735 }
736 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 736 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
737 dayLabel->setFont( dlf ); 737 dayLabel->setFont( dlf );
738 dayLabel->setNum( -1 ); 738 dayLabel->setNum( -1 );
739 //dayLabel->setAlignment(QLabel::AlignHCenter); 739 //dayLabel->setAlignment(QLabel::AlignHCenter);
740 740
741 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 741 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
742 dayLabel->show(); 742 dayLabel->show();
743 DateList::ConstIterator dit; 743 DateList::ConstIterator dit;
744 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 744 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
745 int counter = -1; 745 int counter = -1;
746 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 746 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
747 ++counter; 747 ++counter;
748 QDate date = *dit; 748 QDate date = *dit;
749 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 749 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
750 if ( ! appendLabels ) { 750 if ( ! appendLabels ) {
751 dayLabel = mDayLabelsList.next(); 751 dayLabel = mDayLabelsList.next();
752 if ( !dayLabel ) 752 if ( !dayLabel )
753 appendLabels = true; 753 appendLabels = true;
754 } 754 }
755 if ( appendLabels ) { 755 if ( appendLabels ) {
756 dayLabel = getNewDaylabel(); 756 dayLabel = getNewDaylabel();
757 } 757 }
758 dayLabel->setMinimumWidth( 1 ); 758 dayLabel->setMinimumWidth( 1 );
759 dayLabel->setMaximumWidth( 10240 ); 759 dayLabel->setMaximumWidth( 10240 );
760 dayLabel->setFont( dlf ); 760 dayLabel->setFont( dlf );
761 dayLabel->show(); 761 dayLabel->show();
762 dayLabel->setAutoRepeat( false ); 762 dayLabel->setAutoRepeat( false );
763 dayLabel->setNum( counter ); 763 dayLabel->setNum( counter );
764 QString str; 764 QString str;
765 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 765 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
766 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 766 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
767 switch ( maxLen ) { 767 switch ( maxLen ) {
768 case 2: 768 case 2:
769 str = QString::number( date.day() ); 769 str = QString::number( date.day() );
770 break; 770 break;
771 771
772 case 3: 772 case 3:
773 str = dayName.left( 1 ) +QString::number( date.day()); 773 str = dayName.left( 1 ) +QString::number( date.day());
774 774
775 break; 775 break;
776 case 4: 776 case 4:
777 str = dayName.left( 1 ) + " " +QString::number( date.day()); 777 str = dayName.left( 1 ) + " " +QString::number( date.day());
778 778
779 break; 779 break;
780 case 5: 780 case 5:
781 str = dayName.left( 2 ) + " " +QString::number( date.day()); 781 str = dayName.left( 2 ) + " " +QString::number( date.day());
782 782
783 break; 783 break;
784 case 6: 784 case 6:
785 str = dayName.left( 3 ) + " " +QString::number( date.day()); 785 str = dayName.left( 3 ) + " " +QString::number( date.day());
786 break; 786 break;
787 787
788 default: 788 default:
789 break; 789 break;
790 } 790 }
791 if ( oneday ) { 791 if ( oneday ) {
792 QString addString; 792 QString addString;
793 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 793 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
794 addString = i18n("Today"); 794 addString = i18n("Today");
795 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 795 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
796 addString = i18n("Tomorrow"); 796 addString = i18n("Tomorrow");
797 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 797 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
798 addString = i18n("Yesterday"); 798 addString = i18n("Yesterday");
799 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 799 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
800 addString = i18n("Day before yesterday"); 800 addString = i18n("Day before yesterday");
801 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 801 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
802 addString = i18n("Day after tomorrow"); 802 addString = i18n("Day after tomorrow");
803 if ( !addString.isEmpty() ) { 803 if ( !addString.isEmpty() ) {
804 str = addString+", " + str; 804 str = addString+", " + str;
805 } else { 805 } else {
806 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 806 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
807 } 807 }
808 } 808 }
809 dayLabel->setText(str); 809 dayLabel->setText(str);
810 //dayLabel->setAlignment(QLabel::AlignHCenter); 810 //dayLabel->setAlignment(QLabel::AlignHCenter);
811 if (date == QDate::currentDate()) { 811 if (date == QDate::currentDate()) {
812 QFont bFont = dlf; 812 QFont bFont = dlf;
813 bFont.setBold( true ); 813 bFont.setBold( true );
814 dayLabel->setFont(bFont); 814 dayLabel->setFont(bFont);
815 } 815 }
816 //dayLayout->addWidget(dayLabel); 816 //dayLayout->addWidget(dayLabel);
817 817
818#ifndef KORG_NOPLUGINS 818#ifndef KORG_NOPLUGINS
819 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 819 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
820 CalendarDecoration *it; 820 CalendarDecoration *it;
821 for(it = cds.first(); it; it = cds.next()) { 821 for(it = cds.first(); it; it = cds.next()) {
822 QString text = it->shortText( date ); 822 QString text = it->shortText( date );
823 if ( !text.isEmpty() ) { 823 if ( !text.isEmpty() ) {
824 QLabel *label = new QLabel(text,mDayLabels); 824 QLabel *label = new QLabel(text,mDayLabels);
825 label->setAlignment(AlignCenter); 825 label->setAlignment(AlignCenter);
826 dayLayout->addWidget(label); 826 dayLayout->addWidget(label);
827 } 827 }
828 } 828 }
829 829
830 for(it = cds.first(); it; it = cds.next()) { 830 for(it = cds.first(); it; it = cds.next()) {
831 QWidget *wid = it->smallWidget(mDayLabels,date); 831 QWidget *wid = it->smallWidget(mDayLabels,date);
832 if ( wid ) { 832 if ( wid ) {
833 // wid->setHeight(20); 833 // wid->setHeight(20);
834 dayLayout->addWidget(wid); 834 dayLayout->addWidget(wid);
835 } 835 }
836 } 836 }
837#endif 837#endif
838 } 838 }
839 if ( ! appendLabels ) { 839 if ( ! appendLabels ) {
840 dayLabel = mDayLabelsList.next(); 840 dayLabel = mDayLabelsList.next();
841 if ( !dayLabel ) 841 if ( !dayLabel )
842 appendLabels = true; 842 appendLabels = true;
843 } 843 }
844 if ( appendLabels ) { 844 if ( appendLabels ) {
845 dayLabel = getNewDaylabel(); 845 dayLabel = getNewDaylabel();
846 } 846 }
847 //dayLabel->hide();//test only 847 //dayLabel->hide();//test only
848 848
849 dayLabel->setText(">"); 849 dayLabel->setText(">");
850 dayLabel->setFont( dlf ); 850 dayLabel->setFont( dlf );
851 dayLabel->setAutoRepeat( true ); 851 dayLabel->setAutoRepeat( true );
852 dayLabel->show(); 852 dayLabel->show();
853 dayLabel->setNum( -2 ); 853 dayLabel->setNum( -2 );
854 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); 854 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
855 855
856 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 856 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
857 if ( !appendLabels ) { 857 if ( !appendLabels ) {
858 dayLabel = mDayLabelsList.next(); 858 dayLabel = mDayLabelsList.next();
859 while ( dayLabel ) { 859 while ( dayLabel ) {
860 //qDebug("!dayLabel %d",dayLabel ); 860 //qDebug("!dayLabel %d",dayLabel );
861 dayLabel->hide(); 861 dayLabel->hide();
862 dayLabel = mDayLabelsList.next(); 862 dayLabel = mDayLabelsList.next();
863 } 863 }
864 } 864 }
865 865
866 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 866 mDayLabelsFrame->setFixedHeight( newHight + 4 );
867} 867}
868 868
869int KOAgendaView::maxDatesHint() 869int KOAgendaView::maxDatesHint()
870{ 870{
871 // Not sure about the max number of events, so return 0 for now. 871 // Not sure about the max number of events, so return 0 for now.
872 return 0; 872 return 0;
873} 873}
874 874
875int KOAgendaView::currentDateCount() 875int KOAgendaView::currentDateCount()
876{ 876{
877 return mSelectedDates.count(); 877 return mSelectedDates.count();
878} 878}
879 879
880QPtrList<Incidence> KOAgendaView::selectedIncidences() 880QPtrList<Incidence> KOAgendaView::selectedIncidences()
881{ 881{
882 QPtrList<Incidence> selected; 882 QPtrList<Incidence> selected;
883 Incidence *incidence; 883 Incidence *incidence;
884 884
885 incidence = mAgenda->selectedIncidence(); 885 incidence = mAgenda->selectedIncidence();
886 if (incidence) selected.append(incidence); 886 if (incidence) selected.append(incidence);
887 887
888 incidence = mAllDayAgenda->selectedIncidence(); 888 incidence = mAllDayAgenda->selectedIncidence();
889 if (incidence) selected.append(incidence); 889 if (incidence) selected.append(incidence);
890 890
891 return selected; 891 return selected;
892} 892}
893 893
894DateList KOAgendaView::selectedDates() 894DateList KOAgendaView::selectedDates()
895{ 895{
896 DateList selected; 896 DateList selected;
897 QDate qd; 897 QDate qd;
898 898
899 qd = mAgenda->selectedIncidenceDate(); 899 qd = mAgenda->selectedIncidenceDate();
900 if (qd.isValid()) selected.append(qd); 900 if (qd.isValid()) selected.append(qd);
901 901
902 qd = mAllDayAgenda->selectedIncidenceDate(); 902 qd = mAllDayAgenda->selectedIncidenceDate();
903 if (qd.isValid()) selected.append(qd); 903 if (qd.isValid()) selected.append(qd);
904 904
905 return selected; 905 return selected;
906} 906}
907 907
908 908
909void KOAgendaView::updateView() 909void KOAgendaView::updateView()
910{ 910{
911 if ( mBlockUpdating ) 911 if ( mBlockUpdating )
912 return; 912 return;
913 // kdDebug() << "KOAgendaView::updateView()" << endl; 913 // kdDebug() << "KOAgendaView::updateView()" << endl;
914 fillAgenda(); 914 fillAgenda();
915 915
916} 916}
917 917
918 918
919/* 919/*
920 Update configuration settings for the agenda view. This method is not 920 Update configuration settings for the agenda view. This method is not
921 complete. 921 complete.
922*/ 922*/
923void KOAgendaView::updateConfig() 923void KOAgendaView::updateConfig()
924{ 924{
925 if ( mBlockUpdating ) 925 if ( mBlockUpdating )
926 return; 926 return;
927 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { 927 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
928 int old = KOPrefs::instance()->mHourSize; 928 int old = KOPrefs::instance()->mHourSize;
929 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; 929 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
930 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); 930 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
931 } 931 }
932 932
933 933
934 // update config for children 934 // update config for children
935 mTimeLabels->updateConfig(); 935 mTimeLabels->updateConfig();
936 mAgenda->storePosition(); 936 mAgenda->storePosition();
937 mAgenda->updateConfig(); 937 mAgenda->updateConfig();
938 mAllDayAgenda->updateConfig(); 938 mAllDayAgenda->updateConfig();
939 // widget synchronization 939 // widget synchronization
940 //TODO: find a better way, maybe signal/slot 940 //TODO: find a better way, maybe signal/slot
941 mTimeLabels->positionChanged(); 941 mTimeLabels->positionChanged();
942 942
943 // for some reason, this needs to be called explicitly 943 // for some reason, this needs to be called explicitly
944 mTimeLabels->repaint(); 944 mTimeLabels->repaint();
945 945
946 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 946 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
947 947
948 // ToolTips displaying summary of events 948 // ToolTips displaying summary of events
949 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 949 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
950 ->mEnableToolTips); 950 ->mEnableToolTips);
951 951
952 //setHolidayMasks(); 952 //setHolidayMasks();
953 953
954 //createDayLabels(); called by via updateView(); 954 //createDayLabels(); called by via updateView();
955 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 955 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
956 updateView(); 956 updateView();
957 mAgenda->restorePosition(); 957 mAgenda->restorePosition();
958} 958}
959 959
960 960
961void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 961void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
962{ 962{
963 963
964 964
965 int xxx = item->cellX(); 965 int xxx = item->cellX();
966 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); 966 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() );
967 if ( mMinY.at(xxx) > item->cellYTop() ) 967 if ( mMinY.at(xxx) > item->cellYTop() )
968 mMinY.at(xxx) = item->cellYTop(); 968 mMinY.at(xxx) = item->cellYTop();
969 if ( mMaxY.at(xxx) < item->cellYBottom() ) 969 if ( mMaxY.at(xxx) < item->cellYBottom() )
970 mMaxY.at(xxx) = item->cellYBottom(); 970 mMaxY.at(xxx) = item->cellYBottom();
971 971
972 QDateTime startDt,endDt; 972 QDateTime startDt,endDt;
973 QDate startDate; 973 QDate startDate;
974 int lenInSecs; 974 int lenInSecs;
975 // if ( type == KOAgenda::RESIZETOP ) 975 // if ( type == KOAgenda::RESIZETOP )
976 // qDebug("RESIZETOP "); 976 // qDebug("RESIZETOP ");
977 // if ( type == KOAgenda::RESIZEBOTTOM ) 977 // if ( type == KOAgenda::RESIZEBOTTOM )
978 // qDebug("RESIZEBOTTOM "); 978 // qDebug("RESIZEBOTTOM ");
979 // if ( type == KOAgenda::MOVE ) 979 // if ( type == KOAgenda::MOVE )
980 // qDebug("MOVE "); 980 // qDebug("MOVE ");
981 if ( item->incidence()->typeID() == eventID ) { 981 if ( item->incidence()->typeID() == eventID ) {
982 startDt =item->incidence()->dtStart(); 982 startDt =item->incidence()->dtStart();
983 endDt = item->incidence()->dtEnd(); 983 endDt = item->incidence()->dtEnd();
984 lenInSecs = startDt.secsTo( endDt ); 984 lenInSecs = startDt.secsTo( endDt );
985 } 985 }
986 986
987 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 987 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
988 988
989 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { 989 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) {
990 startDate = mSelectedDates[item->mLastMoveXPos]; 990 startDate = mSelectedDates[item->mLastMoveXPos];