summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-05 08:37:52 (UTC)
committer zautrix <zautrix>2005-07-05 08:37:52 (UTC)
commit7e49703511de87f624cc8813b18ebbfcc01752cd (patch) (unidiff)
tree896918396dbf518f6358a066f93a04bd4185f535
parent28ca4c37fb0e131b2978584992840b3fdca21d3e (diff)
downloadkdepimpi-7e49703511de87f624cc8813b18ebbfcc01752cd.zip
kdepimpi-7e49703511de87f624cc8813b18ebbfcc01752cd.tar.gz
kdepimpi-7e49703511de87f624cc8813b18ebbfcc01752cd.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp35
-rw-r--r--korganizer/koagenda.h3
-rw-r--r--korganizer/koagendaview.cpp22
-rw-r--r--korganizer/koagendaview.h1
4 files changed, 44 insertions, 17 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index c339b57..662576f 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1,824 +1,834 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 Marcus Bains line. 5 Marcus Bains line.
6 Copyright (c) 2001 Ali Rahimi 6 Copyright (c) 2001 Ali Rahimi
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#define protected public 28#define protected public
29#include <qwidget.h> 29#include <qwidget.h>
30#undef protected 30#undef protected
31#endif 31#endif
32#include <qintdict.h> 32#include <qintdict.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qpainter.h> 37#include <qpainter.h>
38 38
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kglobal.h> 42#include <kglobal.h>
43 43
44#include "koagendaitem.h" 44#include "koagendaitem.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47 47
48#include "koagenda.h" 48#include "koagenda.h"
49 49
50#include <libkcal/event.h> 50#include <libkcal/event.h>
51#include <libkcal/todo.h> 51#include <libkcal/todo.h>
52 52
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
55#endif 55#endif
56 56
57//extern bool globalFlagBlockPainting; 57//extern bool globalFlagBlockPainting;
58extern int globalFlagBlockAgenda; 58extern int globalFlagBlockAgenda;
59extern int globalFlagBlockAgendaItemPaint; 59extern int globalFlagBlockAgendaItemPaint;
60extern int globalFlagBlockAgendaItemUpdate; 60extern int globalFlagBlockAgendaItemUpdate;
61extern int globalFlagBlockStartup; 61extern int globalFlagBlockStartup;
62 62
63bool KOAgenda::mInvalidPixmap = false; 63
64//////////////////////////////////////////////////////////////////////////// 64////////////////////////////////////////////////////////////////////////////
65MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 65MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
66 : QFrame(_agenda->viewport(),name), agenda(_agenda) 66 : QFrame(_agenda->viewport(),name), agenda(_agenda)
67{ 67{
68 setLineWidth(0); 68 setLineWidth(0);
69 setMargin(0); 69 setMargin(0);
70 setBackgroundColor(Qt::red); 70 setBackgroundColor(Qt::red);
71 minutes = new QTimer(this); 71 minutes = new QTimer(this);
72 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 72 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
73 minutes->start(0, true); 73 minutes->start(0, true);
74 mTimeBox = new QLabel(this); 74 mTimeBox = new QLabel(this);
75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
76 QPalette pal = mTimeBox->palette(); 76 QPalette pal = mTimeBox->palette();
77 pal.setColor(QColorGroup::Foreground, Qt::red); 77 pal.setColor(QColorGroup::Foreground, Qt::red);
78 mTimeBox->setPalette(pal); 78 mTimeBox->setPalette(pal);
79 //mTimeBox->setAutoMask(true); 79 //mTimeBox->setAutoMask(true);
80 80
81 agenda->addChild(mTimeBox); 81 agenda->addChild(mTimeBox);
82 82
83 oldToday = -1; 83 oldToday = -1;
84} 84}
85 85
86MarcusBains::~MarcusBains() 86MarcusBains::~MarcusBains()
87{ 87{
88 delete minutes; 88 delete minutes;
89} 89}
90 90
91int MarcusBains::todayColumn() 91int MarcusBains::todayColumn()
92{ 92{
93 QDate currentDate = QDate::currentDate(); 93 QDate currentDate = QDate::currentDate();
94 94
95 DateList dateList = agenda->dateList(); 95 DateList dateList = agenda->dateList();
96 DateList::ConstIterator it; 96 DateList::ConstIterator it;
97 int col = 0; 97 int col = 0;
98 for(it = dateList.begin(); it != dateList.end(); ++it) { 98 for(it = dateList.begin(); it != dateList.end(); ++it) {
99 if((*it) == currentDate) 99 if((*it) == currentDate)
100 return KOGlobals::self()->reverseLayout() ? 100 return KOGlobals::self()->reverseLayout() ?
101 agenda->columns() - 1 - col : col; 101 agenda->columns() - 1 - col : col;
102 ++col; 102 ++col;
103 } 103 }
104 104
105 return -1; 105 return -1;
106} 106}
107void MarcusBains::updateLoc() 107void MarcusBains::updateLoc()
108{ 108{
109 updateLocation(); 109 updateLocation();
110} 110}
111void MarcusBains::updateLocation(bool recalculate) 111void MarcusBains::updateLocation(bool recalculate)
112{ 112{
113 113
114 QTime tim = QTime::currentTime(); 114 QTime tim = QTime::currentTime();
115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
116 if((tim.hour() == 0) && (oldTime.hour()==23)) 116 if((tim.hour() == 0) && (oldTime.hour()==23))
117 recalculate = true; 117 recalculate = true;
118 118
119 int mins = tim.hour()*60 + tim.minute(); 119 int mins = tim.hour()*60 + tim.minute();
120 int minutesPerCell = 24 * 60 / agenda->rows(); 120 int minutesPerCell = 24 * 60 / agenda->rows();
121 int y = mins*agenda->gridSpacingY()/minutesPerCell; 121 int y = mins*agenda->gridSpacingY()/minutesPerCell;
122 int today = recalculate ? todayColumn() : oldToday; 122 int today = recalculate ? todayColumn() : oldToday;
123 int x = agenda->gridSpacingX()*today; 123 int x = agenda->gridSpacingX()*today;
124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
125 125
126 oldTime = tim; 126 oldTime = tim;
127 oldToday = today; 127 oldToday = today;
128 128
129 if(disabled || (today<0)) { 129 if(disabled || (today<0)) {
130 hide(); mTimeBox->hide(); 130 hide(); mTimeBox->hide();
131 return; 131 return;
132 } else { 132 } else {
133 show(); mTimeBox->show(); 133 show(); mTimeBox->show();
134 } 134 }
135 135
136 if(recalculate) 136 if(recalculate)
137 setFixedSize(agenda->gridSpacingX(),1); 137 setFixedSize(agenda->gridSpacingX(),1);
138 agenda->moveChild(this, x, y); 138 agenda->moveChild(this, x, y);
139 raise(); 139 raise();
140 140
141 if(recalculate) 141 if(recalculate)
142 //mTimeBox->setFont(QFont("helvetica",10)); 142 //mTimeBox->setFont(QFont("helvetica",10));
143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
144 144
145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
146 mTimeBox->adjustSize(); 146 mTimeBox->adjustSize();
147 // the -2 below is there because there is a bug in this program 147 // the -2 below is there because there is a bug in this program
148 // somewhere, where the last column of this widget is a few pixels 148 // somewhere, where the last column of this widget is a few pixels
149 // narrower than the other columns. 149 // narrower than the other columns.
150 int offs = (today==agenda->columns()-1) ? -4 : 0; 150 int offs = (today==agenda->columns()-1) ? -4 : 0;
151 agenda->moveChild(mTimeBox, 151 agenda->moveChild(mTimeBox,
152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
153 y-mTimeBox->height()); 153 y-mTimeBox->height());
154 154
155 mTimeBox->raise(); 155 mTimeBox->raise();
156 //mTimeBox->setAutoMask(true); 156 //mTimeBox->setAutoMask(true);
157 minutes->start(5000,true); 157 minutes->start(5000,true);
158} 158}
159 159
160 160
161//////////////////////////////////////////////////////////////////////////// 161////////////////////////////////////////////////////////////////////////////
162 162
163 163
164/* 164/*
165 Create an agenda widget with rows rows and columns columns. 165 Create an agenda widget with rows rows and columns columns.
166*/ 166*/
167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
168 const char *name,WFlags f) : 168 const char *name,WFlags f) :
169 QScrollView(parent,name,f) 169 QScrollView(parent,name,f)
170{ 170{
171 171
172 mAllAgendaPopup = 0; 172 mAllAgendaPopup = 0;
173 mColumns = columns; 173 mColumns = columns;
174 mRows = rows; 174 mRows = rows;
175 mGridSpacingY = rowSize; 175 mGridSpacingY = rowSize;
176 mAllDayMode = false; 176 mAllDayMode = false;
177#ifndef DESKTOP_VERSION 177#ifndef DESKTOP_VERSION
178 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 178 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
179#endif 179#endif
180 mHolidayMask = 0; 180 mHolidayMask = 0;
181 init(); 181 init();
182 connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); 182 connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) );
183} 183}
184 184
185/* 185/*
186 Create an agenda widget with columns columns and one row. This is used for 186 Create an agenda widget with columns columns and one row. This is used for
187 all-day events. 187 all-day events.
188*/ 188*/
189KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 189KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
190 QScrollView(parent,name,f) 190 QScrollView(parent,name,f)
191{ 191{
192 mAllAgendaPopup = 0; 192 mAllAgendaPopup = 0;
193 blockResize = false; 193 blockResize = false;
194 mColumns = columns; 194 mColumns = columns;
195 mRows = 1; 195 mRows = 1;
196 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 196 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
197 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 197 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
198 mAllDayMode = true; 198 mAllDayMode = true;
199#ifndef DESKTOP_VERSION 199#ifndef DESKTOP_VERSION
200 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 200 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
201#endif 201#endif
202 mHolidayMask = 0; 202 mHolidayMask = 0;
203 init(); 203 init();
204} 204}
205 205
206 206
207KOAgenda::~KOAgenda() 207KOAgenda::~KOAgenda()
208{ 208{
209 if(mMarcusBains) delete mMarcusBains; 209 if(mMarcusBains) delete mMarcusBains;
210 210
211} 211}
212 212
213Incidence *KOAgenda::selectedIncidence() const 213Incidence *KOAgenda::selectedIncidence() const
214{ 214{
215 return (mSelectedItem ? mSelectedItem->incidence() : 0); 215 return (mSelectedItem ? mSelectedItem->incidence() : 0);
216} 216}
217 217
218 218
219QDate KOAgenda::selectedIncidenceDate() const 219QDate KOAgenda::selectedIncidenceDate() const
220{ 220{
221 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 221 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
222} 222}
223 223
224 224
225void KOAgenda::init() 225void KOAgenda::init()
226{ 226{
227 mPopupTimer = new QTimer(this); 227 mPopupTimer = new QTimer(this);
228 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 228 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
229 229
230 mNewItemPopup = new QPopupMenu( this ); 230 mNewItemPopup = new QPopupMenu( this );
231 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 231 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
232 QString pathString = ""; 232 QString pathString = "";
233 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 233 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
234 if ( QApplication::desktop()->width() < 480 ) 234 if ( QApplication::desktop()->width() < 480 )
235 pathString += "icons16/"; 235 pathString += "icons16/";
236 } else 236 } else
237 pathString += "iconsmini/"; 237 pathString += "iconsmini/";
238 238
239 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 239 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
241 mNewItemPopup->insertSeparator ( ); 241 mNewItemPopup->insertSeparator ( );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
245 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 245 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
246 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); 246 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 );
247 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 247 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
248#ifndef _WIN32_ 248#ifndef _WIN32_
249 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 249 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
250 viewport()->setWFlags ( wflags); 250 viewport()->setWFlags ( wflags);
251#endif 251#endif
252 mGridSpacingX = 80; 252 mGridSpacingX = 80;
253 mResizeBorderWidth = 8; 253 mResizeBorderWidth = 8;
254 mScrollBorderWidth = 8; 254 mScrollBorderWidth = 8;
255 mScrollDelay = 30; 255 mScrollDelay = 30;
256 mScrollOffset = 10; 256 mScrollOffset = 10;
257 mPaintPixmap.resize( 20,20); 257 mPaintPixmap.resize( 20,20);
258 //enableClipper(true); 258 //enableClipper(true);
259 259
260 // Grab key strokes for keyboard navigation of agenda. Seems to have no 260 // Grab key strokes for keyboard navigation of agenda. Seems to have no
261 // effect. Has to be fixed. 261 // effect. Has to be fixed.
262 setFocusPolicy(WheelFocus); 262 setFocusPolicy(WheelFocus);
263 263
264 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 264 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
265 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 265 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
266 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 266 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
267 267
268 mStartCellX = 0; 268 mStartCellX = 0;
269 mStartCellY = 0; 269 mStartCellY = 0;
270 mCurrentCellX = 0; 270 mCurrentCellX = 0;
271 mCurrentCellY = 0; 271 mCurrentCellY = 0;
272 272
273 mSelectionCellX = 0; 273 mSelectionCellX = 0;
274 mSelectionYTop = 0; 274 mSelectionYTop = 0;
275 mSelectionHeight = 0; 275 mSelectionHeight = 0;
276 276
277 mOldLowerScrollValue = -1; 277 mOldLowerScrollValue = -1;
278 mOldUpperScrollValue = -1; 278 mOldUpperScrollValue = -1;
279 279
280 mClickedItem = 0; 280 mClickedItem = 0;
281 281
282 mActionItem = 0; 282 mActionItem = 0;
283 mActionType = NOP; 283 mActionType = NOP;
284 mItemMoved = false; 284 mItemMoved = false;
285 285
286 mSelectedItem = 0; 286 mSelectedItem = 0;
287 287
288 // mItems.setAutoDelete(true); 288 // mItems.setAutoDelete(true);
289 289
290 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 290 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
291 291
292 viewport()->update(); 292 viewport()->update();
293 293
294 setMinimumSize(30, 1); 294 setMinimumSize(30, 1);
295// setMaximumHeight(mGridSpacingY * mRows + 5); 295// setMaximumHeight(mGridSpacingY * mRows + 5);
296 296
297 // Disable horizontal scrollbar. This is a hack. The geometry should be 297 // Disable horizontal scrollbar. This is a hack. The geometry should be
298 // controlled in a way that the contents horizontally always fits. Then it is 298 // controlled in a way that the contents horizontally always fits. Then it is
299 // not necessary to turn off the scrollbar. 299 // not necessary to turn off the scrollbar.
300 setHScrollBarMode(AlwaysOff); 300 setHScrollBarMode(AlwaysOff);
301 if ( ! mAllDayMode ) 301 if ( ! mAllDayMode )
302 setVScrollBarMode(AlwaysOn); 302 setVScrollBarMode(AlwaysOn);
303 else 303 else
304 setVScrollBarMode(AlwaysOff); 304 setVScrollBarMode(AlwaysOff);
305 305
306 setStartHour(KOPrefs::instance()->mDayBegins); 306 setStartHour(KOPrefs::instance()->mDayBegins);
307 307
308 calculateWorkingHours(); 308 calculateWorkingHours();
309 309
310 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 310 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
311 SLOT(checkScrollBoundaries(int))); 311 SLOT(checkScrollBoundaries(int)));
312 312
313 // Create the Marcus Bains line. 313 // Create the Marcus Bains line.
314 if(mAllDayMode) 314 if(mAllDayMode)
315 mMarcusBains = 0; 315 mMarcusBains = 0;
316 else { 316 else {
317 mMarcusBains = new MarcusBains(this); 317 mMarcusBains = new MarcusBains(this);
318 addChild(mMarcusBains); 318 addChild(mMarcusBains);
319 } 319 }
320 mPopupKind = 0; 320 mPopupKind = 0;
321 mPopupItem = 0; 321 mPopupItem = 0;
322 mInvalidPixmap = false; 322 mInvalidPixmap = false;
323 323
324} 324}
325 325
326void KOAgenda::shrinkPixmap() 326void KOAgenda::shrinkPixmap()
327{ 327{
328 mPaintPixmap.resize( 20,20); 328 mPaintPixmap.resize( 20,20);
329 mInvalidPixmap = true; 329 mInvalidPixmap = true;
330} 330}
331void KOAgenda::slotContentMove(int,int) 331void KOAgenda::slotContentMove(int,int)
332{ 332{
333 emit sendPing();
333 if ( mActionType == NOP ) 334 if ( mActionType == NOP )
334 slotClearSelection(); 335 slotClearSelection();
335 if ( mSelectedItem && !mActionItem ) { 336 if ( mSelectedItem && !mActionItem ) {
336 deselectItem(); 337 deselectItem();
337 emit incidenceSelected( 0 ); 338 emit incidenceSelected( 0 );
338 } 339 }
339} 340}
340void KOAgenda::clear() 341void KOAgenda::clear()
341{ 342{
342 KOAgendaItem *item; 343 KOAgendaItem *item;
343 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 344 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
344 mUnusedItems.append( item ); 345 mUnusedItems.append( item );
345 //item->hide(); 346 //item->hide();
346 } 347 }
347 mItems.clear(); 348 mItems.clear();
348 mSelectedItem = 0; 349 mSelectedItem = 0;
349 clearSelection(); 350 clearSelection();
350} 351}
351 352
352void KOAgenda::clearSelection() 353void KOAgenda::clearSelection()
353{ 354{
354 mSelectionCellX = 0; 355 mSelectionCellX = 0;
355 mSelectionYTop = 0; 356 mSelectionYTop = 0;
356 mSelectionHeight = 0; 357 mSelectionHeight = 0;
357} 358}
358 359
359void KOAgenda::marcus_bains() 360void KOAgenda::marcus_bains()
360{ 361{
361 if(mMarcusBains) mMarcusBains->updateLocation(true); 362 if(mMarcusBains) mMarcusBains->updateLocation(true);
362} 363}
363 364
364 365
365void KOAgenda::changeColumns(int columns) 366void KOAgenda::changeColumns(int columns)
366{ 367{
367 if (columns == 0) { 368 if (columns == 0) {
368 qDebug("KOAgenda::changeColumns() called with argument 0 "); 369 qDebug("KOAgenda::changeColumns() called with argument 0 ");
369 return; 370 return;
370 } 371 }
371 clear(); 372 clear();
372 mColumns = columns; 373 mColumns = columns;
373 computeSizes(); 374 computeSizes();
374} 375}
375 376
376/* 377/*
377 This is the eventFilter function, which gets all events from the KOAgendaItems 378 This is the eventFilter function, which gets all events from the KOAgendaItems
378 contained in the agenda. It has to handle moving and resizing for all items. 379 contained in the agenda. It has to handle moving and resizing for all items.
379*/ 380*/
380bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 381bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
381{ 382{
382 // kdDebug() << "KOAgenda::eventFilter" << endl; 383 // kdDebug() << "KOAgenda::eventFilter" << endl;
383 switch(event->type()) { 384 switch(event->type()) {
384 case QEvent::MouseButtonPress: 385 case QEvent::MouseButtonPress:
385 case QEvent::MouseButtonDblClick: 386 case QEvent::MouseButtonDblClick:
386 case QEvent::MouseButtonRelease: 387 case QEvent::MouseButtonRelease:
387 case QEvent::MouseMove: 388 case QEvent::MouseMove:
388 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 389 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
389 390
390 case (QEvent::Leave): 391 case (QEvent::Leave):
391 if (!mActionItem) 392 if (!mActionItem)
392 setCursor(arrowCursor); 393 setCursor(arrowCursor);
393 return true; 394 return true;
394 395
395 default: 396 default:
396 return QScrollView::eventFilter(object,event); 397 return QScrollView::eventFilter(object,event);
397 } 398 }
398} 399}
399void KOAgenda::popupMenu() 400void KOAgenda::popupMenu()
400{ 401{
401 mPopupTimer->stop(); 402 mPopupTimer->stop();
402 if ( mPopupKind == 1 || mPopupKind == 3 ) { 403 if ( mPopupKind == 1 || mPopupKind == 3 ) {
403 if (mActionItem ) { 404 if (mActionItem ) {
404 endItemAction(); 405 endItemAction();
405 } 406 }
406 mLeftMouseDown = false; // no more leftMouse computation 407 mLeftMouseDown = false; // no more leftMouse computation
407 if (mPopupItem) { 408 if (mPopupItem) {
408 //mClickedItem = mPopupItem; 409 //mClickedItem = mPopupItem;
409 selectItem(mPopupItem); 410 selectItem(mPopupItem);
410 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) 411 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 )
411 mAllAgendaPopup->installEventFilter( this ); 412 mAllAgendaPopup->installEventFilter( this );
412 emit showIncidencePopupSignal(mPopupItem->incidence()); 413 emit showIncidencePopupSignal(mPopupItem->incidence());
413 414
414 } 415 }
415 } else if ( mPopupKind == 2 || mPopupKind == 4 ) { 416 } else if ( mPopupKind == 2 || mPopupKind == 4 ) {
416 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 417 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
417 endSelectAction( false ); // do not emit new event signal 418 endSelectAction( false ); // do not emit new event signal
418 mLeftMouseDown = false; // no more leftMouse computation 419 mLeftMouseDown = false; // no more leftMouse computation
419 } 420 }
420 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) 421 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 )
421 mNewItemPopup->installEventFilter( this ); 422 mNewItemPopup->installEventFilter( this );
422 mNewItemPopup->popup( mPopupPos); 423 mNewItemPopup->popup( mPopupPos);
423 424
424 } 425 }
425 mLeftMouseDown = false; 426 mLeftMouseDown = false;
426 mPopupItem = 0; 427 mPopupItem = 0;
427 mPopupKind = 0; 428 mPopupKind = 0;
428} 429}
429void KOAgenda::categoryChanged(Incidence * inc) 430void KOAgenda::categoryChanged(Incidence * inc)
430{ 431{
431 KOAgendaItem *item; 432 KOAgendaItem *item;
432 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 433 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
433 if ( item->incidence() == inc ) { 434 if ( item->incidence() == inc ) {
434 item->initColor (); 435 item->initColor ();
435 item->updateItem(); 436 item->updateItem();
436 } 437 }
437 } 438 }
438} 439}
439bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 440bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
440{ 441{
442
443 if ( mInvalidPixmap ) {
444 mInvalidPixmap = false;
445 qDebug("InvalidPixmap ");
446 computeSizes();
447 emit updateViewSignal();
448 return true;
449 }
450 emit sendPing();
441 static int startX = 0; 451 static int startX = 0;
442 static int startY = 0; 452 static int startY = 0;
443 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); 453 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 );
444 static bool blockMoving = true; 454 static bool blockMoving = true;
445 455
446 //qDebug("KOAgenda::eventFilter_mous "); 456 //qDebug("KOAgenda::eventFilter_mous ");
447 if ( object == mNewItemPopup ) { 457 if ( object == mNewItemPopup ) {
448 //qDebug("mNewItemPopup "); 458 //qDebug("mNewItemPopup ");
449 if ( me->type() == QEvent::MouseButtonRelease ) { 459 if ( me->type() == QEvent::MouseButtonRelease ) {
450 mNewItemPopup->removeEventFilter( this ); 460 mNewItemPopup->removeEventFilter( this );
451 int dX = me->globalPos().x() - mPopupPos.x();; 461 int dX = me->globalPos().x() - mPopupPos.x();;
452 if ( dX < 0 ) 462 if ( dX < 0 )
453 dX = -dX; 463 dX = -dX;
454 int dY = me->globalPos().y() - mPopupPos.y(); 464 int dY = me->globalPos().y() - mPopupPos.y();
455 if ( dY < 0 ) 465 if ( dY < 0 )
456 dY = -dY; 466 dY = -dY;
457 if ( dX > blockmoveDist || dY > blockmoveDist ) { 467 if ( dX > blockmoveDist || dY > blockmoveDist ) {
458 mNewItemPopup->hide(); 468 mNewItemPopup->hide();
459 } 469 }
460 } 470 }
461 return true; 471 return true;
462 } 472 }
463 if ( object == mAllAgendaPopup ) { 473 if ( object == mAllAgendaPopup ) {
464 //qDebug(" mAllAgendaPopup "); 474 //qDebug(" mAllAgendaPopup ");
465 if ( me->type() == QEvent::MouseButtonRelease ) { 475 if ( me->type() == QEvent::MouseButtonRelease ) {
466 mAllAgendaPopup->removeEventFilter( this ); 476 mAllAgendaPopup->removeEventFilter( this );
467 int dX = me->globalPos().x() - mPopupPos.x();; 477 int dX = me->globalPos().x() - mPopupPos.x();;
468 if ( dX < 0 ) 478 if ( dX < 0 )
469 dX = -dX; 479 dX = -dX;
470 int dY = me->globalPos().y() - mPopupPos.y(); 480 int dY = me->globalPos().y() - mPopupPos.y();
471 if ( dY < 0 ) 481 if ( dY < 0 )
472 dY = -dY; 482 dY = -dY;
473 if ( dX > blockmoveDist || dY > blockmoveDist ) { 483 if ( dX > blockmoveDist || dY > blockmoveDist ) {
474 mAllAgendaPopup->hide(); 484 mAllAgendaPopup->hide();
475 } 485 }
476 } 486 }
477 return true; 487 return true;
478 } 488 }
479 QPoint viewportPos; 489 QPoint viewportPos;
480 if (object != viewport()) { 490 if (object != viewport()) {
481 blockmoveDist = blockmoveDist*2; 491 blockmoveDist = blockmoveDist*2;
482 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 492 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
483 } else { 493 } else {
484 viewportPos = me->pos(); 494 viewportPos = me->pos();
485 } 495 }
486 bool objIsNotViewport = (object != viewport()); 496 bool objIsNotViewport = (object != viewport());
487 bool leftButt = false; 497 bool leftButt = false;
488#ifdef DESKTOP_VERSION 498#ifdef DESKTOP_VERSION
489 leftButt = (me->button() == LeftButton); 499 leftButt = (me->button() == LeftButton);
490#endif 500#endif
491 switch (me->type()) { 501 switch (me->type()) {
492 case QEvent::MouseButtonPress: 502 case QEvent::MouseButtonPress:
493 if (me->button() == LeftButton) { 503 if (me->button() == LeftButton) {
494 mPopupTimer->start( 600 ); 504 mPopupTimer->start( 600 );
495 mLeftMouseDown = true; 505 mLeftMouseDown = true;
496 } 506 }
497 blockMoving = true; 507 blockMoving = true;
498 startX = viewportPos.x(); 508 startX = viewportPos.x();
499 startY = viewportPos.y(); 509 startY = viewportPos.y();
500 mPopupPos = me->globalPos(); 510 mPopupPos = me->globalPos();
501 if ( objIsNotViewport && !leftButt ) { 511 if ( objIsNotViewport && !leftButt ) {
502 KOAgendaItem * tempItem = (KOAgendaItem *)object; 512 KOAgendaItem * tempItem = (KOAgendaItem *)object;
503 if (mAllDayMode) { 513 if (mAllDayMode) {
504 if ( tempItem->height() > 10 ) { 514 if ( tempItem->height() > 10 ) {
505 int minV = tempItem->height()/4; 515 int minV = tempItem->height()/4;
506 if ( minV > (blockmoveDist/2)-2 ) { 516 if ( minV > (blockmoveDist/2)-2 ) {
507 if ( minV > blockmoveDist ) 517 if ( minV > blockmoveDist )
508 minV = blockmoveDist; 518 minV = blockmoveDist;
509 else 519 else
510 minV = (blockmoveDist/2); 520 minV = (blockmoveDist/2);
511 } 521 }
512 bool border = false; 522 bool border = false;
513 int diff = tempItem->y() - viewportPos.y(); 523 int diff = tempItem->y() - viewportPos.y();
514 if ( diff < 0 ) 524 if ( diff < 0 )
515 diff *= -1; 525 diff *= -1;
516 if ( diff < minV ) { 526 if ( diff < minV ) {
517 border = true; 527 border = true;
518 objIsNotViewport = false; 528 objIsNotViewport = false;
519 } 529 }
520 if ( ! border ) { 530 if ( ! border ) {
521 diff = tempItem->y() + tempItem->height()- viewportPos.y(); 531 diff = tempItem->y() + tempItem->height()- viewportPos.y();
522 if ( diff < 0 ) 532 if ( diff < 0 )
523 diff *= -1; 533 diff *= -1;
524 if ( diff < minV ) { 534 if ( diff < minV ) {
525 border = true; 535 border = true;
526 objIsNotViewport = false; 536 objIsNotViewport = false;
527 } 537 }
528 } 538 }
529 } 539 }
530 } else { // not allday 540 } else { // not allday
531 if ( tempItem->width() > 10 ) { 541 if ( tempItem->width() > 10 ) {
532 int minH = tempItem->width()/4; 542 int minH = tempItem->width()/4;
533 if ( minH > (blockmoveDist/2)-2 ) { 543 if ( minH > (blockmoveDist/2)-2 ) {
534 if ( minH > blockmoveDist ) 544 if ( minH > blockmoveDist )
535 minH = blockmoveDist; 545 minH = blockmoveDist;
536 else 546 else
537 minH = (blockmoveDist/2); 547 minH = (blockmoveDist/2);
538 } 548 }
539 bool border = false; 549 bool border = false;
540 int diff = tempItem->x() - viewportPos.x(); 550 int diff = tempItem->x() - viewportPos.x();
541 if ( diff < 0 ) 551 if ( diff < 0 )
542 diff *= -1; 552 diff *= -1;
543 if ( diff < minH ) { 553 if ( diff < minH ) {
544 border = true; 554 border = true;
545 objIsNotViewport = false; 555 objIsNotViewport = false;
546 } 556 }
547 if ( ! border ) { 557 if ( ! border ) {
548 diff = tempItem->x() + tempItem->width() - viewportPos.x(); 558 diff = tempItem->x() + tempItem->width() - viewportPos.x();
549 if ( diff < 0 ) 559 if ( diff < 0 )
550 diff *= -1; 560 diff *= -1;
551 if ( diff < minH ) { 561 if ( diff < minH ) {
552 border = true; 562 border = true;
553 objIsNotViewport = false; 563 objIsNotViewport = false;
554 } 564 }
555 } 565 }
556 } 566 }
557 } 567 }
558 } 568 }
559 if ( objIsNotViewport ) { 569 if ( objIsNotViewport ) {
560 mPopupItem = (KOAgendaItem *)object; 570 mPopupItem = (KOAgendaItem *)object;
561 mPopupKind = 1; 571 mPopupKind = 1;
562 if (me->button() == RightButton) { 572 if (me->button() == RightButton) {
563 mPopupKind = 3; 573 mPopupKind = 3;
564 popupMenu(); 574 popupMenu();
565 } else if (me->button() == LeftButton) { 575 } else if (me->button() == LeftButton) {
566 mActionItem = (KOAgendaItem *)object; 576 mActionItem = (KOAgendaItem *)object;
567 if (mActionItem) { 577 if (mActionItem) {
568 emit signalClearSelection(); 578 emit signalClearSelection();
569 slotClearSelection(); 579 slotClearSelection();
570 selectItem(mActionItem); 580 selectItem(mActionItem);
571 Incidence *incidence = mActionItem->incidence(); 581 Incidence *incidence = mActionItem->incidence();
572 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 582 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
573 mActionItem = 0; 583 mActionItem = 0;
574 } else { 584 } else {
575 startItemAction(viewportPos); 585 startItemAction(viewportPos);
576 } 586 }
577 } 587 }
578 } 588 }
579 } else { // ---------- viewport() 589 } else { // ---------- viewport()
580 mPopupItem = 0; 590 mPopupItem = 0;
581 mPopupKind = 2; 591 mPopupKind = 2;
582 selectItem(0); 592 selectItem(0);
583 mActionItem = 0; 593 mActionItem = 0;
584 if (me->button() == RightButton) { 594 if (me->button() == RightButton) {
585 int x,y; 595 int x,y;
586 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 596 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
587 int gx,gy; 597 int gx,gy;
588 contentsToGrid(x,y,gx,gy); 598 contentsToGrid(x,y,gx,gy);
589 mCurrentCellX = gx; 599 mCurrentCellX = gx;
590 mCurrentCellY = gy; 600 mCurrentCellY = gy;
591 mStartCellX = gx; 601 mStartCellX = gx;
592 mStartCellY = gy; 602 mStartCellY = gy;
593 mPopupKind = 4; 603 mPopupKind = 4;
594 popupMenu(); 604 popupMenu();
595 } else if (me->button() == LeftButton) { 605 } else if (me->button() == LeftButton) {
596 setCursor(arrowCursor); 606 setCursor(arrowCursor);
597 startSelectAction(viewportPos); 607 startSelectAction(viewportPos);
598 } 608 }
599 } 609 }
600 break; 610 break;
601 611
602 case QEvent::MouseButtonRelease: 612 case QEvent::MouseButtonRelease:
603 if (me->button() == LeftButton ) { 613 if (me->button() == LeftButton ) {
604 mPopupTimer->stop(); 614 mPopupTimer->stop();
605 } 615 }
606 if (object != viewport()) { 616 if (object != viewport()) {
607 if (me->button() == LeftButton && mLeftMouseDown) { 617 if (me->button() == LeftButton && mLeftMouseDown) {
608 if (mActionItem) { 618 if (mActionItem) {
609 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 619 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
610 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 620 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
611 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 621 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
612 mScrollUpTimer.stop(); 622 mScrollUpTimer.stop();
613 mScrollDownTimer.stop(); 623 mScrollDownTimer.stop();
614 mActionItem->resetMove(); 624 mActionItem->resetMove();
615 placeSubCells( mActionItem ); 625 placeSubCells( mActionItem );
616 // emit startDragSignal( mActionItem->incidence() ); 626 // emit startDragSignal( mActionItem->incidence() );
617 setCursor( arrowCursor ); 627 setCursor( arrowCursor );
618 mActionItem = 0; 628 mActionItem = 0;
619 mActionType = NOP; 629 mActionType = NOP;
620 mItemMoved = 0; 630 mItemMoved = 0;
621 mLeftMouseDown = false; 631 mLeftMouseDown = false;
622 return true; 632 return true;
623 } 633 }
624 endItemAction(); 634 endItemAction();
625 } 635 }
626 } 636 }
627 637
628 } else { // ---------- viewport() 638 } else { // ---------- viewport()
629 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 639 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
630 endSelectAction( true ); // emit new event signal 640 endSelectAction( true ); // emit new event signal
631 } 641 }
632 } 642 }
633 if (me->button() == LeftButton) 643 if (me->button() == LeftButton)
634 mLeftMouseDown = false; 644 mLeftMouseDown = false;
635 645
636 break; 646 break;
637 647
638 case QEvent::MouseMove: 648 case QEvent::MouseMove:
639 //qDebug("mm "); 649 //qDebug("mm ");
640 if ( !mLeftMouseDown ) 650 if ( !mLeftMouseDown )
641 return false; 651 return false;
642 if ( blockMoving ) { 652 if ( blockMoving ) {
643 int dX, dY; 653 int dX, dY;
644 dX = startX - viewportPos.x(); 654 dX = startX - viewportPos.x();
645 if ( dX < 0 ) 655 if ( dX < 0 )
646 dX = -dX; 656 dX = -dX;
647 dY = viewportPos.y() - startY; 657 dY = viewportPos.y() - startY;
648 if ( dY < 0 ) 658 if ( dY < 0 )
649 dY = -dY; 659 dY = -dY;
650 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 660 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
651 if ( dX > blockmoveDist || dY > blockmoveDist ) { 661 if ( dX > blockmoveDist || dY > blockmoveDist ) {
652 blockMoving = false; 662 blockMoving = false;
653 } 663 }
654 } 664 }
655 if ( ! blockMoving ) 665 if ( ! blockMoving )
656 mPopupTimer->stop(); 666 mPopupTimer->stop();
657 if (object != viewport()) { 667 if (object != viewport()) {
658 KOAgendaItem *moveItem = (KOAgendaItem *)object; 668 KOAgendaItem *moveItem = (KOAgendaItem *)object;
659 if (!moveItem->incidence()->isReadOnly() ) { 669 if (!moveItem->incidence()->isReadOnly() ) {
660 if (!mActionItem) 670 if (!mActionItem)
661 setNoActionCursor(moveItem,viewportPos); 671 setNoActionCursor(moveItem,viewportPos);
662 else { 672 else {
663 if ( !blockMoving ) 673 if ( !blockMoving )
664 performItemAction(viewportPos); 674 performItemAction(viewportPos);
665 } 675 }
666 } 676 }
667 } else { // ---------- viewport() 677 } else { // ---------- viewport()
668 mPopupPos = viewport()->mapToGlobal( me->pos() ); 678 mPopupPos = viewport()->mapToGlobal( me->pos() );
669 if ( mActionType == SELECT ) { 679 if ( mActionType == SELECT ) {
670 performSelectAction( viewportPos ); 680 performSelectAction( viewportPos );
671 } 681 }
672 } 682 }
673 break; 683 break;
674 684
675 case QEvent::MouseButtonDblClick: 685 case QEvent::MouseButtonDblClick:
676 mPopupTimer->stop(); 686 mPopupTimer->stop();
677 if (object == viewport()) { 687 if (object == viewport()) {
678 selectItem(0); 688 selectItem(0);
679 int x,y; 689 int x,y;
680 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 690 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
681 int gx,gy; 691 int gx,gy;
682 contentsToGrid(x,y,gx,gy); 692 contentsToGrid(x,y,gx,gy);
683 emit newEventSignal(gx,gy); 693 emit newEventSignal(gx,gy);
684 } else { 694 } else {
685 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 695 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
686 selectItem(doubleClickedItem); 696 selectItem(doubleClickedItem);
687 if ( KOPrefs::instance()->mEditOnDoubleClick ) 697 if ( KOPrefs::instance()->mEditOnDoubleClick )
688 emit editIncidenceSignal(doubleClickedItem->incidence()); 698 emit editIncidenceSignal(doubleClickedItem->incidence());
689 else 699 else
690 emit showIncidenceSignal(doubleClickedItem->incidence()); 700 emit showIncidenceSignal(doubleClickedItem->incidence());
691 } 701 }
692 break; 702 break;
693 703
694 default: 704 default:
695 break; 705 break;
696 } 706 }
697 return true; 707 return true;
698 708
699} 709}
700 710
701void KOAgenda::newItem( int item ) 711void KOAgenda::newItem( int item )
702{ 712{
703 if ( item == 1 ) { //new event 713 if ( item == 1 ) { //new event
704 newEventSignal(mStartCellX ,mStartCellY ); 714 newEventSignal(mStartCellX ,mStartCellY );
705 } else 715 } else
706 if ( item == 2 ) { //new event 716 if ( item == 2 ) { //new event
707 newTodoSignal(mStartCellX ,mStartCellY ); 717 newTodoSignal(mStartCellX ,mStartCellY );
708 } else 718 } else
709 { 719 {
710 emit showDateView( item, mStartCellX ); 720 emit showDateView( item, mStartCellX );
711 // 3Day view 721 // 3Day view
712 // 4Week view 722 // 4Week view
713 // 5Month view 723 // 5Month view
714 // 6Journal view 724 // 6Journal view
715 } 725 }
716} 726}
717void KOAgenda::slotClearSelection() 727void KOAgenda::slotClearSelection()
718{ 728{
719 if (mSelectionHeight) { 729 if (mSelectionHeight) {
720 int selectionX = mSelectionCellX * mGridSpacingX; 730 int selectionX = mSelectionCellX * mGridSpacingX;
721 int top = mSelectionYTop - 2 *mGridSpacingY; 731 int top = mSelectionYTop - 2 *mGridSpacingY;
722 int hei = mSelectionHeight + 4 *mGridSpacingY; 732 int hei = mSelectionHeight + 4 *mGridSpacingY;
723 clearSelection(); 733 clearSelection();
724 repaintContents( selectionX, top, 734 repaintContents( selectionX, top,
725 mGridSpacingX, hei ,false ); 735 mGridSpacingX, hei ,false );
726 } 736 }
727 737
728} 738}
729void KOAgenda::startSelectAction(QPoint viewportPos) 739void KOAgenda::startSelectAction(QPoint viewportPos)
730{ 740{
731 741
732 emit signalClearSelection(); 742 emit signalClearSelection();
733 slotClearSelection(); 743 slotClearSelection();
734 744
735 mActionType = SELECT; 745 mActionType = SELECT;
736 746
737 int x,y; 747 int x,y;
738 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 748 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
739 int gx,gy; 749 int gx,gy;
740 contentsToGrid(x,y,gx,gy); 750 contentsToGrid(x,y,gx,gy);
741 751
742 mStartCellX = gx; 752 mStartCellX = gx;
743 mStartCellY = gy; 753 mStartCellY = gy;
744 mCurrentCellX = gx; 754 mCurrentCellX = gx;
745 mCurrentCellY = gy; 755 mCurrentCellY = gy;
746 756
747 // Store new selection 757 // Store new selection
748 mSelectionCellX = gx; 758 mSelectionCellX = gx;
749 mSelectionYTop = gy * mGridSpacingY; 759 mSelectionYTop = gy * mGridSpacingY;
750 mSelectionHeight = mGridSpacingY; 760 mSelectionHeight = mGridSpacingY;
751 761
752 // Paint new selection 762 // Paint new selection
753 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, 763 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop,
754 mGridSpacingX-1, mSelectionHeight ); 764 mGridSpacingX-1, mSelectionHeight );
755} 765}
756 766
757void KOAgenda::performSelectAction(QPoint viewportPos) 767void KOAgenda::performSelectAction(QPoint viewportPos)
758{ 768{
759 int x,y; 769 int x,y;
760 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 770 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
761 int gx,gy; 771 int gx,gy;
762 contentsToGrid(x,y,gx,gy); 772 contentsToGrid(x,y,gx,gy);
763 773
764 QPoint clipperPos = clipper()-> 774 QPoint clipperPos = clipper()->
765 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 775 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
766 776
767 // Scroll if cursor was moved to upper or lower end of agenda. 777 // Scroll if cursor was moved to upper or lower end of agenda.
768 if (clipperPos.y() < mScrollBorderWidth) { 778 if (clipperPos.y() < mScrollBorderWidth) {
769 mScrollUpTimer.start(mScrollDelay); 779 mScrollUpTimer.start(mScrollDelay);
770 } else if (visibleHeight() - clipperPos.y() < 780 } else if (visibleHeight() - clipperPos.y() <
771 mScrollBorderWidth) { 781 mScrollBorderWidth) {
772 mScrollDownTimer.start(mScrollDelay); 782 mScrollDownTimer.start(mScrollDelay);
773 } else { 783 } else {
774 mScrollUpTimer.stop(); 784 mScrollUpTimer.stop();
775 mScrollDownTimer.stop(); 785 mScrollDownTimer.stop();
776 } 786 }
777 787
778 if ( gy > mCurrentCellY ) { 788 if ( gy > mCurrentCellY ) {
779 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 789 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
780 790
781 791
782 repaintContents( (KOGlobals::self()->reverseLayout() ? 792 repaintContents( (KOGlobals::self()->reverseLayout() ?
783 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 793 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
784 mGridSpacingX, mSelectionYTop, 794 mGridSpacingX, mSelectionYTop,
785 mGridSpacingX, mSelectionHeight , false); 795 mGridSpacingX, mSelectionHeight , false);
786 796
787 mCurrentCellY = gy; 797 mCurrentCellY = gy;
788 } else if ( gy < mCurrentCellY ) { 798 } else if ( gy < mCurrentCellY ) {
789 if ( gy >= mStartCellY ) { 799 if ( gy >= mStartCellY ) {
790 int selectionHeight = mSelectionHeight; 800 int selectionHeight = mSelectionHeight;
791 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 801 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
792 802
793 repaintContents( (KOGlobals::self()->reverseLayout() ? 803 repaintContents( (KOGlobals::self()->reverseLayout() ?
794 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 804 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
795 mGridSpacingX, mSelectionYTop, 805 mGridSpacingX, mSelectionYTop,
796 mGridSpacingX, selectionHeight,false ); 806 mGridSpacingX, selectionHeight,false );
797 807
798 mCurrentCellY = gy; 808 mCurrentCellY = gy;
799 } else { 809 } else {
800 } 810 }
801 } 811 }
802} 812}
803 813
804void KOAgenda::endSelectAction( bool emitNewEvent ) 814void KOAgenda::endSelectAction( bool emitNewEvent )
805{ 815{
806 mActionType = NOP; 816 mActionType = NOP;
807 mScrollUpTimer.stop(); 817 mScrollUpTimer.stop();
808 mScrollDownTimer.stop(); 818 mScrollDownTimer.stop();
809 819
810 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 820 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
811 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 821 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
812 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 822 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
813 } 823 }
814} 824}
815 825
816void KOAgenda::startItemAction(QPoint viewportPos) 826void KOAgenda::startItemAction(QPoint viewportPos)
817{ 827{
818 int x,y; 828 int x,y;
819 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 829 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
820 int gx,gy; 830 int gx,gy;
821 contentsToGrid(x,y,gx,gy); 831 contentsToGrid(x,y,gx,gy);
822 832
823 mStartCellX = gx; 833 mStartCellX = gx;
824 mStartCellY = gy; 834 mStartCellY = gy;
@@ -886,825 +896,832 @@ void KOAgenda::performItemAction(QPoint viewportPos)
886 mScrollDownTimer.stop(); 896 mScrollDownTimer.stop();
887 mActionItem->resetMove(); 897 mActionItem->resetMove();
888 placeSubCells( mActionItem ); 898 placeSubCells( mActionItem );
889 // emit startDragSignal( mActionItem->incidence() ); 899 // emit startDragSignal( mActionItem->incidence() );
890 setCursor( arrowCursor ); 900 setCursor( arrowCursor );
891 mActionItem = 0; 901 mActionItem = 0;
892 mActionType = NOP; 902 mActionType = NOP;
893 mItemMoved = 0; 903 mItemMoved = 0;
894 return; 904 return;
895 } 905 }
896 } else { 906 } else {
897 switch ( mActionType ) { 907 switch ( mActionType ) {
898 case MOVE: 908 case MOVE:
899 setCursor( sizeAllCursor ); 909 setCursor( sizeAllCursor );
900 break; 910 break;
901 case RESIZETOP: 911 case RESIZETOP:
902 case RESIZEBOTTOM: 912 case RESIZEBOTTOM:
903 setCursor( sizeVerCursor ); 913 setCursor( sizeVerCursor );
904 break; 914 break;
905 case RESIZELEFT: 915 case RESIZELEFT:
906 case RESIZERIGHT: 916 case RESIZERIGHT:
907 setCursor( sizeHorCursor ); 917 setCursor( sizeHorCursor );
908 break; 918 break;
909 default: 919 default:
910 setCursor( arrowCursor ); 920 setCursor( arrowCursor );
911 } 921 }
912 } 922 }
913 923
914 // Scroll if item was moved to upper or lower end of agenda. 924 // Scroll if item was moved to upper or lower end of agenda.
915 if (clipperPos.y() < mScrollBorderWidth) { 925 if (clipperPos.y() < mScrollBorderWidth) {
916 mScrollUpTimer.start(mScrollDelay); 926 mScrollUpTimer.start(mScrollDelay);
917 } else if (visibleHeight() - clipperPos.y() < 927 } else if (visibleHeight() - clipperPos.y() <
918 mScrollBorderWidth) { 928 mScrollBorderWidth) {
919 mScrollDownTimer.start(mScrollDelay); 929 mScrollDownTimer.start(mScrollDelay);
920 } else { 930 } else {
921 mScrollUpTimer.stop(); 931 mScrollUpTimer.stop();
922 mScrollDownTimer.stop(); 932 mScrollDownTimer.stop();
923 } 933 }
924 934
925 // Move or resize item if necessary 935 // Move or resize item if necessary
926 if (mCurrentCellX != gx || mCurrentCellY != gy) { 936 if (mCurrentCellX != gx || mCurrentCellY != gy) {
927 mItemMoved = true; 937 mItemMoved = true;
928 mActionItem->raise(); 938 mActionItem->raise();
929 if (mActionType == MOVE) { 939 if (mActionType == MOVE) {
930 // Move all items belonging to a multi item 940 // Move all items belonging to a multi item
931 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 941 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
932 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 942 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
933 if (!moveItem) moveItem = mActionItem; 943 if (!moveItem) moveItem = mActionItem;
934 while (moveItem) { 944 while (moveItem) {
935 int dy; 945 int dy;
936 if (isMultiItem) dy = 0; 946 if (isMultiItem) dy = 0;
937 else dy = gy - mCurrentCellY; 947 else dy = gy - mCurrentCellY;
938 moveItem->moveRelative(gx - mCurrentCellX,dy); 948 moveItem->moveRelative(gx - mCurrentCellX,dy);
939 int x,y; 949 int x,y;
940 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 950 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
941 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 951 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
942 mGridSpacingY * moveItem->cellHeight()); 952 mGridSpacingY * moveItem->cellHeight());
943 moveItem->raise(); 953 moveItem->raise();
944 moveChild(moveItem,x,y); 954 moveChild(moveItem,x,y);
945 moveItem = moveItem->nextMultiItem(); 955 moveItem = moveItem->nextMultiItem();
946 } 956 }
947 } else if (mActionType == RESIZETOP) { 957 } else if (mActionType == RESIZETOP) {
948 if (mCurrentCellY <= mActionItem->cellYBottom()) { 958 if (mCurrentCellY <= mActionItem->cellYBottom()) {
949 mActionItem->expandTop(gy - mCurrentCellY); 959 mActionItem->expandTop(gy - mCurrentCellY);
950 mActionItem->resize(mActionItem->width(), 960 mActionItem->resize(mActionItem->width(),
951 mGridSpacingY * mActionItem->cellHeight()); 961 mGridSpacingY * mActionItem->cellHeight());
952 int x,y; 962 int x,y;
953 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 963 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
954 //moveChild(mActionItem,childX(mActionItem),y); 964 //moveChild(mActionItem,childX(mActionItem),y);
955 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 965 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
956 } 966 }
957 } else if (mActionType == RESIZEBOTTOM) { 967 } else if (mActionType == RESIZEBOTTOM) {
958 if (mCurrentCellY >= mActionItem->cellYTop()) { 968 if (mCurrentCellY >= mActionItem->cellYTop()) {
959 mActionItem->expandBottom(gy - mCurrentCellY); 969 mActionItem->expandBottom(gy - mCurrentCellY);
960 mActionItem->resize(mActionItem->width(), 970 mActionItem->resize(mActionItem->width(),
961 mGridSpacingY * mActionItem->cellHeight()); 971 mGridSpacingY * mActionItem->cellHeight());
962 } 972 }
963 } else if (mActionType == RESIZELEFT) { 973 } else if (mActionType == RESIZELEFT) {
964 if (mCurrentCellX <= mActionItem->cellXWidth()) { 974 if (mCurrentCellX <= mActionItem->cellXWidth()) {
965 mActionItem->expandLeft(gx - mCurrentCellX); 975 mActionItem->expandLeft(gx - mCurrentCellX);
966 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 976 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
967 mActionItem->height()); 977 mActionItem->height());
968 int x,y; 978 int x,y;
969 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 979 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
970 moveChild(mActionItem,x,childY(mActionItem)); 980 moveChild(mActionItem,x,childY(mActionItem));
971 } 981 }
972 } else if (mActionType == RESIZERIGHT) { 982 } else if (mActionType == RESIZERIGHT) {
973 if (mCurrentCellX >= mActionItem->cellX()) { 983 if (mCurrentCellX >= mActionItem->cellX()) {
974 mActionItem->expandRight(gx - mCurrentCellX); 984 mActionItem->expandRight(gx - mCurrentCellX);
975 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 985 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
976 mActionItem->height()); 986 mActionItem->height());
977 } 987 }
978 } 988 }
979 mCurrentCellX = gx; 989 mCurrentCellX = gx;
980 mCurrentCellY = gy; 990 mCurrentCellY = gy;
981 } 991 }
982} 992}
983 993
984void KOAgenda::endItemAction() 994void KOAgenda::endItemAction()
985{ 995{
986 996
987 if ( mItemMoved ) { 997 if ( mItemMoved ) {
988 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 998 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
989 if ( !placeItem ) { 999 if ( !placeItem ) {
990 placeItem = mActionItem; 1000 placeItem = mActionItem;
991 } 1001 }
992 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 1002 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
993 Incidence* oldInc = placeItem->incidence(); 1003 Incidence* oldInc = placeItem->incidence();
994 placeItem->recreateIncidence(); 1004 placeItem->recreateIncidence();
995 emit addToCalSignal(placeItem->incidence(), oldInc ); 1005 emit addToCalSignal(placeItem->incidence(), oldInc );
996 } 1006 }
997 int type = mActionType; 1007 int type = mActionType;
998 if ( mAllDayMode ) 1008 if ( mAllDayMode )
999 type = -1; 1009 type = -1;
1000 KOAgendaItem *modifiedItem = placeItem; 1010 KOAgendaItem *modifiedItem = placeItem;
1001 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 1011 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
1002 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 1012 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
1003 KOAgendaItem *item; 1013 KOAgendaItem *item;
1004 1014
1005 if ( placeItem->incidence()->typeID() == todoID ) { 1015 if ( placeItem->incidence()->typeID() == todoID ) {
1006 mSelectedItem = 0; 1016 mSelectedItem = 0;
1007 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 1017 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
1008 modifiedItem->mLastMoveXPos = mCurrentCellX; 1018 modifiedItem->mLastMoveXPos = mCurrentCellX;
1009 emit itemModified( modifiedItem, mActionType ); 1019 emit itemModified( modifiedItem, mActionType );
1010 } 1020 }
1011 else { 1021 else {
1012 1022
1013 1023
1014 globalFlagBlockAgendaItemPaint = 1; 1024 globalFlagBlockAgendaItemPaint = 1;
1015 for ( item=oldconflictItems.first(); item != 0; 1025 for ( item=oldconflictItems.first(); item != 0;
1016 item=oldconflictItems.next() ) { 1026 item=oldconflictItems.next() ) {
1017 placeSubCells(item); 1027 placeSubCells(item);
1018 } 1028 }
1019 while ( placeItem ) { 1029 while ( placeItem ) {
1020 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1030 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1021 oldconflictItems = placeItem->conflictItems(); 1031 oldconflictItems = placeItem->conflictItems();
1022 for ( item=oldconflictItems.first(); item != 0; 1032 for ( item=oldconflictItems.first(); item != 0;
1023 item=oldconflictItems.next() ) { 1033 item=oldconflictItems.next() ) {
1024 placeSubCells(item); 1034 placeSubCells(item);
1025 } 1035 }
1026 placeSubCells( placeItem ); 1036 placeSubCells( placeItem );
1027 placeItem = placeItem->nextMultiItem(); 1037 placeItem = placeItem->nextMultiItem();
1028 } 1038 }
1029 globalFlagBlockAgendaItemPaint = 0; 1039 globalFlagBlockAgendaItemPaint = 0;
1030 for ( item=oldconflictItems.first(); item != 0; 1040 for ( item=oldconflictItems.first(); item != 0;
1031 item=oldconflictItems.next() ) { 1041 item=oldconflictItems.next() ) {
1032 globalFlagBlockAgendaItemUpdate = 0; 1042 globalFlagBlockAgendaItemUpdate = 0;
1033 item->repaintMe(); 1043 item->repaintMe();
1034 globalFlagBlockAgendaItemUpdate = 1; 1044 globalFlagBlockAgendaItemUpdate = 1;
1035 item->repaint( false ); 1045 item->repaint( false );
1036 } 1046 }
1037 placeItem = modifiedItem; 1047 placeItem = modifiedItem;
1038 1048
1039 while ( placeItem ) { 1049 while ( placeItem ) {
1040 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1050 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1041 globalFlagBlockAgendaItemUpdate = 0; 1051 globalFlagBlockAgendaItemUpdate = 0;
1042 placeItem->repaintMe(); 1052 placeItem->repaintMe();
1043 globalFlagBlockAgendaItemUpdate = 1; 1053 globalFlagBlockAgendaItemUpdate = 1;
1044 placeItem->repaint(false); 1054 placeItem->repaint(false);
1045 placeItem = placeItem->nextMultiItem(); 1055 placeItem = placeItem->nextMultiItem();
1046 } 1056 }
1047 emit itemModified( modifiedItem, mActionType ); 1057 emit itemModified( modifiedItem, mActionType );
1048 1058
1049 1059
1050 placeItem = modifiedItem; 1060 placeItem = modifiedItem;
1051 while ( placeItem ) { 1061 while ( placeItem ) {
1052 oldconflictItems = placeItem->conflictItems(); 1062 oldconflictItems = placeItem->conflictItems();
1053 for ( item=oldconflictItems.first(); item != 0; 1063 for ( item=oldconflictItems.first(); item != 0;
1054 item=oldconflictItems.next() ) { 1064 item=oldconflictItems.next() ) {
1055 placeSubCells(item); 1065 placeSubCells(item);
1056 } 1066 }
1057 placeSubCells( placeItem ); 1067 placeSubCells( placeItem );
1058 placeItem = placeItem->nextMultiItem(); 1068 placeItem = placeItem->nextMultiItem();
1059 1069
1060 } 1070 }
1061 placeItem = modifiedItem; 1071 placeItem = modifiedItem;
1062 while ( placeItem ) { 1072 while ( placeItem ) {
1063 oldconflictItems = placeItem->conflictItems(); 1073 oldconflictItems = placeItem->conflictItems();
1064 for ( item=oldconflictItems.first(); item != 0; 1074 for ( item=oldconflictItems.first(); item != 0;
1065 item=oldconflictItems.next() ) { 1075 item=oldconflictItems.next() ) {
1066 globalFlagBlockAgendaItemUpdate = 0; 1076 globalFlagBlockAgendaItemUpdate = 0;
1067 item->repaintMe(); 1077 item->repaintMe();
1068 globalFlagBlockAgendaItemUpdate = 1; 1078 globalFlagBlockAgendaItemUpdate = 1;
1069 item->repaint(false); 1079 item->repaint(false);
1070 } 1080 }
1071 placeItem = placeItem->nextMultiItem(); 1081 placeItem = placeItem->nextMultiItem();
1072 } 1082 }
1073 /* 1083 /*
1074 1084
1075 oldconflictItems = modifiedItem->conflictItems(); 1085 oldconflictItems = modifiedItem->conflictItems();
1076 for ( item=oldconflictItems.first(); item != 0; 1086 for ( item=oldconflictItems.first(); item != 0;
1077 item=oldconflictItems.next() ) { 1087 item=oldconflictItems.next() ) {
1078 globalFlagBlockAgendaItemUpdate = 0; 1088 globalFlagBlockAgendaItemUpdate = 0;
1079 item->paintMe(false); 1089 item->paintMe(false);
1080 globalFlagBlockAgendaItemUpdate = 1; 1090 globalFlagBlockAgendaItemUpdate = 1;
1081 item->repaint(false); 1091 item->repaint(false);
1082 } 1092 }
1083 */ 1093 */
1084 1094
1085 1095
1086 } 1096 }
1087 1097
1088 } 1098 }
1089 1099
1090 mScrollUpTimer.stop(); 1100 mScrollUpTimer.stop();
1091 mScrollDownTimer.stop(); 1101 mScrollDownTimer.stop();
1092 setCursor( arrowCursor ); 1102 setCursor( arrowCursor );
1093 mActionItem = 0; 1103 mActionItem = 0;
1094 mActionType = NOP; 1104 mActionType = NOP;
1095 mItemMoved = 0; 1105 mItemMoved = 0;
1096 1106
1097} 1107}
1098 1108
1099void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 1109void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1100{ 1110{
1101// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 1111// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
1102// QPoint point = viewport()->mapToGlobal(viewportPos); 1112// QPoint point = viewport()->mapToGlobal(viewportPos);
1103// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 1113// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
1104// point = clipper()->mapFromGlobal(point); 1114// point = clipper()->mapFromGlobal(point);
1105// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 1115// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
1106 1116
1107 int x,y; 1117 int x,y;
1108 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 1118 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
1109// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 1119// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
1110 int gx,gy; 1120 int gx,gy;
1111 contentsToGrid(x,y,gx,gy); 1121 contentsToGrid(x,y,gx,gy);
1112 1122
1113 // Change cursor to resize cursor if appropriate 1123 // Change cursor to resize cursor if appropriate
1114 if (mAllDayMode) { 1124 if (mAllDayMode) {
1115 int gridDistanceX = (x - gx * mGridSpacingX); 1125 int gridDistanceX = (x - gx * mGridSpacingX);
1116 if (gridDistanceX < mResizeBorderWidth && 1126 if (gridDistanceX < mResizeBorderWidth &&
1117 moveItem->cellX() == gx) { 1127 moveItem->cellX() == gx) {
1118 setCursor(sizeHorCursor); 1128 setCursor(sizeHorCursor);
1119 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 1129 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
1120 moveItem->cellXWidth() == gx) { 1130 moveItem->cellXWidth() == gx) {
1121 setCursor(sizeHorCursor); 1131 setCursor(sizeHorCursor);
1122 } else { 1132 } else {
1123 setCursor(arrowCursor); 1133 setCursor(arrowCursor);
1124 } 1134 }
1125 } else { 1135 } else {
1126 int gridDistanceY = (y - gy * mGridSpacingY); 1136 int gridDistanceY = (y - gy * mGridSpacingY);
1127 if (gridDistanceY < mResizeBorderWidth && 1137 if (gridDistanceY < mResizeBorderWidth &&
1128 moveItem->cellYTop() == gy && 1138 moveItem->cellYTop() == gy &&
1129 !moveItem->firstMultiItem()) { 1139 !moveItem->firstMultiItem()) {
1130 setCursor(sizeVerCursor); 1140 setCursor(sizeVerCursor);
1131 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 1141 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
1132 moveItem->cellYBottom() == gy && 1142 moveItem->cellYBottom() == gy &&
1133 !moveItem->lastMultiItem()) { 1143 !moveItem->lastMultiItem()) {
1134 setCursor(sizeVerCursor); 1144 setCursor(sizeVerCursor);
1135 } else { 1145 } else {
1136 setCursor(arrowCursor); 1146 setCursor(arrowCursor);
1137 } 1147 }
1138 } 1148 }
1139} 1149}
1140 1150
1141 1151
1142/* 1152/*
1143 Place item in cell and take care that multiple items using the same cell do 1153 Place item in cell and take care that multiple items using the same cell do
1144 not overlap. This method is not yet optimal. It doesn´t use the maximum space 1154 not overlap. This method is not yet optimal. It doesn´t use the maximum space
1145 it can get in all cases. 1155 it can get in all cases.
1146 At the moment the method has a bug: When an item is placed only the sub cell 1156 At the moment the method has a bug: When an item is placed only the sub cell
1147 widths of the items are changed, which are within the Y region the item to 1157 widths of the items are changed, which are within the Y region the item to
1148 place spans. When the sub cell width change of one of this items affects a 1158 place spans. When the sub cell width change of one of this items affects a
1149 cell, where other items are, which do not overlap in Y with the item to place, 1159 cell, where other items are, which do not overlap in Y with the item to place,
1150 the display gets corrupted, although the corruption looks quite nice. 1160 the display gets corrupted, although the corruption looks quite nice.
1151*/ 1161*/
1152void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1162void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1153{ 1163{
1154 1164
1155 QPtrList<KOAgendaItem> conflictItems; 1165 QPtrList<KOAgendaItem> conflictItems;
1156 int maxSubCells = 0; 1166 int maxSubCells = 0;
1157 QIntDict<KOAgendaItem> subCellDict(7); 1167 QIntDict<KOAgendaItem> subCellDict(7);
1158 1168
1159 KOAgendaItem *item; 1169 KOAgendaItem *item;
1160 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1170 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1161 if (item != placeItem) { 1171 if (item != placeItem) {
1162 if (placeItem->cellX() <= item->cellXWidth() && 1172 if (placeItem->cellX() <= item->cellXWidth() &&
1163 placeItem->cellXWidth() >= item->cellX()) { 1173 placeItem->cellXWidth() >= item->cellX()) {
1164 if ((placeItem->cellYTop() <= item->cellYBottom()) && 1174 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
1165 (placeItem->cellYBottom() >= item->cellYTop())) { 1175 (placeItem->cellYBottom() >= item->cellYTop())) {
1166 conflictItems.append(item); 1176 conflictItems.append(item);
1167 if (item->subCells() > maxSubCells) 1177 if (item->subCells() > maxSubCells)
1168 maxSubCells = item->subCells(); 1178 maxSubCells = item->subCells();
1169 subCellDict.insert(item->subCell(),item); 1179 subCellDict.insert(item->subCell(),item);
1170 } 1180 }
1171 } 1181 }
1172 } 1182 }
1173 } 1183 }
1174 1184
1175 if (conflictItems.count() > 0) { 1185 if (conflictItems.count() > 0) {
1176 // Look for unused sub cell and insert item 1186 // Look for unused sub cell and insert item
1177 int i; 1187 int i;
1178 for(i=0;i<maxSubCells;++i) { 1188 for(i=0;i<maxSubCells;++i) {
1179 if (!subCellDict.find(i)) { 1189 if (!subCellDict.find(i)) {
1180 placeItem->setSubCell(i); 1190 placeItem->setSubCell(i);
1181 break; 1191 break;
1182 } 1192 }
1183 } 1193 }
1184 if (i == maxSubCells) { 1194 if (i == maxSubCells) {
1185 placeItem->setSubCell(maxSubCells); 1195 placeItem->setSubCell(maxSubCells);
1186 maxSubCells++; // add new item to number of sub cells 1196 maxSubCells++; // add new item to number of sub cells
1187 } 1197 }
1188 1198
1189 // Prepare for sub cell geometry adjustment 1199 // Prepare for sub cell geometry adjustment
1190 int newSubCellWidth; 1200 int newSubCellWidth;
1191 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1201 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1192 else newSubCellWidth = mGridSpacingX / maxSubCells; 1202 else newSubCellWidth = mGridSpacingX / maxSubCells;
1193 conflictItems.append(placeItem); 1203 conflictItems.append(placeItem);
1194 1204
1195 1205
1196 // Adjust sub cell geometry of all direct conflict items 1206 // Adjust sub cell geometry of all direct conflict items
1197 for ( item=conflictItems.first(); item != 0; 1207 for ( item=conflictItems.first(); item != 0;
1198 item=conflictItems.next() ) { 1208 item=conflictItems.next() ) {
1199 item->setSubCells(maxSubCells); 1209 item->setSubCells(maxSubCells);
1200 if (mAllDayMode) { 1210 if (mAllDayMode) {
1201 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1211 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1202 } else { 1212 } else {
1203 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1213 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1204 } 1214 }
1205 int x,y; 1215 int x,y;
1206 gridToContents(item->cellX(),item->cellYTop(),x,y); 1216 gridToContents(item->cellX(),item->cellYTop(),x,y);
1207 if (mAllDayMode) { 1217 if (mAllDayMode) {
1208 y += item->subCell() * newSubCellWidth; 1218 y += item->subCell() * newSubCellWidth;
1209 } else { 1219 } else {
1210 x += item->subCell() * newSubCellWidth; 1220 x += item->subCell() * newSubCellWidth;
1211 } 1221 }
1212 moveChild(item,x,y); 1222 moveChild(item,x,y);
1213 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1223 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1214 //item->updateItem(); 1224 //item->updateItem();
1215 } 1225 }
1216 // Adjust sub cell geometry of all conflict items of all conflict items 1226 // Adjust sub cell geometry of all conflict items of all conflict items
1217 for ( item=conflictItems.first(); item != 0; 1227 for ( item=conflictItems.first(); item != 0;
1218 item=conflictItems.next() ) { 1228 item=conflictItems.next() ) {
1219 if ( placeItem != item ) { 1229 if ( placeItem != item ) {
1220 KOAgendaItem *item2; 1230 KOAgendaItem *item2;
1221 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1231 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1222 for ( item2=conflictItems2.first(); item2 != 0; 1232 for ( item2=conflictItems2.first(); item2 != 0;
1223 item2=conflictItems2.next() ) { 1233 item2=conflictItems2.next() ) {
1224 if ( item2->subCells() != maxSubCells) { 1234 if ( item2->subCells() != maxSubCells) {
1225 item2->setSubCells(maxSubCells); 1235 item2->setSubCells(maxSubCells);
1226 if (mAllDayMode) { 1236 if (mAllDayMode) {
1227 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1237 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1228 } else { 1238 } else {
1229 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1239 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1230 } 1240 }
1231 int x,y; 1241 int x,y;
1232 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1242 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1233 if (mAllDayMode) { 1243 if (mAllDayMode) {
1234 y += item2->subCell() * newSubCellWidth; 1244 y += item2->subCell() * newSubCellWidth;
1235 } else { 1245 } else {
1236 x += item2->subCell() * newSubCellWidth; 1246 x += item2->subCell() * newSubCellWidth;
1237 } 1247 }
1238 moveChild(item2,x,y); 1248 moveChild(item2,x,y);
1239 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1249 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1240 } 1250 }
1241 } 1251 }
1242 } 1252 }
1243 } 1253 }
1244 } else { 1254 } else {
1245 placeItem->setSubCell(0); 1255 placeItem->setSubCell(0);
1246 placeItem->setSubCells(1); 1256 placeItem->setSubCells(1);
1247 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1257 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1248 else placeItem->resize(mGridSpacingX,placeItem->height()); 1258 else placeItem->resize(mGridSpacingX,placeItem->height());
1249 int x,y; 1259 int x,y;
1250 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1260 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1251 moveChild(placeItem,x,y); 1261 moveChild(placeItem,x,y);
1252 } 1262 }
1253 placeItem->setConflictItems(conflictItems); 1263 placeItem->setConflictItems(conflictItems);
1254 // for ( item=conflictItems.first(); item != 0; 1264 // for ( item=conflictItems.first(); item != 0;
1255// item=conflictItems.next() ) { 1265// item=conflictItems.next() ) {
1256// //item->updateItem(); 1266// //item->updateItem();
1257// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1267// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1258// } 1268// }
1259// placeItem->updateItem(); 1269// placeItem->updateItem();
1260} 1270}
1261 1271
1262void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1272void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1263{ 1273{
1264 if ( globalFlagBlockAgenda ) 1274 if ( globalFlagBlockAgenda )
1265 return; 1275 return;
1266 1276
1267 if ( mInvalidPixmap ) { 1277 if ( mInvalidPixmap ) {
1268 mInvalidPixmap = false; 1278 mInvalidPixmap = false;
1269 qDebug("InvalidPixmap "); 1279 qDebug("InvalidPixmap ");
1270 QTimer::singleShot( 0, this, SIGNAL( updateViewSignal() )); 1280 computeSizes();
1281 emit updateViewSignal();
1271 return; 1282 return;
1272 } 1283 }
1273 if ( ! mAllDayMode ) { 1284 if ( ! mAllDayMode ) {
1274 // currently not working for 1285 // currently not working for
1275 1286
1276 //qDebug("KOAgenda::drawContents "); 1287 //qDebug("KOAgenda::drawContents ");
1277 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1288#if 0
1278 ;//drawContentsToPainter(); 1289 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1279 1290 qDebug("WAU ");
1291 drawContentsToPainter();
1292 }
1293#endif
1280 QPaintDevice* pd = p->device(); 1294 QPaintDevice* pd = p->device();
1281 p->end(); 1295 p->end();
1282 int vx, vy; 1296 int vx, vy;
1283 int selectionX = KOGlobals::self()->reverseLayout() ? 1297 int selectionX = KOGlobals::self()->reverseLayout() ?
1284 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1298 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1285 mSelectionCellX * mGridSpacingX; 1299 mSelectionCellX * mGridSpacingX;
1286 contentsToViewport ( cx, cy, vx,vy); 1300 contentsToViewport ( cx, cy, vx,vy);
1287 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1301 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1288 1302
1289 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1303 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1290 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1304 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1291 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1305 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1292 1306
1293 int vxSel, vySel; 1307 int vxSel, vySel;
1294 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1308 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1295 int off = mSelectionHeight; 1309 int off = mSelectionHeight;
1296 if ( vySel < 0 ) 1310 if ( vySel < 0 )
1297 off += vySel; 1311 off += vySel;
1298 //qDebug("OFF %d %d %d", off,vySel, vy ); 1312 //qDebug("OFF %d %d %d", off,vySel, vy );
1299 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); 1313 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
1300 } else { 1314 } else {
1301 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1315 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1302 } 1316 }
1303 } 1317 }
1304 if ( mSelectionHeight > 0 ) { 1318 if ( mSelectionHeight > 0 ) {
1305 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1319 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1306 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1320 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1307 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1321 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1308 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1322 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1309 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1323 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1310 int hei = mSelectionHeight; 1324 int hei = mSelectionHeight;
1311 int offset = 0; 1325 int offset = 0;
1312 while ( hei > 0 ) { 1326 while ( hei > 0 ) {
1313 int p_hei = 5; 1327 int p_hei = 5;
1314 if ( hei < 5 ) p_hei = hei; 1328 if ( hei < 5 ) p_hei = hei;
1315 hei -= 5; 1329 hei -= 5;
1316 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1330 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1317 offset += 5; 1331 offset += 5;
1318 } 1332 }
1319 } 1333 }
1320 } 1334 }
1321 p->begin( pd ); 1335 p->begin( pd );
1322 } else { 1336 } else {
1323 1337#if 0
1324 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1338 qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() );
1325 ;//drawContentsToPainter(); 1339 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1326 1340 qDebug("WAUWAU ");
1341 drawContentsToPainter();
1342 }
1343#endif
1327 QPaintDevice* pd = p->device(); 1344 QPaintDevice* pd = p->device();
1328 p->end(); 1345 p->end();
1329 int vx, vy; 1346 int vx, vy;
1330 int selectionX = KOGlobals::self()->reverseLayout() ? 1347 int selectionX = KOGlobals::self()->reverseLayout() ?
1331 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1348 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1332 mSelectionCellX * mGridSpacingX; 1349 mSelectionCellX * mGridSpacingX;
1333 contentsToViewport ( cx, cy, vx,vy); 1350 contentsToViewport ( cx, cy, vx,vy);
1334 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1351 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1335 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1352 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1336 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1353 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1337 1354
1338 if ( mSelectionHeight > 0 ) { 1355 if ( mSelectionHeight > 0 ) {
1339 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1356 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1340 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1357 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1341 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1358 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1342 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1359 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1343 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1360 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1344 int hei = mSelectionHeight; 1361 int hei = mSelectionHeight;
1345 int offset = 0; 1362 int offset = 0;
1346 while ( hei > 0 ) { 1363 while ( hei > 0 ) {
1347 int p_hei = 5; 1364 int p_hei = 5;
1348 if ( hei < 5 ) p_hei = hei; 1365 if ( hei < 5 ) p_hei = hei;
1349 hei -= 5; 1366 hei -= 5;
1350 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1367 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1351 offset += 5; 1368 offset += 5;
1352 } 1369 }
1353 } 1370 }
1354 } 1371 }
1355 p->begin( pd ); 1372 p->begin( pd );
1356 } 1373 }
1357 1374
1358} 1375}
1359 1376
1360void KOAgenda::finishUpdate() 1377void KOAgenda::finishUpdate()
1361{ 1378{
1362 1379
1363 KOAgendaItem *item; 1380 KOAgendaItem *item;
1364 globalFlagBlockAgendaItemPaint = 1; 1381 globalFlagBlockAgendaItemPaint = 1;
1365 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems 1382 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems
1366 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1383 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1367 if ( !item->checkLayout() ) { 1384 if ( !item->checkLayout() ) {
1368 //qDebug(" conflictitem found "); 1385 //qDebug(" conflictitem found ");
1369 int newSubCellWidth; 1386 int newSubCellWidth;
1370 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1387 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1371 else newSubCellWidth = mGridSpacingX / item->subCells(); 1388 else newSubCellWidth = mGridSpacingX / item->subCells();
1372 1389
1373 if (mAllDayMode) { 1390 if (mAllDayMode) {
1374 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1391 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1375 } else { 1392 } else {
1376 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1393 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1377 } 1394 }
1378 int x,y; 1395 int x,y;
1379 gridToContents(item->cellX(),item->cellYTop(),x,y); 1396 gridToContents(item->cellX(),item->cellYTop(),x,y);
1380 if (mAllDayMode) { 1397 if (mAllDayMode) {
1381 y += item->subCell() * newSubCellWidth; 1398 y += item->subCell() * newSubCellWidth;
1382 } else { 1399 } else {
1383 x += item->subCell() * newSubCellWidth; 1400 x += item->subCell() * newSubCellWidth;
1384 } 1401 }
1385 moveChild(item,x,y); 1402 moveChild(item,x,y);
1386 } 1403 }
1387 } 1404 }
1388 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1405 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1389 if ( !item->isVisible() ) 1406 if ( !item->isVisible() )
1390 item->show(); 1407 item->show();
1391 1408
1392 } 1409 }
1393 globalFlagBlockAgendaItemUpdate = 0; 1410 globalFlagBlockAgendaItemUpdate = 0;
1394 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1411 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1395 item->repaintMe( ); 1412 item->repaintMe( );
1396 } 1413 }
1397 globalFlagBlockAgendaItemUpdate = 1; 1414 globalFlagBlockAgendaItemUpdate = 1;
1398 qApp->processEvents(); 1415 qApp->processEvents();
1399 globalFlagBlockAgendaItemPaint = 0; 1416 globalFlagBlockAgendaItemPaint = 0;
1400 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1417 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1401 item->repaint( false ); 1418 item->repaint( false );
1402 } 1419 }
1403 1420
1404} 1421}
1405 1422
1406/* 1423/*
1407 Draw grid in the background of the agenda. 1424 Draw grid in the background of the agenda.
1408*/ 1425*/
1409void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1426void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1410{ 1427{
1411 1428
1412 1429
1413 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1430 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1414 return; 1431 return;
1415 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1432 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1416 return; 1433 return;
1417 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1434 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1418 if ( ch < 1 ) 1435 if ( ch < 1 )
1419 ch = 1; 1436 ch = 1;
1420 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1437 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1421 mPaintPixmap.resize( contentsWidth()+42, ch ); 1438 mPaintPixmap.resize( contentsWidth()+42, ch );
1422 } 1439 }
1423 mCurPixWid = contentsWidth(); 1440 mCurPixWid = contentsWidth();
1424 mCurPixHei = ch; 1441 mCurPixHei = ch;
1425 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { 1442 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) {
1426 mHighlightPixmap.resize( mGridSpacingX-1, 5 ); 1443 mHighlightPixmap.resize( mGridSpacingX-1, 5 );
1427 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1444 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1428 } 1445 }
1429 mPixPainter.begin( &mPaintPixmap) ; 1446 mPixPainter.begin( &mPaintPixmap) ;
1430 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1447 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1431 QPainter * p ; 1448 QPainter * p ;
1432 if (paint == 0) { 1449 if (paint == 0) {
1433 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1450 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1434 p = &mPixPainter; 1451 p = &mPixPainter;
1435 } 1452 }
1436 else 1453 else
1437 p = paint ; 1454 p = paint ;
1438 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1455 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1439 1456
1440 //--cx;++cw; 1457 //--cx;++cw;
1441 int lGridSpacingY = mGridSpacingY*2; 1458 int lGridSpacingY = mGridSpacingY*2;
1442 int selDay; 1459 int selDay;
1443 QDate curDate = QDate::currentDate(); 1460 QDate curDate = QDate::currentDate();
1444 if ( !backgroundOnly ) { 1461 if ( !backgroundOnly ) {
1445 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1462 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1446 { 1463 {
1447 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { 1464 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) {
1448 int x1 = cx; 1465 int x1 = cx;
1449 int y1 = 0; 1466 int y1 = 0;
1450 if (y1 < cy) y1 = cy; 1467 if (y1 < cy) y1 = cy;
1451 int x2 = cx+cw-1; 1468 int x2 = cx+cw-1;
1452 int y2 = contentsHeight(); 1469 int y2 = contentsHeight();
1453 if (y2 > cy+ch-1) y2=cy+ch-1; 1470 if (y2 > cy+ch-1) y2=cy+ch-1;
1454 if (x2 >= x1 && y2 >= y1) { 1471 if (x2 >= x1 && y2 >= y1) {
1455 int gxStart = selDay; 1472 int gxStart = selDay;
1456 int gxEnd = gxStart ; 1473 int gxEnd = gxStart ;
1457 int xStart = KOGlobals::self()->reverseLayout() ? 1474 int xStart = KOGlobals::self()->reverseLayout() ?
1458 (mColumns - 1 - gxStart)*mGridSpacingX : 1475 (mColumns - 1 - gxStart)*mGridSpacingX :
1459 gxStart*mGridSpacingX; 1476 gxStart*mGridSpacingX;
1460 if (xStart < x1) xStart = x1; 1477 if (xStart < x1) xStart = x1;
1461 int xEnd = KOGlobals::self()->reverseLayout() ? 1478 int xEnd = KOGlobals::self()->reverseLayout() ?
1462 (mColumns - gxStart)*mGridSpacingX-1 : 1479 (mColumns - gxStart)*mGridSpacingX-1 :
1463 (gxStart+1)*mGridSpacingX-1; 1480 (gxStart+1)*mGridSpacingX-1;
1464 if (xEnd > x2) xEnd = x2; 1481 if (xEnd > x2) xEnd = x2;
1465 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1482 if ( KOPrefs::instance()->mUseHighlightLightColor )
1466 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1483 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1467 KOPrefs::instance()->mAgendaBgColor.light()); 1484 KOPrefs::instance()->mAgendaBgColor.light());
1468 else 1485 else
1469 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1486 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1470 KOPrefs::instance()->mAgendaBgColor.dark()); 1487 KOPrefs::instance()->mAgendaBgColor.dark());
1471 1488
1472 } 1489 }
1473 } 1490 }
1474 } 1491 }
1475 } 1492 }
1476 // Highlight working hours 1493 // Highlight working hours
1477 1494
1478 if ( !backgroundOnly ) 1495 if ( !backgroundOnly )
1479 if (mWorkingHoursEnable) { 1496 if (mWorkingHoursEnable) {
1480 int x1 = cx; 1497 int x1 = cx;
1481 int y1 = mWorkingHoursYTop; 1498 int y1 = mWorkingHoursYTop;
1482 if (y1 < cy) y1 = cy; 1499 if (y1 < cy) y1 = cy;
1483 int x2 = cx+cw-1; 1500 int x2 = cx+cw-1;
1484 // int x2 = mGridSpacingX * 5 - 1; 1501 // int x2 = mGridSpacingX * 5 - 1;
1485 // if (x2 > cx+cw-1) x2 = cx + cw - 1; 1502 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1486 int y2 = mWorkingHoursYBottom; 1503 int y2 = mWorkingHoursYBottom;
1487 if (y2 > cy+ch-1) y2=cy+ch-1; 1504 if (y2 > cy+ch-1) y2=cy+ch-1;
1488 1505
1489 if (x2 >= x1 && y2 >= y1) { 1506 if (x2 >= x1 && y2 >= y1) {
1490 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); 1507 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1491 int gxStart = x1/mGridSpacingX; 1508 int gxStart = x1/mGridSpacingX;
1492 int gxEnd = x2/mGridSpacingX; 1509 int gxEnd = x2/mGridSpacingX;
1493 while(gxStart <= gxEnd) { 1510 while(gxStart <= gxEnd) {
1494 if (gxStart < int(mHolidayMask->count()) && 1511 if (gxStart < int(mHolidayMask->count()) &&
1495 !mHolidayMask->at(gxStart)) { 1512 !mHolidayMask->at(gxStart)) {
1496 int xStart = KOGlobals::self()->reverseLayout() ? 1513 int xStart = KOGlobals::self()->reverseLayout() ?
1497 (mColumns - 1 - gxStart)*mGridSpacingX : 1514 (mColumns - 1 - gxStart)*mGridSpacingX :
1498 gxStart*mGridSpacingX; 1515 gxStart*mGridSpacingX;
1499 if (xStart < x1) xStart = x1; 1516 if (xStart < x1) xStart = x1;
1500 int xEnd = KOGlobals::self()->reverseLayout() ? 1517 int xEnd = KOGlobals::self()->reverseLayout() ?
1501 (mColumns - gxStart)*mGridSpacingX-1 : 1518 (mColumns - gxStart)*mGridSpacingX-1 :
1502 (gxStart+1)*mGridSpacingX-1; 1519 (gxStart+1)*mGridSpacingX-1;
1503 if (xEnd > x2) xEnd = x2; 1520 if (xEnd > x2) xEnd = x2;
1504 if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { 1521 if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) {
1505 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1522 if ( KOPrefs::instance()->mUseHighlightLightColor )
1506 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1523 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1507 KOPrefs::instance()->mWorkingHoursColor.light()); 1524 KOPrefs::instance()->mWorkingHoursColor.light());
1508 else 1525 else
1509 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1526 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1510 KOPrefs::instance()->mWorkingHoursColor.dark()); 1527 KOPrefs::instance()->mWorkingHoursColor.dark());
1511 } else { 1528 } else {
1512 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1529 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1513 KOPrefs::instance()->mWorkingHoursColor); 1530 KOPrefs::instance()->mWorkingHoursColor);
1514 } 1531 }
1515 } 1532 }
1516 ++gxStart; 1533 ++gxStart;
1517 } 1534 }
1518 } 1535 }
1519 } 1536 }
1520 /* 1537 /*
1521 int selectionX = KOGlobals::self()->reverseLayout() ? 1538 int selectionX = KOGlobals::self()->reverseLayout() ?
1522 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1539 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1523 mSelectionCellX * mGridSpacingX; 1540 mSelectionCellX * mGridSpacingX;
1524 1541
1525 // Draw selection 1542 // Draw selection
1526 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1543 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1527 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1544 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1528 // TODO: paint only part within cx,cy,cw,ch 1545 // TODO: paint only part within cx,cy,cw,ch
1529 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, 1546 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1530 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1547 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1531 } 1548 }
1532 */ 1549 */
1533 // Draw vertical lines of grid 1550 // Draw vertical lines of grid
1534 1551
1535 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1552 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1536 if ( mGridSpacingX > 0 ) { 1553 if ( mGridSpacingX > 0 ) {
1537 while (x < cx + cw) { 1554 while (x < cx + cw) {
1538 p->drawLine(x,cy,x,cy+ch); 1555 p->drawLine(x,cy,x,cy+ch);
1539 x+=mGridSpacingX; 1556 x+=mGridSpacingX;
1540 } 1557 }
1541 } 1558 }
1542 // Draw horizontal lines of grid 1559 // Draw horizontal lines of grid
1543 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1560 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1544 if ( lGridSpacingY > 0 ) { 1561 if ( lGridSpacingY > 0 ) {
1545 while (y < cy + ch) { 1562 while (y < cy + ch) {
1546 p->setPen( SolidLine ); 1563 p->setPen( SolidLine );
1547 p->drawLine(cx,y,cx+cw,y); 1564 p->drawLine(cx,y,cx+cw,y);
1548 y+=lGridSpacingY; 1565 y+=lGridSpacingY;
1549 p->setPen( DotLine ); 1566 p->setPen( DotLine );
1550 p->drawLine(cx,y,cx+cw,y); 1567 p->drawLine(cx,y,cx+cw,y);
1551 y+=lGridSpacingY; 1568 y+=lGridSpacingY;
1552 } 1569 }
1553 p->setPen( SolidLine ); 1570 p->setPen( SolidLine );
1554 } 1571 }
1555 mPixPainter.end() ; 1572 mPixPainter.end() ;
1556} 1573}
1557 1574
1558/* 1575/*
1559 Convert srcollview contents coordinates to agenda grid coordinates. 1576 Convert srcollview contents coordinates to agenda grid coordinates.
1560*/ 1577*/
1561void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1578void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1562{ 1579{
1563 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : 1580 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1564 x/mGridSpacingX; 1581 x/mGridSpacingX;
1565 gy = y/mGridSpacingY; 1582 gy = y/mGridSpacingY;
1566} 1583}
1567 1584
1568/* 1585/*
1569 Convert agenda grid coordinates to scrollview contents coordinates. 1586 Convert agenda grid coordinates to scrollview contents coordinates.
1570*/ 1587*/
1571void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) 1588void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
1572{ 1589{
1573 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: 1590 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
1574 gx*mGridSpacingX; 1591 gx*mGridSpacingX;
1575 y = gy*mGridSpacingY; 1592 y = gy*mGridSpacingY;
1576} 1593}
1577 1594
1578 1595
1579/* 1596/*
1580 Return Y coordinate corresponding to time. Coordinates are rounded to fit into 1597 Return Y coordinate corresponding to time. Coordinates are rounded to fit into
1581 the grid. 1598 the grid.
1582*/ 1599*/
1583int KOAgenda::timeToY(const QTime &time) 1600int KOAgenda::timeToY(const QTime &time)
1584{ 1601{
1585 int minutesPerCell = 24 * 60 / mRows; 1602 int minutesPerCell = 24 * 60 / mRows;
1586 int timeMinutes = time.hour() * 60 + time.minute(); 1603 int timeMinutes = time.hour() * 60 + time.minute();
1587 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; 1604 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell;
1588 return Y; 1605 return Y;
1589} 1606}
1590 1607
1591 1608
1592/* 1609/*
1593 Return time corresponding to cell y coordinate. Coordinates are rounded to 1610 Return time corresponding to cell y coordinate. Coordinates are rounded to
1594 fit into the grid. 1611 fit into the grid.
1595*/ 1612*/
1596QTime KOAgenda::gyToTime(int gy) 1613QTime KOAgenda::gyToTime(int gy)
1597{ 1614{
1598 1615
1599 int secondsPerCell = 24 * 60 * 60/ mRows; 1616 int secondsPerCell = 24 * 60 * 60/ mRows;
1600 1617
1601 int timeSeconds = secondsPerCell * gy; 1618 int timeSeconds = secondsPerCell * gy;
1602 1619
1603 QTime time( 0, 0, 0 ); 1620 QTime time( 0, 0, 0 );
1604 if ( timeSeconds < 24 * 60 * 60 ) { 1621 if ( timeSeconds < 24 * 60 * 60 ) {
1605 time = time.addSecs(timeSeconds); 1622 time = time.addSecs(timeSeconds);
1606 } else { 1623 } else {
1607 time.setHMS( 23, 59, 59 ); 1624 time.setHMS( 23, 59, 59 );
1608 } 1625 }
1609 1626
1610 return time; 1627 return time;
1611} 1628}
1612 1629
1613void KOAgenda::setStartHour(int startHour) 1630void KOAgenda::setStartHour(int startHour)
1614{ 1631{
1615 int startCell = startHour * mRows / 24; 1632 int startCell = startHour * mRows / 24;
1616 setContentsPos(0,startCell * gridSpacingY()); 1633 setContentsPos(0,startCell * gridSpacingY());
1617} 1634}
1618void KOAgenda::hideUnused() 1635void KOAgenda::hideUnused()
1619{ 1636{
1620 // experimental only 1637 // experimental only
1621 // return; 1638 // return;
1622 KOAgendaItem *item; 1639 KOAgendaItem *item;
1623 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { 1640 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
1624 item->hide(); 1641 item->hide();
1625 } 1642 }
1626} 1643}
1627 1644
1628 1645
1629KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1646KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1630{ 1647{
1631 1648
1632 KOAgendaItem *fi; 1649 KOAgendaItem *fi;
1633 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { 1650 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
1634 if ( fi->incidence() == event ) { 1651 if ( fi->incidence() == event ) {
1635 mUnusedItems.remove(); 1652 mUnusedItems.remove();
1636 fi->init( event, qd ); 1653 fi->init( event, qd );
1637 return fi; 1654 return fi;
1638 } 1655 }
1639 } 1656 }
1640 fi=mUnusedItems.first(); 1657 fi=mUnusedItems.first();
1641 if ( fi ) { 1658 if ( fi ) {
1642 mUnusedItems.remove(); 1659 mUnusedItems.remove();
1643 fi->init( event, qd ); 1660 fi->init( event, qd );
1644 return fi; 1661 return fi;
1645 } 1662 }
1646 // qDebug("new KOAgendaItem "); 1663 // qDebug("new KOAgendaItem ");
1647 1664
1648 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); 1665 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1649 agendaItem->installEventFilter(this); 1666 agendaItem->installEventFilter(this);
1650 addChild(agendaItem,0,0); 1667 addChild(agendaItem,0,0);
1651 return agendaItem; 1668 return agendaItem;
1652} 1669}
1653KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1670KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1654{ 1671{
1655 KOAgendaItem *item; 1672 KOAgendaItem *item;
1656 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1673 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1657 if ( item->incidence() == todo ) { 1674 if ( item->incidence() == todo ) {
1658 mItems.remove(); 1675 mItems.remove();
1659 return item; 1676 return item;
1660 } 1677 }
1661 } 1678 }
1662 return 0; 1679 return 0;
1663} 1680}
1664 1681
1665 1682
1666void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1683void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1667{ 1684{
1668 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1685 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1669 KOAgendaItem *item; 1686 KOAgendaItem *item;
1670 item = getItemForTodo ( todo ); 1687 item = getItemForTodo ( todo );
1671 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1688 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1672 if ( item ) { 1689 if ( item ) {
1673 blockSignals( true ); 1690 blockSignals( true );
1674 //qDebug("item found "); 1691 //qDebug("item found ");
1675 item->hide(); 1692 item->hide();
1676 item->setCellX(-2, -1 ); 1693 item->setCellX(-2, -1 );
1677 item->select(false); 1694 item->select(false);
1678 mUnusedItems.append( item ); 1695 mUnusedItems.append( item );
1679 mItems.remove( item ); 1696 mItems.remove( item );
1680 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1697 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1681 KOAgendaItem *itemit; 1698 KOAgendaItem *itemit;
1682 //globalFlagBlockAgendaItemPaint = 1; 1699 //globalFlagBlockAgendaItemPaint = 1;
1683 for ( itemit=oldconflictItems.first(); itemit != 0; 1700 for ( itemit=oldconflictItems.first(); itemit != 0;
1684 itemit=oldconflictItems.next() ) { 1701 itemit=oldconflictItems.next() ) {
1685 if ( itemit != item ) 1702 if ( itemit != item )
1686 placeSubCells(itemit); 1703 placeSubCells(itemit);
1687 } 1704 }
1688 qApp->processEvents(); 1705 qApp->processEvents();
1689 //globalFlagBlockAgendaItemPaint = 0; 1706 //globalFlagBlockAgendaItemPaint = 0;
1690 for ( itemit=oldconflictItems.first(); itemit != 0; 1707 for ( itemit=oldconflictItems.first(); itemit != 0;
1691 itemit=oldconflictItems.next() ) { 1708 itemit=oldconflictItems.next() ) {
1692 globalFlagBlockAgendaItemUpdate = 0; 1709 globalFlagBlockAgendaItemUpdate = 0;
1693 if ( itemit != item ) 1710 if ( itemit != item )
1694 itemit->repaintMe(); 1711 itemit->repaintMe();
1695 globalFlagBlockAgendaItemUpdate = 1; 1712 globalFlagBlockAgendaItemUpdate = 1;
1696 //qDebug("sigleshot "); 1713 //qDebug("sigleshot ");
1697 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); 1714 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() ));
1698 //itemit->repaint( false ); repaintItem() 1715 //itemit->repaint( false ); repaintItem()
1699 } 1716 }
1700 blockSignals( false ); 1717 blockSignals( false );
1701 } 1718 }
1702 if ( remove ) { 1719 if ( remove ) {
1703 //qDebug("remove****************************************** "); 1720 //qDebug("remove****************************************** ");
1704 return; 1721 return;
1705 } 1722 }
1706 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) 1723 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda )
1707 return; 1724 return;
1708 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1725 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1709 QDate currentDate = QDate::currentDate(); 1726 QDate currentDate = QDate::currentDate();
1710 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1727 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda );
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 5d813b2..0e3aed8 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -1,305 +1,306 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDA_H 23#ifndef KOAGENDA_H
24#define KOAGENDA_H 24#define KOAGENDA_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qmemarray.h> 28#include <qmemarray.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qpixmap.h> 30#include <qpixmap.h>
31#include <qguardedptr.h> 31#include <qguardedptr.h>
32 32
33#include "koagendaitem.h" 33#include "koagendaitem.h"
34#include "koeventview.h" 34#include "koeventview.h"
35 35
36class QPopupMenu; 36class QPopupMenu;
37class QTime; 37class QTime;
38class KConfig; 38class KConfig;
39class QFrame; 39class QFrame;
40class KOAgenda; 40class KOAgenda;
41class KCal::Event; 41class KCal::Event;
42class KCal::Todo; 42class KCal::Todo;
43 43
44using namespace KCal; 44using namespace KCal;
45 45
46class MarcusBains : public QFrame { 46class MarcusBains : public QFrame {
47 Q_OBJECT 47 Q_OBJECT
48 public: 48 public:
49 MarcusBains(KOAgenda *agenda=0,const char *name=0); 49 MarcusBains(KOAgenda *agenda=0,const char *name=0);
50 virtual ~MarcusBains(); 50 virtual ~MarcusBains();
51 51
52 public slots: 52 public slots:
53 void updateLocation(bool recalculate=false); 53 void updateLocation(bool recalculate=false);
54 void updateLoc(); 54 void updateLoc();
55 55
56 private: 56 private:
57 int todayColumn(); 57 int todayColumn();
58 QTimer *minutes; 58 QTimer *minutes;
59 QLabel *mTimeBox; 59 QLabel *mTimeBox;
60 KOAgenda *agenda; 60 KOAgenda *agenda;
61 QTime oldTime; 61 QTime oldTime;
62 int oldToday; 62 int oldToday;
63}; 63};
64 64
65 65
66class KOAgenda : public QScrollView 66class KOAgenda : public QScrollView
67{ 67{
68 Q_OBJECT 68 Q_OBJECT
69 public: 69 public:
70 enum MouseActionType { NOP, MOVE, SELECT, 70 enum MouseActionType { NOP, MOVE, SELECT,
71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
72 72
73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
74 const char * name=0, WFlags f=0 ); 74 const char * name=0, WFlags f=0 );
75 KOAgenda ( int columns, QWidget * parent=0, 75 KOAgenda ( int columns, QWidget * parent=0,
76 const char * name=0, WFlags f=0 ); 76 const char * name=0, WFlags f=0 );
77 virtual ~KOAgenda(); 77 virtual ~KOAgenda();
78 static bool mInvalidPixmap; 78 bool mInvalidPixmap;
79 79
80 Incidence *selectedIncidence() const; 80 Incidence *selectedIncidence() const;
81 QDate selectedIncidenceDate() const; 81 QDate selectedIncidenceDate() const;
82 82
83 virtual bool eventFilter ( QObject *, QEvent * ); 83 virtual bool eventFilter ( QObject *, QEvent * );
84 84
85 void contentsToGrid (int x, int y, int& gx, int& gy); 85 void contentsToGrid (int x, int y, int& gx, int& gy);
86 void gridToContents (int gx, int gy, int& x, int& y); 86 void gridToContents (int gx, int gy, int& x, int& y);
87 87
88 int timeToY (const QTime &time); 88 int timeToY (const QTime &time);
89 QTime gyToTime (int y); 89 QTime gyToTime (int y);
90 90
91 void setStartHour(int startHour); 91 void setStartHour(int startHour);
92 92
93 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 93 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
94 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 94 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
95 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 95 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
96 int YTop,int YBottom); 96 int YTop,int YBottom);
97 97
98 void changeColumns(int columns); 98 void changeColumns(int columns);
99 99
100 int columns() { return mColumns; } 100 int columns() { return mColumns; }
101 int rows() { return mRows; } 101 int rows() { return mRows; }
102 102
103 int gridSpacingX() const { return mGridSpacingX; } 103 int gridSpacingX() const { return mGridSpacingX; }
104 int gridSpacingY() const { return mGridSpacingY; } 104 int gridSpacingY() const { return mGridSpacingY; }
105 105
106// virtual QSizePolicy sizePolicy() const; 106// virtual QSizePolicy sizePolicy() const;
107 107
108 void clear(); 108 void clear();
109 109
110 void clearSelection(); 110 void clearSelection();
111 void hideUnused(); 111 void hideUnused();
112 112
113 /** Calculates the minimum width */ 113 /** Calculates the minimum width */
114 virtual int minimumWidth() const; 114 virtual int minimumWidth() const;
115 /** Update configuration from preference settings */ 115 /** Update configuration from preference settings */
116 void updateConfig(); 116 void updateConfig();
117 117
118 void checkScrollBoundaries(); 118 void checkScrollBoundaries();
119 119
120 void setHolidayMask(QMemArray<bool> *); 120 void setHolidayMask(QMemArray<bool> *);
121 void setDateList(const DateList &selectedDates); 121 void setDateList(const DateList &selectedDates);
122 DateList dateList() const; 122 DateList dateList() const;
123 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 123 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
124 void finishUpdate(); 124 void finishUpdate();
125 void printSelection(); 125 void printSelection();
126 void storePosition(); 126 void storePosition();
127 void restorePosition(); 127 void restorePosition();
128 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } 128 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; }
129 void shrinkPixmap(); 129 void shrinkPixmap();
130 130
131 public slots: 131 public slots:
132 void slotContentMove(int,int); 132 void slotContentMove(int,int);
133 void categoryChanged(Incidence * inc); 133 void categoryChanged(Incidence * inc);
134 void slotClearSelection(); 134 void slotClearSelection();
135 void popupMenu(); 135 void popupMenu();
136 void newItem( int ); 136 void newItem( int );
137 void moveChild( QWidget *, int, int ); 137 void moveChild( QWidget *, int, int );
138 void scrollUp(); 138 void scrollUp();
139 void scrollDown(); 139 void scrollDown();
140 void updateTodo( Todo * t, int , bool ); 140 void updateTodo( Todo * t, int , bool );
141 void popupAlarm(); 141 void popupAlarm();
142 142
143 void checkScrollBoundaries(int); 143 void checkScrollBoundaries(int);
144 144
145 /** Deselect selected items. This function does not emit any signals. */ 145 /** Deselect selected items. This function does not emit any signals. */
146 void deselectItem(); 146 void deselectItem();
147 /** Select item. If the argument is 0, the currently selected item gets 147 /** Select item. If the argument is 0, the currently selected item gets
148 deselected. This function emits the itemSelected(bool) signal to inform 148 deselected. This function emits the itemSelected(bool) signal to inform
149 about selection/deseelction of events. */ 149 about selection/deseelction of events. */
150 void selectItem(KOAgendaItem *); 150 void selectItem(KOAgendaItem *);
151 void finishResize(); 151 void finishResize();
152 152
153 signals: 153 signals:
154 void signalClearSelection(); 154 void signalClearSelection();
155 void showDateView( int, int); 155 void showDateView( int, int);
156 void newEventSignal(); 156 void newEventSignal();
157 void newEventSignal(int gx,int gy); 157 void newEventSignal(int gx,int gy);
158 void newTodoSignal(int gx,int gy); 158 void newTodoSignal(int gx,int gy);
159 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 159 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
160 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 160 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
161 void newStartSelectSignal(); 161 void newStartSelectSignal();
162 void showIncidenceSignal(Incidence *); 162 void showIncidenceSignal(Incidence *);
163 void editIncidenceSignal(Incidence *); 163 void editIncidenceSignal(Incidence *);
164 void deleteIncidenceSignal(Incidence *); 164 void deleteIncidenceSignal(Incidence *);
165 void showIncidencePopupSignal(Incidence *); 165 void showIncidencePopupSignal(Incidence *);
166 166
167 void itemModified(KOAgendaItem *item, int ); 167 void itemModified(KOAgendaItem *item, int );
168 void incidenceSelected(Incidence *); 168 void incidenceSelected(Incidence *);
169 169
170 void lowerYChanged(int); 170 void lowerYChanged(int);
171 void upperYChanged(int); 171 void upperYChanged(int);
172 172
173 void startDragSignal(Incidence *); 173 void startDragSignal(Incidence *);
174 void addToCalSignal(Incidence *, Incidence *); 174 void addToCalSignal(Incidence *, Incidence *);
175 void resizedSignal(); 175 void resizedSignal();
176 void updateViewSignal(); 176 void updateViewSignal();
177 void sendPing();
177 178
178 protected: 179 protected:
179 KOEventPopupMenu * mAllAgendaPopup; 180 KOEventPopupMenu * mAllAgendaPopup;
180 QPainter mPixPainter; 181 QPainter mPixPainter;
181 QPixmap mPaintPixmap; 182 QPixmap mPaintPixmap;
182 QPixmap mHighlightPixmap; 183 QPixmap mHighlightPixmap;
183 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 184 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
184 virtual void resizeEvent ( QResizeEvent * ); 185 virtual void resizeEvent ( QResizeEvent * );
185 186
186 /** Handles mouse events. Called from eventFilter */ 187 /** Handles mouse events. Called from eventFilter */
187 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 188 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
188 189
189 /** Start selecting time span. */ 190 /** Start selecting time span. */
190 void startSelectAction(QPoint viewportPos); 191 void startSelectAction(QPoint viewportPos);
191 192
192 /** Select time span. */ 193 /** Select time span. */
193 void performSelectAction(QPoint viewportPos); 194 void performSelectAction(QPoint viewportPos);
194 195
195 /** Emd selecting time span. */ 196 /** Emd selecting time span. */
196 void endSelectAction( bool emitNewEvent = false ); 197 void endSelectAction( bool emitNewEvent = false );
197 198
198 /** Start moving/resizing agenda item */ 199 /** Start moving/resizing agenda item */
199 void startItemAction(QPoint viewportPos); 200 void startItemAction(QPoint viewportPos);
200 201
201 /** Move/resize agenda item */ 202 /** Move/resize agenda item */
202 void performItemAction(QPoint viewportPos); 203 void performItemAction(QPoint viewportPos);
203 204
204 /** End moving/resizing agenda item */ 205 /** End moving/resizing agenda item */
205 void endItemAction(); 206 void endItemAction();
206 207
207 /** Set cursor, when no item action is in progress */ 208 /** Set cursor, when no item action is in progress */
208 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 209 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
209 210
210 /** Place agenda item in agenda and adjust other cells if necessary */ 211 /** Place agenda item in agenda and adjust other cells if necessary */
211 void placeSubCells(KOAgendaItem *placeItem); 212 void placeSubCells(KOAgendaItem *placeItem);
212 213
213 /** Process the keyevent, including the ignored keyevents of eventwidgets. 214 /** Process the keyevent, including the ignored keyevents of eventwidgets.
214 * Implements pgup/pgdn and cursor key navigation in the view. 215 * Implements pgup/pgdn and cursor key navigation in the view.
215 */ 216 */
216 void keyPressEvent( QKeyEvent * ); 217 void keyPressEvent( QKeyEvent * );
217 218
218 void calculateWorkingHours(); 219 void calculateWorkingHours();
219 220
220 virtual void contentsMousePressEvent ( QMouseEvent * ); 221 virtual void contentsMousePressEvent ( QMouseEvent * );
221 222
222 private: 223 private:
223 void init(); 224 void init();
224 void marcus_bains(); 225 void marcus_bains();
225 bool mAllDayMode; 226 bool mAllDayMode;
226 bool blockResize; 227 bool blockResize;
227 bool mLeftMouseDown; 228 bool mLeftMouseDown;
228 KOAgendaItem *mPopupItem; 229 KOAgendaItem *mPopupItem;
229 QTimer* mPopupTimer; 230 QTimer* mPopupTimer;
230 int mPopupKind; 231 int mPopupKind;
231 QPoint mPopupPos; 232 QPoint mPopupPos;
232 QTimer mResizeTimer; 233 QTimer mResizeTimer;
233 double mContentPosition; 234 double mContentPosition;
234 235
235 // Width and height of agenda cells 236 // Width and height of agenda cells
236 int mGridSpacingX; 237 int mGridSpacingX;
237 int mGridSpacingY; 238 int mGridSpacingY;
238 239
239 // size of border, where mouse action will resize the KOAgendaItem 240 // size of border, where mouse action will resize the KOAgendaItem
240 int mResizeBorderWidth; 241 int mResizeBorderWidth;
241 242
242 // size of border, where mouse mve will cause a scroll of the agenda 243 // size of border, where mouse mve will cause a scroll of the agenda
243 int mScrollBorderWidth; 244 int mScrollBorderWidth;
244 int mScrollDelay; 245 int mScrollDelay;
245 int mScrollOffset; 246 int mScrollOffset;
246 247
247 QTimer mScrollUpTimer; 248 QTimer mScrollUpTimer;
248 QTimer mScrollDownTimer; 249 QTimer mScrollDownTimer;
249 250
250 // Number of Columns/Rows of agenda grid 251 // Number of Columns/Rows of agenda grid
251 int mColumns; 252 int mColumns;
252 int mRows; 253 int mRows;
253 254
254 // Cells to store Move and Resize coordiantes 255 // Cells to store Move and Resize coordiantes
255 int mStartCellX; 256 int mStartCellX;
256 int mStartCellY; 257 int mStartCellY;
257 int mCurrentCellX; 258 int mCurrentCellX;
258 int mCurrentCellY; 259 int mCurrentCellY;
259 260
260 // Working Hour coordiantes 261 // Working Hour coordiantes
261 bool mWorkingHoursEnable; 262 bool mWorkingHoursEnable;
262 int mWorkingHoursYTop; 263 int mWorkingHoursYTop;
263 int mWorkingHoursYBottom; 264 int mWorkingHoursYBottom;
264 265
265 // Selection 266 // Selection
266 int mSelectionCellX; 267 int mSelectionCellX;
267 int mSelectionYTop; 268 int mSelectionYTop;
268 int mSelectionHeight; 269 int mSelectionHeight;
269 270
270 // List of dates to be displayed 271 // List of dates to be displayed
271 DateList mSelectedDates; 272 DateList mSelectedDates;
272 273
273 // The KOAgendaItem, which has been right-clicked last 274 // The KOAgendaItem, which has been right-clicked last
274 KOAgendaItem *mClickedItem; 275 KOAgendaItem *mClickedItem;
275 276
276 // The KOAgendaItem, which is being moved/resized 277 // The KOAgendaItem, which is being moved/resized
277 QGuardedPtr<KOAgendaItem> mActionItem; 278 QGuardedPtr<KOAgendaItem> mActionItem;
278 279
279 // Currently selected item 280 // Currently selected item
280 QGuardedPtr<KOAgendaItem> mSelectedItem; 281 QGuardedPtr<KOAgendaItem> mSelectedItem;
281 282
282 // The Marcus Bains Line widget. 283 // The Marcus Bains Line widget.
283 MarcusBains *mMarcusBains; 284 MarcusBains *mMarcusBains;
284 void computeSizes(); 285 void computeSizes();
285 286
286 MouseActionType mActionType; 287 MouseActionType mActionType;
287 288
288 bool mItemMoved; 289 bool mItemMoved;
289 290
290 // List of all Items contained in agenda 291 // List of all Items contained in agenda
291 QPtrList<KOAgendaItem> mItems; 292 QPtrList<KOAgendaItem> mItems;
292 QPtrList<KOAgendaItem> mUnusedItems; 293 QPtrList<KOAgendaItem> mUnusedItems;
293 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); 294 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport);
294 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems 295 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems
295 QPopupMenu *mNewItemPopup; 296 QPopupMenu *mNewItemPopup;
296 297
297 int mOldLowerScrollValue; 298 int mOldLowerScrollValue;
298 int mOldUpperScrollValue; 299 int mOldUpperScrollValue;
299 KOAgendaItem * getItemForTodo ( Todo * todo ); 300 KOAgendaItem * getItemForTodo ( Todo * todo );
300 QMemArray<bool> *mHolidayMask; 301 QMemArray<bool> *mHolidayMask;
301 int mCurPixWid; 302 int mCurPixWid;
302 int mCurPixHei; 303 int mCurPixHei;
303}; 304};
304 305
305#endif // KOAGENDA_H 306#endif // KOAGENDA_H
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 488d9d4..1b21a71 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1661 +1,1669 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79#define IDLETIMEOUT 3 79#define IDLETIMEOUT 15
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 myPix.resize( 1, 1 ); 84 myPix.resize( 1, 1 );
85 mRows = rows; 85 mRows = rows;
86 86
87 mRedrawNeeded = true; 87 mRedrawNeeded = true;
88 setMinimumHeight( 20 ); 88 setMinimumHeight( 20 );
89 mCellHeight = KOPrefs::instance()->mHourSize*4; 89 mCellHeight = KOPrefs::instance()->mHourSize*4;
90 90
91 enableClipper(true); 91 enableClipper(true);
92 92
93 setHScrollBarMode(AlwaysOff); 93 setHScrollBarMode(AlwaysOff);
94 setVScrollBarMode(AlwaysOff); 94 setVScrollBarMode(AlwaysOff);
95 95
96 resizeContents(50,mRows * mCellHeight); 96 resizeContents(50,mRows * mCellHeight);
97 97
98 viewport()->setBackgroundMode( PaletteBackground ); 98 viewport()->setBackgroundMode( PaletteBackground );
99} 99}
100 100
101void TimeLabels::setCellHeight(int height) 101void TimeLabels::setCellHeight(int height)
102{ 102{
103 mCellHeight = height; 103 mCellHeight = height;
104} 104}
105 105
106/* 106/*
107 Optimization so that only the "dirty" portion of the scroll view 107 Optimization so that only the "dirty" portion of the scroll view
108 is redrawn. Unfortunately, this is not called by default paintEvent() method. 108 is redrawn. Unfortunately, this is not called by default paintEvent() method.
109*/ 109*/
110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 111{
112 112
113 cx = contentsX() + frameWidth()*2; 113 cx = contentsX() + frameWidth()*2;
114 cw = contentsWidth() ; 114 cw = contentsWidth() ;
115 // end of workaround 115 // end of workaround
116 116
117 int cell = ((int)(cy/mCellHeight)); 117 int cell = ((int)(cy/mCellHeight));
118 int y = cell * mCellHeight; 118 int y = cell * mCellHeight;
119 QFontMetrics fm = fontMetrics(); 119 QFontMetrics fm = fontMetrics();
120 QString hour; 120 QString hour;
121 QString suffix = "am"; 121 QString suffix = "am";
122 int timeHeight = fm.ascent(); 122 int timeHeight = fm.ascent();
123 QFont nFont = font(); 123 QFont nFont = font();
124 p->setFont( font()); 124 p->setFont( font());
125 125
126 if (!KGlobal::locale()->use12Clock()) { 126 if (!KGlobal::locale()->use12Clock()) {
127 suffix = "00"; 127 suffix = "00";
128 } else 128 } else
129 if (cell > 11) suffix = "pm"; 129 if (cell > 11) suffix = "pm";
130 130
131 if ( timeHeight > mCellHeight ) { 131 if ( timeHeight > mCellHeight ) {
132 timeHeight = mCellHeight-1; 132 timeHeight = mCellHeight-1;
133 int pointS = nFont.pointSize(); 133 int pointS = nFont.pointSize();
134 while ( pointS > 4 ) { 134 while ( pointS > 4 ) {
135 nFont.setPointSize( pointS ); 135 nFont.setPointSize( pointS );
136 fm = QFontMetrics( nFont ); 136 fm = QFontMetrics( nFont );
137 if ( fm.ascent() < mCellHeight ) 137 if ( fm.ascent() < mCellHeight )
138 break; 138 break;
139 -- pointS; 139 -- pointS;
140 } 140 }
141 fm = QFontMetrics( nFont ); 141 fm = QFontMetrics( nFont );
142 timeHeight = fm.ascent(); 142 timeHeight = fm.ascent();
143 } 143 }
144 //timeHeight -= (timeHeight/4-2); 144 //timeHeight -= (timeHeight/4-2);
145 QFont sFont = nFont; 145 QFont sFont = nFont;
146 sFont.setPointSize( sFont.pointSize()/2 ); 146 sFont.setPointSize( sFont.pointSize()/2 );
147 QFontMetrics fmS( sFont ); 147 QFontMetrics fmS( sFont );
148 int sHei = fmS.ascent() ; 148 int sHei = fmS.ascent() ;
149 //sHei -= (sHei/4-2); 149 //sHei -= (sHei/4-2);
150 int startW = mMiniWidth - frameWidth()-2 ; 150 int startW = mMiniWidth - frameWidth()-2 ;
151 int tw2 = fmS.width(suffix); 151 int tw2 = fmS.width(suffix);
152 timeHeight = (timeHeight-1) /2 -1; 152 timeHeight = (timeHeight-1) /2 -1;
153 //testline 153 //testline
154 //p->drawLine(0,0,0,contentsHeight()); 154 //p->drawLine(0,0,0,contentsHeight());
155 while (y < cy + ch+mCellHeight) { 155 while (y < cy + ch+mCellHeight) {
156 p->drawLine(startW-tw2+1 ,y,cw+2,y); 156 p->drawLine(startW-tw2+1 ,y,cw+2,y);
157 hour.setNum(cell); 157 hour.setNum(cell);
158 // handle 24h and am/pm time formats 158 // handle 24h and am/pm time formats
159 if (KGlobal::locale()->use12Clock()) { 159 if (KGlobal::locale()->use12Clock()) {
160 if (cell == 12) suffix = "pm"; 160 if (cell == 12) suffix = "pm";
161 if (cell == 0) hour.setNum(12); 161 if (cell == 0) hour.setNum(12);
162 if (cell > 12) hour.setNum(cell - 12); 162 if (cell > 12) hour.setNum(cell - 12);
163 } 163 }
164 164
165 // center and draw the time label 165 // center and draw the time label
166 int timeWidth = fm.width(hour); 166 int timeWidth = fm.width(hour);
167 int offset = startW - timeWidth - tw2 -1 ; 167 int offset = startW - timeWidth - tw2 -1 ;
168 p->setFont( nFont ); 168 p->setFont( nFont );
169 p->drawText( offset, y+ timeHeight, hour); 169 p->drawText( offset, y+ timeHeight, hour);
170 p->setFont( sFont ); 170 p->setFont( sFont );
171 offset = startW - tw2; 171 offset = startW - tw2;
172 p->drawText( offset, y -1, suffix); 172 p->drawText( offset, y -1, suffix);
173 173
174 // increment indices 174 // increment indices
175 y += mCellHeight; 175 y += mCellHeight;
176 cell++; 176 cell++;
177 } 177 }
178 178
179 179
180 180
181 181
182} 182}
183 183
184/** 184/**
185 Calculates the minimum width. 185 Calculates the minimum width.
186*/ 186*/
187int TimeLabels::minimumWidth() const 187int TimeLabels::minimumWidth() const
188{ 188{
189 return mMiniWidth; 189 return mMiniWidth;
190} 190}
191 191
192/** updates widget's internal state */ 192/** updates widget's internal state */
193void TimeLabels::updateConfig() 193void TimeLabels::updateConfig()
194{ 194{
195 mRedrawNeeded = true; 195 mRedrawNeeded = true;
196 // set the font 196 // set the font
197 // config->setGroup("Fonts"); 197 // config->setGroup("Fonts");
198 // QFont font = config->readFontEntry("TimeBar Font"); 198 // QFont font = config->readFontEntry("TimeBar Font");
199 setFont(KOPrefs::instance()->mTimeBarFont); 199 setFont(KOPrefs::instance()->mTimeBarFont);
200 QString test = "20"; 200 QString test = "20";
201 if (KGlobal::locale()->use12Clock()) 201 if (KGlobal::locale()->use12Clock())
202 test = "12"; 202 test = "12";
203 mMiniWidth = fontMetrics().width(test); 203 mMiniWidth = fontMetrics().width(test);
204 if (KGlobal::locale()->use12Clock()) 204 if (KGlobal::locale()->use12Clock())
205 test = "pm"; 205 test = "pm";
206 else { 206 else {
207 test = "00"; 207 test = "00";
208 } 208 }
209 QFont sFont = font(); 209 QFont sFont = font();
210 sFont.setPointSize( sFont.pointSize()/2 ); 210 sFont.setPointSize( sFont.pointSize()/2 );
211 QFontMetrics fmS( sFont ); 211 QFontMetrics fmS( sFont );
212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; 212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ;
213 // update geometry restrictions based on new settings 213 // update geometry restrictions based on new settings
214 setFixedWidth( mMiniWidth ); 214 setFixedWidth( mMiniWidth );
215 215
216 // update HourSize 216 // update HourSize
217 mCellHeight = KOPrefs::instance()->mHourSize*4; 217 mCellHeight = KOPrefs::instance()->mHourSize*4;
218 resizeContents(mMiniWidth,mRows * mCellHeight+1); 218 resizeContents(mMiniWidth,mRows * mCellHeight+1);
219} 219}
220 220
221/** update time label positions */ 221/** update time label positions */
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 connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); 576 connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) );
577 connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); 577 connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) );
578 578
579 connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) );
580 connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) );
581
582
579 mIdleTimer = new QTimer ( this );; 583 mIdleTimer = new QTimer ( this );;
580 connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); 584 connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout()));
581} 585}
586void KOAgendaView::startIdleTimeout()
587{
588 mIdleStart = QDateTime::currentDateTime();
589 mIdleTimer->start( IDLETIMEOUT * 1000 );
590}
582void KOAgendaView::slotIdleTimeout() 591void KOAgendaView::slotIdleTimeout()
583{ 592{
584 qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); 593 qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) );
585 int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); 594 int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() );
586 mIdleTimer->stop(); 595 mIdleTimer->stop();
587 bool isActice = topLevelWidget()->isActiveWindow(); 596 bool isActice = topLevelWidget()->isActiveWindow();
588 qDebug("KO: Active Window %d ", isActice); 597 qDebug("KO: Active Window %d %d", isActice, isVisible());
589 // we do nothing if we wake up from a suspend 598 // we do nothing if we wake up from a suspend
590 if ( secsfromstart > IDLETIMEOUT + 50 && isActice ) { 599 if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) {
591 qDebug("KO: Wakeup from suspend "); 600 qDebug("KO: Wakeup from suspend ");
592 mIdleTimer->start( IDLETIMEOUT * 1000 ); 601 startIdleTimeout();
593 return; 602 return;
594 } 603 }
595 qDebug("KO: Downsizing Pixmaps "); 604 qDebug("KO: Downsizing Pixmaps ");
596 mAgenda->shrinkPixmap(); 605 mAgenda->shrinkPixmap();
597 mAllDayAgenda->shrinkPixmap(); 606 mAllDayAgenda->shrinkPixmap();
598 KOAgendaItem::paintPix()->resize( 20,20); 607 KOAgendaItem::paintPix()->resize( 20,20);
599 KOAgendaItem::paintPixAllday()->resize( 20,20); 608 KOAgendaItem::paintPixAllday()->resize( 20,20);
600 609
601} 610}
602void KOAgendaView::toggleAllDay() 611void KOAgendaView::toggleAllDay()
603{ 612{
604 if ( mSplitterAgenda->firstHandle() ) 613 if ( mSplitterAgenda->firstHandle() )
605 mSplitterAgenda->firstHandle()->toggle(); 614 mSplitterAgenda->firstHandle()->toggle();
606} 615}
607void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 616void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
608{ 617{
609 calendar()->addIncidence( inc ); 618 calendar()->addIncidence( inc );
610 619
611 if ( incOld ) { 620 if ( incOld ) {
612 if ( incOld->typeID() == todoID ) 621 if ( incOld->typeID() == todoID )
613 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 622 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
614 else 623 else
615 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 624 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
616 } 625 }
617 626
618} 627}
619void KOAgendaView::categoryChanged(Incidence * inc) 628void KOAgendaView::categoryChanged(Incidence * inc)
620{ 629{
621 mAgenda->categoryChanged( inc ); 630 mAgenda->categoryChanged( inc );
622 mAllDayAgenda->categoryChanged( inc ); 631 mAllDayAgenda->categoryChanged( inc );
623} 632}
624KOAgendaView::~KOAgendaView() 633KOAgendaView::~KOAgendaView()
625{ 634{
626 delete mAllAgendaPopup; 635 delete mAllAgendaPopup;
627 //delete mAllDayAgendaPopup; 636 //delete mAllDayAgendaPopup;
628 delete KOAgendaItem::paintPix(); 637 delete KOAgendaItem::paintPix();
629 delete KOAgendaItem::paintPixAllday(); 638 delete KOAgendaItem::paintPixAllday();
630} 639}
631void KOAgendaView::resizeEvent( QResizeEvent* e ) 640void KOAgendaView::resizeEvent( QResizeEvent* e )
632{ 641{
633 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 642 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
634 bool uc = false; 643 bool uc = false;
635 int ow = e->oldSize().width(); 644 int ow = e->oldSize().width();
636 int oh = e->oldSize().height(); 645 int oh = e->oldSize().height();
637 int w = e->size().width(); 646 int w = e->size().width();
638 int h = e->size().height(); 647 int h = e->size().height();
639 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 648 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
640 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 649 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
641 uc = true; 650 uc = true;
642 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 651 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
643 } 652 }
644 mUpcomingWidth = e->size().width() ; 653 mUpcomingWidth = e->size().width() ;
645 if ( mBlockUpdating || uc ) { 654 if ( mBlockUpdating || uc ) {
646 mBlockUpdating = false; 655 mBlockUpdating = false;
647 //mAgenda->setMinimumSize(800 , 600 ); 656 //mAgenda->setMinimumSize(800 , 600 );
648 //qDebug("mAgenda->resize+++++++++++++++ "); 657 //qDebug("mAgenda->resize+++++++++++++++ ");
649 updateConfig(); 658 updateConfig();
650 //qDebug("KOAgendaView::Updating now possible "); 659 //qDebug("KOAgendaView::Updating now possible ");
651 } else 660 } else
652 createDayLabels(); 661 createDayLabels();
653 //qDebug("resizeEvent end "); 662 //qDebug("resizeEvent end ");
654 663
655} 664}
656void KOAgendaView::slotDaylabelClicked( int num ) 665void KOAgendaView::slotDaylabelClicked( int num )
657{ 666{
658 667
659 QDate firstDate = mSelectedDates.first(); 668 QDate firstDate = mSelectedDates.first();
660 if ( num == -1 ) 669 if ( num == -1 )
661 emit showDateView( 6, firstDate ); 670 emit showDateView( 6, firstDate );
662 else if (num >= 0 ) { 671 else if (num >= 0 ) {
663 if ( mSelectedDates.count() == 1) 672 if ( mSelectedDates.count() == 1)
664 emit showDateView( 9, firstDate.addDays( num ) ); 673 emit showDateView( 9, firstDate.addDays( num ) );
665 else 674 else
666 emit showDateView( 3, firstDate.addDays( num ) ); 675 emit showDateView( 3, firstDate.addDays( num ) );
667 } 676 }
668 else 677 else
669 showDateView( 10, firstDate.addDays(1) ); 678 showDateView( 10, firstDate.addDays(1) );
670} 679}
671 680
672KOAgendaButton* KOAgendaView::getNewDaylabel() 681KOAgendaButton* KOAgendaView::getNewDaylabel()
673{ 682{
674 683
675 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 684 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
676 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 685 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
677 mDayLabelsList.append( dayLabel ); 686 mDayLabelsList.append( dayLabel );
678 mLayoutDayLabels->addWidget(dayLabel); 687 mLayoutDayLabels->addWidget(dayLabel);
679 return dayLabel ; 688 return dayLabel ;
680} 689}
681 690
682void KOAgendaView::createDayLabels() 691void KOAgendaView::createDayLabels()
683{ 692{
684 693
685 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 694 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
686 // qDebug(" KOAgendaView::createDayLabels() blocked "); 695 // qDebug(" KOAgendaView::createDayLabels() blocked ");
687 return; 696 return;
688 697
689 } 698 }
690 int newHight; 699 int newHight;
691 if ( !mSelectedDates.count()) 700 if ( !mSelectedDates.count())
692 return; 701 return;
693 702
694 // ### Before deleting and recreating we could check if mSelectedDates changed... 703 // ### Before deleting and recreating we could check if mSelectedDates changed...
695 // It would remove some flickering and gain speed (since this is called by 704 // It would remove some flickering and gain speed (since this is called by
696 // each updateView() call) 705 // each updateView() call)
697 706
698 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 707 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
699 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 708 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
700 if ( maxWid < 20 ) 709 if ( maxWid < 20 )
701 maxWid = 20; 710 maxWid = 20;
702 711
703 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 712 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
704 QFontMetrics fm ( dlf ); 713 QFontMetrics fm ( dlf );
705 dlf.setBold( true ); 714 dlf.setBold( true );
706 int selCount = mSelectedDates.count(); 715 int selCount = mSelectedDates.count();
707 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 716 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
708 QString dayTest = "Mon 20"; 717 QString dayTest = "Mon 20";
709 //QString dayTest = "Mon 20"; 718 //QString dayTest = "Mon 20";
710 int wid = fm.width( dayTest ); 719 int wid = fm.width( dayTest );
711 //maxWid -= ( selCount * 3 ); //working for QLabels 720 //maxWid -= ( selCount * 3 ); //working for QLabels
712 if ( QApplication::desktop()->width() <= 320 ) 721 if ( QApplication::desktop()->width() <= 320 )
713 maxWid -= ( selCount * 3 ); //working for QPushButton 722 maxWid -= ( selCount * 3 ); //working for QPushButton
714 else 723 else
715 maxWid -= ( selCount * 4 ); //working for QPushButton 724 maxWid -= ( selCount * 4 ); //working for QPushButton
716 if ( maxWid < 0 ) 725 if ( maxWid < 0 )
717 maxWid = 20; 726 maxWid = 20;
718 int needWid = wid * selCount; 727 int needWid = wid * selCount;
719 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 728 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
720 //if ( needWid > maxWid ) 729 //if ( needWid > maxWid )
721 // qDebug("DAYLABELS TOOOOOOO BIG "); 730 // qDebug("DAYLABELS TOOOOOOO BIG ");
722 while ( needWid > maxWid ) { 731 while ( needWid > maxWid ) {
723 dayTest = dayTest.left( dayTest.length() - 1 ); 732 dayTest = dayTest.left( dayTest.length() - 1 );
724 wid = fm.width( dayTest ); 733 wid = fm.width( dayTest );
725 needWid = wid * selCount; 734 needWid = wid * selCount;
726 } 735 }
727 int maxLen = dayTest.length(); 736 int maxLen = dayTest.length();
728 int fontPoint = dlf.pointSize(); 737 int fontPoint = dlf.pointSize();
729 if ( maxLen < 2 ) { 738 if ( maxLen < 2 ) {
730 int fontPoint = dlf.pointSize(); 739 int fontPoint = dlf.pointSize();
731 while ( fontPoint > 4 ) { 740 while ( fontPoint > 4 ) {
732 --fontPoint; 741 --fontPoint;
733 dlf.setPointSize( fontPoint ); 742 dlf.setPointSize( fontPoint );
734 QFontMetrics f( dlf ); 743 QFontMetrics f( dlf );
735 wid = f.width( "30" ); 744 wid = f.width( "30" );
736 needWid = wid * selCount; 745 needWid = wid * selCount;
737 if ( needWid < maxWid ) 746 if ( needWid < maxWid )
738 break; 747 break;
739 } 748 }
740 maxLen = 2; 749 maxLen = 2;
741 } 750 }
742 //qDebug("Max len %d ", dayTest.length() ); 751 //qDebug("Max len %d ", dayTest.length() );
743 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) 752 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() )
744 dlf.setBold( false ); 753 dlf.setBold( false );
745 QFontMetrics tempF( dlf ); 754 QFontMetrics tempF( dlf );
746 newHight = tempF.height(); 755 newHight = tempF.height();
747 mDayLabels->setFont( dlf ); 756 mDayLabels->setFont( dlf );
748 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 757 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
749 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 758 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
750 //mLayoutDayLabels->addSpacing( 2 ); 759 //mLayoutDayLabels->addSpacing( 2 );
751 // QFont lFont = dlf; 760 // QFont lFont = dlf;
752 bool appendLabels = false; 761 bool appendLabels = false;
753 KOAgendaButton *dayLabel; 762 KOAgendaButton *dayLabel;
754 dayLabel = mDayLabelsList.first(); 763 dayLabel = mDayLabelsList.first();
755 if ( !dayLabel ) { 764 if ( !dayLabel ) {
756 appendLabels = true; 765 appendLabels = true;
757 dayLabel = getNewDaylabel(); 766 dayLabel = getNewDaylabel();
758 } 767 }
759 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 768 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
760 dayLabel->setFont( dlf ); 769 dayLabel->setFont( dlf );
761 dayLabel->setNum( -1 ); 770 dayLabel->setNum( -1 );
762 //dayLabel->setAlignment(QLabel::AlignHCenter); 771 //dayLabel->setAlignment(QLabel::AlignHCenter);
763 772
764 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 773 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
765 dayLabel->show(); 774 dayLabel->show();
766 DateList::ConstIterator dit; 775 DateList::ConstIterator dit;
767 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 776 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
768 int counter = -1; 777 int counter = -1;
769 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 778 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
770 ++counter; 779 ++counter;
771 QDate date = *dit; 780 QDate date = *dit;
772 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 781 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
773 if ( ! appendLabels ) { 782 if ( ! appendLabels ) {
774 dayLabel = mDayLabelsList.next(); 783 dayLabel = mDayLabelsList.next();
775 if ( !dayLabel ) 784 if ( !dayLabel )
776 appendLabels = true; 785 appendLabels = true;
777 } 786 }
778 if ( appendLabels ) { 787 if ( appendLabels ) {
779 dayLabel = getNewDaylabel(); 788 dayLabel = getNewDaylabel();
780 } 789 }
781 dayLabel->setMinimumWidth( 1 ); 790 dayLabel->setMinimumWidth( 1 );
782 dayLabel->setMaximumWidth( 10240 ); 791 dayLabel->setMaximumWidth( 10240 );
783 dayLabel->setFont( dlf ); 792 dayLabel->setFont( dlf );
784 dayLabel->show(); 793 dayLabel->show();
785 dayLabel->setAutoRepeat( false ); 794 dayLabel->setAutoRepeat( false );
786 dayLabel->setNum( counter ); 795 dayLabel->setNum( counter );
787 QString str; 796 QString str;
788 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 797 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
789 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 798 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
790 switch ( maxLen ) { 799 switch ( maxLen ) {
791 case 2: 800 case 2:
792 str = QString::number( date.day() ); 801 str = QString::number( date.day() );
793 break; 802 break;
794 803
795 case 3: 804 case 3:
796 str = dayName.left( 1 ) +QString::number( date.day()); 805 str = dayName.left( 1 ) +QString::number( date.day());
797 806
798 break; 807 break;
799 case 4: 808 case 4:
800 str = dayName.left( 1 ) + " " +QString::number( date.day()); 809 str = dayName.left( 1 ) + " " +QString::number( date.day());
801 810
802 break; 811 break;
803 case 5: 812 case 5:
804 str = dayName.left( 2 ) + " " +QString::number( date.day()); 813 str = dayName.left( 2 ) + " " +QString::number( date.day());
805 814
806 break; 815 break;
807 case 6: 816 case 6:
808 str = dayName.left( 3 ) + " " +QString::number( date.day()); 817 str = dayName.left( 3 ) + " " +QString::number( date.day());
809 break; 818 break;
810 819
811 default: 820 default:
812 break; 821 break;
813 } 822 }
814 if ( oneday ) { 823 if ( oneday ) {
815 QString addString; 824 QString addString;
816 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 825 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
817 addString = i18n("Today"); 826 addString = i18n("Today");
818 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 827 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
819 addString = i18n("Tomorrow"); 828 addString = i18n("Tomorrow");
820 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 829 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
821 addString = i18n("Yesterday"); 830 addString = i18n("Yesterday");
822 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 831 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
823 addString = i18n("Day before yesterday"); 832 addString = i18n("Day before yesterday");
824 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 833 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
825 addString = i18n("Day after tomorrow"); 834 addString = i18n("Day after tomorrow");
826 if ( !addString.isEmpty() ) { 835 if ( !addString.isEmpty() ) {
827 str = addString+", " + str; 836 str = addString+", " + str;
828 } else { 837 } else {
829 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 838 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
830 } 839 }
831 } 840 }
832 dayLabel->setText(str); 841 dayLabel->setText(str);
833 //dayLabel->setAlignment(QLabel::AlignHCenter); 842 //dayLabel->setAlignment(QLabel::AlignHCenter);
834 if (date == QDate::currentDate()) { 843 if (date == QDate::currentDate()) {
835 QFont bFont = dlf; 844 QFont bFont = dlf;
836 bFont.setBold( true ); 845 bFont.setBold( true );
837 dayLabel->setFont(bFont); 846 dayLabel->setFont(bFont);
838 } 847 }
839 //dayLayout->addWidget(dayLabel); 848 //dayLayout->addWidget(dayLabel);
840 849
841#ifndef KORG_NOPLUGINS 850#ifndef KORG_NOPLUGINS
842 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 851 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
843 CalendarDecoration *it; 852 CalendarDecoration *it;
844 for(it = cds.first(); it; it = cds.next()) { 853 for(it = cds.first(); it; it = cds.next()) {
845 QString text = it->shortText( date ); 854 QString text = it->shortText( date );
846 if ( !text.isEmpty() ) { 855 if ( !text.isEmpty() ) {
847 QLabel *label = new QLabel(text,mDayLabels); 856 QLabel *label = new QLabel(text,mDayLabels);
848 label->setAlignment(AlignCenter); 857 label->setAlignment(AlignCenter);
849 dayLayout->addWidget(label); 858 dayLayout->addWidget(label);
850 } 859 }
851 } 860 }
852 861
853 for(it = cds.first(); it; it = cds.next()) { 862 for(it = cds.first(); it; it = cds.next()) {
854 QWidget *wid = it->smallWidget(mDayLabels,date); 863 QWidget *wid = it->smallWidget(mDayLabels,date);
855 if ( wid ) { 864 if ( wid ) {
856 // wid->setHeight(20); 865 // wid->setHeight(20);
857 dayLayout->addWidget(wid); 866 dayLayout->addWidget(wid);
858 } 867 }
859 } 868 }
860#endif 869#endif
861 } 870 }
862 if ( ! appendLabels ) { 871 if ( ! appendLabels ) {
863 dayLabel = mDayLabelsList.next(); 872 dayLabel = mDayLabelsList.next();
864 if ( !dayLabel ) 873 if ( !dayLabel )
865 appendLabels = true; 874 appendLabels = true;
866 } 875 }
867 if ( appendLabels ) { 876 if ( appendLabels ) {
868 dayLabel = getNewDaylabel(); 877 dayLabel = getNewDaylabel();
869 } 878 }
870 //dayLabel->hide();//test only 879 //dayLabel->hide();//test only
871 880
872 dayLabel->setText(">"); 881 dayLabel->setText(">");
873 dayLabel->setFont( dlf ); 882 dayLabel->setFont( dlf );
874 dayLabel->setAutoRepeat( true ); 883 dayLabel->setAutoRepeat( true );
875 dayLabel->show(); 884 dayLabel->show();
876 dayLabel->setNum( -2 ); 885 dayLabel->setNum( -2 );
877 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); 886 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
878 887
879 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 888 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
880 if ( !appendLabels ) { 889 if ( !appendLabels ) {
881 dayLabel = mDayLabelsList.next(); 890 dayLabel = mDayLabelsList.next();
882 while ( dayLabel ) { 891 while ( dayLabel ) {
883 //qDebug("!dayLabel %d",dayLabel ); 892 //qDebug("!dayLabel %d",dayLabel );
884 dayLabel->hide(); 893 dayLabel->hide();
885 dayLabel = mDayLabelsList.next(); 894 dayLabel = mDayLabelsList.next();
886 } 895 }
887 } 896 }
888 897
889 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 898 mDayLabelsFrame->setFixedHeight( newHight + 4 );
890} 899}
891 900
892int KOAgendaView::maxDatesHint() 901int KOAgendaView::maxDatesHint()
893{ 902{
894 // Not sure about the max number of events, so return 0 for now. 903 // Not sure about the max number of events, so return 0 for now.
895 return 0; 904 return 0;
896} 905}
897 906
898int KOAgendaView::currentDateCount() 907int KOAgendaView::currentDateCount()
899{ 908{
900 return mSelectedDates.count(); 909 return mSelectedDates.count();
901} 910}
902 911
903QPtrList<Incidence> KOAgendaView::selectedIncidences() 912QPtrList<Incidence> KOAgendaView::selectedIncidences()
904{ 913{
905 QPtrList<Incidence> selected; 914 QPtrList<Incidence> selected;
906 Incidence *incidence; 915 Incidence *incidence;
907 916
908 incidence = mAgenda->selectedIncidence(); 917 incidence = mAgenda->selectedIncidence();
909 if (incidence) selected.append(incidence); 918 if (incidence) selected.append(incidence);
910 919
911 incidence = mAllDayAgenda->selectedIncidence(); 920 incidence = mAllDayAgenda->selectedIncidence();
912 if (incidence) selected.append(incidence); 921 if (incidence) selected.append(incidence);
913 922
914 return selected; 923 return selected;
915} 924}
916 925
917DateList KOAgendaView::selectedDates() 926DateList KOAgendaView::selectedDates()
918{ 927{
919 DateList selected; 928 DateList selected;
920 QDate qd; 929 QDate qd;
921 930
922 qd = mAgenda->selectedIncidenceDate(); 931 qd = mAgenda->selectedIncidenceDate();
923 if (qd.isValid()) selected.append(qd); 932 if (qd.isValid()) selected.append(qd);
924 933
925 qd = mAllDayAgenda->selectedIncidenceDate(); 934 qd = mAllDayAgenda->selectedIncidenceDate();
926 if (qd.isValid()) selected.append(qd); 935 if (qd.isValid()) selected.append(qd);
927 936
928 return selected; 937 return selected;
929} 938}
930 939
931 940
932void KOAgendaView::updateView() 941void KOAgendaView::updateView()
933{ 942{
934 if ( mBlockUpdating ) 943 if ( mBlockUpdating )
935 return; 944 return;
936 // kdDebug() << "KOAgendaView::updateView()" << endl; 945 // kdDebug() << "KOAgendaView::updateView()" << endl;
937 fillAgenda(); 946 fillAgenda();
938 947
939} 948}
940 949
941 950
942/* 951/*
943 Update configuration settings for the agenda view. This method is not 952 Update configuration settings for the agenda view. This method is not
944 complete. 953 complete.
945*/ 954*/
946void KOAgendaView::updateConfig() 955void KOAgendaView::updateConfig()
947{ 956{
948 if ( mBlockUpdating ) 957 if ( mBlockUpdating )
949 return; 958 return;
950 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { 959 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
951 int old = KOPrefs::instance()->mHourSize; 960 int old = KOPrefs::instance()->mHourSize;
952 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; 961 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
953 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); 962 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
954 } 963 }
955 964
956 965
957 // update config for children 966 // update config for children
958 mTimeLabels->updateConfig(); 967 mTimeLabels->updateConfig();
959 mAgenda->storePosition(); 968 mAgenda->storePosition();
960 mAgenda->updateConfig(); 969 mAgenda->updateConfig();
961 mAllDayAgenda->updateConfig(); 970 mAllDayAgenda->updateConfig();
962 // widget synchronization 971 // widget synchronization
963 //TODO: find a better way, maybe signal/slot 972 //TODO: find a better way, maybe signal/slot
964 mTimeLabels->positionChanged(); 973 mTimeLabels->positionChanged();
965 974
966 // for some reason, this needs to be called explicitly 975 // for some reason, this needs to be called explicitly
967 mTimeLabels->repaint(); 976 mTimeLabels->repaint();
968 977
969 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 978 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
970 979
971 // ToolTips displaying summary of events 980 // ToolTips displaying summary of events
972 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 981 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
973 ->mEnableToolTips); 982 ->mEnableToolTips);
974 983
975 //setHolidayMasks(); 984 //setHolidayMasks();
976 985
977 //createDayLabels(); called by via updateView(); 986 //createDayLabels(); called by via updateView();
978 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 987 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
979 updateView(); 988 updateView();
980 mAgenda->restorePosition(); 989 mAgenda->restorePosition();
981} 990}
982 991
983 992
984void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 993void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
985{ 994{
986 995
987 996
988 int xxx = item->cellX(); 997 int xxx = item->cellX();
989 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); 998 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() );
990 if ( mMinY.at(xxx) > item->cellYTop() ) 999 if ( mMinY.at(xxx) > item->cellYTop() )
991 mMinY.at(xxx) = item->cellYTop(); 1000 mMinY.at(xxx) = item->cellYTop();
992 if ( mMaxY.at(xxx) < item->cellYBottom() ) 1001 if ( mMaxY.at(xxx) < item->cellYBottom() )
993 mMaxY.at(xxx) = item->cellYBottom(); 1002 mMaxY.at(xxx) = item->cellYBottom();
994 1003
995 QDateTime startDt,endDt; 1004 QDateTime startDt,endDt;
996 QDate startDate; 1005 QDate startDate;
997 int lenInSecs; 1006 int lenInSecs;
998 // if ( type == KOAgenda::RESIZETOP ) 1007 // if ( type == KOAgenda::RESIZETOP )
999 // qDebug("RESIZETOP "); 1008 // qDebug("RESIZETOP ");
1000 // if ( type == KOAgenda::RESIZEBOTTOM ) 1009 // if ( type == KOAgenda::RESIZEBOTTOM )
1001 // qDebug("RESIZEBOTTOM "); 1010 // qDebug("RESIZEBOTTOM ");
1002 // if ( type == KOAgenda::MOVE ) 1011 // if ( type == KOAgenda::MOVE )
1003 // qDebug("MOVE "); 1012 // qDebug("MOVE ");
1004 if ( item->incidence()->typeID() == eventID ) { 1013 if ( item->incidence()->typeID() == eventID ) {
1005 startDt =item->incidence()->dtStart(); 1014 startDt =item->incidence()->dtStart();
1006 endDt = item->incidence()->dtEnd(); 1015 endDt = item->incidence()->dtEnd();
1007 lenInSecs = startDt.secsTo( endDt ); 1016 lenInSecs = startDt.secsTo( endDt );
1008 } 1017 }
1009 1018
1010 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 1019 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
1011 1020
1012 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { 1021 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) {
1013 startDate = mSelectedDates[item->mLastMoveXPos]; 1022 startDate = mSelectedDates[item->mLastMoveXPos];
1014 } else { 1023 } else {
1015 if (item->cellX() < 0) { 1024 if (item->cellX() < 0) {
1016 startDate = (mSelectedDates.first()).addDays(item->cellX()); 1025 startDate = (mSelectedDates.first()).addDays(item->cellX());
1017 } else { 1026 } else {
1018 startDate = mSelectedDates[item->cellX()]; 1027 startDate = mSelectedDates[item->cellX()];
1019 } 1028 }
1020 } 1029 }
1021 startDt.setDate(startDate); 1030 startDt.setDate(startDate);
1022 1031
1023 if (item->incidence()->doesFloat()) { 1032 if (item->incidence()->doesFloat()) {
1024 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 1033 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
1025 } else { 1034 } else {
1026 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 1035 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
1027 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 1036 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
1028 if ( item->incidence()->typeID() == eventID ) { 1037 if ( item->incidence()->typeID() == eventID ) {
1029 if ( type == KOAgenda::MOVE ) { 1038 if ( type == KOAgenda::MOVE ) {
1030 endDt = startDt.addSecs(lenInSecs); 1039 endDt = startDt.addSecs(lenInSecs);
1031 1040
1032 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 1041 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
1033 if (item->lastMultiItem()) { 1042 if (item->lastMultiItem()) {
1034 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1043 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1035 endDt.setDate(startDate. 1044 endDt.setDate(startDate.
1036 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1045 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1037 } else { 1046 } else {
1038 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1047 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1039 endDt.setDate(startDate); 1048 endDt.setDate(startDate);
1040 } 1049 }
1041 } 1050 }
1042 } else { 1051 } else {
1043 // todo 1052 // todo
1044 if (item->lastMultiItem()) { 1053 if (item->lastMultiItem()) {
1045 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1054 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1046 endDt.setDate(startDate. 1055 endDt.setDate(startDate.
1047 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1056 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1048 } else { 1057 } else {
1049 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 1058 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
1050 if ( item->cellYBottom() > 0 ) 1059 if ( item->cellYBottom() > 0 )
1051 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1060 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1052 else 1061 else
1053 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 1062 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
1054 endDt.setDate(startDate); 1063 endDt.setDate(startDate);
1055 } 1064 }
1056 } 1065 }
1057 } 1066 }
1058 if ( item->incidence()->typeID() == eventID ) { 1067 if ( item->incidence()->typeID() == eventID ) {
1059 item->incidence()->setDtStart(startDt); 1068 item->incidence()->setDtStart(startDt);
1060 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1069 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1061 } else if ( item->incidence()->typeID() == todoID ) { 1070 } else if ( item->incidence()->typeID() == todoID ) {
1062 Todo* to = static_cast<Todo*>(item->incidence()); 1071 Todo* to = static_cast<Todo*>(item->incidence());
1063 1072
1064 to->setDtDue(endDt); 1073 to->setDtDue(endDt);
1065 if ( to->hasStartDate() ) { 1074 if ( to->hasStartDate() ) {
1066 if (to->dtStart() >= to->dtDue() ) 1075 if (to->dtStart() >= to->dtDue() )
1067 to->setDtStart(to->dtDue().addDays( -2 )); 1076 to->setDtStart(to->dtDue().addDays( -2 ));
1068 } 1077 }
1069 1078
1070 } 1079 }
1071 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1080 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1072 item->incidence()->setRevision(item->incidence()->revision()+1); 1081 item->incidence()->setRevision(item->incidence()->revision()+1);
1073 item->setItemDate(startDt.date()); 1082 item->setItemDate(startDt.date());
1074 //item->updateItem(); 1083 //item->updateItem();
1075 if ( item->incidence()->typeID() == todoID ) { 1084 if ( item->incidence()->typeID() == todoID ) {
1076 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1085 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1077 1086
1078 } 1087 }
1079 else 1088 else
1080 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1089 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1081 item->updateItem(); 1090 item->updateItem();
1082} 1091}
1083 1092
1084void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1093void KOAgendaView::showDates( const QDate &start, const QDate &end )
1085{ 1094{
1086 // kdDebug() << "KOAgendaView::selectDates" << endl; 1095 // kdDebug() << "KOAgendaView::selectDates" << endl;
1087 1096
1088 mSelectedDates.clear(); 1097 mSelectedDates.clear();
1089 // qDebug("KOAgendaView::showDates "); 1098 // qDebug("KOAgendaView::showDates ");
1090 QDate d = start; 1099 QDate d = start;
1091 while (d <= end) { 1100 while (d <= end) {
1092 mSelectedDates.append(d); 1101 mSelectedDates.append(d);
1093 d = d.addDays( 1 ); 1102 d = d.addDays( 1 );
1094 } 1103 }
1095 1104
1096 // and update the view 1105 // and update the view
1097 fillAgenda(); 1106 fillAgenda();
1098} 1107}
1099 1108
1100 1109
1101void KOAgendaView::showEvents(QPtrList<Event>) 1110void KOAgendaView::showEvents(QPtrList<Event>)
1102{ 1111{
1103 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1112 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1104} 1113}
1105 1114
1106void KOAgendaView::changeEventDisplay(Event *, int) 1115void KOAgendaView::changeEventDisplay(Event *, int)
1107{ 1116{
1108 // qDebug("KOAgendaView::changeEventDisplay "); 1117 // qDebug("KOAgendaView::changeEventDisplay ");
1109 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1118 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1110 // this should be re-written to be MUCH smarter. Right now we 1119 // this should be re-written to be MUCH smarter. Right now we
1111 // are just playing dumb. 1120 // are just playing dumb.
1112 fillAgenda(); 1121 fillAgenda();
1113} 1122}
1114 1123
1115void KOAgendaView::fillAgenda(const QDate &) 1124void KOAgendaView::fillAgenda(const QDate &)
1116{ 1125{
1117 // qDebug("KOAgendaView::fillAgenda "); 1126 // qDebug("KOAgendaView::fillAgenda ");
1118 fillAgenda(); 1127 fillAgenda();
1119} 1128}
1120 1129
1121void KOAgendaView::fillAgenda() 1130void KOAgendaView::fillAgenda()
1122{ 1131{
1123 if ( globalFlagBlockStartup ) 1132 if ( globalFlagBlockStartup )
1124 return; 1133 return;
1125 if ( globalFlagBlockAgenda == 1 ) 1134 if ( globalFlagBlockAgenda == 1 )
1126 return; 1135 return;
1127 static bool onlyOne = false; 1136 static bool onlyOne = false;
1128 if ( onlyOne ) 1137 if ( onlyOne )
1129 return; 1138 return;
1130 onlyOne = true; 1139 onlyOne = true;
1131 //if ( globalFlagBlockAgenda == 2 ) 1140 //if ( globalFlagBlockAgenda == 2 )
1132 //globalFlagBlockAgenda = 0; 1141 //globalFlagBlockAgenda = 0;
1133 // globalFlagBlockPainting = false; 1142 // globalFlagBlockPainting = false;
1134 if ( globalFlagBlockAgenda == 0 ) 1143 if ( globalFlagBlockAgenda == 0 )
1135 globalFlagBlockAgenda = 1; 1144 globalFlagBlockAgenda = 1;
1136 // clearView(); 1145 // clearView();
1137 //qDebug("fillAgenda()++++ "); 1146 //qDebug("fillAgenda()++++ ");
1138 globalFlagBlockAgendaItemPaint = 1; 1147 globalFlagBlockAgendaItemPaint = 1;
1139 1148
1140 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1149 mAllDayAgenda->changeColumns(mSelectedDates.count());
1141 mAgenda->changeColumns(mSelectedDates.count()); 1150 mAgenda->changeColumns(mSelectedDates.count());
1142 qApp->processEvents(); 1151 qApp->processEvents();
1143 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1152 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1144 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1153 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1145 setHolidayMasks(); 1154 setHolidayMasks();
1146 1155
1147 mMinY.resize(mSelectedDates.count()); 1156 mMinY.resize(mSelectedDates.count());
1148 mMaxY.resize(mSelectedDates.count()); 1157 mMaxY.resize(mSelectedDates.count());
1149 1158
1150 QPtrList<Event> dayEvents; 1159 QPtrList<Event> dayEvents;
1151 1160
1152 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1161 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1153 // Therefore, gtodoset all of them. 1162 // Therefore, gtodoset all of them.
1154 QPtrList<Todo> todos = calendar()->todos(); 1163 QPtrList<Todo> todos = calendar()->todos();
1155 1164
1156 mAgenda->setDateList(mSelectedDates); 1165 mAgenda->setDateList(mSelectedDates);
1157 1166
1158 QDate today = QDate::currentDate(); 1167 QDate today = QDate::currentDate();
1159 1168
1160 DateList::ConstIterator dit; 1169 DateList::ConstIterator dit;
1161 int curCol = 0; 1170 int curCol = 0;
1162 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1171 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1163 QDate currentDate = *dit; 1172 QDate currentDate = *dit;
1164 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1173 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1165 // << endl; 1174 // << endl;
1166 1175
1167 dayEvents = calendar()->events(currentDate,false); 1176 dayEvents = calendar()->events(currentDate,false);
1168 1177
1169 // Default values, which can never be reached 1178 // Default values, which can never be reached
1170 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1179 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1171 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1180 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1172 1181
1173 unsigned int numEvent; 1182 unsigned int numEvent;
1174 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1183 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1175 Event *event = dayEvents.at(numEvent); 1184 Event *event = dayEvents.at(numEvent);
1176 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1185 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1177 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1186 if ( event->uid().left(15) == QString("last-syncEvent-") )
1178 continue; 1187 continue;
1179 // kdDebug() << " Event: " << event->summary() << endl; 1188 // kdDebug() << " Event: " << event->summary() << endl;
1180 1189
1181 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1190 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1182 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1191 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1183 1192
1184 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1193 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1185 1194
1186 if (event->doesFloat()) { 1195 if (event->doesFloat()) {
1187 if (event->recurrence()->doesRecur()) { 1196 if (event->recurrence()->doesRecur()) {
1188 if (event->isMultiDay() ) { 1197 if (event->isMultiDay() ) {
1189 endX = endX - beginX;// endX is now number of days 1198 endX = endX - beginX;// endX is now number of days
1190 if ( event->recursOn( currentDate ) ) { 1199 if ( event->recursOn( currentDate ) ) {
1191 endX += curCol; 1200 endX += curCol;
1192 beginX = curCol; 1201 beginX = curCol;
1193 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1202 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1194 } else { 1203 } else {
1195 //qDebug("days %d %s",endX , currentDate.toString().latin1()); 1204 //qDebug("days %d %s",endX , currentDate.toString().latin1());
1196 QDate dateit = currentDate.addDays( -endX ); 1205 QDate dateit = currentDate.addDays( -endX );
1197 if ( event->recursOn( dateit ) ) { 1206 if ( event->recursOn( dateit ) ) {
1198 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); 1207 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
1199 if ( curCol-endX < 0 ) { 1208 if ( curCol-endX < 0 ) {
1200 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1209 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1201 } 1210 }
1202 } 1211 }
1203 } 1212 }
1204 } else { 1213 } else {
1205 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1214 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1206 } 1215 }
1207 1216
1208 } else { 1217 } else {
1209 if (beginX <= 0 && curCol == 0) { 1218 if (beginX <= 0 && curCol == 0) {
1210 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1219 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1211 } else if (beginX == curCol) { 1220 } else if (beginX == curCol) {
1212 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1221 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1213 } 1222 }
1214 } 1223 }
1215 } else if (event->isMultiDay()) { 1224 } else if (event->isMultiDay()) {
1216 if ( event->doesRecur () ) { 1225 if ( event->doesRecur () ) {
1217 QDate dateit = currentDate; 1226 QDate dateit = currentDate;
1218 int count = 0; 1227 int count = 0;
1219 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1228 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1220 while (! event->recursOn( dateit ) && count <= max ) { 1229 while (! event->recursOn( dateit ) && count <= max ) {
1221 ++count; 1230 ++count;
1222 dateit = dateit.addDays( -1 ); 1231 dateit = dateit.addDays( -1 );
1223 } 1232 }
1224 bool ok; 1233 bool ok;
1225 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1234 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1226 if ( ok ) 1235 if ( ok )
1227 { 1236 {
1228 int secs = event->dtStart().secsTo( event->dtEnd() ); 1237 int secs = event->dtStart().secsTo( event->dtEnd() );
1229 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1238 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1230 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1239 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1231 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1240 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1232 1241
1233 } 1242 }
1234 } 1243 }
1235 int startY = mAgenda->timeToY(event->dtStart().time()); 1244 int startY = mAgenda->timeToY(event->dtStart().time());
1236 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1245 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1237 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1246 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1238 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1247 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1239 //qDebug("insert!!! "); 1248 //qDebug("insert!!! ");
1240 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1249 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1241 } 1250 }
1242 if (beginX == curCol) { 1251 if (beginX == curCol) {
1243 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1252 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1244 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1253 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1245 } else if (endX == curCol) { 1254 } else if (endX == curCol) {
1246 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1255 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1247 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1256 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1248 } else { 1257 } else {
1249 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1258 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1250 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1259 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1251 } 1260 }
1252 } else { 1261 } else {
1253 int startY = mAgenda->timeToY(event->dtStart().time()); 1262 int startY = mAgenda->timeToY(event->dtStart().time());
1254 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1263 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1255 if (endY < startY) endY = startY; 1264 if (endY < startY) endY = startY;
1256 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1265 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1257 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1266 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1258 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1267 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1259 } 1268 }
1260 } 1269 }
1261 // ---------- [display Todos -------------- 1270 // ---------- [display Todos --------------
1262 unsigned int numTodo; 1271 unsigned int numTodo;
1263 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1272 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1264 Todo *todo = todos.at(numTodo); 1273 Todo *todo = todos.at(numTodo);
1265 1274
1266 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1275 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1267 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; 1276 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue;
1268 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1277 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1269 // Already completed items can be displayed on their original due date 1278 // Already completed items can be displayed on their original due date
1270 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1279 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1271 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1280 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1272 bool fillIn = false; 1281 bool fillIn = false;
1273 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1282 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1274 fillIn = true; 1283 fillIn = true;
1275 if ( ! fillIn && !todo->hasCompletedDate() ) 1284 if ( ! fillIn && !todo->hasCompletedDate() )
1276 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1285 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1277 if ( fillIn ) { 1286 if ( fillIn ) {
1278 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1287 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1279 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1288 if ( KOPrefs::instance()->mShowTodoInAgenda )
1280 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1289 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1281 } 1290 }
1282 else { 1291 else {
1283 QDateTime dt; 1292 QDateTime dt;
1284 if ( todo->hasCompletedDate() ) 1293 if ( todo->hasCompletedDate() )
1285 dt = todo->completed(); 1294 dt = todo->completed();
1286 else 1295 else
1287 dt = todo->dtDue();; 1296 dt = todo->dtDue();;
1288 1297
1289 1298
1290 int endY = mAgenda->timeToY(dt.time()) - 1; 1299 int endY = mAgenda->timeToY(dt.time()) - 1;
1291 int hi = (18/KOPrefs::instance()->mHourSize); 1300 int hi = (18/KOPrefs::instance()->mHourSize);
1292 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1301 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1293 int startY = endY -hi; 1302 int startY = endY -hi;
1294 1303
1295 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1304 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1296 1305
1297 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1306 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1298 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1307 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1299 } 1308 }
1300 } 1309 }
1301 } 1310 }
1302 // ---------- display Todos] -------------- 1311 // ---------- display Todos] --------------
1303 1312
1304 ++curCol; 1313 ++curCol;
1305 } 1314 }
1306 mAgenda->hideUnused(); 1315 mAgenda->hideUnused();
1307 mAllDayAgenda->hideUnused(); 1316 mAllDayAgenda->hideUnused();
1308 mAgenda->checkScrollBoundaries(); 1317 mAgenda->checkScrollBoundaries();
1309 deleteSelectedDateTime(); 1318 deleteSelectedDateTime();
1310 createDayLabels(); 1319 createDayLabels();
1311 emit incidenceSelected( 0 ); 1320 emit incidenceSelected( 0 );
1312 1321
1313 if ( globalFlagBlockAgenda == 2 ) { 1322 if ( globalFlagBlockAgenda == 2 ) {
1314 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1323 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1315 setStartHour( KOPrefs::instance()->mDayBegins ); 1324 setStartHour( KOPrefs::instance()->mDayBegins );
1316 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1325 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1317 setStartHour( QTime::currentTime ().hour() ); 1326 setStartHour( QTime::currentTime ().hour() );
1318 } 1327 }
1319 qApp->processEvents(); 1328 qApp->processEvents();
1320 globalFlagBlockAgenda = 0; 1329 globalFlagBlockAgenda = 0;
1321 mAllDayAgenda->drawContentsToPainter(); 1330 mAllDayAgenda->drawContentsToPainter();
1322 mAgenda->drawContentsToPainter(); 1331 mAgenda->drawContentsToPainter();
1323 repaintAgenda(); 1332 repaintAgenda();
1324 mIdleTimer->start ( IDLETIMEOUT *1000 ); 1333 startIdleTimeout();
1325 mIdleStart = QDateTime::currentDateTime();
1326 onlyOne = false; 1334 onlyOne = false;
1327} 1335}
1328void KOAgendaView::repaintAgenda() 1336void KOAgendaView::repaintAgenda()
1329{ 1337{
1330 mAgenda->viewport()->repaint( false ); 1338 mAgenda->viewport()->repaint( false );
1331 mAllDayAgenda->viewport()->repaint( false ); 1339 mAllDayAgenda->viewport()->repaint( false );
1332 mAgenda->finishUpdate(); 1340 mAgenda->finishUpdate();
1333 mAllDayAgenda->finishUpdate(); 1341 mAllDayAgenda->finishUpdate();
1334} 1342}
1335 1343
1336 1344
1337void KOAgendaView::clearView() 1345void KOAgendaView::clearView()
1338{ 1346{
1339 mAllDayAgenda->clear(); 1347 mAllDayAgenda->clear();
1340 mAgenda->clear(); 1348 mAgenda->clear();
1341} 1349}
1342void KOAgendaView::clearList() 1350void KOAgendaView::clearList()
1343{ 1351{
1344 clearView(); 1352 clearView();
1345 mAllDayAgenda->hideUnused(); 1353 mAllDayAgenda->hideUnused();
1346 mAgenda->hideUnused(); 1354 mAgenda->hideUnused();
1347} 1355}
1348 1356
1349void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1357void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1350 const QDate &td) 1358 const QDate &td)
1351{ 1359{
1352#ifndef KORG_NOPRINTER 1360#ifndef KORG_NOPRINTER
1353 if (fd == td) 1361 if (fd == td)
1354 calPrinter->preview(CalPrinter::Day, fd, td); 1362 calPrinter->preview(CalPrinter::Day, fd, td);
1355 else 1363 else
1356 calPrinter->preview(CalPrinter::Week, fd, td); 1364 calPrinter->preview(CalPrinter::Week, fd, td);
1357#endif 1365#endif
1358} 1366}
1359 1367
1360// void KOAgendaView::updateMovedTodo() 1368// void KOAgendaView::updateMovedTodo()
1361// { 1369// {
1362// // updateConfig(); 1370// // updateConfig();
1363// // emit updateTodoViews(); 1371// // emit updateTodoViews();
1364// } 1372// }
1365 1373
1366void KOAgendaView::slotShowDateView( int mode , int d ) 1374void KOAgendaView::slotShowDateView( int mode , int d )
1367{ 1375{
1368 if ( d >= mSelectedDates.count() ) { 1376 if ( d >= mSelectedDates.count() ) {
1369 qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); 1377 qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() );
1370 1378
1371 } else { 1379 } else {
1372 QDate day = mSelectedDates[d]; 1380 QDate day = mSelectedDates[d];
1373 emit showDateView(mode , day ); 1381 emit showDateView(mode , day );
1374 } 1382 }
1375 1383
1376} 1384}
1377void KOAgendaView::newEvent(int gx, int gy) 1385void KOAgendaView::newEvent(int gx, int gy)
1378{ 1386{
1379 if (!mSelectedDates.count()) return; 1387 if (!mSelectedDates.count()) return;
1380 1388
1381 QDate day = mSelectedDates[gx]; 1389 QDate day = mSelectedDates[gx];
1382 1390
1383 QTime time = mAgenda->gyToTime(gy); 1391 QTime time = mAgenda->gyToTime(gy);
1384 QDateTime dt(day,time); 1392 QDateTime dt(day,time);
1385 // if ( dt < QDateTime::currentDateTime () ) 1393 // if ( dt < QDateTime::currentDateTime () )
1386 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1394 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1387 emit newEventSignal(dt); 1395 emit newEventSignal(dt);
1388} 1396}
1389 1397
1390void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1398void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1391{ 1399{
1392 if (!mSelectedDates.count()) return; 1400 if (!mSelectedDates.count()) return;
1393 1401
1394 QDate dayStart = mSelectedDates[gxStart]; 1402 QDate dayStart = mSelectedDates[gxStart];
1395 QDate dayEnd = mSelectedDates[gxEnd]; 1403 QDate dayEnd = mSelectedDates[gxEnd];
1396 1404
1397 QTime timeStart = mAgenda->gyToTime(gyStart); 1405 QTime timeStart = mAgenda->gyToTime(gyStart);
1398 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1406 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1399 1407
1400 QDateTime dtStart(dayStart,timeStart); 1408 QDateTime dtStart(dayStart,timeStart);
1401 QDateTime dtEnd(dayEnd,timeEnd); 1409 QDateTime dtEnd(dayEnd,timeEnd);
1402 1410
1403 emit newEventSignal(dtStart,dtEnd); 1411 emit newEventSignal(dtStart,dtEnd);
1404} 1412}
1405 1413
1406void KOAgendaView::newEventAllDay(int gx, int ) 1414void KOAgendaView::newEventAllDay(int gx, int )
1407{ 1415{
1408 if (!mSelectedDates.count()) return; 1416 if (!mSelectedDates.count()) return;
1409 1417
1410 QDate day = mSelectedDates[gx]; 1418 QDate day = mSelectedDates[gx];
1411 1419
1412 emit newEventSignal(day); 1420 emit newEventSignal(day);
1413} 1421}
1414void KOAgendaView::newTodoAllDay(int gx, int ) 1422void KOAgendaView::newTodoAllDay(int gx, int )
1415{ 1423{
1416 if (!mSelectedDates.count()) return; 1424 if (!mSelectedDates.count()) return;
1417 1425
1418 QDateTime day (mSelectedDates[gx] ); 1426 QDateTime day (mSelectedDates[gx] );
1419 emit newTodoSignal(day, true); 1427 emit newTodoSignal(day, true);
1420} 1428}
1421void KOAgendaView::newTodo(int gx, int gy ) 1429void KOAgendaView::newTodo(int gx, int gy )
1422{ 1430{
1423 if (!mSelectedDates.count()) return; 1431 if (!mSelectedDates.count()) return;
1424 QDate dayStart = mSelectedDates[gx]; 1432 QDate dayStart = mSelectedDates[gx];
1425 QTime timeStart = mAgenda->gyToTime(gy); 1433 QTime timeStart = mAgenda->gyToTime(gy);
1426 QDateTime dt (dayStart,timeStart); 1434 QDateTime dt (dayStart,timeStart);
1427 emit newTodoSignal( dt, false ); 1435 emit newTodoSignal( dt, false );
1428} 1436}
1429 1437
1430void KOAgendaView::updateEventIndicatorTop(int newY) 1438void KOAgendaView::updateEventIndicatorTop(int newY)
1431{ 1439{
1432 uint i; 1440 uint i;
1433 for(i=0;i<mMinY.size();++i) { 1441 for(i=0;i<mMinY.size();++i) {
1434 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1442 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1435 else mEventIndicatorTop->enableColumn(i,false); 1443 else mEventIndicatorTop->enableColumn(i,false);
1436 } 1444 }
1437 1445
1438 mEventIndicatorTop->update(); 1446 mEventIndicatorTop->update();
1439} 1447}
1440 1448
1441void KOAgendaView::updateEventIndicatorBottom(int newY) 1449void KOAgendaView::updateEventIndicatorBottom(int newY)
1442{ 1450{
1443 uint i; 1451 uint i;
1444 for(i=0;i<mMaxY.size();++i) { 1452 for(i=0;i<mMaxY.size();++i) {
1445 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1453 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1446 else mEventIndicatorBottom->enableColumn(i,false); 1454 else mEventIndicatorBottom->enableColumn(i,false);
1447 } 1455 }
1448 1456
1449 mEventIndicatorBottom->update(); 1457 mEventIndicatorBottom->update();
1450} 1458}
1451 1459
1452void KOAgendaView::startDrag(Event *event) 1460void KOAgendaView::startDrag(Event *event)
1453{ 1461{
1454#ifndef KORG_NODND 1462#ifndef KORG_NODND
1455 DndFactory factory( calendar() ); 1463 DndFactory factory( calendar() );
1456 ICalDrag *vd = factory.createDrag(event,this); 1464 ICalDrag *vd = factory.createDrag(event,this);
1457 if (vd->drag()) { 1465 if (vd->drag()) {
1458 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1466 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1459 } 1467 }
1460#endif 1468#endif
1461} 1469}
1462 1470
1463void KOAgendaView::readSettings() 1471void KOAgendaView::readSettings()
1464{ 1472{
1465 readSettings(KOGlobals::config()); 1473 readSettings(KOGlobals::config());
1466} 1474}
1467 1475
1468void KOAgendaView::readSettings(KConfig *config) 1476void KOAgendaView::readSettings(KConfig *config)
1469{ 1477{
1470 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1478 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1471 1479
1472 config->setGroup("Views"); 1480 config->setGroup("Views");
1473 1481
1474 //#ifndef KORG_NOSPLITTER 1482 //#ifndef KORG_NOSPLITTER
1475 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1483 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1476 if (sizes.count() == 2) { 1484 if (sizes.count() == 2) {
1477 if ( sizes[0] < 20 ) { 1485 if ( sizes[0] < 20 ) {
1478 sizes[1] = sizes[1] +20 - sizes[0]; 1486 sizes[1] = sizes[1] +20 - sizes[0];
1479 sizes[0] = 20; 1487 sizes[0] = 20;
1480 } 1488 }
1481 mSplitterAgenda->setSizes(sizes); 1489 mSplitterAgenda->setSizes(sizes);
1482 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1490 // qDebug("read %d %d ",sizes[0],sizes[1] );
1483 } 1491 }
1484 //#endif 1492 //#endif
1485 1493
1486 // updateConfig(); 1494 // updateConfig();
1487} 1495}
1488 1496
1489void KOAgendaView::writeSettings(KConfig *config) 1497void KOAgendaView::writeSettings(KConfig *config)
1490{ 1498{
1491 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1499 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1492 1500
1493 config->setGroup("Views"); 1501 config->setGroup("Views");
1494 1502
1495 //#ifndef KORG_NOSPLITTER 1503 //#ifndef KORG_NOSPLITTER
1496 QValueList<int> list = mSplitterAgenda->sizes(); 1504 QValueList<int> list = mSplitterAgenda->sizes();
1497 config->writeEntry("Separator AgendaView",list); 1505 config->writeEntry("Separator AgendaView",list);
1498 //qDebug("write %d %d ", list[0],list[1] ); 1506 //qDebug("write %d %d ", list[0],list[1] );
1499 //#endif 1507 //#endif
1500} 1508}
1501 1509
1502void KOAgendaView::setHolidayMasks() 1510void KOAgendaView::setHolidayMasks()
1503{ 1511{
1504 mHolidayMask.resize(mSelectedDates.count()); 1512 mHolidayMask.resize(mSelectedDates.count());
1505 1513
1506 uint i; 1514 uint i;
1507 for(i=0;i<mSelectedDates.count();++i) { 1515 for(i=0;i<mSelectedDates.count();++i) {
1508 QDate date = mSelectedDates[i]; 1516 QDate date = mSelectedDates[i];
1509 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1517 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1510 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1518 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1511 bool showHoliday = false; 1519 bool showHoliday = false;
1512 if ( KOPrefs::instance()->mExcludeHolidays ) { 1520 if ( KOPrefs::instance()->mExcludeHolidays ) {
1513 QPtrList<Event> events = calendar()->events( date, true ); 1521 QPtrList<Event> events = calendar()->events( date, true );
1514 Event *event; 1522 Event *event;
1515 for( event = events.first(); event; event = events.next() ) { 1523 for( event = events.first(); event; event = events.next() ) {
1516 if ( event->isHoliday()) { 1524 if ( event->isHoliday()) {
1517 showHoliday = true; 1525 showHoliday = true;
1518 break; 1526 break;
1519 } 1527 }
1520 } 1528 }
1521 1529
1522 } 1530 }
1523 1531
1524#ifndef KORG_NOPLUGINS 1532#ifndef KORG_NOPLUGINS
1525 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1533 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1526 !KOCore::self()->holiday(date).isEmpty(); 1534 !KOCore::self()->holiday(date).isEmpty();
1527#endif 1535#endif
1528 bool showDay = showSaturday || showSunday || showHoliday; 1536 bool showDay = showSaturday || showSunday || showHoliday;
1529 1537
1530 if (showDay) { 1538 if (showDay) {
1531 mHolidayMask.at(i) = true; 1539 mHolidayMask.at(i) = true;
1532 } else { 1540 } else {
1533 mHolidayMask.at(i) = false; 1541 mHolidayMask.at(i) = false;
1534 } 1542 }
1535 } 1543 }
1536 1544
1537 mAgenda->setHolidayMask(&mHolidayMask); 1545 mAgenda->setHolidayMask(&mHolidayMask);
1538 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1546 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1539} 1547}
1540 1548
1541void KOAgendaView::setContentsPos(int y) 1549void KOAgendaView::setContentsPos(int y)
1542{ 1550{
1543 mAgenda->setContentsPos(0,y); 1551 mAgenda->setContentsPos(0,y);
1544} 1552}
1545 1553
1546void KOAgendaView::clearSelection() 1554void KOAgendaView::clearSelection()
1547{ 1555{
1548 mAgenda->deselectItem(); 1556 mAgenda->deselectItem();
1549 mAllDayAgenda->deselectItem(); 1557 mAllDayAgenda->deselectItem();
1550} 1558}
1551 1559
1552void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1560void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1553 int gxEnd, int gyEnd) 1561 int gxEnd, int gyEnd)
1554{ 1562{
1555 mTimeSpanInAllDay = true; 1563 mTimeSpanInAllDay = true;
1556 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1564 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1557} 1565}
1558 1566
1559 1567
1560 1568
1561 1569
1562void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1570void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1563 int gxEnd, int gyEnd) 1571 int gxEnd, int gyEnd)
1564{ 1572{
1565 if (!mSelectedDates.count()) return; 1573 if (!mSelectedDates.count()) return;
1566 1574
1567 QDate dayStart = mSelectedDates[gxStart]; 1575 QDate dayStart = mSelectedDates[gxStart];
1568 QDate dayEnd = mSelectedDates[gxEnd]; 1576 QDate dayEnd = mSelectedDates[gxEnd];
1569 1577
1570 QTime timeStart = mAgenda->gyToTime(gyStart); 1578 QTime timeStart = mAgenda->gyToTime(gyStart);
1571 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1579 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1572 1580
1573 QDateTime dtStart(dayStart,timeStart); 1581 QDateTime dtStart(dayStart,timeStart);
1574 QDateTime dtEnd(dayEnd,timeEnd); 1582 QDateTime dtEnd(dayEnd,timeEnd);
1575 1583
1576 mTimeSpanBegin = dtStart; 1584 mTimeSpanBegin = dtStart;
1577 mTimeSpanEnd = dtEnd; 1585 mTimeSpanEnd = dtEnd;
1578 1586
1579} 1587}
1580 1588
1581void KOAgendaView::deleteSelectedDateTime() 1589void KOAgendaView::deleteSelectedDateTime()
1582{ 1590{
1583 mTimeSpanBegin.setDate(QDate()); 1591 mTimeSpanBegin.setDate(QDate());
1584 mTimeSpanEnd.setDate(QDate()); 1592 mTimeSpanEnd.setDate(QDate());
1585 mTimeSpanInAllDay = false; 1593 mTimeSpanInAllDay = false;
1586} 1594}
1587 1595
1588void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1596void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1589{ 1597{
1590 e->ignore(); 1598 e->ignore();
1591} 1599}
1592 1600
1593void KOAgendaView::scrollOneHourUp() 1601void KOAgendaView::scrollOneHourUp()
1594{ 1602{
1595 1603
1596 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1604 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1597} 1605}
1598void KOAgendaView::scrollOneHourDown() 1606void KOAgendaView::scrollOneHourDown()
1599{ 1607{
1600 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1608 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1601} 1609}
1602 1610
1603void KOAgendaView::setStartHour( int h ) 1611void KOAgendaView::setStartHour( int h )
1604{ 1612{
1605 mAgenda->setStartHour( h ); 1613 mAgenda->setStartHour( h );
1606 1614
1607} 1615}
1608void KOAgendaView::setInitStartHour() 1616void KOAgendaView::setInitStartHour()
1609{ 1617{
1610 1618
1611 if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1619 if ( KOPrefs::instance()->mCenterOnCurrentTime )
1612 setStartHour( QTime::currentTime ().hour() ); 1620 setStartHour( QTime::currentTime ().hour() );
1613 else 1621 else
1614 setStartHour( KOPrefs::instance()->mDayBegins ); 1622 setStartHour( KOPrefs::instance()->mDayBegins );
1615 1623
1616} 1624}
1617 1625
1618 1626
1619void KOAgendaView::updateTodo( Todo * t, int ) 1627void KOAgendaView::updateTodo( Todo * t, int )
1620{ 1628{
1621 if ( !isVisible() ) 1629 if ( !isVisible() )
1622 return; 1630 return;
1623 bool remove = false; 1631 bool remove = false;
1624 bool removeAD = false; 1632 bool removeAD = false;
1625 QDate da; 1633 QDate da;
1626 if ( t->hasCompletedDate() ) 1634 if ( t->hasCompletedDate() )
1627 da = t->completed().date(); 1635 da = t->completed().date();
1628 else 1636 else
1629 da = t->dtDue().date(); 1637 da = t->dtDue().date();
1630 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1638 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1631 remove = true; 1639 remove = true;
1632 removeAD = true; 1640 removeAD = true;
1633 } 1641 }
1634 else { 1642 else {
1635 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1643 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1636 if ( overdue && 1644 if ( overdue &&
1637 QDate::currentDate() >= mSelectedDates.first() && 1645 QDate::currentDate() >= mSelectedDates.first() &&
1638 QDate::currentDate() <= mSelectedDates.last()) { 1646 QDate::currentDate() <= mSelectedDates.last()) {
1639 removeAD = false; 1647 removeAD = false;
1640 remove = true; 1648 remove = true;
1641 } 1649 }
1642 else { 1650 else {
1643 1651
1644 if ( da < mSelectedDates.first() || 1652 if ( da < mSelectedDates.first() ||
1645 da > mSelectedDates.last() ) { 1653 da > mSelectedDates.last() ) {
1646 remove = true; 1654 remove = true;
1647 removeAD = true; 1655 removeAD = true;
1648 } else { 1656 } else {
1649 remove = t->doesFloat() && !t->hasCompletedDate(); 1657 remove = t->doesFloat() && !t->hasCompletedDate();
1650 removeAD = !remove; 1658 removeAD = !remove;
1651 } 1659 }
1652 } 1660 }
1653 } 1661 }
1654 int days = mSelectedDates.first().daysTo( da ); 1662 int days = mSelectedDates.first().daysTo( da );
1655 //qDebug("daysto %d %d %d", days, remove,removeAD ); 1663 //qDebug("daysto %d %d %d", days, remove,removeAD );
1656 mAgenda->updateTodo( t , days, remove); 1664 mAgenda->updateTodo( t , days, remove);
1657 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1665 if ( KOPrefs::instance()->mShowTodoInAgenda )
1658 mAllDayAgenda->updateTodo( t , days, removeAD); 1666 mAllDayAgenda->updateTodo( t , days, removeAD);
1659 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1667 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1660 1668
1661} 1669}
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index effd7a3..4b7ef5b 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -1,297 +1,298 @@
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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDAVIEW_H 23#ifndef KOAGENDAVIEW_H
24#define KOAGENDAVIEW_H 24#define KOAGENDAVIEW_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qksplitter.h> 31#include <qksplitter.h>
32#else 32#else
33#include <qsplitter.h> 33#include <qsplitter.h>
34#endif 34#endif
35#include <qmemarray.h> 35#include <qmemarray.h>
36 36
37#include "koeventview.h" 37#include "koeventview.h"
38 38
39class QHBox; 39class QHBox;
40class QFrame; 40class QFrame;
41class QLabel; 41class QLabel;
42class QPushButton; 42class QPushButton;
43class CalendarView; 43class CalendarView;
44class KOAgenda; 44class KOAgenda;
45class KOAgendaItem; 45class KOAgendaItem;
46class KConfig; 46class KConfig;
47class KDGanttMinimizeSplitter; 47class KDGanttMinimizeSplitter;
48 48
49class KOAgendaButton : public QPushButton 49class KOAgendaButton : public QPushButton
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) : 53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) :
54 QPushButton( parent, name ) 54 QPushButton( parent, name )
55 { 55 {
56 mNum = -3; 56 mNum = -3;
57 setFlat( true ); 57 setFlat( true );
58 setFocusPolicy(NoFocus); 58 setFocusPolicy(NoFocus);
59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); 59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) ); 60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) );
61 }; 61 };
62 62
63 QSize sizeHint () const { return QSize( 5,5) ;} 63 QSize sizeHint () const { return QSize( 5,5) ;}
64 void setNum( int n) { mNum = n; } 64 void setNum( int n) { mNum = n; }
65private slots: 65private slots:
66 void bClicked() {emit numClicked( mNum);} 66 void bClicked() {emit numClicked( mNum);}
67signals: 67signals:
68 void numClicked( int ); 68 void numClicked( int );
69private: 69private:
70 int mNum; 70 int mNum;
71}; 71};
72 72
73class TimeLabels : public QScrollView { 73class TimeLabels : public QScrollView {
74 Q_OBJECT 74 Q_OBJECT
75 public: 75 public:
76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
77 77
78 void setCellHeight(int height); 78 void setCellHeight(int height);
79 79
80 /** Calculates the minimum width */ 80 /** Calculates the minimum width */
81 virtual int minimumWidth() const; 81 virtual int minimumWidth() const;
82 82
83 /** updates widget's internal state */ 83 /** updates widget's internal state */
84 void updateConfig(); 84 void updateConfig();
85 85
86 /** */ 86 /** */
87 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
88 88
89 /** */ 89 /** */
90 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
91 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
92 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
93 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
94 94
95 public slots: 95 public slots:
96 /** update time label positions */ 96 /** update time label positions */
97 void positionChanged(); 97 void positionChanged();
98 signals: 98 signals:
99 void scaleChanged(); 99 void scaleChanged();
100 protected: 100 protected:
101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
102 102
103 private: 103 private:
104 QPixmap myPix; 104 QPixmap myPix;
105 bool mRedrawNeeded; 105 bool mRedrawNeeded;
106 int mMiniWidth; 106 int mMiniWidth;
107 int mMouseDownY; 107 int mMouseDownY;
108 QString mOrgCap; 108 QString mOrgCap;
109 int mRows; 109 int mRows;
110 int mCellHeight; 110 int mCellHeight;
111 111
112 /** */ 112 /** */
113 KOAgenda* mAgenda; 113 KOAgenda* mAgenda;
114}; 114};
115 115
116class EventIndicator : public QFrame { 116class EventIndicator : public QFrame {
117 Q_OBJECT 117 Q_OBJECT
118 public: 118 public:
119 enum Location { Top, Bottom }; 119 enum Location { Top, Bottom };
120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
121 virtual ~EventIndicator(); 121 virtual ~EventIndicator();
122 122
123 void changeColumns(int columns); 123 void changeColumns(int columns);
124 void setPaintWidget( KDGanttMinimizeSplitter* ); 124 void setPaintWidget( KDGanttMinimizeSplitter* );
125 void setXOffset( int ); 125 void setXOffset( int );
126 void enableColumn(int column, bool enable); 126 void enableColumn(int column, bool enable);
127 127
128 protected: 128 protected:
129 void drawContents(QPainter *); 129 void drawContents(QPainter *);
130 130
131 private: 131 private:
132 int mXOffset; 132 int mXOffset;
133 KDGanttMinimizeSplitter* mPaintWidget; 133 KDGanttMinimizeSplitter* mPaintWidget;
134 int mColumns; 134 int mColumns;
135 QHBox *mTopBox; 135 QHBox *mTopBox;
136 QBoxLayout *mTopLayout; 136 QBoxLayout *mTopLayout;
137 Location mLocation; 137 Location mLocation;
138 QPixmap mPixmap; 138 QPixmap mPixmap;
139 QMemArray<bool> mEnabled; 139 QMemArray<bool> mEnabled;
140}; 140};
141 141
142/** 142/**
143 KOAgendaView is the agenda-like view used to display events in an one or 143 KOAgendaView is the agenda-like view used to display events in an one or
144 multi-day view. 144 multi-day view.
145*/ 145*/
146class KOAgendaView : public KOEventView { 146class KOAgendaView : public KOEventView {
147 Q_OBJECT 147 Q_OBJECT
148 public: 148 public:
149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
150 virtual ~KOAgendaView(); 150 virtual ~KOAgendaView();
151 void setStartHour( int ); 151 void setStartHour( int );
152 void toggleAllDay(); 152 void toggleAllDay();
153 153
154 154
155 /** Returns maximum number of days supported by the koagendaview */ 155 /** Returns maximum number of days supported by the koagendaview */
156 virtual int maxDatesHint(); 156 virtual int maxDatesHint();
157 157
158 /** Returns number of currently shown dates. */ 158 /** Returns number of currently shown dates. */
159 virtual int currentDateCount(); 159 virtual int currentDateCount();
160 160
161 /** returns the currently selected events */ 161 /** returns the currently selected events */
162 virtual QPtrList<Incidence> selectedIncidences(); 162 virtual QPtrList<Incidence> selectedIncidences();
163 163
164 /** returns the currently selected events */ 164 /** returns the currently selected events */
165 virtual DateList selectedDates(); 165 virtual DateList selectedDates();
166 166
167 /** Remove all events from view */ 167 /** Remove all events from view */
168 void clearView(); 168 void clearView();
169 void clearList(); 169 void clearList();
170 KOAgenda *agenda() { return mAgenda;} 170 KOAgenda *agenda() { return mAgenda;}
171 virtual void printPreview(CalPrinter *calPrinter, 171 virtual void printPreview(CalPrinter *calPrinter,
172 const QDate &, const QDate &); 172 const QDate &, const QDate &);
173 173
174 /** start-datetime of selection */ 174 /** start-datetime of selection */
175 QDateTime selectionStart() {return mTimeSpanBegin;} 175 QDateTime selectionStart() {return mTimeSpanBegin;}
176 /** end-datetime of selection */ 176 /** end-datetime of selection */
177 QDateTime selectionEnd() {return mTimeSpanEnd;} 177 QDateTime selectionEnd() {return mTimeSpanEnd;}
178 /** returns true if selection is for whole day */ 178 /** returns true if selection is for whole day */
179 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 179 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
180 /** make selected start/end invalid */ 180 /** make selected start/end invalid */
181 void deleteSelectedDateTime(); 181 void deleteSelectedDateTime();
182 void repaintAgenda(); 182 void repaintAgenda();
183 public slots: 183 public slots:
184 void setInitStartHour(); 184 void setInitStartHour();
185 virtual void updateView(); 185 virtual void updateView();
186 virtual void updateConfig(); 186 virtual void updateConfig();
187 virtual void showDates(const QDate &start, const QDate &end); 187 virtual void showDates(const QDate &start, const QDate &end);
188 virtual void showEvents(QPtrList<Event> eventList); 188 virtual void showEvents(QPtrList<Event> eventList);
189 189
190 void updateTodo( Todo *, int ); 190 void updateTodo( Todo *, int );
191 void changeEventDisplay(Event *, int); 191 void changeEventDisplay(Event *, int);
192 192
193 void clearSelection(); 193 void clearSelection();
194 194
195 void newTodo(int gx,int gy); 195 void newTodo(int gx,int gy);
196 void newEvent(int gx,int gy); 196 void newEvent(int gx,int gy);
197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
198 void newEventAllDay(int gx, int gy); 198 void newEventAllDay(int gx, int gy);
199 void newTodoAllDay(int gx, int gy); 199 void newTodoAllDay(int gx, int gy);
200 200
201 void startDrag(Event *); 201 void startDrag(Event *);
202 202
203 void readSettings(); 203 void readSettings();
204 void readSettings(KConfig *); 204 void readSettings(KConfig *);
205 void writeSettings(KConfig *); 205 void writeSettings(KConfig *);
206 206
207 void setContentsPos(int y); 207 void setContentsPos(int y);
208 208
209 void scrollOneHourUp(); 209 void scrollOneHourUp();
210 void scrollOneHourDown(); 210 void scrollOneHourDown();
211 void addToCalSlot(Incidence *, Incidence *); 211 void addToCalSlot(Incidence *, Incidence *);
212 void slotShowDateView( int, int ); 212 void slotShowDateView( int, int );
213 void fillAgenda(); 213 void fillAgenda();
214 void startIdleTimeout();
214 215
215 signals: 216 signals:
216 void showDateView( int, QDate ); 217 void showDateView( int, QDate );
217 void newTodoSignal( QDateTime ,bool ); 218 void newTodoSignal( QDateTime ,bool );
218 void toggleExpand(); 219 void toggleExpand();
219 void selectWeekNum( int ); 220 void selectWeekNum( int );
220 void todoMoved( Todo *, int ); 221 void todoMoved( Todo *, int );
221 void incidenceChanged(Incidence * , int ); 222 void incidenceChanged(Incidence * , int );
222 // void cloneIncidenceSignal(Incidence *); 223 // void cloneIncidenceSignal(Incidence *);
223 224
224 protected: 225 protected:
225 KOAgendaButton* getNewDaylabel(); 226 KOAgendaButton* getNewDaylabel();
226 bool mBlockUpdating; 227 bool mBlockUpdating;
227 int mUpcomingWidth; 228 int mUpcomingWidth;
228 /** Fill agenda beginning with date startDate */ 229 /** Fill agenda beginning with date startDate */
229 void fillAgenda(const QDate &startDate); 230 void fillAgenda(const QDate &startDate);
230 void resizeEvent( QResizeEvent* e ); 231 void resizeEvent( QResizeEvent* e );
231 /** Fill agenda using the current set value for the start date */ 232 /** Fill agenda using the current set value for the start date */
232 233
233 /** Create labels for the selected dates. */ 234 /** Create labels for the selected dates. */
234 void createDayLabels(); 235 void createDayLabels();
235 236
236 /** 237 /**
237 Set the masks on the agenda widgets indicating, which days are holidays. 238 Set the masks on the agenda widgets indicating, which days are holidays.
238 */ 239 */
239 void setHolidayMasks(); 240 void setHolidayMasks();
240 241
241 protected slots: 242 protected slots:
242 void slotIdleTimeout(); 243 void slotIdleTimeout();
243 void categoryChanged( Incidence * ); 244 void categoryChanged( Incidence * );
244 void slotDaylabelClicked( int ); 245 void slotDaylabelClicked( int );
245 /** Update event belonging to agenda item */ 246 /** Update event belonging to agenda item */
246 void updateEventDates(KOAgendaItem *item, int mode = -1); 247 void updateEventDates(KOAgendaItem *item, int mode = -1);
247 //void updateMovedTodo(); 248 //void updateMovedTodo();
248 249
249 void updateEventIndicatorTop(int newY); 250 void updateEventIndicatorTop(int newY);
250 void updateEventIndicatorBottom(int newY); 251 void updateEventIndicatorBottom(int newY);
251 252
252 /** Updates data for selected timespan */ 253 /** Updates data for selected timespan */
253 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 254 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
254 /** Updates data for selected timespan for all day event*/ 255 /** Updates data for selected timespan for all day event*/
255 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 256 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
256 257
257 private: 258 private:
258 QTimer* mIdleTimer; 259 QTimer* mIdleTimer;
259 QDateTime mIdleStart; 260 QDateTime mIdleStart;
260 // view widgets 261 // view widgets
261 QFrame *mDayLabels; 262 QFrame *mDayLabels;
262 QHBox *mDayLabelsFrame; 263 QHBox *mDayLabelsFrame;
263 QBoxLayout *mLayoutDayLabels; 264 QBoxLayout *mLayoutDayLabels;
264 QFrame *mAllDayFrame; 265 QFrame *mAllDayFrame;
265 KOAgenda *mAllDayAgenda; 266 KOAgenda *mAllDayAgenda;
266 KOAgenda *mAgenda; 267 KOAgenda *mAgenda;
267 TimeLabels *mTimeLabels; 268 TimeLabels *mTimeLabels;
268 QWidget *mDummyAllDayLeft; 269 QWidget *mDummyAllDayLeft;
269 270
270 KDGanttMinimizeSplitter* mSplitterAgenda; 271 KDGanttMinimizeSplitter* mSplitterAgenda;
271 QPushButton *mExpandButton; 272 QPushButton *mExpandButton;
272 273
273 DateList mSelectedDates; // List of dates to be displayed 274 DateList mSelectedDates; // List of dates to be displayed
274 int mViewType; 275 int mViewType;
275 276
276 bool mWeekStartsMonday; 277 bool mWeekStartsMonday;
277 int mStartHour; 278 int mStartHour;
278 279
279 KOEventPopupMenu *mAllAgendaPopup; 280 KOEventPopupMenu *mAllAgendaPopup;
280 //KOEventPopupMenu *mAllDayAgendaPopup; 281 //KOEventPopupMenu *mAllDayAgendaPopup;
281 282
282 EventIndicator *mEventIndicatorTop; 283 EventIndicator *mEventIndicatorTop;
283 EventIndicator *mEventIndicatorBottom; 284 EventIndicator *mEventIndicatorBottom;
284 285
285 QMemArray<int> mMinY; 286 QMemArray<int> mMinY;
286 QMemArray<int> mMaxY; 287 QMemArray<int> mMaxY;
287 288
288 QMemArray<bool> mHolidayMask; 289 QMemArray<bool> mHolidayMask;
289 290
290 QPtrList<KOAgendaButton> mDayLabelsList; 291 QPtrList<KOAgendaButton> mDayLabelsList;
291 QDateTime mTimeSpanBegin; 292 QDateTime mTimeSpanBegin;
292 QDateTime mTimeSpanEnd; 293 QDateTime mTimeSpanEnd;
293 bool mTimeSpanInAllDay; 294 bool mTimeSpanInAllDay;
294 void keyPressEvent ( QKeyEvent * e ); 295 void keyPressEvent ( QKeyEvent * e );
295}; 296};
296 297
297#endif // KOAGENDAVIEW_H 298#endif // KOAGENDAVIEW_H