summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp172
1 files changed, 80 insertions, 92 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 14f52b8..ed7a443 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1,2238 +1,2226 @@
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
63//////////////////////////////////////////////////////////////////////////// 63////////////////////////////////////////////////////////////////////////////
64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
65 : QFrame(_agenda->viewport(),name), agenda(_agenda) 65 : QFrame(_agenda->viewport(),name), agenda(_agenda)
66{ 66{
67 setLineWidth(0); 67 setLineWidth(0);
68 setMargin(0); 68 setMargin(0);
69 setBackgroundColor(Qt::red); 69 setBackgroundColor(Qt::red);
70 minutes = new QTimer(this); 70 minutes = new QTimer(this);
71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
72 minutes->start(0, true); 72 minutes->start(0, true);
73 mTimeBox = new QLabel(this); 73 mTimeBox = new QLabel(this);
74 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 74 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
75 QPalette pal = mTimeBox->palette(); 75 QPalette pal = mTimeBox->palette();
76 pal.setColor(QColorGroup::Foreground, Qt::red); 76 pal.setColor(QColorGroup::Foreground, Qt::red);
77 mTimeBox->setPalette(pal); 77 mTimeBox->setPalette(pal);
78 //mTimeBox->setAutoMask(true); 78 //mTimeBox->setAutoMask(true);
79 79
80 agenda->addChild(mTimeBox); 80 agenda->addChild(mTimeBox);
81 81
82 oldToday = -1; 82 oldToday = -1;
83} 83}
84 84
85MarcusBains::~MarcusBains() 85MarcusBains::~MarcusBains()
86{ 86{
87 delete minutes; 87 delete minutes;
88} 88}
89 89
90int MarcusBains::todayColumn() 90int MarcusBains::todayColumn()
91{ 91{
92 QDate currentDate = QDate::currentDate(); 92 QDate currentDate = QDate::currentDate();
93 93
94 DateList dateList = agenda->dateList(); 94 DateList dateList = agenda->dateList();
95 DateList::ConstIterator it; 95 DateList::ConstIterator it;
96 int col = 0; 96 int col = 0;
97 for(it = dateList.begin(); it != dateList.end(); ++it) { 97 for(it = dateList.begin(); it != dateList.end(); ++it) {
98 if((*it) == currentDate) 98 if((*it) == currentDate)
99 return KOGlobals::self()->reverseLayout() ? 99 return KOGlobals::self()->reverseLayout() ?
100 agenda->columns() - 1 - col : col; 100 agenda->columns() - 1 - col : col;
101 ++col; 101 ++col;
102 } 102 }
103 103
104 return -1; 104 return -1;
105} 105}
106void MarcusBains::updateLoc() 106void MarcusBains::updateLoc()
107{ 107{
108 updateLocation(); 108 updateLocation();
109} 109}
110void MarcusBains::updateLocation(bool recalculate) 110void MarcusBains::updateLocation(bool recalculate)
111{ 111{
112 112
113 QTime tim = QTime::currentTime(); 113 QTime tim = QTime::currentTime();
114 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 114 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
115 if((tim.hour() == 0) && (oldTime.hour()==23)) 115 if((tim.hour() == 0) && (oldTime.hour()==23))
116 recalculate = true; 116 recalculate = true;
117 117
118 int mins = tim.hour()*60 + tim.minute(); 118 int mins = tim.hour()*60 + tim.minute();
119 int minutesPerCell = 24 * 60 / agenda->rows(); 119 int minutesPerCell = 24 * 60 / agenda->rows();
120 int y = mins*agenda->gridSpacingY()/minutesPerCell; 120 int y = mins*agenda->gridSpacingY()/minutesPerCell;
121 int today = recalculate ? todayColumn() : oldToday; 121 int today = recalculate ? todayColumn() : oldToday;
122 int x = agenda->gridSpacingX()*today; 122 int x = agenda->gridSpacingX()*today;
123 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 123 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
124 124
125 oldTime = tim; 125 oldTime = tim;
126 oldToday = today; 126 oldToday = today;
127 127
128 if(disabled || (today<0)) { 128 if(disabled || (today<0)) {
129 hide(); mTimeBox->hide(); 129 hide(); mTimeBox->hide();
130 return; 130 return;
131 } else { 131 } else {
132 show(); mTimeBox->show(); 132 show(); mTimeBox->show();
133 } 133 }
134 134
135 if(recalculate) 135 if(recalculate)
136 setFixedSize(agenda->gridSpacingX(),1); 136 setFixedSize(agenda->gridSpacingX(),1);
137 agenda->moveChild(this, x, y); 137 agenda->moveChild(this, x, y);
138 raise(); 138 raise();
139 139
140 if(recalculate) 140 if(recalculate)
141 //mTimeBox->setFont(QFont("helvetica",10)); 141 //mTimeBox->setFont(QFont("helvetica",10));
142 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 142 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
143 143
144 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 144 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
145 mTimeBox->adjustSize(); 145 mTimeBox->adjustSize();
146 // the -2 below is there because there is a bug in this program 146 // the -2 below is there because there is a bug in this program
147 // somewhere, where the last column of this widget is a few pixels 147 // somewhere, where the last column of this widget is a few pixels
148 // narrower than the other columns. 148 // narrower than the other columns.
149 int offs = (today==agenda->columns()-1) ? -4 : 0; 149 int offs = (today==agenda->columns()-1) ? -4 : 0;
150 agenda->moveChild(mTimeBox, 150 agenda->moveChild(mTimeBox,
151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
152 y-mTimeBox->height()); 152 y-mTimeBox->height());
153 153
154 mTimeBox->raise(); 154 mTimeBox->raise();
155 //mTimeBox->setAutoMask(true); 155 //mTimeBox->setAutoMask(true);
156 minutes->start(5000,true); 156 minutes->start(5000,true);
157} 157}
158 158
159 159
160//////////////////////////////////////////////////////////////////////////// 160////////////////////////////////////////////////////////////////////////////
161 161
162 162
163/* 163/*
164 Create an agenda widget with rows rows and columns columns. 164 Create an agenda widget with rows rows and columns columns.
165*/ 165*/
166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
167 const char *name,WFlags f) : 167 const char *name,WFlags f) :
168 QScrollView(parent,name,f) 168 QScrollView(parent,name,f)
169{ 169{
170 170
171 171
172 mColumns = columns; 172 mColumns = columns;
173 mRows = rows; 173 mRows = rows;
174 mGridSpacingY = rowSize; 174 mGridSpacingY = rowSize;
175 mAllDayMode = false; 175 mAllDayMode = false;
176#ifndef DESKTOP_VERSION 176#ifndef DESKTOP_VERSION
177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
178#endif 178#endif
179 mHolidayMask = 0; 179 mHolidayMask = 0;
180 init(); 180 init();
181} 181}
182 182
183/* 183/*
184 Create an agenda widget with columns columns and one row. This is used for 184 Create an agenda widget with columns columns and one row. This is used for
185 all-day events. 185 all-day events.
186*/ 186*/
187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
188 QScrollView(parent,name,f) 188 QScrollView(parent,name,f)
189{ 189{
190 blockResize = false; 190 blockResize = false;
191 mColumns = columns; 191 mColumns = columns;
192 mRows = 1; 192 mRows = 1;
193 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 193 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
194 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 194 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
195 mAllDayMode = true; 195 mAllDayMode = true;
196#ifndef DESKTOP_VERSION 196#ifndef DESKTOP_VERSION
197 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 197 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
198#endif 198#endif
199 mHolidayMask = 0; 199 mHolidayMask = 0;
200 init(); 200 init();
201} 201}
202 202
203 203
204KOAgenda::~KOAgenda() 204KOAgenda::~KOAgenda()
205{ 205{
206 if(mMarcusBains) delete mMarcusBains; 206 if(mMarcusBains) delete mMarcusBains;
207 207
208} 208}
209 209
210Incidence *KOAgenda::selectedIncidence() const 210Incidence *KOAgenda::selectedIncidence() const
211{ 211{
212 return (mSelectedItem ? mSelectedItem->incidence() : 0); 212 return (mSelectedItem ? mSelectedItem->incidence() : 0);
213} 213}
214 214
215 215
216QDate KOAgenda::selectedIncidenceDate() const 216QDate KOAgenda::selectedIncidenceDate() const
217{ 217{
218 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 218 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
219} 219}
220 220
221 221
222void KOAgenda::init() 222void KOAgenda::init()
223{ 223{
224 mPopupTimer = new QTimer(this); 224 mPopupTimer = new QTimer(this);
225 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 225 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
226 226
227 mNewItemPopup = new QPopupMenu( this ); 227 mNewItemPopup = new QPopupMenu( this );
228 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 228 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
229 QString pathString = ""; 229 QString pathString = "";
230 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 230 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
231 if ( QApplication::desktop()->width() < 480 ) 231 if ( QApplication::desktop()->width() < 480 )
232 pathString += "icons16/"; 232 pathString += "icons16/";
233 } else 233 } else
234 pathString += "iconsmini/"; 234 pathString += "iconsmini/";
235 235
236 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 236 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
238 mNewItemPopup->insertSeparator ( ); 238 mNewItemPopup->insertSeparator ( );
239 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 239 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
241 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 241 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
245#ifndef _WIN32_ 245#ifndef _WIN32_
246 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 246 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
247 viewport()->setWFlags ( wflags); 247 viewport()->setWFlags ( wflags);
248#endif 248#endif
249 mGridSpacingX = 80; 249 mGridSpacingX = 80;
250 mResizeBorderWidth = 8; 250 mResizeBorderWidth = 8;
251 mScrollBorderWidth = 8; 251 mScrollBorderWidth = 8;
252 mScrollDelay = 30; 252 mScrollDelay = 30;
253 mScrollOffset = 10; 253 mScrollOffset = 10;
254 mPaintPixmap.resize( 20,20); 254 mPaintPixmap.resize( 20,20);
255 //enableClipper(true); 255 //enableClipper(true);
256 256
257 // Grab key strokes for keyboard navigation of agenda. Seems to have no 257 // Grab key strokes for keyboard navigation of agenda. Seems to have no
258 // effect. Has to be fixed. 258 // effect. Has to be fixed.
259 setFocusPolicy(WheelFocus); 259 setFocusPolicy(WheelFocus);
260 260
261 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 261 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
262 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 262 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
263 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 263 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
264 264
265 mStartCellX = 0; 265 mStartCellX = 0;
266 mStartCellY = 0; 266 mStartCellY = 0;
267 mCurrentCellX = 0; 267 mCurrentCellX = 0;
268 mCurrentCellY = 0; 268 mCurrentCellY = 0;
269 269
270 mSelectionCellX = 0; 270 mSelectionCellX = 0;
271 mSelectionYTop = 0; 271 mSelectionYTop = 0;
272 mSelectionHeight = 0; 272 mSelectionHeight = 0;
273 273
274 mOldLowerScrollValue = -1; 274 mOldLowerScrollValue = -1;
275 mOldUpperScrollValue = -1; 275 mOldUpperScrollValue = -1;
276 276
277 mClickedItem = 0; 277 mClickedItem = 0;
278 278
279 mActionItem = 0; 279 mActionItem = 0;
280 mActionType = NOP; 280 mActionType = NOP;
281 mItemMoved = false; 281 mItemMoved = false;
282 282
283 mSelectedItem = 0; 283 mSelectedItem = 0;
284 284
285 // mItems.setAutoDelete(true); 285 // mItems.setAutoDelete(true);
286 286
287 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 287 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
288 288
289 viewport()->update(); 289 viewport()->update();
290 290
291 setMinimumSize(30, 1); 291 setMinimumSize(30, 1);
292// setMaximumHeight(mGridSpacingY * mRows + 5); 292// setMaximumHeight(mGridSpacingY * mRows + 5);
293 293
294 // Disable horizontal scrollbar. This is a hack. The geometry should be 294 // Disable horizontal scrollbar. This is a hack. The geometry should be
295 // controlled in a way that the contents horizontally always fits. Then it is 295 // controlled in a way that the contents horizontally always fits. Then it is
296 // not necessary to turn off the scrollbar. 296 // not necessary to turn off the scrollbar.
297 setHScrollBarMode(AlwaysOff); 297 setHScrollBarMode(AlwaysOff);
298 if ( ! mAllDayMode ) 298 if ( ! mAllDayMode )
299 setVScrollBarMode(AlwaysOn); 299 setVScrollBarMode(AlwaysOn);
300 else 300 else
301 setVScrollBarMode(AlwaysOff); 301 setVScrollBarMode(AlwaysOff);
302 302
303 setStartHour(KOPrefs::instance()->mDayBegins); 303 setStartHour(KOPrefs::instance()->mDayBegins);
304 304
305 calculateWorkingHours(); 305 calculateWorkingHours();
306 306
307 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 307 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
308 SLOT(checkScrollBoundaries(int))); 308 SLOT(checkScrollBoundaries(int)));
309 309
310 // Create the Marcus Bains line. 310 // Create the Marcus Bains line.
311 if(mAllDayMode) 311 if(mAllDayMode)
312 mMarcusBains = 0; 312 mMarcusBains = 0;
313 else { 313 else {
314 mMarcusBains = new MarcusBains(this); 314 mMarcusBains = new MarcusBains(this);
315 addChild(mMarcusBains); 315 addChild(mMarcusBains);
316 } 316 }
317 mPopupKind = 0; 317 mPopupKind = 0;
318 mPopupItem = 0; 318 mPopupItem = 0;
319} 319}
320 320
321void KOAgenda::clear() 321void KOAgenda::clear()
322{ 322{
323 KOAgendaItem *item; 323 KOAgendaItem *item;
324 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 324 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
325 mUnusedItems.append( item ); 325 mUnusedItems.append( item );
326 //item->hide(); 326 //item->hide();
327 } 327 }
328 mItems.clear(); 328 mItems.clear();
329 mSelectedItem = 0; 329 mSelectedItem = 0;
330 clearSelection(); 330 clearSelection();
331} 331}
332 332
333void KOAgenda::clearSelection() 333void KOAgenda::clearSelection()
334{ 334{
335 mSelectionCellX = 0; 335 mSelectionCellX = 0;
336 mSelectionYTop = 0; 336 mSelectionYTop = 0;
337 mSelectionHeight = 0; 337 mSelectionHeight = 0;
338} 338}
339 339
340void KOAgenda::marcus_bains() 340void KOAgenda::marcus_bains()
341{ 341{
342 if(mMarcusBains) mMarcusBains->updateLocation(true); 342 if(mMarcusBains) mMarcusBains->updateLocation(true);
343} 343}
344 344
345 345
346void KOAgenda::changeColumns(int columns) 346void KOAgenda::changeColumns(int columns)
347{ 347{
348 if (columns == 0) { 348 if (columns == 0) {
349 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; 349 qDebug("KOAgenda::changeColumns() called with argument 0 ");
350 return; 350 return;
351 } 351 }
352 352 clear();
353 clear(); 353 mColumns = columns;
354
355 mColumns = columns;
356// setMinimumSize(mColumns * 10, mGridSpacingY + 1);
357// init();
358// update();
359 //qDebug("KOAgenda::changeColumns ");
360 computeSizes(); 354 computeSizes();
361 // QResizeEvent event( size(), size() );
362
363 //QApplication::sendEvent( this, &event );
364} 355}
365 356
366/* 357/*
367 This is the eventFilter function, which gets all events from the KOAgendaItems 358 This is the eventFilter function, which gets all events from the KOAgendaItems
368 contained in the agenda. It has to handle moving and resizing for all items. 359 contained in the agenda. It has to handle moving and resizing for all items.
369*/ 360*/
370bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 361bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
371{ 362{
372// kdDebug() << "KOAgenda::eventFilter" << endl; 363 // kdDebug() << "KOAgenda::eventFilter" << endl;
373 switch(event->type()) { 364 switch(event->type()) {
374 case QEvent::MouseButtonPress: 365 case QEvent::MouseButtonPress:
375 case QEvent::MouseButtonDblClick: 366 case QEvent::MouseButtonDblClick:
376 case QEvent::MouseButtonRelease: 367 case QEvent::MouseButtonRelease:
377 case QEvent::MouseMove: 368 case QEvent::MouseMove:
378 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 369 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
379 370
380 case (QEvent::Leave): 371 case (QEvent::Leave):
381 if (!mActionItem) 372 if (!mActionItem)
382 setCursor(arrowCursor); 373 setCursor(arrowCursor);
383 return true; 374 return true;
384 375
385 default: 376 default:
386 return QScrollView::eventFilter(object,event); 377 return QScrollView::eventFilter(object,event);
387 } 378 }
388} 379}
389void KOAgenda::popupMenu() 380void KOAgenda::popupMenu()
390{ 381{
391 mPopupTimer->stop(); 382 mPopupTimer->stop();
392 if ( mPopupKind == 1 ) { 383 if ( mPopupKind == 1 ) {
393 if (mActionItem ) { 384 if (mActionItem ) {
394 endItemAction(); 385 endItemAction();
395 } 386 }
396 mLeftMouseDown = false; // no more leftMouse computation 387 mLeftMouseDown = false; // no more leftMouse computation
397 if (mPopupItem) { 388 if (mPopupItem) {
398 selectItem(mPopupItem); 389 selectItem(mPopupItem);
399 emit showIncidencePopupSignal(mPopupItem->incidence()); 390 emit showIncidencePopupSignal(mPopupItem->incidence());
400 391
401 } 392 }
402 } else if ( mPopupKind == 2 ) { 393 } else if ( mPopupKind == 2 ) {
403 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 394 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
404 endSelectAction( false ); // do not emit new event signal 395 endSelectAction( false ); // do not emit new event signal
405 mLeftMouseDown = false; // no more leftMouse computation 396 mLeftMouseDown = false; // no more leftMouse computation
406 } 397 }
407 mNewItemPopup->popup( mPopupPos); 398 mNewItemPopup->popup( mPopupPos);
408 } 399 }
409 mLeftMouseDown = false; 400 mLeftMouseDown = false;
410 mPopupItem = 0; 401 mPopupItem = 0;
411 mPopupKind = 0; 402 mPopupKind = 0;
412} 403}
413 404
414bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 405bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
415{ 406{
416 //qDebug("KOAgenda::eventFilter_mous "); 407 //qDebug("KOAgenda::eventFilter_mous ");
417 QPoint viewportPos; 408 QPoint viewportPos;
418 if (object != viewport()) { 409 if (object != viewport()) {
419 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 410 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
420 } else { 411 } else {
421 viewportPos = me->pos(); 412 viewportPos = me->pos();
422 } 413 }
423 static int startX = 0; 414 static int startX = 0;
424 static int startY = 0; 415 static int startY = 0;
425 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 416 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
426 static bool blockMoving = true; 417 static bool blockMoving = true;
427 switch (me->type()) { 418 switch (me->type()) {
428 case QEvent::MouseButtonPress: 419 case QEvent::MouseButtonPress:
429 if (me->button() == LeftButton) { 420 if (me->button() == LeftButton) {
430 mPopupTimer->start( 600 ); 421 mPopupTimer->start( 600 );
431 mLeftMouseDown = true; 422 mLeftMouseDown = true;
432 } 423 }
433 blockMoving = true; 424 blockMoving = true;
434 startX = viewportPos.x(); 425 startX = viewportPos.x();
435 startY = viewportPos.y(); 426 startY = viewportPos.y();
436 if (object != viewport()) { 427 if (object != viewport()) {
437 mPopupItem = (KOAgendaItem *)object; 428 mPopupItem = (KOAgendaItem *)object;
438 mPopupKind = 1; 429 mPopupKind = 1;
439 if (me->button() == RightButton) { 430 if (me->button() == RightButton) {
440 popupMenu(); 431 popupMenu();
441 } else if (me->button() == LeftButton) { 432 } else if (me->button() == LeftButton) {
442 mActionItem = (KOAgendaItem *)object; 433 mActionItem = (KOAgendaItem *)object;
443 if (mActionItem) { 434 if (mActionItem) {
444 if ( mSelectionHeight > 0 ) { 435 if ( mSelectionHeight > 0 ) {
445 int selectionCellX = mSelectionCellX * mGridSpacingX; 436 int selectionCellX = mSelectionCellX * mGridSpacingX;
446 int selectionYTop = mSelectionYTop; 437 int selectionYTop = mSelectionYTop;
447 int gridSpacingX = mGridSpacingX; 438 int gridSpacingX = mGridSpacingX;
448 int selectionHeight = mSelectionHeight; 439 int selectionHeight = mSelectionHeight;
449 clearSelection(); 440 clearSelection();
450 repaintContents( selectionCellX, selectionYTop, 441 repaintContents( selectionCellX, selectionYTop,
451 gridSpacingX, selectionHeight,false ); 442 gridSpacingX, selectionHeight,false );
452 } 443 }
453 selectItem(mActionItem); 444 selectItem(mActionItem);
454 Incidence *incidence = mActionItem->incidence(); 445 Incidence *incidence = mActionItem->incidence();
455 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 446 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
456 mActionItem = 0; 447 mActionItem = 0;
457 } else { 448 } else {
458 startItemAction(viewportPos); 449 startItemAction(viewportPos);
459 } 450 }
460 } 451 }
461 } 452 }
462 } else { // ---------- viewport() 453 } else { // ---------- viewport()
463 mPopupItem = 0; 454 mPopupItem = 0;
464 mPopupKind = 2; 455 mPopupKind = 2;
465 selectItem(0); 456 selectItem(0);
466 mActionItem = 0; 457 mActionItem = 0;
467 mPopupPos = viewport()->mapToGlobal( me->pos() ); 458 mPopupPos = viewport()->mapToGlobal( me->pos() );
468 if (me->button() == RightButton) { 459 if (me->button() == RightButton) {
469 popupMenu(); 460 popupMenu();
470 } else if (me->button() == LeftButton) { 461 } else if (me->button() == LeftButton) {
471 setCursor(arrowCursor); 462 setCursor(arrowCursor);
472 startSelectAction(viewportPos); 463 startSelectAction(viewportPos);
473 } 464 }
474 } 465 }
475 break; 466 break;
476 467
477 case QEvent::MouseButtonRelease: 468 case QEvent::MouseButtonRelease:
478 if (me->button() == LeftButton ) { 469 if (me->button() == LeftButton ) {
479 mPopupTimer->stop(); 470 mPopupTimer->stop();
480 } 471 }
481 if (object != viewport()) { 472 if (object != viewport()) {
482 if (me->button() == LeftButton && mLeftMouseDown) { 473 if (me->button() == LeftButton && mLeftMouseDown) {
483 if (mActionItem) { 474 if (mActionItem) {
484 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 475 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
485 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 476 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
486 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 477 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
487 mScrollUpTimer.stop(); 478 mScrollUpTimer.stop();
488 mScrollDownTimer.stop(); 479 mScrollDownTimer.stop();
489 mActionItem->resetMove(); 480 mActionItem->resetMove();
490 placeSubCells( mActionItem ); 481 placeSubCells( mActionItem );
491 // emit startDragSignal( mActionItem->incidence() ); 482 // emit startDragSignal( mActionItem->incidence() );
492 setCursor( arrowCursor ); 483 setCursor( arrowCursor );
493 mActionItem = 0; 484 mActionItem = 0;
494 mActionType = NOP; 485 mActionType = NOP;
495 mItemMoved = 0; 486 mItemMoved = 0;
496 mLeftMouseDown = false; 487 mLeftMouseDown = false;
497 return true; 488 return true;
498 } 489 }
499 endItemAction(); 490 endItemAction();
500 } 491 }
501 } 492 }
502 493
503 } else { // ---------- viewport() 494 } else { // ---------- viewport()
504 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 495 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
505 endSelectAction( true ); // emit new event signal 496 endSelectAction( true ); // emit new event signal
506 } 497 }
507 } 498 }
508 if (me->button() == LeftButton) 499 if (me->button() == LeftButton)
509 mLeftMouseDown = false; 500 mLeftMouseDown = false;
510 501
511 break; 502 break;
512 503
513 case QEvent::MouseMove: 504 case QEvent::MouseMove:
514 if ( !mLeftMouseDown ) 505 if ( !mLeftMouseDown )
515 return true; 506 return true;
516 if ( blockMoving ) { 507 if ( blockMoving ) {
517 int dX, dY; 508 int dX, dY;
518 dX = startX - viewportPos.x(); 509 dX = startX - viewportPos.x();
519 if ( dX < 0 ) 510 if ( dX < 0 )
520 dX = -dX; 511 dX = -dX;
521 dY = viewportPos.y() - startY; 512 dY = viewportPos.y() - startY;
522 if ( dY < 0 ) 513 if ( dY < 0 )
523 dY = -dY; 514 dY = -dY;
524 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 515 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
525 if ( dX > blockmoveDist || dY > blockmoveDist ) { 516 if ( dX > blockmoveDist || dY > blockmoveDist ) {
526 blockMoving = false; 517 blockMoving = false;
527 } 518 }
528 } 519 }
529 if ( ! blockMoving ) 520 if ( ! blockMoving )
530 mPopupTimer->stop(); 521 mPopupTimer->stop();
531 if (object != viewport()) { 522 if (object != viewport()) {
532 KOAgendaItem *moveItem = (KOAgendaItem *)object; 523 KOAgendaItem *moveItem = (KOAgendaItem *)object;
533 if (!moveItem->incidence()->isReadOnly() ) { 524 if (!moveItem->incidence()->isReadOnly() ) {
534 if (!mActionItem) 525 if (!mActionItem)
535 setNoActionCursor(moveItem,viewportPos); 526 setNoActionCursor(moveItem,viewportPos);
536 else { 527 else {
537 if ( !blockMoving ) 528 if ( !blockMoving )
538 performItemAction(viewportPos); 529 performItemAction(viewportPos);
539 } 530 }
540 } 531 }
541 } else { // ---------- viewport() 532 } else { // ---------- viewport()
542 mPopupPos = viewport()->mapToGlobal( me->pos() ); 533 mPopupPos = viewport()->mapToGlobal( me->pos() );
543 if ( mActionType == SELECT ) { 534 if ( mActionType == SELECT ) {
544 performSelectAction( viewportPos ); 535 performSelectAction( viewportPos );
545 } 536 }
546 } 537 }
547 break; 538 break;
548 539
549 case QEvent::MouseButtonDblClick: 540 case QEvent::MouseButtonDblClick:
550 mPopupTimer->stop(); 541 mPopupTimer->stop();
551 if (object == viewport()) { 542 if (object == viewport()) {
552 selectItem(0); 543 selectItem(0);
553 int x,y; 544 int x,y;
554 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 545 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
555 int gx,gy; 546 int gx,gy;
556 contentsToGrid(x,y,gx,gy); 547 contentsToGrid(x,y,gx,gy);
557 emit newEventSignal(gx,gy); 548 emit newEventSignal(gx,gy);
558 } else { 549 } else {
559 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 550 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
560 selectItem(doubleClickedItem); 551 selectItem(doubleClickedItem);
561 if ( KOPrefs::instance()->mEditOnDoubleClick ) 552 if ( KOPrefs::instance()->mEditOnDoubleClick )
562 emit editIncidenceSignal(doubleClickedItem->incidence()); 553 emit editIncidenceSignal(doubleClickedItem->incidence());
563 else 554 else
564 emit showIncidenceSignal(doubleClickedItem->incidence()); 555 emit showIncidenceSignal(doubleClickedItem->incidence());
565 } 556 }
566 break; 557 break;
567 558
568 default: 559 default:
569 break; 560 break;
570 } 561 }
571 return true; 562 return true;
572#if 0 563#if 0
573 //qDebug("KOAgenda::eventFilter_mous "); 564 //qDebug("KOAgenda::eventFilter_mous ");
574 QPoint viewportPos; 565 QPoint viewportPos;
575 if (object != viewport()) { 566 if (object != viewport()) {
576 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 567 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
577 } else { 568 } else {
578 viewportPos = me->pos(); 569 viewportPos = me->pos();
579 } 570 }
580 static int startX = 0; 571 static int startX = 0;
581 static int startY = 0; 572 static int startY = 0;
582 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); 573 static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 );
583 static bool blockMoving = true; 574 static bool blockMoving = true;
584 static bool leftMouseDown = false; 575 static bool leftMouseDown = false;
585 bool rightButtonPressed = false; 576 bool rightButtonPressed = false;
586 switch (me->type()) { 577 switch (me->type()) {
587 case QEvent::MouseButtonPress: 578 case QEvent::MouseButtonPress:
588 if (me->button() == LeftButton) { 579 if (me->button() == LeftButton) {
589 leftMouseDown = true; 580 leftMouseDown = true;
590 } 581 }
591 else if (me->button() == RightButton) { 582 else if (me->button() == RightButton) {
592 leftMouseDown = false; 583 leftMouseDown = false;
593 } 584 }
594 blockMoving = true; 585 blockMoving = true;
595 startX = viewportPos.x(); 586 startX = viewportPos.x();
596 startY = viewportPos.y(); 587 startY = viewportPos.y();
597 if (object != viewport()) { // item clicked ************** 588 if (object != viewport()) { // item clicked **************
598 if (me->button() == RightButton) { 589 if (me->button() == RightButton) {
599 leftMouseDown = false; 590 leftMouseDown = false;
600 mClickedItem = (KOAgendaItem *)object; 591 mClickedItem = (KOAgendaItem *)object;
601 if (mActionItem ) { 592 if (mActionItem ) {
602 endItemAction(); 593 endItemAction();
603 } 594 }
604 if (mClickedItem) { 595 if (mClickedItem) {
605 selectItem(mClickedItem); 596 selectItem(mClickedItem);
606 emit showIncidencePopupSignal(mClickedItem->incidence()); 597 emit showIncidencePopupSignal(mClickedItem->incidence());
607 } 598 }
608 return true; 599 return true;
609 } else if (me->button() == LeftButton) { 600 } else if (me->button() == LeftButton) {
610 mActionItem = (KOAgendaItem *)object; 601 mActionItem = (KOAgendaItem *)object;
611 if (mActionItem) { 602 if (mActionItem) {
612 if ( mSelectionHeight > 0 ) { 603 if ( mSelectionHeight > 0 ) {
613 int selectionCellX = mSelectionCellX * mGridSpacingX; 604 int selectionCellX = mSelectionCellX * mGridSpacingX;
614 int selectionYTop = mSelectionYTop; 605 int selectionYTop = mSelectionYTop;
615 int gridSpacingX = mGridSpacingX; 606 int gridSpacingX = mGridSpacingX;
616 int selectionHeight = mSelectionHeight; 607 int selectionHeight = mSelectionHeight;
617 clearSelection(); 608 clearSelection();
618 repaintContents( selectionCellX, selectionYTop, 609 repaintContents( selectionCellX, selectionYTop,
619 gridSpacingX, selectionHeight,false ); 610 gridSpacingX, selectionHeight,false );
620 } 611 }
621 selectItem(mActionItem); 612 selectItem(mActionItem);
622 Incidence *incidence = mActionItem->incidence(); 613 Incidence *incidence = mActionItem->incidence();
623 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 614 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
624 mActionItem = 0; 615 mActionItem = 0;
625 } else { 616 } else {
626 startItemAction(viewportPos); 617 startItemAction(viewportPos);
627 } 618 }
628 } 619 }
629 } 620 }
630 } else { // ---------- viewport() 621 } else { // ---------- viewport()
631 selectItem(0); 622 selectItem(0);
632 mActionItem = 0; 623 mActionItem = 0;
633 if (me->button() == LeftButton ) { 624 if (me->button() == LeftButton ) {
634 setCursor(arrowCursor); 625 setCursor(arrowCursor);
635 startSelectAction(viewportPos); 626 startSelectAction(viewportPos);
636 } else if (me->button() == RightButton ) { 627 } else if (me->button() == RightButton ) {
637 setCursor(arrowCursor); 628 setCursor(arrowCursor);
638 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action 629 if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action
639 endSelectAction( false ); // do not emit new event signal 630 endSelectAction( false ); // do not emit new event signal
640 leftMouseDown = false; // no more leftMouse computation 631 leftMouseDown = false; // no more leftMouse computation
641 } 632 }
642 int x,y; 633 int x,y;
643 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 634 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
644 int gx,gy; 635 int gx,gy;
645 contentsToGrid(x,y,gx,gy); 636 contentsToGrid(x,y,gx,gy);
646 mCurrentCellX = gx; 637 mCurrentCellX = gx;
647 mCurrentCellY = gy; 638 mCurrentCellY = gy;
648 mStartCellX = gx; 639 mStartCellX = gx;
649 mStartCellY = gy; 640 mStartCellY = gy;
650 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); 641 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
651 } 642 }
652 } 643 }
653 break; 644 break;
654 645
655 case QEvent::MouseButtonRelease: 646 case QEvent::MouseButtonRelease:
656 647
657 if (object != viewport()) { 648 if (object != viewport()) {
658 if (me->button() == LeftButton && leftMouseDown) { 649 if (me->button() == LeftButton && leftMouseDown) {
659 if (mActionItem) { 650 if (mActionItem) {
660 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 651 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
661 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 652 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
662 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 653 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
663 mScrollUpTimer.stop(); 654 mScrollUpTimer.stop();
664 mScrollDownTimer.stop(); 655 mScrollDownTimer.stop();
665 mActionItem->resetMove(); 656 mActionItem->resetMove();
666 placeSubCells( mActionItem ); 657 placeSubCells( mActionItem );
667 // emit startDragSignal( mActionItem->incidence() ); 658 // emit startDragSignal( mActionItem->incidence() );
668 setCursor( arrowCursor ); 659 setCursor( arrowCursor );
669 mActionItem = 0; 660 mActionItem = 0;
670 mActionType = NOP; 661 mActionType = NOP;
671 mItemMoved = 0; 662 mItemMoved = 0;
672 leftMouseDown = false; 663 leftMouseDown = false;
673 return true; 664 return true;
674 } 665 }
675 endItemAction(); 666 endItemAction();
676 } 667 }
677 } 668 }
678 669
679 } else { // ---------- viewport() 670 } else { // ---------- viewport()
680 if (me->button() == LeftButton && leftMouseDown ) { //left click 671 if (me->button() == LeftButton && leftMouseDown ) { //left click
681 endSelectAction( true ); // emit new event signal 672 endSelectAction( true ); // emit new event signal
682 } 673 }
683 } 674 }
684 if (me->button() == LeftButton) 675 if (me->button() == LeftButton)
685 leftMouseDown = false; 676 leftMouseDown = false;
686 677
687 break; 678 break;
688 679
689 case QEvent::MouseMove: 680 case QEvent::MouseMove:
690 if ( !leftMouseDown ) 681 if ( !leftMouseDown )
691 return true; 682 return true;
692 if ( blockMoving ) { 683 if ( blockMoving ) {
693 int dX, dY; 684 int dX, dY;
694 dX = startX - viewportPos.x(); 685 dX = startX - viewportPos.x();
695 if ( dX < 0 ) 686 if ( dX < 0 )
696 dX = -dX; 687 dX = -dX;
697 dY = viewportPos.y() - startY; 688 dY = viewportPos.y() - startY;
698 if ( dY < 0 ) 689 if ( dY < 0 )
699 dY = -dY; 690 dY = -dY;
700 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 691 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
701 if ( dX > blockmoveDist || dY > blockmoveDist ) { 692 if ( dX > blockmoveDist || dY > blockmoveDist ) {
702 blockMoving = false; 693 blockMoving = false;
703 } 694 }
704 } 695 }
705 if (object != viewport()) { 696 if (object != viewport()) {
706 KOAgendaItem *moveItem = (KOAgendaItem *)object; 697 KOAgendaItem *moveItem = (KOAgendaItem *)object;
707 if (!moveItem->incidence()->isReadOnly() ) { 698 if (!moveItem->incidence()->isReadOnly() ) {
708 if (!mActionItem) 699 if (!mActionItem)
709 setNoActionCursor(moveItem,viewportPos); 700 setNoActionCursor(moveItem,viewportPos);
710 else { 701 else {
711 if ( !blockMoving ) 702 if ( !blockMoving )
712 performItemAction(viewportPos); 703 performItemAction(viewportPos);
713 } 704 }
714 } 705 }
715 } else { // ---------- viewport() 706 } else { // ---------- viewport()
716 if ( mActionType == SELECT ) { 707 if ( mActionType == SELECT ) {
717 performSelectAction( viewportPos ); 708 performSelectAction( viewportPos );
718 } 709 }
719 } 710 }
720 break; 711 break;
721 712
722 case QEvent::MouseButtonDblClick: 713 case QEvent::MouseButtonDblClick:
723 blockMoving = false; 714 blockMoving = false;
724 leftMouseDown = false; 715 leftMouseDown = false;
725 if (object == viewport()) { 716 if (object == viewport()) {
726 selectItem(0); 717 selectItem(0);
727 int x,y; 718 int x,y;
728 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 719 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
729 int gx,gy; 720 int gx,gy;
730 contentsToGrid(x,y,gx,gy); 721 contentsToGrid(x,y,gx,gy);
731 emit newEventSignal(gx,gy); 722 emit newEventSignal(gx,gy);
732 } else { 723 } else {
733 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 724 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
734 selectItem(doubleClickedItem); 725 selectItem(doubleClickedItem);
735 if ( KOPrefs::instance()->mEditOnDoubleClick ) 726 if ( KOPrefs::instance()->mEditOnDoubleClick )
736 emit editIncidenceSignal(doubleClickedItem->incidence()); 727 emit editIncidenceSignal(doubleClickedItem->incidence());
737 else 728 else
738 emit showIncidenceSignal(doubleClickedItem->incidence()); 729 emit showIncidenceSignal(doubleClickedItem->incidence());
739 } 730 }
740 break; 731 break;
741 732
742 default: 733 default:
743 break; 734 break;
744 } 735 }
745 return true; 736 return true;
746#endif 737#endif
747} 738}
748 739
749void KOAgenda::newItem( int item ) 740void KOAgenda::newItem( int item )
750{ 741{
751 if ( item == 1 ) { //new event 742 if ( item == 1 ) { //new event
752 newEventSignal(mStartCellX ,mStartCellY ); 743 newEventSignal(mStartCellX ,mStartCellY );
753 } else 744 } else
754 if ( item == 2 ) { //new event 745 if ( item == 2 ) { //new event
755 newTodoSignal(mStartCellX ,mStartCellY ); 746 newTodoSignal(mStartCellX ,mStartCellY );
756 } else 747 } else
757 { 748 {
758 QDate day = mSelectedDates[mStartCellX]; 749 QDate day = mSelectedDates[mStartCellX];
759 emit showDateView( item, day ); 750 emit showDateView( item, day );
760 // 3Day view 751 // 3Day view
761 // 4Week view 752 // 4Week view
762 // 5Month view 753 // 5Month view
763 // 6Journal view 754 // 6Journal view
764 } 755 }
765} 756}
766void KOAgenda::startSelectAction(QPoint viewportPos) 757void KOAgenda::startSelectAction(QPoint viewportPos)
767{ 758{
768 //emit newStartSelectSignal(); 759 //emit newStartSelectSignal();
769 760
770 mActionType = SELECT; 761 mActionType = SELECT;
771 762
772 int x,y; 763 int x,y;
773 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 764 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
774 int gx,gy; 765 int gx,gy;
775 contentsToGrid(x,y,gx,gy); 766 contentsToGrid(x,y,gx,gy);
776 767
777 mStartCellX = gx; 768 mStartCellX = gx;
778 mStartCellY = gy; 769 mStartCellY = gy;
779 mCurrentCellX = gx; 770 mCurrentCellX = gx;
780 mCurrentCellY = gy; 771 mCurrentCellY = gy;
781 772
782 // Store coordinates of old selection 773 // Store coordinates of old selection
783 int selectionX = mSelectionCellX * mGridSpacingX; 774 int selectionX = mSelectionCellX * mGridSpacingX;
784 int selectionYTop = mSelectionYTop; 775 int selectionYTop = mSelectionYTop;
785 int selectionHeight = mSelectionHeight; 776 int selectionHeight = mSelectionHeight;
786 777
787 // Store new selection 778 // Store new selection
788 mSelectionCellX = gx; 779 mSelectionCellX = gx;
789 mSelectionYTop = gy * mGridSpacingY; 780 mSelectionYTop = gy * mGridSpacingY;
790 mSelectionHeight = mGridSpacingY; 781 mSelectionHeight = mGridSpacingY;
791 782
792 // Clear old selection 783 // Clear old selection
793 repaintContents( selectionX, selectionYTop, 784 repaintContents( selectionX, selectionYTop,
794 mGridSpacingX, selectionHeight,false ); 785 mGridSpacingX, selectionHeight,false );
795 786
796 // Paint new selection 787 // Paint new selection
797 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, 788 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop,
798 // mGridSpacingX, mSelectionHeight ); 789 // mGridSpacingX, mSelectionHeight );
799} 790}
800 791
801void KOAgenda::performSelectAction(QPoint viewportPos) 792void KOAgenda::performSelectAction(QPoint viewportPos)
802{ 793{
803 int x,y; 794 int x,y;
804 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 795 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
805 int gx,gy; 796 int gx,gy;
806 contentsToGrid(x,y,gx,gy); 797 contentsToGrid(x,y,gx,gy);
807 798
808 QPoint clipperPos = clipper()-> 799 QPoint clipperPos = clipper()->
809 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 800 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
810 801
811 // Scroll if cursor was moved to upper or lower end of agenda. 802 // Scroll if cursor was moved to upper or lower end of agenda.
812 if (clipperPos.y() < mScrollBorderWidth) { 803 if (clipperPos.y() < mScrollBorderWidth) {
813 mScrollUpTimer.start(mScrollDelay); 804 mScrollUpTimer.start(mScrollDelay);
814 } else if (visibleHeight() - clipperPos.y() < 805 } else if (visibleHeight() - clipperPos.y() <
815 mScrollBorderWidth) { 806 mScrollBorderWidth) {
816 mScrollDownTimer.start(mScrollDelay); 807 mScrollDownTimer.start(mScrollDelay);
817 } else { 808 } else {
818 mScrollUpTimer.stop(); 809 mScrollUpTimer.stop();
819 mScrollDownTimer.stop(); 810 mScrollDownTimer.stop();
820 } 811 }
821 812
822 if ( gy > mCurrentCellY ) { 813 if ( gy > mCurrentCellY ) {
823 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 814 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
824 815
825#if 0 816#if 0
826 // FIXME: Repaint only the newly selected region 817 // FIXME: Repaint only the newly selected region
827 repaintContents( mSelectionCellX * mGridSpacingX, 818 repaintContents( mSelectionCellX * mGridSpacingX,
828 mCurrentCellY + mGridSpacingY, 819 mCurrentCellY + mGridSpacingY,
829 mGridSpacingX, 820 mGridSpacingX,
830 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); 821 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY );
831#else 822#else
832 repaintContents( (KOGlobals::self()->reverseLayout() ? 823 repaintContents( (KOGlobals::self()->reverseLayout() ?
833 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 824 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
834 mGridSpacingX, mSelectionYTop, 825 mGridSpacingX, mSelectionYTop,
835 mGridSpacingX, mSelectionHeight , false); 826 mGridSpacingX, mSelectionHeight , false);
836#endif 827#endif
837 828
838 mCurrentCellY = gy; 829 mCurrentCellY = gy;
839 } else if ( gy < mCurrentCellY ) { 830 } else if ( gy < mCurrentCellY ) {
840 if ( gy >= mStartCellY ) { 831 if ( gy >= mStartCellY ) {
841 int selectionHeight = mSelectionHeight; 832 int selectionHeight = mSelectionHeight;
842 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 833 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
843 834
844 repaintContents( (KOGlobals::self()->reverseLayout() ? 835 repaintContents( (KOGlobals::self()->reverseLayout() ?
845 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 836 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
846 mGridSpacingX, mSelectionYTop, 837 mGridSpacingX, mSelectionYTop,
847 mGridSpacingX, selectionHeight,false ); 838 mGridSpacingX, selectionHeight,false );
848 839
849 mCurrentCellY = gy; 840 mCurrentCellY = gy;
850 } else { 841 } else {
851 } 842 }
852 } 843 }
853} 844}
854 845
855void KOAgenda::endSelectAction( bool emitNewEvent ) 846void KOAgenda::endSelectAction( bool emitNewEvent )
856{ 847{
857 mActionType = NOP; 848 mActionType = NOP;
858 mScrollUpTimer.stop(); 849 mScrollUpTimer.stop();
859 mScrollDownTimer.stop(); 850 mScrollDownTimer.stop();
860 851
861 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 852 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
862 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 853 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
863 qDebug("ew event signal "); 854 qDebug("ew event signal ");
864 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 855 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
865 } 856 }
866} 857}
867 858
868void KOAgenda::startItemAction(QPoint viewportPos) 859void KOAgenda::startItemAction(QPoint viewportPos)
869{ 860{
870 int x,y; 861 int x,y;
871 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 862 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
872 int gx,gy; 863 int gx,gy;
873 contentsToGrid(x,y,gx,gy); 864 contentsToGrid(x,y,gx,gy);
874 865
875 mStartCellX = gx; 866 mStartCellX = gx;
876 mStartCellY = gy; 867 mStartCellY = gy;
877 mCurrentCellX = gx; 868 mCurrentCellX = gx;
878 mCurrentCellY = gy; 869 mCurrentCellY = gy;
879 870
880 if (mAllDayMode) { 871 if (mAllDayMode) {
881 int gridDistanceX = (x - gx * mGridSpacingX); 872 int gridDistanceX = (x - gx * mGridSpacingX);
882 if (gridDistanceX < mResizeBorderWidth && 873 if (gridDistanceX < mResizeBorderWidth &&
883 mActionItem->cellX() == mCurrentCellX) { 874 mActionItem->cellX() == mCurrentCellX) {
884 mActionType = RESIZELEFT; 875 mActionType = RESIZELEFT;
885 setCursor(sizeHorCursor); 876 setCursor(sizeHorCursor);
886 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 877 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
887 mActionItem->cellXWidth() == mCurrentCellX) { 878 mActionItem->cellXWidth() == mCurrentCellX) {
888 mActionType = RESIZERIGHT; 879 mActionType = RESIZERIGHT;
889 setCursor(sizeHorCursor); 880 setCursor(sizeHorCursor);
890 } else { 881 } else {
891 mActionType = MOVE; 882 mActionType = MOVE;
892 mActionItem->startMove(); 883 mActionItem->startMove();
893 setCursor(sizeAllCursor); 884 setCursor(sizeAllCursor);
894 } 885 }
895 } else { 886 } else {
896 int gridDistanceY = (y - gy * mGridSpacingY); 887 int gridDistanceY = (y - gy * mGridSpacingY);
897 bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); 888 bool allowResize = ( mActionItem->incidence()->type() != "Todo" );
898 if (allowResize && gridDistanceY < mResizeBorderWidth && 889 if (allowResize && gridDistanceY < mResizeBorderWidth &&
899 mActionItem->cellYTop() == mCurrentCellY && 890 mActionItem->cellYTop() == mCurrentCellY &&
900 !mActionItem->firstMultiItem()) { 891 !mActionItem->firstMultiItem()) {
901 mActionType = RESIZETOP; 892 mActionType = RESIZETOP;
902 setCursor(sizeVerCursor); 893 setCursor(sizeVerCursor);
903 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 894 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
904 mActionItem->cellYBottom() == mCurrentCellY && 895 mActionItem->cellYBottom() == mCurrentCellY &&
905 !mActionItem->lastMultiItem()) { 896 !mActionItem->lastMultiItem()) {
906 mActionType = RESIZEBOTTOM; 897 mActionType = RESIZEBOTTOM;
907 setCursor(sizeVerCursor); 898 setCursor(sizeVerCursor);
908 } else { 899 } else {
909 mActionType = MOVE; 900 mActionType = MOVE;
910 mActionItem->startMove(); 901 mActionItem->startMove();
911 setCursor(sizeAllCursor); 902 setCursor(sizeAllCursor);
912 } 903 }
913 } 904 }
914} 905}
915 906
916void KOAgenda::performItemAction(QPoint viewportPos) 907void KOAgenda::performItemAction(QPoint viewportPos)
917{ 908{
918// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 909// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
919// QPoint point = viewport()->mapToGlobal(viewportPos); 910// QPoint point = viewport()->mapToGlobal(viewportPos);
920// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 911// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
921// point = clipper()->mapFromGlobal(point); 912// point = clipper()->mapFromGlobal(point);
922// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 913// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
923// kdDebug() << "visible height: " << visibleHeight() << endl; 914// kdDebug() << "visible height: " << visibleHeight() << endl;
924 int x,y; 915 int x,y;
925 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 916 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
926// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 917// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
927 int gx,gy; 918 int gx,gy;
928 contentsToGrid(x,y,gx,gy); 919 contentsToGrid(x,y,gx,gy);
929 QPoint clipperPos = clipper()-> 920 QPoint clipperPos = clipper()->
930 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 921 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
931 922
932 // Cursor left active agenda area. 923 // Cursor left active agenda area.
933 // This starts a drag. 924 // This starts a drag.
934 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 925 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
935 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 926 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
936 if ( mActionType == MOVE ) { 927 if ( mActionType == MOVE ) {
937 mScrollUpTimer.stop(); 928 mScrollUpTimer.stop();
938 mScrollDownTimer.stop(); 929 mScrollDownTimer.stop();
939 mActionItem->resetMove(); 930 mActionItem->resetMove();
940 placeSubCells( mActionItem ); 931 placeSubCells( mActionItem );
941 // emit startDragSignal( mActionItem->incidence() ); 932 // emit startDragSignal( mActionItem->incidence() );
942 setCursor( arrowCursor ); 933 setCursor( arrowCursor );
943 mActionItem = 0; 934 mActionItem = 0;
944 mActionType = NOP; 935 mActionType = NOP;
945 mItemMoved = 0; 936 mItemMoved = 0;
946 return; 937 return;
947 } 938 }
948 } else { 939 } else {
949 switch ( mActionType ) { 940 switch ( mActionType ) {
950 case MOVE: 941 case MOVE:
951 setCursor( sizeAllCursor ); 942 setCursor( sizeAllCursor );
952 break; 943 break;
953 case RESIZETOP: 944 case RESIZETOP:
954 case RESIZEBOTTOM: 945 case RESIZEBOTTOM:
955 setCursor( sizeVerCursor ); 946 setCursor( sizeVerCursor );
956 break; 947 break;
957 case RESIZELEFT: 948 case RESIZELEFT:
958 case RESIZERIGHT: 949 case RESIZERIGHT:
959 setCursor( sizeHorCursor ); 950 setCursor( sizeHorCursor );
960 break; 951 break;
961 default: 952 default:
962 setCursor( arrowCursor ); 953 setCursor( arrowCursor );
963 } 954 }
964 } 955 }
965 956
966 // Scroll if item was moved to upper or lower end of agenda. 957 // Scroll if item was moved to upper or lower end of agenda.
967 if (clipperPos.y() < mScrollBorderWidth) { 958 if (clipperPos.y() < mScrollBorderWidth) {
968 mScrollUpTimer.start(mScrollDelay); 959 mScrollUpTimer.start(mScrollDelay);
969 } else if (visibleHeight() - clipperPos.y() < 960 } else if (visibleHeight() - clipperPos.y() <
970 mScrollBorderWidth) { 961 mScrollBorderWidth) {
971 mScrollDownTimer.start(mScrollDelay); 962 mScrollDownTimer.start(mScrollDelay);
972 } else { 963 } else {
973 mScrollUpTimer.stop(); 964 mScrollUpTimer.stop();
974 mScrollDownTimer.stop(); 965 mScrollDownTimer.stop();
975 } 966 }
976 967
977 // Move or resize item if necessary 968 // Move or resize item if necessary
978 if (mCurrentCellX != gx || mCurrentCellY != gy) { 969 if (mCurrentCellX != gx || mCurrentCellY != gy) {
979 mItemMoved = true; 970 mItemMoved = true;
980 mActionItem->raise(); 971 mActionItem->raise();
981 if (mActionType == MOVE) { 972 if (mActionType == MOVE) {
982 // Move all items belonging to a multi item 973 // Move all items belonging to a multi item
983 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 974 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
984 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 975 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
985 if (!moveItem) moveItem = mActionItem; 976 if (!moveItem) moveItem = mActionItem;
986 while (moveItem) { 977 while (moveItem) {
987 int dy; 978 int dy;
988 if (isMultiItem) dy = 0; 979 if (isMultiItem) dy = 0;
989 else dy = gy - mCurrentCellY; 980 else dy = gy - mCurrentCellY;
990 moveItem->moveRelative(gx - mCurrentCellX,dy); 981 moveItem->moveRelative(gx - mCurrentCellX,dy);
991 int x,y; 982 int x,y;
992 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 983 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
993 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 984 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
994 mGridSpacingY * moveItem->cellHeight()); 985 mGridSpacingY * moveItem->cellHeight());
995 moveChild(moveItem,x,y); 986 moveChild(moveItem,x,y);
996 moveItem = moveItem->nextMultiItem(); 987 moveItem = moveItem->nextMultiItem();
997 } 988 }
998 } else if (mActionType == RESIZETOP) { 989 } else if (mActionType == RESIZETOP) {
999 if (mCurrentCellY <= mActionItem->cellYBottom()) { 990 if (mCurrentCellY <= mActionItem->cellYBottom()) {
1000 mActionItem->expandTop(gy - mCurrentCellY); 991 mActionItem->expandTop(gy - mCurrentCellY);
1001 mActionItem->resize(mActionItem->width(), 992 mActionItem->resize(mActionItem->width(),
1002 mGridSpacingY * mActionItem->cellHeight()); 993 mGridSpacingY * mActionItem->cellHeight());
1003 int x,y; 994 int x,y;
1004 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 995 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
1005 //moveChild(mActionItem,childX(mActionItem),y); 996 //moveChild(mActionItem,childX(mActionItem),y);
1006 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 997 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
1007 } 998 }
1008 } else if (mActionType == RESIZEBOTTOM) { 999 } else if (mActionType == RESIZEBOTTOM) {
1009 if (mCurrentCellY >= mActionItem->cellYTop()) { 1000 if (mCurrentCellY >= mActionItem->cellYTop()) {
1010 mActionItem->expandBottom(gy - mCurrentCellY); 1001 mActionItem->expandBottom(gy - mCurrentCellY);
1011 mActionItem->resize(mActionItem->width(), 1002 mActionItem->resize(mActionItem->width(),
1012 mGridSpacingY * mActionItem->cellHeight()); 1003 mGridSpacingY * mActionItem->cellHeight());
1013 } 1004 }
1014 } else if (mActionType == RESIZELEFT) { 1005 } else if (mActionType == RESIZELEFT) {
1015 if (mCurrentCellX <= mActionItem->cellXWidth()) { 1006 if (mCurrentCellX <= mActionItem->cellXWidth()) {
1016 mActionItem->expandLeft(gx - mCurrentCellX); 1007 mActionItem->expandLeft(gx - mCurrentCellX);
1017 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 1008 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
1018 mActionItem->height()); 1009 mActionItem->height());
1019 int x,y; 1010 int x,y;
1020 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 1011 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
1021 moveChild(mActionItem,x,childY(mActionItem)); 1012 moveChild(mActionItem,x,childY(mActionItem));
1022 } 1013 }
1023 } else if (mActionType == RESIZERIGHT) { 1014 } else if (mActionType == RESIZERIGHT) {
1024 if (mCurrentCellX >= mActionItem->cellX()) { 1015 if (mCurrentCellX >= mActionItem->cellX()) {
1025 mActionItem->expandRight(gx - mCurrentCellX); 1016 mActionItem->expandRight(gx - mCurrentCellX);
1026 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 1017 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
1027 mActionItem->height()); 1018 mActionItem->height());
1028 } 1019 }
1029 } 1020 }
1030 mCurrentCellX = gx; 1021 mCurrentCellX = gx;
1031 mCurrentCellY = gy; 1022 mCurrentCellY = gy;
1032 } 1023 }
1033} 1024}
1034 1025
1035void KOAgenda::endItemAction() 1026void KOAgenda::endItemAction()
1036{ 1027{
1037 1028
1038 if ( mItemMoved ) { 1029 if ( mItemMoved ) {
1039 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 1030 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
1040 if ( !placeItem ) { 1031 if ( !placeItem ) {
1041 placeItem = mActionItem; 1032 placeItem = mActionItem;
1042 } 1033 }
1043 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 1034 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
1044 Incidence* oldInc = placeItem->incidence(); 1035 Incidence* oldInc = placeItem->incidence();
1045 placeItem->recreateIncidence(); 1036 placeItem->recreateIncidence();
1046 emit addToCalSignal(placeItem->incidence(), oldInc ); 1037 emit addToCalSignal(placeItem->incidence(), oldInc );
1047 } 1038 }
1048 int type = mActionType; 1039 int type = mActionType;
1049 if ( mAllDayMode ) 1040 if ( mAllDayMode )
1050 type = -1; 1041 type = -1;
1051 KOAgendaItem *modifiedItem = placeItem; 1042 KOAgendaItem *modifiedItem = placeItem;
1052 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 1043 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
1053 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 1044 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
1054 KOAgendaItem *item; 1045 KOAgendaItem *item;
1055 1046
1056 if ( placeItem->incidence()->type() == "Todo" ) { 1047 if ( placeItem->incidence()->type() == "Todo" ) {
1057 mSelectedItem = 0; 1048 mSelectedItem = 0;
1058 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 1049 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
1059 modifiedItem->mLastMoveXPos = mCurrentCellX; 1050 modifiedItem->mLastMoveXPos = mCurrentCellX;
1060 emit itemModified( modifiedItem, mActionType ); 1051 emit itemModified( modifiedItem, mActionType );
1061 } 1052 }
1062 else { 1053 else {
1063#if 0 1054#if 0
1064 for ( item=oldconflictItems.first(); item != 0; 1055 for ( item=oldconflictItems.first(); item != 0;
1065 item=oldconflictItems.next() ) { 1056 item=oldconflictItems.next() ) {
1066 placeSubCells(item); 1057 placeSubCells(item);
1067 } 1058 }
1068 while ( placeItem ) { 1059 while ( placeItem ) {
1069 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1060 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1070 placeSubCells( placeItem ); 1061 placeSubCells( placeItem );
1071 placeItem = placeItem->nextMultiItem(); 1062 placeItem = placeItem->nextMultiItem();
1072 } 1063 }
1073#endif 1064#endif
1074 1065
1075 globalFlagBlockAgendaItemPaint = 1; 1066 globalFlagBlockAgendaItemPaint = 1;
1076 for ( item=oldconflictItems.first(); item != 0; 1067 for ( item=oldconflictItems.first(); item != 0;
1077 item=oldconflictItems.next() ) { 1068 item=oldconflictItems.next() ) {
1078 placeSubCells(item); 1069 placeSubCells(item);
1079 } 1070 }
1080 while ( placeItem ) { 1071 while ( placeItem ) {
1081 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1072 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1082 oldconflictItems = placeItem->conflictItems(); 1073 oldconflictItems = placeItem->conflictItems();
1083 for ( item=oldconflictItems.first(); item != 0; 1074 for ( item=oldconflictItems.first(); item != 0;
1084 item=oldconflictItems.next() ) { 1075 item=oldconflictItems.next() ) {
1085 placeSubCells(item); 1076 placeSubCells(item);
1086 } 1077 }
1087 placeSubCells( placeItem ); 1078 placeSubCells( placeItem );
1088 placeItem = placeItem->nextMultiItem(); 1079 placeItem = placeItem->nextMultiItem();
1089 } 1080 }
1090 globalFlagBlockAgendaItemPaint = 0; 1081 globalFlagBlockAgendaItemPaint = 0;
1091 for ( item=oldconflictItems.first(); item != 0; 1082 for ( item=oldconflictItems.first(); item != 0;
1092 item=oldconflictItems.next() ) { 1083 item=oldconflictItems.next() ) {
1093 globalFlagBlockAgendaItemUpdate = 0; 1084 globalFlagBlockAgendaItemUpdate = 0;
1094 item->repaintMe(); 1085 item->repaintMe();
1095 globalFlagBlockAgendaItemUpdate = 1; 1086 globalFlagBlockAgendaItemUpdate = 1;
1096 item->repaint( false ); 1087 item->repaint( false );
1097 } 1088 }
1098 placeItem = modifiedItem; 1089 placeItem = modifiedItem;
1099 1090
1100 while ( placeItem ) { 1091 while ( placeItem ) {
1101 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1092 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1102 globalFlagBlockAgendaItemUpdate = 0; 1093 globalFlagBlockAgendaItemUpdate = 0;
1103 placeItem->repaintMe(); 1094 placeItem->repaintMe();
1104 globalFlagBlockAgendaItemUpdate = 1; 1095 globalFlagBlockAgendaItemUpdate = 1;
1105 placeItem->repaint(false); 1096 placeItem->repaint(false);
1106 placeItem = placeItem->nextMultiItem(); 1097 placeItem = placeItem->nextMultiItem();
1107 } 1098 }
1108 emit itemModified( modifiedItem, mActionType ); 1099 emit itemModified( modifiedItem, mActionType );
1109 1100
1110 1101
1111 placeItem = modifiedItem; 1102 placeItem = modifiedItem;
1112 while ( placeItem ) { 1103 while ( placeItem ) {
1113 oldconflictItems = placeItem->conflictItems(); 1104 oldconflictItems = placeItem->conflictItems();
1114 for ( item=oldconflictItems.first(); item != 0; 1105 for ( item=oldconflictItems.first(); item != 0;
1115 item=oldconflictItems.next() ) { 1106 item=oldconflictItems.next() ) {
1116 placeSubCells(item); 1107 placeSubCells(item);
1117 } 1108 }
1118 placeSubCells( placeItem ); 1109 placeSubCells( placeItem );
1119 placeItem = placeItem->nextMultiItem(); 1110 placeItem = placeItem->nextMultiItem();
1120 1111
1121 } 1112 }
1122 placeItem = modifiedItem; 1113 placeItem = modifiedItem;
1123 while ( placeItem ) { 1114 while ( placeItem ) {
1124 oldconflictItems = placeItem->conflictItems(); 1115 oldconflictItems = placeItem->conflictItems();
1125 for ( item=oldconflictItems.first(); item != 0; 1116 for ( item=oldconflictItems.first(); item != 0;
1126 item=oldconflictItems.next() ) { 1117 item=oldconflictItems.next() ) {
1127 globalFlagBlockAgendaItemUpdate = 0; 1118 globalFlagBlockAgendaItemUpdate = 0;
1128 item->repaintMe(); 1119 item->repaintMe();
1129 globalFlagBlockAgendaItemUpdate = 1; 1120 globalFlagBlockAgendaItemUpdate = 1;
1130 item->repaint(false); 1121 item->repaint(false);
1131 } 1122 }
1132 placeItem = placeItem->nextMultiItem(); 1123 placeItem = placeItem->nextMultiItem();
1133 } 1124 }
1134 /* 1125 /*
1135 1126
1136 oldconflictItems = modifiedItem->conflictItems(); 1127 oldconflictItems = modifiedItem->conflictItems();
1137 for ( item=oldconflictItems.first(); item != 0; 1128 for ( item=oldconflictItems.first(); item != 0;
1138 item=oldconflictItems.next() ) { 1129 item=oldconflictItems.next() ) {
1139 globalFlagBlockAgendaItemUpdate = 0; 1130 globalFlagBlockAgendaItemUpdate = 0;
1140 item->paintMe(false); 1131 item->paintMe(false);
1141 globalFlagBlockAgendaItemUpdate = 1; 1132 globalFlagBlockAgendaItemUpdate = 1;
1142 item->repaint(false); 1133 item->repaint(false);
1143 } 1134 }
1144 */ 1135 */
1145 1136
1146 1137
1147 } 1138 }
1148 1139
1149 } 1140 }
1150 1141
1151 mScrollUpTimer.stop(); 1142 mScrollUpTimer.stop();
1152 mScrollDownTimer.stop(); 1143 mScrollDownTimer.stop();
1153 setCursor( arrowCursor ); 1144 setCursor( arrowCursor );
1154 mActionItem = 0; 1145 mActionItem = 0;
1155 mActionType = NOP; 1146 mActionType = NOP;
1156 mItemMoved = 0; 1147 mItemMoved = 0;
1157 1148
1158} 1149}
1159 1150
1160void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 1151void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1161{ 1152{
1162// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 1153// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
1163// QPoint point = viewport()->mapToGlobal(viewportPos); 1154// QPoint point = viewport()->mapToGlobal(viewportPos);
1164// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 1155// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
1165// point = clipper()->mapFromGlobal(point); 1156// point = clipper()->mapFromGlobal(point);
1166// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 1157// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
1167 1158
1168 int x,y; 1159 int x,y;
1169 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 1160 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
1170// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 1161// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
1171 int gx,gy; 1162 int gx,gy;
1172 contentsToGrid(x,y,gx,gy); 1163 contentsToGrid(x,y,gx,gy);
1173 1164
1174 // Change cursor to resize cursor if appropriate 1165 // Change cursor to resize cursor if appropriate
1175 if (mAllDayMode) { 1166 if (mAllDayMode) {
1176 int gridDistanceX = (x - gx * mGridSpacingX); 1167 int gridDistanceX = (x - gx * mGridSpacingX);
1177 if (gridDistanceX < mResizeBorderWidth && 1168 if (gridDistanceX < mResizeBorderWidth &&
1178 moveItem->cellX() == gx) { 1169 moveItem->cellX() == gx) {
1179 setCursor(sizeHorCursor); 1170 setCursor(sizeHorCursor);
1180 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 1171 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
1181 moveItem->cellXWidth() == gx) { 1172 moveItem->cellXWidth() == gx) {
1182 setCursor(sizeHorCursor); 1173 setCursor(sizeHorCursor);
1183 } else { 1174 } else {
1184 setCursor(arrowCursor); 1175 setCursor(arrowCursor);
1185 } 1176 }
1186 } else { 1177 } else {
1187 int gridDistanceY = (y - gy * mGridSpacingY); 1178 int gridDistanceY = (y - gy * mGridSpacingY);
1188 if (gridDistanceY < mResizeBorderWidth && 1179 if (gridDistanceY < mResizeBorderWidth &&
1189 moveItem->cellYTop() == gy && 1180 moveItem->cellYTop() == gy &&
1190 !moveItem->firstMultiItem()) { 1181 !moveItem->firstMultiItem()) {
1191 setCursor(sizeVerCursor); 1182 setCursor(sizeVerCursor);
1192 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 1183 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
1193 moveItem->cellYBottom() == gy && 1184 moveItem->cellYBottom() == gy &&
1194 !moveItem->lastMultiItem()) { 1185 !moveItem->lastMultiItem()) {
1195 setCursor(sizeVerCursor); 1186 setCursor(sizeVerCursor);
1196 } else { 1187 } else {
1197 setCursor(arrowCursor); 1188 setCursor(arrowCursor);
1198 } 1189 }
1199 } 1190 }
1200} 1191}
1201 1192
1202 1193
1203/* 1194/*
1204 Place item in cell and take care that multiple items using the same cell do 1195 Place item in cell and take care that multiple items using the same cell do
1205 not overlap. This method is not yet optimal. It doesn´t use the maximum space 1196 not overlap. This method is not yet optimal. It doesn´t use the maximum space
1206 it can get in all cases. 1197 it can get in all cases.
1207 At the moment the method has a bug: When an item is placed only the sub cell 1198 At the moment the method has a bug: When an item is placed only the sub cell
1208 widths of the items are changed, which are within the Y region the item to 1199 widths of the items are changed, which are within the Y region the item to
1209 place spans. When the sub cell width change of one of this items affects a 1200 place spans. When the sub cell width change of one of this items affects a
1210 cell, where other items are, which do not overlap in Y with the item to place, 1201 cell, where other items are, which do not overlap in Y with the item to place,
1211 the display gets corrupted, although the corruption looks quite nice. 1202 the display gets corrupted, although the corruption looks quite nice.
1212*/ 1203*/
1213void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1204void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1214{ 1205{
1215 1206
1216 QPtrList<KOAgendaItem> conflictItems; 1207 QPtrList<KOAgendaItem> conflictItems;
1217 int maxSubCells = 0; 1208 int maxSubCells = 0;
1218 QIntDict<KOAgendaItem> subCellDict(5); 1209 QIntDict<KOAgendaItem> subCellDict(5);
1219 1210
1220 KOAgendaItem *item; 1211 KOAgendaItem *item;
1221 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1212 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1222 if (item != placeItem) { 1213 if (item != placeItem) {
1223 if (placeItem->cellX() <= item->cellXWidth() && 1214 if (placeItem->cellX() <= item->cellXWidth() &&
1224 placeItem->cellXWidth() >= item->cellX()) { 1215 placeItem->cellXWidth() >= item->cellX()) {
1225 if ((placeItem->cellYTop() <= item->cellYBottom()) && 1216 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
1226 (placeItem->cellYBottom() >= item->cellYTop())) { 1217 (placeItem->cellYBottom() >= item->cellYTop())) {
1227 conflictItems.append(item); 1218 conflictItems.append(item);
1228 if (item->subCells() > maxSubCells) 1219 if (item->subCells() > maxSubCells)
1229 maxSubCells = item->subCells(); 1220 maxSubCells = item->subCells();
1230 subCellDict.insert(item->subCell(),item); 1221 subCellDict.insert(item->subCell(),item);
1231 } 1222 }
1232 } 1223 }
1233 } 1224 }
1234 } 1225 }
1235 1226
1236 if (conflictItems.count() > 0) { 1227 if (conflictItems.count() > 0) {
1237 // Look for unused sub cell and insert item 1228 // Look for unused sub cell and insert item
1238 int i; 1229 int i;
1239 for(i=0;i<maxSubCells;++i) { 1230 for(i=0;i<maxSubCells;++i) {
1240 if (!subCellDict.find(i)) { 1231 if (!subCellDict.find(i)) {
1241 placeItem->setSubCell(i); 1232 placeItem->setSubCell(i);
1242 break; 1233 break;
1243 } 1234 }
1244 } 1235 }
1245 if (i == maxSubCells) { 1236 if (i == maxSubCells) {
1246 placeItem->setSubCell(maxSubCells); 1237 placeItem->setSubCell(maxSubCells);
1247 maxSubCells++; // add new item to number of sub cells 1238 maxSubCells++; // add new item to number of sub cells
1248 } 1239 }
1249 1240
1250 // Prepare for sub cell geometry adjustment 1241 // Prepare for sub cell geometry adjustment
1251 int newSubCellWidth; 1242 int newSubCellWidth;
1252 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1243 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1253 else newSubCellWidth = mGridSpacingX / maxSubCells; 1244 else newSubCellWidth = mGridSpacingX / maxSubCells;
1254 conflictItems.append(placeItem); 1245 conflictItems.append(placeItem);
1255 1246
1256 1247
1257 // Adjust sub cell geometry of all direct conflict items 1248 // Adjust sub cell geometry of all direct conflict items
1258 for ( item=conflictItems.first(); item != 0; 1249 for ( item=conflictItems.first(); item != 0;
1259 item=conflictItems.next() ) { 1250 item=conflictItems.next() ) {
1260 item->setSubCells(maxSubCells); 1251 item->setSubCells(maxSubCells);
1261 if (mAllDayMode) { 1252 if (mAllDayMode) {
1262 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1253 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1263 } else { 1254 } else {
1264 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1255 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1265 } 1256 }
1266 int x,y; 1257 int x,y;
1267 gridToContents(item->cellX(),item->cellYTop(),x,y); 1258 gridToContents(item->cellX(),item->cellYTop(),x,y);
1268 if (mAllDayMode) { 1259 if (mAllDayMode) {
1269 y += item->subCell() * newSubCellWidth; 1260 y += item->subCell() * newSubCellWidth;
1270 } else { 1261 } else {
1271 x += item->subCell() * newSubCellWidth; 1262 x += item->subCell() * newSubCellWidth;
1272 } 1263 }
1273 moveChild(item,x,y); 1264 moveChild(item,x,y);
1274 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1265 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1275 //item->updateItem(); 1266 //item->updateItem();
1276 } 1267 }
1277 // Adjust sub cell geometry of all conflict items of all conflict items 1268 // Adjust sub cell geometry of all conflict items of all conflict items
1278 for ( item=conflictItems.first(); item != 0; 1269 for ( item=conflictItems.first(); item != 0;
1279 item=conflictItems.next() ) { 1270 item=conflictItems.next() ) {
1280 if ( placeItem != item ) { 1271 if ( placeItem != item ) {
1281 KOAgendaItem *item2; 1272 KOAgendaItem *item2;
1282 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1273 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1283 for ( item2=conflictItems2.first(); item2 != 0; 1274 for ( item2=conflictItems2.first(); item2 != 0;
1284 item2=conflictItems2.next() ) { 1275 item2=conflictItems2.next() ) {
1285 if ( item2->subCells() != maxSubCells) { 1276 if ( item2->subCells() != maxSubCells) {
1286 item2->setSubCells(maxSubCells); 1277 item2->setSubCells(maxSubCells);
1287 if (mAllDayMode) { 1278 if (mAllDayMode) {
1288 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1279 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1289 } else { 1280 } else {
1290 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1281 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1291 } 1282 }
1292 int x,y; 1283 int x,y;
1293 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1284 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1294 if (mAllDayMode) { 1285 if (mAllDayMode) {
1295 y += item2->subCell() * newSubCellWidth; 1286 y += item2->subCell() * newSubCellWidth;
1296 } else { 1287 } else {
1297 x += item2->subCell() * newSubCellWidth; 1288 x += item2->subCell() * newSubCellWidth;
1298 } 1289 }
1299 moveChild(item2,x,y); 1290 moveChild(item2,x,y);
1300 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1291 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1301 } 1292 }
1302 } 1293 }
1303 } 1294 }
1304 } 1295 }
1305 } else { 1296 } else {
1306 placeItem->setSubCell(0); 1297 placeItem->setSubCell(0);
1307 placeItem->setSubCells(1); 1298 placeItem->setSubCells(1);
1308 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1299 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1309 else placeItem->resize(mGridSpacingX,placeItem->height()); 1300 else placeItem->resize(mGridSpacingX,placeItem->height());
1310 int x,y; 1301 int x,y;
1311 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1302 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1312 moveChild(placeItem,x,y); 1303 moveChild(placeItem,x,y);
1313 } 1304 }
1314 placeItem->setConflictItems(conflictItems); 1305 placeItem->setConflictItems(conflictItems);
1315 // for ( item=conflictItems.first(); item != 0; 1306 // for ( item=conflictItems.first(); item != 0;
1316// item=conflictItems.next() ) { 1307// item=conflictItems.next() ) {
1317// //item->updateItem(); 1308// //item->updateItem();
1318// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1309// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1319// } 1310// }
1320// placeItem->updateItem(); 1311// placeItem->updateItem();
1321} 1312}
1322 1313
1323void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1314void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1324{ 1315{
1325 if ( globalFlagBlockAgenda ) 1316 if ( globalFlagBlockAgenda )
1326 return; 1317 return;
1327 //qDebug("KOAgenda::drawContents "); 1318 //qDebug("KOAgenda::drawContents ");
1328 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1319 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1329 ;//drawContentsToPainter(); 1320 ;//drawContentsToPainter();
1330 1321
1331 QPaintDevice* pd = p->device(); 1322 QPaintDevice* pd = p->device();
1332 p->end(); 1323 p->end();
1333 int vx, vy; 1324 int vx, vy;
1334 int selectionX = KOGlobals::self()->reverseLayout() ? 1325 int selectionX = KOGlobals::self()->reverseLayout() ?
1335 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1326 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1336 mSelectionCellX * mGridSpacingX; 1327 mSelectionCellX * mGridSpacingX;
1337 contentsToViewport ( cx, cy, vx,vy); 1328 contentsToViewport ( cx, cy, vx,vy);
1338 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1329 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1339 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1330 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1340 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1331 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1341 1332
1342 if ( mSelectionHeight > 0 ) { 1333 if ( mSelectionHeight > 0 ) {
1343 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1334 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1344 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1335 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1345 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1336 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1346 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1337 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1347 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1338 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1348 } 1339 }
1349 } 1340 }
1350 //qDebug("btbl "); 1341 //qDebug("btbl ");
1351 p->begin( pd ); 1342 p->begin( pd );
1352 //qDebug("end "); 1343 //qDebug("end ");
1353} 1344}
1354 1345
1355void KOAgenda::finishUpdate() 1346void KOAgenda::finishUpdate()
1356{ 1347{
1357 1348
1358 KOAgendaItem *item; 1349 KOAgendaItem *item;
1359 globalFlagBlockAgendaItemPaint = 1; 1350 globalFlagBlockAgendaItemPaint = 1;
1360 // 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 1351 // 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
1361 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1352 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1362 if ( !item->checkLayout() ) { 1353 if ( !item->checkLayout() ) {
1363 //qDebug(" conflictitem found "); 1354 //qDebug(" conflictitem found ");
1364 int newSubCellWidth; 1355 int newSubCellWidth;
1365 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1356 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1366 else newSubCellWidth = mGridSpacingX / item->subCells(); 1357 else newSubCellWidth = mGridSpacingX / item->subCells();
1367 1358
1368 if (mAllDayMode) { 1359 if (mAllDayMode) {
1369 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1360 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1370 } else { 1361 } else {
1371 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1362 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1372 } 1363 }
1373 int x,y; 1364 int x,y;
1374 gridToContents(item->cellX(),item->cellYTop(),x,y); 1365 gridToContents(item->cellX(),item->cellYTop(),x,y);
1375 if (mAllDayMode) { 1366 if (mAllDayMode) {
1376 y += item->subCell() * newSubCellWidth; 1367 y += item->subCell() * newSubCellWidth;
1377 } else { 1368 } else {
1378 x += item->subCell() * newSubCellWidth; 1369 x += item->subCell() * newSubCellWidth;
1379 } 1370 }
1380 moveChild(item,x,y); 1371 moveChild(item,x,y);
1381 } 1372 }
1382 } 1373 }
1383 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1374 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1384 if ( !item->isVisible() ) 1375 if ( !item->isVisible() )
1385 item->show(); 1376 item->show();
1386 1377
1387 } 1378 }
1388 globalFlagBlockAgendaItemUpdate = 0; 1379 globalFlagBlockAgendaItemUpdate = 0;
1389 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1380 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1390 item->repaintMe( ); 1381 item->repaintMe( );
1391 } 1382 }
1392 globalFlagBlockAgendaItemUpdate = 1; 1383 globalFlagBlockAgendaItemUpdate = 1;
1393 qApp->processEvents(); 1384 qApp->processEvents();
1394 globalFlagBlockAgendaItemPaint = 0; 1385 globalFlagBlockAgendaItemPaint = 0;
1395 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1386 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1396 item->repaint( false ); 1387 item->repaint( false );
1397 } 1388 }
1398 1389
1399} 1390}
1400 1391
1401/* 1392/*
1402 Draw grid in the background of the agenda. 1393 Draw grid in the background of the agenda.
1403*/ 1394*/
1404void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1395void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1405{ 1396{
1406 1397
1407 1398
1408 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1399 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1409 return; 1400 return;
1410 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1401 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1411 return; 1402 return;
1412 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1403 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1413 if ( ch < 1 ) 1404 if ( ch < 1 )
1414 ch = 1; 1405 ch = 1;
1415 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1406 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1416 mPaintPixmap.resize( contentsWidth()+42, ch ); 1407 mPaintPixmap.resize( contentsWidth()+42, ch );
1417 } 1408 }
1418 mCurPixWid = contentsWidth(); 1409 mCurPixWid = contentsWidth();
1419 mCurPixHei = ch; 1410 mCurPixHei = ch;
1420 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { 1411 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) {
1421 mHighlightPixmap.resize( mGridSpacingX-1, ch ); 1412 mHighlightPixmap.resize( mGridSpacingX-1, ch );
1422 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1413 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1423 } 1414 }
1424 mPixPainter.begin( &mPaintPixmap) ; 1415 mPixPainter.begin( &mPaintPixmap) ;
1425 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1416 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1426 QPainter * p ; 1417 QPainter * p ;
1427 if (paint == 0) { 1418 if (paint == 0) {
1428 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1419 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1429 p = &mPixPainter; 1420 p = &mPixPainter;
1430 } 1421 }
1431 else 1422 else
1432 p = paint ; 1423 p = paint ;
1433 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1424 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1434 1425
1435 //--cx;++cw; 1426 //--cx;++cw;
1436 int lGridSpacingY = mGridSpacingY*2; 1427 int lGridSpacingY = mGridSpacingY*2;
1437 int selDay; 1428 int selDay;
1438 if ( !backgroundOnly ) 1429 if ( !backgroundOnly )
1439 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1430 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1440 { 1431 {
1441 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { 1432 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) {
1442 int x1 = cx; 1433 int x1 = cx;
1443 int y1 = 0; 1434 int y1 = 0;
1444 if (y1 < cy) y1 = cy; 1435 if (y1 < cy) y1 = cy;
1445 int x2 = cx+cw-1; 1436 int x2 = cx+cw-1;
1446 int y2 = contentsHeight(); 1437 int y2 = contentsHeight();
1447 if (y2 > cy+ch-1) y2=cy+ch-1; 1438 if (y2 > cy+ch-1) y2=cy+ch-1;
1448 if (x2 >= x1 && y2 >= y1) { 1439 if (x2 >= x1 && y2 >= y1) {
1449 int gxStart = selDay; 1440 int gxStart = selDay;
1450 int gxEnd = gxStart ; 1441 int gxEnd = gxStart ;
1451 int xStart = KOGlobals::self()->reverseLayout() ? 1442 int xStart = KOGlobals::self()->reverseLayout() ?
1452 (mColumns - 1 - gxStart)*mGridSpacingX : 1443 (mColumns - 1 - gxStart)*mGridSpacingX :
1453 gxStart*mGridSpacingX; 1444 gxStart*mGridSpacingX;
1454 if (xStart < x1) xStart = x1; 1445 if (xStart < x1) xStart = x1;
1455 int xEnd = KOGlobals::self()->reverseLayout() ? 1446 int xEnd = KOGlobals::self()->reverseLayout() ?
1456 (mColumns - gxStart)*mGridSpacingX-1 : 1447 (mColumns - gxStart)*mGridSpacingX-1 :
1457 (gxStart+1)*mGridSpacingX-1; 1448 (gxStart+1)*mGridSpacingX-1;
1458 if (xEnd > x2) xEnd = x2; 1449 if (xEnd > x2) xEnd = x2;
1459 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1450 if ( KOPrefs::instance()->mUseHighlightLightColor )
1460 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1451 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1461 KOPrefs::instance()->mAgendaBgColor.light()); 1452 KOPrefs::instance()->mAgendaBgColor.light());
1462 else 1453 else
1463 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1454 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1464 KOPrefs::instance()->mAgendaBgColor.dark()); 1455 KOPrefs::instance()->mAgendaBgColor.dark());
1465 1456
1466 } 1457 }
1467 } 1458 }
1468 } 1459 }
1469 // Highlight working hours 1460 // Highlight working hours
1470 1461
1471 if ( !backgroundOnly ) 1462 if ( !backgroundOnly )
1472 if (mWorkingHoursEnable) { 1463 if (mWorkingHoursEnable) {
1473 int x1 = cx; 1464 int x1 = cx;
1474 int y1 = mWorkingHoursYTop; 1465 int y1 = mWorkingHoursYTop;
1475 if (y1 < cy) y1 = cy; 1466 if (y1 < cy) y1 = cy;
1476 int x2 = cx+cw-1; 1467 int x2 = cx+cw-1;
1477 // int x2 = mGridSpacingX * 5 - 1; 1468 // int x2 = mGridSpacingX * 5 - 1;
1478 // if (x2 > cx+cw-1) x2 = cx + cw - 1; 1469 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1479 int y2 = mWorkingHoursYBottom; 1470 int y2 = mWorkingHoursYBottom;
1480 if (y2 > cy+ch-1) y2=cy+ch-1; 1471 if (y2 > cy+ch-1) y2=cy+ch-1;
1481 1472
1482 if (x2 >= x1 && y2 >= y1) { 1473 if (x2 >= x1 && y2 >= y1) {
1483 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); 1474 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1484 int gxStart = x1/mGridSpacingX; 1475 int gxStart = x1/mGridSpacingX;
1485 int gxEnd = x2/mGridSpacingX; 1476 int gxEnd = x2/mGridSpacingX;
1486 while(gxStart <= gxEnd) { 1477 while(gxStart <= gxEnd) {
1487 if (gxStart < int(mHolidayMask->count()) && 1478 if (gxStart < int(mHolidayMask->count()) &&
1488 !mHolidayMask->at(gxStart)) { 1479 !mHolidayMask->at(gxStart)) {
1489 int xStart = KOGlobals::self()->reverseLayout() ? 1480 int xStart = KOGlobals::self()->reverseLayout() ?
1490 (mColumns - 1 - gxStart)*mGridSpacingX : 1481 (mColumns - 1 - gxStart)*mGridSpacingX :
1491 gxStart*mGridSpacingX; 1482 gxStart*mGridSpacingX;
1492 if (xStart < x1) xStart = x1; 1483 if (xStart < x1) xStart = x1;
1493 int xEnd = KOGlobals::self()->reverseLayout() ? 1484 int xEnd = KOGlobals::self()->reverseLayout() ?
1494 (mColumns - gxStart)*mGridSpacingX-1 : 1485 (mColumns - gxStart)*mGridSpacingX-1 :
1495 (gxStart+1)*mGridSpacingX-1; 1486 (gxStart+1)*mGridSpacingX-1;
1496 if (xEnd > x2) xEnd = x2; 1487 if (xEnd > x2) xEnd = x2;
1497 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { 1488 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) {
1498 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1489 if ( KOPrefs::instance()->mUseHighlightLightColor )
1499 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1490 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1500 KOPrefs::instance()->mWorkingHoursColor.light()); 1491 KOPrefs::instance()->mWorkingHoursColor.light());
1501 else 1492 else
1502 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1493 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1503 KOPrefs::instance()->mWorkingHoursColor.dark()); 1494 KOPrefs::instance()->mWorkingHoursColor.dark());
1504 } else { 1495 } else {
1505 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1496 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1506 KOPrefs::instance()->mWorkingHoursColor); 1497 KOPrefs::instance()->mWorkingHoursColor);
1507 } 1498 }
1508 } 1499 }
1509 ++gxStart; 1500 ++gxStart;
1510 } 1501 }
1511 } 1502 }
1512 } 1503 }
1513 /* 1504 /*
1514 int selectionX = KOGlobals::self()->reverseLayout() ? 1505 int selectionX = KOGlobals::self()->reverseLayout() ?
1515 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1506 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1516 mSelectionCellX * mGridSpacingX; 1507 mSelectionCellX * mGridSpacingX;
1517 1508
1518 // Draw selection 1509 // Draw selection
1519 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1510 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1520 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1511 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1521 // TODO: paint only part within cx,cy,cw,ch 1512 // TODO: paint only part within cx,cy,cw,ch
1522 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, 1513 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1523 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1514 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1524 } 1515 }
1525 */ 1516 */
1526 // Draw vertical lines of grid 1517 // Draw vertical lines of grid
1527 1518
1528 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1519 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1529 if ( mGridSpacingX > 0 ) { 1520 if ( mGridSpacingX > 0 ) {
1530 while (x < cx + cw) { 1521 while (x < cx + cw) {
1531 p->drawLine(x,cy,x,cy+ch); 1522 p->drawLine(x,cy,x,cy+ch);
1532 x+=mGridSpacingX; 1523 x+=mGridSpacingX;
1533 } 1524 }
1534 } 1525 }
1535 // Draw horizontal lines of grid 1526 // Draw horizontal lines of grid
1536 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1527 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1537 if ( lGridSpacingY > 0 ) { 1528 if ( lGridSpacingY > 0 ) {
1538 while (y < cy + ch) { 1529 while (y < cy + ch) {
1539 p->setPen( SolidLine ); 1530 p->setPen( SolidLine );
1540 p->drawLine(cx,y,cx+cw,y); 1531 p->drawLine(cx,y,cx+cw,y);
1541 y+=lGridSpacingY; 1532 y+=lGridSpacingY;
1542 p->setPen( DotLine ); 1533 p->setPen( DotLine );
1543 p->drawLine(cx,y,cx+cw,y); 1534 p->drawLine(cx,y,cx+cw,y);
1544 y+=lGridSpacingY; 1535 y+=lGridSpacingY;
1545 } 1536 }
1546 p->setPen( SolidLine ); 1537 p->setPen( SolidLine );
1547 } 1538 }
1548 mPixPainter.end() ; 1539 mPixPainter.end() ;
1549} 1540}
1550 1541
1551/* 1542/*
1552 Convert srcollview contents coordinates to agenda grid coordinates. 1543 Convert srcollview contents coordinates to agenda grid coordinates.
1553*/ 1544*/
1554void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1545void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1555{ 1546{
1556 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : 1547 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1557 x/mGridSpacingX; 1548 x/mGridSpacingX;
1558 gy = y/mGridSpacingY; 1549 gy = y/mGridSpacingY;
1559} 1550}
1560 1551
1561/* 1552/*
1562 Convert agenda grid coordinates to scrollview contents coordinates. 1553 Convert agenda grid coordinates to scrollview contents coordinates.
1563*/ 1554*/
1564void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) 1555void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
1565{ 1556{
1566 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: 1557 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
1567 gx*mGridSpacingX; 1558 gx*mGridSpacingX;
1568 y = gy*mGridSpacingY; 1559 y = gy*mGridSpacingY;
1569} 1560}
1570 1561
1571 1562
1572/* 1563/*
1573 Return Y coordinate corresponding to time. Coordinates are rounded to fit into 1564 Return Y coordinate corresponding to time. Coordinates are rounded to fit into
1574 the grid. 1565 the grid.
1575*/ 1566*/
1576int KOAgenda::timeToY(const QTime &time) 1567int KOAgenda::timeToY(const QTime &time)
1577{ 1568{
1578 int minutesPerCell = 24 * 60 / mRows; 1569 int minutesPerCell = 24 * 60 / mRows;
1579 int timeMinutes = time.hour() * 60 + time.minute(); 1570 int timeMinutes = time.hour() * 60 + time.minute();
1580 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; 1571 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell;
1581 return Y; 1572 return Y;
1582} 1573}
1583 1574
1584 1575
1585/* 1576/*
1586 Return time corresponding to cell y coordinate. Coordinates are rounded to 1577 Return time corresponding to cell y coordinate. Coordinates are rounded to
1587 fit into the grid. 1578 fit into the grid.
1588*/ 1579*/
1589QTime KOAgenda::gyToTime(int gy) 1580QTime KOAgenda::gyToTime(int gy)
1590{ 1581{
1591 1582
1592 int secondsPerCell = 24 * 60 * 60/ mRows; 1583 int secondsPerCell = 24 * 60 * 60/ mRows;
1593 1584
1594 int timeSeconds = secondsPerCell * gy; 1585 int timeSeconds = secondsPerCell * gy;
1595 1586
1596 QTime time( 0, 0, 0 ); 1587 QTime time( 0, 0, 0 );
1597 if ( timeSeconds < 24 * 60 * 60 ) { 1588 if ( timeSeconds < 24 * 60 * 60 ) {
1598 time = time.addSecs(timeSeconds); 1589 time = time.addSecs(timeSeconds);
1599 } else { 1590 } else {
1600 time.setHMS( 23, 59, 59 ); 1591 time.setHMS( 23, 59, 59 );
1601 } 1592 }
1602 1593
1603 return time; 1594 return time;
1604} 1595}
1605 1596
1606void KOAgenda::setStartHour(int startHour) 1597void KOAgenda::setStartHour(int startHour)
1607{ 1598{
1608 int startCell = startHour * mRows / 24; 1599 int startCell = startHour * mRows / 24;
1609 setContentsPos(0,startCell * gridSpacingY()); 1600 setContentsPos(0,startCell * gridSpacingY());
1610} 1601}
1611void KOAgenda::hideUnused() 1602void KOAgenda::hideUnused()
1612{ 1603{
1613 // experimental only 1604 // experimental only
1614 // return; 1605 // return;
1615 KOAgendaItem *item; 1606 KOAgendaItem *item;
1616 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { 1607 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
1617 item->hide(); 1608 item->hide();
1618 } 1609 }
1619} 1610}
1620 1611
1621 1612
1622KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1613KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1623{ 1614{
1624 1615
1625 KOAgendaItem *fi; 1616 KOAgendaItem *fi;
1626 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { 1617 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
1627 if ( fi->incidence() == event ) { 1618 if ( fi->incidence() == event ) {
1628 mUnusedItems.remove(); 1619 mUnusedItems.remove();
1629 fi->init( event, qd ); 1620 fi->init( event, qd );
1630 return fi; 1621 return fi;
1631 } 1622 }
1632 } 1623 }
1633 fi=mUnusedItems.first(); 1624 fi=mUnusedItems.first();
1634 if ( fi ) { 1625 if ( fi ) {
1635 mUnusedItems.remove(); 1626 mUnusedItems.remove();
1636 fi->init( event, qd ); 1627 fi->init( event, qd );
1637 return fi; 1628 return fi;
1638 } 1629 }
1639 // qDebug("new KOAgendaItem "); 1630 // qDebug("new KOAgendaItem ");
1640 1631
1641 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); 1632 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1642 agendaItem->installEventFilter(this); 1633 agendaItem->installEventFilter(this);
1643 addChild(agendaItem,0,0); 1634 addChild(agendaItem,0,0);
1644 return agendaItem; 1635 return agendaItem;
1645} 1636}
1646KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1637KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1647{ 1638{
1648 KOAgendaItem *item; 1639 KOAgendaItem *item;
1649 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1640 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1650 if ( item->incidence() == todo ) { 1641 if ( item->incidence() == todo ) {
1651 mItems.remove(); 1642 mItems.remove();
1652 return item; 1643 return item;
1653 } 1644 }
1654 } 1645 }
1655 return 0; 1646 return 0;
1656} 1647}
1657 1648
1658 1649
1659void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1650void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1660{ 1651{
1661 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1652 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1662 KOAgendaItem *item; 1653 KOAgendaItem *item;
1663 item = getItemForTodo ( todo ); 1654 item = getItemForTodo ( todo );
1664 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1655 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1665 if ( item ) { 1656 if ( item ) {
1666 blockSignals( true ); 1657 blockSignals( true );
1667 //qDebug("item found "); 1658 //qDebug("item found ");
1668 item->hide(); 1659 item->hide();
1669 item->setCellX(-2, -1 ); 1660 item->setCellX(-2, -1 );
1670 item->select(false); 1661 item->select(false);
1671 mUnusedItems.append( item ); 1662 mUnusedItems.append( item );
1672 mItems.remove( item ); 1663 mItems.remove( item );
1673 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1664 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1674 KOAgendaItem *itemit; 1665 KOAgendaItem *itemit;
1675 //globalFlagBlockAgendaItemPaint = 1; 1666 //globalFlagBlockAgendaItemPaint = 1;
1676 for ( itemit=oldconflictItems.first(); itemit != 0; 1667 for ( itemit=oldconflictItems.first(); itemit != 0;
1677 itemit=oldconflictItems.next() ) { 1668 itemit=oldconflictItems.next() ) {
1678 if ( itemit != item ) 1669 if ( itemit != item )
1679 placeSubCells(itemit); 1670 placeSubCells(itemit);
1680 } 1671 }
1681 qApp->processEvents(); 1672 qApp->processEvents();
1682 //globalFlagBlockAgendaItemPaint = 0; 1673 //globalFlagBlockAgendaItemPaint = 0;
1683 for ( itemit=oldconflictItems.first(); itemit != 0; 1674 for ( itemit=oldconflictItems.first(); itemit != 0;
1684 itemit=oldconflictItems.next() ) { 1675 itemit=oldconflictItems.next() ) {
1685 globalFlagBlockAgendaItemUpdate = 0; 1676 globalFlagBlockAgendaItemUpdate = 0;
1686 if ( itemit != item ) 1677 if ( itemit != item )
1687 itemit->repaintMe(); 1678 itemit->repaintMe();
1688 globalFlagBlockAgendaItemUpdate = 1; 1679 globalFlagBlockAgendaItemUpdate = 1;
1689 itemit->repaint(); 1680 itemit->repaint();
1690 } 1681 }
1691 blockSignals( false ); 1682 blockSignals( false );
1692 } 1683 }
1693 if ( remove ) { 1684 if ( remove ) {
1694 //qDebug("remove****************************************** "); 1685 //qDebug("remove****************************************** ");
1695 return; 1686 return;
1696 } 1687 }
1697 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1688 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1698 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1689 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda );
1699 QDate currentDate; 1690 QDate currentDate;
1700 QDateTime dt; 1691 QDateTime dt;
1701 if ( todo->hasCompletedDate() ) 1692 if ( todo->hasCompletedDate() )
1702 dt = todo->completed(); 1693 dt = todo->completed();
1703 else 1694 else
1704 dt = todo->dtDue(); 1695 dt = todo->dtDue();
1705 if ( overdue ) { 1696 if ( overdue ) {
1706 currentDate = QDate::currentDate(); 1697 currentDate = QDate::currentDate();
1707 days += todo->dtDue().date().daysTo( currentDate ); 1698 days += todo->dtDue().date().daysTo( currentDate );
1708 } 1699 }
1709 else 1700 else
1710 currentDate = dt.date(); 1701 currentDate = dt.date();
1711 1702
1712 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { 1703 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
1713 if ( ! mAllDayMode ) return; 1704 if ( ! mAllDayMode ) return;
1714 // aldayagenda 1705 // aldayagenda
1715 globalFlagBlockAgendaItemPaint = 1; 1706 globalFlagBlockAgendaItemPaint = 1;
1716 item = insertAllDayItem(todo, currentDate,days, days); 1707 item = insertAllDayItem(todo, currentDate,days, days);
1717 item->show(); 1708 item->show();
1718 1709
1719 } 1710 }
1720 else { 1711 else {
1721 if ( mAllDayMode ) return; 1712 if ( mAllDayMode ) return;
1722 // mAgenda 1713 // mAgenda
1723 globalFlagBlockAgendaItemPaint = 1; 1714 globalFlagBlockAgendaItemPaint = 1;
1724 int endY = timeToY(dt.time()) - 1; 1715 int endY = timeToY(dt.time()) - 1;
1725 int hi = 12/KOPrefs::instance()->mHourSize; 1716 int hi = 12/KOPrefs::instance()->mHourSize;
1726 int startY = endY - 1-hi; 1717 int startY = endY - 1-hi;
1727 item = insertItem(todo,currentDate,days,startY,endY); 1718 item = insertItem(todo,currentDate,days,startY,endY);
1728 item->show(); 1719 item->show();
1729 } 1720 }
1730 qApp->processEvents(); 1721 qApp->processEvents();
1731 globalFlagBlockAgendaItemPaint = 0; 1722 globalFlagBlockAgendaItemPaint = 0;
1732 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1723 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1733 KOAgendaItem *itemit; 1724 KOAgendaItem *itemit;
1734 for ( itemit=oldconflictItems.first(); itemit != 0; 1725 for ( itemit=oldconflictItems.first(); itemit != 0;
1735 itemit=oldconflictItems.next() ) { 1726 itemit=oldconflictItems.next() ) {
1736 globalFlagBlockAgendaItemUpdate = 0; 1727 globalFlagBlockAgendaItemUpdate = 0;
1737 itemit->repaintMe(); 1728 itemit->repaintMe();
1738 globalFlagBlockAgendaItemUpdate = 1; 1729 globalFlagBlockAgendaItemUpdate = 1;
1739 itemit->repaint(); 1730 itemit->repaint();
1740 } 1731 }
1741 globalFlagBlockAgendaItemUpdate = 0; 1732 globalFlagBlockAgendaItemUpdate = 0;
1742 item->repaintMe(); 1733 item->repaintMe();
1743 globalFlagBlockAgendaItemUpdate = 1; 1734 globalFlagBlockAgendaItemUpdate = 1;
1744 item->repaint(); 1735 item->repaint();
1745} 1736}
1746/* 1737/*
1747 Insert KOAgendaItem into agenda. 1738 Insert KOAgendaItem into agenda.
1748*/ 1739*/
1749KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1740KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1750{ 1741{
1751 //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl;
1752
1753 if (mAllDayMode) { 1742 if (mAllDayMode) {
1754 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; 1743 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. ");
1755 return 0; 1744 return 0;
1756 } 1745 }
1757 1746
1758 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1747 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1759 //agendaItem->setFrameStyle(WinPanel|Raised); 1748 //agendaItem->setFrameStyle(WinPanel|Raised);
1760 1749
1761 int YSize = YBottom - YTop + 1; 1750 int YSize = YBottom - YTop + 1;
1762 if (YSize < 0) { 1751 if (YSize < 0) {
1763 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl;
1764 YSize = 1; 1752 YSize = 1;
1765 } 1753 }
1766 int iheight = mGridSpacingY * YSize; 1754 int iheight = mGridSpacingY * YSize;
1767 1755
1768 agendaItem->resize(mGridSpacingX,iheight ); 1756 agendaItem->resize(mGridSpacingX,iheight );
1769 agendaItem->setCellXY(X,YTop,YBottom); 1757 agendaItem->setCellXY(X,YTop,YBottom);
1770 agendaItem->setCellXWidth(X); 1758 agendaItem->setCellXWidth(X);
1771 1759
1772 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1760 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1773 mItems.append(agendaItem); 1761 mItems.append(agendaItem);
1774 1762
1775 placeSubCells(agendaItem); 1763 placeSubCells(agendaItem);
1776 1764
1777 //agendaItem->show(); 1765 //agendaItem->show();
1778 1766
1779 marcus_bains(); 1767 marcus_bains();
1780 1768
1781 return agendaItem; 1769 return agendaItem;
1782} 1770}
1783 1771
1784 1772
1785/* 1773/*
1786 Insert all-day KOAgendaItem into agenda. 1774 Insert all-day KOAgendaItem into agenda.
1787*/ 1775*/
1788KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1776KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1789{ 1777{
1790 if (!mAllDayMode) { 1778 if (!mAllDayMode) {
1791 return 0; 1779 return 0;
1792 } 1780 }
1793 1781
1794 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1782 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1795 1783
1796 agendaItem->setCellXY(XBegin,0,0); 1784 agendaItem->setCellXY(XBegin,0,0);
1797 agendaItem->setCellXWidth(XEnd); 1785 agendaItem->setCellXWidth(XEnd);
1798 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1786 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1799 1787
1800 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1788 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1801 mItems.append(agendaItem); 1789 mItems.append(agendaItem);
1802 1790
1803 placeSubCells(agendaItem); 1791 placeSubCells(agendaItem);
1804 1792
1805 //agendaItem->show(); 1793 //agendaItem->show();
1806 1794
1807 return agendaItem; 1795 return agendaItem;
1808} 1796}
1809 1797
1810 1798
1811void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1799void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1812 int YTop,int YBottom) 1800 int YTop,int YBottom)
1813{ 1801{
1814 if (mAllDayMode) { 1802 if (mAllDayMode) {
1815 ; 1803 ;
1816 return; 1804 return;
1817 } 1805 }
1818 1806
1819 int cellX,cellYTop,cellYBottom; 1807 int cellX,cellYTop,cellYBottom;
1820 QString newtext; 1808 QString newtext;
1821 int width = XEnd - XBegin + 1; 1809 int width = XEnd - XBegin + 1;
1822 int count = 0; 1810 int count = 0;
1823 KOAgendaItem *current = 0; 1811 KOAgendaItem *current = 0;
1824 QPtrList<KOAgendaItem> multiItems; 1812 QPtrList<KOAgendaItem> multiItems;
1825 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1813 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1826 if (cellX == XBegin) cellYTop = YTop; 1814 if (cellX == XBegin) cellYTop = YTop;
1827 else cellYTop = 0; 1815 else cellYTop = 0;
1828 if (cellX == XEnd) cellYBottom = YBottom; 1816 if (cellX == XEnd) cellYBottom = YBottom;
1829 else cellYBottom = rows() - 1; 1817 else cellYBottom = rows() - 1;
1830 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1818 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1831 newtext.append(event->summary()); 1819 newtext.append(event->summary());
1832 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1820 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1833 current->setText(newtext); 1821 current->setText(newtext);
1834 multiItems.append(current); 1822 multiItems.append(current);
1835 } 1823 }
1836 1824
1837 KOAgendaItem *next = 0; 1825 KOAgendaItem *next = 0;
1838 KOAgendaItem *last = multiItems.last(); 1826 KOAgendaItem *last = multiItems.last();
1839 KOAgendaItem *first = multiItems.first(); 1827 KOAgendaItem *first = multiItems.first();
1840 KOAgendaItem *setFirst,*setLast; 1828 KOAgendaItem *setFirst,*setLast;
1841 current = first; 1829 current = first;
1842 while (current) { 1830 while (current) {
1843 next = multiItems.next(); 1831 next = multiItems.next();
1844 if (current == first) setFirst = 0; 1832 if (current == first) setFirst = 0;
1845 else setFirst = first; 1833 else setFirst = first;
1846 if (current == last) setLast = 0; 1834 if (current == last) setLast = 0;
1847 else setLast = last; 1835 else setLast = last;
1848 1836
1849 current->setMultiItem(setFirst,next,setLast); 1837 current->setMultiItem(setFirst,next,setLast);
1850 current = next; 1838 current = next;
1851 } 1839 }
1852 1840
1853 marcus_bains(); 1841 marcus_bains();
1854} 1842}
1855 1843
1856 1844
1857//QSizePolicy KOAgenda::sizePolicy() const 1845//QSizePolicy KOAgenda::sizePolicy() const
1858//{ 1846//{
1859 // Thought this would make the all-day event agenda minimum size and the 1847 // Thought this would make the all-day event agenda minimum size and the
1860 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1848 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1861 // don´t seem to think that an Expanding widget needs more space than a 1849 // don´t seem to think that an Expanding widget needs more space than a
1862 // Preferred one. 1850 // Preferred one.
1863 // But it doesn´t hurt, so it stays. 1851 // But it doesn´t hurt, so it stays.
1864// if (mAllDayMode) { 1852// if (mAllDayMode) {
1865// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1853// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1866// } else { 1854// } else {
1867// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1855// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1868// } 1856// }
1869//} 1857//}
1870void KOAgenda::finishResize ( ) 1858void KOAgenda::finishResize ( )
1871{ 1859{
1872 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1860 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1873 if ( globalFlagBlockAgenda == 0 ) { 1861 if ( globalFlagBlockAgenda == 0 ) {
1874 finishUpdate(); 1862 finishUpdate();
1875 //qDebug("finishUpdate() called "); 1863 //qDebug("finishUpdate() called ");
1876 } 1864 }
1877} 1865}
1878/* 1866/*
1879 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1867 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1880*/ 1868*/
1881void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1869void KOAgenda::resizeEvent ( QResizeEvent *ev )
1882{ 1870{
1883 1871
1884 mResizeTimer.start( 150 , true ); 1872 mResizeTimer.start( 150 , true );
1885 computeSizes(); 1873 computeSizes();
1886 return; 1874 return;
1887 1875
1888} 1876}
1889void KOAgenda::computeSizes() 1877void KOAgenda::computeSizes()
1890{ 1878{
1891 if ( globalFlagBlockStartup ) 1879 if ( globalFlagBlockStartup )
1892 return; 1880 return;
1881 int frameOffset = frameWidth() * 2 +1;
1882 if (mAllDayMode) {
1883 mGridSpacingX = (width()-frameOffset) / mColumns;
1884 mGridSpacingY = height() - 2 * frameWidth() - 1;
1885 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1886 // mGridSpacingY = height();
1887 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1893 1888
1894 if (mAllDayMode) { 1889 KOAgendaItem *item;
1895 mGridSpacingX = (width()-3) / mColumns; 1890 int subCellWidth;
1896 mGridSpacingY = height() - 2 * frameWidth() - 1; 1891 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1897 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1892 subCellWidth = mGridSpacingY / item->subCells();
1898// mGridSpacingY = height(); 1893 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1899// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1894 moveChild(item,KOGlobals::self()->reverseLayout() ?
1900 1895 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1901 KOAgendaItem *item;
1902 int subCellWidth;
1903 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1904 subCellWidth = mGridSpacingY / item->subCells();
1905 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1906 moveChild(item,KOGlobals::self()->reverseLayout() ?
1907 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1908 item->cellX() * mGridSpacingX, 1896 item->cellX() * mGridSpacingX,
1909 item->subCell() * subCellWidth); 1897 item->subCell() * subCellWidth);
1910 } 1898 }
1911 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1899 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1912 } else { 1900 } else {
1913 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; 1901 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns;
1914 if (height() > mGridSpacingY * mRows + 1 ) { 1902 if (height() > mGridSpacingY * mRows + 1 ) {
1915 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1903 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1916 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1904 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1917 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1905 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1918 emit resizedSignal(); 1906 emit resizedSignal();
1919 } else 1907 } else
1920 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1908 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1921 KOAgendaItem *item; 1909 KOAgendaItem *item;
1922 int subCellWidth; 1910 int subCellWidth;
1923 1911
1924 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1912 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1925 subCellWidth = mGridSpacingX / item->subCells(); 1913 subCellWidth = mGridSpacingX / item->subCells();
1926 item->resize(subCellWidth,item->height()); 1914 item->resize(subCellWidth,item->height());
1927 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1915 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1928 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1916 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1929 item->cellX() * mGridSpacingX) + 1917 item->cellX() * mGridSpacingX) +
1930 item->subCell() * subCellWidth,childY(item)); 1918 item->subCell() * subCellWidth,childY(item));
1919 }
1920 }
1921 int cw = contentsWidth();
1922 int ch = contentsHeight();
1923 if ( mAllDayMode ) {
1924 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1925 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 )
1926 paintPixAll->resize( cw, ch );
1927 } else {
1928 QPixmap* paintPix = KOAgendaItem::paintPix();
1929 if ( paintPix->width() < cw || paintPix->height() < ch )
1930 KOAgendaItem::resizePixmap( cw , ch );
1931 } 1931 }
1932 }
1933 int cw = contentsWidth();
1934 int ch = contentsHeight();
1935 if ( mAllDayMode ) {
1936 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1937 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 )
1938 paintPixAll->resize( cw, ch );
1939 } else {
1940 QPixmap* paintPix = KOAgendaItem::paintPix();
1941 if ( paintPix->width() < cw || paintPix->height() < ch )
1942 KOAgendaItem::resizePixmap( cw , ch );
1943 }
1944 1932
1945 checkScrollBoundaries(); 1933 checkScrollBoundaries();
1946 marcus_bains(); 1934 marcus_bains();
1947 drawContentsToPainter(); 1935 drawContentsToPainter();
1948 viewport()->repaint(false); 1936 viewport()->repaint(false);
1949} 1937}
1950 1938
1951void KOAgenda::scrollUp() 1939void KOAgenda::scrollUp()
1952{ 1940{
1953 scrollBy(0,-mScrollOffset); 1941 scrollBy(0,-mScrollOffset);
1954} 1942}
1955 1943
1956 1944
1957void KOAgenda::scrollDown() 1945void KOAgenda::scrollDown()
1958{ 1946{
1959 scrollBy(0,mScrollOffset); 1947 scrollBy(0,mScrollOffset);
1960} 1948}
1961 1949
1962void KOAgenda::popupAlarm() 1950void KOAgenda::popupAlarm()
1963{ 1951{
1964 if (!mClickedItem) { 1952 if (!mClickedItem) {
1965 qDebug("KOAgenda::popupAlarm() called without having a clicked item "); 1953 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
1966 return; 1954 return;
1967 } 1955 }
1968// TODO: deal correctly with multiple alarms 1956 // TODO: deal correctly with multiple alarms
1969 Alarm* alarm; 1957 Alarm* alarm;
1970 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 1958 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1971 for(alarm=list.first();alarm;alarm=list.next()) { 1959 for(alarm=list.first();alarm;alarm=list.next()) {
1972 alarm->toggleAlarm(); 1960 alarm->toggleAlarm();
1973 } 1961 }
1974 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 1962 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
1975 mClickedItem->paintMe( true ); 1963 mClickedItem->paintMe( true );
1976 mClickedItem->repaint( false ); 1964 mClickedItem->repaint( false );
1977} 1965}
1978 1966
1979/* 1967/*
1980 Calculates the minimum width 1968 Calculates the minimum width
1981*/ 1969*/
1982int KOAgenda::minimumWidth() const 1970int KOAgenda::minimumWidth() const
1983{ 1971{
1984 // TODO:: develop a way to dynamically determine the minimum width 1972 // TODO:: develop a way to dynamically determine the minimum width
1985 int min = 100; 1973 int min = 100;
1986 1974
1987 return min; 1975 return min;
1988} 1976}
1989 1977
1990void KOAgenda::updateConfig() 1978void KOAgenda::updateConfig()
1991{ 1979{
1992 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 1980 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
1993 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 1981 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
1994 if ( mAllDayMode ) { 1982 if ( mAllDayMode ) {
1995 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 1983 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
1996 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 1984 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
1997 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 1985 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
1998 // setMaximumHeight( mGridSpacingY+1 ); 1986 // setMaximumHeight( mGridSpacingY+1 );
1999 viewport()->repaint( false ); 1987 viewport()->repaint( false );
2000 //setFixedHeight( mGridSpacingY+1 ); 1988 //setFixedHeight( mGridSpacingY+1 );
2001 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 1989 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
2002 } 1990 }
2003 else { 1991 else {
2004 mGridSpacingY = KOPrefs::instance()->mHourSize; 1992 mGridSpacingY = KOPrefs::instance()->mHourSize;
2005 calculateWorkingHours(); 1993 calculateWorkingHours();
2006 marcus_bains(); 1994 marcus_bains();
2007 } 1995 }
2008} 1996}
2009 1997
2010void KOAgenda::checkScrollBoundaries() 1998void KOAgenda::checkScrollBoundaries()
2011{ 1999{
2012 // Invalidate old values to force update 2000 // Invalidate old values to force update
2013 mOldLowerScrollValue = -1; 2001 mOldLowerScrollValue = -1;
2014 mOldUpperScrollValue = -1; 2002 mOldUpperScrollValue = -1;
2015 2003
2016 checkScrollBoundaries(verticalScrollBar()->value()); 2004 checkScrollBoundaries(verticalScrollBar()->value());
2017} 2005}
2018 2006
2019void KOAgenda::checkScrollBoundaries(int v) 2007void KOAgenda::checkScrollBoundaries(int v)
2020{ 2008{
2021 if ( mGridSpacingY == 0 ) 2009 if ( mGridSpacingY == 0 )
2022 return; 2010 return;
2023 int yMin = v/mGridSpacingY; 2011 int yMin = v/mGridSpacingY;
2024 int yMax = (v+visibleHeight())/mGridSpacingY; 2012 int yMax = (v+visibleHeight())/mGridSpacingY;
2025 2013
2026// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; 2014// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
2027 2015
2028 if (yMin != mOldLowerScrollValue) { 2016 if (yMin != mOldLowerScrollValue) {
2029 mOldLowerScrollValue = yMin; 2017 mOldLowerScrollValue = yMin;
2030 emit lowerYChanged(yMin); 2018 emit lowerYChanged(yMin);
2031 } 2019 }
2032 if (yMax != mOldUpperScrollValue) { 2020 if (yMax != mOldUpperScrollValue) {
2033 mOldUpperScrollValue = yMax; 2021 mOldUpperScrollValue = yMax;
2034 emit upperYChanged(yMax); 2022 emit upperYChanged(yMax);
2035 } 2023 }
2036} 2024}
2037 2025
2038void KOAgenda::deselectItem() 2026void KOAgenda::deselectItem()
2039{ 2027{
2040 if (mSelectedItem.isNull()) return; 2028 if (mSelectedItem.isNull()) return;
2041 mSelectedItem->select(false); 2029 mSelectedItem->select(false);
2042 mSelectedItem = 0; 2030 mSelectedItem = 0;
2043} 2031}
2044 2032
2045void KOAgenda::selectItem(KOAgendaItem *item) 2033void KOAgenda::selectItem(KOAgendaItem *item)
2046{ 2034{
2047 if ((KOAgendaItem *)mSelectedItem == item) return; 2035 if ((KOAgendaItem *)mSelectedItem == item) return;
2048 deselectItem(); 2036 deselectItem();
2049 if (item == 0) { 2037 if (item == 0) {
2050 emit incidenceSelected( 0 ); 2038 emit incidenceSelected( 0 );
2051 return; 2039 return;
2052 } 2040 }
2053 mSelectedItem = item; 2041 mSelectedItem = item;
2054 mSelectedItem->select(); 2042 mSelectedItem->select();
2055 emit incidenceSelected( mSelectedItem->incidence() ); 2043 emit incidenceSelected( mSelectedItem->incidence() );
2056} 2044}
2057 2045
2058// This function seems never be called. 2046// This function seems never be called.
2059void KOAgenda::keyPressEvent( QKeyEvent *kev ) 2047void KOAgenda::keyPressEvent( QKeyEvent *kev )
2060{ 2048{
2061 switch(kev->key()) { 2049 switch(kev->key()) {
2062 case Key_PageDown: 2050 case Key_PageDown:
2063 verticalScrollBar()->addPage(); 2051 verticalScrollBar()->addPage();
2064 break; 2052 break;
2065 case Key_PageUp: 2053 case Key_PageUp:
2066 verticalScrollBar()->subtractPage(); 2054 verticalScrollBar()->subtractPage();
2067 break; 2055 break;
2068 case Key_Down: 2056 case Key_Down:
2069 verticalScrollBar()->addLine(); 2057 verticalScrollBar()->addLine();
2070 break; 2058 break;
2071 case Key_Up: 2059 case Key_Up:
2072 verticalScrollBar()->subtractLine(); 2060 verticalScrollBar()->subtractLine();
2073 break; 2061 break;
2074 default: 2062 default:
2075 ; 2063 ;
2076 } 2064 }
2077} 2065}
2078 2066
2079void KOAgenda::calculateWorkingHours() 2067void KOAgenda::calculateWorkingHours()
2080{ 2068{
2081// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; 2069// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
2082 mWorkingHoursEnable = !mAllDayMode; 2070 mWorkingHoursEnable = !mAllDayMode;
2083 2071
2084 mWorkingHoursYTop = mGridSpacingY * 2072 mWorkingHoursYTop = mGridSpacingY *
2085 KOPrefs::instance()->mWorkingHoursStart * 4; 2073 KOPrefs::instance()->mWorkingHoursStart * 4;
2086 mWorkingHoursYBottom = mGridSpacingY * 2074 mWorkingHoursYBottom = mGridSpacingY *
2087 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; 2075 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
2088} 2076}
2089 2077
2090 2078
2091DateList KOAgenda::dateList() const 2079DateList KOAgenda::dateList() const
2092{ 2080{
2093 return mSelectedDates; 2081 return mSelectedDates;
2094} 2082}
2095 2083
2096void KOAgenda::setDateList(const DateList &selectedDates) 2084void KOAgenda::setDateList(const DateList &selectedDates)
2097{ 2085{
2098 mSelectedDates = selectedDates; 2086 mSelectedDates = selectedDates;
2099 marcus_bains(); 2087 marcus_bains();
2100} 2088}
2101 2089
2102void KOAgenda::setHolidayMask(QMemArray<bool> *mask) 2090void KOAgenda::setHolidayMask(QMemArray<bool> *mask)
2103{ 2091{
2104 mHolidayMask = mask; 2092 mHolidayMask = mask;
2105 2093
2106/* 2094/*
2107 kdDebug() << "HolidayMask: "; 2095 kdDebug() << "HolidayMask: ";
2108 for(uint i=0;i<mask->count();++i) { 2096 for(uint i=0;i<mask->count();++i) {
2109 kdDebug() << (mask->at(i) ? "*" : "o"); 2097 kdDebug() << (mask->at(i) ? "*" : "o");
2110 } 2098 }
2111 kdDebug() << endl; 2099 kdDebug() << endl;
2112*/ 2100*/
2113} 2101}
2114 2102
2115void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) 2103void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
2116{ 2104{
2117 2105
2118 QScrollView::contentsMousePressEvent(event); 2106 QScrollView::contentsMousePressEvent(event);
2119} 2107}
2120 2108
2121void KOAgenda::storePosition() 2109void KOAgenda::storePosition()
2122{ 2110{
2123 //mContentPosition 2111 //mContentPosition
2124 int max = mGridSpacingY*4*24; 2112 int max = mGridSpacingY*4*24;
2125 if ( contentsY() < 5 && max > viewport()->height()*3/2 ) 2113 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
2126 mContentPosition = 0; 2114 mContentPosition = 0;
2127 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) 2115 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2)
2128 mContentPosition = -1.0; 2116 mContentPosition = -1.0;
2129 else 2117 else
2130 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); 2118 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2)));
2131 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); 2119 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height());
2132 2120
2133} 2121}
2134void KOAgenda::restorePosition() 2122void KOAgenda::restorePosition()
2135{ 2123{
2136 int posY; 2124 int posY;
2137 int max = mGridSpacingY*4*24; 2125 int max = mGridSpacingY*4*24;
2138 if ( mContentPosition < 0 ) 2126 if ( mContentPosition < 0 )
2139 posY = max-viewport()->height(); 2127 posY = max-viewport()->height();
2140 else 2128 else
2141 if ( mContentPosition == 0 ) 2129 if ( mContentPosition == 0 )
2142 posY = 0; 2130 posY = 0;
2143 else 2131 else
2144 posY = (max/mContentPosition)-(viewport()->height()/2); 2132 posY = (max/mContentPosition)-(viewport()->height()/2);
2145 setContentsPos (0, posY ); 2133 setContentsPos (0, posY );
2146 //qDebug("posY %d hei %d", posY, max); 2134 //qDebug("posY %d hei %d", posY, max);
2147 2135
2148} 2136}
2149void KOAgenda::moveChild( QWidget *w, int x , int y ) 2137void KOAgenda::moveChild( QWidget *w, int x , int y )
2150{ 2138{
2151 ++x; 2139 ++x;
2152 QScrollView::moveChild( w, x , y ); 2140 QScrollView::moveChild( w, x , y );
2153} 2141}
2154#include <qmessagebox.h> 2142#include <qmessagebox.h>
2155#ifdef DESKTOP_VERSION 2143#ifdef DESKTOP_VERSION
2156#include <qprinter.h> 2144#include <qprinter.h>
2157#include <qpainter.h> 2145#include <qpainter.h>
2158#include <qpaintdevicemetrics.h> 2146#include <qpaintdevicemetrics.h>
2159 2147
2160#endif 2148#endif
2161void KOAgenda::printSelection() 2149void KOAgenda::printSelection()
2162{ 2150{
2163#ifdef DESKTOP_VERSION 2151#ifdef DESKTOP_VERSION
2164 if ( mStartCellY == mCurrentCellY ) { 2152 if ( mStartCellY == mCurrentCellY ) {
2165 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2153 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2166 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), 2154 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "),
2167 i18n("OK"), 0, 0, 2155 i18n("OK"), 0, 0,
2168 0, 1 ); 2156 0, 1 );
2169 return; 2157 return;
2170 } 2158 }
2171 2159
2172 float dx, dy; 2160 float dx, dy;
2173 int x,y,w,h; 2161 int x,y,w,h;
2174 x= 0; 2162 x= 0;
2175 w= contentsWidth()+2; 2163 w= contentsWidth()+2;
2176 // h= contentsHeight(); 2164 // h= contentsHeight();
2177 y = mGridSpacingY*mStartCellY; 2165 y = mGridSpacingY*mStartCellY;
2178 h = mGridSpacingY*(mCurrentCellY+1)-y+2; 2166 h = mGridSpacingY*(mCurrentCellY+1)-y+2;
2179 2167
2180 //return; 2168 //return;
2181 QPrinter* printer = new QPrinter(); 2169 QPrinter* printer = new QPrinter();
2182 if ( !printer->setup()) { 2170 if ( !printer->setup()) {
2183 delete printer; 2171 delete printer;
2184 return; 2172 return;
2185 } 2173 }
2186 QPainter p( printer ); 2174 QPainter p( printer );
2187 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); 2175 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
2188 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); 2176 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() );
2189 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); 2177 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true );
2190 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); 2178 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
2191 // p.drawText( 0, 0, date ); 2179 // p.drawText( 0, 0, date );
2192 int offset = m.width()/8; 2180 int offset = m.width()/8;
2193 // compute the scale 2181 // compute the scale
2194 dx = ((float) m.width()-offset) / (float)w; 2182 dx = ((float) m.width()-offset) / (float)w;
2195 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; 2183 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h;
2196 float scale; 2184 float scale;
2197 // scale to fit the width or height of the paper 2185 // scale to fit the width or height of the paper
2198 if ( dx < dy ) 2186 if ( dx < dy )
2199 scale = dx; 2187 scale = dx;
2200 else 2188 else
2201 scale = dy; 2189 scale = dy;
2202 // set the scale 2190 // set the scale
2203 p.drawText( offset* scale, offset* scale*3/4, date ); 2191 p.drawText( offset* scale, offset* scale*3/4, date );
2204 2192
2205 int selDay; 2193 int selDay;
2206 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); 2194 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count()));
2207 float startX = 1; 2195 float startX = 1;
2208 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 2196 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
2209 { 2197 {
2210 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); 2198 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true );
2211 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); 2199 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) );
2212 p.drawText( offset* scale+startX, (offset+hei)* scale, text ); 2200 p.drawText( offset* scale+startX, (offset+hei)* scale, text );
2213 startX += widOffset; 2201 startX += widOffset;
2214 2202
2215 } 2203 }
2216 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); 2204 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale));
2217 p.scale( scale, scale ); 2205 p.scale( scale, scale );
2218 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); 2206 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale );
2219 // now printing with y offset: 2 hei 2207 // now printing with y offset: 2 hei
2220 // p.translate( 0, -y*scale); 2208 // p.translate( 0, -y*scale);
2221 2209
2222 drawContentsToPainter(&p, true ); 2210 drawContentsToPainter(&p, true );
2223 globalFlagBlockAgendaItemUpdate = false; 2211 globalFlagBlockAgendaItemUpdate = false;
2224 KOAgendaItem *item; 2212 KOAgendaItem *item;
2225 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 2213 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
2226 item->select(false); 2214 item->select(false);
2227 item->paintMe( false, &p ); 2215 item->paintMe( false, &p );
2228 } 2216 }
2229 globalFlagBlockAgendaItemUpdate = true; 2217 globalFlagBlockAgendaItemUpdate = true;
2230 p.end(); 2218 p.end();
2231 delete printer; 2219 delete printer;
2232#else 2220#else
2233 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2221 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2234 i18n("Not supported \non PDA!\n"), 2222 i18n("Not supported \non PDA!\n"),
2235 i18n("OK"), 0, 0, 2223 i18n("OK"), 0, 0,
2236 0, 1 ); 2224 0, 1 );
2237#endif 2225#endif
2238} 2226}