summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp11
-rw-r--r--korganizer/koagenda.h1
-rw-r--r--korganizer/koagendaitem.cpp34
-rw-r--r--korganizer/koagendaitem.h1
-rw-r--r--korganizer/koagendaview.cpp11
-rw-r--r--korganizer/koagendaview.h1
-rw-r--r--korganizer/koeventpopupmenu.cpp44
-rw-r--r--korganizer/koeventpopupmenu.h4
-rw-r--r--korganizer/koeventview.cpp1
-rw-r--r--korganizer/kolistview.cpp8
10 files changed, 89 insertions, 27 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index ce73168..f860f7d 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1,1179 +1,1188 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 Marcus Bains line. 5 Marcus Bains line.
6 Copyright (c) 2001 Ali Rahimi 6 Copyright (c) 2001 Ali Rahimi
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#define protected public 28#define protected public
29#include <qwidget.h> 29#include <qwidget.h>
30#undef protected 30#undef protected
31#endif 31#endif
32#include <qintdict.h> 32#include <qintdict.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qpainter.h> 37#include <qpainter.h>
38 38
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kglobal.h> 42#include <kglobal.h>
43 43
44#include "koagendaitem.h" 44#include "koagendaitem.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47 47
48#include "koagenda.h" 48#include "koagenda.h"
49 49
50#include <libkcal/event.h> 50#include <libkcal/event.h>
51#include <libkcal/todo.h> 51#include <libkcal/todo.h>
52 52
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
55#endif 55#endif
56 56
57//extern bool globalFlagBlockPainting; 57//extern bool globalFlagBlockPainting;
58extern int globalFlagBlockAgenda; 58extern int globalFlagBlockAgenda;
59extern int globalFlagBlockAgendaItemPaint; 59extern int globalFlagBlockAgendaItemPaint;
60extern int globalFlagBlockAgendaItemUpdate; 60extern int globalFlagBlockAgendaItemUpdate;
61extern int globalFlagBlockStartup; 61extern int globalFlagBlockStartup;
62 62
63//////////////////////////////////////////////////////////////////////////// 63////////////////////////////////////////////////////////////////////////////
64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
65 : QFrame(_agenda->viewport(),name), agenda(_agenda) 65 : QFrame(_agenda->viewport(),name), agenda(_agenda)
66{ 66{
67 setLineWidth(0); 67 setLineWidth(0);
68 setMargin(0); 68 setMargin(0);
69 setBackgroundColor(Qt::red); 69 setBackgroundColor(Qt::red);
70 minutes = new QTimer(this); 70 minutes = new QTimer(this);
71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
72 minutes->start(0, true); 72 minutes->start(0, true);
73 mTimeBox = new QLabel(this); 73 mTimeBox = new QLabel(this);
74 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 74 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
75 QPalette pal = mTimeBox->palette(); 75 QPalette pal = mTimeBox->palette();
76 pal.setColor(QColorGroup::Foreground, Qt::red); 76 pal.setColor(QColorGroup::Foreground, Qt::red);
77 mTimeBox->setPalette(pal); 77 mTimeBox->setPalette(pal);
78 //mTimeBox->setAutoMask(true); 78 //mTimeBox->setAutoMask(true);
79 79
80 agenda->addChild(mTimeBox); 80 agenda->addChild(mTimeBox);
81 81
82 oldToday = -1; 82 oldToday = -1;
83} 83}
84 84
85MarcusBains::~MarcusBains() 85MarcusBains::~MarcusBains()
86{ 86{
87 delete minutes; 87 delete minutes;
88} 88}
89 89
90int MarcusBains::todayColumn() 90int MarcusBains::todayColumn()
91{ 91{
92 QDate currentDate = QDate::currentDate(); 92 QDate currentDate = QDate::currentDate();
93 93
94 DateList dateList = agenda->dateList(); 94 DateList dateList = agenda->dateList();
95 DateList::ConstIterator it; 95 DateList::ConstIterator it;
96 int col = 0; 96 int col = 0;
97 for(it = dateList.begin(); it != dateList.end(); ++it) { 97 for(it = dateList.begin(); it != dateList.end(); ++it) {
98 if((*it) == currentDate) 98 if((*it) == currentDate)
99 return KOGlobals::self()->reverseLayout() ? 99 return KOGlobals::self()->reverseLayout() ?
100 agenda->columns() - 1 - col : col; 100 agenda->columns() - 1 - col : col;
101 ++col; 101 ++col;
102 } 102 }
103 103
104 return -1; 104 return -1;
105} 105}
106void MarcusBains::updateLoc() 106void MarcusBains::updateLoc()
107{ 107{
108 updateLocation(); 108 updateLocation();
109} 109}
110void MarcusBains::updateLocation(bool recalculate) 110void MarcusBains::updateLocation(bool recalculate)
111{ 111{
112 112
113 QTime tim = QTime::currentTime(); 113 QTime tim = QTime::currentTime();
114 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 114 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
115 if((tim.hour() == 0) && (oldTime.hour()==23)) 115 if((tim.hour() == 0) && (oldTime.hour()==23))
116 recalculate = true; 116 recalculate = true;
117 117
118 int mins = tim.hour()*60 + tim.minute(); 118 int mins = tim.hour()*60 + tim.minute();
119 int minutesPerCell = 24 * 60 / agenda->rows(); 119 int minutesPerCell = 24 * 60 / agenda->rows();
120 int y = mins*agenda->gridSpacingY()/minutesPerCell; 120 int y = mins*agenda->gridSpacingY()/minutesPerCell;
121 int today = recalculate ? todayColumn() : oldToday; 121 int today = recalculate ? todayColumn() : oldToday;
122 int x = agenda->gridSpacingX()*today; 122 int x = agenda->gridSpacingX()*today;
123 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 123 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
124 124
125 oldTime = tim; 125 oldTime = tim;
126 oldToday = today; 126 oldToday = today;
127 127
128 if(disabled || (today<0)) { 128 if(disabled || (today<0)) {
129 hide(); mTimeBox->hide(); 129 hide(); mTimeBox->hide();
130 return; 130 return;
131 } else { 131 } else {
132 show(); mTimeBox->show(); 132 show(); mTimeBox->show();
133 } 133 }
134 134
135 if(recalculate) 135 if(recalculate)
136 setFixedSize(agenda->gridSpacingX(),1); 136 setFixedSize(agenda->gridSpacingX(),1);
137 agenda->moveChild(this, x, y); 137 agenda->moveChild(this, x, y);
138 raise(); 138 raise();
139 139
140 if(recalculate) 140 if(recalculate)
141 //mTimeBox->setFont(QFont("helvetica",10)); 141 //mTimeBox->setFont(QFont("helvetica",10));
142 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 142 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
143 143
144 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 144 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
145 mTimeBox->adjustSize(); 145 mTimeBox->adjustSize();
146 // the -2 below is there because there is a bug in this program 146 // the -2 below is there because there is a bug in this program
147 // somewhere, where the last column of this widget is a few pixels 147 // somewhere, where the last column of this widget is a few pixels
148 // narrower than the other columns. 148 // narrower than the other columns.
149 int offs = (today==agenda->columns()-1) ? -4 : 0; 149 int offs = (today==agenda->columns()-1) ? -4 : 0;
150 agenda->moveChild(mTimeBox, 150 agenda->moveChild(mTimeBox,
151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
152 y-mTimeBox->height()); 152 y-mTimeBox->height());
153 153
154 mTimeBox->raise(); 154 mTimeBox->raise();
155 //mTimeBox->setAutoMask(true); 155 //mTimeBox->setAutoMask(true);
156 minutes->start(5000,true); 156 minutes->start(5000,true);
157} 157}
158 158
159 159
160//////////////////////////////////////////////////////////////////////////// 160////////////////////////////////////////////////////////////////////////////
161 161
162 162
163/* 163/*
164 Create an agenda widget with rows rows and columns columns. 164 Create an agenda widget with rows rows and columns columns.
165*/ 165*/
166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
167 const char *name,WFlags f) : 167 const char *name,WFlags f) :
168 QScrollView(parent,name,f) 168 QScrollView(parent,name,f)
169{ 169{
170 170
171 mAllAgendaPopup = 0; 171 mAllAgendaPopup = 0;
172 mColumns = columns; 172 mColumns = columns;
173 mRows = rows; 173 mRows = rows;
174 mGridSpacingY = rowSize; 174 mGridSpacingY = rowSize;
175 mAllDayMode = false; 175 mAllDayMode = false;
176#ifndef DESKTOP_VERSION 176#ifndef DESKTOP_VERSION
177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
178#endif 178#endif
179 mHolidayMask = 0; 179 mHolidayMask = 0;
180 init(); 180 init();
181} 181}
182 182
183/* 183/*
184 Create an agenda widget with columns columns and one row. This is used for 184 Create an agenda widget with columns columns and one row. This is used for
185 all-day events. 185 all-day events.
186*/ 186*/
187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
188 QScrollView(parent,name,f) 188 QScrollView(parent,name,f)
189{ 189{
190 mAllAgendaPopup = 0; 190 mAllAgendaPopup = 0;
191 blockResize = false; 191 blockResize = false;
192 mColumns = columns; 192 mColumns = columns;
193 mRows = 1; 193 mRows = 1;
194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
195 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 195 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
196 mAllDayMode = true; 196 mAllDayMode = true;
197#ifndef DESKTOP_VERSION 197#ifndef DESKTOP_VERSION
198 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 198 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
199#endif 199#endif
200 mHolidayMask = 0; 200 mHolidayMask = 0;
201 init(); 201 init();
202} 202}
203 203
204 204
205KOAgenda::~KOAgenda() 205KOAgenda::~KOAgenda()
206{ 206{
207 if(mMarcusBains) delete mMarcusBains; 207 if(mMarcusBains) delete mMarcusBains;
208 208
209} 209}
210 210
211Incidence *KOAgenda::selectedIncidence() const 211Incidence *KOAgenda::selectedIncidence() const
212{ 212{
213 return (mSelectedItem ? mSelectedItem->incidence() : 0); 213 return (mSelectedItem ? mSelectedItem->incidence() : 0);
214} 214}
215 215
216 216
217QDate KOAgenda::selectedIncidenceDate() const 217QDate KOAgenda::selectedIncidenceDate() const
218{ 218{
219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
220} 220}
221 221
222 222
223void KOAgenda::init() 223void KOAgenda::init()
224{ 224{
225 mPopupTimer = new QTimer(this); 225 mPopupTimer = new QTimer(this);
226 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 226 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
227 227
228 mNewItemPopup = new QPopupMenu( this ); 228 mNewItemPopup = new QPopupMenu( this );
229 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 229 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
230 QString pathString = ""; 230 QString pathString = "";
231 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 231 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
232 if ( QApplication::desktop()->width() < 480 ) 232 if ( QApplication::desktop()->width() < 480 )
233 pathString += "icons16/"; 233 pathString += "icons16/";
234 } else 234 } else
235 pathString += "iconsmini/"; 235 pathString += "iconsmini/";
236 236
237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
238 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 238 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
239 mNewItemPopup->insertSeparator ( ); 239 mNewItemPopup->insertSeparator ( );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
241 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 241 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 );
245 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 245 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
246#ifndef _WIN32_ 246#ifndef _WIN32_
247 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 247 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
248 viewport()->setWFlags ( wflags); 248 viewport()->setWFlags ( wflags);
249#endif 249#endif
250 mGridSpacingX = 80; 250 mGridSpacingX = 80;
251 mResizeBorderWidth = 8; 251 mResizeBorderWidth = 8;
252 mScrollBorderWidth = 8; 252 mScrollBorderWidth = 8;
253 mScrollDelay = 30; 253 mScrollDelay = 30;
254 mScrollOffset = 10; 254 mScrollOffset = 10;
255 mPaintPixmap.resize( 20,20); 255 mPaintPixmap.resize( 20,20);
256 //enableClipper(true); 256 //enableClipper(true);
257 257
258 // Grab key strokes for keyboard navigation of agenda. Seems to have no 258 // Grab key strokes for keyboard navigation of agenda. Seems to have no
259 // effect. Has to be fixed. 259 // effect. Has to be fixed.
260 setFocusPolicy(WheelFocus); 260 setFocusPolicy(WheelFocus);
261 261
262 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 262 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
263 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 263 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
264 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 264 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
265 265
266 mStartCellX = 0; 266 mStartCellX = 0;
267 mStartCellY = 0; 267 mStartCellY = 0;
268 mCurrentCellX = 0; 268 mCurrentCellX = 0;
269 mCurrentCellY = 0; 269 mCurrentCellY = 0;
270 270
271 mSelectionCellX = 0; 271 mSelectionCellX = 0;
272 mSelectionYTop = 0; 272 mSelectionYTop = 0;
273 mSelectionHeight = 0; 273 mSelectionHeight = 0;
274 274
275 mOldLowerScrollValue = -1; 275 mOldLowerScrollValue = -1;
276 mOldUpperScrollValue = -1; 276 mOldUpperScrollValue = -1;
277 277
278 mClickedItem = 0; 278 mClickedItem = 0;
279 279
280 mActionItem = 0; 280 mActionItem = 0;
281 mActionType = NOP; 281 mActionType = NOP;
282 mItemMoved = false; 282 mItemMoved = false;
283 283
284 mSelectedItem = 0; 284 mSelectedItem = 0;
285 285
286 // mItems.setAutoDelete(true); 286 // mItems.setAutoDelete(true);
287 287
288 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 288 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
289 289
290 viewport()->update(); 290 viewport()->update();
291 291
292 setMinimumSize(30, 1); 292 setMinimumSize(30, 1);
293// setMaximumHeight(mGridSpacingY * mRows + 5); 293// setMaximumHeight(mGridSpacingY * mRows + 5);
294 294
295 // Disable horizontal scrollbar. This is a hack. The geometry should be 295 // 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 296 // controlled in a way that the contents horizontally always fits. Then it is
297 // not necessary to turn off the scrollbar. 297 // not necessary to turn off the scrollbar.
298 setHScrollBarMode(AlwaysOff); 298 setHScrollBarMode(AlwaysOff);
299 if ( ! mAllDayMode ) 299 if ( ! mAllDayMode )
300 setVScrollBarMode(AlwaysOn); 300 setVScrollBarMode(AlwaysOn);
301 else 301 else
302 setVScrollBarMode(AlwaysOff); 302 setVScrollBarMode(AlwaysOff);
303 303
304 setStartHour(KOPrefs::instance()->mDayBegins); 304 setStartHour(KOPrefs::instance()->mDayBegins);
305 305
306 calculateWorkingHours(); 306 calculateWorkingHours();
307 307
308 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 308 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
309 SLOT(checkScrollBoundaries(int))); 309 SLOT(checkScrollBoundaries(int)));
310 310
311 // Create the Marcus Bains line. 311 // Create the Marcus Bains line.
312 if(mAllDayMode) 312 if(mAllDayMode)
313 mMarcusBains = 0; 313 mMarcusBains = 0;
314 else { 314 else {
315 mMarcusBains = new MarcusBains(this); 315 mMarcusBains = new MarcusBains(this);
316 addChild(mMarcusBains); 316 addChild(mMarcusBains);
317 } 317 }
318 mPopupKind = 0; 318 mPopupKind = 0;
319 mPopupItem = 0; 319 mPopupItem = 0;
320} 320}
321 321
322void KOAgenda::clear() 322void KOAgenda::clear()
323{ 323{
324 KOAgendaItem *item; 324 KOAgendaItem *item;
325 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 325 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
326 mUnusedItems.append( item ); 326 mUnusedItems.append( item );
327 //item->hide(); 327 //item->hide();
328 } 328 }
329 mItems.clear(); 329 mItems.clear();
330 mSelectedItem = 0; 330 mSelectedItem = 0;
331 clearSelection(); 331 clearSelection();
332} 332}
333 333
334void KOAgenda::clearSelection() 334void KOAgenda::clearSelection()
335{ 335{
336 mSelectionCellX = 0; 336 mSelectionCellX = 0;
337 mSelectionYTop = 0; 337 mSelectionYTop = 0;
338 mSelectionHeight = 0; 338 mSelectionHeight = 0;
339} 339}
340 340
341void KOAgenda::marcus_bains() 341void KOAgenda::marcus_bains()
342{ 342{
343 if(mMarcusBains) mMarcusBains->updateLocation(true); 343 if(mMarcusBains) mMarcusBains->updateLocation(true);
344} 344}
345 345
346 346
347void KOAgenda::changeColumns(int columns) 347void KOAgenda::changeColumns(int columns)
348{ 348{
349 if (columns == 0) { 349 if (columns == 0) {
350 qDebug("KOAgenda::changeColumns() called with argument 0 "); 350 qDebug("KOAgenda::changeColumns() called with argument 0 ");
351 return; 351 return;
352 } 352 }
353 clear(); 353 clear();
354 mColumns = columns; 354 mColumns = columns;
355 computeSizes(); 355 computeSizes();
356} 356}
357 357
358/* 358/*
359 This is the eventFilter function, which gets all events from the KOAgendaItems 359 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. 360 contained in the agenda. It has to handle moving and resizing for all items.
361*/ 361*/
362bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 362bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
363{ 363{
364 // kdDebug() << "KOAgenda::eventFilter" << endl; 364 // kdDebug() << "KOAgenda::eventFilter" << endl;
365 switch(event->type()) { 365 switch(event->type()) {
366 case QEvent::MouseButtonPress: 366 case QEvent::MouseButtonPress:
367 case QEvent::MouseButtonDblClick: 367 case QEvent::MouseButtonDblClick:
368 case QEvent::MouseButtonRelease: 368 case QEvent::MouseButtonRelease:
369 case QEvent::MouseMove: 369 case QEvent::MouseMove:
370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 370 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
371 371
372 case (QEvent::Leave): 372 case (QEvent::Leave):
373 if (!mActionItem) 373 if (!mActionItem)
374 setCursor(arrowCursor); 374 setCursor(arrowCursor);
375 return true; 375 return true;
376 376
377 default: 377 default:
378 return QScrollView::eventFilter(object,event); 378 return QScrollView::eventFilter(object,event);
379 } 379 }
380} 380}
381void KOAgenda::popupMenu() 381void KOAgenda::popupMenu()
382{ 382{
383 mPopupTimer->stop(); 383 mPopupTimer->stop();
384 if ( mPopupKind == 1 || mPopupKind == 3 ) { 384 if ( mPopupKind == 1 || mPopupKind == 3 ) {
385 if (mActionItem ) { 385 if (mActionItem ) {
386 endItemAction(); 386 endItemAction();
387 } 387 }
388 mLeftMouseDown = false; // no more leftMouse computation 388 mLeftMouseDown = false; // no more leftMouse computation
389 if (mPopupItem) { 389 if (mPopupItem) {
390 //mClickedItem = mPopupItem; 390 //mClickedItem = mPopupItem;
391 selectItem(mPopupItem); 391 selectItem(mPopupItem);
392 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) 392 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 )
393 mAllAgendaPopup->installEventFilter( this ); 393 mAllAgendaPopup->installEventFilter( this );
394 emit showIncidencePopupSignal(mPopupItem->incidence()); 394 emit showIncidencePopupSignal(mPopupItem->incidence());
395 395
396 } 396 }
397 } else if ( mPopupKind == 2 || mPopupKind == 4 ) { 397 } else if ( mPopupKind == 2 || mPopupKind == 4 ) {
398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 398 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
399 endSelectAction( false ); // do not emit new event signal 399 endSelectAction( false ); // do not emit new event signal
400 mLeftMouseDown = false; // no more leftMouse computation 400 mLeftMouseDown = false; // no more leftMouse computation
401 } 401 }
402 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) 402 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 )
403 mNewItemPopup->installEventFilter( this ); 403 mNewItemPopup->installEventFilter( this );
404 mNewItemPopup->popup( mPopupPos); 404 mNewItemPopup->popup( mPopupPos);
405 405
406 } 406 }
407 mLeftMouseDown = false; 407 mLeftMouseDown = false;
408 mPopupItem = 0; 408 mPopupItem = 0;
409 mPopupKind = 0; 409 mPopupKind = 0;
410} 410}
411 411void KOAgenda::categoryChanged(Incidence * inc)
412{
413 KOAgendaItem *item;
414 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
415 if ( item->incidence() == inc ) {
416 item->initColor ();
417 item->updateItem();
418 }
419 }
420}
412bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 421bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
413{ 422{
414 static int startX = 0; 423 static int startX = 0;
415 static int startY = 0; 424 static int startY = 0;
416 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); 425 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 );
417 static bool blockMoving = true; 426 static bool blockMoving = true;
418 427
419 //qDebug("KOAgenda::eventFilter_mous "); 428 //qDebug("KOAgenda::eventFilter_mous ");
420 if ( object == mNewItemPopup ) { 429 if ( object == mNewItemPopup ) {
421 //qDebug("mNewItemPopup "); 430 //qDebug("mNewItemPopup ");
422 if ( me->type() == QEvent::MouseButtonRelease ) { 431 if ( me->type() == QEvent::MouseButtonRelease ) {
423 mNewItemPopup->removeEventFilter( this ); 432 mNewItemPopup->removeEventFilter( this );
424 int dX = me->globalPos().x() - mPopupPos.x();; 433 int dX = me->globalPos().x() - mPopupPos.x();;
425 if ( dX < 0 ) 434 if ( dX < 0 )
426 dX = -dX; 435 dX = -dX;
427 int dY = me->globalPos().y() - mPopupPos.y(); 436 int dY = me->globalPos().y() - mPopupPos.y();
428 if ( dY < 0 ) 437 if ( dY < 0 )
429 dY = -dY; 438 dY = -dY;
430 if ( dX > blockmoveDist || dY > blockmoveDist ) { 439 if ( dX > blockmoveDist || dY > blockmoveDist ) {
431 mNewItemPopup->hide(); 440 mNewItemPopup->hide();
432 } 441 }
433 } 442 }
434 return true; 443 return true;
435 } 444 }
436 if ( object == mAllAgendaPopup ) { 445 if ( object == mAllAgendaPopup ) {
437 //qDebug(" mAllAgendaPopup "); 446 //qDebug(" mAllAgendaPopup ");
438 if ( me->type() == QEvent::MouseButtonRelease ) { 447 if ( me->type() == QEvent::MouseButtonRelease ) {
439 mAllAgendaPopup->removeEventFilter( this ); 448 mAllAgendaPopup->removeEventFilter( this );
440 int dX = me->globalPos().x() - mPopupPos.x();; 449 int dX = me->globalPos().x() - mPopupPos.x();;
441 if ( dX < 0 ) 450 if ( dX < 0 )
442 dX = -dX; 451 dX = -dX;
443 int dY = me->globalPos().y() - mPopupPos.y(); 452 int dY = me->globalPos().y() - mPopupPos.y();
444 if ( dY < 0 ) 453 if ( dY < 0 )
445 dY = -dY; 454 dY = -dY;
446 if ( dX > blockmoveDist || dY > blockmoveDist ) { 455 if ( dX > blockmoveDist || dY > blockmoveDist ) {
447 mAllAgendaPopup->hide(); 456 mAllAgendaPopup->hide();
448 } 457 }
449 } 458 }
450 return true; 459 return true;
451 } 460 }
452 QPoint viewportPos; 461 QPoint viewportPos;
453 if (object != viewport()) { 462 if (object != viewport()) {
454 blockmoveDist = blockmoveDist*2; 463 blockmoveDist = blockmoveDist*2;
455 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 464 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
456 } else { 465 } else {
457 viewportPos = me->pos(); 466 viewportPos = me->pos();
458 } 467 }
459 bool objIsNotViewport = (object != viewport()); 468 bool objIsNotViewport = (object != viewport());
460 bool leftButt = false; 469 bool leftButt = false;
461#ifdef DESKTOP_VERSION 470#ifdef DESKTOP_VERSION
462 leftButt = (me->button() == LeftButton); 471 leftButt = (me->button() == LeftButton);
463#endif 472#endif
464 switch (me->type()) { 473 switch (me->type()) {
465 case QEvent::MouseButtonPress: 474 case QEvent::MouseButtonPress:
466 if (me->button() == LeftButton) { 475 if (me->button() == LeftButton) {
467 mPopupTimer->start( 600 ); 476 mPopupTimer->start( 600 );
468 mLeftMouseDown = true; 477 mLeftMouseDown = true;
469 } 478 }
470 blockMoving = true; 479 blockMoving = true;
471 startX = viewportPos.x(); 480 startX = viewportPos.x();
472 startY = viewportPos.y(); 481 startY = viewportPos.y();
473 mPopupPos = me->globalPos(); 482 mPopupPos = me->globalPos();
474 if ( objIsNotViewport && !leftButt ) { 483 if ( objIsNotViewport && !leftButt ) {
475 KOAgendaItem * tempItem = (KOAgendaItem *)object; 484 KOAgendaItem * tempItem = (KOAgendaItem *)object;
476 if (mAllDayMode) { 485 if (mAllDayMode) {
477 if ( tempItem->height() > 10 ) { 486 if ( tempItem->height() > 10 ) {
478 int minV = tempItem->height()/4; 487 int minV = tempItem->height()/4;
479 if ( minV > (blockmoveDist/2)-2 ) { 488 if ( minV > (blockmoveDist/2)-2 ) {
480 if ( minV > blockmoveDist ) 489 if ( minV > blockmoveDist )
481 minV = blockmoveDist; 490 minV = blockmoveDist;
482 else 491 else
483 minV = (blockmoveDist/2); 492 minV = (blockmoveDist/2);
484 } 493 }
485 bool border = false; 494 bool border = false;
486 int diff = tempItem->y() - viewportPos.y(); 495 int diff = tempItem->y() - viewportPos.y();
487 if ( diff < 0 ) 496 if ( diff < 0 )
488 diff *= -1; 497 diff *= -1;
489 if ( diff < minV ) { 498 if ( diff < minV ) {
490 border = true; 499 border = true;
491 objIsNotViewport = false; 500 objIsNotViewport = false;
492 } 501 }
493 if ( ! border ) { 502 if ( ! border ) {
494 diff = tempItem->y() + tempItem->height()- viewportPos.y(); 503 diff = tempItem->y() + tempItem->height()- viewportPos.y();
495 if ( diff < 0 ) 504 if ( diff < 0 )
496 diff *= -1; 505 diff *= -1;
497 if ( diff < minV ) { 506 if ( diff < minV ) {
498 border = true; 507 border = true;
499 objIsNotViewport = false; 508 objIsNotViewport = false;
500 } 509 }
501 } 510 }
502 } 511 }
503 } else { // not allday 512 } else { // not allday
504 if ( tempItem->width() > 10 ) { 513 if ( tempItem->width() > 10 ) {
505 int minH = tempItem->width()/4; 514 int minH = tempItem->width()/4;
506 if ( minH > (blockmoveDist/2)-2 ) { 515 if ( minH > (blockmoveDist/2)-2 ) {
507 if ( minH > blockmoveDist ) 516 if ( minH > blockmoveDist )
508 minH = blockmoveDist; 517 minH = blockmoveDist;
509 else 518 else
510 minH = (blockmoveDist/2); 519 minH = (blockmoveDist/2);
511 } 520 }
512 bool border = false; 521 bool border = false;
513 int diff = tempItem->x() - viewportPos.x(); 522 int diff = tempItem->x() - viewportPos.x();
514 if ( diff < 0 ) 523 if ( diff < 0 )
515 diff *= -1; 524 diff *= -1;
516 if ( diff < minH ) { 525 if ( diff < minH ) {
517 border = true; 526 border = true;
518 objIsNotViewport = false; 527 objIsNotViewport = false;
519 } 528 }
520 if ( ! border ) { 529 if ( ! border ) {
521 diff = tempItem->x() + tempItem->width() - viewportPos.x(); 530 diff = tempItem->x() + tempItem->width() - viewportPos.x();
522 if ( diff < 0 ) 531 if ( diff < 0 )
523 diff *= -1; 532 diff *= -1;
524 if ( diff < minH ) { 533 if ( diff < minH ) {
525 border = true; 534 border = true;
526 objIsNotViewport = false; 535 objIsNotViewport = false;
527 } 536 }
528 } 537 }
529 } 538 }
530 } 539 }
531 } 540 }
532 if ( objIsNotViewport ) { 541 if ( objIsNotViewport ) {
533 mPopupItem = (KOAgendaItem *)object; 542 mPopupItem = (KOAgendaItem *)object;
534 mPopupKind = 1; 543 mPopupKind = 1;
535 if (me->button() == RightButton) { 544 if (me->button() == RightButton) {
536 mPopupKind = 3; 545 mPopupKind = 3;
537 popupMenu(); 546 popupMenu();
538 } else if (me->button() == LeftButton) { 547 } else if (me->button() == LeftButton) {
539 mActionItem = (KOAgendaItem *)object; 548 mActionItem = (KOAgendaItem *)object;
540 if (mActionItem) { 549 if (mActionItem) {
541 emit signalClearSelection(); 550 emit signalClearSelection();
542 slotClearSelection(); 551 slotClearSelection();
543 selectItem(mActionItem); 552 selectItem(mActionItem);
544 Incidence *incidence = mActionItem->incidence(); 553 Incidence *incidence = mActionItem->incidence();
545 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 554 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
546 mActionItem = 0; 555 mActionItem = 0;
547 } else { 556 } else {
548 startItemAction(viewportPos); 557 startItemAction(viewportPos);
549 } 558 }
550 } 559 }
551 } 560 }
552 } else { // ---------- viewport() 561 } else { // ---------- viewport()
553 mPopupItem = 0; 562 mPopupItem = 0;
554 mPopupKind = 2; 563 mPopupKind = 2;
555 selectItem(0); 564 selectItem(0);
556 mActionItem = 0; 565 mActionItem = 0;
557 if (me->button() == RightButton) { 566 if (me->button() == RightButton) {
558 int x,y; 567 int x,y;
559 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 568 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
560 int gx,gy; 569 int gx,gy;
561 contentsToGrid(x,y,gx,gy); 570 contentsToGrid(x,y,gx,gy);
562 mCurrentCellX = gx; 571 mCurrentCellX = gx;
563 mCurrentCellY = gy; 572 mCurrentCellY = gy;
564 mStartCellX = gx; 573 mStartCellX = gx;
565 mStartCellY = gy; 574 mStartCellY = gy;
566 mPopupKind = 4; 575 mPopupKind = 4;
567 popupMenu(); 576 popupMenu();
568 } else if (me->button() == LeftButton) { 577 } else if (me->button() == LeftButton) {
569 setCursor(arrowCursor); 578 setCursor(arrowCursor);
570 startSelectAction(viewportPos); 579 startSelectAction(viewportPos);
571 } 580 }
572 } 581 }
573 break; 582 break;
574 583
575 case QEvent::MouseButtonRelease: 584 case QEvent::MouseButtonRelease:
576 if (me->button() == LeftButton ) { 585 if (me->button() == LeftButton ) {
577 mPopupTimer->stop(); 586 mPopupTimer->stop();
578 } 587 }
579 if (object != viewport()) { 588 if (object != viewport()) {
580 if (me->button() == LeftButton && mLeftMouseDown) { 589 if (me->button() == LeftButton && mLeftMouseDown) {
581 if (mActionItem) { 590 if (mActionItem) {
582 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 591 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
583 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 592 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
584 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 593 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
585 mScrollUpTimer.stop(); 594 mScrollUpTimer.stop();
586 mScrollDownTimer.stop(); 595 mScrollDownTimer.stop();
587 mActionItem->resetMove(); 596 mActionItem->resetMove();
588 placeSubCells( mActionItem ); 597 placeSubCells( mActionItem );
589 // emit startDragSignal( mActionItem->incidence() ); 598 // emit startDragSignal( mActionItem->incidence() );
590 setCursor( arrowCursor ); 599 setCursor( arrowCursor );
591 mActionItem = 0; 600 mActionItem = 0;
592 mActionType = NOP; 601 mActionType = NOP;
593 mItemMoved = 0; 602 mItemMoved = 0;
594 mLeftMouseDown = false; 603 mLeftMouseDown = false;
595 return true; 604 return true;
596 } 605 }
597 endItemAction(); 606 endItemAction();
598 } 607 }
599 } 608 }
600 609
601 } else { // ---------- viewport() 610 } else { // ---------- viewport()
602 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 611 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
603 endSelectAction( true ); // emit new event signal 612 endSelectAction( true ); // emit new event signal
604 } 613 }
605 } 614 }
606 if (me->button() == LeftButton) 615 if (me->button() == LeftButton)
607 mLeftMouseDown = false; 616 mLeftMouseDown = false;
608 617
609 break; 618 break;
610 619
611 case QEvent::MouseMove: 620 case QEvent::MouseMove:
612 //qDebug("mm "); 621 //qDebug("mm ");
613 if ( !mLeftMouseDown ) 622 if ( !mLeftMouseDown )
614 return false; 623 return false;
615 if ( blockMoving ) { 624 if ( blockMoving ) {
616 int dX, dY; 625 int dX, dY;
617 dX = startX - viewportPos.x(); 626 dX = startX - viewportPos.x();
618 if ( dX < 0 ) 627 if ( dX < 0 )
619 dX = -dX; 628 dX = -dX;
620 dY = viewportPos.y() - startY; 629 dY = viewportPos.y() - startY;
621 if ( dY < 0 ) 630 if ( dY < 0 )
622 dY = -dY; 631 dY = -dY;
623 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 632 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
624 if ( dX > blockmoveDist || dY > blockmoveDist ) { 633 if ( dX > blockmoveDist || dY > blockmoveDist ) {
625 blockMoving = false; 634 blockMoving = false;
626 } 635 }
627 } 636 }
628 if ( ! blockMoving ) 637 if ( ! blockMoving )
629 mPopupTimer->stop(); 638 mPopupTimer->stop();
630 if (object != viewport()) { 639 if (object != viewport()) {
631 KOAgendaItem *moveItem = (KOAgendaItem *)object; 640 KOAgendaItem *moveItem = (KOAgendaItem *)object;
632 if (!moveItem->incidence()->isReadOnly() ) { 641 if (!moveItem->incidence()->isReadOnly() ) {
633 if (!mActionItem) 642 if (!mActionItem)
634 setNoActionCursor(moveItem,viewportPos); 643 setNoActionCursor(moveItem,viewportPos);
635 else { 644 else {
636 if ( !blockMoving ) 645 if ( !blockMoving )
637 performItemAction(viewportPos); 646 performItemAction(viewportPos);
638 } 647 }
639 } 648 }
640 } else { // ---------- viewport() 649 } else { // ---------- viewport()
641 mPopupPos = viewport()->mapToGlobal( me->pos() ); 650 mPopupPos = viewport()->mapToGlobal( me->pos() );
642 if ( mActionType == SELECT ) { 651 if ( mActionType == SELECT ) {
643 performSelectAction( viewportPos ); 652 performSelectAction( viewportPos );
644 } 653 }
645 } 654 }
646 break; 655 break;
647 656
648 case QEvent::MouseButtonDblClick: 657 case QEvent::MouseButtonDblClick:
649 mPopupTimer->stop(); 658 mPopupTimer->stop();
650 if (object == viewport()) { 659 if (object == viewport()) {
651 selectItem(0); 660 selectItem(0);
652 int x,y; 661 int x,y;
653 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 662 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
654 int gx,gy; 663 int gx,gy;
655 contentsToGrid(x,y,gx,gy); 664 contentsToGrid(x,y,gx,gy);
656 emit newEventSignal(gx,gy); 665 emit newEventSignal(gx,gy);
657 } else { 666 } else {
658 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 667 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
659 selectItem(doubleClickedItem); 668 selectItem(doubleClickedItem);
660 if ( KOPrefs::instance()->mEditOnDoubleClick ) 669 if ( KOPrefs::instance()->mEditOnDoubleClick )
661 emit editIncidenceSignal(doubleClickedItem->incidence()); 670 emit editIncidenceSignal(doubleClickedItem->incidence());
662 else 671 else
663 emit showIncidenceSignal(doubleClickedItem->incidence()); 672 emit showIncidenceSignal(doubleClickedItem->incidence());
664 } 673 }
665 break; 674 break;
666 675
667 default: 676 default:
668 break; 677 break;
669 } 678 }
670 return true; 679 return true;
671 680
672} 681}
673 682
674void KOAgenda::newItem( int item ) 683void KOAgenda::newItem( int item )
675{ 684{
676 if ( item == 1 ) { //new event 685 if ( item == 1 ) { //new event
677 newEventSignal(mStartCellX ,mStartCellY ); 686 newEventSignal(mStartCellX ,mStartCellY );
678 } else 687 } else
679 if ( item == 2 ) { //new event 688 if ( item == 2 ) { //new event
680 newTodoSignal(mStartCellX ,mStartCellY ); 689 newTodoSignal(mStartCellX ,mStartCellY );
681 } else 690 } else
682 { 691 {
683 emit showDateView( item, mStartCellX ); 692 emit showDateView( item, mStartCellX );
684 // 3Day view 693 // 3Day view
685 // 4Week view 694 // 4Week view
686 // 5Month view 695 // 5Month view
687 // 6Journal view 696 // 6Journal view
688 } 697 }
689} 698}
690void KOAgenda::slotClearSelection() 699void KOAgenda::slotClearSelection()
691{ 700{
692 if (mSelectionHeight) { 701 if (mSelectionHeight) {
693 int selectionX = mSelectionCellX * mGridSpacingX; 702 int selectionX = mSelectionCellX * mGridSpacingX;
694 int top = mSelectionYTop - 2 *mGridSpacingY; 703 int top = mSelectionYTop - 2 *mGridSpacingY;
695 int hei = mSelectionHeight + 4 *mGridSpacingY; 704 int hei = mSelectionHeight + 4 *mGridSpacingY;
696 clearSelection(); 705 clearSelection();
697 repaintContents( selectionX, top, 706 repaintContents( selectionX, top,
698 mGridSpacingX, hei ,false ); 707 mGridSpacingX, hei ,false );
699 } 708 }
700 709
701} 710}
702void KOAgenda::startSelectAction(QPoint viewportPos) 711void KOAgenda::startSelectAction(QPoint viewportPos)
703{ 712{
704 713
705 emit signalClearSelection(); 714 emit signalClearSelection();
706 slotClearSelection(); 715 slotClearSelection();
707 716
708 mActionType = SELECT; 717 mActionType = SELECT;
709 718
710 int x,y; 719 int x,y;
711 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 720 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
712 int gx,gy; 721 int gx,gy;
713 contentsToGrid(x,y,gx,gy); 722 contentsToGrid(x,y,gx,gy);
714 723
715 mStartCellX = gx; 724 mStartCellX = gx;
716 mStartCellY = gy; 725 mStartCellY = gy;
717 mCurrentCellX = gx; 726 mCurrentCellX = gx;
718 mCurrentCellY = gy; 727 mCurrentCellY = gy;
719 728
720 // Store new selection 729 // Store new selection
721 mSelectionCellX = gx; 730 mSelectionCellX = gx;
722 mSelectionYTop = gy * mGridSpacingY; 731 mSelectionYTop = gy * mGridSpacingY;
723 mSelectionHeight = mGridSpacingY; 732 mSelectionHeight = mGridSpacingY;
724 733
725 // Paint new selection 734 // Paint new selection
726 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, 735 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop,
727 mGridSpacingX-1, mSelectionHeight ); 736 mGridSpacingX-1, mSelectionHeight );
728} 737}
729 738
730void KOAgenda::performSelectAction(QPoint viewportPos) 739void KOAgenda::performSelectAction(QPoint viewportPos)
731{ 740{
732 int x,y; 741 int x,y;
733 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 742 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
734 int gx,gy; 743 int gx,gy;
735 contentsToGrid(x,y,gx,gy); 744 contentsToGrid(x,y,gx,gy);
736 745
737 QPoint clipperPos = clipper()-> 746 QPoint clipperPos = clipper()->
738 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 747 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
739 748
740 // Scroll if cursor was moved to upper or lower end of agenda. 749 // Scroll if cursor was moved to upper or lower end of agenda.
741 if (clipperPos.y() < mScrollBorderWidth) { 750 if (clipperPos.y() < mScrollBorderWidth) {
742 mScrollUpTimer.start(mScrollDelay); 751 mScrollUpTimer.start(mScrollDelay);
743 } else if (visibleHeight() - clipperPos.y() < 752 } else if (visibleHeight() - clipperPos.y() <
744 mScrollBorderWidth) { 753 mScrollBorderWidth) {
745 mScrollDownTimer.start(mScrollDelay); 754 mScrollDownTimer.start(mScrollDelay);
746 } else { 755 } else {
747 mScrollUpTimer.stop(); 756 mScrollUpTimer.stop();
748 mScrollDownTimer.stop(); 757 mScrollDownTimer.stop();
749 } 758 }
750 759
751 if ( gy > mCurrentCellY ) { 760 if ( gy > mCurrentCellY ) {
752 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 761 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
753 762
754 763
755 repaintContents( (KOGlobals::self()->reverseLayout() ? 764 repaintContents( (KOGlobals::self()->reverseLayout() ?
756 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 765 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
757 mGridSpacingX, mSelectionYTop, 766 mGridSpacingX, mSelectionYTop,
758 mGridSpacingX, mSelectionHeight , false); 767 mGridSpacingX, mSelectionHeight , false);
759 768
760 mCurrentCellY = gy; 769 mCurrentCellY = gy;
761 } else if ( gy < mCurrentCellY ) { 770 } else if ( gy < mCurrentCellY ) {
762 if ( gy >= mStartCellY ) { 771 if ( gy >= mStartCellY ) {
763 int selectionHeight = mSelectionHeight; 772 int selectionHeight = mSelectionHeight;
764 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 773 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
765 774
766 repaintContents( (KOGlobals::self()->reverseLayout() ? 775 repaintContents( (KOGlobals::self()->reverseLayout() ?
767 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 776 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
768 mGridSpacingX, mSelectionYTop, 777 mGridSpacingX, mSelectionYTop,
769 mGridSpacingX, selectionHeight,false ); 778 mGridSpacingX, selectionHeight,false );
770 779
771 mCurrentCellY = gy; 780 mCurrentCellY = gy;
772 } else { 781 } else {
773 } 782 }
774 } 783 }
775} 784}
776 785
777void KOAgenda::endSelectAction( bool emitNewEvent ) 786void KOAgenda::endSelectAction( bool emitNewEvent )
778{ 787{
779 mActionType = NOP; 788 mActionType = NOP;
780 mScrollUpTimer.stop(); 789 mScrollUpTimer.stop();
781 mScrollDownTimer.stop(); 790 mScrollDownTimer.stop();
782 791
783 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 792 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
784 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 793 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
785 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 794 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
786 } 795 }
787} 796}
788 797
789void KOAgenda::startItemAction(QPoint viewportPos) 798void KOAgenda::startItemAction(QPoint viewportPos)
790{ 799{
791 int x,y; 800 int x,y;
792 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 801 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
793 int gx,gy; 802 int gx,gy;
794 contentsToGrid(x,y,gx,gy); 803 contentsToGrid(x,y,gx,gy);
795 804
796 mStartCellX = gx; 805 mStartCellX = gx;
797 mStartCellY = gy; 806 mStartCellY = gy;
798 mCurrentCellX = gx; 807 mCurrentCellX = gx;
799 mCurrentCellY = gy; 808 mCurrentCellY = gy;
800 809
801 if (mAllDayMode) { 810 if (mAllDayMode) {
802 int gridDistanceX = (x - gx * mGridSpacingX); 811 int gridDistanceX = (x - gx * mGridSpacingX);
803 if (gridDistanceX < mResizeBorderWidth && 812 if (gridDistanceX < mResizeBorderWidth &&
804 mActionItem->cellX() == mCurrentCellX) { 813 mActionItem->cellX() == mCurrentCellX) {
805 mActionType = RESIZELEFT; 814 mActionType = RESIZELEFT;
806 setCursor(sizeHorCursor); 815 setCursor(sizeHorCursor);
807 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 816 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
808 mActionItem->cellXWidth() == mCurrentCellX) { 817 mActionItem->cellXWidth() == mCurrentCellX) {
809 mActionType = RESIZERIGHT; 818 mActionType = RESIZERIGHT;
810 setCursor(sizeHorCursor); 819 setCursor(sizeHorCursor);
811 } else { 820 } else {
812 mActionType = MOVE; 821 mActionType = MOVE;
813 mActionItem->startMove(); 822 mActionItem->startMove();
814 setCursor(sizeAllCursor); 823 setCursor(sizeAllCursor);
815 } 824 }
816 } else { 825 } else {
817 int gridDistanceY = (y - gy * mGridSpacingY); 826 int gridDistanceY = (y - gy * mGridSpacingY);
818 bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); 827 bool allowResize = ( mActionItem->incidence()->typeID() != todoID );
819 if (allowResize && gridDistanceY < mResizeBorderWidth && 828 if (allowResize && gridDistanceY < mResizeBorderWidth &&
820 mActionItem->cellYTop() == mCurrentCellY && 829 mActionItem->cellYTop() == mCurrentCellY &&
821 !mActionItem->firstMultiItem()) { 830 !mActionItem->firstMultiItem()) {
822 mActionType = RESIZETOP; 831 mActionType = RESIZETOP;
823 setCursor(sizeVerCursor); 832 setCursor(sizeVerCursor);
824 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 833 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
825 mActionItem->cellYBottom() == mCurrentCellY && 834 mActionItem->cellYBottom() == mCurrentCellY &&
826 !mActionItem->lastMultiItem()) { 835 !mActionItem->lastMultiItem()) {
827 mActionType = RESIZEBOTTOM; 836 mActionType = RESIZEBOTTOM;
828 setCursor(sizeVerCursor); 837 setCursor(sizeVerCursor);
829 } else { 838 } else {
830 mActionType = MOVE; 839 mActionType = MOVE;
831 mActionItem->startMove(); 840 mActionItem->startMove();
832 setCursor(sizeAllCursor); 841 setCursor(sizeAllCursor);
833 } 842 }
834 } 843 }
835} 844}
836 845
837void KOAgenda::performItemAction(QPoint viewportPos) 846void KOAgenda::performItemAction(QPoint viewportPos)
838{ 847{
839// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 848// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
840// QPoint point = viewport()->mapToGlobal(viewportPos); 849// QPoint point = viewport()->mapToGlobal(viewportPos);
841// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 850// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
842// point = clipper()->mapFromGlobal(point); 851// point = clipper()->mapFromGlobal(point);
843// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 852// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
844// kdDebug() << "visible height: " << visibleHeight() << endl; 853// kdDebug() << "visible height: " << visibleHeight() << endl;
845 int x,y; 854 int x,y;
846 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 855 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
847// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 856// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
848 int gx,gy; 857 int gx,gy;
849 contentsToGrid(x,y,gx,gy); 858 contentsToGrid(x,y,gx,gy);
850 QPoint clipperPos = clipper()-> 859 QPoint clipperPos = clipper()->
851 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 860 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
852 861
853 // Cursor left active agenda area. 862 // Cursor left active agenda area.
854 // This starts a drag. 863 // This starts a drag.
855 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 864 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
856 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 865 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
857 if ( mActionType == MOVE ) { 866 if ( mActionType == MOVE ) {
858 mScrollUpTimer.stop(); 867 mScrollUpTimer.stop();
859 mScrollDownTimer.stop(); 868 mScrollDownTimer.stop();
860 mActionItem->resetMove(); 869 mActionItem->resetMove();
861 placeSubCells( mActionItem ); 870 placeSubCells( mActionItem );
862 // emit startDragSignal( mActionItem->incidence() ); 871 // emit startDragSignal( mActionItem->incidence() );
863 setCursor( arrowCursor ); 872 setCursor( arrowCursor );
864 mActionItem = 0; 873 mActionItem = 0;
865 mActionType = NOP; 874 mActionType = NOP;
866 mItemMoved = 0; 875 mItemMoved = 0;
867 return; 876 return;
868 } 877 }
869 } else { 878 } else {
870 switch ( mActionType ) { 879 switch ( mActionType ) {
871 case MOVE: 880 case MOVE:
872 setCursor( sizeAllCursor ); 881 setCursor( sizeAllCursor );
873 break; 882 break;
874 case RESIZETOP: 883 case RESIZETOP:
875 case RESIZEBOTTOM: 884 case RESIZEBOTTOM:
876 setCursor( sizeVerCursor ); 885 setCursor( sizeVerCursor );
877 break; 886 break;
878 case RESIZELEFT: 887 case RESIZELEFT:
879 case RESIZERIGHT: 888 case RESIZERIGHT:
880 setCursor( sizeHorCursor ); 889 setCursor( sizeHorCursor );
881 break; 890 break;
882 default: 891 default:
883 setCursor( arrowCursor ); 892 setCursor( arrowCursor );
884 } 893 }
885 } 894 }
886 895
887 // Scroll if item was moved to upper or lower end of agenda. 896 // Scroll if item was moved to upper or lower end of agenda.
888 if (clipperPos.y() < mScrollBorderWidth) { 897 if (clipperPos.y() < mScrollBorderWidth) {
889 mScrollUpTimer.start(mScrollDelay); 898 mScrollUpTimer.start(mScrollDelay);
890 } else if (visibleHeight() - clipperPos.y() < 899 } else if (visibleHeight() - clipperPos.y() <
891 mScrollBorderWidth) { 900 mScrollBorderWidth) {
892 mScrollDownTimer.start(mScrollDelay); 901 mScrollDownTimer.start(mScrollDelay);
893 } else { 902 } else {
894 mScrollUpTimer.stop(); 903 mScrollUpTimer.stop();
895 mScrollDownTimer.stop(); 904 mScrollDownTimer.stop();
896 } 905 }
897 906
898 // Move or resize item if necessary 907 // Move or resize item if necessary
899 if (mCurrentCellX != gx || mCurrentCellY != gy) { 908 if (mCurrentCellX != gx || mCurrentCellY != gy) {
900 mItemMoved = true; 909 mItemMoved = true;
901 mActionItem->raise(); 910 mActionItem->raise();
902 if (mActionType == MOVE) { 911 if (mActionType == MOVE) {
903 // Move all items belonging to a multi item 912 // Move all items belonging to a multi item
904 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 913 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
905 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 914 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
906 if (!moveItem) moveItem = mActionItem; 915 if (!moveItem) moveItem = mActionItem;
907 while (moveItem) { 916 while (moveItem) {
908 int dy; 917 int dy;
909 if (isMultiItem) dy = 0; 918 if (isMultiItem) dy = 0;
910 else dy = gy - mCurrentCellY; 919 else dy = gy - mCurrentCellY;
911 moveItem->moveRelative(gx - mCurrentCellX,dy); 920 moveItem->moveRelative(gx - mCurrentCellX,dy);
912 int x,y; 921 int x,y;
913 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 922 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
914 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 923 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
915 mGridSpacingY * moveItem->cellHeight()); 924 mGridSpacingY * moveItem->cellHeight());
916 moveChild(moveItem,x,y); 925 moveChild(moveItem,x,y);
917 moveItem = moveItem->nextMultiItem(); 926 moveItem = moveItem->nextMultiItem();
918 } 927 }
919 } else if (mActionType == RESIZETOP) { 928 } else if (mActionType == RESIZETOP) {
920 if (mCurrentCellY <= mActionItem->cellYBottom()) { 929 if (mCurrentCellY <= mActionItem->cellYBottom()) {
921 mActionItem->expandTop(gy - mCurrentCellY); 930 mActionItem->expandTop(gy - mCurrentCellY);
922 mActionItem->resize(mActionItem->width(), 931 mActionItem->resize(mActionItem->width(),
923 mGridSpacingY * mActionItem->cellHeight()); 932 mGridSpacingY * mActionItem->cellHeight());
924 int x,y; 933 int x,y;
925 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 934 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
926 //moveChild(mActionItem,childX(mActionItem),y); 935 //moveChild(mActionItem,childX(mActionItem),y);
927 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 936 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
928 } 937 }
929 } else if (mActionType == RESIZEBOTTOM) { 938 } else if (mActionType == RESIZEBOTTOM) {
930 if (mCurrentCellY >= mActionItem->cellYTop()) { 939 if (mCurrentCellY >= mActionItem->cellYTop()) {
931 mActionItem->expandBottom(gy - mCurrentCellY); 940 mActionItem->expandBottom(gy - mCurrentCellY);
932 mActionItem->resize(mActionItem->width(), 941 mActionItem->resize(mActionItem->width(),
933 mGridSpacingY * mActionItem->cellHeight()); 942 mGridSpacingY * mActionItem->cellHeight());
934 } 943 }
935 } else if (mActionType == RESIZELEFT) { 944 } else if (mActionType == RESIZELEFT) {
936 if (mCurrentCellX <= mActionItem->cellXWidth()) { 945 if (mCurrentCellX <= mActionItem->cellXWidth()) {
937 mActionItem->expandLeft(gx - mCurrentCellX); 946 mActionItem->expandLeft(gx - mCurrentCellX);
938 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 947 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
939 mActionItem->height()); 948 mActionItem->height());
940 int x,y; 949 int x,y;
941 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 950 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
942 moveChild(mActionItem,x,childY(mActionItem)); 951 moveChild(mActionItem,x,childY(mActionItem));
943 } 952 }
944 } else if (mActionType == RESIZERIGHT) { 953 } else if (mActionType == RESIZERIGHT) {
945 if (mCurrentCellX >= mActionItem->cellX()) { 954 if (mCurrentCellX >= mActionItem->cellX()) {
946 mActionItem->expandRight(gx - mCurrentCellX); 955 mActionItem->expandRight(gx - mCurrentCellX);
947 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 956 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
948 mActionItem->height()); 957 mActionItem->height());
949 } 958 }
950 } 959 }
951 mCurrentCellX = gx; 960 mCurrentCellX = gx;
952 mCurrentCellY = gy; 961 mCurrentCellY = gy;
953 } 962 }
954} 963}
955 964
956void KOAgenda::endItemAction() 965void KOAgenda::endItemAction()
957{ 966{
958 967
959 if ( mItemMoved ) { 968 if ( mItemMoved ) {
960 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 969 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
961 if ( !placeItem ) { 970 if ( !placeItem ) {
962 placeItem = mActionItem; 971 placeItem = mActionItem;
963 } 972 }
964 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 973 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
965 Incidence* oldInc = placeItem->incidence(); 974 Incidence* oldInc = placeItem->incidence();
966 placeItem->recreateIncidence(); 975 placeItem->recreateIncidence();
967 emit addToCalSignal(placeItem->incidence(), oldInc ); 976 emit addToCalSignal(placeItem->incidence(), oldInc );
968 } 977 }
969 int type = mActionType; 978 int type = mActionType;
970 if ( mAllDayMode ) 979 if ( mAllDayMode )
971 type = -1; 980 type = -1;
972 KOAgendaItem *modifiedItem = placeItem; 981 KOAgendaItem *modifiedItem = placeItem;
973 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 982 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
974 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 983 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
975 KOAgendaItem *item; 984 KOAgendaItem *item;
976 985
977 if ( placeItem->incidence()->typeID() == todoID ) { 986 if ( placeItem->incidence()->typeID() == todoID ) {
978 mSelectedItem = 0; 987 mSelectedItem = 0;
979 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 988 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
980 modifiedItem->mLastMoveXPos = mCurrentCellX; 989 modifiedItem->mLastMoveXPos = mCurrentCellX;
981 emit itemModified( modifiedItem, mActionType ); 990 emit itemModified( modifiedItem, mActionType );
982 } 991 }
983 else { 992 else {
984 993
985 994
986 globalFlagBlockAgendaItemPaint = 1; 995 globalFlagBlockAgendaItemPaint = 1;
987 for ( item=oldconflictItems.first(); item != 0; 996 for ( item=oldconflictItems.first(); item != 0;
988 item=oldconflictItems.next() ) { 997 item=oldconflictItems.next() ) {
989 placeSubCells(item); 998 placeSubCells(item);
990 } 999 }
991 while ( placeItem ) { 1000 while ( placeItem ) {
992 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1001 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
993 oldconflictItems = placeItem->conflictItems(); 1002 oldconflictItems = placeItem->conflictItems();
994 for ( item=oldconflictItems.first(); item != 0; 1003 for ( item=oldconflictItems.first(); item != 0;
995 item=oldconflictItems.next() ) { 1004 item=oldconflictItems.next() ) {
996 placeSubCells(item); 1005 placeSubCells(item);
997 } 1006 }
998 placeSubCells( placeItem ); 1007 placeSubCells( placeItem );
999 placeItem = placeItem->nextMultiItem(); 1008 placeItem = placeItem->nextMultiItem();
1000 } 1009 }
1001 globalFlagBlockAgendaItemPaint = 0; 1010 globalFlagBlockAgendaItemPaint = 0;
1002 for ( item=oldconflictItems.first(); item != 0; 1011 for ( item=oldconflictItems.first(); item != 0;
1003 item=oldconflictItems.next() ) { 1012 item=oldconflictItems.next() ) {
1004 globalFlagBlockAgendaItemUpdate = 0; 1013 globalFlagBlockAgendaItemUpdate = 0;
1005 item->repaintMe(); 1014 item->repaintMe();
1006 globalFlagBlockAgendaItemUpdate = 1; 1015 globalFlagBlockAgendaItemUpdate = 1;
1007 item->repaint( false ); 1016 item->repaint( false );
1008 } 1017 }
1009 placeItem = modifiedItem; 1018 placeItem = modifiedItem;
1010 1019
1011 while ( placeItem ) { 1020 while ( placeItem ) {
1012 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1021 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1013 globalFlagBlockAgendaItemUpdate = 0; 1022 globalFlagBlockAgendaItemUpdate = 0;
1014 placeItem->repaintMe(); 1023 placeItem->repaintMe();
1015 globalFlagBlockAgendaItemUpdate = 1; 1024 globalFlagBlockAgendaItemUpdate = 1;
1016 placeItem->repaint(false); 1025 placeItem->repaint(false);
1017 placeItem = placeItem->nextMultiItem(); 1026 placeItem = placeItem->nextMultiItem();
1018 } 1027 }
1019 emit itemModified( modifiedItem, mActionType ); 1028 emit itemModified( modifiedItem, mActionType );
1020 1029
1021 1030
1022 placeItem = modifiedItem; 1031 placeItem = modifiedItem;
1023 while ( placeItem ) { 1032 while ( placeItem ) {
1024 oldconflictItems = placeItem->conflictItems(); 1033 oldconflictItems = placeItem->conflictItems();
1025 for ( item=oldconflictItems.first(); item != 0; 1034 for ( item=oldconflictItems.first(); item != 0;
1026 item=oldconflictItems.next() ) { 1035 item=oldconflictItems.next() ) {
1027 placeSubCells(item); 1036 placeSubCells(item);
1028 } 1037 }
1029 placeSubCells( placeItem ); 1038 placeSubCells( placeItem );
1030 placeItem = placeItem->nextMultiItem(); 1039 placeItem = placeItem->nextMultiItem();
1031 1040
1032 } 1041 }
1033 placeItem = modifiedItem; 1042 placeItem = modifiedItem;
1034 while ( placeItem ) { 1043 while ( placeItem ) {
1035 oldconflictItems = placeItem->conflictItems(); 1044 oldconflictItems = placeItem->conflictItems();
1036 for ( item=oldconflictItems.first(); item != 0; 1045 for ( item=oldconflictItems.first(); item != 0;
1037 item=oldconflictItems.next() ) { 1046 item=oldconflictItems.next() ) {
1038 globalFlagBlockAgendaItemUpdate = 0; 1047 globalFlagBlockAgendaItemUpdate = 0;
1039 item->repaintMe(); 1048 item->repaintMe();
1040 globalFlagBlockAgendaItemUpdate = 1; 1049 globalFlagBlockAgendaItemUpdate = 1;
1041 item->repaint(false); 1050 item->repaint(false);
1042 } 1051 }
1043 placeItem = placeItem->nextMultiItem(); 1052 placeItem = placeItem->nextMultiItem();
1044 } 1053 }
1045 /* 1054 /*
1046 1055
1047 oldconflictItems = modifiedItem->conflictItems(); 1056 oldconflictItems = modifiedItem->conflictItems();
1048 for ( item=oldconflictItems.first(); item != 0; 1057 for ( item=oldconflictItems.first(); item != 0;
1049 item=oldconflictItems.next() ) { 1058 item=oldconflictItems.next() ) {
1050 globalFlagBlockAgendaItemUpdate = 0; 1059 globalFlagBlockAgendaItemUpdate = 0;
1051 item->paintMe(false); 1060 item->paintMe(false);
1052 globalFlagBlockAgendaItemUpdate = 1; 1061 globalFlagBlockAgendaItemUpdate = 1;
1053 item->repaint(false); 1062 item->repaint(false);
1054 } 1063 }
1055 */ 1064 */
1056 1065
1057 1066
1058 } 1067 }
1059 1068
1060 } 1069 }
1061 1070
1062 mScrollUpTimer.stop(); 1071 mScrollUpTimer.stop();
1063 mScrollDownTimer.stop(); 1072 mScrollDownTimer.stop();
1064 setCursor( arrowCursor ); 1073 setCursor( arrowCursor );
1065 mActionItem = 0; 1074 mActionItem = 0;
1066 mActionType = NOP; 1075 mActionType = NOP;
1067 mItemMoved = 0; 1076 mItemMoved = 0;
1068 1077
1069} 1078}
1070 1079
1071void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 1080void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1072{ 1081{
1073// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 1082// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
1074// QPoint point = viewport()->mapToGlobal(viewportPos); 1083// QPoint point = viewport()->mapToGlobal(viewportPos);
1075// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 1084// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
1076// point = clipper()->mapFromGlobal(point); 1085// point = clipper()->mapFromGlobal(point);
1077// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 1086// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
1078 1087
1079 int x,y; 1088 int x,y;
1080 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 1089 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
1081// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 1090// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
1082 int gx,gy; 1091 int gx,gy;
1083 contentsToGrid(x,y,gx,gy); 1092 contentsToGrid(x,y,gx,gy);
1084 1093
1085 // Change cursor to resize cursor if appropriate 1094 // Change cursor to resize cursor if appropriate
1086 if (mAllDayMode) { 1095 if (mAllDayMode) {
1087 int gridDistanceX = (x - gx * mGridSpacingX); 1096 int gridDistanceX = (x - gx * mGridSpacingX);
1088 if (gridDistanceX < mResizeBorderWidth && 1097 if (gridDistanceX < mResizeBorderWidth &&
1089 moveItem->cellX() == gx) { 1098 moveItem->cellX() == gx) {
1090 setCursor(sizeHorCursor); 1099 setCursor(sizeHorCursor);
1091 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 1100 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
1092 moveItem->cellXWidth() == gx) { 1101 moveItem->cellXWidth() == gx) {
1093 setCursor(sizeHorCursor); 1102 setCursor(sizeHorCursor);
1094 } else { 1103 } else {
1095 setCursor(arrowCursor); 1104 setCursor(arrowCursor);
1096 } 1105 }
1097 } else { 1106 } else {
1098 int gridDistanceY = (y - gy * mGridSpacingY); 1107 int gridDistanceY = (y - gy * mGridSpacingY);
1099 if (gridDistanceY < mResizeBorderWidth && 1108 if (gridDistanceY < mResizeBorderWidth &&
1100 moveItem->cellYTop() == gy && 1109 moveItem->cellYTop() == gy &&
1101 !moveItem->firstMultiItem()) { 1110 !moveItem->firstMultiItem()) {
1102 setCursor(sizeVerCursor); 1111 setCursor(sizeVerCursor);
1103 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 1112 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
1104 moveItem->cellYBottom() == gy && 1113 moveItem->cellYBottom() == gy &&
1105 !moveItem->lastMultiItem()) { 1114 !moveItem->lastMultiItem()) {
1106 setCursor(sizeVerCursor); 1115 setCursor(sizeVerCursor);
1107 } else { 1116 } else {
1108 setCursor(arrowCursor); 1117 setCursor(arrowCursor);
1109 } 1118 }
1110 } 1119 }
1111} 1120}
1112 1121
1113 1122
1114/* 1123/*
1115 Place item in cell and take care that multiple items using the same cell do 1124 Place item in cell and take care that multiple items using the same cell do
1116 not overlap. This method is not yet optimal. It doesn´t use the maximum space 1125 not overlap. This method is not yet optimal. It doesn´t use the maximum space
1117 it can get in all cases. 1126 it can get in all cases.
1118 At the moment the method has a bug: When an item is placed only the sub cell 1127 At the moment the method has a bug: When an item is placed only the sub cell
1119 widths of the items are changed, which are within the Y region the item to 1128 widths of the items are changed, which are within the Y region the item to
1120 place spans. When the sub cell width change of one of this items affects a 1129 place spans. When the sub cell width change of one of this items affects a
1121 cell, where other items are, which do not overlap in Y with the item to place, 1130 cell, where other items are, which do not overlap in Y with the item to place,
1122 the display gets corrupted, although the corruption looks quite nice. 1131 the display gets corrupted, although the corruption looks quite nice.
1123*/ 1132*/
1124void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1133void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1125{ 1134{
1126 1135
1127 QPtrList<KOAgendaItem> conflictItems; 1136 QPtrList<KOAgendaItem> conflictItems;
1128 int maxSubCells = 0; 1137 int maxSubCells = 0;
1129 QIntDict<KOAgendaItem> subCellDict(5); 1138 QIntDict<KOAgendaItem> subCellDict(5);
1130 1139
1131 KOAgendaItem *item; 1140 KOAgendaItem *item;
1132 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1141 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1133 if (item != placeItem) { 1142 if (item != placeItem) {
1134 if (placeItem->cellX() <= item->cellXWidth() && 1143 if (placeItem->cellX() <= item->cellXWidth() &&
1135 placeItem->cellXWidth() >= item->cellX()) { 1144 placeItem->cellXWidth() >= item->cellX()) {
1136 if ((placeItem->cellYTop() <= item->cellYBottom()) && 1145 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
1137 (placeItem->cellYBottom() >= item->cellYTop())) { 1146 (placeItem->cellYBottom() >= item->cellYTop())) {
1138 conflictItems.append(item); 1147 conflictItems.append(item);
1139 if (item->subCells() > maxSubCells) 1148 if (item->subCells() > maxSubCells)
1140 maxSubCells = item->subCells(); 1149 maxSubCells = item->subCells();
1141 subCellDict.insert(item->subCell(),item); 1150 subCellDict.insert(item->subCell(),item);
1142 } 1151 }
1143 } 1152 }
1144 } 1153 }
1145 } 1154 }
1146 1155
1147 if (conflictItems.count() > 0) { 1156 if (conflictItems.count() > 0) {
1148 // Look for unused sub cell and insert item 1157 // Look for unused sub cell and insert item
1149 int i; 1158 int i;
1150 for(i=0;i<maxSubCells;++i) { 1159 for(i=0;i<maxSubCells;++i) {
1151 if (!subCellDict.find(i)) { 1160 if (!subCellDict.find(i)) {
1152 placeItem->setSubCell(i); 1161 placeItem->setSubCell(i);
1153 break; 1162 break;
1154 } 1163 }
1155 } 1164 }
1156 if (i == maxSubCells) { 1165 if (i == maxSubCells) {
1157 placeItem->setSubCell(maxSubCells); 1166 placeItem->setSubCell(maxSubCells);
1158 maxSubCells++; // add new item to number of sub cells 1167 maxSubCells++; // add new item to number of sub cells
1159 } 1168 }
1160 1169
1161 // Prepare for sub cell geometry adjustment 1170 // Prepare for sub cell geometry adjustment
1162 int newSubCellWidth; 1171 int newSubCellWidth;
1163 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1172 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1164 else newSubCellWidth = mGridSpacingX / maxSubCells; 1173 else newSubCellWidth = mGridSpacingX / maxSubCells;
1165 conflictItems.append(placeItem); 1174 conflictItems.append(placeItem);
1166 1175
1167 1176
1168 // Adjust sub cell geometry of all direct conflict items 1177 // Adjust sub cell geometry of all direct conflict items
1169 for ( item=conflictItems.first(); item != 0; 1178 for ( item=conflictItems.first(); item != 0;
1170 item=conflictItems.next() ) { 1179 item=conflictItems.next() ) {
1171 item->setSubCells(maxSubCells); 1180 item->setSubCells(maxSubCells);
1172 if (mAllDayMode) { 1181 if (mAllDayMode) {
1173 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1182 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1174 } else { 1183 } else {
1175 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1184 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1176 } 1185 }
1177 int x,y; 1186 int x,y;
1178 gridToContents(item->cellX(),item->cellYTop(),x,y); 1187 gridToContents(item->cellX(),item->cellYTop(),x,y);
1179 if (mAllDayMode) { 1188 if (mAllDayMode) {
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index fb9983e..de6acac 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -1,300 +1,301 @@
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 78
79 Incidence *selectedIncidence() const; 79 Incidence *selectedIncidence() const;
80 QDate selectedIncidenceDate() const; 80 QDate selectedIncidenceDate() const;
81 81
82 virtual bool eventFilter ( QObject *, QEvent * ); 82 virtual bool eventFilter ( QObject *, QEvent * );
83 83
84 void contentsToGrid (int x, int y, int& gx, int& gy); 84 void contentsToGrid (int x, int y, int& gx, int& gy);
85 void gridToContents (int gx, int gy, int& x, int& y); 85 void gridToContents (int gx, int gy, int& x, int& y);
86 86
87 int timeToY (const QTime &time); 87 int timeToY (const QTime &time);
88 QTime gyToTime (int y); 88 QTime gyToTime (int y);
89 89
90 void setStartHour(int startHour); 90 void setStartHour(int startHour);
91 91
92 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 92 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
93 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 93 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
94 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 94 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
95 int YTop,int YBottom); 95 int YTop,int YBottom);
96 96
97 void changeColumns(int columns); 97 void changeColumns(int columns);
98 98
99 int columns() { return mColumns; } 99 int columns() { return mColumns; }
100 int rows() { return mRows; } 100 int rows() { return mRows; }
101 101
102 int gridSpacingX() const { return mGridSpacingX; } 102 int gridSpacingX() const { return mGridSpacingX; }
103 int gridSpacingY() const { return mGridSpacingY; } 103 int gridSpacingY() const { return mGridSpacingY; }
104 104
105// virtual QSizePolicy sizePolicy() const; 105// virtual QSizePolicy sizePolicy() const;
106 106
107 void clear(); 107 void clear();
108 108
109 void clearSelection(); 109 void clearSelection();
110 void hideUnused(); 110 void hideUnused();
111 111
112 /** Calculates the minimum width */ 112 /** Calculates the minimum width */
113 virtual int minimumWidth() const; 113 virtual int minimumWidth() const;
114 /** Update configuration from preference settings */ 114 /** Update configuration from preference settings */
115 void updateConfig(); 115 void updateConfig();
116 116
117 void checkScrollBoundaries(); 117 void checkScrollBoundaries();
118 118
119 void setHolidayMask(QMemArray<bool> *); 119 void setHolidayMask(QMemArray<bool> *);
120 void setDateList(const DateList &selectedDates); 120 void setDateList(const DateList &selectedDates);
121 DateList dateList() const; 121 DateList dateList() const;
122 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 122 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
123 void finishUpdate(); 123 void finishUpdate();
124 void printSelection(); 124 void printSelection();
125 void storePosition(); 125 void storePosition();
126 void restorePosition(); 126 void restorePosition();
127 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } 127 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; }
128 128
129 public slots: 129 public slots:
130 void categoryChanged(Incidence * inc);
130 void slotClearSelection(); 131 void slotClearSelection();
131 void popupMenu(); 132 void popupMenu();
132 void newItem( int ); 133 void newItem( int );
133 void moveChild( QWidget *, int, int ); 134 void moveChild( QWidget *, int, int );
134 void scrollUp(); 135 void scrollUp();
135 void scrollDown(); 136 void scrollDown();
136 void updateTodo( Todo * t, int , bool ); 137 void updateTodo( Todo * t, int , bool );
137 void popupAlarm(); 138 void popupAlarm();
138 139
139 void checkScrollBoundaries(int); 140 void checkScrollBoundaries(int);
140 141
141 /** Deselect selected items. This function does not emit any signals. */ 142 /** Deselect selected items. This function does not emit any signals. */
142 void deselectItem(); 143 void deselectItem();
143 /** Select item. If the argument is 0, the currently selected item gets 144 /** Select item. If the argument is 0, the currently selected item gets
144 deselected. This function emits the itemSelected(bool) signal to inform 145 deselected. This function emits the itemSelected(bool) signal to inform
145 about selection/deseelction of events. */ 146 about selection/deseelction of events. */
146 void selectItem(KOAgendaItem *); 147 void selectItem(KOAgendaItem *);
147 void finishResize(); 148 void finishResize();
148 149
149 signals: 150 signals:
150 void signalClearSelection(); 151 void signalClearSelection();
151 void showDateView( int, int); 152 void showDateView( int, int);
152 void newEventSignal(); 153 void newEventSignal();
153 void newEventSignal(int gx,int gy); 154 void newEventSignal(int gx,int gy);
154 void newTodoSignal(int gx,int gy); 155 void newTodoSignal(int gx,int gy);
155 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 156 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
156 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 157 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
157 void newStartSelectSignal(); 158 void newStartSelectSignal();
158 void showIncidenceSignal(Incidence *); 159 void showIncidenceSignal(Incidence *);
159 void editIncidenceSignal(Incidence *); 160 void editIncidenceSignal(Incidence *);
160 void deleteIncidenceSignal(Incidence *); 161 void deleteIncidenceSignal(Incidence *);
161 void showIncidencePopupSignal(Incidence *); 162 void showIncidencePopupSignal(Incidence *);
162 163
163 void itemModified(KOAgendaItem *item, int ); 164 void itemModified(KOAgendaItem *item, int );
164 void incidenceSelected(Incidence *); 165 void incidenceSelected(Incidence *);
165 166
166 void lowerYChanged(int); 167 void lowerYChanged(int);
167 void upperYChanged(int); 168 void upperYChanged(int);
168 169
169 void startDragSignal(Incidence *); 170 void startDragSignal(Incidence *);
170 void addToCalSignal(Incidence *, Incidence *); 171 void addToCalSignal(Incidence *, Incidence *);
171 void resizedSignal(); 172 void resizedSignal();
172 173
173 protected: 174 protected:
174 KOEventPopupMenu * mAllAgendaPopup; 175 KOEventPopupMenu * mAllAgendaPopup;
175 QPainter mPixPainter; 176 QPainter mPixPainter;
176 QPixmap mPaintPixmap; 177 QPixmap mPaintPixmap;
177 QPixmap mHighlightPixmap; 178 QPixmap mHighlightPixmap;
178 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 179 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
179 virtual void resizeEvent ( QResizeEvent * ); 180 virtual void resizeEvent ( QResizeEvent * );
180 181
181 /** Handles mouse events. Called from eventFilter */ 182 /** Handles mouse events. Called from eventFilter */
182 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 183 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
183 184
184 /** Start selecting time span. */ 185 /** Start selecting time span. */
185 void startSelectAction(QPoint viewportPos); 186 void startSelectAction(QPoint viewportPos);
186 187
187 /** Select time span. */ 188 /** Select time span. */
188 void performSelectAction(QPoint viewportPos); 189 void performSelectAction(QPoint viewportPos);
189 190
190 /** Emd selecting time span. */ 191 /** Emd selecting time span. */
191 void endSelectAction( bool emitNewEvent = false ); 192 void endSelectAction( bool emitNewEvent = false );
192 193
193 /** Start moving/resizing agenda item */ 194 /** Start moving/resizing agenda item */
194 void startItemAction(QPoint viewportPos); 195 void startItemAction(QPoint viewportPos);
195 196
196 /** Move/resize agenda item */ 197 /** Move/resize agenda item */
197 void performItemAction(QPoint viewportPos); 198 void performItemAction(QPoint viewportPos);
198 199
199 /** End moving/resizing agenda item */ 200 /** End moving/resizing agenda item */
200 void endItemAction(); 201 void endItemAction();
201 202
202 /** Set cursor, when no item action is in progress */ 203 /** Set cursor, when no item action is in progress */
203 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 204 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
204 205
205 /** Place agenda item in agenda and adjust other cells if necessary */ 206 /** Place agenda item in agenda and adjust other cells if necessary */
206 void placeSubCells(KOAgendaItem *placeItem); 207 void placeSubCells(KOAgendaItem *placeItem);
207 208
208 /** Process the keyevent, including the ignored keyevents of eventwidgets. 209 /** Process the keyevent, including the ignored keyevents of eventwidgets.
209 * Implements pgup/pgdn and cursor key navigation in the view. 210 * Implements pgup/pgdn and cursor key navigation in the view.
210 */ 211 */
211 void keyPressEvent( QKeyEvent * ); 212 void keyPressEvent( QKeyEvent * );
212 213
213 void calculateWorkingHours(); 214 void calculateWorkingHours();
214 215
215 virtual void contentsMousePressEvent ( QMouseEvent * ); 216 virtual void contentsMousePressEvent ( QMouseEvent * );
216 217
217 private: 218 private:
218 void init(); 219 void init();
219 void marcus_bains(); 220 void marcus_bains();
220 bool mAllDayMode; 221 bool mAllDayMode;
221 bool blockResize; 222 bool blockResize;
222 bool mLeftMouseDown; 223 bool mLeftMouseDown;
223 KOAgendaItem *mPopupItem; 224 KOAgendaItem *mPopupItem;
224 QTimer* mPopupTimer; 225 QTimer* mPopupTimer;
225 int mPopupKind; 226 int mPopupKind;
226 QPoint mPopupPos; 227 QPoint mPopupPos;
227 QTimer mResizeTimer; 228 QTimer mResizeTimer;
228 double mContentPosition; 229 double mContentPosition;
229 230
230 // Width and height of agenda cells 231 // Width and height of agenda cells
231 int mGridSpacingX; 232 int mGridSpacingX;
232 int mGridSpacingY; 233 int mGridSpacingY;
233 234
234 // size of border, where mouse action will resize the KOAgendaItem 235 // size of border, where mouse action will resize the KOAgendaItem
235 int mResizeBorderWidth; 236 int mResizeBorderWidth;
236 237
237 // size of border, where mouse mve will cause a scroll of the agenda 238 // size of border, where mouse mve will cause a scroll of the agenda
238 int mScrollBorderWidth; 239 int mScrollBorderWidth;
239 int mScrollDelay; 240 int mScrollDelay;
240 int mScrollOffset; 241 int mScrollOffset;
241 242
242 QTimer mScrollUpTimer; 243 QTimer mScrollUpTimer;
243 QTimer mScrollDownTimer; 244 QTimer mScrollDownTimer;
244 245
245 // Number of Columns/Rows of agenda grid 246 // Number of Columns/Rows of agenda grid
246 int mColumns; 247 int mColumns;
247 int mRows; 248 int mRows;
248 249
249 // Cells to store Move and Resize coordiantes 250 // Cells to store Move and Resize coordiantes
250 int mStartCellX; 251 int mStartCellX;
251 int mStartCellY; 252 int mStartCellY;
252 int mCurrentCellX; 253 int mCurrentCellX;
253 int mCurrentCellY; 254 int mCurrentCellY;
254 255
255 // Working Hour coordiantes 256 // Working Hour coordiantes
256 bool mWorkingHoursEnable; 257 bool mWorkingHoursEnable;
257 int mWorkingHoursYTop; 258 int mWorkingHoursYTop;
258 int mWorkingHoursYBottom; 259 int mWorkingHoursYBottom;
259 260
260 // Selection 261 // Selection
261 int mSelectionCellX; 262 int mSelectionCellX;
262 int mSelectionYTop; 263 int mSelectionYTop;
263 int mSelectionHeight; 264 int mSelectionHeight;
264 265
265 // List of dates to be displayed 266 // List of dates to be displayed
266 DateList mSelectedDates; 267 DateList mSelectedDates;
267 268
268 // The KOAgendaItem, which has been right-clicked last 269 // The KOAgendaItem, which has been right-clicked last
269 KOAgendaItem *mClickedItem; 270 KOAgendaItem *mClickedItem;
270 271
271 // The KOAgendaItem, which is being moved/resized 272 // The KOAgendaItem, which is being moved/resized
272 QGuardedPtr<KOAgendaItem> mActionItem; 273 QGuardedPtr<KOAgendaItem> mActionItem;
273 274
274 // Currently selected item 275 // Currently selected item
275 QGuardedPtr<KOAgendaItem> mSelectedItem; 276 QGuardedPtr<KOAgendaItem> mSelectedItem;
276 277
277 // The Marcus Bains Line widget. 278 // The Marcus Bains Line widget.
278 MarcusBains *mMarcusBains; 279 MarcusBains *mMarcusBains;
279 void computeSizes(); 280 void computeSizes();
280 281
281 MouseActionType mActionType; 282 MouseActionType mActionType;
282 283
283 bool mItemMoved; 284 bool mItemMoved;
284 285
285 // List of all Items contained in agenda 286 // List of all Items contained in agenda
286 QPtrList<KOAgendaItem> mItems; 287 QPtrList<KOAgendaItem> mItems;
287 QPtrList<KOAgendaItem> mUnusedItems; 288 QPtrList<KOAgendaItem> mUnusedItems;
288 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); 289 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport);
289 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems 290 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems
290 QPopupMenu *mNewItemPopup; 291 QPopupMenu *mNewItemPopup;
291 292
292 int mOldLowerScrollValue; 293 int mOldLowerScrollValue;
293 int mOldUpperScrollValue; 294 int mOldUpperScrollValue;
294 KOAgendaItem * getItemForTodo ( Todo * todo ); 295 KOAgendaItem * getItemForTodo ( Todo * todo );
295 QMemArray<bool> *mHolidayMask; 296 QMemArray<bool> *mHolidayMask;
296 int mCurPixWid; 297 int mCurPixWid;
297 int mCurPixHei; 298 int mCurPixHei;
298}; 299};
299 300
300#endif // KOAGENDA_H 301#endif // KOAGENDA_H
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index a8e0678..a42d07b 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,829 +1,833 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qlabel.h> 20#include <qlabel.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qhbox.h> 22#include <qhbox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qwhatsthis.h> 25#include <qwhatsthis.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qpainter.h> 28#include <qpainter.h>
29 29
30#include <kiconloader.h> 30#include <kiconloader.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#define AGENDA_ICON_SIZE 5 36#define AGENDA_ICON_SIZE 5
37#else 37#else
38#include <qapplication.h> 38#include <qapplication.h>
39#define AGENDA_ICON_SIZE 7 39#define AGENDA_ICON_SIZE 7
40#endif 40#endif
41#include <libkcal/icaldrag.h> 41#include <libkcal/icaldrag.h>
42#include <libkcal/vcaldrag.h> 42#include <libkcal/vcaldrag.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44extern int globalFlagBlockAgenda; 44extern int globalFlagBlockAgenda;
45extern int globalFlagBlockAgendaItemPaint; 45extern int globalFlagBlockAgendaItemPaint;
46extern int globalFlagBlockAgendaItemUpdate; 46extern int globalFlagBlockAgendaItemUpdate;
47 47
48#include "koprefs.h" 48#include "koprefs.h"
49 49
50#include "koagendaitem.h" 50#include "koagendaitem.h"
51//#include "koagendaitem.moc" 51//#include "koagendaitem.moc"
52 52
53 53
54//-------------------------------------------------------------------------- 54//--------------------------------------------------------------------------
55 55
56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
57 57
58//-------------------------------------------------------------------------- 58//--------------------------------------------------------------------------
59 59
60class KOAgendaItemWhatsThis :public QWhatsThis 60class KOAgendaItemWhatsThis :public QWhatsThis
61{ 61{
62public: 62public:
63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
64 64
65protected: 65protected:
66 virtual QString text( const QPoint& ) 66 virtual QString text( const QPoint& )
67 { 67 {
68 return _view->getWhatsThisText() ; 68 return _view->getWhatsThisText() ;
69 } 69 }
70private: 70private:
71 KOAgendaItem * _view; 71 KOAgendaItem * _view;
72}; 72};
73 73
74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
75 const char *name,WFlags) : 75 const char *name,WFlags) :
76 QWidget(parent, name), mIncidence(incidence), mDate(qd) 76 QWidget(parent, name), mIncidence(incidence), mDate(qd)
77{ 77{
78#ifndef DESKTOP_VERSION 78#ifndef DESKTOP_VERSION
79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
80#endif 80#endif
81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); 81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this);
82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
83 setWFlags ( wflags); 83 setWFlags ( wflags);
84 mAllDay = allday; 84 mAllDay = allday;
85 init ( incidence, qd ); 85 init ( incidence, qd );
86 //setMouseTracking(true); 86 //setMouseTracking(true);
87 //setAcceptDrops(true); 87 //setAcceptDrops(true);
88 xPaintCoord = -1; 88 xPaintCoord = -1;
89 yPaintCoord = -1; 89 yPaintCoord = -1;
90} 90}
91QString KOAgendaItem::getWhatsThisText() 91QString KOAgendaItem::getWhatsThisText()
92{ 92{
93 if ( mIncidence ) 93 if ( mIncidence )
94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence, 94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
95 KOPrefs::instance()->mWTshowDetails, 95 KOPrefs::instance()->mWTshowDetails,
96 KOPrefs::instance()->mWTshowCreated, 96 KOPrefs::instance()->mWTshowCreated,
97 KOPrefs::instance()->mWTshowChanged); 97 KOPrefs::instance()->mWTshowChanged);
98 return "KOAgendaItem::getWhatsThisText()::internal error"; 98 return "KOAgendaItem::getWhatsThisText()::internal error";
99} 99}
100void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 100
101void KOAgendaItem::initColor ()
101{ 102{
102 mIncidence = incidence; 103 if ( (mIncidence->typeID() == todoID ) &&
103 mDate = qd; 104 ( !((static_cast<Todo*>(mIncidence))->isCompleted()) &&
104 mFirstMultiItem = 0; 105 ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) {
105 mNextMultiItem = 0; 106 if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date())
106 mLastMultiItem = 0;
107 computeText();
108
109 if ( (incidence->typeID() == todoID ) &&
110 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
111 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
112 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
113 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 107 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
114 else 108 else
115 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 109 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
116 } 110 }
117 else { 111 else {
118 QStringList categories = mIncidence->categories(); 112 QStringList categories = mIncidence->categories();
119 QString cat = categories.first(); 113 QString cat = categories.first();
120 if (cat.isEmpty()) { 114 if (cat.isEmpty()) {
121 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) 115 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) )
122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 116 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
123 else 117 else
124 mBackgroundColor =KOPrefs::instance()->defaultColor( incidence->calID() ); 118 mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() );
125 } else { 119 } else {
126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 120 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
127 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 121 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) {
128 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 122 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
129 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; 123 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor;
130 } 124 }
131 } 125 }
132 126
133 } 127 }
134 128
135 QColor BackgroundColor ( mBackgroundColor ); 129 QColor BackgroundColor ( mBackgroundColor );
136 if ( mIncidence->calID() > 1 ) { 130 if ( mIncidence->calID() > 1 ) {
137 BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); 131 BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() );
138 } 132 }
139 mColorGroup = QColorGroup( BackgroundColor.light(), 133 mColorGroup = QColorGroup( BackgroundColor.light(),
140 BackgroundColor.dark(),BackgroundColor.light(), 134 BackgroundColor.dark(),BackgroundColor.light(),
141 BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; 135 BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ;
142 setBackgroundColor( mBackgroundColor ); 136 setBackgroundColor( mBackgroundColor );
143 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); 137 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250);
138}
139void KOAgendaItem::init ( Incidence *incidence, QDate qd )
140{
141 mIncidence = incidence;
142 mDate = qd;
143 mFirstMultiItem = 0;
144 mNextMultiItem = 0;
145 mLastMultiItem = 0;
146 computeText();
147 initColor();
144 mConflictItems.clear(); 148 mConflictItems.clear();
145 setCellXY(0,0,1); 149 setCellXY(0,0,1);
146 setCellXWidth(0); 150 setCellXWidth(0);
147 setSubCell(0); 151 setSubCell(0);
148 setSubCells(1); 152 setSubCells(1);
149 setMultiItem(0,0,0); 153 setMultiItem(0,0,0);
150 startMove(); 154 startMove();
151 mSelected = true; 155 mSelected = true;
152 select(false); 156 select(false);
153 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 157 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
154 mFontPixelSize = fontinf.height();; 158 mFontPixelSize = fontinf.height();;
155 hide(); 159 hide();
156 xPaintCoord = -1; 160 xPaintCoord = -1;
157 yPaintCoord = -1; 161 yPaintCoord = -1;
158} 162}
159 163
160 164
161KOAgendaItem::~KOAgendaItem() 165KOAgendaItem::~KOAgendaItem()
162{ 166{
163#if QT_VERSION >= 0x030000 167#if QT_VERSION >= 0x030000
164 168
165#else 169#else
166 delete mKOAgendaItemWhatsThis; 170 delete mKOAgendaItemWhatsThis;
167#endif 171#endif
168 172
169} 173}
170 174
171void KOAgendaItem::recreateIncidence() 175void KOAgendaItem::recreateIncidence()
172{ 176{
173#if 0 177#if 0
174 Incidence* newInc = mIncidence->clone(); 178 Incidence* newInc = mIncidence->clone();
175 newInc->recreate(); 179 newInc->recreate();
176 if ( mIncidence->doesRecur() ) { 180 if ( mIncidence->doesRecur() ) {
177 mIncidence->addExDate( mDate ); 181 mIncidence->addExDate( mDate );
178 newInc->recurrence()->unsetRecurs(); 182 newInc->recurrence()->unsetRecurs();
179 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 183 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
180 QTime tim = mIncidence->dtStart().time(); 184 QTime tim = mIncidence->dtStart().time();
181 newInc->setDtStart( QDateTime(mDate, tim) ); 185 newInc->setDtStart( QDateTime(mDate, tim) );
182 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 186 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
183 } 187 }
184#endif 188#endif
185 mIncidence = mIncidence->recreateCloneException( mDate ); 189 mIncidence = mIncidence->recreateCloneException( mDate );
186} 190}
187bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 191bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
188{ 192{
189 int size = AGENDA_ICON_SIZE; 193 int size = AGENDA_ICON_SIZE;
190 194
191 int yOff = 0; 195 int yOff = 0;
192 int xOff = 0; 196 int xOff = 0;
193 int x = pos().x() +3; 197 int x = pos().x() +3;
194 int y; 198 int y;
195 if ( mAllDay ) 199 if ( mAllDay )
196 y = pos().y()+3; 200 y = pos().y()+3;
197 else 201 else
198 y = mCellYTop * ( height() / cellHeight() ) +3; 202 y = mCellYTop * ( height() / cellHeight() ) +3;
199 if (mIncidence->cancelled()) { 203 if (mIncidence->cancelled()) {
200 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 204 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
201 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 205 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
202 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 206 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
203 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 207 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
204 if ( horLayout ) 208 if ( horLayout )
205 ++xOff; 209 ++xOff;
206 else 210 else
207 ++yOff; 211 ++yOff;
208 } 212 }
209 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { 213 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) {
210 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 214 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
211 if ( horLayout ) 215 if ( horLayout )
212 ++xOff; 216 ++xOff;
213 else 217 else
214 ++yOff; 218 ++yOff;
215 } 219 }
216 if (mIncidence->recurrence()->doesRecur()) { 220 if (mIncidence->recurrence()->doesRecur()) {
217 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
218 if ( horLayout ) 222 if ( horLayout )
219 ++xOff; 223 ++xOff;
220 else 224 else
221 ++yOff; 225 ++yOff;
222 } 226 }
223 if (mIncidence->description().length() > 0) { 227 if (mIncidence->description().length() > 0) {
224 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 228 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
225 if ( horLayout ) 229 if ( horLayout )
226 ++xOff; 230 ++xOff;
227 else 231 else
228 ++yOff; 232 ++yOff;
229 } 233 }
230 if (mIncidence->isReadOnly()) { 234 if (mIncidence->isReadOnly()) {
231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 235 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
232 if ( horLayout ) 236 if ( horLayout )
233 ++xOff; 237 ++xOff;
234 else 238 else
235 ++yOff; 239 ++yOff;
236 } 240 }
237 241
238 if (mIncidence->attendeeCount()>0) { 242 if (mIncidence->attendeeCount()>0) {
239 243
240 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 244 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
241 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 245 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
242 if ( horLayout ) 246 if ( horLayout )
243 ++xOff; 247 ++xOff;
244 else 248 else
245 ++yOff; 249 ++yOff;
246 } else { 250 } else {
247 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 251 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
248 if (me!=0) { 252 if (me!=0) {
249 253
250 254
251 } else { 255 } else {
252 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 256 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
253 if ( horLayout ) 257 if ( horLayout )
254 ++xOff; 258 ++xOff;
255 else 259 else
256 ++yOff; 260 ++yOff;
257 261
258 } 262 }
259 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 263 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
260 if ( horLayout ) 264 if ( horLayout )
261 ++xOff; 265 ++xOff;
262 else 266 else
263 ++yOff; 267 ++yOff;
264 268
265 } 269 }
266 270
267 } 271 }
268 return ( yOff || xOff ); 272 return ( yOff || xOff );
269} 273}
270 274
271 275
272void KOAgendaItem::select(bool selected) 276void KOAgendaItem::select(bool selected)
273{ 277{
274 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 278 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
275 if (mSelected == selected) return; 279 if (mSelected == selected) return;
276 mSelected = selected; 280 mSelected = selected;
277 if ( ! isVisible() ) 281 if ( ! isVisible() )
278 return; 282 return;
279 if ( firstMultiItem() ) 283 if ( firstMultiItem() )
280 firstMultiItem()->select( selected ); 284 firstMultiItem()->select( selected );
281 if ( !firstMultiItem() && nextMultiItem() ) { 285 if ( !firstMultiItem() && nextMultiItem() ) {
282 KOAgendaItem * placeItem = nextMultiItem(); 286 KOAgendaItem * placeItem = nextMultiItem();
283 while ( placeItem ) { 287 while ( placeItem ) {
284 placeItem->select( selected ); 288 placeItem->select( selected );
285 placeItem = placeItem->nextMultiItem(); 289 placeItem = placeItem->nextMultiItem();
286 } 290 }
287 } 291 }
288 globalFlagBlockAgendaItemUpdate = 0; 292 globalFlagBlockAgendaItemUpdate = 0;
289 paintMe( selected ); 293 paintMe( selected );
290 globalFlagBlockAgendaItemUpdate = 1; 294 globalFlagBlockAgendaItemUpdate = 1;
291 repaint( false ); 295 repaint( false );
292} 296}
293 297
294 298
295/* 299/*
296 The eventFilter has to filter the mouse events of the agenda item childs. The 300 The eventFilter has to filter the mouse events of the agenda item childs. The
297 events are fed into the event handling method of KOAgendaItem. This allows the 301 events are fed into the event handling method of KOAgendaItem. This allows the
298 KOAgenda to handle the KOAgendaItems by using an eventFilter. 302 KOAgenda to handle the KOAgendaItems by using an eventFilter.
299*/ 303*/
300bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 304bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
301{ 305{
302 if (e->type() == QEvent::MouseButtonPress || 306 if (e->type() == QEvent::MouseButtonPress ||
303 e->type() == QEvent::MouseButtonDblClick || 307 e->type() == QEvent::MouseButtonDblClick ||
304 e->type() == QEvent::MouseButtonRelease || 308 e->type() == QEvent::MouseButtonRelease ||
305 e->type() == QEvent::MouseMove) { 309 e->type() == QEvent::MouseMove) {
306 QMouseEvent *me = (QMouseEvent *)e; 310 QMouseEvent *me = (QMouseEvent *)e;
307 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 311 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
308 mapToGlobal(me->pos())); 312 mapToGlobal(me->pos()));
309 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 313 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
310 return event(&returnEvent); 314 return event(&returnEvent);
311 } else { 315 } else {
312 return false; 316 return false;
313 } 317 }
314} 318}
315void KOAgendaItem::repaintMe( ) 319void KOAgendaItem::repaintMe( )
316{ 320{
317 paintMe ( mSelected ); 321 paintMe ( mSelected );
318} 322}
319void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 323void KOAgendaItem::paintMe( bool selected, QPainter* paint )
320{ 324{
321 if ( globalFlagBlockAgendaItemUpdate && ! selected) 325 if ( globalFlagBlockAgendaItemUpdate && ! selected)
322 return; 326 return;
323 QPainter pa; 327 QPainter pa;
324 328
325 if ( mSelected ) { 329 if ( mSelected ) {
326 pa.begin( paintPixSel() ); 330 pa.begin( paintPixSel() );
327 } else { 331 } else {
328 if ( mAllDay ) 332 if ( mAllDay )
329 pa.begin( paintPixAllday() ); 333 pa.begin( paintPixAllday() );
330 else 334 else
331 pa.begin( paintPix() ); 335 pa.begin( paintPix() );
332 } 336 }
333 int x, yy, w, h; 337 int x, yy, w, h;
334 float nfh = 7.0; 338 float nfh = 7.0;
335 x = pos().x(); w = width(); h = height (); 339 x = pos().x(); w = width(); h = height ();
336 if ( mAllDay ) 340 if ( mAllDay )
337 yy = y(); 341 yy = y();
338 else 342 else
339 yy = mCellYTop * ( height() / cellHeight() ); 343 yy = mCellYTop * ( height() / cellHeight() );
340 xPaintCoord= x; 344 xPaintCoord= x;
341 yPaintCoord = yy; 345 yPaintCoord = yy;
342 wPaintCoord = width(); 346 wPaintCoord = width();
343 hPaintCoord = height(); 347 hPaintCoord = height();
344 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 348 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
345 if ( paint == 0 ) 349 if ( paint == 0 )
346 paint = &pa; 350 paint = &pa;
347 bool horLayout = ( w < h ); 351 bool horLayout = ( w < h );
348 int maxhei = mFontPixelSize+4; 352 int maxhei = mFontPixelSize+4;
349 if ( horLayout ) 353 if ( horLayout )
350 maxhei += AGENDA_ICON_SIZE -4; 354 maxhei += AGENDA_ICON_SIZE -4;
351 bool small = ( h < maxhei ); 355 bool small = ( h < maxhei );
352 if ( ! small ) 356 if ( ! small )
353 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 357 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
354 else { 358 else {
355 QFont f = KOPrefs::instance()->mAgendaViewFont; 359 QFont f = KOPrefs::instance()->mAgendaViewFont;
356 f.setBold( false ); 360 f.setBold( false );
357 int fh = f.pointSize(); 361 int fh = f.pointSize();
358 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 362 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
359 if ( nfh < 6 ) 363 if ( nfh < 6 )
360 nfh = 6; 364 nfh = 6;
361 f.setPointSize( nfh ); 365 f.setPointSize( nfh );
362 paint->setFont(f); 366 paint->setFont(f);
363 } 367 }
364 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 368 paint->fillRect ( x, yy, w, h, mBackgroundColor );
365 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 369 static const QPixmap completedPxmp = SmallIcon("greenhook16");
366 static const QPixmap overduePxmp = SmallIcon("redcross16"); 370 static const QPixmap overduePxmp = SmallIcon("redcross16");
367 if ( mIncidence->typeID() == todoID ) { 371 if ( mIncidence->typeID() == todoID ) {
368 Todo* tempTodo = static_cast<Todo*>(mIncidence); 372 Todo* tempTodo = static_cast<Todo*>(mIncidence);
369 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 373 int xx = pos().x()+(width()-completedPxmp.width()-3 );
370 int yyy = yy+3; 374 int yyy = yy+3;
371 if ( tempTodo->isCompleted() ) 375 if ( tempTodo->isCompleted() )
372 paint->drawPixmap ( xx, yyy, completedPxmp ); 376 paint->drawPixmap ( xx, yyy, completedPxmp );
373 else { 377 else {
374 paint->drawPixmap ( xx, yyy, overduePxmp ); 378 paint->drawPixmap ( xx, yyy, overduePxmp );
375 379
376 } 380 }
377 } 381 }
378 bool addIcon = false; 382 bool addIcon = false;
379 if ( ! small || w > 3 * h || h > 3* w ) 383 if ( ! small || w > 3 * h || h > 3* w )
380 addIcon = updateIcons( paint, horLayout ); 384 addIcon = updateIcons( paint, horLayout );
381 385
382 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 386 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
383 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); 387 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0);
384 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 388 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
385 if ( ! small ) { 389 if ( ! small ) {
386 x += 3; yy += 3;w -= 6; h-= 5; 390 x += 3; yy += 3;w -= 6; h-= 5;
387 } else { 391 } else {
388 x += 2; yy += 1;w -= 4; h-= 4; 392 x += 2; yy += 1;w -= 4; h-= 4;
389 if ( nfh < 6.01 ) { 393 if ( nfh < 6.01 ) {
390 yy -= 2; 394 yy -= 2;
391 h += 4; 395 h += 4;
392 } 396 }
393 else 397 else
394 if ( nfh < h -2 ) 398 if ( nfh < h -2 )
395 ++yy; 399 ++yy;
396 } 400 }
397 int align; 401 int align;
398#ifndef DESKTOP_VERSION 402#ifndef DESKTOP_VERSION
399 align = ( AlignLeft|WordBreak|AlignTop); 403 align = ( AlignLeft|WordBreak|AlignTop);
400#else 404#else
401 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 405 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
402#endif 406#endif
403 if ( addIcon ) { 407 if ( addIcon ) {
404 if ( ! horLayout ) { 408 if ( ! horLayout ) {
405 x += AGENDA_ICON_SIZE+3; 409 x += AGENDA_ICON_SIZE+3;
406 w -= (AGENDA_ICON_SIZE+3); 410 w -= (AGENDA_ICON_SIZE+3);
407 } 411 }
408 else { 412 else {
409 yy+= AGENDA_ICON_SIZE+2; 413 yy+= AGENDA_ICON_SIZE+2;
410 h -=(AGENDA_ICON_SIZE+3); 414 h -=(AGENDA_ICON_SIZE+3);
411 } 415 }
412 } 416 }
413 if ( mWhiteText ) 417 if ( mWhiteText )
414 paint->setPen ( white); 418 paint->setPen ( white);
415 if ( x < 0 ) { 419 if ( x < 0 ) {
416 w = w+x-3; 420 w = w+x-3;
417 x = 3; 421 x = 3;
418 if ( w > parentWidget()->width() ){ 422 if ( w > parentWidget()->width() ){
419 w = parentWidget()->width() - 6; 423 w = parentWidget()->width() - 6;
420#ifndef DESKTOP_VERSION 424#ifndef DESKTOP_VERSION
421 align = ( AlignHCenter|WordBreak|AlignTop); 425 align = ( AlignHCenter|WordBreak|AlignTop);
422#else 426#else
423 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 427 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
424#endif 428#endif
425 429
426 } 430 }
427 } 431 }
428 QRect dr; 432 QRect dr;
429 if ( w + x > parentWidget()->width() ) 433 if ( w + x > parentWidget()->width() )
430 w = parentWidget()->width()-x; 434 w = parentWidget()->width()-x;
431 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 435 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
432 //qDebug("%d %d %d %d ", x, yy, w, h ); 436 //qDebug("%d %d %d %d ", x, yy, w, h );
433 if ( mIncidence->cancelled() ){ 437 if ( mIncidence->cancelled() ){
434 438
435 439
436 small = ( height() < 20 ); 440 small = ( height() < 20 );
437 441
438 if ( ! small ) { 442 if ( ! small ) {
439 QFontMetrics fm ( paint->font() ); 443 QFontMetrics fm ( paint->font() );
440 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 444 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
441 } 445 }
442 446
443 } 447 }
444 pa.end(); 448 pa.end();
445 449
446} 450}
447void KOAgendaItem::resizePixmap( int w , int h ) 451void KOAgendaItem::resizePixmap( int w , int h )
448{ 452{
449 paintPix()->resize( w, h ); 453 paintPix()->resize( w, h );
450 paintPixSel()->resize( w, h ); 454 paintPixSel()->resize( w, h );
451 455
452} 456}
453QPixmap * KOAgendaItem::paintPix() 457QPixmap * KOAgendaItem::paintPix()
454{ 458{
455 static QPixmap* mPaintPix = 0; 459 static QPixmap* mPaintPix = 0;
456 if ( ! mPaintPix ) { 460 if ( ! mPaintPix ) {
457 int w = QApplication::desktop()->width(); 461 int w = QApplication::desktop()->width();
458 int h = QApplication::desktop()->height(); 462 int h = QApplication::desktop()->height();
459 mPaintPix = new QPixmap(w,h); 463 mPaintPix = new QPixmap(w,h);
460 } 464 }
461 return mPaintPix ; 465 return mPaintPix ;
462} 466}
463QPixmap * KOAgendaItem::paintPixAllday() 467QPixmap * KOAgendaItem::paintPixAllday()
464{ 468{
465 static QPixmap* mPaintPixA = 0; 469 static QPixmap* mPaintPixA = 0;
466 if ( ! mPaintPixA ) { 470 if ( ! mPaintPixA ) {
467 int w = QApplication::desktop()->width(); 471 int w = QApplication::desktop()->width();
468 int h = QApplication::desktop()->height()/3; 472 int h = QApplication::desktop()->height()/3;
469 mPaintPixA = new QPixmap(w,h); 473 mPaintPixA = new QPixmap(w,h);
470 } 474 }
471 return mPaintPixA ; 475 return mPaintPixA ;
472} 476}
473QPixmap * KOAgendaItem::paintPixSel() 477QPixmap * KOAgendaItem::paintPixSel()
474{ 478{
475 static QPixmap* mPaintPixSel = 0; 479 static QPixmap* mPaintPixSel = 0;
476 if ( ! mPaintPixSel ) { 480 if ( ! mPaintPixSel ) {
477 int w = QApplication::desktop()->width(); 481 int w = QApplication::desktop()->width();
478 int h = QApplication::desktop()->height(); 482 int h = QApplication::desktop()->height();
479 mPaintPixSel = new QPixmap(w,h); 483 mPaintPixSel = new QPixmap(w,h);
480 } 484 }
481 return mPaintPixSel ; 485 return mPaintPixSel ;
482} 486}
483void KOAgendaItem::paintEvent ( QPaintEvent *e ) 487void KOAgendaItem::paintEvent ( QPaintEvent *e )
484{ 488{
485 489
486 if ( globalFlagBlockAgendaItemPaint ) 490 if ( globalFlagBlockAgendaItemPaint )
487 return; 491 return;
488 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 492 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
489 return; 493 return;
490 int yy; 494 int yy;
491 if ( mAllDay ) 495 if ( mAllDay )
492 yy = y(); 496 yy = y();
493 else 497 else
494 yy = mCellYTop * ( height() / cellHeight() ); 498 yy = mCellYTop * ( height() / cellHeight() );
495 int xx = x(); 499 int xx = x();
496 500
497 if ( xPaintCoord != xx || yPaintCoord != yy || 501 if ( xPaintCoord != xx || yPaintCoord != yy ||
498 wPaintCoord != width() || hPaintCoord != height()) { 502 wPaintCoord != width() || hPaintCoord != height()) {
499 xPaintCoord= xx; 503 xPaintCoord= xx;
500 yPaintCoord = yy; 504 yPaintCoord = yy;
501 wPaintCoord = width(); 505 wPaintCoord = width();
502 hPaintCoord = height(); 506 hPaintCoord = height();
503 globalFlagBlockAgendaItemUpdate = 0; 507 globalFlagBlockAgendaItemUpdate = 0;
504 paintMe( mSelected ); 508 paintMe( mSelected );
505 //qDebug("calling paintMe "); 509 //qDebug("calling paintMe ");
506 globalFlagBlockAgendaItemUpdate = 1; 510 globalFlagBlockAgendaItemUpdate = 1;
507 } 511 }
508 int rx, ry, rw, rh; 512 int rx, ry, rw, rh;
509 rx = e->rect().x(); 513 rx = e->rect().x();
510 ry = e->rect().y(); 514 ry = e->rect().y();
511 rw = e->rect().width(); 515 rw = e->rect().width();
512 rh = e->rect().height(); 516 rh = e->rect().height();
513 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 517 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
514 518
515 QPixmap* paintFrom ; 519 QPixmap* paintFrom ;
516 if ( mSelected ) { 520 if ( mSelected ) {
517 paintFrom = paintPixSel(); 521 paintFrom = paintPixSel();
518 } else { 522 } else {
519 if ( mAllDay ) 523 if ( mAllDay )
520 paintFrom = paintPixAllday(); 524 paintFrom = paintPixAllday();
521 else 525 else
522 paintFrom = paintPix(); 526 paintFrom = paintPix();
523 } 527 }
524 xx += rx; 528 xx += rx;
525 529
526 if ( xx < 0 ) { 530 if ( xx < 0 ) {
527 rw = rw + xx; 531 rw = rw + xx;
528 rx -= xx; 532 rx -= xx;
529 xx = 0; 533 xx = 0;
530 if ( rw <= 1 ) { 534 if ( rw <= 1 ) {
531 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 535 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
532 return; 536 return;
533 } 537 }
534 } 538 }
535 if ( paintFrom->width() < xx+rw ) { 539 if ( paintFrom->width() < xx+rw ) {
536 rw = paintFrom->width() - xx; 540 rw = paintFrom->width() - xx;
537 if ( rw <= 1 ) { 541 if ( rw <= 1 ) {
538 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 542 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
539 return; 543 return;
540 } 544 }
541 } 545 }
542 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 546 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
543 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 547 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
544} 548}
545void KOAgendaItem::computeText() 549void KOAgendaItem::computeText()
546{ 550{
547 mDisplayedText = mIncidence->summary(); 551 mDisplayedText = mIncidence->summary();
548 if ( (mIncidence->typeID() == todoID ) ) { 552 if ( (mIncidence->typeID() == todoID ) ) {
549 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 553 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
550 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 554 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
551 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 555 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
552 else if ( !(mIncidence->doesFloat())) 556 else if ( !(mIncidence->doesFloat()))
553 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 557 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
554 } 558 }
555 } else { 559 } else {
556 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 560 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
557 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 561 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
558 562
559 if ( mAllDay ) { 563 if ( mAllDay ) {
560 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 564 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
561 if ( mIncidence->doesRecur() ) { 565 if ( mIncidence->doesRecur() ) {
562 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; 566 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
563 } else { 567 } else {
564 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 568 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
565 } 569 }
566 } 570 }
567 } 571 }
568 } 572 }
569 573
570 if ( !mIncidence->location().isEmpty() ) { 574 if ( !mIncidence->location().isEmpty() ) {
571 if ( mAllDay ) 575 if ( mAllDay )
572 mDisplayedText += " ("; 576 mDisplayedText += " (";
573 else 577 else
574 mDisplayedText += "\n("; 578 mDisplayedText += "\n(";
575 mDisplayedText += mIncidence->location() +")"; 579 mDisplayedText += mIncidence->location() +")";
576 } 580 }
577#ifdef DESKTOP_VERSION 581#ifdef DESKTOP_VERSION
578 QString tipText = mIncidence->summary(); 582 QString tipText = mIncidence->summary();
579 if ( !mIncidence->doesFloat() ) { 583 if ( !mIncidence->doesFloat() ) {
580 if ( mIncidence->typeID() == eventID ) { 584 if ( mIncidence->typeID() == eventID ) {
581 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 585 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
582 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 586 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
583 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 587 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
584 } 588 }
585 else { 589 else {
586 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 590 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
587 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 591 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
588 } 592 }
589 } 593 }
590 else if ( mIncidence->typeID() == todoID ) { 594 else if ( mIncidence->typeID() == todoID ) {
591 if (mIncidence->hasStartDate()) 595 if (mIncidence->hasStartDate())
592 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 596 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
593 if (((Todo*)mIncidence)->hasDueDate()) 597 if (((Todo*)mIncidence)->hasDueDate())
594 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 598 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
595 } 599 }
596 } else if ( mIncidence->typeID() == todoID ) { 600 } else if ( mIncidence->typeID() == todoID ) {
597 if (mIncidence->hasStartDate()) 601 if (mIncidence->hasStartDate())
598 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 602 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
599 if (((Todo*)mIncidence)->hasDueDate()) 603 if (((Todo*)mIncidence)->hasDueDate())
600 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 604 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
601 } 605 }
602 606
603 if (!mIncidence->location().isEmpty()) { 607 if (!mIncidence->location().isEmpty()) {
604 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 608 tipText += "\n"+i18n("Location: ")+mIncidence->location();
605 } 609 }
606 QToolTip::add(this,tipText,toolTipGroup(),""); 610 QToolTip::add(this,tipText,toolTipGroup(),"");
607#endif 611#endif
608} 612}
609void KOAgendaItem::updateItem() 613void KOAgendaItem::updateItem()
610{ 614{
611 computeText(); 615 computeText();
612 616
613 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 617 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
614 paintMe( mSelected ); 618 paintMe( mSelected );
615 repaint( false); 619 repaint( false);
616} 620}
617 621
618void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 622void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
619{ 623{
620 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 624 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
621 paintMe( mSelected ); 625 paintMe( mSelected );
622 repaint( false ); 626 repaint( false );
623} 627}
624 628
625/* 629/*
626 Return height of item in units of agenda cells 630 Return height of item in units of agenda cells
627*/ 631*/
628int KOAgendaItem::cellHeight() 632int KOAgendaItem::cellHeight()
629{ 633{
630 int ret = mCellYBottom - mCellYTop + 1; 634 int ret = mCellYBottom - mCellYTop + 1;
631 if ( ret <= 0 ) { 635 if ( ret <= 0 ) {
632 ret = 1; 636 ret = 1;
633 mCellYBottom = 0; 637 mCellYBottom = 0;
634 mCellYTop = 0; 638 mCellYTop = 0;
635 } 639 }
636 return ret; 640 return ret;
637} 641}
638 642
639/* 643/*
640 Return height of item in units of agenda cells 644 Return height of item in units of agenda cells
641*/ 645*/
642int KOAgendaItem::cellWidth() 646int KOAgendaItem::cellWidth()
643{ 647{
644 return mCellXWidth - mCellX + 1; 648 return mCellXWidth - mCellX + 1;
645} 649}
646 650
647void KOAgendaItem::setItemDate(QDate qd) 651void KOAgendaItem::setItemDate(QDate qd)
648{ 652{
649 mDate = qd; 653 mDate = qd;
650} 654}
651 655
652void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 656void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
653{ 657{
654 mCellX = X; 658 mCellX = X;
655 mCellYTop = YTop; 659 mCellYTop = YTop;
656 mCellYBottom = YBottom; 660 mCellYBottom = YBottom;
657} 661}
658 662
659void KOAgendaItem::setCellXWidth(int xwidth) 663void KOAgendaItem::setCellXWidth(int xwidth)
660{ 664{
661 mCellXWidth = xwidth; 665 mCellXWidth = xwidth;
662} 666}
663 667
664void KOAgendaItem::setCellX(int XLeft, int XRight) 668void KOAgendaItem::setCellX(int XLeft, int XRight)
665{ 669{
666 mCellX = XLeft; 670 mCellX = XLeft;
667 mCellXWidth = XRight; 671 mCellXWidth = XRight;
668} 672}
669 673
670void KOAgendaItem::setCellY(int YTop, int YBottom) 674void KOAgendaItem::setCellY(int YTop, int YBottom)
671{ 675{
672 mCellYTop = YTop; 676 mCellYTop = YTop;
673 mCellYBottom = YBottom; 677 mCellYBottom = YBottom;
674} 678}
675 679
676void KOAgendaItem::setSubCell(int subCell) 680void KOAgendaItem::setSubCell(int subCell)
677{ 681{
678 mSubCell = subCell; 682 mSubCell = subCell;
679} 683}
680 684
681void KOAgendaItem::setSubCells(int subCells) 685void KOAgendaItem::setSubCells(int subCells)
682{ 686{
683 mSubCells = subCells; 687 mSubCells = subCells;
684} 688}
685 689
686void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 690void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
687 KOAgendaItem *last) 691 KOAgendaItem *last)
688{ 692{
689 mFirstMultiItem = first; 693 mFirstMultiItem = first;
690 mNextMultiItem = next; 694 mNextMultiItem = next;
691 mLastMultiItem = last; 695 mLastMultiItem = last;
692} 696}
693 697
694void KOAgendaItem::startMove() 698void KOAgendaItem::startMove()
695{ 699{
696 mStartCellX = mCellX; 700 mStartCellX = mCellX;
697 mStartCellXWidth = mCellXWidth; 701 mStartCellXWidth = mCellXWidth;
698 mStartCellYTop = mCellYTop; 702 mStartCellYTop = mCellYTop;
699 mStartCellYBottom = mCellYBottom; 703 mStartCellYBottom = mCellYBottom;
700} 704}
701 705
702void KOAgendaItem::resetMove() 706void KOAgendaItem::resetMove()
703{ 707{
704 mCellX = mStartCellX; 708 mCellX = mStartCellX;
705 mCellXWidth = mStartCellXWidth; 709 mCellXWidth = mStartCellXWidth;
706 mCellYTop = mStartCellYTop; 710 mCellYTop = mStartCellYTop;
707 mCellYBottom = mStartCellYBottom; 711 mCellYBottom = mStartCellYBottom;
708} 712}
709 713
710void KOAgendaItem::moveRelative(int dx, int dy) 714void KOAgendaItem::moveRelative(int dx, int dy)
711{ 715{
712 int newX = cellX() + dx; 716 int newX = cellX() + dx;
713 int newXWidth = cellXWidth() + dx; 717 int newXWidth = cellXWidth() + dx;
714 int newYTop = cellYTop() + dy; 718 int newYTop = cellYTop() + dy;
715 int newYBottom = cellYBottom() + dy; 719 int newYBottom = cellYBottom() + dy;
716 setCellXY(newX,newYTop,newYBottom); 720 setCellXY(newX,newYTop,newYBottom);
717 setCellXWidth(newXWidth); 721 setCellXWidth(newXWidth);
718} 722}
719 723
720void KOAgendaItem::expandTop(int dy) 724void KOAgendaItem::expandTop(int dy)
721{ 725{
722 int newYTop = cellYTop() + dy; 726 int newYTop = cellYTop() + dy;
723 int newYBottom = cellYBottom(); 727 int newYBottom = cellYBottom();
724 if (newYTop > newYBottom) newYTop = newYBottom; 728 if (newYTop > newYBottom) newYTop = newYBottom;
725 setCellY(newYTop, newYBottom); 729 setCellY(newYTop, newYBottom);
726} 730}
727 731
728void KOAgendaItem::expandBottom(int dy) 732void KOAgendaItem::expandBottom(int dy)
729{ 733{
730 int newYTop = cellYTop(); 734 int newYTop = cellYTop();
731 int newYBottom = cellYBottom() + dy; 735 int newYBottom = cellYBottom() + dy;
732 if (newYBottom < newYTop) newYBottom = newYTop; 736 if (newYBottom < newYTop) newYBottom = newYTop;
733 setCellY(newYTop, newYBottom); 737 setCellY(newYTop, newYBottom);
734} 738}
735 739
736void KOAgendaItem::expandLeft(int dx) 740void KOAgendaItem::expandLeft(int dx)
737{ 741{
738 int newX = cellX() + dx; 742 int newX = cellX() + dx;
739 int newXWidth = cellXWidth(); 743 int newXWidth = cellXWidth();
740 if (newX > newXWidth) newX = newXWidth; 744 if (newX > newXWidth) newX = newXWidth;
741 setCellX(newX,newXWidth); 745 setCellX(newX,newXWidth);
742} 746}
743 747
744void KOAgendaItem::expandRight(int dx) 748void KOAgendaItem::expandRight(int dx)
745{ 749{
746 int newX = cellX(); 750 int newX = cellX();
747 int newXWidth = cellXWidth() + dx; 751 int newXWidth = cellXWidth() + dx;
748 if (newXWidth < newX) newXWidth = newX; 752 if (newXWidth < newX) newXWidth = newX;
749 setCellX(newX,newXWidth); 753 setCellX(newX,newXWidth);
750} 754}
751 755
752QToolTipGroup *KOAgendaItem::toolTipGroup() 756QToolTipGroup *KOAgendaItem::toolTipGroup()
753{ 757{
754 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 758 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
755 return mToolTipGroup; 759 return mToolTipGroup;
756} 760}
757 761
758void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 762void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
759{ 763{
760#ifndef KORG_NODND 764#ifndef KORG_NODND
761 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 765 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
762 !QTextDrag::canDecode( e ) ) { 766 !QTextDrag::canDecode( e ) ) {
763 e->ignore(); 767 e->ignore();
764 return; 768 return;
765 } 769 }
766 e->accept(); 770 e->accept();
767#endif 771#endif
768} 772}
769 773
770void KOAgendaItem::dropEvent( QDropEvent *e ) 774void KOAgendaItem::dropEvent( QDropEvent *e )
771{ 775{
772#ifndef KORG_NODND 776#ifndef KORG_NODND
773 QString text; 777 QString text;
774 if(QTextDrag::decode(e,text)) 778 if(QTextDrag::decode(e,text))
775 { 779 {
776 kdDebug() << "Dropped : " << text << endl; 780 kdDebug() << "Dropped : " << text << endl;
777 QStringList emails = QStringList::split(",",text); 781 QStringList emails = QStringList::split(",",text);
778 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 782 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
779 kdDebug() << " Email: " << (*it) << endl; 783 kdDebug() << " Email: " << (*it) << endl;
780 int pos = (*it).find("<"); 784 int pos = (*it).find("<");
781 QString name = (*it).left(pos); 785 QString name = (*it).left(pos);
782 QString email = (*it).mid(pos); 786 QString email = (*it).mid(pos);
783 if (!email.isEmpty()) { 787 if (!email.isEmpty()) {
784 mIncidence->addAttendee(new Attendee(name,email)); 788 mIncidence->addAttendee(new Attendee(name,email));
785 } 789 }
786 } 790 }
787 } 791 }
788#endif 792#endif
789} 793}
790 794
791 795
792QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 796QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
793{ 797{
794 return mConflictItems; 798 return mConflictItems;
795} 799}
796 800
797void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 801void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
798{ 802{
799 mConflictItems = ci; 803 mConflictItems = ci;
800 KOAgendaItem *item; 804 KOAgendaItem *item;
801 for ( item=mConflictItems.first(); item != 0; 805 for ( item=mConflictItems.first(); item != 0;
802 item=mConflictItems.next() ) { 806 item=mConflictItems.next() ) {
803 item->addConflictItem(this); 807 item->addConflictItem(this);
804 } 808 }
805} 809}
806 810
807void KOAgendaItem::addConflictItem(KOAgendaItem *ci) 811void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
808{ 812{
809 if (mConflictItems.find(ci)<0) 813 if (mConflictItems.find(ci)<0)
810 mConflictItems.append(ci); 814 mConflictItems.append(ci);
811} 815}
812 816
813bool KOAgendaItem::checkLayout() 817bool KOAgendaItem::checkLayout()
814{ 818{
815 if ( !mConflictItems.count() ) 819 if ( !mConflictItems.count() )
816 return true; 820 return true;
817 int max = 0; 821 int max = 0;
818 KOAgendaItem *item; 822 KOAgendaItem *item;
819 for ( item=mConflictItems.first(); item != 0; 823 for ( item=mConflictItems.first(); item != 0;
820 item=mConflictItems.next() ) { 824 item=mConflictItems.next() ) {
821 if ( item->subCells() > max ) 825 if ( item->subCells() > max )
822 max = item->subCells(); 826 max = item->subCells();
823 } 827 }
824 if ( max > subCells() ) { 828 if ( max > subCells() ) {
825 setSubCells( max ); 829 setSubCells( max );
826 return false; 830 return false;
827 } 831 }
828 return true; 832 return true;
829} 833}
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index d1b1940..dc2316a 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -1,165 +1,166 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19#ifndef KOAGENDAITEM_H 19#ifndef KOAGENDAITEM_H
20#define KOAGENDAITEM_H 20#define KOAGENDAITEM_H
21 21
22#include <qframe.h> 22#include <qframe.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qpalette.h> 26#include <qpalette.h>
27 27
28#include <libkcal/incidence.h> 28#include <libkcal/incidence.h>
29 29
30class KOAgendaItemWhatsThis; 30class KOAgendaItemWhatsThis;
31class QToolTipGroup; 31class QToolTipGroup;
32class QDragEnterEvent; 32class QDragEnterEvent;
33class QDropEvent; 33class QDropEvent;
34 34
35using namespace KCal; 35using namespace KCal;
36 36
37/* 37/*
38 The KOAgendaItem has to make sure that it receives all mouse events, which are 38 The KOAgendaItem has to make sure that it receives all mouse events, which are
39 to be used for dragging and resizing. That means it has to be installed as 39 to be used for dragging and resizing. That means it has to be installed as
40 eventfiler for its children, if it has children, and it has to pass mouse 40 eventfiler for its children, if it has children, and it has to pass mouse
41 events from the cildren to itself. See eventFilter(). 41 events from the cildren to itself. See eventFilter().
42*/ 42*/
43class KOAgendaItem : public QWidget 43class KOAgendaItem : public QWidget
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 public: 46 public:
47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, 47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0,
48 WFlags f=0 ); 48 WFlags f=0 );
49 ~KOAgendaItem(); 49 ~KOAgendaItem();
50 QString getWhatsThisText(); 50 QString getWhatsThisText();
51 void init ( Incidence *incidence, QDate qd ); 51 void init ( Incidence *incidence, QDate qd );
52 int cellX() { return mCellX; } 52 int cellX() { return mCellX; }
53 int cellXWidth() { return mCellXWidth; } 53 int cellXWidth() { return mCellXWidth; }
54 int cellYTop() { return mCellYTop; } 54 int cellYTop() { return mCellYTop; }
55 int cellYBottom() { return mCellYBottom; } 55 int cellYBottom() { return mCellYBottom; }
56 int cellHeight(); 56 int cellHeight();
57 int cellWidth(); 57 int cellWidth();
58 int subCell() { return mSubCell; } 58 int subCell() { return mSubCell; }
59 int subCells() { return mSubCells; } 59 int subCells() { return mSubCells; }
60 60
61 void setCellXY(int X, int YTop, int YBottom); 61 void setCellXY(int X, int YTop, int YBottom);
62 void setCellY(int YTop, int YBottom); 62 void setCellY(int YTop, int YBottom);
63 void setCellX(int XLeft, int XRight); 63 void setCellX(int XLeft, int XRight);
64 void setCellXWidth(int xwidth); 64 void setCellXWidth(int xwidth);
65 void setSubCell(int subCell); 65 void setSubCell(int subCell);
66 void setSubCells(int subCells); 66 void setSubCells(int subCells);
67 67
68 /** Start movement */ 68 /** Start movement */
69 void startMove(); 69 void startMove();
70 /** Reset to original values */ 70 /** Reset to original values */
71 void resetMove(); 71 void resetMove();
72 72
73 void moveRelative(int dx,int dy); 73 void moveRelative(int dx,int dy);
74 void expandTop(int dy); 74 void expandTop(int dy);
75 void expandBottom(int dy); 75 void expandBottom(int dy);
76 void expandLeft(int dx); 76 void expandLeft(int dx);
77 void expandRight(int dx); 77 void expandRight(int dx);
78 int mLastMoveXPos; 78 int mLastMoveXPos;
79 79
80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
81 KOAgendaItem *last); 81 KOAgendaItem *last);
82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } 82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; } 83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; } 84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; }
85 85
86 Incidence *incidence() const { return mIncidence; } 86 Incidence *incidence() const { return mIncidence; }
87 QDate itemDate() { return mDate; } 87 QDate itemDate() { return mDate; }
88 88
89 /** Update the date of this item's occurence (not in the event) */ 89 /** Update the date of this item's occurence (not in the event) */
90 void setItemDate(QDate qd); 90 void setItemDate(QDate qd);
91 91
92 void setText ( const QString & text ) { mDisplayedText = text; } 92 void setText ( const QString & text ) { mDisplayedText = text; }
93 QString text () { return mDisplayedText; } 93 QString text () { return mDisplayedText; }
94 94
95 virtual bool eventFilter ( QObject *, QEvent * ); 95 virtual bool eventFilter ( QObject *, QEvent * );
96 96
97 static QToolTipGroup *toolTipGroup(); 97 static QToolTipGroup *toolTipGroup();
98 98
99 QPtrList<KOAgendaItem> conflictItems(); 99 QPtrList<KOAgendaItem> conflictItems();
100 void setConflictItems(QPtrList<KOAgendaItem>); 100 void setConflictItems(QPtrList<KOAgendaItem>);
101 void addConflictItem(KOAgendaItem *ci); 101 void addConflictItem(KOAgendaItem *ci);
102 void paintMe( bool, QPainter* painter = 0 ); 102 void paintMe( bool, QPainter* painter = 0 );
103 void repaintMe(); 103 void repaintMe();
104 static void resizePixmap( int, int ); 104 static void resizePixmap( int, int );
105 static QPixmap * paintPix(); 105 static QPixmap * paintPix();
106 static QPixmap * paintPixSel(); 106 static QPixmap * paintPixSel();
107 static QPixmap * paintPixAllday(); 107 static QPixmap * paintPixAllday();
108 void updateItem(); 108 void updateItem();
109 void computeText(); 109 void computeText();
110 void recreateIncidence(); 110 void recreateIncidence();
111 bool checkLayout(); 111 bool checkLayout();
112 void initColor ();
112 public slots: 113 public slots:
113 bool updateIcons( QPainter *, bool ); 114 bool updateIcons( QPainter *, bool );
114 void select(bool=true); 115 void select(bool=true);
115 116
116 protected: 117 protected:
117 void dragEnterEvent(QDragEnterEvent *e); 118 void dragEnterEvent(QDragEnterEvent *e);
118 void dropEvent(QDropEvent *e); 119 void dropEvent(QDropEvent *e);
119 void paintEvent ( QPaintEvent * ); 120 void paintEvent ( QPaintEvent * );
120 void resizeEvent ( QResizeEvent *ev ); 121 void resizeEvent ( QResizeEvent *ev );
121 122
122 private: 123 private:
123 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; 124 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis;
124 bool mAllDay; 125 bool mAllDay;
125 bool mWhiteText; 126 bool mWhiteText;
126 int mCellX; 127 int mCellX;
127 int mCellXWidth; 128 int mCellXWidth;
128 int mCellYTop,mCellYBottom; 129 int mCellYTop,mCellYBottom;
129 int mSubCell; // subcell number of this item 130 int mSubCell; // subcell number of this item
130 int mSubCells; // Total number of subcells in cell of this item 131 int mSubCells; // Total number of subcells in cell of this item
131 int xPaintCoord; 132 int xPaintCoord;
132 int yPaintCoord; 133 int yPaintCoord;
133 int wPaintCoord; 134 int wPaintCoord;
134 int hPaintCoord; 135 int hPaintCoord;
135 // Variables to remember start position 136 // Variables to remember start position
136 int mStartCellX; 137 int mStartCellX;
137 int mStartCellXWidth; 138 int mStartCellXWidth;
138 int mStartCellYTop,mStartCellYBottom; 139 int mStartCellYTop,mStartCellYBottom;
139 int mLastMovePos; 140 int mLastMovePos;
140 141
141 // Multi item pointers 142 // Multi item pointers
142 KOAgendaItem *mFirstMultiItem; 143 KOAgendaItem *mFirstMultiItem;
143 KOAgendaItem *mNextMultiItem; 144 KOAgendaItem *mNextMultiItem;
144 KOAgendaItem *mLastMultiItem; 145 KOAgendaItem *mLastMultiItem;
145 146
146 int mFontPixelSize; 147 int mFontPixelSize;
147 Incidence *mIncidence; // corresponding event or todo 148 Incidence *mIncidence; // corresponding event or todo
148 QDate mDate; //date this events occurs (for recurrence) 149 QDate mDate; //date this events occurs (for recurrence)
149 //void showIcon( QLabel*, int ); 150 //void showIcon( QLabel*, int );
150 //QLabel *mTodoIconLabel; 151 //QLabel *mTodoIconLabel;
151 //QLabel *mItemLabel; 152 //QLabel *mItemLabel;
152 //QWidget *mIconBox; 153 //QWidget *mIconBox;
153 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; 154 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
154 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; 155 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
155 //QLabel *mIconMoreInfo; 156 //QLabel *mIconMoreInfo;
156 static QToolTipGroup *mToolTipGroup; 157 static QToolTipGroup *mToolTipGroup;
157 158
158 QColor mBackgroundColor; 159 QColor mBackgroundColor;
159 QColorGroup mColorGroup; 160 QColorGroup mColorGroup;
160 QString mDisplayedText; 161 QString mDisplayedText;
161 bool mSelected; 162 bool mSelected;
162 QPtrList<KOAgendaItem> mConflictItems; 163 QPtrList<KOAgendaItem> mConflictItems;
163}; 164};
164 165
165#endif // KOAGENDAITEM_H 166#endif // KOAGENDAITEM_H
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index c851ab5..a42227c 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1359 +1,1368 @@
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
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 myPix.resize( 1, 1 ); 84 myPix.resize( 1, 1 );
85 mRows = rows; 85 mRows = rows;
86 86
87 mRedrawNeeded = true; 87 mRedrawNeeded = true;
88 setMinimumHeight( 20 ); 88 setMinimumHeight( 20 );
89 mCellHeight = KOPrefs::instance()->mHourSize*4; 89 mCellHeight = KOPrefs::instance()->mHourSize*4;
90 90
91 enableClipper(true); 91 enableClipper(true);
92 92
93 setHScrollBarMode(AlwaysOff); 93 setHScrollBarMode(AlwaysOff);
94 setVScrollBarMode(AlwaysOff); 94 setVScrollBarMode(AlwaysOff);
95 95
96 resizeContents(50,mRows * mCellHeight); 96 resizeContents(50,mRows * mCellHeight);
97 97
98 viewport()->setBackgroundMode( PaletteBackground ); 98 viewport()->setBackgroundMode( PaletteBackground );
99} 99}
100 100
101void TimeLabels::setCellHeight(int height) 101void TimeLabels::setCellHeight(int height)
102{ 102{
103 mCellHeight = height; 103 mCellHeight = height;
104} 104}
105 105
106/* 106/*
107 Optimization so that only the "dirty" portion of the scroll view 107 Optimization so that only the "dirty" portion of the scroll view
108 is redrawn. Unfortunately, this is not called by default paintEvent() method. 108 is redrawn. Unfortunately, this is not called by default paintEvent() method.
109*/ 109*/
110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 111{
112 112
113 cx = contentsX() + frameWidth()*2; 113 cx = contentsX() + frameWidth()*2;
114 cw = contentsWidth() ; 114 cw = contentsWidth() ;
115 // end of workaround 115 // end of workaround
116 116
117 int cell = ((int)(cy/mCellHeight)); 117 int cell = ((int)(cy/mCellHeight));
118 int y = cell * mCellHeight; 118 int y = cell * mCellHeight;
119 QFontMetrics fm = fontMetrics(); 119 QFontMetrics fm = fontMetrics();
120 QString hour; 120 QString hour;
121 QString suffix = "am"; 121 QString suffix = "am";
122 int timeHeight = fm.ascent(); 122 int timeHeight = fm.ascent();
123 QFont nFont = font(); 123 QFont nFont = font();
124 p->setFont( font()); 124 p->setFont( font());
125 125
126 if (!KGlobal::locale()->use12Clock()) { 126 if (!KGlobal::locale()->use12Clock()) {
127 suffix = "00"; 127 suffix = "00";
128 } else 128 } else
129 if (cell > 11) suffix = "pm"; 129 if (cell > 11) suffix = "pm";
130 130
131 if ( timeHeight > mCellHeight ) { 131 if ( timeHeight > mCellHeight ) {
132 timeHeight = mCellHeight-1; 132 timeHeight = mCellHeight-1;
133 int pointS = nFont.pointSize(); 133 int pointS = nFont.pointSize();
134 while ( pointS > 4 ) { 134 while ( pointS > 4 ) {
135 nFont.setPointSize( pointS ); 135 nFont.setPointSize( pointS );
136 fm = QFontMetrics( nFont ); 136 fm = QFontMetrics( nFont );
137 if ( fm.ascent() < mCellHeight ) 137 if ( fm.ascent() < mCellHeight )
138 break; 138 break;
139 -- pointS; 139 -- pointS;
140 } 140 }
141 fm = QFontMetrics( nFont ); 141 fm = QFontMetrics( nFont );
142 timeHeight = fm.ascent(); 142 timeHeight = fm.ascent();
143 } 143 }
144 //timeHeight -= (timeHeight/4-2); 144 //timeHeight -= (timeHeight/4-2);
145 QFont sFont = nFont; 145 QFont sFont = nFont;
146 sFont.setPointSize( sFont.pointSize()/2 ); 146 sFont.setPointSize( sFont.pointSize()/2 );
147 QFontMetrics fmS( sFont ); 147 QFontMetrics fmS( sFont );
148 int sHei = fmS.ascent() ; 148 int sHei = fmS.ascent() ;
149 //sHei -= (sHei/4-2); 149 //sHei -= (sHei/4-2);
150 int startW = mMiniWidth - frameWidth()-2 ; 150 int startW = mMiniWidth - frameWidth()-2 ;
151 int tw2 = fmS.width(suffix); 151 int tw2 = fmS.width(suffix);
152 timeHeight = (timeHeight-1) /2 -1; 152 timeHeight = (timeHeight-1) /2 -1;
153 //testline 153 //testline
154 //p->drawLine(0,0,0,contentsHeight()); 154 //p->drawLine(0,0,0,contentsHeight());
155 while (y < cy + ch+mCellHeight) { 155 while (y < cy + ch+mCellHeight) {
156 p->drawLine(startW-tw2+1 ,y,cw+2,y); 156 p->drawLine(startW-tw2+1 ,y,cw+2,y);
157 hour.setNum(cell); 157 hour.setNum(cell);
158 // handle 24h and am/pm time formats 158 // handle 24h and am/pm time formats
159 if (KGlobal::locale()->use12Clock()) { 159 if (KGlobal::locale()->use12Clock()) {
160 if (cell == 12) suffix = "pm"; 160 if (cell == 12) suffix = "pm";
161 if (cell == 0) hour.setNum(12); 161 if (cell == 0) hour.setNum(12);
162 if (cell > 12) hour.setNum(cell - 12); 162 if (cell > 12) hour.setNum(cell - 12);
163 } 163 }
164 164
165 // center and draw the time label 165 // center and draw the time label
166 int timeWidth = fm.width(hour); 166 int timeWidth = fm.width(hour);
167 int offset = startW - timeWidth - tw2 -1 ; 167 int offset = startW - timeWidth - tw2 -1 ;
168 p->setFont( nFont ); 168 p->setFont( nFont );
169 p->drawText( offset, y+ timeHeight, hour); 169 p->drawText( offset, y+ timeHeight, hour);
170 p->setFont( sFont ); 170 p->setFont( sFont );
171 offset = startW - tw2; 171 offset = startW - tw2;
172 p->drawText( offset, y -1, suffix); 172 p->drawText( offset, y -1, suffix);
173 173
174 // increment indices 174 // increment indices
175 y += mCellHeight; 175 y += mCellHeight;
176 cell++; 176 cell++;
177 } 177 }
178 178
179 179
180 180
181 181
182} 182}
183 183
184/** 184/**
185 Calculates the minimum width. 185 Calculates the minimum width.
186*/ 186*/
187int TimeLabels::minimumWidth() const 187int TimeLabels::minimumWidth() const
188{ 188{
189 return mMiniWidth; 189 return mMiniWidth;
190} 190}
191 191
192/** updates widget's internal state */ 192/** updates widget's internal state */
193void TimeLabels::updateConfig() 193void TimeLabels::updateConfig()
194{ 194{
195 mRedrawNeeded = true; 195 mRedrawNeeded = true;
196 // set the font 196 // set the font
197 // config->setGroup("Fonts"); 197 // config->setGroup("Fonts");
198 // QFont font = config->readFontEntry("TimeBar Font"); 198 // QFont font = config->readFontEntry("TimeBar Font");
199 setFont(KOPrefs::instance()->mTimeBarFont); 199 setFont(KOPrefs::instance()->mTimeBarFont);
200 QString test = "20"; 200 QString test = "20";
201 if (KGlobal::locale()->use12Clock()) 201 if (KGlobal::locale()->use12Clock())
202 test = "12"; 202 test = "12";
203 mMiniWidth = fontMetrics().width(test); 203 mMiniWidth = fontMetrics().width(test);
204 if (KGlobal::locale()->use12Clock()) 204 if (KGlobal::locale()->use12Clock())
205 test = "pm"; 205 test = "pm";
206 else { 206 else {
207 test = "00"; 207 test = "00";
208 } 208 }
209 QFont sFont = font(); 209 QFont sFont = font();
210 sFont.setPointSize( sFont.pointSize()/2 ); 210 sFont.setPointSize( sFont.pointSize()/2 );
211 QFontMetrics fmS( sFont ); 211 QFontMetrics fmS( sFont );
212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; 212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ;
213 // update geometry restrictions based on new settings 213 // update geometry restrictions based on new settings
214 setFixedWidth( mMiniWidth ); 214 setFixedWidth( mMiniWidth );
215 215
216 // update HourSize 216 // update HourSize
217 mCellHeight = KOPrefs::instance()->mHourSize*4; 217 mCellHeight = KOPrefs::instance()->mHourSize*4;
218 resizeContents(mMiniWidth,mRows * mCellHeight+1); 218 resizeContents(mMiniWidth,mRows * mCellHeight+1);
219} 219}
220 220
221/** update time label positions */ 221/** update time label positions */
222void TimeLabels::positionChanged() 222void TimeLabels::positionChanged()
223{ 223{
224 int adjustment = mAgenda->contentsY(); 224 int adjustment = mAgenda->contentsY();
225 setContentsPos(0, adjustment); 225 setContentsPos(0, adjustment);
226} 226}
227 227
228/** */ 228/** */
229void TimeLabels::setAgenda(KOAgenda* agenda) 229void TimeLabels::setAgenda(KOAgenda* agenda)
230{ 230{
231 mAgenda = agenda; 231 mAgenda = agenda;
232} 232}
233 233
234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
235{ 235{
236 mMouseDownY = e->pos().y(); 236 mMouseDownY = e->pos().y();
237 mOrgCap = topLevelWidget()->caption(); 237 mOrgCap = topLevelWidget()->caption();
238} 238}
239 239
240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
241{ 241{
242 int diff = mMouseDownY - e->pos().y(); 242 int diff = mMouseDownY - e->pos().y();
243 if ( diff < 10 && diff > -10 ) 243 if ( diff < 10 && diff > -10 )
244 return; 244 return;
245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
246 if ( tSize < 4 ) 246 if ( tSize < 4 )
247 tSize = 4; 247 tSize = 4;
248 if ( tSize > 22 ) 248 if ( tSize > 22 )
249 tSize = 22; 249 tSize = 22;
250 tSize = (tSize-2)/2; 250 tSize = (tSize-2)/2;
251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
252 252
253} 253}
254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
255{ 255{
256 topLevelWidget()->setCaption( mOrgCap ); 256 topLevelWidget()->setCaption( mOrgCap );
257 int diff = mMouseDownY - e->pos().y(); 257 int diff = mMouseDownY - e->pos().y();
258 if ( diff < 10 && diff > -10 ) 258 if ( diff < 10 && diff > -10 )
259 return; 259 return;
260 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 260 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
261 if ( tSize < 4 ) 261 if ( tSize < 4 )
262 tSize = 4; 262 tSize = 4;
263 if ( tSize > 22 ) 263 if ( tSize > 22 )
264 tSize = 22; 264 tSize = 22;
265 tSize = (tSize/2)*2; 265 tSize = (tSize/2)*2;
266 if ( tSize == KOPrefs::instance()->mHourSize ) 266 if ( tSize == KOPrefs::instance()->mHourSize )
267 return; 267 return;
268 KOPrefs::instance()->mHourSize = tSize; 268 KOPrefs::instance()->mHourSize = tSize;
269 emit scaleChanged(); 269 emit scaleChanged();
270} 270}
271 271
272/** This is called in response to repaint() */ 272/** This is called in response to repaint() */
273void TimeLabels::paintEvent(QPaintEvent*) 273void TimeLabels::paintEvent(QPaintEvent*)
274{ 274{
275 275
276 // kdDebug() << "paintevent..." << endl; 276 // kdDebug() << "paintevent..." << endl;
277 // this is another hack! 277 // this is another hack!
278 // QPainter painter(this); 278 // QPainter painter(this);
279 //QString c 279 //QString c
280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
281} 281}
282 282
283//////////////////////////////////////////////////////////////////////////// 283////////////////////////////////////////////////////////////////////////////
284 284
285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
286 : QFrame(parent,name) 286 : QFrame(parent,name)
287{ 287{
288 mColumns = 1; 288 mColumns = 1;
289 mTopBox = 0; 289 mTopBox = 0;
290 mLocation = loc; 290 mLocation = loc;
291 mTopLayout = 0; 291 mTopLayout = 0;
292 mPaintWidget = 0; 292 mPaintWidget = 0;
293 mXOffset = 0; 293 mXOffset = 0;
294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
295 else mPixmap = SmallIcon("1downarrow"); 295 else mPixmap = SmallIcon("1downarrow");
296 mEnabled.resize(mColumns); 296 mEnabled.resize(mColumns);
297 mEnabled.fill( false ); 297 mEnabled.fill( false );
298 setMinimumHeight(mPixmap.height()); 298 setMinimumHeight(mPixmap.height());
299} 299}
300 300
301EventIndicator::~EventIndicator() 301EventIndicator::~EventIndicator()
302{ 302{
303} 303}
304 304
305void EventIndicator::drawContents(QPainter *p) 305void EventIndicator::drawContents(QPainter *p)
306{ 306{
307 307
308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
309 KDGanttSplitterHandle* han = 0; 309 KDGanttSplitterHandle* han = 0;
310 if ( mPaintWidget ) 310 if ( mPaintWidget )
311 han = mPaintWidget->firstHandle(); 311 han = mPaintWidget->firstHandle();
312 if ( ! han ) { 312 if ( ! han ) {
313 int i; 313 int i;
314 for(i=0;i<mColumns;++i) { 314 for(i=0;i<mColumns;++i) {
315 if (mEnabled[i]) { 315 if (mEnabled[i]) {
316 int cellWidth = contentsRect().right()/mColumns; 316 int cellWidth = contentsRect().right()/mColumns;
317 int xOffset = KOGlobals::self()->reverseLayout() ? 317 int xOffset = KOGlobals::self()->reverseLayout() ?
318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
319 i*cellWidth + (cellWidth -mPixmap.width()) /2; 319 i*cellWidth + (cellWidth -mPixmap.width()) /2;
320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
321 } 321 }
322 } 322 }
323 } else { 323 } else {
324 han->repaint(); 324 han->repaint();
325 //mPaintWidget->setBackgroundColor( red ); 325 //mPaintWidget->setBackgroundColor( red );
326 326
327 QPainter pa( han ); 327 QPainter pa( han );
328 int i; 328 int i;
329 bool setColor = false; 329 bool setColor = false;
330 for(i=0;i<mColumns;++i) { 330 for(i=0;i<mColumns;++i) {
331 if (mEnabled[i]) { 331 if (mEnabled[i]) {
332 setColor = true; 332 setColor = true;
333 333
334 int cellWidth = contentsRect().right()/mColumns; 334 int cellWidth = contentsRect().right()/mColumns;
335 int xOffset = KOGlobals::self()->reverseLayout() ? 335 int xOffset = KOGlobals::self()->reverseLayout() ?
336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
337 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 337 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
339 //qDebug("222draw pix %d ",xOffset ); 339 //qDebug("222draw pix %d ",xOffset );
340 340
341 } 341 }
342 342
343 } 343 }
344 pa.end(); 344 pa.end();
345 345
346 } 346 }
347} 347}
348 348
349void EventIndicator::setXOffset( int x ) 349void EventIndicator::setXOffset( int x )
350{ 350{
351 mXOffset = x; 351 mXOffset = x;
352} 352}
353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
354{ 354{
355 mPaintWidget = w; 355 mPaintWidget = w;
356 setMaximumHeight(0); 356 setMaximumHeight(0);
357 setMinimumHeight(0); 357 setMinimumHeight(0);
358} 358}
359void EventIndicator::changeColumns(int columns) 359void EventIndicator::changeColumns(int columns)
360{ 360{
361 mColumns = columns; 361 mColumns = columns;
362 mEnabled.resize(mColumns); 362 mEnabled.resize(mColumns);
363 363
364 update(); 364 update();
365} 365}
366 366
367void EventIndicator::enableColumn(int column, bool enable) 367void EventIndicator::enableColumn(int column, bool enable)
368{ 368{
369 mEnabled[column] = enable; 369 mEnabled[column] = enable;
370} 370}
371 371
372 372
373//////////////////////////////////////////////////////////////////////////// 373////////////////////////////////////////////////////////////////////////////
374//////////////////////////////////////////////////////////////////////////// 374////////////////////////////////////////////////////////////////////////////
375//////////////////////////////////////////////////////////////////////////// 375////////////////////////////////////////////////////////////////////////////
376 376
377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
378 KOEventView (cal,parent,name) 378 KOEventView (cal,parent,name)
379{ 379{
380 mBlockUpdating = true; 380 mBlockUpdating = true;
381 mStartHour = 8; 381 mStartHour = 8;
382 mSelectedDates.append(QDate::currentDate()); 382 mSelectedDates.append(QDate::currentDate());
383 383
384 mLayoutDayLabels = 0; 384 mLayoutDayLabels = 0;
385 mDayLabelsFrame = 0; 385 mDayLabelsFrame = 0;
386 mDayLabels = 0; 386 mDayLabels = 0;
387 bool isRTL = KOGlobals::self()->reverseLayout(); 387 bool isRTL = KOGlobals::self()->reverseLayout();
388 QPixmap expandPix; 388 QPixmap expandPix;
389 if ( KOPrefs::instance()->mVerticalScreen ) { 389 if ( KOPrefs::instance()->mVerticalScreen ) {
390 expandPix = SmallIcon( "1updownarrow" ); 390 expandPix = SmallIcon( "1updownarrow" );
391 } else { 391 } else {
392 expandPix = SmallIcon("1leftrightarrow" ); 392 expandPix = SmallIcon("1leftrightarrow" );
393 } 393 }
394 394
395 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
396 396
397 // Create day name labels for agenda columns 397 // Create day name labels for agenda columns
398 // Create agenda splitter 398 // Create agenda splitter
399 399
400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
402 topLayout->addWidget( mSplitterAgenda ); 402 topLayout->addWidget( mSplitterAgenda );
403 mAllDayFrame = new QHBox(mSplitterAgenda); 403 mAllDayFrame = new QHBox(mSplitterAgenda);
404 mAllDayFrame->setFocusPolicy(NoFocus); 404 mAllDayFrame->setFocusPolicy(NoFocus);
405 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 405 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
406 agendaFrame->setFocusPolicy(NoFocus); 406 agendaFrame->setFocusPolicy(NoFocus);
407 407
408 // Create all-day agenda widget 408 // Create all-day agenda widget
409 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 409 mDummyAllDayLeft = new QVBox( mAllDayFrame );
410 410
411 mExpandButton = new QPushButton(mDummyAllDayLeft); 411 mExpandButton = new QPushButton(mDummyAllDayLeft);
412 mExpandButton->setPixmap( expandPix ); 412 mExpandButton->setPixmap( expandPix );
413 int widebut = mExpandButton->sizeHint().width()+4; 413 int widebut = mExpandButton->sizeHint().width()+4;
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
438#endif 438#endif
439 mDayLabelsFrame = new QHBox(agendaFrame); 439 mDayLabelsFrame = new QHBox(agendaFrame);
440 //topLayout->addWidget(mDayLabelsFrame); 440 //topLayout->addWidget(mDayLabelsFrame);
441 mDayLabels = new QFrame (mDayLabelsFrame); 441 mDayLabels = new QFrame (mDayLabelsFrame);
442 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 442 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
444 agendaLayout->addWidget(mEventIndicatorTop,1,1); 444 agendaLayout->addWidget(mEventIndicatorTop,1,1);
445 445
446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
447 agendaFrame); 447 agendaFrame);
448 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 448 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
449 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 449 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
450 agendaLayout->addWidget(dummyAgendaRight,1,2); 450 agendaLayout->addWidget(dummyAgendaRight,1,2);
451 451
452 // Create time labels 452 // Create time labels
453 mTimeLabels = new TimeLabels(24,agendaFrame); 453 mTimeLabels = new TimeLabels(24,agendaFrame);
454 agendaLayout->addWidget(mTimeLabels,2,0); 454 agendaLayout->addWidget(mTimeLabels,2,0);
455 connect(mTimeLabels,SIGNAL( scaleChanged()), 455 connect(mTimeLabels,SIGNAL( scaleChanged()),
456 this,SLOT(updateConfig())); 456 this,SLOT(updateConfig()));
457 457
458 // Create agenda 458 // Create agenda
459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
461 agendaLayout->setColStretch(1,1); 461 agendaLayout->setColStretch(1,1);
462 mAgenda->setFocusPolicy(NoFocus); 462 mAgenda->setFocusPolicy(NoFocus);
463 // Create event context menu for agenda 463 // Create event context menu for agenda
464 mAllAgendaPopup = eventPopup(); 464 mAllAgendaPopup = eventPopup();
465 465
466#if 0 466#if 0
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
470 470
471#endif 471#endif
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 474
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477
478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)),
479 this,SLOT(categoryChanged(Incidence *)));
480
481
477 mAgenda->setPopup( mAllAgendaPopup ); 482 mAgenda->setPopup( mAllAgendaPopup );
478 mAllDayAgenda->setPopup( mAllAgendaPopup ); 483 mAllDayAgenda->setPopup( mAllAgendaPopup );
479 // make connections between dependent widgets 484 // make connections between dependent widgets
480 mTimeLabels->setAgenda(mAgenda); 485 mTimeLabels->setAgenda(mAgenda);
481 486
482 // Update widgets to reflect user preferences 487 // Update widgets to reflect user preferences
483 // updateConfig(); 488 // updateConfig();
484 489
485 // createDayLabels(); 490 // createDayLabels();
486 491
487 // 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
488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
491 496
492 // Scrolling 497 // Scrolling
493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
494 mTimeLabels, SLOT(positionChanged())); 499 mTimeLabels, SLOT(positionChanged()));
495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
496 SLOT(setContentsPos(int))); 501 SLOT(setContentsPos(int)));
497 502
498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
500 505
501 // Create/Show/Edit/Delete Event 506 // Create/Show/Edit/Delete Event
502 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 507 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
503 SLOT(newEvent(int,int))); 508 SLOT(newEvent(int,int)));
504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
505 SLOT(newTodo(int,int))); 510 SLOT(newTodo(int,int)));
506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
507 SLOT(newEvent(int,int,int,int))); 512 SLOT(newEvent(int,int,int,int)));
508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
509 SLOT(newEventAllDay(int,int))); 514 SLOT(newEventAllDay(int,int)));
510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
511 SLOT(newTodoAllDay(int,int))); 516 SLOT(newTodoAllDay(int,int)));
512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
513 SLOT(newEventAllDay(int,int))); 518 SLOT(newEventAllDay(int,int)));
514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
515 SLOT(newTimeSpanSelected(int,int,int,int))); 520 SLOT(newTimeSpanSelected(int,int,int,int)));
516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
520 525
521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
522 SIGNAL(editIncidenceSignal(Incidence *))); 527 SIGNAL(editIncidenceSignal(Incidence *)));
523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
524 SIGNAL(editIncidenceSignal(Incidence *))); 529 SIGNAL(editIncidenceSignal(Incidence *)));
525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
526 SIGNAL(showIncidenceSignal(Incidence *))); 531 SIGNAL(showIncidenceSignal(Incidence *)));
527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
528 SIGNAL(showIncidenceSignal(Incidence *))); 533 SIGNAL(showIncidenceSignal(Incidence *)));
529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
530 SIGNAL(deleteIncidenceSignal(Incidence *))); 535 SIGNAL(deleteIncidenceSignal(Incidence *)));
531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
532 SIGNAL(deleteIncidenceSignal(Incidence *))); 537 SIGNAL(deleteIncidenceSignal(Incidence *)));
533 538
534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
535 SLOT(updateEventDates(KOAgendaItem *, int ))); 540 SLOT(updateEventDates(KOAgendaItem *, int )));
536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
537 SLOT(updateEventDates(KOAgendaItem *, int))); 542 SLOT(updateEventDates(KOAgendaItem *, int)));
538 543
539 // event indicator update 544 // event indicator update
540 connect(mAgenda,SIGNAL(lowerYChanged(int)), 545 connect(mAgenda,SIGNAL(lowerYChanged(int)),
541 SLOT(updateEventIndicatorTop(int))); 546 SLOT(updateEventIndicatorTop(int)));
542 connect(mAgenda,SIGNAL(upperYChanged(int)), 547 connect(mAgenda,SIGNAL(upperYChanged(int)),
543 SLOT(updateEventIndicatorBottom(int))); 548 SLOT(updateEventIndicatorBottom(int)));
544 // drag signals 549 // drag signals
545 /* 550 /*
546 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 551 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
547 SLOT(startDrag(Event *))); 552 SLOT(startDrag(Event *)));
548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
549 SLOT(startDrag(Event *))); 554 SLOT(startDrag(Event *)));
550 */ 555 */
551 // synchronize selections 556 // synchronize selections
552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
553 mAllDayAgenda, SLOT( deselectItem() ) ); 558 mAllDayAgenda, SLOT( deselectItem() ) );
554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
555 mAgenda, SLOT( deselectItem() ) ); 560 mAgenda, SLOT( deselectItem() ) );
556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
557 SIGNAL( incidenceSelected( Incidence * ) ) ); 562 SIGNAL( incidenceSelected( Incidence * ) ) );
558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
559 SIGNAL( incidenceSelected( Incidence * ) ) ); 564 SIGNAL( incidenceSelected( Incidence * ) ) );
560 connect( mAgenda, SIGNAL( resizedSignal() ), 565 connect( mAgenda, SIGNAL( resizedSignal() ),
561 SLOT( updateConfig( ) ) ); 566 SLOT( updateConfig( ) ) );
562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
565 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 570 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
568 573
569 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
570 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
571 576
572} 577}
573 578
574void KOAgendaView::toggleAllDay() 579void KOAgendaView::toggleAllDay()
575{ 580{
576 if ( mSplitterAgenda->firstHandle() ) 581 if ( mSplitterAgenda->firstHandle() )
577 mSplitterAgenda->firstHandle()->toggle(); 582 mSplitterAgenda->firstHandle()->toggle();
578} 583}
579void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 584void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
580{ 585{
581 calendar()->addIncidence( inc ); 586 calendar()->addIncidence( inc );
582 587
583 if ( incOld ) { 588 if ( incOld ) {
584 if ( incOld->typeID() == todoID ) 589 if ( incOld->typeID() == todoID )
585 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 590 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
586 else 591 else
587 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 592 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
588 } 593 }
589 594
590} 595}
591 596void KOAgendaView::categoryChanged(Incidence * inc)
597{
598 mAgenda->categoryChanged( inc );
599 mAllDayAgenda->categoryChanged( inc );
600}
592KOAgendaView::~KOAgendaView() 601KOAgendaView::~KOAgendaView()
593{ 602{
594 delete mAllAgendaPopup; 603 delete mAllAgendaPopup;
595 //delete mAllDayAgendaPopup; 604 //delete mAllDayAgendaPopup;
596 delete KOAgendaItem::paintPix(); 605 delete KOAgendaItem::paintPix();
597 delete KOAgendaItem::paintPixSel(); 606 delete KOAgendaItem::paintPixSel();
598} 607}
599void KOAgendaView::resizeEvent( QResizeEvent* e ) 608void KOAgendaView::resizeEvent( QResizeEvent* e )
600{ 609{
601 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 610 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
602 bool uc = false; 611 bool uc = false;
603 int ow = e->oldSize().width(); 612 int ow = e->oldSize().width();
604 int oh = e->oldSize().height(); 613 int oh = e->oldSize().height();
605 int w = e->size().width(); 614 int w = e->size().width();
606 int h = e->size().height(); 615 int h = e->size().height();
607 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 616 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
608 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 617 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
609 uc = true; 618 uc = true;
610 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 619 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
611 } 620 }
612 mUpcomingWidth = e->size().width() ; 621 mUpcomingWidth = e->size().width() ;
613 if ( mBlockUpdating || uc ) { 622 if ( mBlockUpdating || uc ) {
614 mBlockUpdating = false; 623 mBlockUpdating = false;
615 //mAgenda->setMinimumSize(800 , 600 ); 624 //mAgenda->setMinimumSize(800 , 600 );
616 //qDebug("mAgenda->resize+++++++++++++++ "); 625 //qDebug("mAgenda->resize+++++++++++++++ ");
617 updateConfig(); 626 updateConfig();
618 //qDebug("KOAgendaView::Updating now possible "); 627 //qDebug("KOAgendaView::Updating now possible ");
619 } else 628 } else
620 createDayLabels(); 629 createDayLabels();
621 //qDebug("resizeEvent end "); 630 //qDebug("resizeEvent end ");
622 631
623} 632}
624void KOAgendaView::slotDaylabelClicked( int num ) 633void KOAgendaView::slotDaylabelClicked( int num )
625{ 634{
626 635
627 QDate firstDate = mSelectedDates.first(); 636 QDate firstDate = mSelectedDates.first();
628 if ( num == -1 ) 637 if ( num == -1 )
629 emit showDateView( 6, firstDate ); 638 emit showDateView( 6, firstDate );
630 else if (num >= 0 ) { 639 else if (num >= 0 ) {
631 if ( mSelectedDates.count() == 1) 640 if ( mSelectedDates.count() == 1)
632 emit showDateView( 9, firstDate.addDays( num ) ); 641 emit showDateView( 9, firstDate.addDays( num ) );
633 else 642 else
634 emit showDateView( 3, firstDate.addDays( num ) ); 643 emit showDateView( 3, firstDate.addDays( num ) );
635 } 644 }
636 else 645 else
637 showDateView( 10, firstDate.addDays(1) ); 646 showDateView( 10, firstDate.addDays(1) );
638} 647}
639 648
640KOAgendaButton* KOAgendaView::getNewDaylabel() 649KOAgendaButton* KOAgendaView::getNewDaylabel()
641{ 650{
642 651
643 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 652 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
644 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 653 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
645 mDayLabelsList.append( dayLabel ); 654 mDayLabelsList.append( dayLabel );
646 mLayoutDayLabels->addWidget(dayLabel); 655 mLayoutDayLabels->addWidget(dayLabel);
647 return dayLabel ; 656 return dayLabel ;
648} 657}
649 658
650void KOAgendaView::createDayLabels() 659void KOAgendaView::createDayLabels()
651{ 660{
652 661
653 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 662 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
654 // qDebug(" KOAgendaView::createDayLabels() blocked "); 663 // qDebug(" KOAgendaView::createDayLabels() blocked ");
655 return; 664 return;
656 665
657 } 666 }
658 int newHight; 667 int newHight;
659 if ( !mSelectedDates.count()) 668 if ( !mSelectedDates.count())
660 return; 669 return;
661 670
662 // ### Before deleting and recreating we could check if mSelectedDates changed... 671 // ### Before deleting and recreating we could check if mSelectedDates changed...
663 // It would remove some flickering and gain speed (since this is called by 672 // It would remove some flickering and gain speed (since this is called by
664 // each updateView() call) 673 // each updateView() call)
665 674
666 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 675 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
667 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 676 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
668 if ( maxWid < 20 ) 677 if ( maxWid < 20 )
669 maxWid = 20; 678 maxWid = 20;
670 679
671 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 680 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
672 QFontMetrics fm ( dlf ); 681 QFontMetrics fm ( dlf );
673 dlf.setBold( true ); 682 dlf.setBold( true );
674 int selCount = mSelectedDates.count(); 683 int selCount = mSelectedDates.count();
675 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 684 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
676 QString dayTest = "Mon 20"; 685 QString dayTest = "Mon 20";
677 //QString dayTest = "Mon 20"; 686 //QString dayTest = "Mon 20";
678 int wid = fm.width( dayTest ); 687 int wid = fm.width( dayTest );
679 //maxWid -= ( selCount * 3 ); //working for QLabels 688 //maxWid -= ( selCount * 3 ); //working for QLabels
680 if ( QApplication::desktop()->width() <= 320 ) 689 if ( QApplication::desktop()->width() <= 320 )
681 maxWid -= ( selCount * 3 ); //working for QPushButton 690 maxWid -= ( selCount * 3 ); //working for QPushButton
682 else 691 else
683 maxWid -= ( selCount * 4 ); //working for QPushButton 692 maxWid -= ( selCount * 4 ); //working for QPushButton
684 if ( maxWid < 0 ) 693 if ( maxWid < 0 )
685 maxWid = 20; 694 maxWid = 20;
686 int needWid = wid * selCount; 695 int needWid = wid * selCount;
687 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 696 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
688 //if ( needWid > maxWid ) 697 //if ( needWid > maxWid )
689 // qDebug("DAYLABELS TOOOOOOO BIG "); 698 // qDebug("DAYLABELS TOOOOOOO BIG ");
690 while ( needWid > maxWid ) { 699 while ( needWid > maxWid ) {
691 dayTest = dayTest.left( dayTest.length() - 1 ); 700 dayTest = dayTest.left( dayTest.length() - 1 );
692 wid = fm.width( dayTest ); 701 wid = fm.width( dayTest );
693 needWid = wid * selCount; 702 needWid = wid * selCount;
694 } 703 }
695 int maxLen = dayTest.length(); 704 int maxLen = dayTest.length();
696 int fontPoint = dlf.pointSize(); 705 int fontPoint = dlf.pointSize();
697 if ( maxLen < 2 ) { 706 if ( maxLen < 2 ) {
698 int fontPoint = dlf.pointSize(); 707 int fontPoint = dlf.pointSize();
699 while ( fontPoint > 4 ) { 708 while ( fontPoint > 4 ) {
700 --fontPoint; 709 --fontPoint;
701 dlf.setPointSize( fontPoint ); 710 dlf.setPointSize( fontPoint );
702 QFontMetrics f( dlf ); 711 QFontMetrics f( dlf );
703 wid = f.width( "30" ); 712 wid = f.width( "30" );
704 needWid = wid * selCount; 713 needWid = wid * selCount;
705 if ( needWid < maxWid ) 714 if ( needWid < maxWid )
706 break; 715 break;
707 } 716 }
708 maxLen = 2; 717 maxLen = 2;
709 } 718 }
710 //qDebug("Max len %d ", dayTest.length() ); 719 //qDebug("Max len %d ", dayTest.length() );
711 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) 720 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() )
712 dlf.setBold( false ); 721 dlf.setBold( false );
713 QFontMetrics tempF( dlf ); 722 QFontMetrics tempF( dlf );
714 newHight = tempF.height(); 723 newHight = tempF.height();
715 mDayLabels->setFont( dlf ); 724 mDayLabels->setFont( dlf );
716 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 725 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
717 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 726 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
718 //mLayoutDayLabels->addSpacing( 2 ); 727 //mLayoutDayLabels->addSpacing( 2 );
719 // QFont lFont = dlf; 728 // QFont lFont = dlf;
720 bool appendLabels = false; 729 bool appendLabels = false;
721 KOAgendaButton *dayLabel; 730 KOAgendaButton *dayLabel;
722 dayLabel = mDayLabelsList.first(); 731 dayLabel = mDayLabelsList.first();
723 if ( !dayLabel ) { 732 if ( !dayLabel ) {
724 appendLabels = true; 733 appendLabels = true;
725 dayLabel = getNewDaylabel(); 734 dayLabel = getNewDaylabel();
726 } 735 }
727 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 736 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
728 dayLabel->setFont( dlf ); 737 dayLabel->setFont( dlf );
729 dayLabel->setNum( -1 ); 738 dayLabel->setNum( -1 );
730 //dayLabel->setAlignment(QLabel::AlignHCenter); 739 //dayLabel->setAlignment(QLabel::AlignHCenter);
731 740
732 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 741 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
733 dayLabel->show(); 742 dayLabel->show();
734 DateList::ConstIterator dit; 743 DateList::ConstIterator dit;
735 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 744 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
736 int counter = -1; 745 int counter = -1;
737 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 746 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
738 ++counter; 747 ++counter;
739 QDate date = *dit; 748 QDate date = *dit;
740 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 749 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
741 if ( ! appendLabels ) { 750 if ( ! appendLabels ) {
742 dayLabel = mDayLabelsList.next(); 751 dayLabel = mDayLabelsList.next();
743 if ( !dayLabel ) 752 if ( !dayLabel )
744 appendLabels = true; 753 appendLabels = true;
745 } 754 }
746 if ( appendLabels ) { 755 if ( appendLabels ) {
747 dayLabel = getNewDaylabel(); 756 dayLabel = getNewDaylabel();
748 } 757 }
749 dayLabel->setMinimumWidth( 1 ); 758 dayLabel->setMinimumWidth( 1 );
750 dayLabel->setMaximumWidth( 10240 ); 759 dayLabel->setMaximumWidth( 10240 );
751 dayLabel->setFont( dlf ); 760 dayLabel->setFont( dlf );
752 dayLabel->show(); 761 dayLabel->show();
753 dayLabel->setAutoRepeat( false ); 762 dayLabel->setAutoRepeat( false );
754 dayLabel->setNum( counter ); 763 dayLabel->setNum( counter );
755 QString str; 764 QString str;
756 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 765 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
757 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 766 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
758 switch ( maxLen ) { 767 switch ( maxLen ) {
759 case 2: 768 case 2:
760 str = QString::number( date.day() ); 769 str = QString::number( date.day() );
761 break; 770 break;
762 771
763 case 3: 772 case 3:
764 str = dayName.left( 1 ) +QString::number( date.day()); 773 str = dayName.left( 1 ) +QString::number( date.day());
765 774
766 break; 775 break;
767 case 4: 776 case 4:
768 str = dayName.left( 1 ) + " " +QString::number( date.day()); 777 str = dayName.left( 1 ) + " " +QString::number( date.day());
769 778
770 break; 779 break;
771 case 5: 780 case 5:
772 str = dayName.left( 2 ) + " " +QString::number( date.day()); 781 str = dayName.left( 2 ) + " " +QString::number( date.day());
773 782
774 break; 783 break;
775 case 6: 784 case 6:
776 str = dayName.left( 3 ) + " " +QString::number( date.day()); 785 str = dayName.left( 3 ) + " " +QString::number( date.day());
777 break; 786 break;
778 787
779 default: 788 default:
780 break; 789 break;
781 } 790 }
782 if ( oneday ) { 791 if ( oneday ) {
783 QString addString; 792 QString addString;
784 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 793 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
785 addString = i18n("Today"); 794 addString = i18n("Today");
786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 795 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
787 addString = i18n("Tomorrow"); 796 addString = i18n("Tomorrow");
788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 797 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
789 addString = i18n("Yesterday"); 798 addString = i18n("Yesterday");
790 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 799 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
791 addString = i18n("Day before yesterday"); 800 addString = i18n("Day before yesterday");
792 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 801 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
793 addString = i18n("Day after tomorrow"); 802 addString = i18n("Day after tomorrow");
794 if ( !addString.isEmpty() ) { 803 if ( !addString.isEmpty() ) {
795 str = addString+", " + str; 804 str = addString+", " + str;
796 } else { 805 } else {
797 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 806 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
798 } 807 }
799 } 808 }
800 dayLabel->setText(str); 809 dayLabel->setText(str);
801 //dayLabel->setAlignment(QLabel::AlignHCenter); 810 //dayLabel->setAlignment(QLabel::AlignHCenter);
802 if (date == QDate::currentDate()) { 811 if (date == QDate::currentDate()) {
803 QFont bFont = dlf; 812 QFont bFont = dlf;
804 bFont.setBold( true ); 813 bFont.setBold( true );
805 dayLabel->setFont(bFont); 814 dayLabel->setFont(bFont);
806 } 815 }
807 //dayLayout->addWidget(dayLabel); 816 //dayLayout->addWidget(dayLabel);
808 817
809#ifndef KORG_NOPLUGINS 818#ifndef KORG_NOPLUGINS
810 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 819 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
811 CalendarDecoration *it; 820 CalendarDecoration *it;
812 for(it = cds.first(); it; it = cds.next()) { 821 for(it = cds.first(); it; it = cds.next()) {
813 QString text = it->shortText( date ); 822 QString text = it->shortText( date );
814 if ( !text.isEmpty() ) { 823 if ( !text.isEmpty() ) {
815 QLabel *label = new QLabel(text,mDayLabels); 824 QLabel *label = new QLabel(text,mDayLabels);
816 label->setAlignment(AlignCenter); 825 label->setAlignment(AlignCenter);
817 dayLayout->addWidget(label); 826 dayLayout->addWidget(label);
818 } 827 }
819 } 828 }
820 829
821 for(it = cds.first(); it; it = cds.next()) { 830 for(it = cds.first(); it; it = cds.next()) {
822 QWidget *wid = it->smallWidget(mDayLabels,date); 831 QWidget *wid = it->smallWidget(mDayLabels,date);
823 if ( wid ) { 832 if ( wid ) {
824 // wid->setHeight(20); 833 // wid->setHeight(20);
825 dayLayout->addWidget(wid); 834 dayLayout->addWidget(wid);
826 } 835 }
827 } 836 }
828#endif 837#endif
829 } 838 }
830 if ( ! appendLabels ) { 839 if ( ! appendLabels ) {
831 dayLabel = mDayLabelsList.next(); 840 dayLabel = mDayLabelsList.next();
832 if ( !dayLabel ) 841 if ( !dayLabel )
833 appendLabels = true; 842 appendLabels = true;
834 } 843 }
835 if ( appendLabels ) { 844 if ( appendLabels ) {
836 dayLabel = getNewDaylabel(); 845 dayLabel = getNewDaylabel();
837 } 846 }
838 //dayLabel->hide();//test only 847 //dayLabel->hide();//test only
839 848
840 dayLabel->setText(">"); 849 dayLabel->setText(">");
841 dayLabel->setFont( dlf ); 850 dayLabel->setFont( dlf );
842 dayLabel->setAutoRepeat( true ); 851 dayLabel->setAutoRepeat( true );
843 dayLabel->show(); 852 dayLabel->show();
844 dayLabel->setNum( -2 ); 853 dayLabel->setNum( -2 );
845 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); 854 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
846 855
847 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 856 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
848 if ( !appendLabels ) { 857 if ( !appendLabels ) {
849 dayLabel = mDayLabelsList.next(); 858 dayLabel = mDayLabelsList.next();
850 while ( dayLabel ) { 859 while ( dayLabel ) {
851 //qDebug("!dayLabel %d",dayLabel ); 860 //qDebug("!dayLabel %d",dayLabel );
852 dayLabel->hide(); 861 dayLabel->hide();
853 dayLabel = mDayLabelsList.next(); 862 dayLabel = mDayLabelsList.next();
854 } 863 }
855 } 864 }
856 865
857 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 866 mDayLabelsFrame->setFixedHeight( newHight + 4 );
858} 867}
859 868
860int KOAgendaView::maxDatesHint() 869int KOAgendaView::maxDatesHint()
861{ 870{
862 // Not sure about the max number of events, so return 0 for now. 871 // Not sure about the max number of events, so return 0 for now.
863 return 0; 872 return 0;
864} 873}
865 874
866int KOAgendaView::currentDateCount() 875int KOAgendaView::currentDateCount()
867{ 876{
868 return mSelectedDates.count(); 877 return mSelectedDates.count();
869} 878}
870 879
871QPtrList<Incidence> KOAgendaView::selectedIncidences() 880QPtrList<Incidence> KOAgendaView::selectedIncidences()
872{ 881{
873 QPtrList<Incidence> selected; 882 QPtrList<Incidence> selected;
874 Incidence *incidence; 883 Incidence *incidence;
875 884
876 incidence = mAgenda->selectedIncidence(); 885 incidence = mAgenda->selectedIncidence();
877 if (incidence) selected.append(incidence); 886 if (incidence) selected.append(incidence);
878 887
879 incidence = mAllDayAgenda->selectedIncidence(); 888 incidence = mAllDayAgenda->selectedIncidence();
880 if (incidence) selected.append(incidence); 889 if (incidence) selected.append(incidence);
881 890
882 return selected; 891 return selected;
883} 892}
884 893
885DateList KOAgendaView::selectedDates() 894DateList KOAgendaView::selectedDates()
886{ 895{
887 DateList selected; 896 DateList selected;
888 QDate qd; 897 QDate qd;
889 898
890 qd = mAgenda->selectedIncidenceDate(); 899 qd = mAgenda->selectedIncidenceDate();
891 if (qd.isValid()) selected.append(qd); 900 if (qd.isValid()) selected.append(qd);
892 901
893 qd = mAllDayAgenda->selectedIncidenceDate(); 902 qd = mAllDayAgenda->selectedIncidenceDate();
894 if (qd.isValid()) selected.append(qd); 903 if (qd.isValid()) selected.append(qd);
895 904
896 return selected; 905 return selected;
897} 906}
898 907
899 908
900void KOAgendaView::updateView() 909void KOAgendaView::updateView()
901{ 910{
902 if ( mBlockUpdating ) 911 if ( mBlockUpdating )
903 return; 912 return;
904 // kdDebug() << "KOAgendaView::updateView()" << endl; 913 // kdDebug() << "KOAgendaView::updateView()" << endl;
905 fillAgenda(); 914 fillAgenda();
906 915
907} 916}
908 917
909 918
910/* 919/*
911 Update configuration settings for the agenda view. This method is not 920 Update configuration settings for the agenda view. This method is not
912 complete. 921 complete.
913*/ 922*/
914void KOAgendaView::updateConfig() 923void KOAgendaView::updateConfig()
915{ 924{
916 if ( mBlockUpdating ) 925 if ( mBlockUpdating )
917 return; 926 return;
918 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { 927 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
919 int old = KOPrefs::instance()->mHourSize; 928 int old = KOPrefs::instance()->mHourSize;
920 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; 929 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
921 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); 930 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
922 } 931 }
923 932
924 933
925 // update config for children 934 // update config for children
926 mTimeLabels->updateConfig(); 935 mTimeLabels->updateConfig();
927 mAgenda->storePosition(); 936 mAgenda->storePosition();
928 mAgenda->updateConfig(); 937 mAgenda->updateConfig();
929 mAllDayAgenda->updateConfig(); 938 mAllDayAgenda->updateConfig();
930 // widget synchronization 939 // widget synchronization
931 //TODO: find a better way, maybe signal/slot 940 //TODO: find a better way, maybe signal/slot
932 mTimeLabels->positionChanged(); 941 mTimeLabels->positionChanged();
933 942
934 // for some reason, this needs to be called explicitly 943 // for some reason, this needs to be called explicitly
935 mTimeLabels->repaint(); 944 mTimeLabels->repaint();
936 945
937 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 946 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
938 947
939 // ToolTips displaying summary of events 948 // ToolTips displaying summary of events
940 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 949 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
941 ->mEnableToolTips); 950 ->mEnableToolTips);
942 951
943 //setHolidayMasks(); 952 //setHolidayMasks();
944 953
945 //createDayLabels(); called by via updateView(); 954 //createDayLabels(); called by via updateView();
946 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 955 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
947 updateView(); 956 updateView();
948 mAgenda->restorePosition(); 957 mAgenda->restorePosition();
949} 958}
950 959
951 960
952void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 961void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
953{ 962{
954 963
955 964
956 int xxx = item->cellX(); 965 int xxx = item->cellX();
957 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); 966 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() );
958 if ( mMinY.at(xxx) > item->cellYTop() ) 967 if ( mMinY.at(xxx) > item->cellYTop() )
959 mMinY.at(xxx) = item->cellYTop(); 968 mMinY.at(xxx) = item->cellYTop();
960 if ( mMaxY.at(xxx) < item->cellYBottom() ) 969 if ( mMaxY.at(xxx) < item->cellYBottom() )
961 mMaxY.at(xxx) = item->cellYBottom(); 970 mMaxY.at(xxx) = item->cellYBottom();
962 971
963 QDateTime startDt,endDt; 972 QDateTime startDt,endDt;
964 QDate startDate; 973 QDate startDate;
965 int lenInSecs; 974 int lenInSecs;
966 // if ( type == KOAgenda::RESIZETOP ) 975 // if ( type == KOAgenda::RESIZETOP )
967 // qDebug("RESIZETOP "); 976 // qDebug("RESIZETOP ");
968 // if ( type == KOAgenda::RESIZEBOTTOM ) 977 // if ( type == KOAgenda::RESIZEBOTTOM )
969 // qDebug("RESIZEBOTTOM "); 978 // qDebug("RESIZEBOTTOM ");
970 // if ( type == KOAgenda::MOVE ) 979 // if ( type == KOAgenda::MOVE )
971 // qDebug("MOVE "); 980 // qDebug("MOVE ");
972 if ( item->incidence()->typeID() == eventID ) { 981 if ( item->incidence()->typeID() == eventID ) {
973 startDt =item->incidence()->dtStart(); 982 startDt =item->incidence()->dtStart();
974 endDt = item->incidence()->dtEnd(); 983 endDt = item->incidence()->dtEnd();
975 lenInSecs = startDt.secsTo( endDt ); 984 lenInSecs = startDt.secsTo( endDt );
976 } 985 }
977 986
978 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 987 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
979 988
980 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { 989 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) {
981 startDate = mSelectedDates[item->mLastMoveXPos]; 990 startDate = mSelectedDates[item->mLastMoveXPos];
982 } else { 991 } else {
983 if (item->cellX() < 0) { 992 if (item->cellX() < 0) {
984 startDate = (mSelectedDates.first()).addDays(item->cellX()); 993 startDate = (mSelectedDates.first()).addDays(item->cellX());
985 } else { 994 } else {
986 startDate = mSelectedDates[item->cellX()]; 995 startDate = mSelectedDates[item->cellX()];
987 } 996 }
988 } 997 }
989 startDt.setDate(startDate); 998 startDt.setDate(startDate);
990 999
991 if (item->incidence()->doesFloat()) { 1000 if (item->incidence()->doesFloat()) {
992 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 1001 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
993 } else { 1002 } else {
994 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 1003 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
995 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 1004 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
996 if ( item->incidence()->typeID() == eventID ) { 1005 if ( item->incidence()->typeID() == eventID ) {
997 if ( type == KOAgenda::MOVE ) { 1006 if ( type == KOAgenda::MOVE ) {
998 endDt = startDt.addSecs(lenInSecs); 1007 endDt = startDt.addSecs(lenInSecs);
999 1008
1000 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 1009 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
1001 if (item->lastMultiItem()) { 1010 if (item->lastMultiItem()) {
1002 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1011 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1003 endDt.setDate(startDate. 1012 endDt.setDate(startDate.
1004 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1013 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1005 } else { 1014 } else {
1006 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1015 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1007 endDt.setDate(startDate); 1016 endDt.setDate(startDate);
1008 } 1017 }
1009 } 1018 }
1010 } else { 1019 } else {
1011 // todo 1020 // todo
1012 if (item->lastMultiItem()) { 1021 if (item->lastMultiItem()) {
1013 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1022 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1014 endDt.setDate(startDate. 1023 endDt.setDate(startDate.
1015 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1024 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1016 } else { 1025 } else {
1017 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 1026 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
1018 if ( item->cellYBottom() > 0 ) 1027 if ( item->cellYBottom() > 0 )
1019 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1028 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1020 else 1029 else
1021 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 1030 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
1022 endDt.setDate(startDate); 1031 endDt.setDate(startDate);
1023 } 1032 }
1024 } 1033 }
1025 } 1034 }
1026 if ( item->incidence()->typeID() == eventID ) { 1035 if ( item->incidence()->typeID() == eventID ) {
1027 item->incidence()->setDtStart(startDt); 1036 item->incidence()->setDtStart(startDt);
1028 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1037 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1029 } else if ( item->incidence()->typeID() == todoID ) { 1038 } else if ( item->incidence()->typeID() == todoID ) {
1030 Todo* to = static_cast<Todo*>(item->incidence()); 1039 Todo* to = static_cast<Todo*>(item->incidence());
1031 1040
1032 to->setDtDue(endDt); 1041 to->setDtDue(endDt);
1033 if ( to->hasStartDate() ) { 1042 if ( to->hasStartDate() ) {
1034 if (to->dtStart() >= to->dtDue() ) 1043 if (to->dtStart() >= to->dtDue() )
1035 to->setDtStart(to->dtDue().addDays( -2 )); 1044 to->setDtStart(to->dtDue().addDays( -2 ));
1036 } 1045 }
1037 1046
1038 } 1047 }
1039 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1048 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1040 item->incidence()->setRevision(item->incidence()->revision()+1); 1049 item->incidence()->setRevision(item->incidence()->revision()+1);
1041 item->setItemDate(startDt.date()); 1050 item->setItemDate(startDt.date());
1042 //item->updateItem(); 1051 //item->updateItem();
1043 if ( item->incidence()->typeID() == todoID ) { 1052 if ( item->incidence()->typeID() == todoID ) {
1044 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1053 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1045 1054
1046 } 1055 }
1047 else 1056 else
1048 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1057 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1049 item->updateItem(); 1058 item->updateItem();
1050} 1059}
1051 1060
1052void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1061void KOAgendaView::showDates( const QDate &start, const QDate &end )
1053{ 1062{
1054 // kdDebug() << "KOAgendaView::selectDates" << endl; 1063 // kdDebug() << "KOAgendaView::selectDates" << endl;
1055 1064
1056 mSelectedDates.clear(); 1065 mSelectedDates.clear();
1057 // qDebug("KOAgendaView::showDates "); 1066 // qDebug("KOAgendaView::showDates ");
1058 QDate d = start; 1067 QDate d = start;
1059 while (d <= end) { 1068 while (d <= end) {
1060 mSelectedDates.append(d); 1069 mSelectedDates.append(d);
1061 d = d.addDays( 1 ); 1070 d = d.addDays( 1 );
1062 } 1071 }
1063 1072
1064 // and update the view 1073 // and update the view
1065 fillAgenda(); 1074 fillAgenda();
1066} 1075}
1067 1076
1068 1077
1069void KOAgendaView::showEvents(QPtrList<Event>) 1078void KOAgendaView::showEvents(QPtrList<Event>)
1070{ 1079{
1071 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1080 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1072} 1081}
1073 1082
1074void KOAgendaView::changeEventDisplay(Event *, int) 1083void KOAgendaView::changeEventDisplay(Event *, int)
1075{ 1084{
1076 // qDebug("KOAgendaView::changeEventDisplay "); 1085 // qDebug("KOAgendaView::changeEventDisplay ");
1077 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1086 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1078 // this should be re-written to be MUCH smarter. Right now we 1087 // this should be re-written to be MUCH smarter. Right now we
1079 // are just playing dumb. 1088 // are just playing dumb.
1080 fillAgenda(); 1089 fillAgenda();
1081} 1090}
1082 1091
1083void KOAgendaView::fillAgenda(const QDate &) 1092void KOAgendaView::fillAgenda(const QDate &)
1084{ 1093{
1085 // qDebug("KOAgendaView::fillAgenda "); 1094 // qDebug("KOAgendaView::fillAgenda ");
1086 fillAgenda(); 1095 fillAgenda();
1087} 1096}
1088 1097
1089void KOAgendaView::fillAgenda() 1098void KOAgendaView::fillAgenda()
1090{ 1099{
1091 if ( globalFlagBlockStartup ) 1100 if ( globalFlagBlockStartup )
1092 return; 1101 return;
1093 if ( globalFlagBlockAgenda == 1 ) 1102 if ( globalFlagBlockAgenda == 1 )
1094 return; 1103 return;
1095 static bool onlyOne = false; 1104 static bool onlyOne = false;
1096 if ( onlyOne ) 1105 if ( onlyOne )
1097 return; 1106 return;
1098 onlyOne = true; 1107 onlyOne = true;
1099 //if ( globalFlagBlockAgenda == 2 ) 1108 //if ( globalFlagBlockAgenda == 2 )
1100 //globalFlagBlockAgenda = 0; 1109 //globalFlagBlockAgenda = 0;
1101 // globalFlagBlockPainting = false; 1110 // globalFlagBlockPainting = false;
1102 if ( globalFlagBlockAgenda == 0 ) 1111 if ( globalFlagBlockAgenda == 0 )
1103 globalFlagBlockAgenda = 1; 1112 globalFlagBlockAgenda = 1;
1104 // clearView(); 1113 // clearView();
1105 //qDebug("fillAgenda()++++ "); 1114 //qDebug("fillAgenda()++++ ");
1106 globalFlagBlockAgendaItemPaint = 1; 1115 globalFlagBlockAgendaItemPaint = 1;
1107 1116
1108 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1117 mAllDayAgenda->changeColumns(mSelectedDates.count());
1109 mAgenda->changeColumns(mSelectedDates.count()); 1118 mAgenda->changeColumns(mSelectedDates.count());
1110 qApp->processEvents(); 1119 qApp->processEvents();
1111 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1120 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1112 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1121 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1113 setHolidayMasks(); 1122 setHolidayMasks();
1114 1123
1115 //mAgenda->hideUnused(); 1124 //mAgenda->hideUnused();
1116 //mAllDayAgenda->hideUnused(); 1125 //mAllDayAgenda->hideUnused();
1117 1126
1118 // mAgenda->blockNextRepaint( false ); 1127 // mAgenda->blockNextRepaint( false );
1119 // mAgenda->viewport()->repaint(); 1128 // mAgenda->viewport()->repaint();
1120 // mAgenda->blockNextRepaint( true ); 1129 // mAgenda->blockNextRepaint( true );
1121 mMinY.resize(mSelectedDates.count()); 1130 mMinY.resize(mSelectedDates.count());
1122 mMaxY.resize(mSelectedDates.count()); 1131 mMaxY.resize(mSelectedDates.count());
1123 1132
1124 QPtrList<Event> dayEvents; 1133 QPtrList<Event> dayEvents;
1125 1134
1126 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1135 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1127 // Therefore, gtodoset all of them. 1136 // Therefore, gtodoset all of them.
1128 QPtrList<Todo> todos = calendar()->todos(); 1137 QPtrList<Todo> todos = calendar()->todos();
1129 1138
1130 mAgenda->setDateList(mSelectedDates); 1139 mAgenda->setDateList(mSelectedDates);
1131 1140
1132 QDate today = QDate::currentDate(); 1141 QDate today = QDate::currentDate();
1133 1142
1134 DateList::ConstIterator dit; 1143 DateList::ConstIterator dit;
1135 int curCol = 0; 1144 int curCol = 0;
1136 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1145 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1137 QDate currentDate = *dit; 1146 QDate currentDate = *dit;
1138 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1147 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1139 // << endl; 1148 // << endl;
1140 1149
1141 dayEvents = calendar()->events(currentDate,true); 1150 dayEvents = calendar()->events(currentDate,true);
1142 1151
1143 // Default values, which can never be reached 1152 // Default values, which can never be reached
1144 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1153 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1145 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1154 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1146 1155
1147 unsigned int numEvent; 1156 unsigned int numEvent;
1148 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1157 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1149 Event *event = dayEvents.at(numEvent); 1158 Event *event = dayEvents.at(numEvent);
1150 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1159 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1151 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1160 if ( event->uid().left(15) == QString("last-syncEvent-") )
1152 continue; 1161 continue;
1153 // kdDebug() << " Event: " << event->summary() << endl; 1162 // kdDebug() << " Event: " << event->summary() << endl;
1154 1163
1155 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1164 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1156 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1165 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1157 1166
1158 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1167 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1159 1168
1160 if (event->doesFloat()) { 1169 if (event->doesFloat()) {
1161 if (event->recurrence()->doesRecur()) { 1170 if (event->recurrence()->doesRecur()) {
1162 if (event->isMultiDay() ) { 1171 if (event->isMultiDay() ) {
1163 endX = endX - beginX;// endX is now number of days 1172 endX = endX - beginX;// endX is now number of days
1164 if ( event->recursOn( currentDate ) ) { 1173 if ( event->recursOn( currentDate ) ) {
1165 endX += curCol; 1174 endX += curCol;
1166 beginX = curCol; 1175 beginX = curCol;
1167 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1176 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1168 } else { 1177 } else {
1169 //qDebug("days %d %s",endX , currentDate.toString().latin1()); 1178 //qDebug("days %d %s",endX , currentDate.toString().latin1());
1170 QDate dateit = currentDate.addDays( -endX ); 1179 QDate dateit = currentDate.addDays( -endX );
1171 if ( event->recursOn( dateit ) ) { 1180 if ( event->recursOn( dateit ) ) {
1172 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); 1181 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
1173 if ( curCol-endX < 0 ) { 1182 if ( curCol-endX < 0 ) {
1174 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1183 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1175 } 1184 }
1176 } 1185 }
1177 } 1186 }
1178 } else { 1187 } else {
1179 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1188 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1180 } 1189 }
1181 1190
1182 } else { 1191 } else {
1183 if (beginX <= 0 && curCol == 0) { 1192 if (beginX <= 0 && curCol == 0) {
1184 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1193 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1185 } else if (beginX == curCol) { 1194 } else if (beginX == curCol) {
1186 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1195 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1187 } 1196 }
1188 } 1197 }
1189 } else if (event->isMultiDay()) { 1198 } else if (event->isMultiDay()) {
1190 if ( event->doesRecur () ) { 1199 if ( event->doesRecur () ) {
1191 QDate dateit = currentDate; 1200 QDate dateit = currentDate;
1192 int count = 0; 1201 int count = 0;
1193 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1202 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1194 while (! event->recursOn( dateit ) && count <= max ) { 1203 while (! event->recursOn( dateit ) && count <= max ) {
1195 ++count; 1204 ++count;
1196 dateit = dateit.addDays( -1 ); 1205 dateit = dateit.addDays( -1 );
1197 } 1206 }
1198 bool ok; 1207 bool ok;
1199 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1208 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1200 if ( ok ) 1209 if ( ok )
1201 { 1210 {
1202 int secs = event->dtStart().secsTo( event->dtEnd() ); 1211 int secs = event->dtStart().secsTo( event->dtEnd() );
1203 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1212 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1204 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1213 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1205 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1214 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1206 1215
1207 } 1216 }
1208 } 1217 }
1209 int startY = mAgenda->timeToY(event->dtStart().time()); 1218 int startY = mAgenda->timeToY(event->dtStart().time());
1210 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1219 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1211 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1220 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1212 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1221 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1213 //qDebug("insert!!! "); 1222 //qDebug("insert!!! ");
1214 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1223 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1215 } 1224 }
1216 if (beginX == curCol) { 1225 if (beginX == curCol) {
1217 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1226 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1218 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1227 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1219 } else if (endX == curCol) { 1228 } else if (endX == curCol) {
1220 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1229 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1221 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1230 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1222 } else { 1231 } else {
1223 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1232 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1224 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1233 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1225 } 1234 }
1226 } else { 1235 } else {
1227 int startY = mAgenda->timeToY(event->dtStart().time()); 1236 int startY = mAgenda->timeToY(event->dtStart().time());
1228 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1237 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1229 if (endY < startY) endY = startY; 1238 if (endY < startY) endY = startY;
1230 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1239 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1231 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1240 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1232 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1241 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1233 } 1242 }
1234 } 1243 }
1235 // ---------- [display Todos -------------- 1244 // ---------- [display Todos --------------
1236 unsigned int numTodo; 1245 unsigned int numTodo;
1237 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1246 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1238 Todo *todo = todos.at(numTodo); 1247 Todo *todo = todos.at(numTodo);
1239 1248
1240 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1249 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1241 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; 1250 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue;
1242 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1251 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1243 // Already completed items can be displayed on their original due date 1252 // Already completed items can be displayed on their original due date
1244 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1253 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1245 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1254 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1246 bool fillIn = false; 1255 bool fillIn = false;
1247 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1256 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1248 fillIn = true; 1257 fillIn = true;
1249 if ( ! fillIn && !todo->hasCompletedDate() ) 1258 if ( ! fillIn && !todo->hasCompletedDate() )
1250 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1259 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1251 if ( fillIn ) { 1260 if ( fillIn ) {
1252 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1261 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1253 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1262 if ( KOPrefs::instance()->mShowTodoInAgenda )
1254 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1263 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1255 } 1264 }
1256 else { 1265 else {
1257 QDateTime dt; 1266 QDateTime dt;
1258 if ( todo->hasCompletedDate() ) 1267 if ( todo->hasCompletedDate() )
1259 dt = todo->completed(); 1268 dt = todo->completed();
1260 else 1269 else
1261 dt = todo->dtDue();; 1270 dt = todo->dtDue();;
1262 1271
1263 1272
1264 int endY = mAgenda->timeToY(dt.time()) - 1; 1273 int endY = mAgenda->timeToY(dt.time()) - 1;
1265 int hi = (18/KOPrefs::instance()->mHourSize); 1274 int hi = (18/KOPrefs::instance()->mHourSize);
1266 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1275 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1267 int startY = endY -hi; 1276 int startY = endY -hi;
1268 1277
1269 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1278 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1270 1279
1271 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1280 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1272 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1281 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1273 } 1282 }
1274 } 1283 }
1275 } 1284 }
1276 // ---------- display Todos] -------------- 1285 // ---------- display Todos] --------------
1277 1286
1278 ++curCol; 1287 ++curCol;
1279 } 1288 }
1280 mAgenda->hideUnused(); 1289 mAgenda->hideUnused();
1281 mAllDayAgenda->hideUnused(); 1290 mAllDayAgenda->hideUnused();
1282 mAgenda->checkScrollBoundaries(); 1291 mAgenda->checkScrollBoundaries();
1283 1292
1284 deleteSelectedDateTime(); 1293 deleteSelectedDateTime();
1285 1294
1286 createDayLabels(); 1295 createDayLabels();
1287 emit incidenceSelected( 0 ); 1296 emit incidenceSelected( 0 );
1288 1297
1289 if ( globalFlagBlockAgenda == 2 ) { 1298 if ( globalFlagBlockAgenda == 2 ) {
1290 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1299 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1291 setStartHour( KOPrefs::instance()->mDayBegins ); 1300 setStartHour( KOPrefs::instance()->mDayBegins );
1292 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1301 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1293 setStartHour( QTime::currentTime ().hour() ); 1302 setStartHour( QTime::currentTime ().hour() );
1294 // qApp->processEvents(); 1303 // qApp->processEvents();
1295 } 1304 }
1296 qApp->processEvents(); 1305 qApp->processEvents();
1297 //qDebug("qApp->processEvents(); END "); 1306 //qDebug("qApp->processEvents(); END ");
1298 globalFlagBlockAgenda = 0; 1307 globalFlagBlockAgenda = 0;
1299 1308
1300 // mAgenda->hideUnused(); 1309 // mAgenda->hideUnused();
1301 //mAllDayAgenda->hideUnused(); 1310 //mAllDayAgenda->hideUnused();
1302 mAllDayAgenda->drawContentsToPainter(); 1311 mAllDayAgenda->drawContentsToPainter();
1303 mAgenda->drawContentsToPainter(); 1312 mAgenda->drawContentsToPainter();
1304 repaintAgenda(); 1313 repaintAgenda();
1305 onlyOne = false; 1314 onlyOne = false;
1306 // mAgenda->finishUpdate(); 1315 // mAgenda->finishUpdate();
1307 //mAllDayAgenda->finishUpdate(); 1316 //mAllDayAgenda->finishUpdate();
1308 1317
1309 // repaintAgenda(); 1318 // repaintAgenda();
1310 //qApp->processEvents(); 1319 //qApp->processEvents();
1311 // globalFlagBlockAgenda = 0; 1320 // globalFlagBlockAgenda = 0;
1312} 1321}
1313void KOAgendaView::repaintAgenda() 1322void KOAgendaView::repaintAgenda()
1314{ 1323{
1315 // mAllDayAgenda->drawContentsToPainter(); 1324 // mAllDayAgenda->drawContentsToPainter();
1316// mAllDayAgenda->viewport()->repaint( false ); 1325// mAllDayAgenda->viewport()->repaint( false );
1317// mAgenda->drawContentsToPainter(); 1326// mAgenda->drawContentsToPainter();
1318// mAgenda->viewport()->repaint( false ); 1327// mAgenda->viewport()->repaint( false );
1319// qApp->processEvents(); 1328// qApp->processEvents();
1320 1329
1321 //qDebug("KOAgendaView::repaintAgenda() "); 1330 //qDebug("KOAgendaView::repaintAgenda() ");
1322 //qApp->processEvents(); 1331 //qApp->processEvents();
1323 mAgenda->viewport()->repaint( false ); 1332 mAgenda->viewport()->repaint( false );
1324 mAllDayAgenda->viewport()->repaint( false ); 1333 mAllDayAgenda->viewport()->repaint( false );
1325 mAgenda->finishUpdate(); 1334 mAgenda->finishUpdate();
1326 mAllDayAgenda->finishUpdate(); 1335 mAllDayAgenda->finishUpdate();
1327} 1336}
1328 1337
1329 1338
1330void KOAgendaView::clearView() 1339void KOAgendaView::clearView()
1331{ 1340{
1332 // kdDebug() << "ClearView" << endl; 1341 // kdDebug() << "ClearView" << endl;
1333 mAllDayAgenda->clear(); 1342 mAllDayAgenda->clear();
1334 mAgenda->clear(); 1343 mAgenda->clear();
1335} 1344}
1336void KOAgendaView::clearList() 1345void KOAgendaView::clearList()
1337{ 1346{
1338 // kdDebug() << "ClearView" << endl; 1347 // kdDebug() << "ClearView" << endl;
1339 clearView(); 1348 clearView();
1340 mAllDayAgenda->hideUnused(); 1349 mAllDayAgenda->hideUnused();
1341 mAgenda->hideUnused(); 1350 mAgenda->hideUnused();
1342} 1351}
1343 1352
1344void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1353void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1345 const QDate &td) 1354 const QDate &td)
1346{ 1355{
1347#ifndef KORG_NOPRINTER 1356#ifndef KORG_NOPRINTER
1348 if (fd == td) 1357 if (fd == td)
1349 calPrinter->preview(CalPrinter::Day, fd, td); 1358 calPrinter->preview(CalPrinter::Day, fd, td);
1350 else 1359 else
1351 calPrinter->preview(CalPrinter::Week, fd, td); 1360 calPrinter->preview(CalPrinter::Week, fd, td);
1352#endif 1361#endif
1353} 1362}
1354 1363
1355// void KOAgendaView::updateMovedTodo() 1364// void KOAgendaView::updateMovedTodo()
1356// { 1365// {
1357// // updateConfig(); 1366// // updateConfig();
1358// // emit updateTodoViews(); 1367// // emit updateTodoViews();
1359// } 1368// }
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index cc953fc..a1cf308 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -1,293 +1,294 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDAVIEW_H 23#ifndef KOAGENDAVIEW_H
24#define KOAGENDAVIEW_H 24#define KOAGENDAVIEW_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qksplitter.h> 31#include <qksplitter.h>
32#else 32#else
33#include <qsplitter.h> 33#include <qsplitter.h>
34#endif 34#endif
35#include <qmemarray.h> 35#include <qmemarray.h>
36 36
37#include "koeventview.h" 37#include "koeventview.h"
38 38
39class QHBox; 39class QHBox;
40class QFrame; 40class QFrame;
41class QLabel; 41class QLabel;
42class QPushButton; 42class QPushButton;
43class CalendarView; 43class CalendarView;
44class KOAgenda; 44class KOAgenda;
45class KOAgendaItem; 45class KOAgendaItem;
46class KConfig; 46class KConfig;
47class KDGanttMinimizeSplitter; 47class KDGanttMinimizeSplitter;
48 48
49class KOAgendaButton : public QPushButton 49class KOAgendaButton : public QPushButton
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) : 53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) :
54 QPushButton( parent, name ) 54 QPushButton( parent, name )
55 { 55 {
56 mNum = -3; 56 mNum = -3;
57 setFlat( true ); 57 setFlat( true );
58 setFocusPolicy(NoFocus); 58 setFocusPolicy(NoFocus);
59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); 59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) ); 60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) );
61 }; 61 };
62 62
63 QSize sizeHint () const { return QSize( 5,5) ;} 63 QSize sizeHint () const { return QSize( 5,5) ;}
64 void setNum( int n) { mNum = n; } 64 void setNum( int n) { mNum = n; }
65private slots: 65private slots:
66 void bClicked() {emit numClicked( mNum);} 66 void bClicked() {emit numClicked( mNum);}
67signals: 67signals:
68 void numClicked( int ); 68 void numClicked( int );
69private: 69private:
70 int mNum; 70 int mNum;
71}; 71};
72 72
73class TimeLabels : public QScrollView { 73class TimeLabels : public QScrollView {
74 Q_OBJECT 74 Q_OBJECT
75 public: 75 public:
76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
77 77
78 void setCellHeight(int height); 78 void setCellHeight(int height);
79 79
80 /** Calculates the minimum width */ 80 /** Calculates the minimum width */
81 virtual int minimumWidth() const; 81 virtual int minimumWidth() const;
82 82
83 /** updates widget's internal state */ 83 /** updates widget's internal state */
84 void updateConfig(); 84 void updateConfig();
85 85
86 /** */ 86 /** */
87 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
88 88
89 /** */ 89 /** */
90 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
91 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
92 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
93 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
94 94
95 public slots: 95 public slots:
96 /** update time label positions */ 96 /** update time label positions */
97 void positionChanged(); 97 void positionChanged();
98 signals: 98 signals:
99 void scaleChanged(); 99 void scaleChanged();
100 protected: 100 protected:
101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
102 102
103 private: 103 private:
104 QPixmap myPix; 104 QPixmap myPix;
105 bool mRedrawNeeded; 105 bool mRedrawNeeded;
106 int mMiniWidth; 106 int mMiniWidth;
107 int mMouseDownY; 107 int mMouseDownY;
108 QString mOrgCap; 108 QString mOrgCap;
109 int mRows; 109 int mRows;
110 int mCellHeight; 110 int mCellHeight;
111 111
112 /** */ 112 /** */
113 KOAgenda* mAgenda; 113 KOAgenda* mAgenda;
114}; 114};
115 115
116class EventIndicator : public QFrame { 116class EventIndicator : public QFrame {
117 Q_OBJECT 117 Q_OBJECT
118 public: 118 public:
119 enum Location { Top, Bottom }; 119 enum Location { Top, Bottom };
120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
121 virtual ~EventIndicator(); 121 virtual ~EventIndicator();
122 122
123 void changeColumns(int columns); 123 void changeColumns(int columns);
124 void setPaintWidget( KDGanttMinimizeSplitter* ); 124 void setPaintWidget( KDGanttMinimizeSplitter* );
125 void setXOffset( int ); 125 void setXOffset( int );
126 void enableColumn(int column, bool enable); 126 void enableColumn(int column, bool enable);
127 127
128 protected: 128 protected:
129 void drawContents(QPainter *); 129 void drawContents(QPainter *);
130 130
131 private: 131 private:
132 int mXOffset; 132 int mXOffset;
133 KDGanttMinimizeSplitter* mPaintWidget; 133 KDGanttMinimizeSplitter* mPaintWidget;
134 int mColumns; 134 int mColumns;
135 QHBox *mTopBox; 135 QHBox *mTopBox;
136 QBoxLayout *mTopLayout; 136 QBoxLayout *mTopLayout;
137 Location mLocation; 137 Location mLocation;
138 QPixmap mPixmap; 138 QPixmap mPixmap;
139 QMemArray<bool> mEnabled; 139 QMemArray<bool> mEnabled;
140}; 140};
141 141
142/** 142/**
143 KOAgendaView is the agenda-like view used to display events in an one or 143 KOAgendaView is the agenda-like view used to display events in an one or
144 multi-day view. 144 multi-day view.
145*/ 145*/
146class KOAgendaView : public KOEventView { 146class KOAgendaView : public KOEventView {
147 Q_OBJECT 147 Q_OBJECT
148 public: 148 public:
149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
150 virtual ~KOAgendaView(); 150 virtual ~KOAgendaView();
151 void setStartHour( int ); 151 void setStartHour( int );
152 void toggleAllDay(); 152 void toggleAllDay();
153 153
154 154
155 /** Returns maximum number of days supported by the koagendaview */ 155 /** Returns maximum number of days supported by the koagendaview */
156 virtual int maxDatesHint(); 156 virtual int maxDatesHint();
157 157
158 /** Returns number of currently shown dates. */ 158 /** Returns number of currently shown dates. */
159 virtual int currentDateCount(); 159 virtual int currentDateCount();
160 160
161 /** returns the currently selected events */ 161 /** returns the currently selected events */
162 virtual QPtrList<Incidence> selectedIncidences(); 162 virtual QPtrList<Incidence> selectedIncidences();
163 163
164 /** returns the currently selected events */ 164 /** returns the currently selected events */
165 virtual DateList selectedDates(); 165 virtual DateList selectedDates();
166 166
167 /** Remove all events from view */ 167 /** Remove all events from view */
168 void clearView(); 168 void clearView();
169 void clearList(); 169 void clearList();
170 KOAgenda *agenda() { return mAgenda;} 170 KOAgenda *agenda() { return mAgenda;}
171 virtual void printPreview(CalPrinter *calPrinter, 171 virtual void printPreview(CalPrinter *calPrinter,
172 const QDate &, const QDate &); 172 const QDate &, const QDate &);
173 173
174 /** start-datetime of selection */ 174 /** start-datetime of selection */
175 QDateTime selectionStart() {return mTimeSpanBegin;} 175 QDateTime selectionStart() {return mTimeSpanBegin;}
176 /** end-datetime of selection */ 176 /** end-datetime of selection */
177 QDateTime selectionEnd() {return mTimeSpanEnd;} 177 QDateTime selectionEnd() {return mTimeSpanEnd;}
178 /** returns true if selection is for whole day */ 178 /** returns true if selection is for whole day */
179 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 179 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
180 /** make selected start/end invalid */ 180 /** make selected start/end invalid */
181 void deleteSelectedDateTime(); 181 void deleteSelectedDateTime();
182 void repaintAgenda(); 182 void repaintAgenda();
183 public slots: 183 public slots:
184 void setInitStartHour(); 184 void setInitStartHour();
185 virtual void updateView(); 185 virtual void updateView();
186 virtual void updateConfig(); 186 virtual void updateConfig();
187 virtual void showDates(const QDate &start, const QDate &end); 187 virtual void showDates(const QDate &start, const QDate &end);
188 virtual void showEvents(QPtrList<Event> eventList); 188 virtual void showEvents(QPtrList<Event> eventList);
189 189
190 void updateTodo( Todo *, int ); 190 void updateTodo( Todo *, int );
191 void changeEventDisplay(Event *, int); 191 void changeEventDisplay(Event *, int);
192 192
193 void clearSelection(); 193 void clearSelection();
194 194
195 void newTodo(int gx,int gy); 195 void newTodo(int gx,int gy);
196 void newEvent(int gx,int gy); 196 void newEvent(int gx,int gy);
197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
198 void newEventAllDay(int gx, int gy); 198 void newEventAllDay(int gx, int gy);
199 void newTodoAllDay(int gx, int gy); 199 void newTodoAllDay(int gx, int gy);
200 200
201 void startDrag(Event *); 201 void startDrag(Event *);
202 202
203 void readSettings(); 203 void readSettings();
204 void readSettings(KConfig *); 204 void readSettings(KConfig *);
205 void writeSettings(KConfig *); 205 void writeSettings(KConfig *);
206 206
207 void setContentsPos(int y); 207 void setContentsPos(int y);
208 208
209 void scrollOneHourUp(); 209 void scrollOneHourUp();
210 void scrollOneHourDown(); 210 void scrollOneHourDown();
211 void addToCalSlot(Incidence *, Incidence *); 211 void addToCalSlot(Incidence *, Incidence *);
212 void slotShowDateView( int, int ); 212 void slotShowDateView( int, int );
213 213
214 signals: 214 signals:
215 void showDateView( int, QDate ); 215 void showDateView( int, QDate );
216 void newTodoSignal( QDateTime ,bool ); 216 void newTodoSignal( QDateTime ,bool );
217 void toggleExpand(); 217 void toggleExpand();
218 void selectWeekNum( int ); 218 void selectWeekNum( int );
219 void todoMoved( Todo *, int ); 219 void todoMoved( Todo *, int );
220 void incidenceChanged(Incidence * , int ); 220 void incidenceChanged(Incidence * , int );
221 // void cloneIncidenceSignal(Incidence *); 221 // void cloneIncidenceSignal(Incidence *);
222 222
223 protected: 223 protected:
224 KOAgendaButton* getNewDaylabel(); 224 KOAgendaButton* getNewDaylabel();
225 bool mBlockUpdating; 225 bool mBlockUpdating;
226 int mUpcomingWidth; 226 int mUpcomingWidth;
227 /** Fill agenda beginning with date startDate */ 227 /** Fill agenda beginning with date startDate */
228 void fillAgenda(const QDate &startDate); 228 void fillAgenda(const QDate &startDate);
229 void resizeEvent( QResizeEvent* e ); 229 void resizeEvent( QResizeEvent* e );
230 /** Fill agenda using the current set value for the start date */ 230 /** Fill agenda using the current set value for the start date */
231 void fillAgenda(); 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 categoryChanged( Incidence * );
242 void slotDaylabelClicked( int ); 243 void slotDaylabelClicked( int );
243 /** Update event belonging to agenda item */ 244 /** Update event belonging to agenda item */
244 void updateEventDates(KOAgendaItem *item, int mode = -1); 245 void updateEventDates(KOAgendaItem *item, int mode = -1);
245 //void updateMovedTodo(); 246 //void updateMovedTodo();
246 247
247 void updateEventIndicatorTop(int newY); 248 void updateEventIndicatorTop(int newY);
248 void updateEventIndicatorBottom(int newY); 249 void updateEventIndicatorBottom(int newY);
249 250
250 /** Updates data for selected timespan */ 251 /** Updates data for selected timespan */
251 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 252 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
252 /** Updates data for selected timespan for all day event*/ 253 /** Updates data for selected timespan for all day event*/
253 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 254 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
254 255
255 private: 256 private:
256 // view widgets 257 // view widgets
257 QFrame *mDayLabels; 258 QFrame *mDayLabels;
258 QHBox *mDayLabelsFrame; 259 QHBox *mDayLabelsFrame;
259 QBoxLayout *mLayoutDayLabels; 260 QBoxLayout *mLayoutDayLabels;
260 QFrame *mAllDayFrame; 261 QFrame *mAllDayFrame;
261 KOAgenda *mAllDayAgenda; 262 KOAgenda *mAllDayAgenda;
262 KOAgenda *mAgenda; 263 KOAgenda *mAgenda;
263 TimeLabels *mTimeLabels; 264 TimeLabels *mTimeLabels;
264 QWidget *mDummyAllDayLeft; 265 QWidget *mDummyAllDayLeft;
265 266
266 KDGanttMinimizeSplitter* mSplitterAgenda; 267 KDGanttMinimizeSplitter* mSplitterAgenda;
267 QPushButton *mExpandButton; 268 QPushButton *mExpandButton;
268 269
269 DateList mSelectedDates; // List of dates to be displayed 270 DateList mSelectedDates; // List of dates to be displayed
270 int mViewType; 271 int mViewType;
271 272
272 bool mWeekStartsMonday; 273 bool mWeekStartsMonday;
273 int mStartHour; 274 int mStartHour;
274 275
275 KOEventPopupMenu *mAllAgendaPopup; 276 KOEventPopupMenu *mAllAgendaPopup;
276 //KOEventPopupMenu *mAllDayAgendaPopup; 277 //KOEventPopupMenu *mAllDayAgendaPopup;
277 278
278 EventIndicator *mEventIndicatorTop; 279 EventIndicator *mEventIndicatorTop;
279 EventIndicator *mEventIndicatorBottom; 280 EventIndicator *mEventIndicatorBottom;
280 281
281 QMemArray<int> mMinY; 282 QMemArray<int> mMinY;
282 QMemArray<int> mMaxY; 283 QMemArray<int> mMaxY;
283 284
284 QMemArray<bool> mHolidayMask; 285 QMemArray<bool> mHolidayMask;
285 286
286 QPtrList<KOAgendaButton> mDayLabelsList; 287 QPtrList<KOAgendaButton> mDayLabelsList;
287 QDateTime mTimeSpanBegin; 288 QDateTime mTimeSpanBegin;
288 QDateTime mTimeSpanEnd; 289 QDateTime mTimeSpanEnd;
289 bool mTimeSpanInAllDay; 290 bool mTimeSpanInAllDay;
290 void keyPressEvent ( QKeyEvent * e ); 291 void keyPressEvent ( QKeyEvent * e );
291}; 292};
292 293
293#endif // KOAGENDAVIEW_H 294#endif // KOAGENDAVIEW_H
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp
index 17ef81e..90caaf4 100644
--- a/korganizer/koeventpopupmenu.cpp
+++ b/korganizer/koeventpopupmenu.cpp
@@ -1,130 +1,168 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcursor.h> 24#include <qcursor.h>
25 25
26#include <klocale.h> 26#include <klocale.h>
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kiconloader.h> 28#include <kiconloader.h>
29 29
30#include <libkcal/event.h> 30#include <libkcal/event.h>
31 31
32#include "koeventpopupmenu.h" 32#include "koeventpopupmenu.h"
33#include "koprefs.h"
33 34
34KOEventPopupMenu::KOEventPopupMenu() 35KOEventPopupMenu::KOEventPopupMenu(): QPopupMenu()
35{ 36{
36 mCurrentIncidence = 0; 37 mCurrentIncidence = 0;
37 mHasAdditionalItems = false; 38 mHasAdditionalItems = false;
38 39
39 40
40 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow()))); 41 mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow())));
41 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit()))); 42 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
42 mEditOnlyItems.append(insertItem (i18n("&Delete"), 43 mEditOnlyItems.append(insertItem (i18n("&Delete"),
43 this,SLOT(popupDelete()))); 44 this,SLOT(popupDelete())));
44 mEditOnlyItems.append(insertItem (i18n("&Clone..."), 45 mEditOnlyItems.append(insertItem (i18n("&Clone..."),
45 this,SLOT(popupClone()))); 46 this,SLOT(popupClone())));
46 mEditOnlyItems.append(insertItem (i18n("&Move..."), 47 mEditOnlyItems.append(insertItem (i18n("&Move..."),
47 this,SLOT(popupMove()))); 48 this,SLOT(popupMove())));
48#ifndef DESKTOP_VERSION 49#ifndef DESKTOP_VERSION
49 mEditOnlyItems.append(insertItem (i18n("&Beam..."), 50 mEditOnlyItems.append(insertItem (i18n("&Beam..."),
50 this,SLOT(popupBeam()))); 51 this,SLOT(popupBeam())));
51#endif 52#endif
52 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), 53 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"),
53 this,SLOT(popupCancel()))); 54 this,SLOT(popupCancel())));
54 isDisabled = false; 55 isDisabled = false;
56 mCatPopup = new QPopupMenu ( this );
57 mCatPopup->setCheckable (true);
58 connect(mCatPopup,SIGNAL( aboutToShow ()), this ,SLOT( fillCatPopup()));
59 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT( computeCatPopup( int )));
60 mEditOnlyItems.append(insertItem (i18n("Categories"),mCatPopup ));
55 QValueList<int>::Iterator it; 61 QValueList<int>::Iterator it;
56 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 62 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
57 mSingleOnlyItems.append(*it); 63 mSingleOnlyItems.append(*it);
58 } 64 }
65
59} 66}
60void KOEventPopupMenu::enableDefault( bool enable ) 67void KOEventPopupMenu::enableDefault( bool enable )
61{ 68{
62 isDisabled = !enable; 69 isDisabled = !enable;
63 QValueList<int>::Iterator it; 70 QValueList<int>::Iterator it;
64 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) { 71 for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) {
65 setItemEnabled(*it,enable); 72 setItemEnabled(*it,enable);
66 } 73 }
67 74
68} 75}
69 76
77void KOEventPopupMenu::fillCatPopup()
78{
79 mCatPopup->clear();
80 QStringList checkedCategories = mCurrentIncidence->categories();
81 int index = 0;
82 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
83 it != KOPrefs::instance()->mCustomCategories.end ();
84 ++it) {
85 mCatPopup->insertItem (*it, index );
86 if (checkedCategories.find (*it) != checkedCategories.end ()) {
87 mCatPopup->setItemChecked (index, true);
88 }
89 ++index;
90 }
91}
92void KOEventPopupMenu::computeCatPopup( int index )
93{
94 QStringList categories = mCurrentIncidence->categories();
95 QString colcat = categories.first();
96 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
97 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
98 else
99 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
100 categories.sort ();
101 if ( !colcat.isEmpty() ) {
102 if ( categories.find ( colcat ) != categories.end () ) {
103 categories.remove( colcat );
104 categories.prepend( colcat );
105 }
106 }
107 mCurrentIncidence->setCategories( categories );
108 emit categoryChanged( mCurrentIncidence );
109}
70void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) 110void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
71{ 111{
72 mCurrentIncidence = incidence; 112 mCurrentIncidence = incidence;
73 113
74 if (mCurrentIncidence) { 114 if (mCurrentIncidence) {
75 // Enable/Disabled menu items only valid for editable events. 115 // Enable/Disabled menu items only valid for editable events.
76 if ( !isDisabled ) { 116 if ( !isDisabled ) {
77 QValueList<int>::Iterator it; 117 QValueList<int>::Iterator it;
78 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 118 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
79 setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); 119 setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
80 } 120 }
81 } 121 }
82 popup(QCursor::pos()); 122 popup(QCursor::pos());
83 } else {
84 kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
85 } 123 }
86} 124}
87 125
88void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, 126void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
89 const QObject *receiver, const char *member, 127 const QObject *receiver, const char *member,
90 bool editOnly) 128 bool editOnly)
91{ 129{
92 if (!mHasAdditionalItems) { 130 if (!mHasAdditionalItems) {
93 mHasAdditionalItems = true; 131 mHasAdditionalItems = true;
94 insertSeparator(); 132 insertSeparator();
95 } 133 }
96 int id = insertItem(icon,text,receiver,member); 134 int id = insertItem(icon,text,receiver,member);
97 if (editOnly) mEditOnlyItems.append(id); 135 if (editOnly) mEditOnlyItems.append(id);
98} 136}
99 137
100void KOEventPopupMenu::popupShow() 138void KOEventPopupMenu::popupShow()
101{ 139{
102 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence); 140 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
103} 141}
104 142
105void KOEventPopupMenu::popupEdit() 143void KOEventPopupMenu::popupEdit()
106{ 144{
107 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence); 145 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
108} 146}
109 147
110void KOEventPopupMenu::popupDelete() 148void KOEventPopupMenu::popupDelete()
111{ 149{
112 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence); 150 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
113} 151}
114void KOEventPopupMenu::popupClone() 152void KOEventPopupMenu::popupClone()
115{ 153{
116 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence); 154 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence);
117} 155}
118void KOEventPopupMenu::popupCancel() 156void KOEventPopupMenu::popupCancel()
119{ 157{
120 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence); 158 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence);
121} 159}
122void KOEventPopupMenu::popupMove() 160void KOEventPopupMenu::popupMove()
123{ 161{
124 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence); 162 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence);
125} 163}
126 164
127void KOEventPopupMenu::popupBeam() 165void KOEventPopupMenu::popupBeam()
128{ 166{
129 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence); 167 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence);
130} 168}
diff --git a/korganizer/koeventpopupmenu.h b/korganizer/koeventpopupmenu.h
index 8fb51fa..3d8b595 100644
--- a/korganizer/koeventpopupmenu.h
+++ b/korganizer/koeventpopupmenu.h
@@ -1,76 +1,80 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOEVENTPOPUPMENU_H 23#ifndef KOEVENTPOPUPMENU_H
24#define KOEVENTPOPUPMENU_H 24#define KOEVENTPOPUPMENU_H
25// 25//
26// Context menu for event views with standard event actions 26// Context menu for event views with standard event actions
27// 27//
28 28
29#include <qpopupmenu.h> 29#include <qpopupmenu.h>
30 30
31#include <libkcal/incidence.h> 31#include <libkcal/incidence.h>
32 32
33using namespace KCal; 33using namespace KCal;
34 34
35class KOEventPopupMenu : public QPopupMenu { 35class KOEventPopupMenu : public QPopupMenu {
36 Q_OBJECT 36 Q_OBJECT
37 public: 37 public:
38 KOEventPopupMenu(); 38 KOEventPopupMenu();
39 39
40 void addAdditionalItem(const QIconSet &icon,const QString &text, 40 void addAdditionalItem(const QIconSet &icon,const QString &text,
41 const QObject *receiver, const char *member, 41 const QObject *receiver, const char *member,
42 bool editOnly=false); 42 bool editOnly=false);
43 43
44 44
45 public slots: 45 public slots:
46 void showIncidencePopup(Incidence *); 46 void showIncidencePopup(Incidence *);
47 void enableDefault( bool ); 47 void enableDefault( bool );
48 48
49 protected slots: 49 protected slots:
50 void popupShow(); 50 void popupShow();
51 void popupEdit(); 51 void popupEdit();
52 void popupDelete(); 52 void popupDelete();
53 void popupClone(); 53 void popupClone();
54 void popupCancel(); 54 void popupCancel();
55 void popupMove(); 55 void popupMove();
56 void popupBeam(); 56 void popupBeam();
57 void fillCatPopup();
58 void computeCatPopup( int );
57 59
58 signals: 60 signals:
59 void editIncidenceSignal(Incidence *); 61 void editIncidenceSignal(Incidence *);
60 void showIncidenceSignal(Incidence *); 62 void showIncidenceSignal(Incidence *);
61 void deleteIncidenceSignal(Incidence *); 63 void deleteIncidenceSignal(Incidence *);
62 void cloneIncidenceSignal(Incidence *); 64 void cloneIncidenceSignal(Incidence *);
63 void cancelIncidenceSignal(Incidence *); 65 void cancelIncidenceSignal(Incidence *);
64 void moveIncidenceSignal(Incidence *); 66 void moveIncidenceSignal(Incidence *);
65 void beamIncidenceSignal(Incidence *); 67 void beamIncidenceSignal(Incidence *);
68 void categoryChanged( Incidence * );
66 69
67 private: 70 private:
68 Incidence *mCurrentIncidence; 71 Incidence *mCurrentIncidence;
69 72
70 bool mHasAdditionalItems; 73 bool mHasAdditionalItems;
71 QValueList<int> mEditOnlyItems; 74 QValueList<int> mEditOnlyItems;
72 QValueList<int> mSingleOnlyItems; 75 QValueList<int> mSingleOnlyItems;
73 bool isDisabled; 76 bool isDisabled;
77 QPopupMenu *mCatPopup;
74}; 78};
75 79
76#endif 80#endif
diff --git a/korganizer/koeventview.cpp b/korganizer/koeventview.cpp
index bce2626..1d26930 100644
--- a/korganizer/koeventview.cpp
+++ b/korganizer/koeventview.cpp
@@ -1,130 +1,129 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qpopupmenu.h> 24#include <qpopupmenu.h>
25#include <qcursor.h> 25#include <qcursor.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kdebug.h> 28#include <kdebug.h>
29#include <kiconloader.h> 29#include <kiconloader.h>
30#include <kmessagebox.h> 30#include <kmessagebox.h>
31 31
32#include <libkcal/calendar.h> 32#include <libkcal/calendar.h>
33#include "koprefs.h" 33#include "koprefs.h"
34#include "koeventview.h" 34#include "koeventview.h"
35using namespace KOrg; 35using namespace KOrg;
36 36
37//--------------------------------------------------------------------------- 37//---------------------------------------------------------------------------
38 38
39KOEventView::KOEventView(Calendar *cal,QWidget *parent,const char *name) 39KOEventView::KOEventView(Calendar *cal,QWidget *parent,const char *name)
40 : KOrg::BaseView(cal,parent,name) 40 : KOrg::BaseView(cal,parent,name)
41{ 41{
42} 42}
43 43
44//--------------------------------------------------------------------------- 44//---------------------------------------------------------------------------
45 45
46KOEventView::~KOEventView() 46KOEventView::~KOEventView()
47{ 47{
48} 48}
49 49
50//--------------------------------------------------------------------------- 50//---------------------------------------------------------------------------
51 51
52KOEventPopupMenu *KOEventView::eventPopup() 52KOEventPopupMenu *KOEventView::eventPopup()
53{ 53{
54 KOEventPopupMenu *eventPopup = new KOEventPopupMenu; 54 KOEventPopupMenu *eventPopup = new KOEventPopupMenu;
55 55
56 connect(eventPopup,SIGNAL(editIncidenceSignal(Incidence *)), 56 connect(eventPopup,SIGNAL(editIncidenceSignal(Incidence *)),
57 SIGNAL(editIncidenceSignal(Incidence *))); 57 SIGNAL(editIncidenceSignal(Incidence *)));
58 connect(eventPopup,SIGNAL(showIncidenceSignal(Incidence *)), 58 connect(eventPopup,SIGNAL(showIncidenceSignal(Incidence *)),
59 SIGNAL(showIncidenceSignal(Incidence *))); 59 SIGNAL(showIncidenceSignal(Incidence *)));
60 connect(eventPopup,SIGNAL(deleteIncidenceSignal(Incidence *)), 60 connect(eventPopup,SIGNAL(deleteIncidenceSignal(Incidence *)),
61 SIGNAL(deleteIncidenceSignal(Incidence *))); 61 SIGNAL(deleteIncidenceSignal(Incidence *)));
62 connect(eventPopup,SIGNAL(cancelIncidenceSignal(Incidence *)), 62 connect(eventPopup,SIGNAL(cancelIncidenceSignal(Incidence *)),
63 SIGNAL(cancelIncidenceSignal(Incidence *))); 63 SIGNAL(cancelIncidenceSignal(Incidence *)));
64 connect(eventPopup,SIGNAL(cloneIncidenceSignal(Incidence *)), 64 connect(eventPopup,SIGNAL(cloneIncidenceSignal(Incidence *)),
65 SIGNAL(cloneIncidenceSignal(Incidence *))); 65 SIGNAL(cloneIncidenceSignal(Incidence *)));
66 connect(eventPopup,SIGNAL(beamIncidenceSignal(Incidence *)), 66 connect(eventPopup,SIGNAL(beamIncidenceSignal(Incidence *)),
67 SIGNAL(beamIncidenceSignal(Incidence *))); 67 SIGNAL(beamIncidenceSignal(Incidence *)));
68 connect(eventPopup,SIGNAL(moveIncidenceSignal(Incidence *)), 68 connect(eventPopup,SIGNAL(moveIncidenceSignal(Incidence *)),
69 SIGNAL(moveIncidenceSignal(Incidence *))); 69 SIGNAL(moveIncidenceSignal(Incidence *)));
70 70
71 return eventPopup; 71 return eventPopup;
72} 72}
73 73
74//--------------------------------------------------------------------------- 74//---------------------------------------------------------------------------
75 75
76void KOEventView::showIncidencePopup(QPopupMenu *popup,Incidence *event) 76void KOEventView::showIncidencePopup(QPopupMenu *popup,Incidence *event)
77{ 77{
78 mCurrentIncidence = event; 78 mCurrentIncidence = event;
79 if (event) popup->popup(QCursor::pos()); 79 if (event) popup->popup(QCursor::pos());
80 else kdDebug() << "KOEventView::showEventPopup(): No event selected" << endl;
81} 80}
82 81
83//--------------------------------------------------------------------------- 82//---------------------------------------------------------------------------
84 83
85void KOEventView::popupShow() 84void KOEventView::popupShow()
86{ 85{
87 emit showIncidenceSignal(mCurrentIncidence); 86 emit showIncidenceSignal(mCurrentIncidence);
88} 87}
89 88
90//--------------------------------------------------------------------------- 89//---------------------------------------------------------------------------
91 90
92void KOEventView::popupEdit() 91void KOEventView::popupEdit()
93{ 92{
94 emit editIncidenceSignal(mCurrentIncidence); 93 emit editIncidenceSignal(mCurrentIncidence);
95} 94}
96 95
97//--------------------------------------------------------------------------- 96//---------------------------------------------------------------------------
98 97
99void KOEventView::popupDelete() 98void KOEventView::popupDelete()
100{ 99{
101 emit deleteIncidenceSignal(mCurrentIncidence); 100 emit deleteIncidenceSignal(mCurrentIncidence);
102} 101}
103void KOEventView::popupClone() 102void KOEventView::popupClone()
104{ 103{
105 emit cloneIncidenceSignal(mCurrentIncidence); 104 emit cloneIncidenceSignal(mCurrentIncidence);
106} 105}
107void KOEventView::popupCancel() 106void KOEventView::popupCancel()
108{ 107{
109 emit cancelIncidenceSignal(mCurrentIncidence); 108 emit cancelIncidenceSignal(mCurrentIncidence);
110} 109}
111 110
112//--------------------------------------------------------------------------- 111//---------------------------------------------------------------------------
113 112
114void KOEventView::defaultAction( Incidence *incidence ) 113void KOEventView::defaultAction( Incidence *incidence )
115{ 114{
116 115
117 if ( !incidence ) return; 116 if ( !incidence ) return;
118 117
119 if ( incidence->isReadOnly() ) 118 if ( incidence->isReadOnly() )
120 emit showIncidenceSignal(incidence); 119 emit showIncidenceSignal(incidence);
121 else { 120 else {
122 if ( KOPrefs::instance()->mEditOnDoubleClick ) 121 if ( KOPrefs::instance()->mEditOnDoubleClick )
123 emit editIncidenceSignal(incidence); 122 emit editIncidenceSignal(incidence);
124 else 123 else
125 emit showIncidenceSignal(incidence); 124 emit showIncidenceSignal(incidence);
126 } 125 }
127} 126}
128 127
129//--------------------------------------------------------------------------- 128//---------------------------------------------------------------------------
130 129
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 8f17e6e..43e1113 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1476 +1,1472 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlistview.h> 25#include <qlistview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qfileinfo.h> 30#include <qfileinfo.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qwhatsthis.h> 35#include <qwhatsthis.h>
36#include <qregexp.h> 36#include <qregexp.h>
37#include <qpainter.h> 37#include <qpainter.h>
38#include <qpaintdevicemetrics.h> 38#include <qpaintdevicemetrics.h>
39 39
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43#include <kglobal.h> 43#include <kglobal.h>
44 44
45#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
46#include <libkcal/calendar.h> 46#include <libkcal/calendar.h>
47#include <libkcal/calendarlocal.h> 47#include <libkcal/calendarlocal.h>
48#include <libkcal/icalformat.h> 48#include <libkcal/icalformat.h>
49#include <libkcal/vcalformat.h> 49#include <libkcal/vcalformat.h>
50#include <libkcal/recurrence.h> 50#include <libkcal/recurrence.h>
51#include <libkcal/filestorage.h> 51#include <libkcal/filestorage.h>
52#include <libkdepim/categoryselectdialog.h> 52#include <libkdepim/categoryselectdialog.h>
53#include <libkcal/kincidenceformatter.h> 53#include <libkcal/kincidenceformatter.h>
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#else 56#else
57#include <qapplication.h> 57#include <qapplication.h>
58#endif 58#endif
59 59
60#ifndef KORG_NOPRINTER 60#ifndef KORG_NOPRINTER
61#include "calprinter.h" 61#include "calprinter.h"
62#endif 62#endif
63#include "koglobals.h" 63#include "koglobals.h"
64#include "koprefs.h" 64#include "koprefs.h"
65#include "kfiledialog.h" 65#include "kfiledialog.h"
66 66
67#include "kolistview.h" 67#include "kolistview.h"
68#include "koeventviewer.h" 68#include "koeventviewer.h"
69 69
70extern QPixmap* sgListViewCompletedPix[6]; 70extern QPixmap* sgListViewCompletedPix[6];
71 71
72class KOListViewWhatsThis :public QWhatsThis 72class KOListViewWhatsThis :public QWhatsThis
73{ 73{
74public: 74public:
75 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 75 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
76 76
77protected: 77protected:
78 virtual QString text( const QPoint& p) 78 virtual QString text( const QPoint& p)
79 { 79 {
80 return _view->getWhatsThisText(p) ; 80 return _view->getWhatsThisText(p) ;
81 } 81 }
82private: 82private:
83 QWidget* _wid; 83 QWidget* _wid;
84 KOListView * _view; 84 KOListView * _view;
85}; 85};
86 86
87 87
88ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 88ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
89{ 89{
90 mItem = item; 90 mItem = item;
91 mDate = date; 91 mDate = date;
92} 92}
93 93
94ListItemVisitor::~ListItemVisitor() 94ListItemVisitor::~ListItemVisitor()
95{ 95{
96} 96}
97 97
98bool ListItemVisitor::visit(Event *e) 98bool ListItemVisitor::visit(Event *e)
99{ 99{
100 bool ok = false; 100 bool ok = false;
101 QString start, end; 101 QString start, end;
102 QDate ds, de; 102 QDate ds, de;
103 if ( e->doesRecur() ) { 103 if ( e->doesRecur() ) {
104 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 104 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
105 if ( ok ) { 105 if ( ok ) {
106 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 106 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
107 start = KGlobal::locale()->formatDate(ds,true); 107 start = KGlobal::locale()->formatDate(ds,true);
108 de = ds.addDays( days); 108 de = ds.addDays( days);
109 end = KGlobal::locale()->formatDate(de,true); 109 end = KGlobal::locale()->formatDate(de,true);
110 } 110 }
111 111
112 } 112 }
113 if ( ! ok ) { 113 if ( ! ok ) {
114 start =e->dtStartDateStr(); 114 start =e->dtStartDateStr();
115 end = e->dtEndDateStr(); 115 end = e->dtEndDateStr();
116 ds = e->dtStart().date(); 116 ds = e->dtStart().date();
117 de = e->dtEnd().date(); 117 de = e->dtEnd().date();
118 } 118 }
119 mItem->setText(0,e->summary()); 119 mItem->setText(0,e->summary());
120 mItem->setText(1,start); 120 mItem->setText(1,start);
121 if ( e->doesFloat() ) 121 if ( e->doesFloat() )
122 mItem->setText(2,"---"); 122 mItem->setText(2,"---");
123 else 123 else
124 mItem->setText(2,e->dtStartTimeStr()); 124 mItem->setText(2,e->dtStartTimeStr());
125 mItem->setText(3,end); 125 mItem->setText(3,end);
126 if ( e->doesFloat() ) 126 if ( e->doesFloat() )
127 mItem->setText(4,"---"); 127 mItem->setText(4,"---");
128 else 128 else
129 mItem->setText(4,e->dtEndTimeStr()); 129 mItem->setText(4,e->dtEndTimeStr());
130 if ( e->isAlarmEnabled() ) { 130 if ( e->isAlarmEnabled() ) {
131 mItem->setText(5,e->alarms().first()->offsetText() ); 131 mItem->setText(5,e->alarms().first()->offsetText() );
132 } else { 132 } else {
133 mItem->setText(5, i18n("No")); 133 mItem->setText(5, i18n("No"));
134 } 134 }
135 mItem->setText(6, e->recurrence()->recurrenceText()); 135 mItem->setText(6, e->recurrence()->recurrenceText());
136 if( ! e->doesRecur() ) 136 if( ! e->doesRecur() )
137 mItem->setSortKey( 6, "-" ); 137 mItem->setSortKey( 6, "-" );
138 mItem->setText(7,"---"); 138 mItem->setText(7,"---");
139 mItem->setText(8,"---"); 139 mItem->setText(8,"---");
140 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 140 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
141 mItem->setText(10,e->categoriesStr()); 141 mItem->setText(10,e->categoriesStr());
142 mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); 142 mItem->setText(11, KOPrefs::instance()->calName( e->calID() ));
143 143
144 QString key; 144 QString key;
145 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 145 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
146 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 146 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
147 mItem->setSortKey(1,key); 147 mItem->setSortKey(1,key);
148 148
149 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 149 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
150 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 150 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
151 mItem->setSortKey(3,key); 151 mItem->setSortKey(3,key);
152 return true; 152 return true;
153} 153}
154 154
155bool ListItemVisitor::visit(Todo *t) 155bool ListItemVisitor::visit(Todo *t)
156{ 156{
157 mItem->setText(0,t->summary()); 157 mItem->setText(0,t->summary());
158 if ( t->isCompleted() ) { 158 if ( t->isCompleted() ) {
159 mItem->setSortKey(0,"99"+ t->summary().left(10)); 159 mItem->setSortKey(0,"99"+ t->summary().left(10));
160 } else 160 } else
161 mItem->setSortKey(0,QString::number( t->percentComplete() )+ t->summary().left(10)); 161 mItem->setSortKey(0,QString::number( t->percentComplete() )+ t->summary().left(10));
162 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); 162 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20]));
163 if (t->hasStartDate()) { 163 if (t->hasStartDate()) {
164 mItem->setText(1,t->dtStartDateStr()); 164 mItem->setText(1,t->dtStartDateStr());
165 if (t->doesFloat()) { 165 if (t->doesFloat()) {
166 mItem->setText(2,"---"); 166 mItem->setText(2,"---");
167 } else { 167 } else {
168 mItem->setText(2,t->dtStartTimeStr()); 168 mItem->setText(2,t->dtStartTimeStr());
169 } 169 }
170 } else { 170 } else {
171 mItem->setText(1,"---"); 171 mItem->setText(1,"---");
172 mItem->setText(2,"---"); 172 mItem->setText(2,"---");
173 } 173 }
174 mItem->setText(3,"---"); 174 mItem->setText(3,"---");
175 mItem->setText(4,"---"); 175 mItem->setText(4,"---");
176 if ( t->isAlarmEnabled() ) { 176 if ( t->isAlarmEnabled() ) {
177 mItem->setText(5,t->alarms().first()->offsetText() ); 177 mItem->setText(5,t->alarms().first()->offsetText() );
178 } else { 178 } else {
179 mItem->setText(5, i18n("No")); 179 mItem->setText(5, i18n("No"));
180 } 180 }
181 mItem->setText(6, t->recurrence()->recurrenceText()); 181 mItem->setText(6, t->recurrence()->recurrenceText());
182 if( ! t->doesRecur() ) 182 if( ! t->doesRecur() )
183 mItem->setSortKey( 6, "-" ); 183 mItem->setSortKey( 6, "-" );
184 if (t->hasDueDate()) { 184 if (t->hasDueDate()) {
185 mItem->setText(7,t->dtDueDateStr()); 185 mItem->setText(7,t->dtDueDateStr());
186 if (t->doesFloat()) { 186 if (t->doesFloat()) {
187 mItem->setText(8,"---"); 187 mItem->setText(8,"---");
188 } else { 188 } else {
189 mItem->setText(8,t->dtDueTimeStr()); 189 mItem->setText(8,t->dtDueTimeStr());
190 } 190 }
191 } else { 191 } else {
192 mItem->setText(7,"---"); 192 mItem->setText(7,"---");
193 mItem->setText(8,"---"); 193 mItem->setText(8,"---");
194 } 194 }
195 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 195 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
196 mItem->setText(10,t->categoriesStr()); 196 mItem->setText(10,t->categoriesStr());
197 mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); 197 mItem->setText(11, KOPrefs::instance()->calName( t->calID() ));
198 198
199 QString key; 199 QString key;
200 QDate d; 200 QDate d;
201 if (t->hasDueDate()) { 201 if (t->hasDueDate()) {
202 d = t->dtDue().date(); 202 d = t->dtDue().date();
203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
205 mItem->setSortKey(7,key); 205 mItem->setSortKey(7,key);
206 } 206 }
207 if ( t->hasStartDate() ) { 207 if ( t->hasStartDate() ) {
208 d = t->dtStart().date(); 208 d = t->dtStart().date();
209 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 209 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
210 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 210 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
211 mItem->setSortKey(1,key); 211 mItem->setSortKey(1,key);
212 } 212 }
213 return true; 213 return true;
214} 214}
215 215
216bool ListItemVisitor::visit(Journal * j) 216bool ListItemVisitor::visit(Journal * j)
217{ 217{
218 218
219 QString des; 219 QString des;
220 if ( !j->summary().isEmpty() ) { 220 if ( !j->summary().isEmpty() ) {
221 des = j->summary(); 221 des = j->summary();
222 } else { 222 } else {
223 des = j->description().left(30); 223 des = j->description().left(30);
224 des = des.simplifyWhiteSpace (); 224 des = des.simplifyWhiteSpace ();
225 des.replace (QRegExp ("\\n"),"" ); 225 des.replace (QRegExp ("\\n"),"" );
226 des.replace (QRegExp ("\\r"),"" ); 226 des.replace (QRegExp ("\\r"),"" );
227 } 227 }
228 mItem->setText(0,i18n("Journal: ")+des.left(25)); 228 mItem->setText(0,i18n("Journal: ")+des.left(25));
229 mItem->setText(1,j->dtStartDateStr()); 229 mItem->setText(1,j->dtStartDateStr());
230 mItem->setText(2,"---"); 230 mItem->setText(2,"---");
231 mItem->setText(3,"---"); 231 mItem->setText(3,"---");
232 mItem->setText(4,"---"); 232 mItem->setText(4,"---");
233 mItem->setText(5,"---"); 233 mItem->setText(5,"---");
234 mItem->setText(6,"---"); 234 mItem->setText(6,"---");
235 mItem->setText(7,j->dtStartDateStr()); 235 mItem->setText(7,j->dtStartDateStr());
236 mItem->setText(8,"---"); 236 mItem->setText(8,"---");
237 mItem->setText(9,"---"); 237 mItem->setText(9,"---");
238 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 238 mItem->setText(10,j->categoriesStr());
239 mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); 239 mItem->setText(11, KOPrefs::instance()->calName( j->calID() ));
240 240
241 QString key; 241 QString key;
242 QDate d = j->dtStart().date(); 242 QDate d = j->dtStart().date();
243 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 243 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
244 mItem->setSortKey(1,key); 244 mItem->setSortKey(1,key);
245 mItem->setSortKey(7,key); 245 mItem->setSortKey(7,key);
246 246
247 return true; 247 return true;
248} 248}
249 249
250KOListView::KOListView(Calendar *calendar, QWidget *parent, 250KOListView::KOListView(Calendar *calendar, QWidget *parent,
251 const char *name) 251 const char *name)
252 : KOEventView(calendar, parent, name) 252 : KOEventView(calendar, parent, name)
253{ 253{
254 254
255 mActiveItem = 0; 255 mActiveItem = 0;
256 mForceShowCompletedTodos = false; 256 mForceShowCompletedTodos = false;
257 mListView = new KOListViewListView(this); 257 mListView = new KOListViewListView(this);
258 mListView->addColumn(i18n("Summary")); 258 mListView->addColumn(i18n("Summary"));
259 mListView->addColumn(i18n("Start Date")); 259 mListView->addColumn(i18n("Start Date"));
260 mListView->addColumn(i18n("Start Time")); 260 mListView->addColumn(i18n("Start Time"));
261 mListView->addColumn(i18n("End Date")); 261 mListView->addColumn(i18n("End Date"));
262 mListView->addColumn(i18n("End Time")); 262 mListView->addColumn(i18n("End Time"));
263 mListView->addColumn(i18n("Alarm")); // alarm set? 263 mListView->addColumn(i18n("Alarm")); // alarm set?
264 mListView->addColumn(i18n("Recurs")); // recurs? 264 mListView->addColumn(i18n("Recurs")); // recurs?
265 mListView->addColumn(i18n("Due Date")); 265 mListView->addColumn(i18n("Due Date"));
266 mListView->addColumn(i18n("Due Time")); 266 mListView->addColumn(i18n("Due Time"));
267 mListView->addColumn(i18n("Cancelled")); 267 mListView->addColumn(i18n("Cancelled"));
268 mListView->addColumn(i18n("Categories")); 268 mListView->addColumn(i18n("Categories"));
269 mListView->addColumn(i18n("Calendar")); 269 mListView->addColumn(i18n("Calendar"));
270 270
271 mListView->setColumnAlignment(0,AlignLeft); 271 mListView->setColumnAlignment(0,AlignLeft);
272 mListView->setColumnAlignment(1,AlignLeft); 272 mListView->setColumnAlignment(1,AlignLeft);
273 mListView->setColumnAlignment(2,AlignHCenter); 273 mListView->setColumnAlignment(2,AlignHCenter);
274 mListView->setColumnAlignment(3,AlignLeft); 274 mListView->setColumnAlignment(3,AlignLeft);
275 mListView->setColumnAlignment(4,AlignHCenter); 275 mListView->setColumnAlignment(4,AlignHCenter);
276 mListView->setColumnAlignment(5,AlignLeft); 276 mListView->setColumnAlignment(5,AlignLeft);
277 mListView->setColumnAlignment(6,AlignLeft); 277 mListView->setColumnAlignment(6,AlignLeft);
278 mListView->setColumnAlignment(7,AlignLeft); 278 mListView->setColumnAlignment(7,AlignLeft);
279 mListView->setColumnAlignment(8,AlignLeft); 279 mListView->setColumnAlignment(8,AlignLeft);
280 mListView->setColumnAlignment(9,AlignLeft); 280 mListView->setColumnAlignment(9,AlignLeft);
281 mListView->setColumnAlignment(10,AlignLeft); 281 mListView->setColumnAlignment(10,AlignLeft);
282 mListView->setColumnAlignment(11,AlignLeft); 282 mListView->setColumnAlignment(11,AlignLeft);
283 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 283 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
284 284
285 int iii = 0; 285 int iii = 0;
286 for ( iii = 0; iii< 12 ; ++iii ) 286 for ( iii = 0; iii< 12 ; ++iii )
287 mListView->setColumnWidthMode( iii, QListView::Manual ); 287 mListView->setColumnWidthMode( iii, QListView::Manual );
288 288
289 QBoxLayout *layoutTop = new QVBoxLayout(this); 289 QBoxLayout *layoutTop = new QVBoxLayout(this);
290 layoutTop->addWidget(mListView); 290 layoutTop->addWidget(mListView);
291 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 291 mListView->setFont ( KOPrefs::instance()->mListViewFont );
292 mPopupMenu = eventPopup(); 292 mPopupMenu = eventPopup();
293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
294 i18n("Select all"),this, 294 i18n("Select all"),this,
295 SLOT(allSelection()),true); 295 SLOT(allSelection()),true);
296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
297 i18n("Deselect all"),this, 297 i18n("Deselect all"),this,
298 SLOT(clearSelection()),true); 298 SLOT(clearSelection()),true);
299 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 299 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
300 i18n("Delete all selected"),this, 300 i18n("Delete all selected"),this,
301 SLOT(deleteAll()),true); 301 SLOT(deleteAll()),true);
302 302
303 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 303 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
304 i18n("Hide all selected"),this, 304 i18n("Hide all selected"),this,
305 SLOT(hideAll()),true); 305 SLOT(hideAll()),true);
306 306
307 mPopupMenu->insertSeparator(); 307 mPopupMenu->insertSeparator();
308#ifdef DESKTOP_VERSION 308#ifdef DESKTOP_VERSION
309 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 309 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
310 i18n("Print complete list"),this, 310 i18n("Print complete list"),this,
311 SLOT(printList()),true); 311 SLOT(printList()),true);
312 mPopupMenu->insertSeparator(); 312 mPopupMenu->insertSeparator();
313#endif 313#endif
314 mCalPopup = new QPopupMenu ( this ); 314 mCalPopup = new QPopupMenu ( this );
315 mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup ); 315 mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup );
316 316
317 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, 317 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this,
318 SLOT( populateCalPopup() )); 318 SLOT( populateCalPopup() ));
319 QObject::connect(mCalPopup,SIGNAL(activated( int )),this, 319 QObject::connect(mCalPopup,SIGNAL(activated( int )),this,
320 SLOT( setCalendar( int ) )); 320 SLOT( setCalendar( int ) ));
321 QPopupMenu * exportPO = new QPopupMenu ( this ); 321 QPopupMenu * exportPO = new QPopupMenu ( this );
322 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 322 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
323 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 323 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
324 SLOT(saveToFile())); 324 SLOT(saveToFile()));
325 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 325 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
326 SLOT(saveToFileVCS())); 326 SLOT(saveToFileVCS()));
327 exportPO->insertItem( i18n("Journal/Details..."),this, 327 exportPO->insertItem( i18n("Journal/Details..."),this,
328 SLOT(saveDescriptionToFile())); 328 SLOT(saveDescriptionToFile()));
329 // mPopupMenu->insertSeparator(); 329 // mPopupMenu->insertSeparator();
330 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 330 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
331 i18n("Add Categ. to selected..."),this, 331 i18n("Add Categ. to selected..."),this,
332 SLOT(addCat()),true); 332 SLOT(addCat()),true);
333 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 333 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
334 i18n("Set Categ. for selected..."),this, 334 i18n("Set Categ. for selected..."),this,
335 SLOT(setCat()),true); 335 SLOT(setCat()),true);
336 //mPopupMenu->insertSeparator(); 336 //mPopupMenu->insertSeparator();
337 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 337 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
338 i18n("Set alarm for selected..."),this, 338 i18n("Set alarm for selected..."),this,
339 SLOT(setAlarm()),true); 339 SLOT(setAlarm()),true);
340 340
341 341
342 342
343#ifndef DESKTOP_VERSION 343#ifndef DESKTOP_VERSION
344 mPopupMenu->insertSeparator(); 344 mPopupMenu->insertSeparator();
345 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 345 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
346 i18n("Beam selected via IR"),this, 346 i18n("Beam selected via IR"),this,
347 SLOT(beamSelected()),true); 347 SLOT(beamSelected()),true);
348#endif 348#endif
349 /* 349 /*
350 mPopupMenu = new QPopupMenu; 350 mPopupMenu = new QPopupMenu;
351 mPopupMenu->insertItem(i18n("Edit Event"), this, 351 mPopupMenu->insertItem(i18n("Edit Event"), this,
352 SLOT (editEvent())); 352 SLOT (editEvent()));
353 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 353 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
354 SLOT (deleteEvent())); 354 SLOT (deleteEvent()));
355 mPopupMenu->insertSeparator(); 355 mPopupMenu->insertSeparator();
356 mPopupMenu->insertItem(i18n("Show Dates"), this, 356 mPopupMenu->insertItem(i18n("Show Dates"), this,
357 SLOT(showDates())); 357 SLOT(showDates()));
358 mPopupMenu->insertItem(i18n("Hide Dates"), this, 358 mPopupMenu->insertItem(i18n("Hide Dates"), this,
359 SLOT(hideDates())); 359 SLOT(hideDates()));
360 */ 360 */
361 QObject::connect(mListView,SIGNAL( newEvent()), 361 QObject::connect(mListView,SIGNAL( newEvent()),
362 this,SIGNAL(signalNewEvent())); 362 this,SIGNAL(signalNewEvent()));
363 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 363 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
364 this,SLOT(defaultItemAction(QListViewItem *))); 364 this,SLOT(defaultItemAction(QListViewItem *)));
365 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 365 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
366 const QPoint &, int )), 366 const QPoint &, int )),
367 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 367 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
368 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 368 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
369 SLOT(processSelectionChange(QListViewItem *))); 369 SLOT(processSelectionChange(QListViewItem *)));
370 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 370 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
371 SIGNAL(showIncidenceSignal(Incidence *)) ); 371 SIGNAL(showIncidenceSignal(Incidence *)) );
372 372
373 readSettings(KOGlobals::config(),"KOListView Layout"); 373 readSettings(KOGlobals::config(),"KOListView Layout");
374} 374}
375 375
376KOListView::~KOListView() 376KOListView::~KOListView()
377{ 377{
378 delete mPopupMenu; 378 delete mPopupMenu;
379#if QT_VERSION >= 0x030000 379#if QT_VERSION >= 0x030000
380 380
381#else 381#else
382 delete mKOListViewWhatsThis; 382 delete mKOListViewWhatsThis;
383#endif 383#endif
384} 384}
385 385
386QString KOListView::getWhatsThisText(QPoint p) 386QString KOListView::getWhatsThisText(QPoint p)
387{ 387{
388 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 388 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
389 if ( item ) 389 if ( item )
390 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 390 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
391 KOPrefs::instance()->mWTshowDetails, 391 KOPrefs::instance()->mWTshowDetails,
392 KOPrefs::instance()->mWTshowCreated, 392 KOPrefs::instance()->mWTshowCreated,
393 KOPrefs::instance()->mWTshowChanged); 393 KOPrefs::instance()->mWTshowChanged);
394 return i18n("That is the list view" ); 394 return i18n("That is the list view" );
395 395
396} 396}
397 397
398void KOListView::setCalendar( int c ) 398void KOListView::setCalendar( int c )
399{ 399{
400 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 400 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
401 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), 401 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ),
402 i18n("Continue"), i18n("Cancel"), 0, 402 i18n("Continue"), i18n("Cancel"), 0,
403 0, 1 ); 403 0, 1 );
404 if ( result != 0 ) { 404 if ( result != 0 ) {
405 return; 405 return;
406 } 406 }
407 407
408 QPtrList<Incidence> delSel = getSelectedIncidences() ; 408 QPtrList<Incidence> delSel = getSelectedIncidences() ;
409 int icount = delSel.count(); 409 int icount = delSel.count();
410 if ( icount ) { 410 if ( icount ) {
411 Incidence *incidence = delSel.first(); 411 Incidence *incidence = delSel.first();
412 while ( incidence ) { 412 while ( incidence ) {
413 incidence->setCalID( c ); 413 incidence->setCalID( c );
414 KOListViewItem * item = getItemForEvent( incidence ); 414 KOListViewItem * item = getItemForEvent( incidence );
415 if ( item ) { 415 if ( item ) {
416 ListItemVisitor v(item, mStartDate ); 416 ListItemVisitor v(item, mStartDate );
417 incidence->accept(v); 417 incidence->accept(v);
418 } 418 }
419 incidence = delSel.next(); 419 incidence = delSel.next();
420 } 420 }
421 } 421 }
422 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 422 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
423 KopiCalendarFile * cal = calendars.first(); 423 KopiCalendarFile * cal = calendars.first();
424 while ( cal ) { 424 while ( cal ) {
425 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 425 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
426 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 426 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
427 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 427 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
428 if ( cal->isStandard ) 428 if ( cal->isStandard )
429 mCalendar->setDefaultCalendar( cal->mCalNumber ); 429 mCalendar->setDefaultCalendar( cal->mCalNumber );
430 cal = calendars.next(); 430 cal = calendars.next();
431 } 431 }
432 mCalendar->setSyncEventsReadOnly(); 432 mCalendar->setSyncEventsReadOnly();
433 mCalendar->reInitAlarmSettings(); 433 mCalendar->reInitAlarmSettings();
434 434
435} 435}
436void KOListView::populateCalPopup() 436void KOListView::populateCalPopup()
437{ 437{
438 mCalPopup->clear(); 438 mCalPopup->clear();
439 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 439 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
440 while ( kkf ) { 440 while ( kkf ) {
441 mCalPopup->insertItem( kkf->mName, kkf->mCalNumber); 441 mCalPopup->insertItem( kkf->mName, kkf->mCalNumber);
442 kkf = KOPrefs::instance()->mCalendars.next(); 442 kkf = KOPrefs::instance()->mCalendars.next();
443 } 443 }
444} 444}
445void KOListView::updateList() 445void KOListView::updateList()
446{ 446{
447 // qDebug(" KOListView::updateList() "); 447 // qDebug(" KOListView::updateList() ");
448 448
449} 449}
450 450
451void KOListView::clearList() 451void KOListView::clearList()
452{ 452{
453 clear (); 453 clear ();
454} 454}
455void KOListView::addCat( ) 455void KOListView::addCat( )
456{ 456{
457 setCategories( false ); 457 setCategories( false );
458} 458}
459void KOListView::setCat() 459void KOListView::setCat()
460{ 460{
461 setCategories( true ); 461 setCategories( true );
462} 462}
463 463
464void KOListView::setAlarm() 464void KOListView::setAlarm()
465{ 465{
466 KOAlarmPrefs kap( this); 466 KOAlarmPrefs kap( this);
467 if ( !kap.exec() ) 467 if ( !kap.exec() )
468 return; 468 return;
469 QStringList itemList; 469 QStringList itemList;
470 QPtrList<KOListViewItem> sel ; 470 QPtrList<KOListViewItem> sel ;
471 QListViewItem *qitem = mListView->firstChild (); 471 QListViewItem *qitem = mListView->firstChild ();
472 while ( qitem ) { 472 while ( qitem ) {
473 if ( qitem->isSelected() ) { 473 if ( qitem->isSelected() ) {
474 Incidence* inc = ((KOListViewItem *) qitem)->data(); 474 Incidence* inc = ((KOListViewItem *) qitem)->data();
475 if ( inc->typeID() != journalID ) { 475 if ( inc->typeID() != journalID ) {
476 if ( inc->typeID() == todoID ) { 476 if ( inc->typeID() == todoID ) {
477 if ( ((Todo*)inc)->hasDueDate() ) 477 if ( ((Todo*)inc)->hasDueDate() )
478 sel.append(((KOListViewItem *)qitem)); 478 sel.append(((KOListViewItem *)qitem));
479 } else 479 } else
480 sel.append(((KOListViewItem *)qitem)); 480 sel.append(((KOListViewItem *)qitem));
481 } 481 }
482 } 482 }
483 qitem = qitem->nextSibling(); 483 qitem = qitem->nextSibling();
484 } 484 }
485 int count = 0; 485 int count = 0;
486 KOListViewItem * item, *temp; 486 KOListViewItem * item, *temp;
487 item = sel.first(); 487 item = sel.first();
488 Incidence* inc; 488 Incidence* inc;
489 while ( item ) { 489 while ( item ) {
490 inc = item->data(); 490 inc = item->data();
491 ++count; 491 ++count;
492 if (kap.mAlarmButton->isChecked()) { 492 if (kap.mAlarmButton->isChecked()) {
493 if (inc->alarms().count() == 0) 493 if (inc->alarms().count() == 0)
494 inc->newAlarm(); 494 inc->newAlarm();
495 QPtrList<Alarm> alarms = inc->alarms(); 495 QPtrList<Alarm> alarms = inc->alarms();
496 Alarm *alarm; 496 Alarm *alarm;
497 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 497 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
498 alarm->setEnabled(true); 498 alarm->setEnabled(true);
499 int j = kap.mAlarmTimeEdit->value()* -60; 499 int j = kap.mAlarmTimeEdit->value()* -60;
500 if (kap.mAlarmIncrCombo->currentItem() == 1) 500 if (kap.mAlarmIncrCombo->currentItem() == 1)
501 j = j * 60; 501 j = j * 60;
502 else if (kap.mAlarmIncrCombo->currentItem() == 2) 502 else if (kap.mAlarmIncrCombo->currentItem() == 2)
503 j = j * (60 * 24); 503 j = j * (60 * 24);
504 alarm->setStartOffset( j ); 504 alarm->setStartOffset( j );
505 505
506 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 506 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
507 alarm->setProcedureAlarm(kap.mAlarmProgram); 507 alarm->setProcedureAlarm(kap.mAlarmProgram);
508 } 508 }
509 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 509 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
510 alarm->setAudioAlarm(kap.mAlarmSound); 510 alarm->setAudioAlarm(kap.mAlarmSound);
511 else 511 else
512 alarm->setType(Alarm::Invalid); 512 alarm->setType(Alarm::Invalid);
513 //alarm->setAudioAlarm("default"); 513 //alarm->setAudioAlarm("default");
514 // TODO: Deal with multiple alarms 514 // TODO: Deal with multiple alarms
515 break; // For now, stop after the first alarm 515 break; // For now, stop after the first alarm
516 } 516 }
517 } else { 517 } else {
518 Alarm* alarm = inc->alarms().first(); 518 Alarm* alarm = inc->alarms().first();
519 if ( alarm ) { 519 if ( alarm ) {
520 alarm->setEnabled(false); 520 alarm->setEnabled(false);
521 alarm->setType(Alarm::Invalid); 521 alarm->setType(Alarm::Invalid);
522 } 522 }
523 } 523 }
524 ListItemVisitor v(item, mStartDate ); 524 ListItemVisitor v(item, mStartDate );
525 inc->accept(v); 525 inc->accept(v);
526 item = sel.next(); 526 item = sel.next();
527 } 527 }
528 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); 528 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) );
529 qDebug("KO: Set alarm for %d items", count); 529 qDebug("KO: Set alarm for %d items", count);
530 calendar()->reInitAlarmSettings(); 530 calendar()->reInitAlarmSettings();
531 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 531 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
532} 532}
533void KOListView::setCategories( bool removeOld ) 533void KOListView::setCategories( bool removeOld )
534{ 534{
535 535
536 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 536 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
537 csd->setColorEnabled(); 537 csd->setColorEnabled();
538 if (! csd->exec()) { 538 if (! csd->exec()) {
539 delete csd; 539 delete csd;
540 return; 540 return;
541 } 541 }
542 QStringList catList = csd->selectedCategories(); 542 QStringList catList = csd->selectedCategories();
543 delete csd; 543 delete csd;
544 // if ( catList.count() == 0 ) 544 // if ( catList.count() == 0 )
545 // return; 545 // return;
546 //catList.sort(); 546 //catList.sort();
547 QString categoriesStr = catList.join(","); 547 QString categoriesStr = catList.join(",");
548 int i; 548 int i;
549 QStringList itemList; 549 QStringList itemList;
550 QPtrList<KOListViewItem> sel ; 550 QPtrList<KOListViewItem> sel ;
551 QListViewItem *qitem = mListView->firstChild (); 551 QListViewItem *qitem = mListView->firstChild ();
552 while ( qitem ) { 552 while ( qitem ) {
553 if ( qitem->isSelected() ) { 553 if ( qitem->isSelected() ) {
554 sel.append(((KOListViewItem *)qitem)); 554 sel.append(((KOListViewItem *)qitem));
555 } 555 }
556 qitem = qitem->nextSibling(); 556 qitem = qitem->nextSibling();
557 } 557 }
558 KOListViewItem * item, *temp; 558 KOListViewItem * item, *temp;
559 item = sel.first(); 559 item = sel.first();
560 if( item ) { 560 if( item ) {
561 Incidence* inc = item->data() ; 561 Incidence* inc = item->data() ;
562 bool setSub = false; 562 bool setSub = false;
563 if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) { 563 if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) {
564 int result = KMessageBox::warningYesNoCancel(this, 564 int result = KMessageBox::warningYesNoCancel(this,
565 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), 565 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ),
566 i18n("Todo has subtodos"), 566 i18n("Todo has subtodos"),
567 i18n("Yes"), 567 i18n("Yes"),
568 i18n("No")); 568 i18n("No"));
569 if (result == KMessageBox::Cancel) item = 0; 569 if (result == KMessageBox::Cancel) item = 0;
570 if (result == KMessageBox::Yes) setSub = true; 570 if (result == KMessageBox::Yes) setSub = true;
571 } 571 }
572 while ( item ) { 572 while ( item ) {
573 inc = item->data(); 573 inc = item->data();
574 if ( removeOld ) { 574 if ( removeOld ) {
575 inc->setCategories( catList, setSub ); 575 inc->setCategories( catList, setSub );
576 } else { 576 } else {
577 inc->addCategories( catList, setSub ); 577 inc->addCategories( catList, setSub );
578 } 578 }
579 ListItemVisitor v(item, mStartDate ); 579 ListItemVisitor v(item, mStartDate );
580 inc->accept(v); 580 inc->accept(v);
581 item = sel.next(); 581 item = sel.next();
582 } 582 }
583 } 583 }
584 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 584 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
585} 585}
586 586
587void KOListView::beamSelected() 587void KOListView::beamSelected()
588{ 588{
589 QPtrList<Incidence> delSel = getSelectedIncidences() ; 589 QPtrList<Incidence> delSel = getSelectedIncidences() ;
590 int icount = delSel.count(); 590 int icount = delSel.count();
591 if ( icount ) { 591 if ( icount ) {
592 emit beamIncidenceList( delSel ); 592 emit beamIncidenceList( delSel );
593 return; 593 return;
594 QString fn ; 594 QString fn ;
595 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 595 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
596 QString mes; 596 QString mes;
597 bool createbup = true; 597 bool createbup = true;
598 if ( createbup ) { 598 if ( createbup ) {
599 QString description = "\n"; 599 QString description = "\n";
600 CalendarLocal* cal = new CalendarLocal(); 600 CalendarLocal* cal = new CalendarLocal();
601 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 601 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
602 Incidence *incidence = delSel.first(); 602 Incidence *incidence = delSel.first();
603 while ( incidence ) { 603 while ( incidence ) {
604 Incidence *in = incidence->clone(); 604 Incidence *in = incidence->clone();
605 description += in->summary() + "\n"; 605 description += in->summary() + "\n";
606 cal->addIncidence( in ); 606 cal->addIncidence( in );
607 incidence = delSel.next(); 607 incidence = delSel.next();
608 } 608 }
609 FileStorage storage( cal, fn, new VCalFormat ); 609 FileStorage storage( cal, fn, new VCalFormat );
610 storage.save(); 610 storage.save();
611 delete cal; 611 delete cal;
612 mes = i18n("KO/Pi: Ready for beaming"); 612 mes = i18n("KO/Pi: Ready for beaming");
613 topLevelWidget()->setCaption(mes); 613 topLevelWidget()->setCaption(mes);
614 614
615#ifndef DESKTOP_VERSION 615#ifndef DESKTOP_VERSION
616 Ir *ir = new Ir( this ); 616 Ir *ir = new Ir( this );
617 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 617 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
618 ir->send( fn, description, "text/x-vCalendar" ); 618 ir->send( fn, description, "text/x-vCalendar" );
619#endif 619#endif
620 } 620 }
621 } 621 }
622} 622}
623void KOListView::beamDone( Ir *ir ) 623void KOListView::beamDone( Ir *ir )
624{ 624{
625#ifndef DESKTOP_VERSION 625#ifndef DESKTOP_VERSION
626 delete ir; 626 delete ir;
627#endif 627#endif
628 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 628 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
629} 629}
630 630
631void KOListView::saveDescriptionToFile() 631void KOListView::saveDescriptionToFile()
632{ 632{
633 633
634 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 634 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
635 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 635 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
636 i18n("Continue"), i18n("Cancel"), 0, 636 i18n("Continue"), i18n("Cancel"), 0,
637 0, 1 ); 637 0, 1 );
638 if ( result != 0 ) { 638 if ( result != 0 ) {
639 return; 639 return;
640 } 640 }
641 QPtrList<Incidence> delSel = getSelectedIncidences() ; 641 QPtrList<Incidence> delSel = getSelectedIncidences() ;
642 int icount = delSel.count(); 642 int icount = delSel.count();
643 if ( icount ) { 643 if ( icount ) {
644 QString fn = KOPrefs::instance()->mLastSaveFile; 644 QString fn = KOPrefs::instance()->mLastSaveFile;
645 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 645 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
646 646
647 if ( fn == "" ) 647 if ( fn == "" )
648 return; 648 return;
649 QFileInfo info; 649 QFileInfo info;
650 info.setFile( fn ); 650 info.setFile( fn );
651 QString mes; 651 QString mes;
652 bool createbup = true; 652 bool createbup = true;
653 if ( info. exists() ) { 653 if ( info. exists() ) {
654 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 654 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
655 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 655 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
656 i18n("Overwrite!"), i18n("Cancel"), 0, 656 i18n("Overwrite!"), i18n("Cancel"), 0,
657 0, 1 ); 657 0, 1 );
658 if ( result != 0 ) { 658 if ( result != 0 ) {
659 createbup = false; 659 createbup = false;
660 } 660 }
661 } 661 }
662 if ( createbup ) { 662 if ( createbup ) {
663 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 663 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
664 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 664 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
665 Incidence *incidence = delSel.first(); 665 Incidence *incidence = delSel.first();
666 icount = 0; 666 icount = 0;
667 while ( incidence ) { 667 while ( incidence ) {
668 if ( incidence->typeID() == journalID ) { 668 if ( incidence->typeID() == journalID ) {
669 text += "\n************************************\n"; 669 text += "\n************************************\n";
670 if ( !incidence->summary().isEmpty() ) 670 if ( !incidence->summary().isEmpty() )
671 text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); 671 text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false );
672 else 672 else
673 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 673 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
674 if ( !incidence->location().isEmpty() ) 674 if ( !incidence->location().isEmpty() )
675 text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; 675 text +="\n(" + i18n("Location: ") + incidence->location()+ ")";
676 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 676 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
677 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 677 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
678 ++icount; 678 ++icount;
679 679
680 } else { 680 } else {
681 if ( !incidence->description().isEmpty() ) { 681 if ( !incidence->description().isEmpty() ) {
682 text += "\n************************************\n"; 682 text += "\n************************************\n";
683 if ( incidence->typeID() == todoID ) 683 if ( incidence->typeID() == todoID )
684 text += i18n("To-Do: "); 684 text += i18n("To-Do: ");
685 text += incidence->summary(); 685 text += incidence->summary();
686 if ( !incidence->location().isEmpty() ) 686 if ( !incidence->location().isEmpty() )
687 text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; 687 text +="\n(" + i18n("Location: ") + incidence->location()+ ")";
688 if ( incidence->hasStartDate() ) 688 if ( incidence->hasStartDate() )
689 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 689 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
690 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 690 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
691 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 691 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
692 ++icount; 692 ++icount;
693 693
694 } 694 }
695 } 695 }
696 incidence = delSel.next(); 696 incidence = delSel.next();
697 } 697 }
698 QFile file( fn ); 698 QFile file( fn );
699 if (!file.open( IO_WriteOnly ) ) { 699 if (!file.open( IO_WriteOnly ) ) {
700 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 700 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
701 return; 701 return;
702 } 702 }
703 QTextStream ts( &file ); 703 QTextStream ts( &file );
704 ts << text; 704 ts << text;
705 file.close(); 705 file.close();
706 //qDebug("%s ", text.latin1()); 706 //qDebug("%s ", text.latin1());
707 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 707 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
708 KOPrefs::instance()->mLastSaveFile = fn; 708 KOPrefs::instance()->mLastSaveFile = fn;
709 topLevelWidget()->setCaption(mes); 709 topLevelWidget()->setCaption(mes);
710 } 710 }
711 } 711 }
712} 712}
713void KOListView::saveToFileVCS() 713void KOListView::saveToFileVCS()
714{ 714{
715 writeToFile( false ); 715 writeToFile( false );
716} 716}
717void KOListView::saveToFile() 717void KOListView::saveToFile()
718{ 718{
719 writeToFile( true ); 719 writeToFile( true );
720} 720}
721QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) 721QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos )
722{ 722{
723 QPtrList<Incidence> delSel ; 723 QPtrList<Incidence> delSel ;
724 bool addSubTodos = false; 724 bool addSubTodos = false;
725 bool askSubTodos = true; 725 bool askSubTodos = true;
726 QListViewItem *item = mListView->firstChild (); 726 QListViewItem *item = mListView->firstChild ();
727 while ( item ) { 727 while ( item ) {
728 if ( item->isSelected() ) { 728 if ( item->isSelected() ) {
729 Incidence* inc = ((KOListViewItem *)item)->data(); 729 Incidence* inc = ((KOListViewItem *)item)->data();
730 if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { 730 if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) {
731 if ( (inc->typeID() == todoID && includeTodos) || 731 if ( (inc->typeID() == todoID && includeTodos) ||
732 (inc->typeID() == eventID && includeEvents) || 732 (inc->typeID() == eventID && includeEvents) ||
733 (inc->typeID() == journalID && includeJournals) ) { 733 (inc->typeID() == journalID && includeJournals) ) {
734 if ( inc->typeID() == todoID && onlyDueTodos ) { 734 if ( inc->typeID() == todoID && onlyDueTodos ) {
735 if ( ((Todo*)inc)->hasDueDate() ) 735 if ( ((Todo*)inc)->hasDueDate() )
736 delSel.append( inc ); 736 delSel.append( inc );
737 } else 737 } else
738 delSel.append( inc ); 738 delSel.append( inc );
739 739
740 } 740 }
741 } 741 }
742 if ( inc->typeID() == todoID ) { 742 if ( inc->typeID() == todoID ) {
743 Todo * todo = (Todo*) inc; 743 Todo * todo = (Todo*) inc;
744 if ( todo->relations().count() ) { 744 if ( todo->relations().count() ) {
745 if ( askSubTodos ) { 745 if ( askSubTodos ) {
746 int result = KMessageBox::warningYesNoCancel(this, 746 int result = KMessageBox::warningYesNoCancel(this,
747 i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), 747 i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"),
748 i18n("Todo has subtodos"), 748 i18n("Todo has subtodos"),
749 i18n("Yes"), 749 i18n("Yes"),
750 i18n("No")); 750 i18n("No"));
751 if ( result == KMessageBox::Cancel ) { 751 if ( result == KMessageBox::Cancel ) {
752 delSel.clear(); 752 delSel.clear();
753 return delSel; 753 return delSel;
754 } 754 }
755 if (result == KMessageBox::Yes) 755 if (result == KMessageBox::Yes)
756 addSubTodos = true; 756 addSubTodos = true;
757 askSubTodos = false; 757 askSubTodos = false;
758 } 758 }
759 if ( addSubTodos ) { 759 if ( addSubTodos ) {
760 inc->addRelationsToList( &delSel ); 760 inc->addRelationsToList( &delSel );
761 } 761 }
762 } 762 }
763 } 763 }
764 } 764 }
765 item = item->nextSibling(); 765 item = item->nextSibling();
766 } 766 }
767 return delSel; 767 return delSel;
768} 768}
769 769
770void KOListView::writeToFile( bool iCal ) 770void KOListView::writeToFile( bool iCal )
771{ 771{
772 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; 772 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
773 if ( !iCal ) { 773 if ( !iCal ) {
774 bool journal = false; 774 bool journal = false;
775 Incidence *incidence = delSel.first(); 775 Incidence *incidence = delSel.first();
776 while ( incidence ) { 776 while ( incidence ) {
777 if ( incidence->typeID() == journalID ) { 777 if ( incidence->typeID() == journalID ) {
778 journal = true; 778 journal = true;
779 break; 779 break;
780 } 780 }
781 incidence = delSel.next(); 781 incidence = delSel.next();
782 } 782 }
783 if ( journal ) { 783 if ( journal ) {
784 int result = KMessageBox::warningContinueCancel(this, 784 int result = KMessageBox::warningContinueCancel(this,
785 i18n("The journal entries can not be\nexported to a vCalendar file."), 785 i18n("The journal entries can not be\nexported to a vCalendar file."),
786 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 786 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
787 true); 787 true);
788 if (result != KMessageBox::Continue) return; 788 if (result != KMessageBox::Continue) return;
789 } 789 }
790 } 790 }
791 if ( delSel.count() ) { 791 if ( delSel.count() ) {
792 QString fn = KOPrefs::instance()->mLastSaveFile; 792 QString fn = KOPrefs::instance()->mLastSaveFile;
793 QString extension; 793 QString extension;
794 if ( iCal ) { 794 if ( iCal ) {
795 if ( fn.right( 4 ).lower() == ".vcs" ) { 795 if ( fn.right( 4 ).lower() == ".vcs" ) {
796 fn = fn.left( fn.length() -3) + "ics"; 796 fn = fn.left( fn.length() -3) + "ics";
797 } 797 }
798 } else { 798 } else {
799 if ( fn.right( 4 ).lower() == ".ics" ) { 799 if ( fn.right( 4 ).lower() == ".ics" ) {
800 fn = fn.left( fn.length() -3) + "vcs"; 800 fn = fn.left( fn.length() -3) + "vcs";
801 } 801 }
802 } 802 }
803 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 803 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
804 804
805 if ( fn == "" ) 805 if ( fn == "" )
806 return; 806 return;
807 QFileInfo info; 807 QFileInfo info;
808 info.setFile( fn ); 808 info.setFile( fn );
809 QString mes; 809 QString mes;
810 bool createbup = true; 810 bool createbup = true;
811 if ( info. exists() ) { 811 if ( info. exists() ) {
812 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 812 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
813 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 813 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
814 i18n("Overwrite!"), i18n("Cancel"), 0, 814 i18n("Overwrite!"), i18n("Cancel"), 0,
815 0, 1 ); 815 0, 1 );
816 if ( result != 0 ) { 816 if ( result != 0 ) {
817 createbup = false; 817 createbup = false;
818 } 818 }
819 } 819 }
820 if ( createbup ) { 820 if ( createbup ) {
821 CalendarLocal cal; 821 CalendarLocal cal;
822 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 822 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
823 Incidence *incidence = delSel.first(); 823 Incidence *incidence = delSel.first();
824 while ( incidence ) { 824 while ( incidence ) {
825 cal.addIncidence( incidence->clone() ); 825 cal.addIncidence( incidence->clone() );
826 incidence = delSel.next(); 826 incidence = delSel.next();
827 } 827 }
828 if ( iCal ) { 828 if ( iCal ) {
829 ICalFormat format; 829 ICalFormat format;
830 format.save( &cal, fn ); 830 format.save( &cal, fn );
831 } else { 831 } else {
832 832
833 VCalFormat format; 833 VCalFormat format;
834 format.save( &cal, fn ); 834 format.save( &cal, fn );
835 } 835 }
836 mes = i18n("KO/Pi:Saved %1").arg(fn ); 836 mes = i18n("KO/Pi:Saved %1").arg(fn );
837 KOPrefs::instance()->mLastSaveFile = fn; 837 KOPrefs::instance()->mLastSaveFile = fn;
838 topLevelWidget()->setCaption(mes); 838 topLevelWidget()->setCaption(mes);
839 } 839 }
840 } 840 }
841 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 841 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
842} 842}
843void KOListView::hideAll() 843void KOListView::hideAll()
844{ 844{
845 QPtrList<QListViewItem> delSel ; 845 QPtrList<QListViewItem> delSel ;
846 QListViewItem *item = mListView->firstChild (); 846 QListViewItem *item = mListView->firstChild ();
847 while ( item ) { 847 while ( item ) {
848 if ( item->isSelected() ) { 848 if ( item->isSelected() ) {
849 delSel.append(item); 849 delSel.append(item);
850 } 850 }
851 item = item->nextSibling(); 851 item = item->nextSibling();
852 } 852 }
853 item = delSel.first() ; 853 item = delSel.first() ;
854 while ( item ) { 854 while ( item ) {
855 QListViewItem * del = item; 855 QListViewItem * del = item;
856 item = delSel.next(); 856 item = delSel.next();
857 delete del; 857 delete del;
858 } 858 }
859} 859}
860void KOListView::printList() 860void KOListView::printList()
861{ 861{
862 mListView->printList(); 862 mListView->printList();
863} 863}
864void KOListView::deleteAll() 864void KOListView::deleteAll()
865{ 865{
866 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; 866 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;;
867 if ( delSel.count() ) { 867 if ( delSel.count() ) {
868 int icount = delSel.count(); 868 int icount = delSel.count();
869 Incidence *incidence = delSel.first(); 869 Incidence *incidence = delSel.first();
870 Incidence *toDelete; 870 Incidence *toDelete;
871 KOPrefs *p = KOPrefs::instance(); 871 KOPrefs *p = KOPrefs::instance();
872 bool confirm = p->mConfirm; 872 bool confirm = p->mConfirm;
873 QString mess; 873 QString mess;
874 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 874 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
875 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 875 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
876 p->mConfirm = false; 876 p->mConfirm = false;
877 int delCounter = 0; 877 int delCounter = 0;
878 QDialog dia ( this, "p-dialog", true ); 878 QDialog dia ( this, "p-dialog", true );
879 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 879 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
880 QVBoxLayout lay( &dia ); 880 QVBoxLayout lay( &dia );
881 lay.setMargin(7); 881 lay.setMargin(7);
882 lay.setSpacing(7); 882 lay.setSpacing(7);
883 lay.addWidget( &lab); 883 lay.addWidget( &lab);
884 QProgressBar bar( icount, &dia ); 884 QProgressBar bar( icount, &dia );
885 lay.addWidget( &bar); 885 lay.addWidget( &bar);
886 int w = 220; 886 int w = 220;
887 int h = 50; 887 int h = 50;
888 int dw = QApplication::desktop()->width(); 888 int dw = QApplication::desktop()->width();
889 int dh = QApplication::desktop()->height(); 889 int dh = QApplication::desktop()->height();
890 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 890 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
891 //dia.resize( 240,50 ); 891 //dia.resize( 240,50 );
892 dia.show(); 892 dia.show();
893 893
894 while ( incidence ) { 894 while ( incidence ) {
895 bar.setProgress( delCounter ); 895 bar.setProgress( delCounter );
896 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 896 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
897 dia.setCaption( mess ); 897 dia.setCaption( mess );
898 qApp->processEvents(); 898 qApp->processEvents();
899 toDelete = (incidence); 899 toDelete = (incidence);
900 incidence = delSel.next(); 900 incidence = delSel.next();
901 emit deleteIncidenceSignal(toDelete ); 901 emit deleteIncidenceSignal(toDelete );
902 if ( dia.result() != 0 ) 902 if ( dia.result() != 0 )
903 break; 903 break;
904 904
905 } 905 }
906 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 906 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
907 topLevelWidget ()->setCaption( mess ); 907 topLevelWidget ()->setCaption( mess );
908 p->mConfirm = confirm; 908 p->mConfirm = confirm;
909 } 909 }
910 } 910 }
911 911
912 912
913} 913}
914int KOListView::maxDatesHint() 914int KOListView::maxDatesHint()
915{ 915{
916 return 0; 916 return 0;
917} 917}
918 918
919int KOListView::currentDateCount() 919int KOListView::currentDateCount()
920{ 920{
921 return 0; 921 return 0;
922} 922}
923 923
924QPtrList<Incidence> KOListView::selectedIncidences() 924QPtrList<Incidence> KOListView::selectedIncidences()
925{ 925{
926 QPtrList<Incidence> eventList; 926 QPtrList<Incidence> eventList;
927 QListViewItem *item = mListView->firstChild (); 927 QListViewItem *item = mListView->firstChild ();
928 while ( item ) { 928 while ( item ) {
929 if ( item->isSelected() ) { 929 if ( item->isSelected() ) {
930 eventList.append(((KOListViewItem *)item)->data()); 930 eventList.append(((KOListViewItem *)item)->data());
931 } 931 }
932 932
933 item = item->nextSibling(); 933 item = item->nextSibling();
934 } 934 }
935 935
936 // // QListViewItem *item = mListView->selectedItem(); 936 // // QListViewItem *item = mListView->selectedItem();
937 //if (item) eventList.append(((KOListViewItem *)item)->data()); 937 //if (item) eventList.append(((KOListViewItem *)item)->data());
938 938
939 return eventList; 939 return eventList;
940} 940}
941 941
942DateList KOListView::selectedDates() 942DateList KOListView::selectedDates()
943{ 943{
944 DateList eventList; 944 DateList eventList;
945 return eventList; 945 return eventList;
946} 946}
947 947
948void KOListView::showDates(bool show) 948void KOListView::showDates(bool show)
949{ 949{
950 // Shouldn't we set it to a value greater 0? When showDates is called with 950 // Shouldn't we set it to a value greater 0? When showDates is called with
951 // show == true at first, then the columnwidths are set to zero. 951 // show == true at first, then the columnwidths are set to zero.
952 static int oldColWidth1 = 0; 952 static int oldColWidth1 = 0;
953 static int oldColWidth3 = 0; 953 static int oldColWidth3 = 0;
954 954
955 if (!show) { 955 if (!show) {
956 oldColWidth1 = mListView->columnWidth(1); 956 oldColWidth1 = mListView->columnWidth(1);
957 oldColWidth3 = mListView->columnWidth(3); 957 oldColWidth3 = mListView->columnWidth(3);
958 mListView->setColumnWidth(1, 0); 958 mListView->setColumnWidth(1, 0);
959 mListView->setColumnWidth(3, 0); 959 mListView->setColumnWidth(3, 0);
960 } else { 960 } else {
961 mListView->setColumnWidth(1, oldColWidth1); 961 mListView->setColumnWidth(1, oldColWidth1);
962 mListView->setColumnWidth(3, oldColWidth3); 962 mListView->setColumnWidth(3, oldColWidth3);
963 } 963 }
964 mListView->repaint(); 964 mListView->repaint();
965} 965}
966 966
967void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 967void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
968 const QDate &td) 968 const QDate &td)
969{ 969{
970#ifndef KORG_NOPRINTER 970#ifndef KORG_NOPRINTER
971 calPrinter->preview(CalPrinter::Day, fd, td); 971 calPrinter->preview(CalPrinter::Day, fd, td);
972#endif 972#endif
973} 973}
974 974
975void KOListView::showDates() 975void KOListView::showDates()
976{ 976{
977 showDates(true); 977 showDates(true);
978} 978}
979 979
980void KOListView::hideDates() 980void KOListView::hideDates()
981{ 981{
982 showDates(false); 982 showDates(false);
983} 983}
984 984
985void KOListView::resetFocus() 985void KOListView::resetFocus()
986{ 986{
987 topLevelWidget()->setActiveWindow(); 987 topLevelWidget()->setActiveWindow();
988 topLevelWidget()->raise(); 988 topLevelWidget()->raise();
989 mListView->setFocus(); 989 mListView->setFocus();
990} 990}
991void KOListView::updateView() 991void KOListView::updateView()
992{ 992{
993 mListView->setFocus(); 993 mListView->setFocus();
994 if ( mListView->firstChild () ) 994 if ( mListView->firstChild () )
995 mListView->setCurrentItem( mListView->firstChild () ); 995 mListView->setCurrentItem( mListView->firstChild () );
996} 996}
997void KOListView::updateConfig() 997void KOListView::updateConfig()
998{ 998{
999 999
1000 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 1000 mListView->setFont ( KOPrefs::instance()->mListViewFont );
1001 updateView(); 1001 updateView();
1002 1002
1003} 1003}
1004void KOListView::setStartDate(const QDate &start) 1004void KOListView::setStartDate(const QDate &start)
1005{ 1005{
1006 mStartDate = start; 1006 mStartDate = start;
1007} 1007}
1008 1008
1009void KOListView::showDates(const QDate &start, const QDate &end) 1009void KOListView::showDates(const QDate &start, const QDate &end)
1010{ 1010{
1011 clear(); 1011 clear();
1012 mStartDate = start; 1012 mStartDate = start;
1013 QDate date = start; 1013 QDate date = start;
1014 QPtrList<Journal> j_list;
1015 while( date <= end ) { 1014 while( date <= end ) {
1016 addEvents(calendar()->events(date)); 1015 addEvents(calendar()->events(date));
1017 addTodos(calendar()->todos(date)); 1016 addTodos(calendar()->todos(date));
1018 Journal* jo = calendar()->journal(date); 1017 addJournals( calendar()->journals4Date(date) );
1019 if ( jo )
1020 j_list.append( jo );
1021 date = date.addDays( 1 ); 1018 date = date.addDays( 1 );
1022 } 1019 }
1023 addJournals(j_list);
1024 emit incidenceSelected( 0 ); 1020 emit incidenceSelected( 0 );
1025 updateView(); 1021 updateView();
1026 1022
1027} 1023}
1028 1024
1029void KOListView::addEvents(QPtrList<Event> eventList) 1025void KOListView::addEvents(QPtrList<Event> eventList)
1030{ 1026{
1031 1027
1032 Event *ev; 1028 Event *ev;
1033 for(ev = eventList.first(); ev; ev = eventList.next()) { 1029 for(ev = eventList.first(); ev; ev = eventList.next()) {
1034 addIncidence(ev); 1030 addIncidence(ev);
1035 } 1031 }
1036 if ( !mListView->currentItem() ){ 1032 if ( !mListView->currentItem() ){
1037 updateView(); 1033 updateView();
1038 } 1034 }
1039} 1035}
1040 1036
1041void KOListView::addTodos(QPtrList<Todo> eventList) 1037void KOListView::addTodos(QPtrList<Todo> eventList)
1042{ 1038{
1043 Todo *ev; 1039 Todo *ev;
1044 for(ev = eventList.first(); ev; ev = eventList.next()) { 1040 for(ev = eventList.first(); ev; ev = eventList.next()) {
1045 addIncidence(ev); 1041 addIncidence(ev);
1046 } 1042 }
1047 if ( !mListView->currentItem() ){ 1043 if ( !mListView->currentItem() ){
1048 updateView(); 1044 updateView();
1049 } 1045 }
1050} 1046}
1051void KOListView::addJournals(QPtrList<Journal> eventList) 1047void KOListView::addJournals(QPtrList<Journal> eventList)
1052{ 1048{
1053 Journal *ev; 1049 Journal *ev;
1054 for(ev = eventList.first(); ev; ev = eventList.next()) { 1050 for(ev = eventList.first(); ev; ev = eventList.next()) {
1055 addIncidence(ev); 1051 addIncidence(ev);
1056 } 1052 }
1057 if ( !mListView->currentItem() ){ 1053 if ( !mListView->currentItem() ){
1058 updateView(); 1054 updateView();
1059 } 1055 }
1060} 1056}
1061 1057
1062void KOListView::showCompletedTodos() 1058void KOListView::showCompletedTodos()
1063{ 1059{
1064 mForceShowCompletedTodos = true; 1060 mForceShowCompletedTodos = true;
1065} 1061}
1066void KOListView::addIncidence(Incidence *incidence) 1062void KOListView::addIncidence(Incidence *incidence)
1067{ 1063{
1068 if ( mUidDict.find( incidence->uid() ) ) return; 1064 if ( mUidDict.find( incidence->uid() ) ) return;
1069 1065
1070 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 1066 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
1071 if ( incidence->typeID() == todoID ) { 1067 if ( incidence->typeID() == todoID ) {
1072 if ( ! mForceShowCompletedTodos ) { 1068 if ( ! mForceShowCompletedTodos ) {
1073 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) 1069 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() )
1074 return; 1070 return;
1075 } 1071 }
1076 } 1072 }
1077 mUidDict.insert( incidence->uid(), incidence ); 1073 mUidDict.insert( incidence->uid(), incidence );
1078 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 1074 KOListViewItem *item = new KOListViewItem( incidence, mListView );
1079 ListItemVisitor v(item, mStartDate ); 1075 ListItemVisitor v(item, mStartDate );
1080 if (incidence->accept(v)) { 1076 if (incidence->accept(v)) {
1081 return; 1077 return;
1082 } 1078 }
1083 else delete item; 1079 else delete item;
1084} 1080}
1085 1081
1086void KOListView::showEvents(QPtrList<Event> eventList) 1082void KOListView::showEvents(QPtrList<Event> eventList)
1087{ 1083{
1088 clear(); 1084 clear();
1089 1085
1090 addEvents(eventList); 1086 addEvents(eventList);
1091 1087
1092 // After new creation of list view no events are selected. 1088 // After new creation of list view no events are selected.
1093 emit incidenceSelected( 0 ); 1089 emit incidenceSelected( 0 );
1094} 1090}
1095int KOListView::count() 1091int KOListView::count()
1096{ 1092{
1097 return mListView->childCount(); 1093 return mListView->childCount();
1098} 1094}
1099 1095
1100void KOListView::changeEventDisplay(Event *event, int action) 1096void KOListView::changeEventDisplay(Event *event, int action)
1101{ 1097{
1102 KOListViewItem *item; 1098 KOListViewItem *item;
1103 1099
1104 switch(action) { 1100 switch(action) {
1105 case KOGlobals::EVENTADDED: 1101 case KOGlobals::EVENTADDED:
1106 addIncidence( event ); 1102 addIncidence( event );
1107 break; 1103 break;
1108 case KOGlobals::EVENTEDITED: 1104 case KOGlobals::EVENTEDITED:
1109 item = getItemForEvent(event); 1105 item = getItemForEvent(event);
1110 if (item) { 1106 if (item) {
1111 mUidDict.remove( event->uid() ); 1107 mUidDict.remove( event->uid() );
1112 delete item; 1108 delete item;
1113 addIncidence( event ); 1109 addIncidence( event );
1114 } 1110 }
1115 break; 1111 break;
1116 case KOGlobals::EVENTDELETED: 1112 case KOGlobals::EVENTDELETED:
1117 item = getItemForEvent(event); 1113 item = getItemForEvent(event);
1118 if (item) { 1114 if (item) {
1119 mUidDict.remove( event->uid() ); 1115 mUidDict.remove( event->uid() );
1120 delete item; 1116 delete item;
1121 } 1117 }
1122 break; 1118 break;
1123 default: 1119 default:
1124 ; 1120 ;
1125 } 1121 }
1126} 1122}
1127 1123
1128KOListViewItem *KOListView::getItemForEvent(Incidence *event) 1124KOListViewItem *KOListView::getItemForEvent(Incidence *event)
1129{ 1125{
1130 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 1126 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
1131 while (item) { 1127 while (item) {
1132 if (item->data() == event) return item; 1128 if (item->data() == event) return item;
1133 item = (KOListViewItem *)item->nextSibling(); 1129 item = (KOListViewItem *)item->nextSibling();
1134 } 1130 }
1135 return 0; 1131 return 0;
1136} 1132}
1137 1133
1138void KOListView::defaultItemAction(QListViewItem *i) 1134void KOListView::defaultItemAction(QListViewItem *i)
1139{ 1135{
1140 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 1136 KOListViewItem *item = static_cast<KOListViewItem *>( i );
1141 if ( item ) defaultAction( item->data() ); 1137 if ( item ) defaultAction( item->data() );
1142 1138
1143} 1139}
1144 1140
1145void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 1141void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
1146{ 1142{
1147 mActiveItem = (KOListViewItem *)item; 1143 mActiveItem = (KOListViewItem *)item;
1148 if (mActiveItem) { 1144 if (mActiveItem) {
1149 Incidence *incidence = mActiveItem->data(); 1145 Incidence *incidence = mActiveItem->data();
1150 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); 1146 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) );
1151 mPopupMenu->showIncidencePopup(incidence); 1147 mPopupMenu->showIncidencePopup(incidence);
1152 1148
1153 /* 1149 /*
1154 if ( incidence && incidence->type() == "Event" ) { 1150 if ( incidence && incidence->type() == "Event" ) {
1155 Event *event = static_cast<Event *>( incidence ); 1151 Event *event = static_cast<Event *>( incidence );
1156 mPopupMenu->showEventPopup(event); 1152 mPopupMenu->showEventPopup(event);
1157 } 1153 }
1158 */ 1154 */
1159 } 1155 }
1160} 1156}
1161 1157
1162void KOListView::readSettings(KConfig *config, QString setting) 1158void KOListView::readSettings(KConfig *config, QString setting)
1163{ 1159{
1164 // qDebug("KOListView::readSettings "); 1160 // qDebug("KOListView::readSettings ");
1165 mListView->restoreLayout(config,setting); 1161 mListView->restoreLayout(config,setting);
1166} 1162}
1167 1163
1168void KOListView::writeSettings(KConfig *config, QString setting) 1164void KOListView::writeSettings(KConfig *config, QString setting)
1169{ 1165{
1170 // qDebug("KOListView::writeSettings "); 1166 // qDebug("KOListView::writeSettings ");
1171 mListView->saveLayout(config, setting); 1167 mListView->saveLayout(config, setting);
1172} 1168}
1173 1169
1174void KOListView::processSelectionChange(QListViewItem *) 1170void KOListView::processSelectionChange(QListViewItem *)
1175{ 1171{
1176 1172
1177 KOListViewItem *item = 1173 KOListViewItem *item =
1178 static_cast<KOListViewItem *>( mListView->currentItem() ); 1174 static_cast<KOListViewItem *>( mListView->currentItem() );
1179 1175
1180 if ( !item ) { 1176 if ( !item ) {
1181 emit incidenceSelected( 0 ); 1177 emit incidenceSelected( 0 );
1182 } else { 1178 } else {
1183 emit incidenceSelected( item->data() ); 1179 emit incidenceSelected( item->data() );
1184 } 1180 }
1185} 1181}
1186 1182
1187void KOListView::clearSelection() 1183void KOListView::clearSelection()
1188{ 1184{
1189 mListView->selectAll( false ); 1185 mListView->selectAll( false );
1190} 1186}
1191void KOListView::allSelection() 1187void KOListView::allSelection()
1192{ 1188{
1193 mListView->selectAll( true ); 1189 mListView->selectAll( true );
1194} 1190}
1195 1191
1196void KOListView::clear() 1192void KOListView::clear()
1197{ 1193{
1198 mListView->clear(); 1194 mListView->clear();
1199 mUidDict.clear(); 1195 mUidDict.clear();
1200} 1196}
1201 1197
1202Incidence* KOListView::currentItem() 1198Incidence* KOListView::currentItem()
1203{ 1199{
1204 if ( mListView->currentItem() ) 1200 if ( mListView->currentItem() )
1205 return ((KOListViewItem*) mListView->currentItem())->data(); 1201 return ((KOListViewItem*) mListView->currentItem())->data();
1206 return 0; 1202 return 0;
1207} 1203}
1208void KOListView::keyPressEvent ( QKeyEvent *e) 1204void KOListView::keyPressEvent ( QKeyEvent *e)
1209{ 1205{
1210 1206
1211 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1207 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1212 deleteAll(); 1208 deleteAll();
1213 return; 1209 return;
1214 } 1210 }
1215 1211
1216 e->ignore(); 1212 e->ignore();
1217} 1213}
1218void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1214void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1219{ 1215{
1220 1216
1221 switch ( e->key() ) { 1217 switch ( e->key() ) {
1222 case Qt::Key_Down: 1218 case Qt::Key_Down:
1223 if ( e->state() == ShiftButton ) { 1219 if ( e->state() == ShiftButton ) {
1224 QListViewItem* cn = currentItem(); 1220 QListViewItem* cn = currentItem();
1225 if ( !cn ) 1221 if ( !cn )
1226 cn = firstChild(); 1222 cn = firstChild();
1227 if ( !cn ) 1223 if ( !cn )
1228 return; 1224 return;
1229 while ( cn->nextSibling() ) 1225 while ( cn->nextSibling() )
1230 cn = cn->nextSibling(); 1226 cn = cn->nextSibling();
1231 setCurrentItem ( cn ); 1227 setCurrentItem ( cn );
1232 ensureItemVisible ( cn ); 1228 ensureItemVisible ( cn );
1233 1229
1234 e->accept(); 1230 e->accept();
1235 return; 1231 return;
1236 } 1232 }
1237 if ( e->state() == ControlButton ) { 1233 if ( e->state() == ControlButton ) {
1238 int count = childCount (); 1234 int count = childCount ();
1239 int jump = count / 5; 1235 int jump = count / 5;
1240 QListViewItem* cn; 1236 QListViewItem* cn;
1241 cn = currentItem(); 1237 cn = currentItem();
1242 if ( ! cn ) 1238 if ( ! cn )
1243 return; 1239 return;
1244 if ( jump == 0 ) 1240 if ( jump == 0 )
1245 jump = 1; 1241 jump = 1;
1246 while ( jump && cn->nextSibling() ) { 1242 while ( jump && cn->nextSibling() ) {
1247 cn = cn->nextSibling(); 1243 cn = cn->nextSibling();
1248 --jump; 1244 --jump;
1249 } 1245 }
1250 setCurrentItem ( cn ); 1246 setCurrentItem ( cn );
1251 ensureItemVisible ( cn ); 1247 ensureItemVisible ( cn );
1252 1248
1253 } else 1249 } else
1254 QListView::keyPressEvent ( e ) ; 1250 QListView::keyPressEvent ( e ) ;
1255 e->accept(); 1251 e->accept();
1256 break; 1252 break;
1257 1253
1258 case Qt::Key_Up: 1254 case Qt::Key_Up:
1259 if ( e->state() == ShiftButton ) { 1255 if ( e->state() == ShiftButton ) {
1260 QListViewItem* cn = firstChild(); 1256 QListViewItem* cn = firstChild();
1261 if ( cn ) { 1257 if ( cn ) {
1262 setCurrentItem ( cn ); 1258 setCurrentItem ( cn );
1263 ensureItemVisible ( cn ); 1259 ensureItemVisible ( cn );
1264 } 1260 }
1265 e->accept(); 1261 e->accept();
1266 return; 1262 return;
1267 } 1263 }
1268 if ( e->state() == ControlButton ) { 1264 if ( e->state() == ControlButton ) {
1269 int count = childCount (); 1265 int count = childCount ();
1270 int jump = count / 5; 1266 int jump = count / 5;
1271 QListViewItem* cn; 1267 QListViewItem* cn;
1272 cn = currentItem(); 1268 cn = currentItem();
1273 if ( ! cn ) 1269 if ( ! cn )
1274 return; 1270 return;
1275 if ( jump == 0 ) 1271 if ( jump == 0 )
1276 jump = 1; 1272 jump = 1;
1277 while ( jump && cn->itemAbove ()) { 1273 while ( jump && cn->itemAbove ()) {
1278 cn = cn->itemAbove (); 1274 cn = cn->itemAbove ();
1279 --jump; 1275 --jump;
1280 } 1276 }
1281 setCurrentItem ( cn ); 1277 setCurrentItem ( cn );
1282 ensureItemVisible ( cn ); 1278 ensureItemVisible ( cn );
1283 } else 1279 } else
1284 QListView::keyPressEvent ( e ) ; 1280 QListView::keyPressEvent ( e ) ;
1285 e->accept(); 1281 e->accept();
1286 break; 1282 break;
1287 case Qt::Key_I: { 1283 case Qt::Key_I: {
1288 QListViewItem* cn; 1284 QListViewItem* cn;
1289 cn = currentItem(); 1285 cn = currentItem();
1290 if ( cn ) { 1286 if ( cn ) {
1291 KOListViewItem* ci = (KOListViewItem*)( cn ); 1287 KOListViewItem* ci = (KOListViewItem*)( cn );
1292 if ( ci ){ 1288 if ( ci ){
1293 //emit showIncidence( ci->data()); 1289 //emit showIncidence( ci->data());
1294 cn = cn->nextSibling(); 1290 cn = cn->nextSibling();
1295 if ( cn ) { 1291 if ( cn ) {
1296 setCurrentItem ( cn ); 1292 setCurrentItem ( cn );
1297 ensureItemVisible ( cn ); 1293 ensureItemVisible ( cn );
1298 } 1294 }
1299 emit showIncidence( ci->data()); 1295 emit showIncidence( ci->data());
1300 } 1296 }
1301 } 1297 }
1302 e->accept(); 1298 e->accept();
1303 } 1299 }
1304 break; 1300 break;
1305 case Qt::Key_Return: 1301 case Qt::Key_Return:
1306 case Qt::Key_Enter: 1302 case Qt::Key_Enter:
1307 { 1303 {
1308 QListViewItem* cn; 1304 QListViewItem* cn;
1309 cn = currentItem(); 1305 cn = currentItem();
1310 if ( cn ) { 1306 if ( cn ) {
1311 KOListViewItem* ci = (KOListViewItem*)( cn ); 1307 KOListViewItem* ci = (KOListViewItem*)( cn );
1312 if ( ci ){ 1308 if ( ci ){
1313 if ( e->state() == ShiftButton ) 1309 if ( e->state() == ShiftButton )
1314 ci->setSelected( false ); 1310 ci->setSelected( false );
1315 else 1311 else
1316 ci->setSelected( true ); 1312 ci->setSelected( true );
1317 cn = cn->nextSibling(); 1313 cn = cn->nextSibling();
1318 if ( cn ) { 1314 if ( cn ) {
1319 setCurrentItem ( cn ); 1315 setCurrentItem ( cn );
1320 ensureItemVisible ( cn ); 1316 ensureItemVisible ( cn );
1321 } 1317 }
1322 } 1318 }
1323 } 1319 }
1324 e->accept(); 1320 e->accept();
1325 } 1321 }
1326 break; 1322 break;
1327 default: 1323 default:
1328 e->ignore(); 1324 e->ignore();
1329 } 1325 }
1330} 1326}
1331KOListViewListView::KOListViewListView(KOListView * lv ) 1327KOListViewListView::KOListViewListView(KOListView * lv )
1332 : KListView( lv, "kolistlistview", false ) 1328 : KListView( lv, "kolistlistview", false )
1333{ 1329{
1334 mYMousePos = 0; 1330 mYMousePos = 0;
1335 mPopupTimer = new QTimer(this); 1331 mPopupTimer = new QTimer(this);
1336 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1332 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1337#ifndef DESKTOP_VERSION 1333#ifndef DESKTOP_VERSION
1338 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1334 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1339#endif 1335#endif
1340 setSelectionMode( QListView::Multi ); 1336 setSelectionMode( QListView::Multi );
1341 setMultiSelection( true); 1337 setMultiSelection( true);
1342} 1338}
1343bool KOListViewListView::hasMultiSelection(QListViewItem* item) 1339bool KOListViewListView::hasMultiSelection(QListViewItem* item)
1344{ 1340{
1345 int selCount = 0; 1341 int selCount = 0;
1346 QListViewItem *qitem = firstChild (); 1342 QListViewItem *qitem = firstChild ();
1347 while ( qitem ) { 1343 while ( qitem ) {
1348 if ( qitem->isSelected() && item != qitem ) 1344 if ( qitem->isSelected() && item != qitem )
1349 return true; 1345 return true;
1350 qitem = qitem->nextSibling(); 1346 qitem = qitem->nextSibling();
1351 } 1347 }
1352 return false; 1348 return false;
1353} 1349}
1354void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1350void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1355{ 1351{
1356 if (!e) return; 1352 if (!e) return;
1357 QPoint vp = contentsToViewport(e->pos()); 1353 QPoint vp = contentsToViewport(e->pos());
1358 QListViewItem *item = itemAt(vp); 1354 QListViewItem *item = itemAt(vp);
1359 if (!item) { 1355 if (!item) {
1360 emit newEvent(); 1356 emit newEvent();
1361 return; 1357 return;
1362 } 1358 }
1363 KListView::contentsMouseDoubleClickEvent(e); 1359 KListView::contentsMouseDoubleClickEvent(e);
1364} 1360}
1365#if 0 1361#if 0
1366void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1362void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1367{ 1363{
1368 //qDebug("contentsMousePressEvent++++ "); 1364 //qDebug("contentsMousePressEvent++++ ");
1369 KListView::contentsMousePressEvent( e ); 1365 KListView::contentsMousePressEvent( e );
1370 if ( e->button() == RightButton ) { 1366 if ( e->button() == RightButton ) {
1371 QListViewItem* ci = currentItem(); 1367 QListViewItem* ci = currentItem();
1372 clearSelection () ; 1368 clearSelection () ;
1373 if ( ci ) 1369 if ( ci )
1374 ci->setSelected( true ); 1370 ci->setSelected( true );
1375 } 1371 }
1376} 1372}
1377void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1373void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1378{ 1374{
1379 KListView::contentsMouseReleaseEvent(e); 1375 KListView::contentsMouseReleaseEvent(e);
1380} 1376}
1381void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1377void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1382{ 1378{
1383 KListView::contentsMouseMoveEvent(e); 1379 KListView::contentsMouseMoveEvent(e);
1384} 1380}
1385#endif 1381#endif
1386void KOListViewListView::popupMenu() 1382void KOListViewListView::popupMenu()
1387{ 1383{
1388 mPopupTimer->stop(); 1384 mPopupTimer->stop();
1389 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1385 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1390 QApplication::postEvent( this->viewport(), e ); 1386 QApplication::postEvent( this->viewport(), e );
1391 1387
1392} 1388}
1393void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1389void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1394{ 1390{
1395 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); 1391 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y());
1396 mYMousePos = mapToGlobal( (e->pos())).y(); 1392 mYMousePos = mapToGlobal( (e->pos())).y();
1397 if ( e->button() == LeftButton ) { 1393 if ( e->button() == LeftButton ) {
1398 mPopupTimer->start( 600 ); 1394 mPopupTimer->start( 600 );
1399 mEventPos = contentsToViewport(e->pos()); 1395 mEventPos = contentsToViewport(e->pos());
1400 mEventGlobalPos = e->globalPos(); 1396 mEventGlobalPos = e->globalPos();
1401 } 1397 }
1402 KListView::contentsMousePressEvent( e ); 1398 KListView::contentsMousePressEvent( e );
1403 if ( e->button() == RightButton ) { 1399 if ( e->button() == RightButton ) {
1404 QListViewItem* ci = currentItem(); 1400 QListViewItem* ci = currentItem();
1405 //clearSelection(); 1401 //clearSelection();
1406 if ( ci ) 1402 if ( ci )
1407 ci->setSelected( true ); 1403 ci->setSelected( true );
1408 } 1404 }
1409} 1405}
1410void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1406void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1411{ 1407{
1412 mPopupTimer->stop(); 1408 mPopupTimer->stop();
1413 KListView::contentsMouseReleaseEvent(e); 1409 KListView::contentsMouseReleaseEvent(e);
1414} 1410}
1415void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1411void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1416{ 1412{
1417 // qDebug("contentsMouseMoveEv....... "); 1413 // qDebug("contentsMouseMoveEv....... ");
1418 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1414 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1419 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1415 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1420 if ( diff < 0 ) diff = -diff; 1416 if ( diff < 0 ) diff = -diff;
1421 if ( diff > 15 ) 1417 if ( diff > 15 )
1422 mPopupTimer->stop(); 1418 mPopupTimer->stop();
1423 else { 1419 else {
1424 mEventPos = contentsToViewport(e->pos()); 1420 mEventPos = contentsToViewport(e->pos());
1425 mEventGlobalPos = e->globalPos(); 1421 mEventGlobalPos = e->globalPos();
1426 } 1422 }
1427 KListView::contentsMouseMoveEvent(e); 1423 KListView::contentsMouseMoveEvent(e);
1428} 1424}
1429 1425
1430#define protected public 1426#define protected public
1431#include <qheader.h> 1427#include <qheader.h>
1432#undef protected 1428#undef protected
1433void KOListViewListView::printList() 1429void KOListViewListView::printList()
1434{ 1430{
1435#ifdef DESKTOP_VERSION 1431#ifdef DESKTOP_VERSION
1436 KOPrintPrefs pp ( this ); 1432 KOPrintPrefs pp ( this );
1437 if (!pp.exec() ) 1433 if (!pp.exec() )
1438 return; 1434 return;
1439 int scaleval = pp.printMode() ; 1435 int scaleval = pp.printMode() ;
1440 1436
1441 QPrinter printer; 1437 QPrinter printer;
1442 if (!printer.setup() ) 1438 if (!printer.setup() )
1443 return; 1439 return;
1444 clearSelection (); 1440 clearSelection ();
1445 QPainter p; 1441 QPainter p;
1446 p.begin ( &printer ); 1442 p.begin ( &printer );
1447 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 1443 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
1448 float dx, dy; 1444 float dx, dy;
1449 int wid = (m.width() * 9)/10; 1445 int wid = (m.width() * 9)/10;
1450 dx = (float) wid/(float)contentsWidth (); 1446 dx = (float) wid/(float)contentsWidth ();
1451 dy = (float)(m.height()) / (float)contentsHeight (); 1447 dy = (float)(m.height()) / (float)contentsHeight ();
1452 float scale; 1448 float scale;
1453 // scale to fit the width or height of the paper 1449 // scale to fit the width or height of the paper
1454 if ( dx < dy ) 1450 if ( dx < dy )
1455 scale = dx; 1451 scale = dx;
1456 else 1452 else
1457 scale = dy; 1453 scale = dy;
1458 1454
1459 p.translate( m.width()/10,m.width()/10 ); 1455 p.translate( m.width()/10,m.width()/10 );
1460 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { 1456 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
1461 p.scale( scale, scale ); 1457 p.scale( scale, scale );
1462 } 1458 }
1463 1459
1464 int cou = header()->count(); 1460 int cou = header()->count();
1465 int iii; 1461 int iii;
1466 QRect rect ( 0,0,0, header()->height()); 1462 QRect rect ( 0,0,0, header()->height());
1467 for ( iii = 0; iii < cou; ++iii ) { 1463 for ( iii = 0; iii < cou; ++iii ) {
1468 rect.setLeft ( header()->sectionPos( iii ) ); 1464 rect.setLeft ( header()->sectionPos( iii ) );
1469 rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); 1465 rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii));
1470 header()->paintSection ( & p, header()->mapToIndex (iii), rect ); 1466 header()->paintSection ( & p, header()->mapToIndex (iii), rect );
1471 } 1467 }
1472 p.translate( 0, header()->height()); 1468 p.translate( 0, header()->height());
1473 drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); 1469 drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () );
1474 p.end(); 1470 p.end();
1475#endif 1471#endif
1476} 1472}