summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-05 07:37:53 (UTC)
committer zautrix <zautrix>2005-07-05 07:37:53 (UTC)
commit28ca4c37fb0e131b2978584992840b3fdca21d3e (patch) (unidiff)
treefb4f7e51c0995b71e2a26a7300747b6b1b3acb23
parent5992ea9025ebddde8be72322c90aac8edeaf4d1c (diff)
downloadkdepimpi-28ca4c37fb0e131b2978584992840b3fdca21d3e.zip
kdepimpi-28ca4c37fb0e131b2978584992840b3fdca21d3e.tar.gz
kdepimpi-28ca4c37fb0e131b2978584992840b3fdca21d3e.tar.bz2
fixesss
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp30
-rw-r--r--korganizer/koagenda.h4
-rw-r--r--korganizer/koagendaitem.cpp5
-rw-r--r--korganizer/koagendaview.cpp31
-rw-r--r--korganizer/koagendaview.h5
5 files changed, 65 insertions, 10 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 0280c74..c339b57 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1,513 +1,531 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 Marcus Bains line. 5 Marcus Bains line.
6 Copyright (c) 2001 Ali Rahimi 6 Copyright (c) 2001 Ali Rahimi
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#define protected public 28#define protected public
29#include <qwidget.h> 29#include <qwidget.h>
30#undef protected 30#undef protected
31#endif 31#endif
32#include <qintdict.h> 32#include <qintdict.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qpainter.h> 37#include <qpainter.h>
38 38
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kglobal.h> 42#include <kglobal.h>
43 43
44#include "koagendaitem.h" 44#include "koagendaitem.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47 47
48#include "koagenda.h" 48#include "koagenda.h"
49 49
50#include <libkcal/event.h> 50#include <libkcal/event.h>
51#include <libkcal/todo.h> 51#include <libkcal/todo.h>
52 52
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
55#endif 55#endif
56 56
57//extern bool globalFlagBlockPainting; 57//extern bool globalFlagBlockPainting;
58extern int globalFlagBlockAgenda; 58extern int globalFlagBlockAgenda;
59extern int globalFlagBlockAgendaItemPaint; 59extern int globalFlagBlockAgendaItemPaint;
60extern int globalFlagBlockAgendaItemUpdate; 60extern int globalFlagBlockAgendaItemUpdate;
61extern int globalFlagBlockStartup; 61extern int globalFlagBlockStartup;
62 62
63bool KOAgenda::mInvalidPixmap = false;
63//////////////////////////////////////////////////////////////////////////// 64////////////////////////////////////////////////////////////////////////////
64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 65MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
65 : QFrame(_agenda->viewport(),name), agenda(_agenda) 66 : QFrame(_agenda->viewport(),name), agenda(_agenda)
66{ 67{
67 setLineWidth(0); 68 setLineWidth(0);
68 setMargin(0); 69 setMargin(0);
69 setBackgroundColor(Qt::red); 70 setBackgroundColor(Qt::red);
70 minutes = new QTimer(this); 71 minutes = new QTimer(this);
71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 72 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
72 minutes->start(0, true); 73 minutes->start(0, true);
73 mTimeBox = new QLabel(this); 74 mTimeBox = new QLabel(this);
74 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
75 QPalette pal = mTimeBox->palette(); 76 QPalette pal = mTimeBox->palette();
76 pal.setColor(QColorGroup::Foreground, Qt::red); 77 pal.setColor(QColorGroup::Foreground, Qt::red);
77 mTimeBox->setPalette(pal); 78 mTimeBox->setPalette(pal);
78 //mTimeBox->setAutoMask(true); 79 //mTimeBox->setAutoMask(true);
79 80
80 agenda->addChild(mTimeBox); 81 agenda->addChild(mTimeBox);
81 82
82 oldToday = -1; 83 oldToday = -1;
83} 84}
84 85
85MarcusBains::~MarcusBains() 86MarcusBains::~MarcusBains()
86{ 87{
87 delete minutes; 88 delete minutes;
88} 89}
89 90
90int MarcusBains::todayColumn() 91int MarcusBains::todayColumn()
91{ 92{
92 QDate currentDate = QDate::currentDate(); 93 QDate currentDate = QDate::currentDate();
93 94
94 DateList dateList = agenda->dateList(); 95 DateList dateList = agenda->dateList();
95 DateList::ConstIterator it; 96 DateList::ConstIterator it;
96 int col = 0; 97 int col = 0;
97 for(it = dateList.begin(); it != dateList.end(); ++it) { 98 for(it = dateList.begin(); it != dateList.end(); ++it) {
98 if((*it) == currentDate) 99 if((*it) == currentDate)
99 return KOGlobals::self()->reverseLayout() ? 100 return KOGlobals::self()->reverseLayout() ?
100 agenda->columns() - 1 - col : col; 101 agenda->columns() - 1 - col : col;
101 ++col; 102 ++col;
102 } 103 }
103 104
104 return -1; 105 return -1;
105} 106}
106void MarcusBains::updateLoc() 107void MarcusBains::updateLoc()
107{ 108{
108 updateLocation(); 109 updateLocation();
109} 110}
110void MarcusBains::updateLocation(bool recalculate) 111void MarcusBains::updateLocation(bool recalculate)
111{ 112{
112 113
113 QTime tim = QTime::currentTime(); 114 QTime tim = QTime::currentTime();
114 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
115 if((tim.hour() == 0) && (oldTime.hour()==23)) 116 if((tim.hour() == 0) && (oldTime.hour()==23))
116 recalculate = true; 117 recalculate = true;
117 118
118 int mins = tim.hour()*60 + tim.minute(); 119 int mins = tim.hour()*60 + tim.minute();
119 int minutesPerCell = 24 * 60 / agenda->rows(); 120 int minutesPerCell = 24 * 60 / agenda->rows();
120 int y = mins*agenda->gridSpacingY()/minutesPerCell; 121 int y = mins*agenda->gridSpacingY()/minutesPerCell;
121 int today = recalculate ? todayColumn() : oldToday; 122 int today = recalculate ? todayColumn() : oldToday;
122 int x = agenda->gridSpacingX()*today; 123 int x = agenda->gridSpacingX()*today;
123 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
124 125
125 oldTime = tim; 126 oldTime = tim;
126 oldToday = today; 127 oldToday = today;
127 128
128 if(disabled || (today<0)) { 129 if(disabled || (today<0)) {
129 hide(); mTimeBox->hide(); 130 hide(); mTimeBox->hide();
130 return; 131 return;
131 } else { 132 } else {
132 show(); mTimeBox->show(); 133 show(); mTimeBox->show();
133 } 134 }
134 135
135 if(recalculate) 136 if(recalculate)
136 setFixedSize(agenda->gridSpacingX(),1); 137 setFixedSize(agenda->gridSpacingX(),1);
137 agenda->moveChild(this, x, y); 138 agenda->moveChild(this, x, y);
138 raise(); 139 raise();
139 140
140 if(recalculate) 141 if(recalculate)
141 //mTimeBox->setFont(QFont("helvetica",10)); 142 //mTimeBox->setFont(QFont("helvetica",10));
142 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
143 144
144 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
145 mTimeBox->adjustSize(); 146 mTimeBox->adjustSize();
146 // the -2 below is there because there is a bug in this program 147 // the -2 below is there because there is a bug in this program
147 // somewhere, where the last column of this widget is a few pixels 148 // somewhere, where the last column of this widget is a few pixels
148 // narrower than the other columns. 149 // narrower than the other columns.
149 int offs = (today==agenda->columns()-1) ? -4 : 0; 150 int offs = (today==agenda->columns()-1) ? -4 : 0;
150 agenda->moveChild(mTimeBox, 151 agenda->moveChild(mTimeBox,
151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
152 y-mTimeBox->height()); 153 y-mTimeBox->height());
153 154
154 mTimeBox->raise(); 155 mTimeBox->raise();
155 //mTimeBox->setAutoMask(true); 156 //mTimeBox->setAutoMask(true);
156 minutes->start(5000,true); 157 minutes->start(5000,true);
157} 158}
158 159
159 160
160//////////////////////////////////////////////////////////////////////////// 161////////////////////////////////////////////////////////////////////////////
161 162
162 163
163/* 164/*
164 Create an agenda widget with rows rows and columns columns. 165 Create an agenda widget with rows rows and columns columns.
165*/ 166*/
166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
167 const char *name,WFlags f) : 168 const char *name,WFlags f) :
168 QScrollView(parent,name,f) 169 QScrollView(parent,name,f)
169{ 170{
170 171
171 mAllAgendaPopup = 0; 172 mAllAgendaPopup = 0;
172 mColumns = columns; 173 mColumns = columns;
173 mRows = rows; 174 mRows = rows;
174 mGridSpacingY = rowSize; 175 mGridSpacingY = rowSize;
175 mAllDayMode = false; 176 mAllDayMode = false;
176#ifndef DESKTOP_VERSION 177#ifndef DESKTOP_VERSION
177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 178 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
178#endif 179#endif
179 mHolidayMask = 0; 180 mHolidayMask = 0;
180 init(); 181 init();
182 connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) );
181} 183}
182 184
183/* 185/*
184 Create an agenda widget with columns columns and one row. This is used for 186 Create an agenda widget with columns columns and one row. This is used for
185 all-day events. 187 all-day events.
186*/ 188*/
187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 189KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
188 QScrollView(parent,name,f) 190 QScrollView(parent,name,f)
189{ 191{
190 mAllAgendaPopup = 0; 192 mAllAgendaPopup = 0;
191 blockResize = false; 193 blockResize = false;
192 mColumns = columns; 194 mColumns = columns;
193 mRows = 1; 195 mRows = 1;
194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 196 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
195 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 197 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
196 mAllDayMode = true; 198 mAllDayMode = true;
197#ifndef DESKTOP_VERSION 199#ifndef DESKTOP_VERSION
198 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 200 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
199#endif 201#endif
200 mHolidayMask = 0; 202 mHolidayMask = 0;
201 init(); 203 init();
202} 204}
203 205
204 206
205KOAgenda::~KOAgenda() 207KOAgenda::~KOAgenda()
206{ 208{
207 if(mMarcusBains) delete mMarcusBains; 209 if(mMarcusBains) delete mMarcusBains;
208 210
209} 211}
210 212
211Incidence *KOAgenda::selectedIncidence() const 213Incidence *KOAgenda::selectedIncidence() const
212{ 214{
213 return (mSelectedItem ? mSelectedItem->incidence() : 0); 215 return (mSelectedItem ? mSelectedItem->incidence() : 0);
214} 216}
215 217
216 218
217QDate KOAgenda::selectedIncidenceDate() const 219QDate KOAgenda::selectedIncidenceDate() const
218{ 220{
219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 221 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
220} 222}
221 223
222 224
223void KOAgenda::init() 225void KOAgenda::init()
224{ 226{
225 mPopupTimer = new QTimer(this); 227 mPopupTimer = new QTimer(this);
226 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 228 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
227 229
228 mNewItemPopup = new QPopupMenu( this ); 230 mNewItemPopup = new QPopupMenu( this );
229 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 231 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
230 QString pathString = ""; 232 QString pathString = "";
231 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 233 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
232 if ( QApplication::desktop()->width() < 480 ) 234 if ( QApplication::desktop()->width() < 480 )
233 pathString += "icons16/"; 235 pathString += "icons16/";
234 } else 236 } else
235 pathString += "iconsmini/"; 237 pathString += "iconsmini/";
236 238
237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 239 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
238 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
239 mNewItemPopup->insertSeparator ( ); 241 mNewItemPopup->insertSeparator ( );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
241 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 245 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); 246 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 );
245 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 247 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
246#ifndef _WIN32_ 248#ifndef _WIN32_
247 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 249 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
248 viewport()->setWFlags ( wflags); 250 viewport()->setWFlags ( wflags);
249#endif 251#endif
250 mGridSpacingX = 80; 252 mGridSpacingX = 80;
251 mResizeBorderWidth = 8; 253 mResizeBorderWidth = 8;
252 mScrollBorderWidth = 8; 254 mScrollBorderWidth = 8;
253 mScrollDelay = 30; 255 mScrollDelay = 30;
254 mScrollOffset = 10; 256 mScrollOffset = 10;
255 mPaintPixmap.resize( 20,20); 257 mPaintPixmap.resize( 20,20);
256 //enableClipper(true); 258 //enableClipper(true);
257 259
258 // Grab key strokes for keyboard navigation of agenda. Seems to have no 260 // Grab key strokes for keyboard navigation of agenda. Seems to have no
259 // effect. Has to be fixed. 261 // effect. Has to be fixed.
260 setFocusPolicy(WheelFocus); 262 setFocusPolicy(WheelFocus);
261 263
262 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 264 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
263 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 265 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
264 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 266 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
265 267
266 mStartCellX = 0; 268 mStartCellX = 0;
267 mStartCellY = 0; 269 mStartCellY = 0;
268 mCurrentCellX = 0; 270 mCurrentCellX = 0;
269 mCurrentCellY = 0; 271 mCurrentCellY = 0;
270 272
271 mSelectionCellX = 0; 273 mSelectionCellX = 0;
272 mSelectionYTop = 0; 274 mSelectionYTop = 0;
273 mSelectionHeight = 0; 275 mSelectionHeight = 0;
274 276
275 mOldLowerScrollValue = -1; 277 mOldLowerScrollValue = -1;
276 mOldUpperScrollValue = -1; 278 mOldUpperScrollValue = -1;
277 279
278 mClickedItem = 0; 280 mClickedItem = 0;
279 281
280 mActionItem = 0; 282 mActionItem = 0;
281 mActionType = NOP; 283 mActionType = NOP;
282 mItemMoved = false; 284 mItemMoved = false;
283 285
284 mSelectedItem = 0; 286 mSelectedItem = 0;
285 287
286 // mItems.setAutoDelete(true); 288 // mItems.setAutoDelete(true);
287 289
288 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 290 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
289 291
290 viewport()->update(); 292 viewport()->update();
291 293
292 setMinimumSize(30, 1); 294 setMinimumSize(30, 1);
293// setMaximumHeight(mGridSpacingY * mRows + 5); 295// setMaximumHeight(mGridSpacingY * mRows + 5);
294 296
295 // Disable horizontal scrollbar. This is a hack. The geometry should be 297 // Disable horizontal scrollbar. This is a hack. The geometry should be
296 // controlled in a way that the contents horizontally always fits. Then it is 298 // controlled in a way that the contents horizontally always fits. Then it is
297 // not necessary to turn off the scrollbar. 299 // not necessary to turn off the scrollbar.
298 setHScrollBarMode(AlwaysOff); 300 setHScrollBarMode(AlwaysOff);
299 if ( ! mAllDayMode ) 301 if ( ! mAllDayMode )
300 setVScrollBarMode(AlwaysOn); 302 setVScrollBarMode(AlwaysOn);
301 else 303 else
302 setVScrollBarMode(AlwaysOff); 304 setVScrollBarMode(AlwaysOff);
303 305
304 setStartHour(KOPrefs::instance()->mDayBegins); 306 setStartHour(KOPrefs::instance()->mDayBegins);
305 307
306 calculateWorkingHours(); 308 calculateWorkingHours();
307 309
308 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 310 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
309 SLOT(checkScrollBoundaries(int))); 311 SLOT(checkScrollBoundaries(int)));
310 312
311 // Create the Marcus Bains line. 313 // Create the Marcus Bains line.
312 if(mAllDayMode) 314 if(mAllDayMode)
313 mMarcusBains = 0; 315 mMarcusBains = 0;
314 else { 316 else {
315 mMarcusBains = new MarcusBains(this); 317 mMarcusBains = new MarcusBains(this);
316 addChild(mMarcusBains); 318 addChild(mMarcusBains);
317 } 319 }
318 mPopupKind = 0; 320 mPopupKind = 0;
319 mPopupItem = 0; 321 mPopupItem = 0;
322 mInvalidPixmap = false;
323
320} 324}
321 325
326void KOAgenda::shrinkPixmap()
327{
328 mPaintPixmap.resize( 20,20);
329 mInvalidPixmap = true;
330}
331void KOAgenda::slotContentMove(int,int)
332{
333 if ( mActionType == NOP )
334 slotClearSelection();
335 if ( mSelectedItem && !mActionItem ) {
336 deselectItem();
337 emit incidenceSelected( 0 );
338 }
339}
322void KOAgenda::clear() 340void KOAgenda::clear()
323{ 341{
324 KOAgendaItem *item; 342 KOAgendaItem *item;
325 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 343 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
326 mUnusedItems.append( item ); 344 mUnusedItems.append( item );
327 //item->hide(); 345 //item->hide();
328 } 346 }
329 mItems.clear(); 347 mItems.clear();
330 mSelectedItem = 0; 348 mSelectedItem = 0;
331 clearSelection(); 349 clearSelection();
332} 350}
333 351
334void KOAgenda::clearSelection() 352void KOAgenda::clearSelection()
335{ 353{
336 mSelectionCellX = 0; 354 mSelectionCellX = 0;
337 mSelectionYTop = 0; 355 mSelectionYTop = 0;
338 mSelectionHeight = 0; 356 mSelectionHeight = 0;
339} 357}
340 358
341void KOAgenda::marcus_bains() 359void KOAgenda::marcus_bains()
342{ 360{
343 if(mMarcusBains) mMarcusBains->updateLocation(true); 361 if(mMarcusBains) mMarcusBains->updateLocation(true);
344} 362}
345 363
346 364
347void KOAgenda::changeColumns(int columns) 365void KOAgenda::changeColumns(int columns)
348{ 366{
349 if (columns == 0) { 367 if (columns == 0) {
350 qDebug("KOAgenda::changeColumns() called with argument 0 "); 368 qDebug("KOAgenda::changeColumns() called with argument 0 ");
351 return; 369 return;
352 } 370 }
353 clear(); 371 clear();
354 mColumns = columns; 372 mColumns = columns;
355 computeSizes(); 373 computeSizes();
356} 374}
357 375
358/* 376/*
359 This is the eventFilter function, which gets all events from the KOAgendaItems 377 This is the eventFilter function, which gets all events from the KOAgendaItems
360 contained in the agenda. It has to handle moving and resizing for all items. 378 contained in the agenda. It has to handle moving and resizing for all items.
361*/ 379*/
362bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 380bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
363{ 381{
364 // kdDebug() << "KOAgenda::eventFilter" << endl; 382 // kdDebug() << "KOAgenda::eventFilter" << endl;
365 switch(event->type()) { 383 switch(event->type()) {
366 case QEvent::MouseButtonPress: 384 case QEvent::MouseButtonPress:
367 case QEvent::MouseButtonDblClick: 385 case QEvent::MouseButtonDblClick:
368 case QEvent::MouseButtonRelease: 386 case QEvent::MouseButtonRelease:
369 case QEvent::MouseMove: 387 case QEvent::MouseMove:
370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 388 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
371 389
372 case (QEvent::Leave): 390 case (QEvent::Leave):
373 if (!mActionItem) 391 if (!mActionItem)
374 setCursor(arrowCursor); 392 setCursor(arrowCursor);
375 return true; 393 return true;
376 394
377 default: 395 default:
378 return QScrollView::eventFilter(object,event); 396 return QScrollView::eventFilter(object,event);
379 } 397 }
380} 398}
381void KOAgenda::popupMenu() 399void KOAgenda::popupMenu()
382{ 400{
383 mPopupTimer->stop(); 401 mPopupTimer->stop();
384 if ( mPopupKind == 1 || mPopupKind == 3 ) { 402 if ( mPopupKind == 1 || mPopupKind == 3 ) {
385 if (mActionItem ) { 403 if (mActionItem ) {
386 endItemAction(); 404 endItemAction();
387 } 405 }
388 mLeftMouseDown = false; // no more leftMouse computation 406 mLeftMouseDown = false; // no more leftMouse computation
389 if (mPopupItem) { 407 if (mPopupItem) {
390 //mClickedItem = mPopupItem; 408 //mClickedItem = mPopupItem;
391 selectItem(mPopupItem); 409 selectItem(mPopupItem);
392 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) 410 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 )
393 mAllAgendaPopup->installEventFilter( this ); 411 mAllAgendaPopup->installEventFilter( this );
394 emit showIncidencePopupSignal(mPopupItem->incidence()); 412 emit showIncidencePopupSignal(mPopupItem->incidence());
395 413
396 } 414 }
397 } else if ( mPopupKind == 2 || mPopupKind == 4 ) { 415 } else if ( mPopupKind == 2 || mPopupKind == 4 ) {
398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 416 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
399 endSelectAction( false ); // do not emit new event signal 417 endSelectAction( false ); // do not emit new event signal
400 mLeftMouseDown = false; // no more leftMouse computation 418 mLeftMouseDown = false; // no more leftMouse computation
401 } 419 }
402 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) 420 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 )
403 mNewItemPopup->installEventFilter( this ); 421 mNewItemPopup->installEventFilter( this );
404 mNewItemPopup->popup( mPopupPos); 422 mNewItemPopup->popup( mPopupPos);
405 423
406 } 424 }
407 mLeftMouseDown = false; 425 mLeftMouseDown = false;
408 mPopupItem = 0; 426 mPopupItem = 0;
409 mPopupKind = 0; 427 mPopupKind = 0;
410} 428}
411void KOAgenda::categoryChanged(Incidence * inc) 429void KOAgenda::categoryChanged(Incidence * inc)
412{ 430{
413 KOAgendaItem *item; 431 KOAgendaItem *item;
414 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 432 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
415 if ( item->incidence() == inc ) { 433 if ( item->incidence() == inc ) {
416 item->initColor (); 434 item->initColor ();
417 item->updateItem(); 435 item->updateItem();
418 } 436 }
419 } 437 }
420} 438}
421bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 439bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
422{ 440{
423 static int startX = 0; 441 static int startX = 0;
424 static int startY = 0; 442 static int startY = 0;
425 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); 443 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 );
426 static bool blockMoving = true; 444 static bool blockMoving = true;
427 445
428 //qDebug("KOAgenda::eventFilter_mous "); 446 //qDebug("KOAgenda::eventFilter_mous ");
429 if ( object == mNewItemPopup ) { 447 if ( object == mNewItemPopup ) {
430 //qDebug("mNewItemPopup "); 448 //qDebug("mNewItemPopup ");
431 if ( me->type() == QEvent::MouseButtonRelease ) { 449 if ( me->type() == QEvent::MouseButtonRelease ) {
432 mNewItemPopup->removeEventFilter( this ); 450 mNewItemPopup->removeEventFilter( this );
433 int dX = me->globalPos().x() - mPopupPos.x();; 451 int dX = me->globalPos().x() - mPopupPos.x();;
434 if ( dX < 0 ) 452 if ( dX < 0 )
435 dX = -dX; 453 dX = -dX;
436 int dY = me->globalPos().y() - mPopupPos.y(); 454 int dY = me->globalPos().y() - mPopupPos.y();
437 if ( dY < 0 ) 455 if ( dY < 0 )
438 dY = -dY; 456 dY = -dY;
439 if ( dX > blockmoveDist || dY > blockmoveDist ) { 457 if ( dX > blockmoveDist || dY > blockmoveDist ) {
440 mNewItemPopup->hide(); 458 mNewItemPopup->hide();
441 } 459 }
442 } 460 }
443 return true; 461 return true;
444 } 462 }
445 if ( object == mAllAgendaPopup ) { 463 if ( object == mAllAgendaPopup ) {
446 //qDebug(" mAllAgendaPopup "); 464 //qDebug(" mAllAgendaPopup ");
447 if ( me->type() == QEvent::MouseButtonRelease ) { 465 if ( me->type() == QEvent::MouseButtonRelease ) {
448 mAllAgendaPopup->removeEventFilter( this ); 466 mAllAgendaPopup->removeEventFilter( this );
449 int dX = me->globalPos().x() - mPopupPos.x();; 467 int dX = me->globalPos().x() - mPopupPos.x();;
450 if ( dX < 0 ) 468 if ( dX < 0 )
451 dX = -dX; 469 dX = -dX;
452 int dY = me->globalPos().y() - mPopupPos.y(); 470 int dY = me->globalPos().y() - mPopupPos.y();
453 if ( dY < 0 ) 471 if ( dY < 0 )
454 dY = -dY; 472 dY = -dY;
455 if ( dX > blockmoveDist || dY > blockmoveDist ) { 473 if ( dX > blockmoveDist || dY > blockmoveDist ) {
456 mAllAgendaPopup->hide(); 474 mAllAgendaPopup->hide();
457 } 475 }
458 } 476 }
459 return true; 477 return true;
460 } 478 }
461 QPoint viewportPos; 479 QPoint viewportPos;
462 if (object != viewport()) { 480 if (object != viewport()) {
463 blockmoveDist = blockmoveDist*2; 481 blockmoveDist = blockmoveDist*2;
464 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 482 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
465 } else { 483 } else {
466 viewportPos = me->pos(); 484 viewportPos = me->pos();
467 } 485 }
468 bool objIsNotViewport = (object != viewport()); 486 bool objIsNotViewport = (object != viewport());
469 bool leftButt = false; 487 bool leftButt = false;
470#ifdef DESKTOP_VERSION 488#ifdef DESKTOP_VERSION
471 leftButt = (me->button() == LeftButton); 489 leftButt = (me->button() == LeftButton);
472#endif 490#endif
473 switch (me->type()) { 491 switch (me->type()) {
474 case QEvent::MouseButtonPress: 492 case QEvent::MouseButtonPress:
475 if (me->button() == LeftButton) { 493 if (me->button() == LeftButton) {
476 mPopupTimer->start( 600 ); 494 mPopupTimer->start( 600 );
477 mLeftMouseDown = true; 495 mLeftMouseDown = true;
478 } 496 }
479 blockMoving = true; 497 blockMoving = true;
480 startX = viewportPos.x(); 498 startX = viewportPos.x();
481 startY = viewportPos.y(); 499 startY = viewportPos.y();
482 mPopupPos = me->globalPos(); 500 mPopupPos = me->globalPos();
483 if ( objIsNotViewport && !leftButt ) { 501 if ( objIsNotViewport && !leftButt ) {
484 KOAgendaItem * tempItem = (KOAgendaItem *)object; 502 KOAgendaItem * tempItem = (KOAgendaItem *)object;
485 if (mAllDayMode) { 503 if (mAllDayMode) {
486 if ( tempItem->height() > 10 ) { 504 if ( tempItem->height() > 10 ) {
487 int minV = tempItem->height()/4; 505 int minV = tempItem->height()/4;
488 if ( minV > (blockmoveDist/2)-2 ) { 506 if ( minV > (blockmoveDist/2)-2 ) {
489 if ( minV > blockmoveDist ) 507 if ( minV > blockmoveDist )
490 minV = blockmoveDist; 508 minV = blockmoveDist;
491 else 509 else
492 minV = (blockmoveDist/2); 510 minV = (blockmoveDist/2);
493 } 511 }
494 bool border = false; 512 bool border = false;
495 int diff = tempItem->y() - viewportPos.y(); 513 int diff = tempItem->y() - viewportPos.y();
496 if ( diff < 0 ) 514 if ( diff < 0 )
497 diff *= -1; 515 diff *= -1;
498 if ( diff < minV ) { 516 if ( diff < minV ) {
499 border = true; 517 border = true;
500 objIsNotViewport = false; 518 objIsNotViewport = false;
501 } 519 }
502 if ( ! border ) { 520 if ( ! border ) {
503 diff = tempItem->y() + tempItem->height()- viewportPos.y(); 521 diff = tempItem->y() + tempItem->height()- viewportPos.y();
504 if ( diff < 0 ) 522 if ( diff < 0 )
505 diff *= -1; 523 diff *= -1;
506 if ( diff < minV ) { 524 if ( diff < minV ) {
507 border = true; 525 border = true;
508 objIsNotViewport = false; 526 objIsNotViewport = false;
509 } 527 }
510 } 528 }
511 } 529 }
512 } else { // not allday 530 } else { // not allday
513 if ( tempItem->width() > 10 ) { 531 if ( tempItem->width() > 10 ) {
@@ -733,706 +751,714 @@ void KOAgenda::startSelectAction(QPoint viewportPos)
733 751
734 // Paint new selection 752 // Paint new selection
735 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, 753 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop,
736 mGridSpacingX-1, mSelectionHeight ); 754 mGridSpacingX-1, mSelectionHeight );
737} 755}
738 756
739void KOAgenda::performSelectAction(QPoint viewportPos) 757void KOAgenda::performSelectAction(QPoint viewportPos)
740{ 758{
741 int x,y; 759 int x,y;
742 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 760 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
743 int gx,gy; 761 int gx,gy;
744 contentsToGrid(x,y,gx,gy); 762 contentsToGrid(x,y,gx,gy);
745 763
746 QPoint clipperPos = clipper()-> 764 QPoint clipperPos = clipper()->
747 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 765 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
748 766
749 // Scroll if cursor was moved to upper or lower end of agenda. 767 // Scroll if cursor was moved to upper or lower end of agenda.
750 if (clipperPos.y() < mScrollBorderWidth) { 768 if (clipperPos.y() < mScrollBorderWidth) {
751 mScrollUpTimer.start(mScrollDelay); 769 mScrollUpTimer.start(mScrollDelay);
752 } else if (visibleHeight() - clipperPos.y() < 770 } else if (visibleHeight() - clipperPos.y() <
753 mScrollBorderWidth) { 771 mScrollBorderWidth) {
754 mScrollDownTimer.start(mScrollDelay); 772 mScrollDownTimer.start(mScrollDelay);
755 } else { 773 } else {
756 mScrollUpTimer.stop(); 774 mScrollUpTimer.stop();
757 mScrollDownTimer.stop(); 775 mScrollDownTimer.stop();
758 } 776 }
759 777
760 if ( gy > mCurrentCellY ) { 778 if ( gy > mCurrentCellY ) {
761 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 779 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
762 780
763 781
764 repaintContents( (KOGlobals::self()->reverseLayout() ? 782 repaintContents( (KOGlobals::self()->reverseLayout() ?
765 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 783 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
766 mGridSpacingX, mSelectionYTop, 784 mGridSpacingX, mSelectionYTop,
767 mGridSpacingX, mSelectionHeight , false); 785 mGridSpacingX, mSelectionHeight , false);
768 786
769 mCurrentCellY = gy; 787 mCurrentCellY = gy;
770 } else if ( gy < mCurrentCellY ) { 788 } else if ( gy < mCurrentCellY ) {
771 if ( gy >= mStartCellY ) { 789 if ( gy >= mStartCellY ) {
772 int selectionHeight = mSelectionHeight; 790 int selectionHeight = mSelectionHeight;
773 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 791 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
774 792
775 repaintContents( (KOGlobals::self()->reverseLayout() ? 793 repaintContents( (KOGlobals::self()->reverseLayout() ?
776 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 794 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
777 mGridSpacingX, mSelectionYTop, 795 mGridSpacingX, mSelectionYTop,
778 mGridSpacingX, selectionHeight,false ); 796 mGridSpacingX, selectionHeight,false );
779 797
780 mCurrentCellY = gy; 798 mCurrentCellY = gy;
781 } else { 799 } else {
782 } 800 }
783 } 801 }
784} 802}
785 803
786void KOAgenda::endSelectAction( bool emitNewEvent ) 804void KOAgenda::endSelectAction( bool emitNewEvent )
787{ 805{
788 mActionType = NOP; 806 mActionType = NOP;
789 mScrollUpTimer.stop(); 807 mScrollUpTimer.stop();
790 mScrollDownTimer.stop(); 808 mScrollDownTimer.stop();
791 809
792 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 810 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
793 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 811 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
794 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 812 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
795 } 813 }
796} 814}
797 815
798void KOAgenda::startItemAction(QPoint viewportPos) 816void KOAgenda::startItemAction(QPoint viewportPos)
799{ 817{
800 int x,y; 818 int x,y;
801 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 819 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
802 int gx,gy; 820 int gx,gy;
803 contentsToGrid(x,y,gx,gy); 821 contentsToGrid(x,y,gx,gy);
804 822
805 mStartCellX = gx; 823 mStartCellX = gx;
806 mStartCellY = gy; 824 mStartCellY = gy;
807 mCurrentCellX = gx; 825 mCurrentCellX = gx;
808 mCurrentCellY = gy; 826 mCurrentCellY = gy;
809 827
810 if (mAllDayMode) { 828 if (mAllDayMode) {
811 int gridDistanceX = (x - gx * mGridSpacingX); 829 int gridDistanceX = (x - gx * mGridSpacingX);
812 if (gridDistanceX < mResizeBorderWidth && 830 if (gridDistanceX < mResizeBorderWidth &&
813 mActionItem->cellX() == mCurrentCellX) { 831 mActionItem->cellX() == mCurrentCellX) {
814 mActionType = RESIZELEFT; 832 mActionType = RESIZELEFT;
815 setCursor(sizeHorCursor); 833 setCursor(sizeHorCursor);
816 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 834 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
817 mActionItem->cellXWidth() == mCurrentCellX) { 835 mActionItem->cellXWidth() == mCurrentCellX) {
818 mActionType = RESIZERIGHT; 836 mActionType = RESIZERIGHT;
819 setCursor(sizeHorCursor); 837 setCursor(sizeHorCursor);
820 } else { 838 } else {
821 mActionType = MOVE; 839 mActionType = MOVE;
822 mActionItem->startMove(); 840 mActionItem->startMove();
823 setCursor(sizeAllCursor); 841 setCursor(sizeAllCursor);
824 } 842 }
825 } else { 843 } else {
826 int gridDistanceY = (y - gy * mGridSpacingY); 844 int gridDistanceY = (y - gy * mGridSpacingY);
827 bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); 845 bool allowResize = ( mActionItem->incidence()->typeID() != todoID );
828 if (allowResize && gridDistanceY < mResizeBorderWidth && 846 if (allowResize && gridDistanceY < mResizeBorderWidth &&
829 mActionItem->cellYTop() == mCurrentCellY && 847 mActionItem->cellYTop() == mCurrentCellY &&
830 !mActionItem->firstMultiItem()) { 848 !mActionItem->firstMultiItem()) {
831 mActionType = RESIZETOP; 849 mActionType = RESIZETOP;
832 setCursor(sizeVerCursor); 850 setCursor(sizeVerCursor);
833 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 851 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
834 mActionItem->cellYBottom() == mCurrentCellY && 852 mActionItem->cellYBottom() == mCurrentCellY &&
835 !mActionItem->lastMultiItem()) { 853 !mActionItem->lastMultiItem()) {
836 mActionType = RESIZEBOTTOM; 854 mActionType = RESIZEBOTTOM;
837 setCursor(sizeVerCursor); 855 setCursor(sizeVerCursor);
838 } else { 856 } else {
839 mActionType = MOVE; 857 mActionType = MOVE;
840 mActionItem->startMove(); 858 mActionItem->startMove();
841 setCursor(sizeAllCursor); 859 setCursor(sizeAllCursor);
842 } 860 }
843 } 861 }
844} 862}
845 863
846void KOAgenda::performItemAction(QPoint viewportPos) 864void KOAgenda::performItemAction(QPoint viewportPos)
847{ 865{
848// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 866// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
849// QPoint point = viewport()->mapToGlobal(viewportPos); 867// QPoint point = viewport()->mapToGlobal(viewportPos);
850// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 868// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
851// point = clipper()->mapFromGlobal(point); 869// point = clipper()->mapFromGlobal(point);
852// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 870// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
853// kdDebug() << "visible height: " << visibleHeight() << endl; 871// kdDebug() << "visible height: " << visibleHeight() << endl;
854 int x,y; 872 int x,y;
855 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 873 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
856// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 874// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
857 int gx,gy; 875 int gx,gy;
858 contentsToGrid(x,y,gx,gy); 876 contentsToGrid(x,y,gx,gy);
859 QPoint clipperPos = clipper()-> 877 QPoint clipperPos = clipper()->
860 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 878 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
861 879
862 // Cursor left active agenda area. 880 // Cursor left active agenda area.
863 // This starts a drag. 881 // This starts a drag.
864 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 882 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
865 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 883 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
866 if ( mActionType == MOVE ) { 884 if ( mActionType == MOVE ) {
867 mScrollUpTimer.stop(); 885 mScrollUpTimer.stop();
868 mScrollDownTimer.stop(); 886 mScrollDownTimer.stop();
869 mActionItem->resetMove(); 887 mActionItem->resetMove();
870 placeSubCells( mActionItem ); 888 placeSubCells( mActionItem );
871 // emit startDragSignal( mActionItem->incidence() ); 889 // emit startDragSignal( mActionItem->incidence() );
872 setCursor( arrowCursor ); 890 setCursor( arrowCursor );
873 mActionItem = 0; 891 mActionItem = 0;
874 mActionType = NOP; 892 mActionType = NOP;
875 mItemMoved = 0; 893 mItemMoved = 0;
876 return; 894 return;
877 } 895 }
878 } else { 896 } else {
879 switch ( mActionType ) { 897 switch ( mActionType ) {
880 case MOVE: 898 case MOVE:
881 setCursor( sizeAllCursor ); 899 setCursor( sizeAllCursor );
882 break; 900 break;
883 case RESIZETOP: 901 case RESIZETOP:
884 case RESIZEBOTTOM: 902 case RESIZEBOTTOM:
885 setCursor( sizeVerCursor ); 903 setCursor( sizeVerCursor );
886 break; 904 break;
887 case RESIZELEFT: 905 case RESIZELEFT:
888 case RESIZERIGHT: 906 case RESIZERIGHT:
889 setCursor( sizeHorCursor ); 907 setCursor( sizeHorCursor );
890 break; 908 break;
891 default: 909 default:
892 setCursor( arrowCursor ); 910 setCursor( arrowCursor );
893 } 911 }
894 } 912 }
895 913
896 // Scroll if item was moved to upper or lower end of agenda. 914 // Scroll if item was moved to upper or lower end of agenda.
897 if (clipperPos.y() < mScrollBorderWidth) { 915 if (clipperPos.y() < mScrollBorderWidth) {
898 mScrollUpTimer.start(mScrollDelay); 916 mScrollUpTimer.start(mScrollDelay);
899 } else if (visibleHeight() - clipperPos.y() < 917 } else if (visibleHeight() - clipperPos.y() <
900 mScrollBorderWidth) { 918 mScrollBorderWidth) {
901 mScrollDownTimer.start(mScrollDelay); 919 mScrollDownTimer.start(mScrollDelay);
902 } else { 920 } else {
903 mScrollUpTimer.stop(); 921 mScrollUpTimer.stop();
904 mScrollDownTimer.stop(); 922 mScrollDownTimer.stop();
905 } 923 }
906 924
907 // Move or resize item if necessary 925 // Move or resize item if necessary
908 if (mCurrentCellX != gx || mCurrentCellY != gy) { 926 if (mCurrentCellX != gx || mCurrentCellY != gy) {
909 mItemMoved = true; 927 mItemMoved = true;
910 mActionItem->raise(); 928 mActionItem->raise();
911 if (mActionType == MOVE) { 929 if (mActionType == MOVE) {
912 // Move all items belonging to a multi item 930 // Move all items belonging to a multi item
913 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 931 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
914 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 932 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
915 if (!moveItem) moveItem = mActionItem; 933 if (!moveItem) moveItem = mActionItem;
916 while (moveItem) { 934 while (moveItem) {
917 int dy; 935 int dy;
918 if (isMultiItem) dy = 0; 936 if (isMultiItem) dy = 0;
919 else dy = gy - mCurrentCellY; 937 else dy = gy - mCurrentCellY;
920 moveItem->moveRelative(gx - mCurrentCellX,dy); 938 moveItem->moveRelative(gx - mCurrentCellX,dy);
921 int x,y; 939 int x,y;
922 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 940 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
923 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 941 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
924 mGridSpacingY * moveItem->cellHeight()); 942 mGridSpacingY * moveItem->cellHeight());
943 moveItem->raise();
925 moveChild(moveItem,x,y); 944 moveChild(moveItem,x,y);
926 moveItem = moveItem->nextMultiItem(); 945 moveItem = moveItem->nextMultiItem();
927 } 946 }
928 } else if (mActionType == RESIZETOP) { 947 } else if (mActionType == RESIZETOP) {
929 if (mCurrentCellY <= mActionItem->cellYBottom()) { 948 if (mCurrentCellY <= mActionItem->cellYBottom()) {
930 mActionItem->expandTop(gy - mCurrentCellY); 949 mActionItem->expandTop(gy - mCurrentCellY);
931 mActionItem->resize(mActionItem->width(), 950 mActionItem->resize(mActionItem->width(),
932 mGridSpacingY * mActionItem->cellHeight()); 951 mGridSpacingY * mActionItem->cellHeight());
933 int x,y; 952 int x,y;
934 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 953 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
935 //moveChild(mActionItem,childX(mActionItem),y); 954 //moveChild(mActionItem,childX(mActionItem),y);
936 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 955 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
937 } 956 }
938 } else if (mActionType == RESIZEBOTTOM) { 957 } else if (mActionType == RESIZEBOTTOM) {
939 if (mCurrentCellY >= mActionItem->cellYTop()) { 958 if (mCurrentCellY >= mActionItem->cellYTop()) {
940 mActionItem->expandBottom(gy - mCurrentCellY); 959 mActionItem->expandBottom(gy - mCurrentCellY);
941 mActionItem->resize(mActionItem->width(), 960 mActionItem->resize(mActionItem->width(),
942 mGridSpacingY * mActionItem->cellHeight()); 961 mGridSpacingY * mActionItem->cellHeight());
943 } 962 }
944 } else if (mActionType == RESIZELEFT) { 963 } else if (mActionType == RESIZELEFT) {
945 if (mCurrentCellX <= mActionItem->cellXWidth()) { 964 if (mCurrentCellX <= mActionItem->cellXWidth()) {
946 mActionItem->expandLeft(gx - mCurrentCellX); 965 mActionItem->expandLeft(gx - mCurrentCellX);
947 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 966 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
948 mActionItem->height()); 967 mActionItem->height());
949 int x,y; 968 int x,y;
950 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 969 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
951 moveChild(mActionItem,x,childY(mActionItem)); 970 moveChild(mActionItem,x,childY(mActionItem));
952 } 971 }
953 } else if (mActionType == RESIZERIGHT) { 972 } else if (mActionType == RESIZERIGHT) {
954 if (mCurrentCellX >= mActionItem->cellX()) { 973 if (mCurrentCellX >= mActionItem->cellX()) {
955 mActionItem->expandRight(gx - mCurrentCellX); 974 mActionItem->expandRight(gx - mCurrentCellX);
956 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 975 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
957 mActionItem->height()); 976 mActionItem->height());
958 } 977 }
959 } 978 }
960 mCurrentCellX = gx; 979 mCurrentCellX = gx;
961 mCurrentCellY = gy; 980 mCurrentCellY = gy;
962 } 981 }
963} 982}
964 983
965void KOAgenda::endItemAction() 984void KOAgenda::endItemAction()
966{ 985{
967 986
968 if ( mItemMoved ) { 987 if ( mItemMoved ) {
969 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 988 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
970 if ( !placeItem ) { 989 if ( !placeItem ) {
971 placeItem = mActionItem; 990 placeItem = mActionItem;
972 } 991 }
973 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 992 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
974 Incidence* oldInc = placeItem->incidence(); 993 Incidence* oldInc = placeItem->incidence();
975 placeItem->recreateIncidence(); 994 placeItem->recreateIncidence();
976 emit addToCalSignal(placeItem->incidence(), oldInc ); 995 emit addToCalSignal(placeItem->incidence(), oldInc );
977 } 996 }
978 int type = mActionType; 997 int type = mActionType;
979 if ( mAllDayMode ) 998 if ( mAllDayMode )
980 type = -1; 999 type = -1;
981 KOAgendaItem *modifiedItem = placeItem; 1000 KOAgendaItem *modifiedItem = placeItem;
982 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 1001 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
983 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 1002 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
984 KOAgendaItem *item; 1003 KOAgendaItem *item;
985 1004
986 if ( placeItem->incidence()->typeID() == todoID ) { 1005 if ( placeItem->incidence()->typeID() == todoID ) {
987 mSelectedItem = 0; 1006 mSelectedItem = 0;
988 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 1007 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
989 modifiedItem->mLastMoveXPos = mCurrentCellX; 1008 modifiedItem->mLastMoveXPos = mCurrentCellX;
990 emit itemModified( modifiedItem, mActionType ); 1009 emit itemModified( modifiedItem, mActionType );
991 } 1010 }
992 else { 1011 else {
993 1012
994 1013
995 globalFlagBlockAgendaItemPaint = 1; 1014 globalFlagBlockAgendaItemPaint = 1;
996 for ( item=oldconflictItems.first(); item != 0; 1015 for ( item=oldconflictItems.first(); item != 0;
997 item=oldconflictItems.next() ) { 1016 item=oldconflictItems.next() ) {
998 placeSubCells(item); 1017 placeSubCells(item);
999 } 1018 }
1000 while ( placeItem ) { 1019 while ( placeItem ) {
1001 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1020 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1002 oldconflictItems = placeItem->conflictItems(); 1021 oldconflictItems = placeItem->conflictItems();
1003 for ( item=oldconflictItems.first(); item != 0; 1022 for ( item=oldconflictItems.first(); item != 0;
1004 item=oldconflictItems.next() ) { 1023 item=oldconflictItems.next() ) {
1005 placeSubCells(item); 1024 placeSubCells(item);
1006 } 1025 }
1007 placeSubCells( placeItem ); 1026 placeSubCells( placeItem );
1008 placeItem = placeItem->nextMultiItem(); 1027 placeItem = placeItem->nextMultiItem();
1009 } 1028 }
1010 globalFlagBlockAgendaItemPaint = 0; 1029 globalFlagBlockAgendaItemPaint = 0;
1011 for ( item=oldconflictItems.first(); item != 0; 1030 for ( item=oldconflictItems.first(); item != 0;
1012 item=oldconflictItems.next() ) { 1031 item=oldconflictItems.next() ) {
1013 globalFlagBlockAgendaItemUpdate = 0; 1032 globalFlagBlockAgendaItemUpdate = 0;
1014 item->repaintMe(); 1033 item->repaintMe();
1015 globalFlagBlockAgendaItemUpdate = 1; 1034 globalFlagBlockAgendaItemUpdate = 1;
1016 item->repaint( false ); 1035 item->repaint( false );
1017 } 1036 }
1018 placeItem = modifiedItem; 1037 placeItem = modifiedItem;
1019 1038
1020 while ( placeItem ) { 1039 while ( placeItem ) {
1021 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1040 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1022 globalFlagBlockAgendaItemUpdate = 0; 1041 globalFlagBlockAgendaItemUpdate = 0;
1023 placeItem->repaintMe(); 1042 placeItem->repaintMe();
1024 globalFlagBlockAgendaItemUpdate = 1; 1043 globalFlagBlockAgendaItemUpdate = 1;
1025 placeItem->repaint(false); 1044 placeItem->repaint(false);
1026 placeItem = placeItem->nextMultiItem(); 1045 placeItem = placeItem->nextMultiItem();
1027 } 1046 }
1028 emit itemModified( modifiedItem, mActionType ); 1047 emit itemModified( modifiedItem, mActionType );
1029 1048
1030 1049
1031 placeItem = modifiedItem; 1050 placeItem = modifiedItem;
1032 while ( placeItem ) { 1051 while ( placeItem ) {
1033 oldconflictItems = placeItem->conflictItems(); 1052 oldconflictItems = placeItem->conflictItems();
1034 for ( item=oldconflictItems.first(); item != 0; 1053 for ( item=oldconflictItems.first(); item != 0;
1035 item=oldconflictItems.next() ) { 1054 item=oldconflictItems.next() ) {
1036 placeSubCells(item); 1055 placeSubCells(item);
1037 } 1056 }
1038 placeSubCells( placeItem ); 1057 placeSubCells( placeItem );
1039 placeItem = placeItem->nextMultiItem(); 1058 placeItem = placeItem->nextMultiItem();
1040 1059
1041 } 1060 }
1042 placeItem = modifiedItem; 1061 placeItem = modifiedItem;
1043 while ( placeItem ) { 1062 while ( placeItem ) {
1044 oldconflictItems = placeItem->conflictItems(); 1063 oldconflictItems = placeItem->conflictItems();
1045 for ( item=oldconflictItems.first(); item != 0; 1064 for ( item=oldconflictItems.first(); item != 0;
1046 item=oldconflictItems.next() ) { 1065 item=oldconflictItems.next() ) {
1047 globalFlagBlockAgendaItemUpdate = 0; 1066 globalFlagBlockAgendaItemUpdate = 0;
1048 item->repaintMe(); 1067 item->repaintMe();
1049 globalFlagBlockAgendaItemUpdate = 1; 1068 globalFlagBlockAgendaItemUpdate = 1;
1050 item->repaint(false); 1069 item->repaint(false);
1051 } 1070 }
1052 placeItem = placeItem->nextMultiItem(); 1071 placeItem = placeItem->nextMultiItem();
1053 } 1072 }
1054 /* 1073 /*
1055 1074
1056 oldconflictItems = modifiedItem->conflictItems(); 1075 oldconflictItems = modifiedItem->conflictItems();
1057 for ( item=oldconflictItems.first(); item != 0; 1076 for ( item=oldconflictItems.first(); item != 0;
1058 item=oldconflictItems.next() ) { 1077 item=oldconflictItems.next() ) {
1059 globalFlagBlockAgendaItemUpdate = 0; 1078 globalFlagBlockAgendaItemUpdate = 0;
1060 item->paintMe(false); 1079 item->paintMe(false);
1061 globalFlagBlockAgendaItemUpdate = 1; 1080 globalFlagBlockAgendaItemUpdate = 1;
1062 item->repaint(false); 1081 item->repaint(false);
1063 } 1082 }
1064 */ 1083 */
1065 1084
1066 1085
1067 } 1086 }
1068 1087
1069 } 1088 }
1070 1089
1071 mScrollUpTimer.stop(); 1090 mScrollUpTimer.stop();
1072 mScrollDownTimer.stop(); 1091 mScrollDownTimer.stop();
1073 setCursor( arrowCursor ); 1092 setCursor( arrowCursor );
1074 mActionItem = 0; 1093 mActionItem = 0;
1075 mActionType = NOP; 1094 mActionType = NOP;
1076 mItemMoved = 0; 1095 mItemMoved = 0;
1077 1096
1078} 1097}
1079 1098
1080void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 1099void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1081{ 1100{
1082// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 1101// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
1083// QPoint point = viewport()->mapToGlobal(viewportPos); 1102// QPoint point = viewport()->mapToGlobal(viewportPos);
1084// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 1103// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
1085// point = clipper()->mapFromGlobal(point); 1104// point = clipper()->mapFromGlobal(point);
1086// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 1105// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
1087 1106
1088 int x,y; 1107 int x,y;
1089 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 1108 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
1090// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 1109// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
1091 int gx,gy; 1110 int gx,gy;
1092 contentsToGrid(x,y,gx,gy); 1111 contentsToGrid(x,y,gx,gy);
1093 1112
1094 // Change cursor to resize cursor if appropriate 1113 // Change cursor to resize cursor if appropriate
1095 if (mAllDayMode) { 1114 if (mAllDayMode) {
1096 int gridDistanceX = (x - gx * mGridSpacingX); 1115 int gridDistanceX = (x - gx * mGridSpacingX);
1097 if (gridDistanceX < mResizeBorderWidth && 1116 if (gridDistanceX < mResizeBorderWidth &&
1098 moveItem->cellX() == gx) { 1117 moveItem->cellX() == gx) {
1099 setCursor(sizeHorCursor); 1118 setCursor(sizeHorCursor);
1100 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 1119 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
1101 moveItem->cellXWidth() == gx) { 1120 moveItem->cellXWidth() == gx) {
1102 setCursor(sizeHorCursor); 1121 setCursor(sizeHorCursor);
1103 } else { 1122 } else {
1104 setCursor(arrowCursor); 1123 setCursor(arrowCursor);
1105 } 1124 }
1106 } else { 1125 } else {
1107 int gridDistanceY = (y - gy * mGridSpacingY); 1126 int gridDistanceY = (y - gy * mGridSpacingY);
1108 if (gridDistanceY < mResizeBorderWidth && 1127 if (gridDistanceY < mResizeBorderWidth &&
1109 moveItem->cellYTop() == gy && 1128 moveItem->cellYTop() == gy &&
1110 !moveItem->firstMultiItem()) { 1129 !moveItem->firstMultiItem()) {
1111 setCursor(sizeVerCursor); 1130 setCursor(sizeVerCursor);
1112 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 1131 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
1113 moveItem->cellYBottom() == gy && 1132 moveItem->cellYBottom() == gy &&
1114 !moveItem->lastMultiItem()) { 1133 !moveItem->lastMultiItem()) {
1115 setCursor(sizeVerCursor); 1134 setCursor(sizeVerCursor);
1116 } else { 1135 } else {
1117 setCursor(arrowCursor); 1136 setCursor(arrowCursor);
1118 } 1137 }
1119 } 1138 }
1120} 1139}
1121 1140
1122 1141
1123/* 1142/*
1124 Place item in cell and take care that multiple items using the same cell do 1143 Place item in cell and take care that multiple items using the same cell do
1125 not overlap. This method is not yet optimal. It doesn´t use the maximum space 1144 not overlap. This method is not yet optimal. It doesn´t use the maximum space
1126 it can get in all cases. 1145 it can get in all cases.
1127 At the moment the method has a bug: When an item is placed only the sub cell 1146 At the moment the method has a bug: When an item is placed only the sub cell
1128 widths of the items are changed, which are within the Y region the item to 1147 widths of the items are changed, which are within the Y region the item to
1129 place spans. When the sub cell width change of one of this items affects a 1148 place spans. When the sub cell width change of one of this items affects a
1130 cell, where other items are, which do not overlap in Y with the item to place, 1149 cell, where other items are, which do not overlap in Y with the item to place,
1131 the display gets corrupted, although the corruption looks quite nice. 1150 the display gets corrupted, although the corruption looks quite nice.
1132*/ 1151*/
1133void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1152void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1134{ 1153{
1135 1154
1136 QPtrList<KOAgendaItem> conflictItems; 1155 QPtrList<KOAgendaItem> conflictItems;
1137 int maxSubCells = 0; 1156 int maxSubCells = 0;
1138 QIntDict<KOAgendaItem> subCellDict(7); 1157 QIntDict<KOAgendaItem> subCellDict(7);
1139 1158
1140 KOAgendaItem *item; 1159 KOAgendaItem *item;
1141 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1160 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1142 if (item != placeItem) { 1161 if (item != placeItem) {
1143 if (placeItem->cellX() <= item->cellXWidth() && 1162 if (placeItem->cellX() <= item->cellXWidth() &&
1144 placeItem->cellXWidth() >= item->cellX()) { 1163 placeItem->cellXWidth() >= item->cellX()) {
1145 if ((placeItem->cellYTop() <= item->cellYBottom()) && 1164 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
1146 (placeItem->cellYBottom() >= item->cellYTop())) { 1165 (placeItem->cellYBottom() >= item->cellYTop())) {
1147 conflictItems.append(item); 1166 conflictItems.append(item);
1148 if (item->subCells() > maxSubCells) 1167 if (item->subCells() > maxSubCells)
1149 maxSubCells = item->subCells(); 1168 maxSubCells = item->subCells();
1150 subCellDict.insert(item->subCell(),item); 1169 subCellDict.insert(item->subCell(),item);
1151 } 1170 }
1152 } 1171 }
1153 } 1172 }
1154 } 1173 }
1155 1174
1156 if (conflictItems.count() > 0) { 1175 if (conflictItems.count() > 0) {
1157 // Look for unused sub cell and insert item 1176 // Look for unused sub cell and insert item
1158 int i; 1177 int i;
1159 for(i=0;i<maxSubCells;++i) { 1178 for(i=0;i<maxSubCells;++i) {
1160 if (!subCellDict.find(i)) { 1179 if (!subCellDict.find(i)) {
1161 placeItem->setSubCell(i); 1180 placeItem->setSubCell(i);
1162 break; 1181 break;
1163 } 1182 }
1164 } 1183 }
1165 if (i == maxSubCells) { 1184 if (i == maxSubCells) {
1166 placeItem->setSubCell(maxSubCells); 1185 placeItem->setSubCell(maxSubCells);
1167 maxSubCells++; // add new item to number of sub cells 1186 maxSubCells++; // add new item to number of sub cells
1168 } 1187 }
1169 1188
1170 // Prepare for sub cell geometry adjustment 1189 // Prepare for sub cell geometry adjustment
1171 int newSubCellWidth; 1190 int newSubCellWidth;
1172 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1191 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1173 else newSubCellWidth = mGridSpacingX / maxSubCells; 1192 else newSubCellWidth = mGridSpacingX / maxSubCells;
1174 conflictItems.append(placeItem); 1193 conflictItems.append(placeItem);
1175 1194
1176 1195
1177 // Adjust sub cell geometry of all direct conflict items 1196 // Adjust sub cell geometry of all direct conflict items
1178 for ( item=conflictItems.first(); item != 0; 1197 for ( item=conflictItems.first(); item != 0;
1179 item=conflictItems.next() ) { 1198 item=conflictItems.next() ) {
1180 item->setSubCells(maxSubCells); 1199 item->setSubCells(maxSubCells);
1181 if (mAllDayMode) { 1200 if (mAllDayMode) {
1182 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1201 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1183 } else { 1202 } else {
1184 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1203 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1185 } 1204 }
1186 int x,y; 1205 int x,y;
1187 gridToContents(item->cellX(),item->cellYTop(),x,y); 1206 gridToContents(item->cellX(),item->cellYTop(),x,y);
1188 if (mAllDayMode) { 1207 if (mAllDayMode) {
1189 y += item->subCell() * newSubCellWidth; 1208 y += item->subCell() * newSubCellWidth;
1190 } else { 1209 } else {
1191 x += item->subCell() * newSubCellWidth; 1210 x += item->subCell() * newSubCellWidth;
1192 } 1211 }
1193 moveChild(item,x,y); 1212 moveChild(item,x,y);
1194 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1213 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1195 //item->updateItem(); 1214 //item->updateItem();
1196 } 1215 }
1197 // Adjust sub cell geometry of all conflict items of all conflict items 1216 // Adjust sub cell geometry of all conflict items of all conflict items
1198 for ( item=conflictItems.first(); item != 0; 1217 for ( item=conflictItems.first(); item != 0;
1199 item=conflictItems.next() ) { 1218 item=conflictItems.next() ) {
1200 if ( placeItem != item ) { 1219 if ( placeItem != item ) {
1201 KOAgendaItem *item2; 1220 KOAgendaItem *item2;
1202 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1221 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1203 for ( item2=conflictItems2.first(); item2 != 0; 1222 for ( item2=conflictItems2.first(); item2 != 0;
1204 item2=conflictItems2.next() ) { 1223 item2=conflictItems2.next() ) {
1205 if ( item2->subCells() != maxSubCells) { 1224 if ( item2->subCells() != maxSubCells) {
1206 item2->setSubCells(maxSubCells); 1225 item2->setSubCells(maxSubCells);
1207 if (mAllDayMode) { 1226 if (mAllDayMode) {
1208 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1227 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1209 } else { 1228 } else {
1210 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1229 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1211 } 1230 }
1212 int x,y; 1231 int x,y;
1213 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1232 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1214 if (mAllDayMode) { 1233 if (mAllDayMode) {
1215 y += item2->subCell() * newSubCellWidth; 1234 y += item2->subCell() * newSubCellWidth;
1216 } else { 1235 } else {
1217 x += item2->subCell() * newSubCellWidth; 1236 x += item2->subCell() * newSubCellWidth;
1218 } 1237 }
1219 moveChild(item2,x,y); 1238 moveChild(item2,x,y);
1220 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1239 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1221 } 1240 }
1222 } 1241 }
1223 } 1242 }
1224 } 1243 }
1225 } else { 1244 } else {
1226 placeItem->setSubCell(0); 1245 placeItem->setSubCell(0);
1227 placeItem->setSubCells(1); 1246 placeItem->setSubCells(1);
1228 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1247 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1229 else placeItem->resize(mGridSpacingX,placeItem->height()); 1248 else placeItem->resize(mGridSpacingX,placeItem->height());
1230 int x,y; 1249 int x,y;
1231 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1250 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1232 moveChild(placeItem,x,y); 1251 moveChild(placeItem,x,y);
1233 } 1252 }
1234 placeItem->setConflictItems(conflictItems); 1253 placeItem->setConflictItems(conflictItems);
1235 // for ( item=conflictItems.first(); item != 0; 1254 // for ( item=conflictItems.first(); item != 0;
1236// item=conflictItems.next() ) { 1255// item=conflictItems.next() ) {
1237// //item->updateItem(); 1256// //item->updateItem();
1238// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1257// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1239// } 1258// }
1240// placeItem->updateItem(); 1259// placeItem->updateItem();
1241} 1260}
1242 1261
1243void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1262void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1244{ 1263{
1245 if ( globalFlagBlockAgenda ) 1264 if ( globalFlagBlockAgenda )
1246 return; 1265 return;
1266
1267 if ( mInvalidPixmap ) {
1268 mInvalidPixmap = false;
1269 qDebug("InvalidPixmap ");
1270 QTimer::singleShot( 0, this, SIGNAL( updateViewSignal() ));
1271 return;
1272 }
1247 if ( ! mAllDayMode ) { 1273 if ( ! mAllDayMode ) {
1248 // currently not working for 1274 // currently not working for
1249 1275
1250 //qDebug("KOAgenda::drawContents "); 1276 //qDebug("KOAgenda::drawContents ");
1251 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1277 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1252 ;//drawContentsToPainter(); 1278 ;//drawContentsToPainter();
1253 1279
1254 QPaintDevice* pd = p->device(); 1280 QPaintDevice* pd = p->device();
1255 p->end(); 1281 p->end();
1256 int vx, vy; 1282 int vx, vy;
1257 int selectionX = KOGlobals::self()->reverseLayout() ? 1283 int selectionX = KOGlobals::self()->reverseLayout() ?
1258 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1284 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1259 mSelectionCellX * mGridSpacingX; 1285 mSelectionCellX * mGridSpacingX;
1260 contentsToViewport ( cx, cy, vx,vy); 1286 contentsToViewport ( cx, cy, vx,vy);
1261 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1287 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1262 1288
1263 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1289 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1264 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1290 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1265 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1291 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1266 1292
1267 int vxSel, vySel; 1293 int vxSel, vySel;
1268 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1294 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1269 int off = mSelectionHeight; 1295 int off = mSelectionHeight;
1270 if ( vySel < 0 ) 1296 if ( vySel < 0 )
1271 off += vySel; 1297 off += vySel;
1272 //qDebug("OFF %d %d %d", off,vySel, vy ); 1298 //qDebug("OFF %d %d %d", off,vySel, vy );
1273 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); 1299 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
1274 } else { 1300 } else {
1275 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1301 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1276 } 1302 }
1277 } 1303 }
1278 if ( mSelectionHeight > 0 ) { 1304 if ( mSelectionHeight > 0 ) {
1279 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1305 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1280 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1306 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1281 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1307 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1282 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1308 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1283 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1309 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1284 int hei = mSelectionHeight; 1310 int hei = mSelectionHeight;
1285 int offset = 0; 1311 int offset = 0;
1286 while ( hei > 0 ) { 1312 while ( hei > 0 ) {
1287 int p_hei = 5; 1313 int p_hei = 5;
1288 if ( hei < 5 ) p_hei = hei; 1314 if ( hei < 5 ) p_hei = hei;
1289 hei -= 5; 1315 hei -= 5;
1290 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1316 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1291 offset += 5; 1317 offset += 5;
1292 } 1318 }
1293 } 1319 }
1294 } 1320 }
1295 p->begin( pd ); 1321 p->begin( pd );
1296 } else { 1322 } else {
1297 1323
1298 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1324 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1299 ;//drawContentsToPainter(); 1325 ;//drawContentsToPainter();
1300 1326
1301 QPaintDevice* pd = p->device(); 1327 QPaintDevice* pd = p->device();
1302 p->end(); 1328 p->end();
1303 int vx, vy; 1329 int vx, vy;
1304 int selectionX = KOGlobals::self()->reverseLayout() ? 1330 int selectionX = KOGlobals::self()->reverseLayout() ?
1305 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1331 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1306 mSelectionCellX * mGridSpacingX; 1332 mSelectionCellX * mGridSpacingX;
1307 contentsToViewport ( cx, cy, vx,vy); 1333 contentsToViewport ( cx, cy, vx,vy);
1308 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1334 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1309 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1335 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1310 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1336 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1311 1337
1312 if ( mSelectionHeight > 0 ) { 1338 if ( mSelectionHeight > 0 ) {
1313 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1339 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1314 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1340 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1315 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1341 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1316 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1342 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1317 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1343 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1318 int hei = mSelectionHeight; 1344 int hei = mSelectionHeight;
1319 int offset = 0; 1345 int offset = 0;
1320 while ( hei > 0 ) { 1346 while ( hei > 0 ) {
1321 int p_hei = 5; 1347 int p_hei = 5;
1322 if ( hei < 5 ) p_hei = hei; 1348 if ( hei < 5 ) p_hei = hei;
1323 hei -= 5; 1349 hei -= 5;
1324 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1350 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1325 offset += 5; 1351 offset += 5;
1326 } 1352 }
1327 } 1353 }
1328 } 1354 }
1329 p->begin( pd ); 1355 p->begin( pd );
1330 } 1356 }
1331 1357
1332} 1358}
1333 1359
1334void KOAgenda::finishUpdate() 1360void KOAgenda::finishUpdate()
1335{ 1361{
1336 1362
1337 KOAgendaItem *item; 1363 KOAgendaItem *item;
1338 globalFlagBlockAgendaItemPaint = 1; 1364 globalFlagBlockAgendaItemPaint = 1;
1339 // 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 1365 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems
1340 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1366 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1341 if ( !item->checkLayout() ) { 1367 if ( !item->checkLayout() ) {
1342 //qDebug(" conflictitem found "); 1368 //qDebug(" conflictitem found ");
1343 int newSubCellWidth; 1369 int newSubCellWidth;
1344 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1370 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1345 else newSubCellWidth = mGridSpacingX / item->subCells(); 1371 else newSubCellWidth = mGridSpacingX / item->subCells();
1346 1372
1347 if (mAllDayMode) { 1373 if (mAllDayMode) {
1348 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1374 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1349 } else { 1375 } else {
1350 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1376 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1351 } 1377 }
1352 int x,y; 1378 int x,y;
1353 gridToContents(item->cellX(),item->cellYTop(),x,y); 1379 gridToContents(item->cellX(),item->cellYTop(),x,y);
1354 if (mAllDayMode) { 1380 if (mAllDayMode) {
1355 y += item->subCell() * newSubCellWidth; 1381 y += item->subCell() * newSubCellWidth;
1356 } else { 1382 } else {
1357 x += item->subCell() * newSubCellWidth; 1383 x += item->subCell() * newSubCellWidth;
1358 } 1384 }
1359 moveChild(item,x,y); 1385 moveChild(item,x,y);
1360 } 1386 }
1361 } 1387 }
1362 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1388 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1363 if ( !item->isVisible() ) 1389 if ( !item->isVisible() )
1364 item->show(); 1390 item->show();
1365 1391
1366 } 1392 }
1367 globalFlagBlockAgendaItemUpdate = 0; 1393 globalFlagBlockAgendaItemUpdate = 0;
1368 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1394 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1369 item->repaintMe( ); 1395 item->repaintMe( );
1370 } 1396 }
1371 globalFlagBlockAgendaItemUpdate = 1; 1397 globalFlagBlockAgendaItemUpdate = 1;
1372 qApp->processEvents(); 1398 qApp->processEvents();
1373 globalFlagBlockAgendaItemPaint = 0; 1399 globalFlagBlockAgendaItemPaint = 0;
1374 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1400 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1375 item->repaint( false ); 1401 item->repaint( false );
1376 } 1402 }
1377 1403
1378} 1404}
1379 1405
1380/* 1406/*
1381 Draw grid in the background of the agenda. 1407 Draw grid in the background of the agenda.
1382*/ 1408*/
1383void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1409void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1384{ 1410{
1385 1411
1386 1412
1387 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1413 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1388 return; 1414 return;
1389 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1415 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1390 return; 1416 return;
1391 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1417 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1392 if ( ch < 1 ) 1418 if ( ch < 1 )
1393 ch = 1; 1419 ch = 1;
1394 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1420 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1395 mPaintPixmap.resize( contentsWidth()+42, ch ); 1421 mPaintPixmap.resize( contentsWidth()+42, ch );
1396 } 1422 }
1397 mCurPixWid = contentsWidth(); 1423 mCurPixWid = contentsWidth();
1398 mCurPixHei = ch; 1424 mCurPixHei = ch;
1399 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { 1425 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) {
1400 mHighlightPixmap.resize( mGridSpacingX-1, 5 ); 1426 mHighlightPixmap.resize( mGridSpacingX-1, 5 );
1401 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1427 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1402 } 1428 }
1403 mPixPainter.begin( &mPaintPixmap) ; 1429 mPixPainter.begin( &mPaintPixmap) ;
1404 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1430 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1405 QPainter * p ; 1431 QPainter * p ;
1406 if (paint == 0) { 1432 if (paint == 0) {
1407 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1433 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1408 p = &mPixPainter; 1434 p = &mPixPainter;
1409 } 1435 }
1410 else 1436 else
1411 p = paint ; 1437 p = paint ;
1412 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1438 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1413 1439
1414 //--cx;++cw; 1440 //--cx;++cw;
1415 int lGridSpacingY = mGridSpacingY*2; 1441 int lGridSpacingY = mGridSpacingY*2;
1416 int selDay; 1442 int selDay;
1417 QDate curDate = QDate::currentDate(); 1443 QDate curDate = QDate::currentDate();
1418 if ( !backgroundOnly ) { 1444 if ( !backgroundOnly ) {
1419 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1445 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1420 { 1446 {
1421 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { 1447 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) {
1422 int x1 = cx; 1448 int x1 = cx;
1423 int y1 = 0; 1449 int y1 = 0;
1424 if (y1 < cy) y1 = cy; 1450 if (y1 < cy) y1 = cy;
1425 int x2 = cx+cw-1; 1451 int x2 = cx+cw-1;
1426 int y2 = contentsHeight(); 1452 int y2 = contentsHeight();
1427 if (y2 > cy+ch-1) y2=cy+ch-1; 1453 if (y2 > cy+ch-1) y2=cy+ch-1;
1428 if (x2 >= x1 && y2 >= y1) { 1454 if (x2 >= x1 && y2 >= y1) {
1429 int gxStart = selDay; 1455 int gxStart = selDay;
1430 int gxEnd = gxStart ; 1456 int gxEnd = gxStart ;
1431 int xStart = KOGlobals::self()->reverseLayout() ? 1457 int xStart = KOGlobals::self()->reverseLayout() ?
1432 (mColumns - 1 - gxStart)*mGridSpacingX : 1458 (mColumns - 1 - gxStart)*mGridSpacingX :
1433 gxStart*mGridSpacingX; 1459 gxStart*mGridSpacingX;
1434 if (xStart < x1) xStart = x1; 1460 if (xStart < x1) xStart = x1;
1435 int xEnd = KOGlobals::self()->reverseLayout() ? 1461 int xEnd = KOGlobals::self()->reverseLayout() ?
1436 (mColumns - gxStart)*mGridSpacingX-1 : 1462 (mColumns - gxStart)*mGridSpacingX-1 :
1437 (gxStart+1)*mGridSpacingX-1; 1463 (gxStart+1)*mGridSpacingX-1;
1438 if (xEnd > x2) xEnd = x2; 1464 if (xEnd > x2) xEnd = x2;
@@ -1727,391 +1753,391 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1727 globalFlagBlockAgendaItemUpdate = 1; 1753 globalFlagBlockAgendaItemUpdate = 1;
1728 item->repaint(); 1754 item->repaint();
1729} 1755}
1730/* 1756/*
1731 Insert KOAgendaItem into agenda. 1757 Insert KOAgendaItem into agenda.
1732*/ 1758*/
1733KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1759KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1734{ 1760{
1735 if (mAllDayMode) { 1761 if (mAllDayMode) {
1736 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); 1762 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. ");
1737 return 0; 1763 return 0;
1738 } 1764 }
1739 1765
1740 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1766 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1741 //agendaItem->setFrameStyle(WinPanel|Raised); 1767 //agendaItem->setFrameStyle(WinPanel|Raised);
1742 1768
1743 int YSize = YBottom - YTop + 1; 1769 int YSize = YBottom - YTop + 1;
1744 if (YSize < 0) { 1770 if (YSize < 0) {
1745 YSize = 1; 1771 YSize = 1;
1746 } 1772 }
1747 int iheight = mGridSpacingY * YSize; 1773 int iheight = mGridSpacingY * YSize;
1748 1774
1749 agendaItem->resize(mGridSpacingX,iheight ); 1775 agendaItem->resize(mGridSpacingX,iheight );
1750 agendaItem->setCellXY(X,YTop,YBottom); 1776 agendaItem->setCellXY(X,YTop,YBottom);
1751 agendaItem->setCellXWidth(X); 1777 agendaItem->setCellXWidth(X);
1752 1778
1753 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1779 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1754 mItems.append(agendaItem); 1780 mItems.append(agendaItem);
1755 1781
1756 placeSubCells(agendaItem); 1782 placeSubCells(agendaItem);
1757 1783
1758 //agendaItem->show(); 1784 //agendaItem->show();
1759 1785
1760 marcus_bains(); 1786 marcus_bains();
1761 1787
1762 return agendaItem; 1788 return agendaItem;
1763} 1789}
1764 1790
1765 1791
1766/* 1792/*
1767 Insert all-day KOAgendaItem into agenda. 1793 Insert all-day KOAgendaItem into agenda.
1768*/ 1794*/
1769KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1795KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1770{ 1796{
1771 if (!mAllDayMode) { 1797 if (!mAllDayMode) {
1772 return 0; 1798 return 0;
1773 } 1799 }
1774 1800
1775 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1801 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1776 1802
1777 agendaItem->setCellXY(XBegin,0,0); 1803 agendaItem->setCellXY(XBegin,0,0);
1778 agendaItem->setCellXWidth(XEnd); 1804 agendaItem->setCellXWidth(XEnd);
1779 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1805 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1780 1806
1781 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1807 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1782 mItems.append(agendaItem); 1808 mItems.append(agendaItem);
1783 1809
1784 placeSubCells(agendaItem); 1810 placeSubCells(agendaItem);
1785 1811
1786 //agendaItem->show(); 1812 //agendaItem->show();
1787 1813
1788 return agendaItem; 1814 return agendaItem;
1789} 1815}
1790 1816
1791 1817
1792void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1818void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1793 int YTop,int YBottom) 1819 int YTop,int YBottom)
1794{ 1820{
1795 if (mAllDayMode) { 1821 if (mAllDayMode) {
1796 ; 1822 ;
1797 return; 1823 return;
1798 } 1824 }
1799 1825
1800 int cellX,cellYTop,cellYBottom; 1826 int cellX,cellYTop,cellYBottom;
1801 QString newtext; 1827 QString newtext;
1802 int width = XEnd - XBegin + 1; 1828 int width = XEnd - XBegin + 1;
1803 int count = 0; 1829 int count = 0;
1804 KOAgendaItem *current = 0; 1830 KOAgendaItem *current = 0;
1805 QPtrList<KOAgendaItem> multiItems; 1831 QPtrList<KOAgendaItem> multiItems;
1806 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1832 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1807 if (cellX == XBegin) cellYTop = YTop; 1833 if (cellX == XBegin) cellYTop = YTop;
1808 else cellYTop = 0; 1834 else cellYTop = 0;
1809 if (cellX == XEnd) cellYBottom = YBottom; 1835 if (cellX == XEnd) cellYBottom = YBottom;
1810 else cellYBottom = rows() - 1; 1836 else cellYBottom = rows() - 1;
1811 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1837 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1812 newtext.append(event->summary()); 1838 newtext.append(event->summary());
1813 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1839 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1814 current->setText(newtext); 1840 current->setText(newtext);
1815 multiItems.append(current); 1841 multiItems.append(current);
1816 } 1842 }
1817 1843
1818 KOAgendaItem *next = 0; 1844 KOAgendaItem *next = 0;
1819 KOAgendaItem *last = multiItems.last(); 1845 KOAgendaItem *last = multiItems.last();
1820 KOAgendaItem *first = multiItems.first(); 1846 KOAgendaItem *first = multiItems.first();
1821 KOAgendaItem *setFirst,*setLast; 1847 KOAgendaItem *setFirst,*setLast;
1822 current = first; 1848 current = first;
1823 while (current) { 1849 while (current) {
1824 next = multiItems.next(); 1850 next = multiItems.next();
1825 if (current == first) setFirst = 0; 1851 if (current == first) setFirst = 0;
1826 else setFirst = first; 1852 else setFirst = first;
1827 if (current == last) setLast = 0; 1853 if (current == last) setLast = 0;
1828 else setLast = last; 1854 else setLast = last;
1829 1855
1830 current->setMultiItem(setFirst,next,setLast); 1856 current->setMultiItem(setFirst,next,setLast);
1831 current = next; 1857 current = next;
1832 } 1858 }
1833 1859
1834 marcus_bains(); 1860 marcus_bains();
1835} 1861}
1836 1862
1837 1863
1838//QSizePolicy KOAgenda::sizePolicy() const 1864//QSizePolicy KOAgenda::sizePolicy() const
1839//{ 1865//{
1840 // Thought this would make the all-day event agenda minimum size and the 1866 // Thought this would make the all-day event agenda minimum size and the
1841 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1867 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1842 // don´t seem to think that an Expanding widget needs more space than a 1868 // don´t seem to think that an Expanding widget needs more space than a
1843 // Preferred one. 1869 // Preferred one.
1844 // But it doesn´t hurt, so it stays. 1870 // But it doesn´t hurt, so it stays.
1845// if (mAllDayMode) { 1871// if (mAllDayMode) {
1846// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1872// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1847// } else { 1873// } else {
1848// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1874// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1849// } 1875// }
1850//} 1876//}
1851void KOAgenda::finishResize ( ) 1877void KOAgenda::finishResize ( )
1852{ 1878{
1853 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1879 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1854 if ( globalFlagBlockAgenda == 0 ) { 1880 if ( globalFlagBlockAgenda == 0 ) {
1855 finishUpdate(); 1881 finishUpdate();
1856 //qDebug("finishUpdate() called "); 1882 //qDebug("finishUpdate() called ");
1857 } 1883 }
1858} 1884}
1859/* 1885/*
1860 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1886 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1861*/ 1887*/
1862void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1888void KOAgenda::resizeEvent ( QResizeEvent *ev )
1863{ 1889{
1864 mSelectionHeight = 0; 1890 mSelectionHeight = 0;
1865 mResizeTimer.start( 150 , true ); 1891 mResizeTimer.start( 150 , true );
1866 computeSizes(); 1892 computeSizes();
1867 return; 1893 return;
1868 1894
1869} 1895}
1870void KOAgenda::computeSizes() 1896void KOAgenda::computeSizes()
1871{ 1897{
1872 if ( globalFlagBlockStartup ) 1898 if ( globalFlagBlockStartup )
1873 return; 1899 return;
1874 int frameOffset = frameWidth() * 2 +1; 1900 int frameOffset = frameWidth() * 2 +1;
1875 if (mAllDayMode) { 1901 if (mAllDayMode) {
1876 mGridSpacingX = (width()-frameOffset) / mColumns; 1902 mGridSpacingX = (width()-frameOffset) / mColumns;
1877 mGridSpacingY = height() - 2 * frameWidth() - 1; 1903 mGridSpacingY = height() - 2 * frameWidth() - 1;
1878 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1904 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1879 // mGridSpacingY = height(); 1905 // mGridSpacingY = height();
1880 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1906 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1881 1907
1882 KOAgendaItem *item; 1908 KOAgendaItem *item;
1883 int subCellWidth; 1909 int subCellWidth;
1884 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1910 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1885 subCellWidth = mGridSpacingY / item->subCells(); 1911 subCellWidth = mGridSpacingY / item->subCells();
1886 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1912 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1887 moveChild(item,KOGlobals::self()->reverseLayout() ? 1913 moveChild(item,KOGlobals::self()->reverseLayout() ?
1888 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1914 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1889 item->cellX() * mGridSpacingX, 1915 item->cellX() * mGridSpacingX,
1890 item->subCell() * subCellWidth); 1916 item->subCell() * subCellWidth);
1891 } 1917 }
1892 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1918 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1893 } else { 1919 } else {
1894 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; 1920 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns;
1895 if (height() > mGridSpacingY * mRows + 1 ) { 1921 if (height() > mGridSpacingY * mRows + 1 ) {
1896 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1922 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1897 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1923 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1898 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1924 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1899 emit resizedSignal(); 1925 emit resizedSignal();
1900 } else 1926 } else
1901 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1927 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1902 KOAgendaItem *item; 1928 KOAgendaItem *item;
1903 int subCellWidth; 1929 int subCellWidth;
1904 1930
1905 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1931 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1906 subCellWidth = mGridSpacingX / item->subCells(); 1932 subCellWidth = mGridSpacingX / item->subCells();
1907 item->resize(subCellWidth,item->height()); 1933 item->resize(subCellWidth,item->height());
1908 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1934 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1909 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1935 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1910 item->cellX() * mGridSpacingX) + 1936 item->cellX() * mGridSpacingX) +
1911 item->subCell() * subCellWidth,childY(item)); 1937 item->subCell() * subCellWidth,childY(item));
1912 } 1938 }
1913 } 1939 }
1914 int cw = contentsWidth(); 1940 int cw = contentsWidth();
1915 int ch = contentsHeight(); 1941 int ch = contentsHeight();
1916 if ( mAllDayMode ) { 1942 if ( mAllDayMode ) {
1917 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1943 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1918 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { 1944 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) {
1919 //qDebug("paintPixAll->resize "); 1945 qDebug("paintPixAll->resize ");
1920 paintPixAll->resize( cw, ch ); 1946 paintPixAll->resize( cw, ch );
1921 } 1947 }
1922 } else { 1948 } else {
1923 QPixmap* paintPix = KOAgendaItem::paintPix(); 1949 QPixmap* paintPix = KOAgendaItem::paintPix();
1924 if ( paintPix->width() < cw || paintPix->height() < ch ) { 1950 if ( paintPix->width() < cw || paintPix->height() < ch ) {
1925 //qDebug("paintPix->resize "); 1951 qDebug("paintPix->resize ");
1926 paintPix->resize( cw , ch ); 1952 paintPix->resize( cw , ch );
1927 } 1953 }
1928 } 1954 }
1929 1955
1930 checkScrollBoundaries(); 1956 checkScrollBoundaries();
1931 marcus_bains(); 1957 marcus_bains();
1932 drawContentsToPainter(); 1958 drawContentsToPainter();
1933 viewport()->repaint(false); 1959 viewport()->repaint(false);
1934} 1960}
1935 1961
1936void KOAgenda::scrollUp() 1962void KOAgenda::scrollUp()
1937{ 1963{
1938 scrollBy(0,-mScrollOffset); 1964 scrollBy(0,-mScrollOffset);
1939} 1965}
1940 1966
1941 1967
1942void KOAgenda::scrollDown() 1968void KOAgenda::scrollDown()
1943{ 1969{
1944 scrollBy(0,mScrollOffset); 1970 scrollBy(0,mScrollOffset);
1945} 1971}
1946 1972
1947void KOAgenda::popupAlarm() 1973void KOAgenda::popupAlarm()
1948{ 1974{
1949 if (!mClickedItem) { 1975 if (!mClickedItem) {
1950 qDebug("KOAgenda::popupAlarm() called without having a clicked item "); 1976 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
1951 return; 1977 return;
1952 } 1978 }
1953 // TODO: deal correctly with multiple alarms 1979 // TODO: deal correctly with multiple alarms
1954 Alarm* alarm; 1980 Alarm* alarm;
1955 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 1981 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1956 for(alarm=list.first();alarm;alarm=list.next()) { 1982 for(alarm=list.first();alarm;alarm=list.next()) {
1957 alarm->toggleAlarm(); 1983 alarm->toggleAlarm();
1958 } 1984 }
1959 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 1985 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
1960 mClickedItem->paintMe( true ); 1986 mClickedItem->paintMe( true );
1961 mClickedItem->repaint( false ); 1987 mClickedItem->repaint( false );
1962} 1988}
1963 1989
1964/* 1990/*
1965 Calculates the minimum width 1991 Calculates the minimum width
1966*/ 1992*/
1967int KOAgenda::minimumWidth() const 1993int KOAgenda::minimumWidth() const
1968{ 1994{
1969 // TODO:: develop a way to dynamically determine the minimum width 1995 // TODO:: develop a way to dynamically determine the minimum width
1970 int min = 100; 1996 int min = 100;
1971 1997
1972 return min; 1998 return min;
1973} 1999}
1974 2000
1975void KOAgenda::updateConfig() 2001void KOAgenda::updateConfig()
1976{ 2002{
1977 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 2003 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
1978 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 2004 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
1979 if ( mAllDayMode ) { 2005 if ( mAllDayMode ) {
1980 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 2006 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
1981 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 2007 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
1982 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 2008 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
1983 // setMaximumHeight( mGridSpacingY+1 ); 2009 // setMaximumHeight( mGridSpacingY+1 );
1984 viewport()->repaint( false ); 2010 viewport()->repaint( false );
1985 //setFixedHeight( mGridSpacingY+1 ); 2011 //setFixedHeight( mGridSpacingY+1 );
1986 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 2012 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
1987 } 2013 }
1988 else { 2014 else {
1989 mGridSpacingY = KOPrefs::instance()->mHourSize; 2015 mGridSpacingY = KOPrefs::instance()->mHourSize;
1990 calculateWorkingHours(); 2016 calculateWorkingHours();
1991 marcus_bains(); 2017 marcus_bains();
1992 } 2018 }
1993} 2019}
1994 2020
1995void KOAgenda::checkScrollBoundaries() 2021void KOAgenda::checkScrollBoundaries()
1996{ 2022{
1997 // Invalidate old values to force update 2023 // Invalidate old values to force update
1998 mOldLowerScrollValue = -1; 2024 mOldLowerScrollValue = -1;
1999 mOldUpperScrollValue = -1; 2025 mOldUpperScrollValue = -1;
2000 2026
2001 checkScrollBoundaries(verticalScrollBar()->value()); 2027 checkScrollBoundaries(verticalScrollBar()->value());
2002} 2028}
2003 2029
2004void KOAgenda::checkScrollBoundaries(int v) 2030void KOAgenda::checkScrollBoundaries(int v)
2005{ 2031{
2006 if ( mGridSpacingY == 0 ) 2032 if ( mGridSpacingY == 0 )
2007 return; 2033 return;
2008 int yMin = v/mGridSpacingY; 2034 int yMin = v/mGridSpacingY;
2009 int yMax = (v+visibleHeight())/mGridSpacingY; 2035 int yMax = (v+visibleHeight())/mGridSpacingY;
2010 2036
2011// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; 2037// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
2012 2038
2013 if (yMin != mOldLowerScrollValue) { 2039 if (yMin != mOldLowerScrollValue) {
2014 mOldLowerScrollValue = yMin; 2040 mOldLowerScrollValue = yMin;
2015 emit lowerYChanged(yMin); 2041 emit lowerYChanged(yMin);
2016 } 2042 }
2017 if (yMax != mOldUpperScrollValue) { 2043 if (yMax != mOldUpperScrollValue) {
2018 mOldUpperScrollValue = yMax; 2044 mOldUpperScrollValue = yMax;
2019 emit upperYChanged(yMax); 2045 emit upperYChanged(yMax);
2020 } 2046 }
2021} 2047}
2022 2048
2023void KOAgenda::deselectItem() 2049void KOAgenda::deselectItem()
2024{ 2050{
2025 if (mSelectedItem.isNull()) return; 2051 if (mSelectedItem.isNull()) return;
2026 mSelectedItem->select(false); 2052 mSelectedItem->select(false);
2027 mSelectedItem = 0; 2053 mSelectedItem = 0;
2028} 2054}
2029 2055
2030void KOAgenda::selectItem(KOAgendaItem *item) 2056void KOAgenda::selectItem(KOAgendaItem *item)
2031{ 2057{
2032 if ((KOAgendaItem *)mSelectedItem == item) return; 2058 if ((KOAgendaItem *)mSelectedItem == item) return;
2033 deselectItem(); 2059 deselectItem();
2034 if (item == 0) { 2060 if (item == 0) {
2035 emit incidenceSelected( 0 ); 2061 emit incidenceSelected( 0 );
2036 return; 2062 return;
2037 } 2063 }
2038 mSelectedItem = item; 2064 mSelectedItem = item;
2039 mSelectedItem->select(); 2065 mSelectedItem->select();
2040 emit incidenceSelected( mSelectedItem->incidence() ); 2066 emit incidenceSelected( mSelectedItem->incidence() );
2041} 2067}
2042 2068
2043// This function seems never be called. 2069// This function seems never be called.
2044void KOAgenda::keyPressEvent( QKeyEvent *kev ) 2070void KOAgenda::keyPressEvent( QKeyEvent *kev )
2045{ 2071{
2046 switch(kev->key()) { 2072 switch(kev->key()) {
2047 case Key_PageDown: 2073 case Key_PageDown:
2048 verticalScrollBar()->addPage(); 2074 verticalScrollBar()->addPage();
2049 break; 2075 break;
2050 case Key_PageUp: 2076 case Key_PageUp:
2051 verticalScrollBar()->subtractPage(); 2077 verticalScrollBar()->subtractPage();
2052 break; 2078 break;
2053 case Key_Down: 2079 case Key_Down:
2054 verticalScrollBar()->addLine(); 2080 verticalScrollBar()->addLine();
2055 break; 2081 break;
2056 case Key_Up: 2082 case Key_Up:
2057 verticalScrollBar()->subtractLine(); 2083 verticalScrollBar()->subtractLine();
2058 break; 2084 break;
2059 default: 2085 default:
2060 ; 2086 ;
2061 } 2087 }
2062} 2088}
2063 2089
2064void KOAgenda::calculateWorkingHours() 2090void KOAgenda::calculateWorkingHours()
2065{ 2091{
2066// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; 2092// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
2067 mWorkingHoursEnable = !mAllDayMode; 2093 mWorkingHoursEnable = !mAllDayMode;
2068 2094
2069 mWorkingHoursYTop = mGridSpacingY * 2095 mWorkingHoursYTop = mGridSpacingY *
2070 KOPrefs::instance()->mWorkingHoursStart * 4; 2096 KOPrefs::instance()->mWorkingHoursStart * 4;
2071 mWorkingHoursYBottom = mGridSpacingY * 2097 mWorkingHoursYBottom = mGridSpacingY *
2072 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; 2098 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
2073} 2099}
2074 2100
2075 2101
2076DateList KOAgenda::dateList() const 2102DateList KOAgenda::dateList() const
2077{ 2103{
2078 return mSelectedDates; 2104 return mSelectedDates;
2079} 2105}
2080 2106
2081void KOAgenda::setDateList(const DateList &selectedDates) 2107void KOAgenda::setDateList(const DateList &selectedDates)
2082{ 2108{
2083 mSelectedDates = selectedDates; 2109 mSelectedDates = selectedDates;
2084 marcus_bains(); 2110 marcus_bains();
2085} 2111}
2086 2112
2087void KOAgenda::setHolidayMask(QMemArray<bool> *mask) 2113void KOAgenda::setHolidayMask(QMemArray<bool> *mask)
2088{ 2114{
2089 mHolidayMask = mask; 2115 mHolidayMask = mask;
2090 2116
2091/* 2117/*
2092 kdDebug() << "HolidayMask: "; 2118 kdDebug() << "HolidayMask: ";
2093 for(uint i=0;i<mask->count();++i) { 2119 for(uint i=0;i<mask->count();++i) {
2094 kdDebug() << (mask->at(i) ? "*" : "o"); 2120 kdDebug() << (mask->at(i) ? "*" : "o");
2095 } 2121 }
2096 kdDebug() << endl; 2122 kdDebug() << endl;
2097*/ 2123*/
2098} 2124}
2099 2125
2100void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) 2126void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
2101{ 2127{
2102 2128
2103 QScrollView::contentsMousePressEvent(event); 2129 QScrollView::contentsMousePressEvent(event);
2104} 2130}
2105 2131
2106void KOAgenda::storePosition() 2132void KOAgenda::storePosition()
2107{ 2133{
2108 //mContentPosition 2134 //mContentPosition
2109 int max = mGridSpacingY*4*24; 2135 int max = mGridSpacingY*4*24;
2110 if ( contentsY() < 5 && max > viewport()->height()*3/2 ) 2136 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
2111 mContentPosition = 0; 2137 mContentPosition = 0;
2112 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) 2138 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2)
2113 mContentPosition = -1.0; 2139 mContentPosition = -1.0;
2114 else 2140 else
2115 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); 2141 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2)));
2116 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); 2142 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height());
2117 2143
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index de6acac..5d813b2 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -1,301 +1,305 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDA_H 23#ifndef KOAGENDA_H
24#define KOAGENDA_H 24#define KOAGENDA_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qmemarray.h> 28#include <qmemarray.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qpixmap.h> 30#include <qpixmap.h>
31#include <qguardedptr.h> 31#include <qguardedptr.h>
32 32
33#include "koagendaitem.h" 33#include "koagendaitem.h"
34#include "koeventview.h" 34#include "koeventview.h"
35 35
36class QPopupMenu; 36class QPopupMenu;
37class QTime; 37class QTime;
38class KConfig; 38class KConfig;
39class QFrame; 39class QFrame;
40class KOAgenda; 40class KOAgenda;
41class KCal::Event; 41class KCal::Event;
42class KCal::Todo; 42class KCal::Todo;
43 43
44using namespace KCal; 44using namespace KCal;
45 45
46class MarcusBains : public QFrame { 46class MarcusBains : public QFrame {
47 Q_OBJECT 47 Q_OBJECT
48 public: 48 public:
49 MarcusBains(KOAgenda *agenda=0,const char *name=0); 49 MarcusBains(KOAgenda *agenda=0,const char *name=0);
50 virtual ~MarcusBains(); 50 virtual ~MarcusBains();
51 51
52 public slots: 52 public slots:
53 void updateLocation(bool recalculate=false); 53 void updateLocation(bool recalculate=false);
54 void updateLoc(); 54 void updateLoc();
55 55
56 private: 56 private:
57 int todayColumn(); 57 int todayColumn();
58 QTimer *minutes; 58 QTimer *minutes;
59 QLabel *mTimeBox; 59 QLabel *mTimeBox;
60 KOAgenda *agenda; 60 KOAgenda *agenda;
61 QTime oldTime; 61 QTime oldTime;
62 int oldToday; 62 int oldToday;
63}; 63};
64 64
65 65
66class KOAgenda : public QScrollView 66class KOAgenda : public QScrollView
67{ 67{
68 Q_OBJECT 68 Q_OBJECT
69 public: 69 public:
70 enum MouseActionType { NOP, MOVE, SELECT, 70 enum MouseActionType { NOP, MOVE, SELECT,
71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
72 72
73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
74 const char * name=0, WFlags f=0 ); 74 const char * name=0, WFlags f=0 );
75 KOAgenda ( int columns, QWidget * parent=0, 75 KOAgenda ( int columns, QWidget * parent=0,
76 const char * name=0, WFlags f=0 ); 76 const char * name=0, WFlags f=0 );
77 virtual ~KOAgenda(); 77 virtual ~KOAgenda();
78 static bool mInvalidPixmap;
78 79
79 Incidence *selectedIncidence() const; 80 Incidence *selectedIncidence() const;
80 QDate selectedIncidenceDate() const; 81 QDate selectedIncidenceDate() const;
81 82
82 virtual bool eventFilter ( QObject *, QEvent * ); 83 virtual bool eventFilter ( QObject *, QEvent * );
83 84
84 void contentsToGrid (int x, int y, int& gx, int& gy); 85 void contentsToGrid (int x, int y, int& gx, int& gy);
85 void gridToContents (int gx, int gy, int& x, int& y); 86 void gridToContents (int gx, int gy, int& x, int& y);
86 87
87 int timeToY (const QTime &time); 88 int timeToY (const QTime &time);
88 QTime gyToTime (int y); 89 QTime gyToTime (int y);
89 90
90 void setStartHour(int startHour); 91 void setStartHour(int startHour);
91 92
92 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 93 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
93 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 94 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
94 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 95 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
95 int YTop,int YBottom); 96 int YTop,int YBottom);
96 97
97 void changeColumns(int columns); 98 void changeColumns(int columns);
98 99
99 int columns() { return mColumns; } 100 int columns() { return mColumns; }
100 int rows() { return mRows; } 101 int rows() { return mRows; }
101 102
102 int gridSpacingX() const { return mGridSpacingX; } 103 int gridSpacingX() const { return mGridSpacingX; }
103 int gridSpacingY() const { return mGridSpacingY; } 104 int gridSpacingY() const { return mGridSpacingY; }
104 105
105// virtual QSizePolicy sizePolicy() const; 106// virtual QSizePolicy sizePolicy() const;
106 107
107 void clear(); 108 void clear();
108 109
109 void clearSelection(); 110 void clearSelection();
110 void hideUnused(); 111 void hideUnused();
111 112
112 /** Calculates the minimum width */ 113 /** Calculates the minimum width */
113 virtual int minimumWidth() const; 114 virtual int minimumWidth() const;
114 /** Update configuration from preference settings */ 115 /** Update configuration from preference settings */
115 void updateConfig(); 116 void updateConfig();
116 117
117 void checkScrollBoundaries(); 118 void checkScrollBoundaries();
118 119
119 void setHolidayMask(QMemArray<bool> *); 120 void setHolidayMask(QMemArray<bool> *);
120 void setDateList(const DateList &selectedDates); 121 void setDateList(const DateList &selectedDates);
121 DateList dateList() const; 122 DateList dateList() const;
122 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 123 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
123 void finishUpdate(); 124 void finishUpdate();
124 void printSelection(); 125 void printSelection();
125 void storePosition(); 126 void storePosition();
126 void restorePosition(); 127 void restorePosition();
127 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } 128 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; }
129 void shrinkPixmap();
128 130
129 public slots: 131 public slots:
132 void slotContentMove(int,int);
130 void categoryChanged(Incidence * inc); 133 void categoryChanged(Incidence * inc);
131 void slotClearSelection(); 134 void slotClearSelection();
132 void popupMenu(); 135 void popupMenu();
133 void newItem( int ); 136 void newItem( int );
134 void moveChild( QWidget *, int, int ); 137 void moveChild( QWidget *, int, int );
135 void scrollUp(); 138 void scrollUp();
136 void scrollDown(); 139 void scrollDown();
137 void updateTodo( Todo * t, int , bool ); 140 void updateTodo( Todo * t, int , bool );
138 void popupAlarm(); 141 void popupAlarm();
139 142
140 void checkScrollBoundaries(int); 143 void checkScrollBoundaries(int);
141 144
142 /** Deselect selected items. This function does not emit any signals. */ 145 /** Deselect selected items. This function does not emit any signals. */
143 void deselectItem(); 146 void deselectItem();
144 /** Select item. If the argument is 0, the currently selected item gets 147 /** Select item. If the argument is 0, the currently selected item gets
145 deselected. This function emits the itemSelected(bool) signal to inform 148 deselected. This function emits the itemSelected(bool) signal to inform
146 about selection/deseelction of events. */ 149 about selection/deseelction of events. */
147 void selectItem(KOAgendaItem *); 150 void selectItem(KOAgendaItem *);
148 void finishResize(); 151 void finishResize();
149 152
150 signals: 153 signals:
151 void signalClearSelection(); 154 void signalClearSelection();
152 void showDateView( int, int); 155 void showDateView( int, int);
153 void newEventSignal(); 156 void newEventSignal();
154 void newEventSignal(int gx,int gy); 157 void newEventSignal(int gx,int gy);
155 void newTodoSignal(int gx,int gy); 158 void newTodoSignal(int gx,int gy);
156 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 159 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
157 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 160 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
158 void newStartSelectSignal(); 161 void newStartSelectSignal();
159 void showIncidenceSignal(Incidence *); 162 void showIncidenceSignal(Incidence *);
160 void editIncidenceSignal(Incidence *); 163 void editIncidenceSignal(Incidence *);
161 void deleteIncidenceSignal(Incidence *); 164 void deleteIncidenceSignal(Incidence *);
162 void showIncidencePopupSignal(Incidence *); 165 void showIncidencePopupSignal(Incidence *);
163 166
164 void itemModified(KOAgendaItem *item, int ); 167 void itemModified(KOAgendaItem *item, int );
165 void incidenceSelected(Incidence *); 168 void incidenceSelected(Incidence *);
166 169
167 void lowerYChanged(int); 170 void lowerYChanged(int);
168 void upperYChanged(int); 171 void upperYChanged(int);
169 172
170 void startDragSignal(Incidence *); 173 void startDragSignal(Incidence *);
171 void addToCalSignal(Incidence *, Incidence *); 174 void addToCalSignal(Incidence *, Incidence *);
172 void resizedSignal(); 175 void resizedSignal();
176 void updateViewSignal();
173 177
174 protected: 178 protected:
175 KOEventPopupMenu * mAllAgendaPopup; 179 KOEventPopupMenu * mAllAgendaPopup;
176 QPainter mPixPainter; 180 QPainter mPixPainter;
177 QPixmap mPaintPixmap; 181 QPixmap mPaintPixmap;
178 QPixmap mHighlightPixmap; 182 QPixmap mHighlightPixmap;
179 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 183 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
180 virtual void resizeEvent ( QResizeEvent * ); 184 virtual void resizeEvent ( QResizeEvent * );
181 185
182 /** Handles mouse events. Called from eventFilter */ 186 /** Handles mouse events. Called from eventFilter */
183 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 187 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
184 188
185 /** Start selecting time span. */ 189 /** Start selecting time span. */
186 void startSelectAction(QPoint viewportPos); 190 void startSelectAction(QPoint viewportPos);
187 191
188 /** Select time span. */ 192 /** Select time span. */
189 void performSelectAction(QPoint viewportPos); 193 void performSelectAction(QPoint viewportPos);
190 194
191 /** Emd selecting time span. */ 195 /** Emd selecting time span. */
192 void endSelectAction( bool emitNewEvent = false ); 196 void endSelectAction( bool emitNewEvent = false );
193 197
194 /** Start moving/resizing agenda item */ 198 /** Start moving/resizing agenda item */
195 void startItemAction(QPoint viewportPos); 199 void startItemAction(QPoint viewportPos);
196 200
197 /** Move/resize agenda item */ 201 /** Move/resize agenda item */
198 void performItemAction(QPoint viewportPos); 202 void performItemAction(QPoint viewportPos);
199 203
200 /** End moving/resizing agenda item */ 204 /** End moving/resizing agenda item */
201 void endItemAction(); 205 void endItemAction();
202 206
203 /** Set cursor, when no item action is in progress */ 207 /** Set cursor, when no item action is in progress */
204 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 208 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
205 209
206 /** Place agenda item in agenda and adjust other cells if necessary */ 210 /** Place agenda item in agenda and adjust other cells if necessary */
207 void placeSubCells(KOAgendaItem *placeItem); 211 void placeSubCells(KOAgendaItem *placeItem);
208 212
209 /** Process the keyevent, including the ignored keyevents of eventwidgets. 213 /** Process the keyevent, including the ignored keyevents of eventwidgets.
210 * Implements pgup/pgdn and cursor key navigation in the view. 214 * Implements pgup/pgdn and cursor key navigation in the view.
211 */ 215 */
212 void keyPressEvent( QKeyEvent * ); 216 void keyPressEvent( QKeyEvent * );
213 217
214 void calculateWorkingHours(); 218 void calculateWorkingHours();
215 219
216 virtual void contentsMousePressEvent ( QMouseEvent * ); 220 virtual void contentsMousePressEvent ( QMouseEvent * );
217 221
218 private: 222 private:
219 void init(); 223 void init();
220 void marcus_bains(); 224 void marcus_bains();
221 bool mAllDayMode; 225 bool mAllDayMode;
222 bool blockResize; 226 bool blockResize;
223 bool mLeftMouseDown; 227 bool mLeftMouseDown;
224 KOAgendaItem *mPopupItem; 228 KOAgendaItem *mPopupItem;
225 QTimer* mPopupTimer; 229 QTimer* mPopupTimer;
226 int mPopupKind; 230 int mPopupKind;
227 QPoint mPopupPos; 231 QPoint mPopupPos;
228 QTimer mResizeTimer; 232 QTimer mResizeTimer;
229 double mContentPosition; 233 double mContentPosition;
230 234
231 // Width and height of agenda cells 235 // Width and height of agenda cells
232 int mGridSpacingX; 236 int mGridSpacingX;
233 int mGridSpacingY; 237 int mGridSpacingY;
234 238
235 // size of border, where mouse action will resize the KOAgendaItem 239 // size of border, where mouse action will resize the KOAgendaItem
236 int mResizeBorderWidth; 240 int mResizeBorderWidth;
237 241
238 // size of border, where mouse mve will cause a scroll of the agenda 242 // size of border, where mouse mve will cause a scroll of the agenda
239 int mScrollBorderWidth; 243 int mScrollBorderWidth;
240 int mScrollDelay; 244 int mScrollDelay;
241 int mScrollOffset; 245 int mScrollOffset;
242 246
243 QTimer mScrollUpTimer; 247 QTimer mScrollUpTimer;
244 QTimer mScrollDownTimer; 248 QTimer mScrollDownTimer;
245 249
246 // Number of Columns/Rows of agenda grid 250 // Number of Columns/Rows of agenda grid
247 int mColumns; 251 int mColumns;
248 int mRows; 252 int mRows;
249 253
250 // Cells to store Move and Resize coordiantes 254 // Cells to store Move and Resize coordiantes
251 int mStartCellX; 255 int mStartCellX;
252 int mStartCellY; 256 int mStartCellY;
253 int mCurrentCellX; 257 int mCurrentCellX;
254 int mCurrentCellY; 258 int mCurrentCellY;
255 259
256 // Working Hour coordiantes 260 // Working Hour coordiantes
257 bool mWorkingHoursEnable; 261 bool mWorkingHoursEnable;
258 int mWorkingHoursYTop; 262 int mWorkingHoursYTop;
259 int mWorkingHoursYBottom; 263 int mWorkingHoursYBottom;
260 264
261 // Selection 265 // Selection
262 int mSelectionCellX; 266 int mSelectionCellX;
263 int mSelectionYTop; 267 int mSelectionYTop;
264 int mSelectionHeight; 268 int mSelectionHeight;
265 269
266 // List of dates to be displayed 270 // List of dates to be displayed
267 DateList mSelectedDates; 271 DateList mSelectedDates;
268 272
269 // The KOAgendaItem, which has been right-clicked last 273 // The KOAgendaItem, which has been right-clicked last
270 KOAgendaItem *mClickedItem; 274 KOAgendaItem *mClickedItem;
271 275
272 // The KOAgendaItem, which is being moved/resized 276 // The KOAgendaItem, which is being moved/resized
273 QGuardedPtr<KOAgendaItem> mActionItem; 277 QGuardedPtr<KOAgendaItem> mActionItem;
274 278
275 // Currently selected item 279 // Currently selected item
276 QGuardedPtr<KOAgendaItem> mSelectedItem; 280 QGuardedPtr<KOAgendaItem> mSelectedItem;
277 281
278 // The Marcus Bains Line widget. 282 // The Marcus Bains Line widget.
279 MarcusBains *mMarcusBains; 283 MarcusBains *mMarcusBains;
280 void computeSizes(); 284 void computeSizes();
281 285
282 MouseActionType mActionType; 286 MouseActionType mActionType;
283 287
284 bool mItemMoved; 288 bool mItemMoved;
285 289
286 // List of all Items contained in agenda 290 // List of all Items contained in agenda
287 QPtrList<KOAgendaItem> mItems; 291 QPtrList<KOAgendaItem> mItems;
288 QPtrList<KOAgendaItem> mUnusedItems; 292 QPtrList<KOAgendaItem> mUnusedItems;
289 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); 293 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport);
290 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems 294 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems
291 QPopupMenu *mNewItemPopup; 295 QPopupMenu *mNewItemPopup;
292 296
293 int mOldLowerScrollValue; 297 int mOldLowerScrollValue;
294 int mOldUpperScrollValue; 298 int mOldUpperScrollValue;
295 KOAgendaItem * getItemForTodo ( Todo * todo ); 299 KOAgendaItem * getItemForTodo ( Todo * todo );
296 QMemArray<bool> *mHolidayMask; 300 QMemArray<bool> *mHolidayMask;
297 int mCurPixWid; 301 int mCurPixWid;
298 int mCurPixHei; 302 int mCurPixHei;
299}; 303};
300 304
301#endif // KOAGENDA_H 305#endif // KOAGENDA_H
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 8675ff6..303a92a 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -307,396 +307,393 @@ void KOAgendaItem::select(bool selected)
307 } 307 }
308 } 308 }
309 globalFlagBlockAgendaItemUpdate = 0; 309 globalFlagBlockAgendaItemUpdate = 0;
310 paintMe( selected ); 310 paintMe( selected );
311 globalFlagBlockAgendaItemUpdate = 1; 311 globalFlagBlockAgendaItemUpdate = 1;
312 repaint( false ); 312 repaint( false );
313} 313}
314 314
315 315
316/* 316/*
317 The eventFilter has to filter the mouse events of the agenda item childs. The 317 The eventFilter has to filter the mouse events of the agenda item childs. The
318 events are fed into the event handling method of KOAgendaItem. This allows the 318 events are fed into the event handling method of KOAgendaItem. This allows the
319 KOAgenda to handle the KOAgendaItems by using an eventFilter. 319 KOAgenda to handle the KOAgendaItems by using an eventFilter.
320*/ 320*/
321bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 321bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
322{ 322{
323 if (e->type() == QEvent::MouseButtonPress || 323 if (e->type() == QEvent::MouseButtonPress ||
324 e->type() == QEvent::MouseButtonDblClick || 324 e->type() == QEvent::MouseButtonDblClick ||
325 e->type() == QEvent::MouseButtonRelease || 325 e->type() == QEvent::MouseButtonRelease ||
326 e->type() == QEvent::MouseMove) { 326 e->type() == QEvent::MouseMove) {
327 QMouseEvent *me = (QMouseEvent *)e; 327 QMouseEvent *me = (QMouseEvent *)e;
328 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 328 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
329 mapToGlobal(me->pos())); 329 mapToGlobal(me->pos()));
330 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 330 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
331 return event(&returnEvent); 331 return event(&returnEvent);
332 } else { 332 } else {
333 return false; 333 return false;
334 } 334 }
335} 335}
336void KOAgendaItem::repaintMe( ) 336void KOAgendaItem::repaintMe( )
337{ 337{
338 paintMe ( mSelected ); 338 paintMe ( mSelected );
339} 339}
340void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 340void KOAgendaItem::paintMe( bool selected, QPainter* paint )
341{ 341{
342 if ( globalFlagBlockAgendaItemUpdate && ! selected) 342 if ( globalFlagBlockAgendaItemUpdate && ! selected)
343 return; 343 return;
344 QPainter pa; 344 QPainter pa;
345 345
346 if ( mSelected ) { 346 if ( mSelected ) {
347 pa.begin( this ); 347 pa.begin( this );
348 } else { 348 } else {
349 if ( mAllDay ) 349 if ( mAllDay )
350 pa.begin( paintPixAllday() ); 350 pa.begin( paintPixAllday() );
351 else 351 else
352 pa.begin( paintPix() ); 352 pa.begin( paintPix() );
353 } 353 }
354 int x, yy, w, h; 354 int x, yy, w, h;
355 float nfh = 7.0; 355 float nfh = 7.0;
356 x = pos().x(); w = width(); h = height (); 356 x = pos().x(); w = width(); h = height ();
357 if ( mAllDay ) 357 if ( mAllDay )
358 yy = y(); 358 yy = y();
359 else 359 else
360 yy = mCellYTop * ( height() / cellHeight() ); 360 yy = mCellYTop * ( height() / cellHeight() );
361 if ( mSelected ) { 361 if ( mSelected ) {
362 pa.translate( -x, -yy ); 362 pa.translate( -x, -yy );
363 } 363 }
364 xPaintCoord= x; 364 xPaintCoord= x;
365 yPaintCoord = yy; 365 yPaintCoord = yy;
366 wPaintCoord = width(); 366 wPaintCoord = width();
367 hPaintCoord = height(); 367 hPaintCoord = height();
368 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 368 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
369 if ( paint == 0 ) 369 if ( paint == 0 )
370 paint = &pa; 370 paint = &pa;
371 bool horLayout = ( w < h ); 371 bool horLayout = ( w < h );
372 int maxhei = mFontPixelSize+4; 372 int maxhei = mFontPixelSize+4;
373 if ( horLayout ) 373 if ( horLayout )
374 maxhei += AGENDA_ICON_SIZE -4; 374 maxhei += AGENDA_ICON_SIZE -4;
375 bool small = ( h < maxhei ); 375 bool small = ( h < maxhei );
376 if ( ! small ) 376 if ( ! small )
377 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 377 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
378 else { 378 else {
379 QFont f = KOPrefs::instance()->mAgendaViewFont; 379 QFont f = KOPrefs::instance()->mAgendaViewFont;
380 f.setBold( false ); 380 f.setBold( false );
381 int fh = f.pointSize(); 381 int fh = f.pointSize();
382 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 382 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
383 if ( nfh < 6 ) 383 if ( nfh < 6 )
384 nfh = 6; 384 nfh = 6;
385 f.setPointSize( nfh ); 385 f.setPointSize( nfh );
386 paint->setFont(f); 386 paint->setFont(f);
387 } 387 }
388 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 388 paint->fillRect ( x, yy, w, h, mBackgroundColor );
389 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 389 static const QPixmap completedPxmp = SmallIcon("greenhook16");
390 static const QPixmap overduePxmp = SmallIcon("redcross16"); 390 static const QPixmap overduePxmp = SmallIcon("redcross16");
391 if ( mIncidence->typeID() == todoID ) { 391 if ( mIncidence->typeID() == todoID ) {
392 Todo* tempTodo = static_cast<Todo*>(mIncidence); 392 Todo* tempTodo = static_cast<Todo*>(mIncidence);
393 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 393 int xx = pos().x()+(width()-completedPxmp.width()-3 );
394 int yyy = yy+3; 394 int yyy = yy+3;
395 if ( tempTodo->isCompleted() ) 395 if ( tempTodo->isCompleted() )
396 paint->drawPixmap ( xx, yyy, completedPxmp ); 396 paint->drawPixmap ( xx, yyy, completedPxmp );
397 else { 397 else {
398 paint->drawPixmap ( xx, yyy, overduePxmp ); 398 paint->drawPixmap ( xx, yyy, overduePxmp );
399 399
400 } 400 }
401 } 401 }
402 bool addIcon = false; 402 bool addIcon = false;
403 if ( ! small || w > 3 * h || h > 3* w ) 403 if ( ! small || w > 3 * h || h > 3* w )
404 addIcon = updateIcons( paint, horLayout ); 404 addIcon = updateIcons( paint, horLayout );
405 405
406 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 406 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
407 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); 407 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0);
408 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 408 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
409 if ( ! small ) { 409 if ( ! small ) {
410 x += 3; yy += 3;w -= 6; h-= 5; 410 x += 3; yy += 3;w -= 6; h-= 5;
411 } else { 411 } else {
412 x += 2; yy += 1;w -= 4; h-= 4; 412 x += 2; yy += 1;w -= 4; h-= 4;
413 if ( nfh < 6.01 ) { 413 if ( nfh < 6.01 ) {
414 yy -= 2; 414 yy -= 2;
415 h += 4; 415 h += 4;
416 } 416 }
417 else 417 else
418 if ( nfh < h -2 ) 418 if ( nfh < h -2 )
419 ++yy; 419 ++yy;
420 } 420 }
421 int align; 421 int align;
422#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
423 align = ( AlignLeft|WordBreak|AlignTop); 423 align = ( AlignLeft|WordBreak|AlignTop);
424#else 424#else
425 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 425 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
426#endif 426#endif
427 if ( addIcon ) { 427 if ( addIcon ) {
428 if ( ! horLayout ) { 428 if ( ! horLayout ) {
429 x += AGENDA_ICON_SIZE+3; 429 x += AGENDA_ICON_SIZE+3;
430 w -= (AGENDA_ICON_SIZE+3); 430 w -= (AGENDA_ICON_SIZE+3);
431 } 431 }
432 else { 432 else {
433 yy+= AGENDA_ICON_SIZE+2; 433 yy+= AGENDA_ICON_SIZE+2;
434 h -=(AGENDA_ICON_SIZE+3); 434 h -=(AGENDA_ICON_SIZE+3);
435 } 435 }
436 } 436 }
437 if ( mWhiteText ) 437 if ( mWhiteText )
438 paint->setPen ( white); 438 paint->setPen ( white);
439 if ( x < 0 ) { 439 if ( x < 0 ) {
440 w = w+x-3; 440 w = w+x-3;
441 x = 3; 441 x = 3;
442 if ( !horLayout && addIcon ) 442 if ( !horLayout && addIcon )
443 x += AGENDA_ICON_SIZE+3; 443 x += AGENDA_ICON_SIZE+3;
444 if ( w > parentWidget()->width() ){ 444 if ( w > parentWidget()->width() ){
445 w = parentWidget()->width() - 6; 445 w = parentWidget()->width() - 6;
446#ifndef DESKTOP_VERSION 446#ifndef DESKTOP_VERSION
447 align = ( AlignHCenter|WordBreak|AlignTop); 447 align = ( AlignHCenter|WordBreak|AlignTop);
448#else 448#else
449 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 449 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
450#endif 450#endif
451 451
452 } 452 }
453 } 453 }
454 QRect dr; 454 QRect dr;
455 if ( w + x > parentWidget()->width() ) 455 if ( w + x > parentWidget()->width() )
456 w = parentWidget()->width()-x; 456 w = parentWidget()->width()-x;
457 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 457 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
458 //qDebug("%d %d %d %d ", x, yy, w, h ); 458 //qDebug("%d %d %d %d ", x, yy, w, h );
459 if ( mIncidence->cancelled() ){ 459 if ( mIncidence->cancelled() ){
460 460
461 461
462 small = ( height() < 20 ); 462 small = ( height() < 20 );
463 463
464 if ( ! small ) { 464 if ( ! small ) {
465 QFontMetrics fm ( paint->font() ); 465 QFontMetrics fm ( paint->font() );
466 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 466 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
467 } 467 }
468 468
469 } 469 }
470 pa.end(); 470 pa.end();
471 471
472} 472}
473 473
474QPixmap * KOAgendaItem::paintPix() 474QPixmap * KOAgendaItem::paintPix()
475{ 475{
476 static QPixmap* mPaintPix = 0; 476 static QPixmap* mPaintPix = 0;
477 if ( ! mPaintPix ) { 477 if ( ! mPaintPix ) {
478 int w = QApplication::desktop()->width(); 478 int w = QApplication::desktop()->width();
479 int h = QApplication::desktop()->height(); 479 int h = QApplication::desktop()->height();
480 mPaintPix = new QPixmap(w,h); 480 mPaintPix = new QPixmap(w,h);
481 } 481 }
482 return mPaintPix ; 482 return mPaintPix ;
483} 483}
484QPixmap * KOAgendaItem::paintPixAllday() 484QPixmap * KOAgendaItem::paintPixAllday()
485{ 485{
486 static QPixmap* mPaintPixA = 0; 486 static QPixmap* mPaintPixA = 0;
487 if ( ! mPaintPixA ) { 487 if ( ! mPaintPixA ) {
488 int w = QApplication::desktop()->width(); 488 int w = QApplication::desktop()->width();
489 int h = QApplication::desktop()->height()/5; 489 int h = QApplication::desktop()->height()/5;
490 mPaintPixA = new QPixmap(w,h); 490 mPaintPixA = new QPixmap(w,h);
491 } 491 }
492 return mPaintPixA ; 492 return mPaintPixA ;
493} 493}
494 494
495void KOAgendaItem::repaintItem() 495void KOAgendaItem::repaintItem()
496{ 496{
497 globalFlagBlockAgendaItemPaint = 0; 497 globalFlagBlockAgendaItemPaint = 0;
498 globalFlagBlockAgenda = 0; 498 globalFlagBlockAgenda = 0;
499 //qDebug("AAA ");
500 repaint( false ); 499 repaint( false );
501 //qDebug("BBB ");
502} 500}
503void KOAgendaItem::paintEvent ( QPaintEvent *e ) 501void KOAgendaItem::paintEvent ( QPaintEvent *e )
504{ 502{
505 qDebug("CCC "); 503
506 if ( globalFlagBlockAgendaItemPaint ) 504 if ( globalFlagBlockAgendaItemPaint )
507 return; 505 return;
508 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 506 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
509 return; 507 return;
510 qDebug("DDD ");
511 int yy; 508 int yy;
512 if ( mAllDay ) 509 if ( mAllDay )
513 yy = y(); 510 yy = y();
514 else 511 else
515 yy = mCellYTop * ( height() / cellHeight() ); 512 yy = mCellYTop * ( height() / cellHeight() );
516 int xx = x(); 513 int xx = x();
517 514
518 if ( xPaintCoord != xx || yPaintCoord != yy || 515 if ( xPaintCoord != xx || yPaintCoord != yy ||
519 wPaintCoord != width() || hPaintCoord != height()) { 516 wPaintCoord != width() || hPaintCoord != height()) {
520 xPaintCoord= xx; 517 xPaintCoord= xx;
521 yPaintCoord = yy; 518 yPaintCoord = yy;
522 wPaintCoord = width(); 519 wPaintCoord = width();
523 hPaintCoord = height(); 520 hPaintCoord = height();
524 globalFlagBlockAgendaItemUpdate = 0; 521 globalFlagBlockAgendaItemUpdate = 0;
525 paintMe( mSelected ); 522 paintMe( mSelected );
526 //qDebug("calling paintMe "); 523 //qDebug("calling paintMe ");
527 globalFlagBlockAgendaItemUpdate = 1; 524 globalFlagBlockAgendaItemUpdate = 1;
528 if ( mSelected ) 525 if ( mSelected )
529 return; 526 return;
530 } 527 }
531 int rx, ry, rw, rh; 528 int rx, ry, rw, rh;
532 rx = e->rect().x(); 529 rx = e->rect().x();
533 ry = e->rect().y(); 530 ry = e->rect().y();
534 rw = e->rect().width(); 531 rw = e->rect().width();
535 rh = e->rect().height(); 532 rh = e->rect().height();
536 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 533 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
537 534
538 QPixmap* paintFrom ; 535 QPixmap* paintFrom ;
539 if ( mSelected ) { 536 if ( mSelected ) {
540 paintMe( mSelected ); 537 paintMe( mSelected );
541 return; 538 return;
542 } else { 539 } else {
543 if ( mAllDay ) 540 if ( mAllDay )
544 paintFrom = paintPixAllday(); 541 paintFrom = paintPixAllday();
545 else 542 else
546 paintFrom = paintPix(); 543 paintFrom = paintPix();
547 } 544 }
548 xx += rx; 545 xx += rx;
549 546
550 if ( xx < 0 ) { 547 if ( xx < 0 ) {
551 rw = rw + xx; 548 rw = rw + xx;
552 rx -= xx; 549 rx -= xx;
553 xx = 0; 550 xx = 0;
554 if ( rw <= 1 ) { 551 if ( rw <= 1 ) {
555 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 552 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
556 return; 553 return;
557 } 554 }
558 } 555 }
559 if ( paintFrom->width() < xx+rw ) { 556 if ( paintFrom->width() < xx+rw ) {
560 rw = paintFrom->width() - xx; 557 rw = paintFrom->width() - xx;
561 if ( rw <= 1 ) { 558 if ( rw <= 1 ) {
562 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 559 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
563 return; 560 return;
564 } 561 }
565 } 562 }
566 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 563 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
567 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 564 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
568} 565}
569void KOAgendaItem::computeText() 566void KOAgendaItem::computeText()
570{ 567{
571 mDisplayedText = mIncidence->summary(); 568 mDisplayedText = mIncidence->summary();
572 if ( (mIncidence->typeID() == todoID ) ) { 569 if ( (mIncidence->typeID() == todoID ) ) {
573 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 570 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
574 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 571 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
575 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 572 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
576 else if ( !(mIncidence->doesFloat())) 573 else if ( !(mIncidence->doesFloat()))
577 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 574 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
578 } 575 }
579 } else { 576 } else {
580 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 577 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
581 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 578 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
582 579
583 if ( mAllDay ) { 580 if ( mAllDay ) {
584 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 581 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
585 if ( mIncidence->doesRecur() ) { 582 if ( mIncidence->doesRecur() ) {
586 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; 583 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
587 } else { 584 } else {
588 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 585 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
589 } 586 }
590 } 587 }
591 } 588 }
592 } 589 }
593 590
594 if ( !mIncidence->location().isEmpty() ) { 591 if ( !mIncidence->location().isEmpty() ) {
595 if ( mAllDay ) 592 if ( mAllDay )
596 mDisplayedText += " ("; 593 mDisplayedText += " (";
597 else 594 else
598 mDisplayedText += "\n("; 595 mDisplayedText += "\n(";
599 mDisplayedText += mIncidence->location() +")"; 596 mDisplayedText += mIncidence->location() +")";
600 } 597 }
601#ifdef DESKTOP_VERSION 598#ifdef DESKTOP_VERSION
602 QString tipText = mIncidence->summary(); 599 QString tipText = mIncidence->summary();
603 if ( !mIncidence->doesFloat() ) { 600 if ( !mIncidence->doesFloat() ) {
604 if ( mIncidence->typeID() == eventID ) { 601 if ( mIncidence->typeID() == eventID ) {
605 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 602 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
606 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 603 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
607 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 604 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
608 } 605 }
609 else { 606 else {
610 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 607 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
611 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 608 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
612 } 609 }
613 } 610 }
614 else if ( mIncidence->typeID() == todoID ) { 611 else if ( mIncidence->typeID() == todoID ) {
615 if (mIncidence->hasStartDate()) 612 if (mIncidence->hasStartDate())
616 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 613 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
617 if (((Todo*)mIncidence)->hasDueDate()) 614 if (((Todo*)mIncidence)->hasDueDate())
618 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 615 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
619 } 616 }
620 } else if ( mIncidence->typeID() == todoID ) { 617 } else if ( mIncidence->typeID() == todoID ) {
621 if (mIncidence->hasStartDate()) 618 if (mIncidence->hasStartDate())
622 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 619 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
623 if (((Todo*)mIncidence)->hasDueDate()) 620 if (((Todo*)mIncidence)->hasDueDate())
624 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 621 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
625 } 622 }
626 623
627 if (!mIncidence->location().isEmpty()) { 624 if (!mIncidence->location().isEmpty()) {
628 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 625 tipText += "\n"+i18n("Location: ")+mIncidence->location();
629 } 626 }
630 QToolTip::add(this,tipText,toolTipGroup(),""); 627 QToolTip::add(this,tipText,toolTipGroup(),"");
631#endif 628#endif
632} 629}
633void KOAgendaItem::updateItem() 630void KOAgendaItem::updateItem()
634{ 631{
635 computeText(); 632 computeText();
636 633
637 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 634 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
638 paintMe( mSelected ); 635 paintMe( mSelected );
639 repaint( false); 636 repaint( false);
640} 637}
641 638
642void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 639void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
643{ 640{
644 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 641 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
645 paintMe( mSelected ); 642 paintMe( mSelected );
646 repaint( false ); 643 repaint( false );
647} 644}
648 645
649/* 646/*
650 Return height of item in units of agenda cells 647 Return height of item in units of agenda cells
651*/ 648*/
652int KOAgendaItem::cellHeight() 649int KOAgendaItem::cellHeight()
653{ 650{
654 int ret = mCellYBottom - mCellYTop + 1; 651 int ret = mCellYBottom - mCellYTop + 1;
655 if ( ret <= 0 ) { 652 if ( ret <= 0 ) {
656 ret = 1; 653 ret = 1;
657 mCellYBottom = 0; 654 mCellYBottom = 0;
658 mCellYTop = 0; 655 mCellYTop = 0;
659 } 656 }
660 return ret; 657 return ret;
661} 658}
662 659
663/* 660/*
664 Return height of item in units of agenda cells 661 Return height of item in units of agenda cells
665*/ 662*/
666int KOAgendaItem::cellWidth() 663int KOAgendaItem::cellWidth()
667{ 664{
668 return mCellXWidth - mCellX + 1; 665 return mCellXWidth - mCellX + 1;
669} 666}
670 667
671void KOAgendaItem::setItemDate(QDate qd) 668void KOAgendaItem::setItemDate(QDate qd)
672{ 669{
673 mDate = qd; 670 mDate = qd;
674} 671}
675 672
676void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 673void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
677{ 674{
678 mCellX = X; 675 mCellX = X;
679 mCellYTop = YTop; 676 mCellYTop = YTop;
680 mCellYBottom = YBottom; 677 mCellYBottom = YBottom;
681} 678}
682 679
683void KOAgendaItem::setCellXWidth(int xwidth) 680void KOAgendaItem::setCellXWidth(int xwidth)
684{ 681{
685 mCellXWidth = xwidth; 682 mCellXWidth = xwidth;
686} 683}
687 684
688void KOAgendaItem::setCellX(int XLeft, int XRight) 685void KOAgendaItem::setCellX(int XLeft, int XRight)
689{ 686{
690 mCellX = XLeft; 687 mCellX = XLeft;
691 mCellXWidth = XRight; 688 mCellXWidth = XRight;
692} 689}
693 690
694void KOAgendaItem::setCellY(int YTop, int YBottom) 691void KOAgendaItem::setCellY(int YTop, int YBottom)
695{ 692{
696 mCellYTop = YTop; 693 mCellYTop = YTop;
697 mCellYBottom = YBottom; 694 mCellYBottom = YBottom;
698} 695}
699 696
700void KOAgendaItem::setSubCell(int subCell) 697void KOAgendaItem::setSubCell(int subCell)
701{ 698{
702 mSubCell = subCell; 699 mSubCell = subCell;
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index f811fba..488d9d4 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,271 +1,271 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79#define IDLETIMEOUT 3
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 myPix.resize( 1, 1 ); 84 myPix.resize( 1, 1 );
85 mRows = rows; 85 mRows = rows;
86 86
87 mRedrawNeeded = true; 87 mRedrawNeeded = true;
88 setMinimumHeight( 20 ); 88 setMinimumHeight( 20 );
89 mCellHeight = KOPrefs::instance()->mHourSize*4; 89 mCellHeight = KOPrefs::instance()->mHourSize*4;
90 90
91 enableClipper(true); 91 enableClipper(true);
92 92
93 setHScrollBarMode(AlwaysOff); 93 setHScrollBarMode(AlwaysOff);
94 setVScrollBarMode(AlwaysOff); 94 setVScrollBarMode(AlwaysOff);
95 95
96 resizeContents(50,mRows * mCellHeight); 96 resizeContents(50,mRows * mCellHeight);
97 97
98 viewport()->setBackgroundMode( PaletteBackground ); 98 viewport()->setBackgroundMode( PaletteBackground );
99} 99}
100 100
101void TimeLabels::setCellHeight(int height) 101void TimeLabels::setCellHeight(int height)
102{ 102{
103 mCellHeight = height; 103 mCellHeight = height;
104} 104}
105 105
106/* 106/*
107 Optimization so that only the "dirty" portion of the scroll view 107 Optimization so that only the "dirty" portion of the scroll view
108 is redrawn. Unfortunately, this is not called by default paintEvent() method. 108 is redrawn. Unfortunately, this is not called by default paintEvent() method.
109*/ 109*/
110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 111{
112 112
113 cx = contentsX() + frameWidth()*2; 113 cx = contentsX() + frameWidth()*2;
114 cw = contentsWidth() ; 114 cw = contentsWidth() ;
115 // end of workaround 115 // end of workaround
116 116
117 int cell = ((int)(cy/mCellHeight)); 117 int cell = ((int)(cy/mCellHeight));
118 int y = cell * mCellHeight; 118 int y = cell * mCellHeight;
119 QFontMetrics fm = fontMetrics(); 119 QFontMetrics fm = fontMetrics();
120 QString hour; 120 QString hour;
121 QString suffix = "am"; 121 QString suffix = "am";
122 int timeHeight = fm.ascent(); 122 int timeHeight = fm.ascent();
123 QFont nFont = font(); 123 QFont nFont = font();
124 p->setFont( font()); 124 p->setFont( font());
125 125
126 if (!KGlobal::locale()->use12Clock()) { 126 if (!KGlobal::locale()->use12Clock()) {
127 suffix = "00"; 127 suffix = "00";
128 } else 128 } else
129 if (cell > 11) suffix = "pm"; 129 if (cell > 11) suffix = "pm";
130 130
131 if ( timeHeight > mCellHeight ) { 131 if ( timeHeight > mCellHeight ) {
132 timeHeight = mCellHeight-1; 132 timeHeight = mCellHeight-1;
133 int pointS = nFont.pointSize(); 133 int pointS = nFont.pointSize();
134 while ( pointS > 4 ) { 134 while ( pointS > 4 ) {
135 nFont.setPointSize( pointS ); 135 nFont.setPointSize( pointS );
136 fm = QFontMetrics( nFont ); 136 fm = QFontMetrics( nFont );
137 if ( fm.ascent() < mCellHeight ) 137 if ( fm.ascent() < mCellHeight )
138 break; 138 break;
139 -- pointS; 139 -- pointS;
140 } 140 }
141 fm = QFontMetrics( nFont ); 141 fm = QFontMetrics( nFont );
142 timeHeight = fm.ascent(); 142 timeHeight = fm.ascent();
143 } 143 }
144 //timeHeight -= (timeHeight/4-2); 144 //timeHeight -= (timeHeight/4-2);
145 QFont sFont = nFont; 145 QFont sFont = nFont;
146 sFont.setPointSize( sFont.pointSize()/2 ); 146 sFont.setPointSize( sFont.pointSize()/2 );
147 QFontMetrics fmS( sFont ); 147 QFontMetrics fmS( sFont );
148 int sHei = fmS.ascent() ; 148 int sHei = fmS.ascent() ;
149 //sHei -= (sHei/4-2); 149 //sHei -= (sHei/4-2);
150 int startW = mMiniWidth - frameWidth()-2 ; 150 int startW = mMiniWidth - frameWidth()-2 ;
151 int tw2 = fmS.width(suffix); 151 int tw2 = fmS.width(suffix);
152 timeHeight = (timeHeight-1) /2 -1; 152 timeHeight = (timeHeight-1) /2 -1;
153 //testline 153 //testline
154 //p->drawLine(0,0,0,contentsHeight()); 154 //p->drawLine(0,0,0,contentsHeight());
155 while (y < cy + ch+mCellHeight) { 155 while (y < cy + ch+mCellHeight) {
156 p->drawLine(startW-tw2+1 ,y,cw+2,y); 156 p->drawLine(startW-tw2+1 ,y,cw+2,y);
157 hour.setNum(cell); 157 hour.setNum(cell);
158 // handle 24h and am/pm time formats 158 // handle 24h and am/pm time formats
159 if (KGlobal::locale()->use12Clock()) { 159 if (KGlobal::locale()->use12Clock()) {
160 if (cell == 12) suffix = "pm"; 160 if (cell == 12) suffix = "pm";
161 if (cell == 0) hour.setNum(12); 161 if (cell == 0) hour.setNum(12);
162 if (cell > 12) hour.setNum(cell - 12); 162 if (cell > 12) hour.setNum(cell - 12);
163 } 163 }
164 164
165 // center and draw the time label 165 // center and draw the time label
166 int timeWidth = fm.width(hour); 166 int timeWidth = fm.width(hour);
167 int offset = startW - timeWidth - tw2 -1 ; 167 int offset = startW - timeWidth - tw2 -1 ;
168 p->setFont( nFont ); 168 p->setFont( nFont );
169 p->drawText( offset, y+ timeHeight, hour); 169 p->drawText( offset, y+ timeHeight, hour);
170 p->setFont( sFont ); 170 p->setFont( sFont );
171 offset = startW - tw2; 171 offset = startW - tw2;
172 p->drawText( offset, y -1, suffix); 172 p->drawText( offset, y -1, suffix);
173 173
174 // increment indices 174 // increment indices
175 y += mCellHeight; 175 y += mCellHeight;
176 cell++; 176 cell++;
177 } 177 }
178 178
179 179
180 180
181 181
182} 182}
183 183
184/** 184/**
185 Calculates the minimum width. 185 Calculates the minimum width.
186*/ 186*/
187int TimeLabels::minimumWidth() const 187int TimeLabels::minimumWidth() const
188{ 188{
189 return mMiniWidth; 189 return mMiniWidth;
190} 190}
191 191
192/** updates widget's internal state */ 192/** updates widget's internal state */
193void TimeLabels::updateConfig() 193void TimeLabels::updateConfig()
194{ 194{
195 mRedrawNeeded = true; 195 mRedrawNeeded = true;
196 // set the font 196 // set the font
197 // config->setGroup("Fonts"); 197 // config->setGroup("Fonts");
198 // QFont font = config->readFontEntry("TimeBar Font"); 198 // QFont font = config->readFontEntry("TimeBar Font");
199 setFont(KOPrefs::instance()->mTimeBarFont); 199 setFont(KOPrefs::instance()->mTimeBarFont);
200 QString test = "20"; 200 QString test = "20";
201 if (KGlobal::locale()->use12Clock()) 201 if (KGlobal::locale()->use12Clock())
202 test = "12"; 202 test = "12";
203 mMiniWidth = fontMetrics().width(test); 203 mMiniWidth = fontMetrics().width(test);
204 if (KGlobal::locale()->use12Clock()) 204 if (KGlobal::locale()->use12Clock())
205 test = "pm"; 205 test = "pm";
206 else { 206 else {
207 test = "00"; 207 test = "00";
208 } 208 }
209 QFont sFont = font(); 209 QFont sFont = font();
210 sFont.setPointSize( sFont.pointSize()/2 ); 210 sFont.setPointSize( sFont.pointSize()/2 );
211 QFontMetrics fmS( sFont ); 211 QFontMetrics fmS( sFont );
212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; 212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ;
213 // update geometry restrictions based on new settings 213 // update geometry restrictions based on new settings
214 setFixedWidth( mMiniWidth ); 214 setFixedWidth( mMiniWidth );
215 215
216 // update HourSize 216 // update HourSize
217 mCellHeight = KOPrefs::instance()->mHourSize*4; 217 mCellHeight = KOPrefs::instance()->mHourSize*4;
218 resizeContents(mMiniWidth,mRows * mCellHeight+1); 218 resizeContents(mMiniWidth,mRows * mCellHeight+1);
219} 219}
220 220
221/** update time label positions */ 221/** update time label positions */
222void TimeLabels::positionChanged() 222void TimeLabels::positionChanged()
223{ 223{
224 int adjustment = mAgenda->contentsY(); 224 int adjustment = mAgenda->contentsY();
225 setContentsPos(0, adjustment); 225 setContentsPos(0, adjustment);
226} 226}
227 227
228/** */ 228/** */
229void TimeLabels::setAgenda(KOAgenda* agenda) 229void TimeLabels::setAgenda(KOAgenda* agenda)
230{ 230{
231 mAgenda = agenda; 231 mAgenda = agenda;
232} 232}
233 233
234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
235{ 235{
236 mMouseDownY = e->pos().y(); 236 mMouseDownY = e->pos().y();
237 mOrgCap = topLevelWidget()->caption(); 237 mOrgCap = topLevelWidget()->caption();
238} 238}
239 239
240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
241{ 241{
242 int diff = mMouseDownY - e->pos().y(); 242 int diff = mMouseDownY - e->pos().y();
243 if ( diff < 10 && diff > -10 ) 243 if ( diff < 10 && diff > -10 )
244 return; 244 return;
245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
246 if ( tSize < 4 ) 246 if ( tSize < 4 )
247 tSize = 4; 247 tSize = 4;
248 if ( tSize > 22 ) 248 if ( tSize > 22 )
249 tSize = 22; 249 tSize = 22;
250 tSize = (tSize-2)/2; 250 tSize = (tSize-2)/2;
251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
252 252
253} 253}
254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
255{ 255{
256 topLevelWidget()->setCaption( mOrgCap ); 256 topLevelWidget()->setCaption( mOrgCap );
257 int diff = mMouseDownY - e->pos().y(); 257 int diff = mMouseDownY - e->pos().y();
258 if ( diff < 10 && diff > -10 ) 258 if ( diff < 10 && diff > -10 )
259 return; 259 return;
260 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 260 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
261 if ( tSize < 4 ) 261 if ( tSize < 4 )
262 tSize = 4; 262 tSize = 4;
263 if ( tSize > 22 ) 263 if ( tSize > 22 )
264 tSize = 22; 264 tSize = 22;
265 tSize = (tSize/2)*2; 265 tSize = (tSize/2)*2;
266 if ( tSize == KOPrefs::instance()->mHourSize ) 266 if ( tSize == KOPrefs::instance()->mHourSize )
267 return; 267 return;
268 KOPrefs::instance()->mHourSize = tSize; 268 KOPrefs::instance()->mHourSize = tSize;
269 emit scaleChanged(); 269 emit scaleChanged();
270} 270}
271 271
@@ -384,387 +384,410 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
384 mLayoutDayLabels = 0; 384 mLayoutDayLabels = 0;
385 mDayLabelsFrame = 0; 385 mDayLabelsFrame = 0;
386 mDayLabels = 0; 386 mDayLabels = 0;
387 bool isRTL = KOGlobals::self()->reverseLayout(); 387 bool isRTL = KOGlobals::self()->reverseLayout();
388 QPixmap expandPix; 388 QPixmap expandPix;
389 if ( KOPrefs::instance()->mVerticalScreen ) { 389 if ( KOPrefs::instance()->mVerticalScreen ) {
390 expandPix = SmallIcon( "1updownarrow" ); 390 expandPix = SmallIcon( "1updownarrow" );
391 } else { 391 } else {
392 expandPix = SmallIcon("1leftrightarrow" ); 392 expandPix = SmallIcon("1leftrightarrow" );
393 } 393 }
394 394
395 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
396 396
397 // Create day name labels for agenda columns 397 // Create day name labels for agenda columns
398 // Create agenda splitter 398 // Create agenda splitter
399 399
400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
402 topLayout->addWidget( mSplitterAgenda ); 402 topLayout->addWidget( mSplitterAgenda );
403 mAllDayFrame = new QHBox(mSplitterAgenda); 403 mAllDayFrame = new QHBox(mSplitterAgenda);
404 mAllDayFrame->setFocusPolicy(NoFocus); 404 mAllDayFrame->setFocusPolicy(NoFocus);
405 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 405 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
406 agendaFrame->setFocusPolicy(NoFocus); 406 agendaFrame->setFocusPolicy(NoFocus);
407 407
408 // Create all-day agenda widget 408 // Create all-day agenda widget
409 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 409 mDummyAllDayLeft = new QVBox( mAllDayFrame );
410 410
411 mExpandButton = new QPushButton(mDummyAllDayLeft); 411 mExpandButton = new QPushButton(mDummyAllDayLeft);
412 mExpandButton->setPixmap( expandPix ); 412 mExpandButton->setPixmap( expandPix );
413 int widebut = mExpandButton->sizeHint().width()+4; 413 int widebut = mExpandButton->sizeHint().width()+4;
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
438#endif 438#endif
439 mDayLabelsFrame = new QHBox(agendaFrame); 439 mDayLabelsFrame = new QHBox(agendaFrame);
440 //topLayout->addWidget(mDayLabelsFrame); 440 //topLayout->addWidget(mDayLabelsFrame);
441 mDayLabels = new QFrame (mDayLabelsFrame); 441 mDayLabels = new QFrame (mDayLabelsFrame);
442 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 442 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
444 agendaLayout->addWidget(mEventIndicatorTop,1,1); 444 agendaLayout->addWidget(mEventIndicatorTop,1,1);
445 445
446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
447 agendaFrame); 447 agendaFrame);
448 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 448 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
449 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 449 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
450 agendaLayout->addWidget(dummyAgendaRight,1,2); 450 agendaLayout->addWidget(dummyAgendaRight,1,2);
451 451
452 // Create time labels 452 // Create time labels
453 mTimeLabels = new TimeLabels(24,agendaFrame); 453 mTimeLabels = new TimeLabels(24,agendaFrame);
454 agendaLayout->addWidget(mTimeLabels,2,0); 454 agendaLayout->addWidget(mTimeLabels,2,0);
455 connect(mTimeLabels,SIGNAL( scaleChanged()), 455 connect(mTimeLabels,SIGNAL( scaleChanged()),
456 this,SLOT(updateConfig())); 456 this,SLOT(updateConfig()));
457 457
458 // Create agenda 458 // Create agenda
459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
461 agendaLayout->setColStretch(1,1); 461 agendaLayout->setColStretch(1,1);
462 mAgenda->setFocusPolicy(NoFocus); 462 mAgenda->setFocusPolicy(NoFocus);
463 // Create event context menu for agenda 463 // Create event context menu for agenda
464 mAllAgendaPopup = eventPopup(); 464 mAllAgendaPopup = eventPopup();
465 465
466#if 0 466#if 0
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
470 470
471#endif 471#endif
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 474
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477 477
478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), 478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)),
479 this,SLOT(categoryChanged(Incidence *))); 479 this,SLOT(categoryChanged(Incidence *)));
480 480
481 481
482 mAgenda->setPopup( mAllAgendaPopup ); 482 mAgenda->setPopup( mAllAgendaPopup );
483 mAllDayAgenda->setPopup( mAllAgendaPopup ); 483 mAllDayAgenda->setPopup( mAllAgendaPopup );
484 // make connections between dependent widgets 484 // make connections between dependent widgets
485 mTimeLabels->setAgenda(mAgenda); 485 mTimeLabels->setAgenda(mAgenda);
486 486
487 // Update widgets to reflect user preferences 487 // Update widgets to reflect user preferences
488 // updateConfig(); 488 // updateConfig();
489 489
490 // createDayLabels(); 490 // createDayLabels();
491 491
492 // these blank widgets make the All Day Event box line up with the agenda 492 // these blank widgets make the All Day Event box line up with the agenda
493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
496 496
497 // Scrolling 497 // Scrolling
498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
499 mTimeLabels, SLOT(positionChanged())); 499 mTimeLabels, SLOT(positionChanged()));
500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
501 SLOT(setContentsPos(int))); 501 SLOT(setContentsPos(int)));
502 502
503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
505 505
506 // Create/Show/Edit/Delete Event 506 // Create/Show/Edit/Delete Event
507 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 507 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
508 SLOT(newEvent(int,int))); 508 SLOT(newEvent(int,int)));
509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
510 SLOT(newTodo(int,int))); 510 SLOT(newTodo(int,int)));
511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
512 SLOT(newEvent(int,int,int,int))); 512 SLOT(newEvent(int,int,int,int)));
513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
514 SLOT(newEventAllDay(int,int))); 514 SLOT(newEventAllDay(int,int)));
515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
516 SLOT(newTodoAllDay(int,int))); 516 SLOT(newTodoAllDay(int,int)));
517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
518 SLOT(newEventAllDay(int,int))); 518 SLOT(newEventAllDay(int,int)));
519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
520 SLOT(newTimeSpanSelected(int,int,int,int))); 520 SLOT(newTimeSpanSelected(int,int,int,int)));
521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
525 525
526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
527 SIGNAL(editIncidenceSignal(Incidence *))); 527 SIGNAL(editIncidenceSignal(Incidence *)));
528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
529 SIGNAL(editIncidenceSignal(Incidence *))); 529 SIGNAL(editIncidenceSignal(Incidence *)));
530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
531 SIGNAL(showIncidenceSignal(Incidence *))); 531 SIGNAL(showIncidenceSignal(Incidence *)));
532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
533 SIGNAL(showIncidenceSignal(Incidence *))); 533 SIGNAL(showIncidenceSignal(Incidence *)));
534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
535 SIGNAL(deleteIncidenceSignal(Incidence *))); 535 SIGNAL(deleteIncidenceSignal(Incidence *)));
536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
537 SIGNAL(deleteIncidenceSignal(Incidence *))); 537 SIGNAL(deleteIncidenceSignal(Incidence *)));
538 538
539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
540 SLOT(updateEventDates(KOAgendaItem *, int ))); 540 SLOT(updateEventDates(KOAgendaItem *, int )));
541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
542 SLOT(updateEventDates(KOAgendaItem *, int))); 542 SLOT(updateEventDates(KOAgendaItem *, int)));
543 543
544 // event indicator update 544 // event indicator update
545 connect(mAgenda,SIGNAL(lowerYChanged(int)), 545 connect(mAgenda,SIGNAL(lowerYChanged(int)),
546 SLOT(updateEventIndicatorTop(int))); 546 SLOT(updateEventIndicatorTop(int)));
547 connect(mAgenda,SIGNAL(upperYChanged(int)), 547 connect(mAgenda,SIGNAL(upperYChanged(int)),
548 SLOT(updateEventIndicatorBottom(int))); 548 SLOT(updateEventIndicatorBottom(int)));
549 // drag signals 549 // drag signals
550 /* 550 /*
551 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 551 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
552 SLOT(startDrag(Event *))); 552 SLOT(startDrag(Event *)));
553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
554 SLOT(startDrag(Event *))); 554 SLOT(startDrag(Event *)));
555 */ 555 */
556 // synchronize selections 556 // synchronize selections
557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
558 mAllDayAgenda, SLOT( deselectItem() ) ); 558 mAllDayAgenda, SLOT( deselectItem() ) );
559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
560 mAgenda, SLOT( deselectItem() ) ); 560 mAgenda, SLOT( deselectItem() ) );
561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
562 SIGNAL( incidenceSelected( Incidence * ) ) ); 562 SIGNAL( incidenceSelected( Incidence * ) ) );
563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
564 SIGNAL( incidenceSelected( Incidence * ) ) ); 564 SIGNAL( incidenceSelected( Incidence * ) ) );
565 connect( mAgenda, SIGNAL( resizedSignal() ), 565 connect( mAgenda, SIGNAL( resizedSignal() ),
566 SLOT( updateConfig( ) ) ); 566 SLOT( updateConfig( ) ) );
567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
570 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 570 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
573 573
574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
576 connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) );
577 connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) );
576 578
579 mIdleTimer = new QTimer ( this );;
580 connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout()));
581}
582void KOAgendaView::slotIdleTimeout()
583{
584 qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) );
585 int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() );
586 mIdleTimer->stop();
587 bool isActice = topLevelWidget()->isActiveWindow();
588 qDebug("KO: Active Window %d ", isActice);
589 // we do nothing if we wake up from a suspend
590 if ( secsfromstart > IDLETIMEOUT + 50 && isActice ) {
591 qDebug("KO: Wakeup from suspend ");
592 mIdleTimer->start( IDLETIMEOUT * 1000 );
593 return;
594 }
595 qDebug("KO: Downsizing Pixmaps ");
596 mAgenda->shrinkPixmap();
597 mAllDayAgenda->shrinkPixmap();
598 KOAgendaItem::paintPix()->resize( 20,20);
599 KOAgendaItem::paintPixAllday()->resize( 20,20);
600
577} 601}
578
579void KOAgendaView::toggleAllDay() 602void KOAgendaView::toggleAllDay()
580{ 603{
581 if ( mSplitterAgenda->firstHandle() ) 604 if ( mSplitterAgenda->firstHandle() )
582 mSplitterAgenda->firstHandle()->toggle(); 605 mSplitterAgenda->firstHandle()->toggle();
583} 606}
584void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 607void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
585{ 608{
586 calendar()->addIncidence( inc ); 609 calendar()->addIncidence( inc );
587 610
588 if ( incOld ) { 611 if ( incOld ) {
589 if ( incOld->typeID() == todoID ) 612 if ( incOld->typeID() == todoID )
590 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 613 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
591 else 614 else
592 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 615 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
593 } 616 }
594 617
595} 618}
596void KOAgendaView::categoryChanged(Incidence * inc) 619void KOAgendaView::categoryChanged(Incidence * inc)
597{ 620{
598 mAgenda->categoryChanged( inc ); 621 mAgenda->categoryChanged( inc );
599 mAllDayAgenda->categoryChanged( inc ); 622 mAllDayAgenda->categoryChanged( inc );
600} 623}
601KOAgendaView::~KOAgendaView() 624KOAgendaView::~KOAgendaView()
602{ 625{
603 delete mAllAgendaPopup; 626 delete mAllAgendaPopup;
604 //delete mAllDayAgendaPopup; 627 //delete mAllDayAgendaPopup;
605 delete KOAgendaItem::paintPix(); 628 delete KOAgendaItem::paintPix();
606 delete KOAgendaItem::paintPixAllday(); 629 delete KOAgendaItem::paintPixAllday();
607} 630}
608void KOAgendaView::resizeEvent( QResizeEvent* e ) 631void KOAgendaView::resizeEvent( QResizeEvent* e )
609{ 632{
610 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 633 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
611 bool uc = false; 634 bool uc = false;
612 int ow = e->oldSize().width(); 635 int ow = e->oldSize().width();
613 int oh = e->oldSize().height(); 636 int oh = e->oldSize().height();
614 int w = e->size().width(); 637 int w = e->size().width();
615 int h = e->size().height(); 638 int h = e->size().height();
616 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 639 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
617 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 640 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
618 uc = true; 641 uc = true;
619 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 642 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
620 } 643 }
621 mUpcomingWidth = e->size().width() ; 644 mUpcomingWidth = e->size().width() ;
622 if ( mBlockUpdating || uc ) { 645 if ( mBlockUpdating || uc ) {
623 mBlockUpdating = false; 646 mBlockUpdating = false;
624 //mAgenda->setMinimumSize(800 , 600 ); 647 //mAgenda->setMinimumSize(800 , 600 );
625 //qDebug("mAgenda->resize+++++++++++++++ "); 648 //qDebug("mAgenda->resize+++++++++++++++ ");
626 updateConfig(); 649 updateConfig();
627 //qDebug("KOAgendaView::Updating now possible "); 650 //qDebug("KOAgendaView::Updating now possible ");
628 } else 651 } else
629 createDayLabels(); 652 createDayLabels();
630 //qDebug("resizeEvent end "); 653 //qDebug("resizeEvent end ");
631 654
632} 655}
633void KOAgendaView::slotDaylabelClicked( int num ) 656void KOAgendaView::slotDaylabelClicked( int num )
634{ 657{
635 658
636 QDate firstDate = mSelectedDates.first(); 659 QDate firstDate = mSelectedDates.first();
637 if ( num == -1 ) 660 if ( num == -1 )
638 emit showDateView( 6, firstDate ); 661 emit showDateView( 6, firstDate );
639 else if (num >= 0 ) { 662 else if (num >= 0 ) {
640 if ( mSelectedDates.count() == 1) 663 if ( mSelectedDates.count() == 1)
641 emit showDateView( 9, firstDate.addDays( num ) ); 664 emit showDateView( 9, firstDate.addDays( num ) );
642 else 665 else
643 emit showDateView( 3, firstDate.addDays( num ) ); 666 emit showDateView( 3, firstDate.addDays( num ) );
644 } 667 }
645 else 668 else
646 showDateView( 10, firstDate.addDays(1) ); 669 showDateView( 10, firstDate.addDays(1) );
647} 670}
648 671
649KOAgendaButton* KOAgendaView::getNewDaylabel() 672KOAgendaButton* KOAgendaView::getNewDaylabel()
650{ 673{
651 674
652 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 675 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
653 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 676 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
654 mDayLabelsList.append( dayLabel ); 677 mDayLabelsList.append( dayLabel );
655 mLayoutDayLabels->addWidget(dayLabel); 678 mLayoutDayLabels->addWidget(dayLabel);
656 return dayLabel ; 679 return dayLabel ;
657} 680}
658 681
659void KOAgendaView::createDayLabels() 682void KOAgendaView::createDayLabels()
660{ 683{
661 684
662 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 685 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
663 // qDebug(" KOAgendaView::createDayLabels() blocked "); 686 // qDebug(" KOAgendaView::createDayLabels() blocked ");
664 return; 687 return;
665 688
666 } 689 }
667 int newHight; 690 int newHight;
668 if ( !mSelectedDates.count()) 691 if ( !mSelectedDates.count())
669 return; 692 return;
670 693
671 // ### Before deleting and recreating we could check if mSelectedDates changed... 694 // ### Before deleting and recreating we could check if mSelectedDates changed...
672 // It would remove some flickering and gain speed (since this is called by 695 // It would remove some flickering and gain speed (since this is called by
673 // each updateView() call) 696 // each updateView() call)
674 697
675 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 698 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
676 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 699 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
677 if ( maxWid < 20 ) 700 if ( maxWid < 20 )
678 maxWid = 20; 701 maxWid = 20;
679 702
680 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 703 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
681 QFontMetrics fm ( dlf ); 704 QFontMetrics fm ( dlf );
682 dlf.setBold( true ); 705 dlf.setBold( true );
683 int selCount = mSelectedDates.count(); 706 int selCount = mSelectedDates.count();
684 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 707 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
685 QString dayTest = "Mon 20"; 708 QString dayTest = "Mon 20";
686 //QString dayTest = "Mon 20"; 709 //QString dayTest = "Mon 20";
687 int wid = fm.width( dayTest ); 710 int wid = fm.width( dayTest );
688 //maxWid -= ( selCount * 3 ); //working for QLabels 711 //maxWid -= ( selCount * 3 ); //working for QLabels
689 if ( QApplication::desktop()->width() <= 320 ) 712 if ( QApplication::desktop()->width() <= 320 )
690 maxWid -= ( selCount * 3 ); //working for QPushButton 713 maxWid -= ( selCount * 3 ); //working for QPushButton
691 else 714 else
692 maxWid -= ( selCount * 4 ); //working for QPushButton 715 maxWid -= ( selCount * 4 ); //working for QPushButton
693 if ( maxWid < 0 ) 716 if ( maxWid < 0 )
694 maxWid = 20; 717 maxWid = 20;
695 int needWid = wid * selCount; 718 int needWid = wid * selCount;
696 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 719 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
697 //if ( needWid > maxWid ) 720 //if ( needWid > maxWid )
698 // qDebug("DAYLABELS TOOOOOOO BIG "); 721 // qDebug("DAYLABELS TOOOOOOO BIG ");
699 while ( needWid > maxWid ) { 722 while ( needWid > maxWid ) {
700 dayTest = dayTest.left( dayTest.length() - 1 ); 723 dayTest = dayTest.left( dayTest.length() - 1 );
701 wid = fm.width( dayTest ); 724 wid = fm.width( dayTest );
702 needWid = wid * selCount; 725 needWid = wid * selCount;
703 } 726 }
704 int maxLen = dayTest.length(); 727 int maxLen = dayTest.length();
705 int fontPoint = dlf.pointSize(); 728 int fontPoint = dlf.pointSize();
706 if ( maxLen < 2 ) { 729 if ( maxLen < 2 ) {
707 int fontPoint = dlf.pointSize(); 730 int fontPoint = dlf.pointSize();
708 while ( fontPoint > 4 ) { 731 while ( fontPoint > 4 ) {
709 --fontPoint; 732 --fontPoint;
710 dlf.setPointSize( fontPoint ); 733 dlf.setPointSize( fontPoint );
711 QFontMetrics f( dlf ); 734 QFontMetrics f( dlf );
712 wid = f.width( "30" ); 735 wid = f.width( "30" );
713 needWid = wid * selCount; 736 needWid = wid * selCount;
714 if ( needWid < maxWid ) 737 if ( needWid < maxWid )
715 break; 738 break;
716 } 739 }
717 maxLen = 2; 740 maxLen = 2;
718 } 741 }
719 //qDebug("Max len %d ", dayTest.length() ); 742 //qDebug("Max len %d ", dayTest.length() );
720 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) 743 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() )
721 dlf.setBold( false ); 744 dlf.setBold( false );
722 QFontMetrics tempF( dlf ); 745 QFontMetrics tempF( dlf );
723 newHight = tempF.height(); 746 newHight = tempF.height();
724 mDayLabels->setFont( dlf ); 747 mDayLabels->setFont( dlf );
725 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 748 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
726 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 749 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
727 //mLayoutDayLabels->addSpacing( 2 ); 750 //mLayoutDayLabels->addSpacing( 2 );
728 // QFont lFont = dlf; 751 // QFont lFont = dlf;
729 bool appendLabels = false; 752 bool appendLabels = false;
730 KOAgendaButton *dayLabel; 753 KOAgendaButton *dayLabel;
731 dayLabel = mDayLabelsList.first(); 754 dayLabel = mDayLabelsList.first();
732 if ( !dayLabel ) { 755 if ( !dayLabel ) {
733 appendLabels = true; 756 appendLabels = true;
734 dayLabel = getNewDaylabel(); 757 dayLabel = getNewDaylabel();
735 } 758 }
736 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 759 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
737 dayLabel->setFont( dlf ); 760 dayLabel->setFont( dlf );
738 dayLabel->setNum( -1 ); 761 dayLabel->setNum( -1 );
739 //dayLabel->setAlignment(QLabel::AlignHCenter); 762 //dayLabel->setAlignment(QLabel::AlignHCenter);
740 763
741 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 764 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
742 dayLabel->show(); 765 dayLabel->show();
743 DateList::ConstIterator dit; 766 DateList::ConstIterator dit;
744 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 767 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
745 int counter = -1; 768 int counter = -1;
746 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 769 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
747 ++counter; 770 ++counter;
748 QDate date = *dit; 771 QDate date = *dit;
749 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 772 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
750 if ( ! appendLabels ) { 773 if ( ! appendLabels ) {
751 dayLabel = mDayLabelsList.next(); 774 dayLabel = mDayLabelsList.next();
752 if ( !dayLabel ) 775 if ( !dayLabel )
753 appendLabels = true; 776 appendLabels = true;
754 } 777 }
755 if ( appendLabels ) { 778 if ( appendLabels ) {
756 dayLabel = getNewDaylabel(); 779 dayLabel = getNewDaylabel();
757 } 780 }
758 dayLabel->setMinimumWidth( 1 ); 781 dayLabel->setMinimumWidth( 1 );
759 dayLabel->setMaximumWidth( 10240 ); 782 dayLabel->setMaximumWidth( 10240 );
760 dayLabel->setFont( dlf ); 783 dayLabel->setFont( dlf );
761 dayLabel->show(); 784 dayLabel->show();
762 dayLabel->setAutoRepeat( false ); 785 dayLabel->setAutoRepeat( false );
763 dayLabel->setNum( counter ); 786 dayLabel->setNum( counter );
764 QString str; 787 QString str;
765 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 788 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
766 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 789 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
767 switch ( maxLen ) { 790 switch ( maxLen ) {
768 case 2: 791 case 2:
769 str = QString::number( date.day() ); 792 str = QString::number( date.day() );
770 break; 793 break;
@@ -1109,428 +1132,430 @@ void KOAgendaView::fillAgenda()
1109 //globalFlagBlockAgenda = 0; 1132 //globalFlagBlockAgenda = 0;
1110 // globalFlagBlockPainting = false; 1133 // globalFlagBlockPainting = false;
1111 if ( globalFlagBlockAgenda == 0 ) 1134 if ( globalFlagBlockAgenda == 0 )
1112 globalFlagBlockAgenda = 1; 1135 globalFlagBlockAgenda = 1;
1113 // clearView(); 1136 // clearView();
1114 //qDebug("fillAgenda()++++ "); 1137 //qDebug("fillAgenda()++++ ");
1115 globalFlagBlockAgendaItemPaint = 1; 1138 globalFlagBlockAgendaItemPaint = 1;
1116 1139
1117 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1140 mAllDayAgenda->changeColumns(mSelectedDates.count());
1118 mAgenda->changeColumns(mSelectedDates.count()); 1141 mAgenda->changeColumns(mSelectedDates.count());
1119 qApp->processEvents(); 1142 qApp->processEvents();
1120 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1143 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1121 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1144 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1122 setHolidayMasks(); 1145 setHolidayMasks();
1123 1146
1124 mMinY.resize(mSelectedDates.count()); 1147 mMinY.resize(mSelectedDates.count());
1125 mMaxY.resize(mSelectedDates.count()); 1148 mMaxY.resize(mSelectedDates.count());
1126 1149
1127 QPtrList<Event> dayEvents; 1150 QPtrList<Event> dayEvents;
1128 1151
1129 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1152 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1130 // Therefore, gtodoset all of them. 1153 // Therefore, gtodoset all of them.
1131 QPtrList<Todo> todos = calendar()->todos(); 1154 QPtrList<Todo> todos = calendar()->todos();
1132 1155
1133 mAgenda->setDateList(mSelectedDates); 1156 mAgenda->setDateList(mSelectedDates);
1134 1157
1135 QDate today = QDate::currentDate(); 1158 QDate today = QDate::currentDate();
1136 1159
1137 DateList::ConstIterator dit; 1160 DateList::ConstIterator dit;
1138 int curCol = 0; 1161 int curCol = 0;
1139 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1162 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1140 QDate currentDate = *dit; 1163 QDate currentDate = *dit;
1141 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1164 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1142 // << endl; 1165 // << endl;
1143 1166
1144 dayEvents = calendar()->events(currentDate,false); 1167 dayEvents = calendar()->events(currentDate,false);
1145 1168
1146 // Default values, which can never be reached 1169 // Default values, which can never be reached
1147 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1170 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1148 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1171 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1149 1172
1150 unsigned int numEvent; 1173 unsigned int numEvent;
1151 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1174 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1152 Event *event = dayEvents.at(numEvent); 1175 Event *event = dayEvents.at(numEvent);
1153 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1176 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1154 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1177 if ( event->uid().left(15) == QString("last-syncEvent-") )
1155 continue; 1178 continue;
1156 // kdDebug() << " Event: " << event->summary() << endl; 1179 // kdDebug() << " Event: " << event->summary() << endl;
1157 1180
1158 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1181 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1159 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1182 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1160 1183
1161 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1184 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1162 1185
1163 if (event->doesFloat()) { 1186 if (event->doesFloat()) {
1164 if (event->recurrence()->doesRecur()) { 1187 if (event->recurrence()->doesRecur()) {
1165 if (event->isMultiDay() ) { 1188 if (event->isMultiDay() ) {
1166 endX = endX - beginX;// endX is now number of days 1189 endX = endX - beginX;// endX is now number of days
1167 if ( event->recursOn( currentDate ) ) { 1190 if ( event->recursOn( currentDate ) ) {
1168 endX += curCol; 1191 endX += curCol;
1169 beginX = curCol; 1192 beginX = curCol;
1170 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1193 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1171 } else { 1194 } else {
1172 //qDebug("days %d %s",endX , currentDate.toString().latin1()); 1195 //qDebug("days %d %s",endX , currentDate.toString().latin1());
1173 QDate dateit = currentDate.addDays( -endX ); 1196 QDate dateit = currentDate.addDays( -endX );
1174 if ( event->recursOn( dateit ) ) { 1197 if ( event->recursOn( dateit ) ) {
1175 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); 1198 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
1176 if ( curCol-endX < 0 ) { 1199 if ( curCol-endX < 0 ) {
1177 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1200 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1178 } 1201 }
1179 } 1202 }
1180 } 1203 }
1181 } else { 1204 } else {
1182 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1205 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1183 } 1206 }
1184 1207
1185 } else { 1208 } else {
1186 if (beginX <= 0 && curCol == 0) { 1209 if (beginX <= 0 && curCol == 0) {
1187 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1210 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1188 } else if (beginX == curCol) { 1211 } else if (beginX == curCol) {
1189 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1212 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1190 } 1213 }
1191 } 1214 }
1192 } else if (event->isMultiDay()) { 1215 } else if (event->isMultiDay()) {
1193 if ( event->doesRecur () ) { 1216 if ( event->doesRecur () ) {
1194 QDate dateit = currentDate; 1217 QDate dateit = currentDate;
1195 int count = 0; 1218 int count = 0;
1196 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1219 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1197 while (! event->recursOn( dateit ) && count <= max ) { 1220 while (! event->recursOn( dateit ) && count <= max ) {
1198 ++count; 1221 ++count;
1199 dateit = dateit.addDays( -1 ); 1222 dateit = dateit.addDays( -1 );
1200 } 1223 }
1201 bool ok; 1224 bool ok;
1202 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1225 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1203 if ( ok ) 1226 if ( ok )
1204 { 1227 {
1205 int secs = event->dtStart().secsTo( event->dtEnd() ); 1228 int secs = event->dtStart().secsTo( event->dtEnd() );
1206 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1229 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1207 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1230 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1208 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1231 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1209 1232
1210 } 1233 }
1211 } 1234 }
1212 int startY = mAgenda->timeToY(event->dtStart().time()); 1235 int startY = mAgenda->timeToY(event->dtStart().time());
1213 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1236 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1214 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1237 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1215 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1238 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1216 //qDebug("insert!!! "); 1239 //qDebug("insert!!! ");
1217 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1240 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1218 } 1241 }
1219 if (beginX == curCol) { 1242 if (beginX == curCol) {
1220 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1243 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1221 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1244 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1222 } else if (endX == curCol) { 1245 } else if (endX == curCol) {
1223 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1246 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1224 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1247 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1225 } else { 1248 } else {
1226 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1249 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1227 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1250 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1228 } 1251 }
1229 } else { 1252 } else {
1230 int startY = mAgenda->timeToY(event->dtStart().time()); 1253 int startY = mAgenda->timeToY(event->dtStart().time());
1231 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1254 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1232 if (endY < startY) endY = startY; 1255 if (endY < startY) endY = startY;
1233 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1256 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1234 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1257 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1235 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1258 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1236 } 1259 }
1237 } 1260 }
1238 // ---------- [display Todos -------------- 1261 // ---------- [display Todos --------------
1239 unsigned int numTodo; 1262 unsigned int numTodo;
1240 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1263 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1241 Todo *todo = todos.at(numTodo); 1264 Todo *todo = todos.at(numTodo);
1242 1265
1243 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1266 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1244 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; 1267 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue;
1245 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1268 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1246 // Already completed items can be displayed on their original due date 1269 // Already completed items can be displayed on their original due date
1247 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1270 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1248 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1271 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1249 bool fillIn = false; 1272 bool fillIn = false;
1250 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1273 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1251 fillIn = true; 1274 fillIn = true;
1252 if ( ! fillIn && !todo->hasCompletedDate() ) 1275 if ( ! fillIn && !todo->hasCompletedDate() )
1253 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1276 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1254 if ( fillIn ) { 1277 if ( fillIn ) {
1255 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1278 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1256 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1279 if ( KOPrefs::instance()->mShowTodoInAgenda )
1257 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1280 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1258 } 1281 }
1259 else { 1282 else {
1260 QDateTime dt; 1283 QDateTime dt;
1261 if ( todo->hasCompletedDate() ) 1284 if ( todo->hasCompletedDate() )
1262 dt = todo->completed(); 1285 dt = todo->completed();
1263 else 1286 else
1264 dt = todo->dtDue();; 1287 dt = todo->dtDue();;
1265 1288
1266 1289
1267 int endY = mAgenda->timeToY(dt.time()) - 1; 1290 int endY = mAgenda->timeToY(dt.time()) - 1;
1268 int hi = (18/KOPrefs::instance()->mHourSize); 1291 int hi = (18/KOPrefs::instance()->mHourSize);
1269 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1292 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1270 int startY = endY -hi; 1293 int startY = endY -hi;
1271 1294
1272 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1295 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1273 1296
1274 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1297 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1275 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1298 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1276 } 1299 }
1277 } 1300 }
1278 } 1301 }
1279 // ---------- display Todos] -------------- 1302 // ---------- display Todos] --------------
1280 1303
1281 ++curCol; 1304 ++curCol;
1282 } 1305 }
1283 mAgenda->hideUnused(); 1306 mAgenda->hideUnused();
1284 mAllDayAgenda->hideUnused(); 1307 mAllDayAgenda->hideUnused();
1285 mAgenda->checkScrollBoundaries(); 1308 mAgenda->checkScrollBoundaries();
1286 deleteSelectedDateTime(); 1309 deleteSelectedDateTime();
1287 createDayLabels(); 1310 createDayLabels();
1288 emit incidenceSelected( 0 ); 1311 emit incidenceSelected( 0 );
1289 1312
1290 if ( globalFlagBlockAgenda == 2 ) { 1313 if ( globalFlagBlockAgenda == 2 ) {
1291 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1314 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1292 setStartHour( KOPrefs::instance()->mDayBegins ); 1315 setStartHour( KOPrefs::instance()->mDayBegins );
1293 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1316 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1294 setStartHour( QTime::currentTime ().hour() ); 1317 setStartHour( QTime::currentTime ().hour() );
1295 } 1318 }
1296 qApp->processEvents(); 1319 qApp->processEvents();
1297 globalFlagBlockAgenda = 0; 1320 globalFlagBlockAgenda = 0;
1298 mAllDayAgenda->drawContentsToPainter(); 1321 mAllDayAgenda->drawContentsToPainter();
1299 mAgenda->drawContentsToPainter(); 1322 mAgenda->drawContentsToPainter();
1300 repaintAgenda(); 1323 repaintAgenda();
1324 mIdleTimer->start ( IDLETIMEOUT *1000 );
1325 mIdleStart = QDateTime::currentDateTime();
1301 onlyOne = false; 1326 onlyOne = false;
1302} 1327}
1303void KOAgendaView::repaintAgenda() 1328void KOAgendaView::repaintAgenda()
1304{ 1329{
1305 mAgenda->viewport()->repaint( false ); 1330 mAgenda->viewport()->repaint( false );
1306 mAllDayAgenda->viewport()->repaint( false ); 1331 mAllDayAgenda->viewport()->repaint( false );
1307 mAgenda->finishUpdate(); 1332 mAgenda->finishUpdate();
1308 mAllDayAgenda->finishUpdate(); 1333 mAllDayAgenda->finishUpdate();
1309} 1334}
1310 1335
1311 1336
1312void KOAgendaView::clearView() 1337void KOAgendaView::clearView()
1313{ 1338{
1314 mAllDayAgenda->clear(); 1339 mAllDayAgenda->clear();
1315 mAgenda->clear(); 1340 mAgenda->clear();
1316} 1341}
1317void KOAgendaView::clearList() 1342void KOAgendaView::clearList()
1318{ 1343{
1319 clearView(); 1344 clearView();
1320 mAllDayAgenda->hideUnused(); 1345 mAllDayAgenda->hideUnused();
1321 mAgenda->hideUnused(); 1346 mAgenda->hideUnused();
1322} 1347}
1323 1348
1324void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1349void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1325 const QDate &td) 1350 const QDate &td)
1326{ 1351{
1327#ifndef KORG_NOPRINTER 1352#ifndef KORG_NOPRINTER
1328 if (fd == td) 1353 if (fd == td)
1329 calPrinter->preview(CalPrinter::Day, fd, td); 1354 calPrinter->preview(CalPrinter::Day, fd, td);
1330 else 1355 else
1331 calPrinter->preview(CalPrinter::Week, fd, td); 1356 calPrinter->preview(CalPrinter::Week, fd, td);
1332#endif 1357#endif
1333} 1358}
1334 1359
1335// void KOAgendaView::updateMovedTodo() 1360// void KOAgendaView::updateMovedTodo()
1336// { 1361// {
1337// // updateConfig(); 1362// // updateConfig();
1338// // emit updateTodoViews(); 1363// // emit updateTodoViews();
1339// } 1364// }
1340 1365
1341void KOAgendaView::slotShowDateView( int mode , int d ) 1366void KOAgendaView::slotShowDateView( int mode , int d )
1342{ 1367{
1343 if ( d >= mSelectedDates.count() ) { 1368 if ( d >= mSelectedDates.count() ) {
1344 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); 1369 qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() );
1345 1370
1346 } else { 1371 } else {
1347 QDate day = mSelectedDates[d]; 1372 QDate day = mSelectedDates[d];
1348 emit showDateView(mode , day ); 1373 emit showDateView(mode , day );
1349 } 1374 }
1350 1375
1351} 1376}
1352void KOAgendaView::newEvent(int gx, int gy) 1377void KOAgendaView::newEvent(int gx, int gy)
1353{ 1378{
1354 if (!mSelectedDates.count()) return; 1379 if (!mSelectedDates.count()) return;
1355 1380
1356 QDate day = mSelectedDates[gx]; 1381 QDate day = mSelectedDates[gx];
1357 1382
1358 QTime time = mAgenda->gyToTime(gy); 1383 QTime time = mAgenda->gyToTime(gy);
1359 QDateTime dt(day,time); 1384 QDateTime dt(day,time);
1360 // if ( dt < QDateTime::currentDateTime () ) 1385 // if ( dt < QDateTime::currentDateTime () )
1361 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1386 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1362 emit newEventSignal(dt); 1387 emit newEventSignal(dt);
1363} 1388}
1364 1389
1365void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1390void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1366{ 1391{
1367 if (!mSelectedDates.count()) return; 1392 if (!mSelectedDates.count()) return;
1368 1393
1369 QDate dayStart = mSelectedDates[gxStart]; 1394 QDate dayStart = mSelectedDates[gxStart];
1370 QDate dayEnd = mSelectedDates[gxEnd]; 1395 QDate dayEnd = mSelectedDates[gxEnd];
1371 1396
1372 QTime timeStart = mAgenda->gyToTime(gyStart); 1397 QTime timeStart = mAgenda->gyToTime(gyStart);
1373 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1398 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1374 1399
1375 QDateTime dtStart(dayStart,timeStart); 1400 QDateTime dtStart(dayStart,timeStart);
1376 QDateTime dtEnd(dayEnd,timeEnd); 1401 QDateTime dtEnd(dayEnd,timeEnd);
1377 1402
1378 emit newEventSignal(dtStart,dtEnd); 1403 emit newEventSignal(dtStart,dtEnd);
1379} 1404}
1380 1405
1381void KOAgendaView::newEventAllDay(int gx, int ) 1406void KOAgendaView::newEventAllDay(int gx, int )
1382{ 1407{
1383 if (!mSelectedDates.count()) return; 1408 if (!mSelectedDates.count()) return;
1384 1409
1385 QDate day = mSelectedDates[gx]; 1410 QDate day = mSelectedDates[gx];
1386 1411
1387 emit newEventSignal(day); 1412 emit newEventSignal(day);
1388} 1413}
1389void KOAgendaView::newTodoAllDay(int gx, int ) 1414void KOAgendaView::newTodoAllDay(int gx, int )
1390{ 1415{
1391 if (!mSelectedDates.count()) return; 1416 if (!mSelectedDates.count()) return;
1392 1417
1393 QDateTime day (mSelectedDates[gx] ); 1418 QDateTime day (mSelectedDates[gx] );
1394 emit newTodoSignal(day, true); 1419 emit newTodoSignal(day, true);
1395} 1420}
1396void KOAgendaView::newTodo(int gx, int gy ) 1421void KOAgendaView::newTodo(int gx, int gy )
1397{ 1422{
1398 if (!mSelectedDates.count()) return; 1423 if (!mSelectedDates.count()) return;
1399 QDate dayStart = mSelectedDates[gx]; 1424 QDate dayStart = mSelectedDates[gx];
1400 QTime timeStart = mAgenda->gyToTime(gy); 1425 QTime timeStart = mAgenda->gyToTime(gy);
1401 QDateTime dt (dayStart,timeStart); 1426 QDateTime dt (dayStart,timeStart);
1402 emit newTodoSignal( dt, false ); 1427 emit newTodoSignal( dt, false );
1403} 1428}
1404 1429
1405void KOAgendaView::updateEventIndicatorTop(int newY) 1430void KOAgendaView::updateEventIndicatorTop(int newY)
1406{ 1431{
1407 uint i; 1432 uint i;
1408 for(i=0;i<mMinY.size();++i) { 1433 for(i=0;i<mMinY.size();++i) {
1409 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1434 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1410 else mEventIndicatorTop->enableColumn(i,false); 1435 else mEventIndicatorTop->enableColumn(i,false);
1411 } 1436 }
1412 1437
1413 mEventIndicatorTop->update(); 1438 mEventIndicatorTop->update();
1414} 1439}
1415 1440
1416void KOAgendaView::updateEventIndicatorBottom(int newY) 1441void KOAgendaView::updateEventIndicatorBottom(int newY)
1417{ 1442{
1418 uint i; 1443 uint i;
1419 for(i=0;i<mMaxY.size();++i) { 1444 for(i=0;i<mMaxY.size();++i) {
1420 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1445 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1421 else mEventIndicatorBottom->enableColumn(i,false); 1446 else mEventIndicatorBottom->enableColumn(i,false);
1422 } 1447 }
1423 1448
1424 mEventIndicatorBottom->update(); 1449 mEventIndicatorBottom->update();
1425} 1450}
1426 1451
1427void KOAgendaView::startDrag(Event *event) 1452void KOAgendaView::startDrag(Event *event)
1428{ 1453{
1429#ifndef KORG_NODND 1454#ifndef KORG_NODND
1430 DndFactory factory( calendar() ); 1455 DndFactory factory( calendar() );
1431 ICalDrag *vd = factory.createDrag(event,this); 1456 ICalDrag *vd = factory.createDrag(event,this);
1432 if (vd->drag()) { 1457 if (vd->drag()) {
1433 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1458 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1434 } 1459 }
1435#endif 1460#endif
1436} 1461}
1437 1462
1438void KOAgendaView::readSettings() 1463void KOAgendaView::readSettings()
1439{ 1464{
1440 readSettings(KOGlobals::config()); 1465 readSettings(KOGlobals::config());
1441} 1466}
1442 1467
1443void KOAgendaView::readSettings(KConfig *config) 1468void KOAgendaView::readSettings(KConfig *config)
1444{ 1469{
1445 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1470 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1446 1471
1447 config->setGroup("Views"); 1472 config->setGroup("Views");
1448 1473
1449 //#ifndef KORG_NOSPLITTER 1474 //#ifndef KORG_NOSPLITTER
1450 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1475 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1451 if (sizes.count() == 2) { 1476 if (sizes.count() == 2) {
1452 if ( sizes[0] < 20 ) { 1477 if ( sizes[0] < 20 ) {
1453 sizes[1] = sizes[1] +20 - sizes[0]; 1478 sizes[1] = sizes[1] +20 - sizes[0];
1454 sizes[0] = 20; 1479 sizes[0] = 20;
1455 } 1480 }
1456 mSplitterAgenda->setSizes(sizes); 1481 mSplitterAgenda->setSizes(sizes);
1457 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1482 // qDebug("read %d %d ",sizes[0],sizes[1] );
1458 } 1483 }
1459 //#endif 1484 //#endif
1460 1485
1461 // updateConfig(); 1486 // updateConfig();
1462} 1487}
1463 1488
1464void KOAgendaView::writeSettings(KConfig *config) 1489void KOAgendaView::writeSettings(KConfig *config)
1465{ 1490{
1466 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1491 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1467 1492
1468 config->setGroup("Views"); 1493 config->setGroup("Views");
1469 1494
1470 //#ifndef KORG_NOSPLITTER 1495 //#ifndef KORG_NOSPLITTER
1471 QValueList<int> list = mSplitterAgenda->sizes(); 1496 QValueList<int> list = mSplitterAgenda->sizes();
1472 config->writeEntry("Separator AgendaView",list); 1497 config->writeEntry("Separator AgendaView",list);
1473 //qDebug("write %d %d ", list[0],list[1] ); 1498 //qDebug("write %d %d ", list[0],list[1] );
1474 //#endif 1499 //#endif
1475} 1500}
1476 1501
1477void KOAgendaView::setHolidayMasks() 1502void KOAgendaView::setHolidayMasks()
1478{ 1503{
1479 mHolidayMask.resize(mSelectedDates.count()); 1504 mHolidayMask.resize(mSelectedDates.count());
1480 1505
1481 uint i; 1506 uint i;
1482 for(i=0;i<mSelectedDates.count();++i) { 1507 for(i=0;i<mSelectedDates.count();++i) {
1483 QDate date = mSelectedDates[i]; 1508 QDate date = mSelectedDates[i];
1484 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1509 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1485 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1510 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1486 bool showHoliday = false; 1511 bool showHoliday = false;
1487 if ( KOPrefs::instance()->mExcludeHolidays ) { 1512 if ( KOPrefs::instance()->mExcludeHolidays ) {
1488 QPtrList<Event> events = calendar()->events( date, true ); 1513 QPtrList<Event> events = calendar()->events( date, true );
1489 Event *event; 1514 Event *event;
1490 for( event = events.first(); event; event = events.next() ) { 1515 for( event = events.first(); event; event = events.next() ) {
1491 if ( event->isHoliday()) { 1516 if ( event->isHoliday()) {
1492 showHoliday = true; 1517 showHoliday = true;
1493 break; 1518 break;
1494 } 1519 }
1495 } 1520 }
1496 1521
1497 } 1522 }
1498 1523
1499#ifndef KORG_NOPLUGINS 1524#ifndef KORG_NOPLUGINS
1500 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1525 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1501 !KOCore::self()->holiday(date).isEmpty(); 1526 !KOCore::self()->holiday(date).isEmpty();
1502#endif 1527#endif
1503 bool showDay = showSaturday || showSunday || showHoliday; 1528 bool showDay = showSaturday || showSunday || showHoliday;
1504 1529
1505 if (showDay) { 1530 if (showDay) {
1506 mHolidayMask.at(i) = true; 1531 mHolidayMask.at(i) = true;
1507 } else { 1532 } else {
1508 mHolidayMask.at(i) = false; 1533 mHolidayMask.at(i) = false;
1509 } 1534 }
1510 } 1535 }
1511 1536
1512 mAgenda->setHolidayMask(&mHolidayMask); 1537 mAgenda->setHolidayMask(&mHolidayMask);
1513 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1538 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1514} 1539}
1515 1540
1516void KOAgendaView::setContentsPos(int y) 1541void KOAgendaView::setContentsPos(int y)
1517{ 1542{
1518 mAgenda->setContentsPos(0,y); 1543 mAgenda->setContentsPos(0,y);
1519} 1544}
1520 1545
1521void KOAgendaView::clearSelection() 1546void KOAgendaView::clearSelection()
1522{ 1547{
1523 mAgenda->deselectItem(); 1548 mAgenda->deselectItem();
1524 mAllDayAgenda->deselectItem(); 1549 mAllDayAgenda->deselectItem();
1525} 1550}
1526 1551
1527void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1552void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1528 int gxEnd, int gyEnd) 1553 int gxEnd, int gyEnd)
1529{ 1554{
1530 mTimeSpanInAllDay = true; 1555 mTimeSpanInAllDay = true;
1531 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1556 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1532} 1557}
1533 1558
1534 1559
1535 1560
1536 1561
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index a1cf308..effd7a3 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -21,274 +21,277 @@
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDAVIEW_H 23#ifndef KOAGENDAVIEW_H
24#define KOAGENDAVIEW_H 24#define KOAGENDAVIEW_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qksplitter.h> 31#include <qksplitter.h>
32#else 32#else
33#include <qsplitter.h> 33#include <qsplitter.h>
34#endif 34#endif
35#include <qmemarray.h> 35#include <qmemarray.h>
36 36
37#include "koeventview.h" 37#include "koeventview.h"
38 38
39class QHBox; 39class QHBox;
40class QFrame; 40class QFrame;
41class QLabel; 41class QLabel;
42class QPushButton; 42class QPushButton;
43class CalendarView; 43class CalendarView;
44class KOAgenda; 44class KOAgenda;
45class KOAgendaItem; 45class KOAgendaItem;
46class KConfig; 46class KConfig;
47class KDGanttMinimizeSplitter; 47class KDGanttMinimizeSplitter;
48 48
49class KOAgendaButton : public QPushButton 49class KOAgendaButton : public QPushButton
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) : 53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) :
54 QPushButton( parent, name ) 54 QPushButton( parent, name )
55 { 55 {
56 mNum = -3; 56 mNum = -3;
57 setFlat( true ); 57 setFlat( true );
58 setFocusPolicy(NoFocus); 58 setFocusPolicy(NoFocus);
59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); 59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) ); 60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) );
61 }; 61 };
62 62
63 QSize sizeHint () const { return QSize( 5,5) ;} 63 QSize sizeHint () const { return QSize( 5,5) ;}
64 void setNum( int n) { mNum = n; } 64 void setNum( int n) { mNum = n; }
65private slots: 65private slots:
66 void bClicked() {emit numClicked( mNum);} 66 void bClicked() {emit numClicked( mNum);}
67signals: 67signals:
68 void numClicked( int ); 68 void numClicked( int );
69private: 69private:
70 int mNum; 70 int mNum;
71}; 71};
72 72
73class TimeLabels : public QScrollView { 73class TimeLabels : public QScrollView {
74 Q_OBJECT 74 Q_OBJECT
75 public: 75 public:
76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
77 77
78 void setCellHeight(int height); 78 void setCellHeight(int height);
79 79
80 /** Calculates the minimum width */ 80 /** Calculates the minimum width */
81 virtual int minimumWidth() const; 81 virtual int minimumWidth() const;
82 82
83 /** updates widget's internal state */ 83 /** updates widget's internal state */
84 void updateConfig(); 84 void updateConfig();
85 85
86 /** */ 86 /** */
87 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
88 88
89 /** */ 89 /** */
90 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
91 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
92 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
93 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
94 94
95 public slots: 95 public slots:
96 /** update time label positions */ 96 /** update time label positions */
97 void positionChanged(); 97 void positionChanged();
98 signals: 98 signals:
99 void scaleChanged(); 99 void scaleChanged();
100 protected: 100 protected:
101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
102 102
103 private: 103 private:
104 QPixmap myPix; 104 QPixmap myPix;
105 bool mRedrawNeeded; 105 bool mRedrawNeeded;
106 int mMiniWidth; 106 int mMiniWidth;
107 int mMouseDownY; 107 int mMouseDownY;
108 QString mOrgCap; 108 QString mOrgCap;
109 int mRows; 109 int mRows;
110 int mCellHeight; 110 int mCellHeight;
111 111
112 /** */ 112 /** */
113 KOAgenda* mAgenda; 113 KOAgenda* mAgenda;
114}; 114};
115 115
116class EventIndicator : public QFrame { 116class EventIndicator : public QFrame {
117 Q_OBJECT 117 Q_OBJECT
118 public: 118 public:
119 enum Location { Top, Bottom }; 119 enum Location { Top, Bottom };
120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
121 virtual ~EventIndicator(); 121 virtual ~EventIndicator();
122 122
123 void changeColumns(int columns); 123 void changeColumns(int columns);
124 void setPaintWidget( KDGanttMinimizeSplitter* ); 124 void setPaintWidget( KDGanttMinimizeSplitter* );
125 void setXOffset( int ); 125 void setXOffset( int );
126 void enableColumn(int column, bool enable); 126 void enableColumn(int column, bool enable);
127 127
128 protected: 128 protected:
129 void drawContents(QPainter *); 129 void drawContents(QPainter *);
130 130
131 private: 131 private:
132 int mXOffset; 132 int mXOffset;
133 KDGanttMinimizeSplitter* mPaintWidget; 133 KDGanttMinimizeSplitter* mPaintWidget;
134 int mColumns; 134 int mColumns;
135 QHBox *mTopBox; 135 QHBox *mTopBox;
136 QBoxLayout *mTopLayout; 136 QBoxLayout *mTopLayout;
137 Location mLocation; 137 Location mLocation;
138 QPixmap mPixmap; 138 QPixmap mPixmap;
139 QMemArray<bool> mEnabled; 139 QMemArray<bool> mEnabled;
140}; 140};
141 141
142/** 142/**
143 KOAgendaView is the agenda-like view used to display events in an one or 143 KOAgendaView is the agenda-like view used to display events in an one or
144 multi-day view. 144 multi-day view.
145*/ 145*/
146class KOAgendaView : public KOEventView { 146class KOAgendaView : public KOEventView {
147 Q_OBJECT 147 Q_OBJECT
148 public: 148 public:
149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
150 virtual ~KOAgendaView(); 150 virtual ~KOAgendaView();
151 void setStartHour( int ); 151 void setStartHour( int );
152 void toggleAllDay(); 152 void toggleAllDay();
153 153
154 154
155 /** Returns maximum number of days supported by the koagendaview */ 155 /** Returns maximum number of days supported by the koagendaview */
156 virtual int maxDatesHint(); 156 virtual int maxDatesHint();
157 157
158 /** Returns number of currently shown dates. */ 158 /** Returns number of currently shown dates. */
159 virtual int currentDateCount(); 159 virtual int currentDateCount();
160 160
161 /** returns the currently selected events */ 161 /** returns the currently selected events */
162 virtual QPtrList<Incidence> selectedIncidences(); 162 virtual QPtrList<Incidence> selectedIncidences();
163 163
164 /** returns the currently selected events */ 164 /** returns the currently selected events */
165 virtual DateList selectedDates(); 165 virtual DateList selectedDates();
166 166
167 /** Remove all events from view */ 167 /** Remove all events from view */
168 void clearView(); 168 void clearView();
169 void clearList(); 169 void clearList();
170 KOAgenda *agenda() { return mAgenda;} 170 KOAgenda *agenda() { return mAgenda;}
171 virtual void printPreview(CalPrinter *calPrinter, 171 virtual void printPreview(CalPrinter *calPrinter,
172 const QDate &, const QDate &); 172 const QDate &, const QDate &);
173 173
174 /** start-datetime of selection */ 174 /** start-datetime of selection */
175 QDateTime selectionStart() {return mTimeSpanBegin;} 175 QDateTime selectionStart() {return mTimeSpanBegin;}
176 /** end-datetime of selection */ 176 /** end-datetime of selection */
177 QDateTime selectionEnd() {return mTimeSpanEnd;} 177 QDateTime selectionEnd() {return mTimeSpanEnd;}
178 /** returns true if selection is for whole day */ 178 /** returns true if selection is for whole day */
179 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 179 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
180 /** make selected start/end invalid */ 180 /** make selected start/end invalid */
181 void deleteSelectedDateTime(); 181 void deleteSelectedDateTime();
182 void repaintAgenda(); 182 void repaintAgenda();
183 public slots: 183 public slots:
184 void setInitStartHour(); 184 void setInitStartHour();
185 virtual void updateView(); 185 virtual void updateView();
186 virtual void updateConfig(); 186 virtual void updateConfig();
187 virtual void showDates(const QDate &start, const QDate &end); 187 virtual void showDates(const QDate &start, const QDate &end);
188 virtual void showEvents(QPtrList<Event> eventList); 188 virtual void showEvents(QPtrList<Event> eventList);
189 189
190 void updateTodo( Todo *, int ); 190 void updateTodo( Todo *, int );
191 void changeEventDisplay(Event *, int); 191 void changeEventDisplay(Event *, int);
192 192
193 void clearSelection(); 193 void clearSelection();
194 194
195 void newTodo(int gx,int gy); 195 void newTodo(int gx,int gy);
196 void newEvent(int gx,int gy); 196 void newEvent(int gx,int gy);
197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
198 void newEventAllDay(int gx, int gy); 198 void newEventAllDay(int gx, int gy);
199 void newTodoAllDay(int gx, int gy); 199 void newTodoAllDay(int gx, int gy);
200 200
201 void startDrag(Event *); 201 void startDrag(Event *);
202 202
203 void readSettings(); 203 void readSettings();
204 void readSettings(KConfig *); 204 void readSettings(KConfig *);
205 void writeSettings(KConfig *); 205 void writeSettings(KConfig *);
206 206
207 void setContentsPos(int y); 207 void setContentsPos(int y);
208 208
209 void scrollOneHourUp(); 209 void scrollOneHourUp();
210 void scrollOneHourDown(); 210 void scrollOneHourDown();
211 void addToCalSlot(Incidence *, Incidence *); 211 void addToCalSlot(Incidence *, Incidence *);
212 void slotShowDateView( int, int ); 212 void slotShowDateView( int, int );
213 void fillAgenda();
213 214
214 signals: 215 signals:
215 void showDateView( int, QDate ); 216 void showDateView( int, QDate );
216 void newTodoSignal( QDateTime ,bool ); 217 void newTodoSignal( QDateTime ,bool );
217 void toggleExpand(); 218 void toggleExpand();
218 void selectWeekNum( int ); 219 void selectWeekNum( int );
219 void todoMoved( Todo *, int ); 220 void todoMoved( Todo *, int );
220 void incidenceChanged(Incidence * , int ); 221 void incidenceChanged(Incidence * , int );
221 // void cloneIncidenceSignal(Incidence *); 222 // void cloneIncidenceSignal(Incidence *);
222 223
223 protected: 224 protected:
224 KOAgendaButton* getNewDaylabel(); 225 KOAgendaButton* getNewDaylabel();
225 bool mBlockUpdating; 226 bool mBlockUpdating;
226 int mUpcomingWidth; 227 int mUpcomingWidth;
227 /** Fill agenda beginning with date startDate */ 228 /** Fill agenda beginning with date startDate */
228 void fillAgenda(const QDate &startDate); 229 void fillAgenda(const QDate &startDate);
229 void resizeEvent( QResizeEvent* e ); 230 void resizeEvent( QResizeEvent* e );
230 /** Fill agenda using the current set value for the start date */ 231 /** Fill agenda using the current set value for the start date */
231 void fillAgenda();
232 232
233 /** Create labels for the selected dates. */ 233 /** Create labels for the selected dates. */
234 void createDayLabels(); 234 void createDayLabels();
235 235
236 /** 236 /**
237 Set the masks on the agenda widgets indicating, which days are holidays. 237 Set the masks on the agenda widgets indicating, which days are holidays.
238 */ 238 */
239 void setHolidayMasks(); 239 void setHolidayMasks();
240 240
241 protected slots: 241 protected slots:
242 void slotIdleTimeout();
242 void categoryChanged( Incidence * ); 243 void categoryChanged( Incidence * );
243 void slotDaylabelClicked( int ); 244 void slotDaylabelClicked( int );
244 /** Update event belonging to agenda item */ 245 /** Update event belonging to agenda item */
245 void updateEventDates(KOAgendaItem *item, int mode = -1); 246 void updateEventDates(KOAgendaItem *item, int mode = -1);
246 //void updateMovedTodo(); 247 //void updateMovedTodo();
247 248
248 void updateEventIndicatorTop(int newY); 249 void updateEventIndicatorTop(int newY);
249 void updateEventIndicatorBottom(int newY); 250 void updateEventIndicatorBottom(int newY);
250 251
251 /** Updates data for selected timespan */ 252 /** Updates data for selected timespan */
252 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 253 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
253 /** Updates data for selected timespan for all day event*/ 254 /** Updates data for selected timespan for all day event*/
254 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 255 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
255 256
256 private: 257 private:
258 QTimer* mIdleTimer;
259 QDateTime mIdleStart;
257 // view widgets 260 // view widgets
258 QFrame *mDayLabels; 261 QFrame *mDayLabels;
259 QHBox *mDayLabelsFrame; 262 QHBox *mDayLabelsFrame;
260 QBoxLayout *mLayoutDayLabels; 263 QBoxLayout *mLayoutDayLabels;
261 QFrame *mAllDayFrame; 264 QFrame *mAllDayFrame;
262 KOAgenda *mAllDayAgenda; 265 KOAgenda *mAllDayAgenda;
263 KOAgenda *mAgenda; 266 KOAgenda *mAgenda;
264 TimeLabels *mTimeLabels; 267 TimeLabels *mTimeLabels;
265 QWidget *mDummyAllDayLeft; 268 QWidget *mDummyAllDayLeft;
266 269
267 KDGanttMinimizeSplitter* mSplitterAgenda; 270 KDGanttMinimizeSplitter* mSplitterAgenda;
268 QPushButton *mExpandButton; 271 QPushButton *mExpandButton;
269 272
270 DateList mSelectedDates; // List of dates to be displayed 273 DateList mSelectedDates; // List of dates to be displayed
271 int mViewType; 274 int mViewType;
272 275
273 bool mWeekStartsMonday; 276 bool mWeekStartsMonday;
274 int mStartHour; 277 int mStartHour;
275 278
276 KOEventPopupMenu *mAllAgendaPopup; 279 KOEventPopupMenu *mAllAgendaPopup;
277 //KOEventPopupMenu *mAllDayAgendaPopup; 280 //KOEventPopupMenu *mAllDayAgendaPopup;
278 281
279 EventIndicator *mEventIndicatorTop; 282 EventIndicator *mEventIndicatorTop;
280 EventIndicator *mEventIndicatorBottom; 283 EventIndicator *mEventIndicatorBottom;
281 284
282 QMemArray<int> mMinY; 285 QMemArray<int> mMinY;
283 QMemArray<int> mMaxY; 286 QMemArray<int> mMaxY;
284 287
285 QMemArray<bool> mHolidayMask; 288 QMemArray<bool> mHolidayMask;
286 289
287 QPtrList<KOAgendaButton> mDayLabelsList; 290 QPtrList<KOAgendaButton> mDayLabelsList;
288 QDateTime mTimeSpanBegin; 291 QDateTime mTimeSpanBegin;
289 QDateTime mTimeSpanEnd; 292 QDateTime mTimeSpanEnd;
290 bool mTimeSpanInAllDay; 293 bool mTimeSpanInAllDay;
291 void keyPressEvent ( QKeyEvent * e ); 294 void keyPressEvent ( QKeyEvent * e );
292}; 295};
293 296
294#endif // KOAGENDAVIEW_H 297#endif // KOAGENDAVIEW_H